Author: rmannibucau
Date: Thu Sep 18 18:28:14 2014
New Revision: 1626041

URL: http://svn.apache.org/r1626041
Log:
TOMEE-1351 handling of ROOT for jaxws

Added:
    
tomee/tomee/branches/tomee-1.7.x/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxws-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxws/RootContextTest.java
Modified:
    
tomee/tomee/branches/tomee-1.7.x/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomcatWebAppBuilder.java
    
tomee/tomee/branches/tomee-1.7.x/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/deployment/TomcatWebappDeployer.java
    
tomee/tomee/branches/tomee-1.7.x/tomee/tomee-embedded/src/main/java/org/apache/tomee/embedded/Container.java
    
tomee/tomee/branches/tomee-1.7.x/tomee/tomee-webservices/src/main/java/org/apache/tomee/webservices/TomcatWsRegistry.java

Added: 
tomee/tomee/branches/tomee-1.7.x/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxws-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxws/RootContextTest.java
URL: 
http://svn.apache.org/viewvc/tomee/tomee/branches/tomee-1.7.x/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxws-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxws/RootContextTest.java?rev=1626041&view=auto
==============================================================================
--- 
tomee/tomee/branches/tomee-1.7.x/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxws-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxws/RootContextTest.java
 (added)
+++ 
tomee/tomee/branches/tomee-1.7.x/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxws-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxws/RootContextTest.java
 Thu Sep 18 18:28:14 2014
