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 test for endpoint override
Date Wed, 19 Jul 2017 17:18:08 GMT
Add test for endpoint override


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

Branch: refs/heads/master
Commit: 3a2d7582045e5e78d879eb323b942ec669373d31
Parents: 398ad83
Author: Carlos Sierra <csierra@apache.org>
Authored: Wed Jul 19 19:13:04 2017 +0200
Committer: Carlos Sierra <csierra@apache.org>
Committed: Wed Jul 19 19:13:04 2017 +0200

----------------------------------------------------------------------
 jax-rs.itests/src/main/java/test/JaxrsTest.java | 52 +++++++++++++++++++-
 .../main/java/test/types/TestAddonConflict.java | 37 ++++++++++++++
 .../java/test/types/TestAddonConflict2.java     | 36 ++++++++++++++
 3 files changed, 124 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/3a2d7582/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 1c6e8e7..1f50052 100644
--- a/jax-rs.itests/src/main/java/test/JaxrsTest.java
+++ b/jax-rs.itests/src/main/java/test/JaxrsTest.java
@@ -36,6 +36,8 @@ import org.osgi.framework.ServiceRegistration;
 import org.osgi.service.jaxrs.runtime.dto.FailedApplicationDTO;
 import org.osgi.util.tracker.ServiceTracker;
 import test.types.TestAddon;
+import test.types.TestAddonConflict;
+import test.types.TestAddonConflict2;
 import test.types.TestAddonLifecycle;
 import test.types.TestApplication;
 import test.types.TestApplicationConflict;
@@ -51,7 +53,6 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotEquals;
 import static org.junit.Assert.assertNull;
 
-
 public class JaxrsTest {
 
     private ServiceTracker<ClientBuilder, ClientBuilder> _clientBuilderTracker;
@@ -430,6 +431,55 @@ public class JaxrsTest {
     }
 
     @Test
+    public void testEndpointsOverride() {
+        Client client = createClient();
+
+        WebTarget webTarget = client.
+            target("http://localhost:8080").
+            path("conflict");
+
+        ServiceRegistration<?> serviceRegistration = null;
+        ServiceRegistration<?> serviceRegistration2 = null;
+
+        try {
+            serviceRegistration = registerAddon(new TestAddonConflict());
+
+            Response response = webTarget.request().get();
+
+            assertEquals(
+                "This should say hello1", "hello1",
+                response.readEntity(String.class));
+
+            serviceRegistration2 = registerAddon(
+                new TestAddonConflict2(), "service.ranking", 1);
+
+            response = webTarget.request().get();
+
+            assertEquals(
+                "This should say hello2", "hello2",
+                response.readEntity(String.class));
+
+            serviceRegistration2.unregister();
+
+            serviceRegistration2 = null;
+
+            response = webTarget.request().get();
+
+            assertEquals(
+                "This should say hello1", "hello1",
+                response.readEntity(String.class));
+        }
+        finally {
+            if (serviceRegistration != null) {
+                serviceRegistration.unregister();
+            }
+            if (serviceRegistration2 != null) {
+                serviceRegistration2.unregister();
+            }
+        }
+    }
+
+    @Test
     public void testStandaloneEndPoint() {
         Client client = createClient();
 

http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/3a2d7582/jax-rs.itests/src/main/java/test/types/TestAddonConflict.java
----------------------------------------------------------------------
diff --git a/jax-rs.itests/src/main/java/test/types/TestAddonConflict.java b/jax-rs.itests/src/main/java/test/types/TestAddonConflict.java
new file mode 100644
index 0000000..02f96a7
--- /dev/null
+++ b/jax-rs.itests/src/main/java/test/types/TestAddonConflict.java
@@ -0,0 +1,37 @@
+/**
+ * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
+ * <p>
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * <p>
+ * This library is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ */
+
+package test.types;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+
+/**
+ * @author Carlos Sierra Andrés
+ */
+@Path("/conflict")
+public class TestAddonConflict {
+
+    @GET
+    public String sayHello() {
+        return "hello1";
+    }
+
+    @GET
+    @Path("/conflict1")
+    public String conflict() {
+        return "conflict1";
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/3a2d7582/jax-rs.itests/src/main/java/test/types/TestAddonConflict2.java
----------------------------------------------------------------------
diff --git a/jax-rs.itests/src/main/java/test/types/TestAddonConflict2.java b/jax-rs.itests/src/main/java/test/types/TestAddonConflict2.java
new file mode 100644
index 0000000..c402753
--- /dev/null
+++ b/jax-rs.itests/src/main/java/test/types/TestAddonConflict2.java
@@ -0,0 +1,36 @@
+/**
+ * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
+ * <p>
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * <p>
+ * This library is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ */
+
+package test.types;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+
+/**
+ * @author Carlos Sierra Andrés
+ */
+@Path("/conflict")
+public class TestAddonConflict2 {
+
+    @GET
+    public String sayHello() {
+        return "hello2";
+    }
+
+    @GET
+    @Path("/conflict2")
+    public String conflict() {
+        return "conflict2";
+    }
+}


Mime
View raw message