You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by rm...@apache.org on 2016/03/15 08:37:04 UTC

tomee git commit: TOMEE-1731 web.xml jaxrs application overrides annotation (we were concatenating both)

Repository: tomee
Updated Branches:
  refs/heads/master 64e5b4485 -> a329a6e83


TOMEE-1731 web.xml jaxrs application overrides annotation (we were concatenating both)


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/a329a6e8
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/a329a6e8
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/a329a6e8

Branch: refs/heads/master
Commit: a329a6e835f8171ad2aed15e2140d7615196054b
Parents: 64e5b44
Author: Romain manni-Bucau <rm...@gmail.com>
Authored: Tue Mar 15 08:36:43 2016 +0100
Committer: Romain manni-Bucau <rm...@gmail.com>
Committed: Tue Mar 15 08:36:43 2016 +0100

----------------------------------------------------------------------
 .../tests/jaxrs/webxmloverride/RSApp.java       | 24 ++++++++
 .../tests/jaxrs/webxmloverride/TheResource.java | 29 +++++++++
 .../WebXmlOverrideControlSampleTest.java        | 53 ++++++++++++++++
 .../webxmloverride/WebXmlOverrideTest.java      | 65 ++++++++++++++++++++
 pom.xml                                         | 10 ---
 .../SimpleApplicationWithLongMappingTest.java   |  2 +-
 .../rs/SimpleApplicationWithMappingTest.java    |  2 +-
 .../apache/openejb/server/rest/RESTService.java | 12 ++--
 8 files changed, 178 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/a329a6e8/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxrs-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxrs/webxmloverride/RSApp.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxrs-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxrs/webxmloverride/RSApp.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxrs-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxrs/webxmloverride/RSApp.java
new file mode 100644
index 0000000..4775d0a
--- /dev/null
+++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxrs-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxrs/webxmloverride/RSApp.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.openejb.arquillian.tests.jaxrs.webxmloverride;
+
+import javax.ws.rs.ApplicationPath;
+import javax.ws.rs.core.Application;
+
+@ApplicationPath("annotation")
+public class RSApp extends Application {
+}

http://git-wip-us.apache.org/repos/asf/tomee/blob/a329a6e8/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxrs-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxrs/webxmloverride/TheResource.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxrs-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxrs/webxmloverride/TheResource.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxrs-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxrs/webxmloverride/TheResource.java
new file mode 100644
index 0000000..c15814a
--- /dev/null
+++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxrs-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxrs/webxmloverride/TheResource.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.openejb.arquillian.tests.jaxrs.webxmloverride;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+
+@Path("/")
+public class TheResource {
+    @GET
+    @Path("touch")
+    public String get() {
+        return "resource";
+    }
+}

http://git-wip-us.apache.org/repos/asf/tomee/blob/a329a6e8/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxrs-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxrs/webxmloverride/WebXmlOverrideControlSampleTest.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxrs-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxrs/webxmloverride/WebXmlOverrideControlSampleTest.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxrs-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxrs/webxmloverride/WebXmlOverrideControlSampleTest.java
new file mode 100644
index 0000000..8367f6f
--- /dev/null
+++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxrs-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxrs/webxmloverride/WebXmlOverrideControlSampleTest.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.openejb.arquillian.tests.jaxrs.webxmloverride;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.arquillian.test.api.ArquillianResource;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.StringAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.jboss.shrinkwrap.descriptor.api.Descriptors;
+import org.jboss.shrinkwrap.descriptor.api.webapp30.WebAppDescriptor;
+import org.jboss.shrinkwrap.descriptor.api.webcommon30.WebAppVersionType;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.core.Application;
+import java.net.URL;
+
+import static org.junit.Assert.assertEquals;
+
+@RunWith(Arquillian.class)
+public class WebXmlOverrideControlSampleTest {
+    @Deployment(testable = false)
+    public static Archive<?> war() {
+        return ShrinkWrap.create(WebArchive.class, "WebXmlOverrideTest.war")
+            .addClasses(TheResource.class, RSApp.class);
+    }
+
+    @ArquillianResource
+    private URL base;
+
+    @Test
+    public void control() {
+        assertEquals("resource", ClientBuilder.newClient().target(base.toExternalForm() + "annotation/touch").request().get(String.class));
+    }
+}