@@ -0,0 +1,51 @@
+/*
+ * 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.jaxws;
+
+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.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+import java.net.URL;
+
+import static org.junit.Assert.assertEquals;
+
+@RunWith(Arquillian.class)
+public class RootContextTest {
+    @ArquillianResource
+    private URL url;
+
+    @Deployment(testable = false)
+    public static WebArchive createDeployment() {
+        return ShrinkWrap.create(WebArchive.class, "ROOT.war")
+                    .addClasses(Hello.class, Hello2.class, HelloWS.class, 
HelloWS2.class);
+    }
+
+    @Test
+    public void invoke() throws Exception {
+        final Service service = Service.create(new URL(url.toExternalForm() + 
"/webservices/HelloWS?wsdl"), new 
QName("http://jaxws.tests.arquillian.openejb.apache.org/";, "HelloWSService"));
+        final Hello hello = service.getPort(Hello.class);
+        assertEquals("hi foo!", hello.hi("foo"));
+    }
+}

Modified: 
tomee/tomee/branches/tomee-1.7.x/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomcatWebAppBuilder.java
URL: 
http://svn.apache.org/viewvc/tomee/tomee/branches/tomee-1.7.x/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomcatWebAppBuilder.java?rev=1626041&r1=1626040&r2=1626041&view=diff
==============================================================================
--- 
tomee/tomee/branches/tomee-1.7.x/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomcatWebAppBuilder.java
 (original)
+++ 
tomee/tomee/branches/tomee-1.7.x/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomcatWebAppBuilder.java
 Thu Sep 18 18:28:14 2014
@@ -562,6 +562,8 @@ public class TomcatWebAppBuilder impleme
                 if (standardContext.getPath() == null) {
                     if (webApp.contextRoot != null && 
webApp.contextRoot.startsWith("/")) {
                         standardContext.setPath(webApp.contextRoot);
+                    } else if (isRoot(webApp.contextRoot)) {
+                        standardContext.setPath("");
                     } else {
                         standardContext.setPath("/" + webApp.contextRoot);
                     }
@@ -622,7 +624,7 @@ public class TomcatWebAppBuilder impleme
     }
 
     private static boolean isRoot(final String name) {
-        return "/ROOT".equals(name) || "ROOT".equals(name) || name == null || 
name.isEmpty();
+        return "/ROOT".equals(name) || "ROOT".equals(name) || name == null || 
name.isEmpty() || "ROOT.war".equals(name);
     }
 
     public void deployWar(final StandardContext standardContext, final String 
host, final AppInfo info) {

Modified: 
tomee/tomee/branches/tomee-1.7.x/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/deployment/TomcatWebappDeployer.java
URL: 
http://svn.apache.org/viewvc/tomee/tomee/branches/tomee-1.7.x/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/deployment/TomcatWebappDeployer.java?rev=1626041&r1=1626040&r2=1626041&view=diff
==============================================================================
--- 
tomee/tomee/branches/tomee-1.7.x/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/deployment/TomcatWebappDeployer.java
 (original)
+++ 
tomee/tomee/branches/tomee-1.7.x/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/deployment/TomcatWebappDeployer.java
 Thu Sep 18 18:28:14 2014
@@ -100,6 +100,9 @@ public class TomcatWebappDeployer implem
 
         if (context == null) {
             webAppInfo.contextRoot = file.getName();
+            if ("ROOT".equals(webAppInfo.contextRoot)) {
+                webAppInfo.contextRoot = "";
+            }
         } else {
             webAppInfo.contextRoot = context;
         }

Modified: 
tomee/tomee/branches/tomee-1.7.x/tomee/tomee-embedded/src/main/java/org/apache/tomee/embedded/Container.java
URL: 
http://svn.apache.org/viewvc/tomee/tomee/branches/tomee-1.7.x/tomee/tomee-embedded/src/main/java/org/apache/tomee/embedded/Container.java?rev=1626041&r1=1626040&r2=1626041&view=diff
==============================================================================
--- 
tomee/tomee/branches/tomee-1.7.x/tomee/tomee-embedded/src/main/java/org/apache/tomee/embedded/Container.java
 (original)
+++ 
tomee/tomee/branches/tomee-1.7.x/tomee/tomee-embedded/src/main/java/org/apache/tomee/embedded/Container.java
 Thu Sep 18 18:28:14 2014
@@ -412,6 +412,9 @@ public class Container implements Closea
                     if (sameApplication(file, webApp)) {
                         webApp.moduleId = name;
                         webApp.contextRoot = lastPart(name, 
webApp.contextRoot);
+                        if ("ROOT".equals(webApp.contextRoot)) {
+                            webApp.contextRoot = "";
+                        }
                     }
                 }
             }

Modified: 
tomee/tomee/branches/tomee-1.7.x/tomee/tomee-webservices/src/main/java/org/apache/tomee/webservices/TomcatWsRegistry.java
URL: 
http://svn.apache.org/viewvc/tomee/tomee/branches/tomee-1.7.x/tomee/tomee-webservices/src/main/java/org/apache/tomee/webservices/TomcatWsRegistry.java?rev=1626041&r1=1626040&r2=1626041&view=diff
==============================================================================
--- 
tomee/tomee/branches/tomee-1.7.x/tomee/tomee-webservices/src/main/java/org/apache/tomee/webservices/TomcatWsRegistry.java
 (original)
+++ 
tomee/tomee/branches/tomee-1.7.x/tomee/tomee-webservices/src/main/java/org/apache/tomee/webservices/TomcatWsRegistry.java
 Thu Sep 18 18:28:14 2014
@@ -104,7 +104,10 @@ public class TomcatWsRegistry implements
             throw new IllegalArgumentException("Invalid virtual host '" + 
virtualHost + "'.  Do you have a matchiing Host entry in the server.xml?");
         }
 
-        if (!contextRoot.startsWith("/")) {
+        if ("ROOT".equals(contextRoot)) { // doesn't happen in tomee itself 
but with all our tooling around
+            contextRoot = "";
+        }
+        if (!contextRoot.startsWith("/") && !contextRoot.isEmpty()) {
             contextRoot = "/" + contextRoot;
         }
 
@@ -209,15 +212,14 @@ public class TomcatWsRegistry implements
         // - new way (/<webappcontext>/webservices/<name>) if webcontext is 
specified
         if (context != null) {
             String root = context;
-            if (!root.startsWith("/")) {
-                root = '/' + root;
+            if ("ROOT".equals(root)) {
+                root = "";
             }
-
-            Context webAppContext = Context.class.cast(host.findChild(root));
-            if (webAppContext == null && "/".equals(root)) {
-                webAppContext = 
Context.class.cast(host.findChild(root.substring(1)));
+            if (!root.startsWith("/") && !root.isEmpty()) {
+                root = '/' + root;
             }
 
+            final Context webAppContext = 
Context.class.cast(host.findChild(root));
             if (webAppContext != null) {
                 // sub context = '/' means the service address is provided by 
webservices
                 if (WEBSERVICE_SUB_CONTEXT.equals("/") && 
path.startsWith("/")) {
@@ -350,10 +352,12 @@ public class TomcatWsRegistry implements
             final StringBuilder fullContextpath;
             if (!WEBSERVICE_OLDCONTEXT_ACTIVE && !fakeDeployment) {
                 String contextPath = context.getName();
-                if (contextPath != null && !contextPath.startsWith("/")) {
-                    contextPath = "/" + contextPath;
-                } else if (contextPath == null) {
-                    contextPath = "/";
+                if (contextPath == null ||  !contextPath.isEmpty()) {
+                    if (contextPath != null && !contextPath.startsWith("/")) {
+                        contextPath = "/" + contextPath;
+                    } else if (contextPath == null) {
+                        contextPath = "/";
+                    }
                 }
 
                 fullContextpath = new StringBuilder(contextPath);


Reply via email to