Repository: incubator-juneau
Updated Branches:
  refs/heads/master d45e1351d -> 015a86df2


Add integration tests to test execution.

Project: http://git-wip-us.apache.org/repos/asf/incubator-juneau/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-juneau/commit/015a86df
Tree: http://git-wip-us.apache.org/repos/asf/incubator-juneau/tree/015a86df
Diff: http://git-wip-us.apache.org/repos/asf/incubator-juneau/diff/015a86df

Branch: refs/heads/master
Commit: 015a86df2fe644ccf68447f14040a679bbe72f11
Parents: d45e135
Author: jamesbognar <jamesbog...@gmail.com>
Authored: Fri Sep 16 13:48:47 2016 -0400
Committer: jamesbognar <jamesbog...@gmail.com>
Committed: Fri Sep 16 13:48:47 2016 -0400

----------------------------------------------------------------------
 .../juneau/microservice/Microservice.java       | 21 +++++-
 .../juneau/microservice/RestMicroservice.java   | 17 +++--
 juneau-samples/pom.xml                          | 15 +++-
 .../juneau/server/samples/_TestSuite.java       | 43 ++++++++++++
 juneau-server-test/pom.xml                      | 13 +++-
 .../apache/juneau/server/test/_TestSuite.java   | 74 ++++++++++++++++++++
 6 files changed, 173 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/015a86df/juneau-microservice/src/main/java/org/apache/juneau/microservice/Microservice.java
----------------------------------------------------------------------
diff --git 
a/juneau-microservice/src/main/java/org/apache/juneau/microservice/Microservice.java
 