http://git-wip-us.apache.org/repos/asf/tomee/blob/a329a6e8/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxrs-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxrs/webxmloverride/WebXmlOverrideTest.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxrs-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxrs/webxmloverride/WebXmlOverrideTest.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxrs-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxrs/webxmloverride/WebXmlOverrideTest.java
new file mode 100644
index 0000000..0742dbf
--- /dev/null
+++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxrs-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxrs/webxmloverride/WebXmlOverrideTest.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.openejb.arquillian.tests.jaxrs.webxmloverride;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.arquillian.test.api.ArquillianResource;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.StringAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.jboss.shrinkwrap.descriptor.api.Descriptors;
+import org.jboss.shrinkwrap.descriptor.api.webapp30.WebAppDescriptor;
+import org.jboss.shrinkwrap.descriptor.api.webcommon30.WebAppVersionType;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.core.Application;
+import java.net.URL;
+
+import static org.junit.Assert.assertEquals;
+
+@RunWith(Arquillian.class)
+public class WebXmlOverrideTest {
+    @Deployment(testable = false)
+    public static Archive<?> war() {
+        return ShrinkWrap.create(WebArchive.class, "WebXmlOverrideTest.war")
+            .addClasses(TheResource.class, RSApp.class)
+            .setWebXML(new StringAsset(
+                Descriptors.create(WebAppDescriptor.class)
+                    .version(WebAppVersionType._3_0)
+                    .createServlet()
+                    .servletName(RSApp.class.getName())
+                    .createInitParam().paramName(Application.class.getName()).paramValue(RSApp.class.getName()).up()
+                    .up()
+                    .createServletMapping()
+                    .servletName(RSApp.class.getName())
+                    .urlPattern("/xml/*")
+                    .up()
+                    .exportAsString()));
+    }
+
+    @ArquillianResource
+    private URL base;
+
+    @Test
+    public void overriden() {
+        assertEquals("resource", ClientBuilder.newClient().target(base.toExternalForm() + "xml/touch").request().get(String.class));
+    }
+}

http://git-wip-us.apache.org/repos/asf/tomee/blob/a329a6e8/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index bdc933a..fac28a7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -242,16 +242,6 @@
         </plugin>
         <plugin>
           <groupId>org.apache.maven.plugins</groupId>
-          <artifactId>maven-compiler-plugin</artifactId>
-          <version>3.3</version>
-        </plugin>
-        <plugin>
-          <groupId>org.apache.maven.plugins</groupId>
-          <artifactId>maven-surefire-plugin</artifactId>
-          <version>2.18.1</version>
-        </plugin>
-        <plugin>
-          <groupId>org.apache.maven.plugins</groupId>
           <artifactId>maven-failsafe-plugin</artifactId>
           <version>2.18.1</version>
         </plugin>

http://git-wip-us.apache.org/repos/asf/tomee/blob/a329a6e8/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/SimpleApplicationWithLongMappingTest.java
----------------------------------------------------------------------
diff --git a/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/SimpleApplicationWithLongMappingTest.java b/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/SimpleApplicationWithLongMappingTest.java
index 0883c2e..f73f784 100644
--- a/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/SimpleApplicationWithLongMappingTest.java
+++ b/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/SimpleApplicationWithLongMappingTest.java
@@ -54,7 +54,7 @@ public class SimpleApplicationWithLongMappingTest {
     @BeforeClass
     public static void beforeClass() {
         port = NetworkUtil.getNextAvailablePort();
-        BASE_URL = "http://localhost:" + port + "/foo/mapping/part2/my-app/";
+        BASE_URL = "http://localhost:" + port + "/foo/mapping/part2";
     }
 
     @Configuration

http://git-wip-us.apache.org/repos/asf/tomee/blob/a329a6e8/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/SimpleApplicationWithMappingTest.java
----------------------------------------------------------------------
diff --git a/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/SimpleApplicationWithMappingTest.java b/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/SimpleApplicationWithMappingTest.java
index 0817644..9b519e3 100644
--- a/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/SimpleApplicationWithMappingTest.java
+++ b/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/SimpleApplicationWithMappingTest.java
@@ -54,7 +54,7 @@ public class SimpleApplicationWithMappingTest {
     @BeforeClass
     public static void beforeClass() {
         port = NetworkUtil.getNextAvailablePort();
-        BASE_URL = "http://localhost:" + port + "/foo/mapping/my-app/";
+        BASE_URL = "http://localhost:" + port + "/foo/mapping";
     }
 
     @Configuration

http://git-wip-us.apache.org/repos/asf/tomee/blob/a329a6e8/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RESTService.java
----------------------------------------------------------------------
diff --git a/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RESTService.java b/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RESTService.java
index 6049263..bcacd75 100644
--- a/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RESTService.java
+++ b/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RESTService.java
@@ -494,7 +494,7 @@ public abstract class RESTService implements ServerService, SelfManaging {
             String mapping = null;
 
             final String name = appClazz.getName();
-            if (name.equals(s.servletClass) || name.equals(s.servletName)) {
+            if (name.equals(s.servletClass) || name.equals(s.servletName) || "javax.ws.rs.core.Application ".equals(s.servletName)) {
                 mapping = s.mappings.iterator().next();
             } else {
                 for (final ParamValueInfo pvi : s.initParams) {
@@ -518,6 +518,9 @@ public abstract class RESTService implements ServerService, SelfManaging {
                 break;
             }
         }
+        if (builder != null) { // https://issues.apache.org/jira/browse/CXF-5702
+            return builder.toString();
+        }
 
         // annotation
         final ApplicationPath path = appClazz.getAnnotation(ApplicationPath.class);
@@ -527,12 +530,7 @@ public abstract class RESTService implements ServerService, SelfManaging {
                 appPath = appPath.substring(0, appPath.length() - 1);
             }
 
-            if (builder == null) {
-                builder = new StringBuilder();
-            } else if (builder.length() > 0 && builder.charAt(builder.length() - 1) != '/') {
-                builder.append('/');
-            }
-
+            builder = new StringBuilder();
             if (appPath.startsWith("/")) {
                 builder.append(appPath.substring(1));
             } else {