aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From csie...@apache.org
Subject [2/2] aries-jax-rs-whiteboard git commit: Add case for application unregistration and registration
Date Wed, 30 Nov 2016 19:04:58 GMT
Add case for application unregistration and registration


Project: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/repo
Commit: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/commit/3dae7ed7
Tree: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/tree/3dae7ed7
Diff: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/diff/3dae7ed7

Branch: refs/heads/master
Commit: 3dae7ed724ea00803cfac22f429de613460016d9
Parents: 840cce2
Author: Carlos Sierra <csierra@apache.org>
Authored: Wed Nov 30 20:04:33 2016 +0100
Committer: Carlos Sierra <csierra@apache.org>
Committed: Wed Nov 30 20:04:33 2016 +0100

----------------------------------------------------------------------
 jax-rs.itests/src/main/java/test/JaxrsTest.java | 48 +++++++++++++++++++-
 1 file changed, 46 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/3dae7ed7/jax-rs.itests/src/main/java/test/JaxrsTest.java
----------------------------------------------------------------------
diff --git a/jax-rs.itests/src/main/java/test/JaxrsTest.java b/jax-rs.itests/src/main/java/test/JaxrsTest.java
index b81d5da..1c8e41a 100644
--- a/jax-rs.itests/src/main/java/test/JaxrsTest.java
+++ b/jax-rs.itests/src/main/java/test/JaxrsTest.java
@@ -36,6 +36,7 @@ import javax.ws.rs.core.Application;
 import javax.ws.rs.core.Response;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 
 
 public class JaxrsTest {
@@ -69,6 +70,51 @@ public class JaxrsTest {
     }
 
     @Test
+    public void testApplicationReadd() {
+        ServiceRegistration<?> serviceRegistration = null;
+
+        Client client = createClient();
+
+        WebTarget webTarget = client.
+            target("http://localhost:8080").
+            path("/test-application");
+
+        assertTrue(webTarget.request().get().getStatus() == 404);
+
+        try {
+            serviceRegistration = registerApplication();
+
+            assertEquals(
+                "Hello application",
+                webTarget.
+                    request().
+                    get().
+                    readEntity(String.class));
+        }
+        finally {
+            if (serviceRegistration != null) {
+                serviceRegistration.unregister();
+            }
+        }
+
+        assertTrue(webTarget.request().get().getStatus() == 404);
+
+        try {
+            serviceRegistration = registerApplication();
+
+            assertEquals("Hello application",
+                webTarget.
+                    request().
+                    get().readEntity(String.class));
+        }
+        finally {
+            if (serviceRegistration != null) {
+                serviceRegistration.unregister();
+            }
+        }
+    }
+
+    @Test
     public void testApplicationEndpointExtension() {
         ServiceRegistration<?> applicationRegistration = null;
 
@@ -77,7 +123,6 @@ public class JaxrsTest {
         try {
             applicationRegistration = registerApplication();
 
-
             TestAddon testAddon = new TestAddon();
 
             Dictionary<String, Object> properties = new Hashtable<>();
@@ -237,7 +282,6 @@ public class JaxrsTest {
         }
     }
 
-
     private Client createClient() {
         Thread thread = Thread.currentThread();
 


Mime
View raw message