b/juneau-microservice/src/main/java/org/apache/juneau/microservice/Microservice.java
index 6db77f7..ec77824 100755
--- 
a/juneau-microservice/src/main/java/org/apache/juneau/microservice/Microservice.java
+++ 
b/juneau-microservice/src/main/java/org/apache/juneau/microservice/Microservice.java
@@ -430,10 +430,24 @@ public abstract class Microservice {
         * <p>
         * Overridden methods MUST call this method FIRST so that the {@link 
#onStart()} method is called.
         *
+        * @return This object (for method chaining).
         * @throws Exception
         */
-       protected void start() throws Exception {
+       protected Microservice start() throws Exception {
                onStart();
+               return this;
+       }
+
+       /**
+        * Joins the application with the current thread.
+        * <p>
+        * Default implementation is a no-op.
+        *
+        * @return This object (for method chaining).
+        * @throws Exception
+        */
+       protected Microservice join() throws Exception {
+               return this;
        }
 
        /**
@@ -442,9 +456,12 @@ public abstract class Microservice {
         * Default implementation simply calls {@link #onStop()}.
         * <p>
         * Overridden methods MUST call this method LAST so that the {@link 
#onStop()} method is called.
+        * 
+        * @return This object (for method chaining).
         */
-       protected void stop() {
+       protected Microservice stop() {
                onStop();
+               return this;
        }
 
        /**

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/015a86df/juneau-microservice/src/main/java/org/apache/juneau/microservice/RestMicroservice.java
----------------------------------------------------------------------
diff --git 
a/juneau-microservice/src/main/java/org/apache/juneau/microservice/RestMicroservice.java
 
b/juneau-microservice/src/main/java/org/apache/juneau/microservice/RestMicroservice.java
index 8e91bf3..8ff30b9 100755
--- 
a/juneau-microservice/src/main/java/org/apache/juneau/microservice/RestMicroservice.java
+++ 
b/juneau-microservice/src/main/java/org/apache/juneau/microservice/RestMicroservice.java
@@ -81,7 +81,7 @@ public class RestMicroservice extends Microservice {
         * @throws Exception
         */
        public static void main(String[] args) throws Exception {
-               new RestMicroservice(args).start();
+               new RestMicroservice(args).start().join();
        }
 
        /**
@@ -99,15 +99,22 @@ public class RestMicroservice extends Microservice {
        
//--------------------------------------------------------------------------------
 
        @Override /* Microservice */
-       protected void start() throws Exception {
+       public RestMicroservice start() throws Exception {
                super.start();
                initLogging();
                createServer();
                startServer();
+               return this;
        }
 
        @Override /* Microservice */
-       public void stop() {
+       public RestMicroservice join() throws Exception {
+               server.join();
+               return this;
+       }
+
+       @Override /* Microservice */
+       public RestMicroservice stop() {
                Thread t = new Thread() {
                        @Override /* Thread */
                        public void run() {
@@ -130,6 +137,7 @@ public class RestMicroservice extends Microservice {
                        e.printStackTrace();
                }
                super.stop();
+               return this;
        }
 
        
//--------------------------------------------------------------------------------
@@ -351,7 +359,7 @@ public class RestMicroservice extends Microservice {
         * Method used to start the Jetty server created by {@link 
#createServer()}.
         * <p>
         * Subclasses can override this method to customize server startup.
-        *
+        * 
         * @throws Exception
         */
        protected void startServer() throws Exception {
@@ -359,7 +367,6 @@ public class RestMicroservice extends Microservice {
                server.start();
                logger.warning("Server started on port " + port);
                onPostStartServer();
-               server.join();
        }
 
        /**

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/015a86df/juneau-samples/pom.xml
----------------------------------------------------------------------
diff --git a/juneau-samples/pom.xml b/juneau-samples/pom.xml
index 2285b19..8a0c34f 100644
--- a/juneau-samples/pom.xml
+++ b/juneau-samples/pom.xml
@@ -28,7 +28,6 @@
        <description>Sample code packaged as a microservice.</description>
        <properties>
                <encoding>UTF-8</encoding>
-               <maven.test.skip>true</maven.test.skip>
        </properties>
        <dependencies>
                <dependency>
@@ -49,7 +48,7 @@
                <dependency>
                        <groupId>junit</groupId>
                        <artifactId>junit</artifactId>
-                       <version>4.10</version>
+                       <version>4.11</version>
                        <scope>test</scope>
                </dependency>
        </dependencies>
@@ -65,6 +64,18 @@
                        </plugin>
                        <plugin>
                                <groupId>org.apache.maven.plugins</groupId>
+                               <artifactId>maven-surefire-plugin</artifactId>
+                               <version>2.19.1</version>
+                               <configuration>
+                                       <includes>
+                                               <include>
+                                                       **/_TestSuite.java
+                                               </include>
+                                       </includes>
+                               </configuration>
+                       </plugin>
+                       <plugin>
+                               <groupId>org.apache.maven.plugins</groupId>
                                <artifactId>maven-shade-plugin</artifactId>
                                <version>2.4.3</version>
                                <configuration>

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/015a86df/juneau-samples/src/test/java/org/apache/juneau/server/samples/_TestSuite.java
----------------------------------------------------------------------
diff --git 
a/juneau-samples/src/test/java/org/apache/juneau/server/samples/_TestSuite.java 
b/juneau-samples/src/test/java/org/apache/juneau/server/samples/_TestSuite.java
new file mode 100644
index 0000000..9861b94
--- /dev/null
+++ 
b/juneau-samples/src/test/java/org/apache/juneau/server/samples/_TestSuite.java
@@ -0,0 +1,43 @@
+package org.apache.juneau.server.samples;
+
+import org.apache.juneau.microservice.*;
+import org.junit.*;
+import org.junit.runner.*;
+import org.junit.runners.*;
+import org.junit.runners.Suite.*;
+
+/**
+ * Runs all the testcases in this project.
+ * Starts a REST service running 
org.apache.juneau.server.samples.RootResources on port 10000.
+ * Stops the REST service after running the tests.
+ */
+@RunWith(Suite.class)
+@SuiteClasses({
+       AddressBookResourceTest.class,
+       RootResourcesTest.class,
+       SampleRemoteableServicesResourceTest.class,
+       TestMultiPartFormPostsTest.class
+})
+public class _TestSuite {
+       static RestMicroservice microservice;
+
+   @BeforeClass
+   public static void setUp() {
+       try {
+                       microservice = new RestMicroservice(new String[0]);
+                       microservice.start();
+               } catch (Exception e) {
+                       e.printStackTrace();
+                       throw new RuntimeException(e);
+               }
+   }
+   
+   @AfterClass
+   public static void tearDown() {
+       try {
+                       microservice.stop();
+               } catch (Exception e) {
+                       throw new RuntimeException(e);
+               }
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/015a86df/juneau-server-test/pom.xml
----------------------------------------------------------------------
diff --git a/juneau-server-test/pom.xml b/juneau-server-test/pom.xml
index 4f23cc8..56d09dd 100644
--- a/juneau-server-test/pom.xml
+++ b/juneau-server-test/pom.xml
@@ -27,7 +27,6 @@
        </parent>
        <properties>
                <encoding>UTF-8</encoding>
-               <maven.test.skip>true</maven.test.skip>
        </properties>
        <dependencies>
                <dependency>
@@ -64,6 +63,18 @@
                                </configuration>
                        </plugin>
                        <plugin>
+                               <groupId>org.apache.maven.plugins</groupId>
+                               <artifactId>maven-surefire-plugin</artifactId>
+                               <version>2.19.1</version>
+                               <configuration>
+                                       <includes>
+                                               <include>
+                                                       **/_TestSuite.java
+                                               </include>
+                                       </includes>
+                               </configuration>
+                       </plugin>
+                       <plugin>
                                <groupId>org.codehaus.mojo</groupId>
                                <artifactId>exec-maven-plugin</artifactId>
                                <version>1.5.0</version>

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/015a86df/juneau-server-test/src/test/java/org/apache/juneau/server/test/_TestSuite.java
----------------------------------------------------------------------
diff --git 
a/juneau-server-test/src/test/java/org/apache/juneau/server/test/_TestSuite.java
 
b/juneau-server-test/src/test/java/org/apache/juneau/server/test/_TestSuite.java
new file mode 100644
index 0000000..a636a76
--- /dev/null
+++ 
b/juneau-server-test/src/test/java/org/apache/juneau/server/test/_TestSuite.java
@@ -0,0 +1,74 @@
+package org.apache.juneau.server.test;
+
+import org.apache.juneau.microservice.*;
+import org.junit.*;
+import org.junit.runner.*;
+import org.junit.runners.*;
+import org.junit.runners.Suite.*;
+
+/**
+ * Runs all the testcases in this project.
+ * Starts a REST service running org.apache.juneau.server.test.Root on port 
10001.
+ * Stops the REST service after running the tests.
+ */
+@RunWith(Suite.class)
+@SuiteClasses({
+       AcceptCharsetTest.class,
+       BeanContextPropertiesTest.class,
+       CallbackStringsTest.class,
+       CharsetEncodingsTest.class,
+       ClientVersionTest.class,
+       ConfigTest.class,
+       ContentTest.class,
+       DefaultContentTypesTest.class,
+       ErrorConditionsTest.class,
+       GroupsTest.class,
+       GzipTest.class,
+       InheritanceTest.class,
+       JacocoDummyTest.class,
+       LargePojosTest.class,
+       MessagesTest.class,
+       NlsPropertyTest.class,
+       NlsTest.class,
+       NoParserInputTest.class,
+       OnPostCallTest.class,
+       OnPreCallTest.class,
+       OptionsWithoutNlsTest.class,
+       OverlappingMethodsTest.class,
+       ParamsTest.class,
+       ParsersTest.class,
+       PathsTest.class,
+       PathTest.class,
+       PropertiesTest.class,
+       RestClientTest.class,
+       RestUtilsTest.class,
+       SerializersTest.class,
+       StaticFilesTest.class,
+       TransformsTest.class,
+       UrisTest.class,
+       UrlContentTest.class,
+       UrlPathPatternTest.class
+})
+public class _TestSuite {
+       static RestMicroservice microservice;
+
+   @BeforeClass
+   public static void setUp() {
+       try {
+                       microservice = new RestMicroservice(new String[0]);
+                       microservice.start();
+               } catch (Exception e) {
+                       e.printStackTrace();
+                       throw new RuntimeException(e);
+               }
+   }
+
+   @AfterClass
+   public static void tearDown() {
+       try {
+                       microservice.stop();
+               } catch (Exception e) {
+                       throw new RuntimeException(e);
+               }
+   }
+}

Reply via email to