Author: rmannibucau
Date: Tue Sep 30 10:09:59 2014
New Revision: 1628385

URL: http://svn.apache.org/r1628385
Log:
TOMEE-1361 ensuring we can reload a jaxrs app - more validations

Modified:
    
tomee/tomee/trunk/maven/tomee-maven-plugin/src/test/java/org/apache/openejb/maven/plugin/app/Endpoint.java
    
tomee/tomee/trunk/maven/tomee-maven-plugin/src/test/java/org/apache/openejb/maven/plugin/test/JAXRSReloadTest.java

Modified: 
tomee/tomee/trunk/maven/tomee-maven-plugin/src/test/java/org/apache/openejb/maven/plugin/app/Endpoint.java
URL: 
http://svn.apache.org/viewvc/tomee/tomee/trunk/maven/tomee-maven-plugin/src/test/java/org/apache/openejb/maven/plugin/app/Endpoint.java?rev=1628385&r1=1628384&r2=1628385&view=diff
==============================================================================
--- 
tomee/tomee/trunk/maven/tomee-maven-plugin/src/test/java/org/apache/openejb/maven/plugin/app/Endpoint.java
 (original)
+++ 
tomee/tomee/trunk/maven/tomee-maven-plugin/src/test/java/org/apache/openejb/maven/plugin/app/Endpoint.java
 Tue Sep 30 10:09:59 2014
@@ -21,8 +21,16 @@ import javax.ws.rs.Path;
 
 @Path("ping")
 public class Endpoint {
+    private static final long TIME_MILLIS = System.currentTimeMillis();
+
     @GET
     public String ping() {
         return "pong";
     }
+
+    @GET
+    @Path("time")
+    public long time() {
+        return TIME_MILLIS;
+    }
 }

Modified: 
tomee/tomee/trunk/maven/tomee-maven-plugin/src/test/java/org/apache/openejb/maven/plugin/test/JAXRSReloadTest.java
URL: 
http://svn.apache.org/viewvc/tomee/tomee/trunk/maven/tomee-maven-plugin/src/test/java/org/apache/openejb/maven/plugin/test/JAXRSReloadTest.java?rev=1628385&r1=1628384&r2=1628385&view=diff
==============================================================================
--- 
tomee/tomee/trunk/maven/tomee-maven-plugin/src/test/java/org/apache/openejb/maven/plugin/test/JAXRSReloadTest.java
 (original)
+++ 
tomee/tomee/trunk/maven/tomee-maven-plugin/src/test/java/org/apache/openejb/maven/plugin/test/JAXRSReloadTest.java
 Tue Sep 30 10:09:59 2014
@@ -32,8 +32,10 @@ import java.io.File;
 import java.io.IOException;
 import java.net.URL;
 
+import static java.lang.Thread.sleep;
 import static org.hamcrest.CoreMatchers.is;
 import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
 
 public class JAXRSReloadTest {
     private static File JAXRS_APP = new File("target/tests/webapps/app-jaxrs");
@@ -80,8 +82,23 @@ public class JAXRSReloadTest {
 
     @Test
     public void simpleStart() throws Exception {
+        // eager check setup is ok and it works (avoid to mix redeployment 
checks with simple deployment)
         assertThat(IO.slurp(new URL(url + "/app-jaxrs/ping")).trim(), 
is("pong"));
-        mojo.reload();
-        assertThat(IO.slurp(new URL(url + "/app-jaxrs/ping")).trim(), 
is("pong"));
+
+        long lastTime = 0;
+        for (int i = 0; i < 10; i++) {
+            sleep(100); // just to make time more explicit
+            mojo.reload();
+
+            // it still works
+            assertThat(IO.slurp(new URL(url + "/app-jaxrs/ping")).trim(), 
is("pong"));
+
+            // we redeployed since we have a new deployment date
+            final long time = Long.parseLong(IO.slurp(new URL(url + 
"/app-jaxrs/ping/time")).trim());
+            if (i > 0) {
+                assertTrue(time >= lastTime);
+            }
+            lastTime = time;
+        }
     }
 }


Reply via email to