You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by cs...@apache.org on 2016/11/30 19:04:57 UTC

[1/2] aries-jax-rs-whiteboard git commit: Extract application registration

Repository: aries-jax-rs-whiteboard
Updated Branches:
  refs/heads/master e0b4a8665 -> 3dae7ed72


Extract application 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/840cce2e
Tree: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/tree/840cce2e
Diff: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/diff/840cce2e

Branch: refs/heads/master
Commit: 840cce2ea2e3337b122965d23dca4a04d4a7387d
Parents: e0b4a86
Author: Carlos Sierra <cs...@apache.org>
Authored: Wed Nov 30 20:01:58 2016 +0100
Committer: Carlos Sierra <cs...@apache.org>
Committed: Wed Nov 30 20:04:20 2016 +0100

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


http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/840cce2e/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 d52d523..b81d5da 100644
--- a/jax-rs.itests/src/main/java/test/JaxrsTest.java
+++ b/jax-rs.itests/src/main/java/test/JaxrsTest.java
@@ -48,15 +48,7 @@ public class JaxrsTest {
         ServiceRegistration<?> serviceRegistration = null;
 
         try {
-            TestApplication testApplication = new TestApplication();
-
-            Dictionary<String, Object> properties = new Hashtable<>();
-
-            properties.put(
-                "osgi.jaxrs.application.base", "/test-application");
-
-            serviceRegistration = bundleContext.registerService(
-                Application.class, testApplication, properties);
+            serviceRegistration = registerApplication();
 
             Client client = createClient();
 
@@ -83,19 +75,12 @@ public class JaxrsTest {
         ServiceRegistration<?> serviceRegistration = null;
 
         try {
-            TestApplication testApplication = new TestApplication();
+            applicationRegistration = registerApplication();
 
-            Dictionary<String, Object> properties = new Hashtable<>();
-
-            properties.put(
-                "osgi.jaxrs.application.base", "/test-application");
-
-            applicationRegistration = bundleContext.registerService(
-                Application.class, testApplication, properties);
 
             TestAddon testAddon = new TestAddon();
 
-            properties = new Hashtable<>();
+            Dictionary<String, Object> properties = new Hashtable<>();
 
             properties.put(
                 "jaxrs.application.select",
@@ -133,19 +118,11 @@ public class JaxrsTest {
         ServiceRegistration<?> filterRegistration = null;
 
         try {
-            TestApplication testApplication = new TestApplication();
-
-            Dictionary<String, Object> properties = new Hashtable<>();
-
-            properties.put(
-                "osgi.jaxrs.application.base", "/test-application");
-
-            applicationRegistration = bundleContext.registerService(
-                Application.class, testApplication, properties);
+            applicationRegistration = registerApplication();
 
             TestFilter testFilter = new TestFilter();
 
-            properties = new Hashtable<>();
+            Dictionary<String, Object> properties = new Hashtable<>();
 
             properties.put(
                 "jaxrs.application.select",
@@ -277,4 +254,17 @@ public class JaxrsTest {
         }
     }
 
+
+    private ServiceRegistration<?> registerApplication() {
+        TestApplication testApplication = new TestApplication();
+
+        Dictionary<String, Object> properties = new Hashtable<>();
+
+        properties.put(
+            "osgi.jaxrs.application.base", "/test-application");
+
+        return bundleContext.registerService(
+            Application.class, testApplication, properties);
+    }
+
 }


[2/2] aries-jax-rs-whiteboard git commit: Add case for application unregistration and registration

Posted by cs...@apache.org.
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 <cs...@apache.org>
Authored: Wed Nov 30 20:04:33 2016 +0100
Committer: Carlos Sierra <cs...@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();