[jbossws-commits] JBossWS SVN: r12830 - in projects: jaxws-httpserver-httpspi and 14 other directories.

jbossws-commits at lists.jboss.org jbossws-commits at lists.jboss.org
Sun Aug 22 07:12:46 EDT 2010


Author: alessio.soldano at jboss.com
Date: 2010-08-22 07:12:45 -0400 (Sun, 22 Aug 2010)
New Revision: 12830

Added:
   projects/jaxws-httpserver-httpspi/
   projects/jaxws-httpserver-httpspi/branches/
   projects/jaxws-httpserver-httpspi/tags/
   projects/jaxws-httpserver-httpspi/trunk/
   projects/jaxws-httpserver-httpspi/trunk/pom.xml
   projects/jaxws-httpserver-httpspi/trunk/src/
   projects/jaxws-httpserver-httpspi/trunk/src/main/
   projects/jaxws-httpserver-httpspi/trunk/src/main/java/
   projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/
   projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/
   projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/
   projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/
   projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/AbstractWrappedOutputStream.java
   projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/HttpContextDelegate.java
   projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/HttpExchangeDelegate.java
   projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/HttpHandlerDelegate.java
   projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/HttpServerContextFactory.java
   projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/PathUtils.java
   projects/jaxws-httpserver-httpspi/trunk/src/main/resources/
   projects/jaxws-httpserver-httpspi/trunk/src/test/
   projects/jaxws-httpserver-httpspi/trunk/src/test/java/
   projects/jaxws-httpserver-httpspi/trunk/src/test/java/org/
   projects/jaxws-httpserver-httpspi/trunk/src/test/java/org/jboss/
   projects/jaxws-httpserver-httpspi/trunk/src/test/java/org/jboss/ws/
   projects/jaxws-httpserver-httpspi/trunk/src/test/java/org/jboss/ws/httpserver_httpspi/
   projects/jaxws-httpserver-httpspi/trunk/src/test/java/org/jboss/ws/httpserver_httpspi/DHRequest.java
   projects/jaxws-httpserver-httpspi/trunk/src/test/java/org/jboss/ws/httpserver_httpspi/DHResponse.java
   projects/jaxws-httpserver-httpspi/trunk/src/test/java/org/jboss/ws/httpserver_httpspi/EndpointAPITest.java
   projects/jaxws-httpserver-httpspi/trunk/src/test/java/org/jboss/ws/httpserver_httpspi/EndpointBean.java
   projects/jaxws-httpserver-httpspi/trunk/src/test/java/org/jboss/ws/httpserver_httpspi/EndpointInterface.java
   projects/jaxws-httpserver-httpspi/trunk/src/test/java/org/jboss/ws/httpserver_httpspi/PathUtilsTest.java
   projects/jaxws-httpserver-httpspi/trunk/src/test/resources/
Log:
Adding external project for JAXWS 2.2 HTTP SPI bridge to JDK6 httpserver



Property changes on: projects/jaxws-httpserver-httpspi/trunk
___________________________________________________________________
Name: svn:ignore
   + .project
.classpath
.settings
target


Added: projects/jaxws-httpserver-httpspi/trunk/pom.xml
===================================================================
--- projects/jaxws-httpserver-httpspi/trunk/pom.xml	                        (rev 0)
+++ projects/jaxws-httpserver-httpspi/trunk/pom.xml	2010-08-22 11:12:45 UTC (rev 12830)
@@ -0,0 +1,111 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <name>JBoss JDK6 httpserver to JAXWS 2.2 HTTP SPI bridge</name>
+  <groupId>org.jboss.ws.projects</groupId>
+  <artifactId>jaxws-httpserver-httpspi</artifactId>
+  <packaging>jar</packaging>
+
+  <version>1.0.0-SNAPSHOT</version>
+
+  <!-- Source Control Management -->
+  <scm>
+    <connection>scm:svn:http://anonsvn.jboss.org/repos/jbossws/projects/jaxws-httpserver-httpspi/trunk</connection>
+    <developerConnection>scm:svn:https://svn.jboss.org/repos/jbossws/projects/jaxws-httpserver-httpspi/trunk</developerConnection>
+    <url>http://fisheye.jboss.com/viewrep/JBossWS/projects/jaxws-httpserver-httpspi/trunk</url>
+  </scm>
+
+  <!-- Parent -->
+  <parent>
+    <groupId>org.jboss.ws</groupId>
+    <artifactId>jbossws-parent</artifactId>
+    <version>1.0.8.GA</version>
+  </parent>
+  
+  <!-- Properties -->
+  <properties>
+    <jaxws.version>1.0.0.Beta1</jaxws.version>
+    <junit.version>4.8.1</junit.version>
+    <cxf.version>2.3.0-SNAPSHOT</cxf.version>
+    <servlet-api.version>1.0.0.Beta2</servlet-api.version>
+  </properties>
+
+  <!-- Dependencies -->
+  <dependencies>
+    <dependency>
+       <groupId>org.jboss.spec.javax.xml.ws</groupId>
+       <artifactId>jboss-jaxws-api_2.2_spec</artifactId>
+       <version>${jaxws.version}</version>
+    </dependency> 
+  
+    <!-- test dependencies -->
+    <dependency>
+      <groupId>org.apache.cxf</groupId>
+      <artifactId>cxf-rt-frontend-jaxws</artifactId>
+      <version>${cxf.version}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>${junit.version}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.spec.javax.servlet</groupId>
+      <artifactId>jboss-servlet-api_3.0_spec</artifactId>
+      <version>${servlet-api.version}</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-dependency-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>create-endorsed-dir</id>
+            <phase>validate</phase>
+            <goals>
+              <goal>copy</goal>
+            </goals>
+            <configuration>
+              <artifactItems>
+                <artifactItem>
+                  <groupId>org.jboss.spec.javax.xml.ws</groupId>
+                  <artifactId>jboss-jaxws-api_2.2_spec</artifactId>
+                  <outputDirectory>${basedir}/target/endorsed</outputDirectory>
+                </artifactItem>
+              </artifactItems>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <configuration>
+          <argLine>-Djava.endorsed.dirs=${basedir}/target/endorsed</argLine>
+        </configuration>
+      </plugin> 
+    </plugins>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-compiler-plugin</artifactId>
+          <configuration>
+            <compilerArguments>
+              <endorseddirs>${basedir}/target/endorsed</endorseddirs>
+            </compilerArguments>
+          </configuration>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+  </build>
+
+</project>

Added: projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/AbstractWrappedOutputStream.java
===================================================================
--- projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/AbstractWrappedOutputStream.java	                        (rev 0)
+++ projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/AbstractWrappedOutputStream.java	2010-08-22 11:12:45 UTC (rev 12830)
@@ -0,0 +1,104 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This 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.
+ *
+ * This software 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.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+/**
+ * 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.jboss.ws.httpserver_httpspi;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * Provides a convenient hook onFirstWrite() for those needing
+ * to wrap an output stream.
+ *
+ */
+public abstract class AbstractWrappedOutputStream extends OutputStream {
+
+   protected OutputStream wrappedStream;
+   protected boolean written;
+   
+   protected AbstractWrappedOutputStream() {
+       super();
+   }
+
+   @Override
+   public void write(byte[] b, int off, int len) throws IOException {
+       if (!written) {
+           onFirstWrite();
+           written = true;
+       }
+       if (wrappedStream != null) {
+           wrappedStream.write(b, off, len);
+       }
+   }
+
+   protected void onFirstWrite() throws IOException {
+   }
+
+   @Override
+   public void write(byte[] b) throws IOException {
+       write(b, 0, b.length);
+   }
+
+   @Override
+   public void write(int b) throws IOException {
+       if (!written) {
+           onFirstWrite();
+           written = true;
+       }
+       if (wrappedStream != null) {
+           wrappedStream.write(b);
+       }
+   }
+   
+   @Override
+   public void close() throws IOException {
+       if (wrappedStream != null) {
+           wrappedStream.close();
+       }
+   }
+
+   @Override
+   public void flush() throws IOException {
+       if (written && wrappedStream != null) {
+           wrappedStream.flush();
+       }
+   }
+}
+

Added: projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/HttpContextDelegate.java
===================================================================
--- projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/HttpContextDelegate.java	                        (rev 0)
+++ projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/HttpContextDelegate.java	2010-08-22 11:12:45 UTC (rev 12830)
@@ -0,0 +1,83 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This 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.
+ *
+ * This software 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.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ws.httpserver_httpspi;
+
+import java.util.Map;
+import java.util.Set;
+
+import javax.xml.ws.spi.http.HttpContext;
+import javax.xml.ws.spi.http.HttpHandler;
+
+/**
+ * A javax.xml.ws.spi.http.HttpContext that delegates
+ * to a com.sun.net.httpserver.HttpContext instance.
+ * 
+ * @author alessio.soldano at jboss.com
+ * @since 22-Aug-2010
+ *
+ */
+ at SuppressWarnings("restriction")
+public class HttpContextDelegate extends HttpContext
+{
+   private com.sun.net.httpserver.HttpContext delegate;
+   private String path;
+
+   public HttpContextDelegate(com.sun.net.httpserver.HttpContext delegate, String path)
+   {
+      this.delegate = delegate;
+      this.path = path;
+   }
+
+   @Override
+   public String getPath()
+   {
+      return path;
+   }
+
+   @Override
+   public Object getAttribute(String name)
+   {
+      Map<String, Object> map = delegate.getAttributes();
+      return map != null ? map.get(name) : null;
+   }
+
+   @Override
+   public Set<String> getAttributeNames()
+   {
+      Map<String, Object> map = delegate.getAttributes();
+      return map != null ? map.keySet() : null;
+   }
+
+   @Override
+   public void setHandler(HttpHandler handler)
+   {
+      if (handler instanceof com.sun.net.httpserver.HttpHandler)
+      {
+         delegate.setHandler((com.sun.net.httpserver.HttpHandler) handler);
+      }
+      else
+      {
+         delegate.setHandler(new HttpHandlerDelegate(handler));
+      }
+   }
+
+}

Added: projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/HttpExchangeDelegate.java
===================================================================
--- projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/HttpExchangeDelegate.java	                        (rev 0)
+++ projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/HttpExchangeDelegate.java	2010-08-22 11:12:45 UTC (rev 12830)
@@ -0,0 +1,226 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This 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.
+ *
+ * This software 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.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ws.httpserver_httpspi;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.HttpURLConnection;
+import java.net.InetSocketAddress;
+import java.security.Principal;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.xml.ws.spi.http.HttpContext;
+import javax.xml.ws.spi.http.HttpExchange;
+
+import com.sun.net.httpserver.HttpServer;
+import com.sun.net.httpserver.HttpsServer;
+
+/**
+ * A javax.xml.ws.spi.http.HttpExchange that delegates
+ * to a com.sun.net.httpserver.HttpExchange instance.
+ * 
+ * @author alessio.soldano at jboss.com
+ * @since 22-Aug-2010
+ *
+ */
+ at SuppressWarnings("restriction")
+public class HttpExchangeDelegate extends HttpExchange
+{
+   private com.sun.net.httpserver.HttpExchange delegate;
+   private HttpContextDelegate contextDelegate;
+   private OutputStream wrappeddOutputStream;
+   private int status;
+
+   public HttpExchangeDelegate(com.sun.net.httpserver.HttpExchange delegate)
+   {
+      this.delegate = delegate;
+   }
+
+   @Override
+   public Map<String, List<String>> getRequestHeaders()
+   {
+      return delegate.getRequestHeaders();
+   }
+
+   @Override
+   public String getRequestHeader(String name)
+   {
+      return delegate.getRequestHeaders().getFirst(name);
+   }
+
+   @Override
+   public Map<String, List<String>> getResponseHeaders()
+   {
+      return delegate.getResponseHeaders();
+   }
+
+   @Override
+   public void addResponseHeader(String name, String value)
+   {
+      delegate.getResponseHeaders().add(name, value);
+   }
+
+   @Override
+   public String getRequestURI()
+   {
+      return delegate.getRequestURI().toString();
+   }
+
+   @Override
+   public String getContextPath()
+   {
+      return PathUtils.getContextPath(delegate.getRequestURI());
+   }
+
+   @Override
+   public String getRequestMethod()
+   {
+      return delegate.getRequestMethod();
+   }
+
+   @Override
+   public HttpContext getHttpContext()
+   {
+      if (contextDelegate == null)
+      {
+         contextDelegate = new HttpContextDelegate(delegate.getHttpContext(), PathUtils.getPath(delegate.getRequestURI()));
+      }
+      return contextDelegate;
+   }
+
+   @Override
+   public void close() throws IOException
+   {
+      delegate.close();
+   }
+   
+   @Override
+   public InputStream getRequestBody() throws IOException
+   {
+      return delegate.getRequestBody();
+   }
+
+   @Override
+   public OutputStream getResponseBody() throws IOException
+   {
+      if (wrappeddOutputStream == null)
+      {
+         wrappeddOutputStream = new AbstractWrappedOutputStream()
+         {
+            /**
+             * On first write we need to send the response headers and
+             * the status as that won't be possible after getting the
+             * response body stream from the delegate
+             */
+            @Override
+            protected void onFirstWrite() throws IOException
+            {
+               if (status == 0) //assume no status -> 200 OK
+               {
+                  status = HttpURLConnection.HTTP_OK;
+               }
+               delegate.sendResponseHeaders(status, 0);
+               this.wrappedStream = delegate.getResponseBody();
+            }
+         };
+      }
+      return wrappeddOutputStream;
+   }
+
+   @Override
+   public void setStatus(int status)
+   {
+      //do not immediately set status to the delegate, as that would flush it to the
+      //client together with the headers, preventing other headers from being added
+      this.status = status;
+   }
+
+   @Override
+   public InetSocketAddress getRemoteAddress()
+   {
+      return delegate.getRemoteAddress();
+   }
+
+   @Override
+   public InetSocketAddress getLocalAddress()
+   {
+      return delegate.getLocalAddress();
+   }
+
+   @Override
+   public String getProtocol()
+   {
+      return delegate.getProtocol();
+   }
+
+   @Override
+   public String getScheme()
+   {
+      String scheme = delegate.getRequestURI().getScheme();
+      if (scheme == null)
+      {
+         //fallback for relative urls (e.g. "/foo/bar?wsdl") with no scheme provided by the container
+         HttpServer server = delegate.getHttpContext().getServer();
+         scheme = server instanceof HttpsServer ? "https" : "http";
+      }
+      return scheme;
+   }
+
+   @Override
+   public String getPathInfo()
+   {
+      return null;
+   }
+
+   @Override
+   public String getQueryString()
+   {
+      return delegate.getRequestURI().getQuery();
+   }
+
+   @Override
+   public Object getAttribute(String name)
+   {
+      return delegate.getAttribute(name);
+   }
+
+   @Override
+   public Set<String> getAttributeNames()
+   {
+      throw new UnsupportedOperationException();
+   }
+
+   @Override
+   public Principal getUserPrincipal()
+   {
+      return delegate.getPrincipal();
+   }
+
+   @Override
+   public boolean isUserInRole(String role)
+   {
+      return false;
+   }
+}

Added: projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/HttpHandlerDelegate.java
===================================================================
--- projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/HttpHandlerDelegate.java	                        (rev 0)
+++ projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/HttpHandlerDelegate.java	2010-08-22 11:12:45 UTC (rev 12830)
@@ -0,0 +1,71 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This 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.
+ *
+ * This software 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.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ws.httpserver_httpspi;
+
+import java.io.IOException;
+
+import com.sun.net.httpserver.HttpExchange;
+import com.sun.net.httpserver.HttpHandler;
+
+/**
+ * A com.sun.net.httpserver.HttpHandler delegating
+ * to a javax.xml.ws.spi.http.HttpHandler instance.
+ * 
+ * @author alessio.soldano at jboss.com
+ * @sine 22-Aug-2010
+ *
+ */
+ at SuppressWarnings("restriction")
+public class HttpHandlerDelegate implements HttpHandler {
+
+   private javax.xml.ws.spi.http.HttpHandler delegate;
+   
+   public HttpHandlerDelegate(javax.xml.ws.spi.http.HttpHandler delegate)
+   {
+      this.delegate = delegate;
+   }
+
+   @Override
+   public void handle(HttpExchange ex) throws IOException
+   {
+      try
+      {
+         delegate.handle(new HttpExchangeDelegate(ex));
+      }
+      catch (IOException e)
+      {
+         e.printStackTrace();
+         throw e;
+      }
+      catch (RuntimeException e)
+      {
+         e.printStackTrace();
+         throw e;
+      }
+      catch (Exception e)
+      {
+         e.printStackTrace();
+         throw new RuntimeException(e);
+      }
+   }
+   
+}
\ No newline at end of file

Added: projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/HttpServerContextFactory.java
===================================================================
--- projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/HttpServerContextFactory.java	                        (rev 0)
+++ projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/HttpServerContextFactory.java	2010-08-22 11:12:45 UTC (rev 12830)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This 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.
+ *
+ * This software 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.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ws.httpserver_httpspi;
+
+import com.sun.net.httpserver.HttpServer;
+import javax.xml.ws.spi.http.HttpContext;
+
+/**
+ * A factory for building JDK6 httpserver' flavor of 
+ * 
+ * @author alessio.soldano at jboss.com
+ * @since 22-Aug-2010
+ *
+ */
+ at SuppressWarnings("restriction")
+public class HttpServerContextFactory
+{
+   public static HttpContext createHttpContext(HttpServer server, String contextPath, String path)
+   {
+      return new HttpContextDelegate(server.createContext(contextPath), path);
+   }
+}

Added: projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/PathUtils.java
===================================================================
--- projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/PathUtils.java	                        (rev 0)
+++ projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/PathUtils.java	2010-08-22 11:12:45 UTC (rev 12830)
@@ -0,0 +1,108 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This 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.
+ *
+ * This software 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.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ws.httpserver_httpspi;
+
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URL;
+
+public class PathUtils
+{
+   /**
+    * Get the final path section of an address (for servlet
+    * container, this is typically a url-pattern for an endpoint)
+    * 
+    * @param addr
+    * @return
+    */
+   public static String getPath(String addr)
+   {
+      return getPathInternal(getPathFromString(addr));
+   }
+   
+   public static String getPath(URI addr)
+   {
+      return getPathInternal(addr.getPath());
+   }
+   
+   private static String getPathInternal(String rawpath)
+   {
+      String path = removeTrailingSlash(rawpath);
+      if (path == null || path.length() == 0)
+      {
+         return path;
+      }
+      int idx = path.lastIndexOf("/");
+      return idx > 0 ? path.substring(path.lastIndexOf("/")) : "";
+   }
+   
+   /**
+    * Get the context path section of an address
+    * 
+    * @param addr
+    * @return
+    */
+   public static String getContextPath(String addr)
+   {
+      return getContextPathInternal(getPathFromString(addr));
+   }
+   
+   public static String getContextPath(URI addr)
+   {
+      return getContextPathInternal(addr.getPath());
+   }
+   
+   private static String getContextPathInternal(String rawpath)
+   {
+      String path = removeTrailingSlash(rawpath);
+      if (path == null || path.length() == 0)
+      {
+         return "/";
+      }
+      int idx = path.lastIndexOf("/");
+      return idx > 0 ? path.substring(0, idx) : path;
+   }
+   
+   private static String getPathFromString(String addr)
+   {
+      String path = null;
+      try
+      {
+         path = new URL(addr).getPath();
+      }
+      catch (MalformedURLException e)
+      {
+         //ignore
+      }
+      return path;
+   }
+   
+   private static String removeTrailingSlash(String path)
+   {
+      if (path != null && path.length() > 0 && path.lastIndexOf('/') == path.length() - 1)
+      {
+         path = path.substring(0, path.length() - 1);
+      }
+      return path;
+   }
+   
+}

Added: projects/jaxws-httpserver-httpspi/trunk/src/test/java/org/jboss/ws/httpserver_httpspi/DHRequest.java
===================================================================
--- projects/jaxws-httpserver-httpspi/trunk/src/test/java/org/jboss/ws/httpserver_httpspi/DHRequest.java	                        (rev 0)
+++ projects/jaxws-httpserver-httpspi/trunk/src/test/java/org/jboss/ws/httpserver_httpspi/DHRequest.java	2010-08-22 11:12:45 UTC (rev 12830)
@@ -0,0 +1,46 @@
+/**
+ * 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.jboss.ws.httpserver_httpspi;
+
+import javax.activation.DataHandler;
+import javax.xml.bind.annotation.XmlMimeType;
+import javax.xml.bind.annotation.XmlType;
+
+ at XmlType(name = "dataRequest", namespace = "http://org.apache.cxf/jaxws/endpoint/")
+public class DHRequest {
+
+    private DataHandler dataHandler;
+
+    public DHRequest() {
+    }
+
+    public DHRequest(DataHandler dataHandler) {
+        this.dataHandler = dataHandler;
+    }
+
+    @XmlMimeType("text/plain")
+    public DataHandler getDataHandler() {
+        return dataHandler;
+    }
+
+    public void setDataHandler(DataHandler dataHandler) {
+        this.dataHandler = dataHandler;
+    }
+
+}

Added: projects/jaxws-httpserver-httpspi/trunk/src/test/java/org/jboss/ws/httpserver_httpspi/DHResponse.java
===================================================================
--- projects/jaxws-httpserver-httpspi/trunk/src/test/java/org/jboss/ws/httpserver_httpspi/DHResponse.java	                        (rev 0)
+++ projects/jaxws-httpserver-httpspi/trunk/src/test/java/org/jboss/ws/httpserver_httpspi/DHResponse.java	2010-08-22 11:12:45 UTC (rev 12830)
@@ -0,0 +1,45 @@
+/**
+ * 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.jboss.ws.httpserver_httpspi;
+
+import javax.activation.DataHandler;
+import javax.xml.bind.annotation.XmlMimeType;
+import javax.xml.bind.annotation.XmlType;
+
+ at XmlType(name = "dataResponse", namespace = "http://org.apache.cxf/jaxws/endpoint/")
+public class DHResponse {
+
+    private DataHandler dataHandler;
+
+    public DHResponse() {
+    }
+
+    public DHResponse(DataHandler dataHandler) {
+        this.dataHandler = dataHandler;
+    }
+
+    @XmlMimeType("text/plain")
+    public DataHandler getDataHandler() {
+        return dataHandler;
+    }
+
+    public void setDataHandler(DataHandler dataHandler) {
+        this.dataHandler = dataHandler;
+    }
+}

Added: projects/jaxws-httpserver-httpspi/trunk/src/test/java/org/jboss/ws/httpserver_httpspi/EndpointAPITest.java
===================================================================
--- projects/jaxws-httpserver-httpspi/trunk/src/test/java/org/jboss/ws/httpserver_httpspi/EndpointAPITest.java	                        (rev 0)
+++ projects/jaxws-httpserver-httpspi/trunk/src/test/java/org/jboss/ws/httpserver_httpspi/EndpointAPITest.java	2010-08-22 11:12:45 UTC (rev 12830)
@@ -0,0 +1,206 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This 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.
+ *
+ * This software 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.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ws.httpserver_httpspi;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.InetSocketAddress;
+import java.net.URL;
+
+import javax.activation.DataHandler;
+import javax.activation.DataSource;
+import javax.xml.namespace.QName;
+import javax.xml.ws.Endpoint;
+import javax.xml.ws.Service;
+import javax.xml.ws.soap.MTOMFeature;
+import javax.xml.ws.spi.http.HttpContext;
+
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * A JAXWS 2.2 Endoint.publish(HttpContext context) API test
+ * using the JDK6 httpsever as underlying http container
+ * 
+ * @author alessio.soldano at jboss.com
+ * @since 22-Aug-2010
+ *
+ */
+ at SuppressWarnings("restriction")
+public class EndpointAPITest extends Assert
+{
+
+   private static int currentPort = 9876;
+
+   private com.sun.net.httpserver.HttpServer server;
+
+   @Before
+   public void setUp() throws IOException
+   {
+      currentPort++;
+      server = com.sun.net.httpserver.HttpServer.create(new InetSocketAddress(currentPort), 0);
+   }
+
+   @After
+   public void tearDown()
+   {
+      server.stop(0);
+      server = null;
+   }
+
+   @Test
+   public void testSingleEndpoint() throws Exception
+   {
+
+      String contextPath = "/ctxt";
+      String path = "/echo";
+      String address = "http://localhost:" + currentPort + contextPath + path;
+
+      HttpContext context = HttpServerContextFactory.createHttpContext(server, contextPath, path);
+
+      Endpoint endpoint = Endpoint.create(new EndpointBean());
+      endpoint.publish(context); // Use httpserver context for publishing
+
+      server.start();
+
+      invokeEndpoint(address);
+
+      endpoint.stop();
+   }
+
+   @Test
+   public void testMultiplePublishSameAddress() throws Exception
+   {
+      server.start();
+      String contextPath = "/ctxt";
+      String path = "/echo";
+      for (int i = 0; i < 3; i++)
+      {
+         HttpContext ctx = HttpServerContextFactory.createHttpContext(server, contextPath, path);
+         String address = "http://localhost:" + currentPort + contextPath + path;
+
+         Endpoint endpoint = Endpoint.create(new EndpointBean());
+         endpoint.publish(ctx); // Use httpserver context for publishing
+
+         invokeEndpoint(address);
+
+         endpoint.stop();
+         server.removeContext(contextPath);
+      }
+   }
+
+   @Test
+   public void testMultipleEndpointsDifferentContexts() throws Exception
+   {
+      server.start();
+      String contextPath = "/ctxt";
+      String path = "/echo";
+      int k = 3;
+      Endpoint[] endpoints = new Endpoint[k];
+      HttpContext[] contexts = new HttpContext[k];
+      String[] addresses = new String[k];
+      for (int i = 0; i < k; i++)
+      {
+         addresses[i] = "http://localhost:" + currentPort + contextPath + i + path;
+         contexts[i] = HttpServerContextFactory.createHttpContext(server, contextPath + i, path);
+         endpoints[i] = Endpoint.create(new EndpointBean());
+         endpoints[i].publish(contexts[i]);
+      }
+      for (int i = 0; i < k; i++)
+      {
+         invokeEndpoint(addresses[i]);
+      }
+      for (int i = 0; i < k; i++)
+      {
+         endpoints[i].stop();
+      }
+   }
+
+   private void invokeEndpoint(String publishURL) throws Exception
+   {
+      URL wsdlURL = new URL(publishURL + "?wsdl");
+      QName qname = new QName("http://org.apache.cxf/jaxws/endpoint/", "EndpointService");
+      Service service = Service.create(wsdlURL, qname);
+      checkBasicInvocations(service);
+      checkMTOMInvocation(service);
+   }
+
+   private static void checkBasicInvocations(Service service)
+   {
+      EndpointInterface port = (EndpointInterface) service.getPort(EndpointInterface.class);
+      String helloWorld = "Hello world!";
+      assertEquals(0, port.getCount());
+      Object retObj = port.echo(helloWorld);
+      assertEquals(helloWorld, retObj);
+      assertEquals(1, port.getCount());
+      port.echo(helloWorld);
+      assertEquals(2, port.getCount());
+      try
+      {
+         port.getException();
+         fail("Exception expected!");
+      }
+      catch (Exception e)
+      {
+         assertEquals("Ooops", e.getMessage());
+      }
+   }
+
+   private static void checkMTOMInvocation(Service service) throws IOException
+   {
+      DataSource ds = new DataSource()
+      {
+         public String getContentType()
+         {
+            return "text/plain";
+         }
+
+         public InputStream getInputStream() throws IOException
+         {
+            return new ByteArrayInputStream("some string".getBytes());
+         }
+
+         public String getName()
+         {
+            return "none";
+         }
+
+         public OutputStream getOutputStream() throws IOException
+         {
+            return null;
+         }
+      };
+      EndpointInterface port = (EndpointInterface) service.getPort(EndpointInterface.class, new MTOMFeature(true));
+      DataHandler dh = new DataHandler(ds);
+      DHResponse response = port.echoDataHandler(new DHRequest(dh));
+      assertNotNull(response);
+      Object content = response.getDataHandler().getContent();
+      assertEquals("Server data", content);
+      String contentType = response.getDataHandler().getContentType();
+      assertEquals("text/plain", contentType);
+   }
+
+}

Added: projects/jaxws-httpserver-httpspi/trunk/src/test/java/org/jboss/ws/httpserver_httpspi/EndpointBean.java
===================================================================
--- projects/jaxws-httpserver-httpspi/trunk/src/test/java/org/jboss/ws/httpserver_httpspi/EndpointBean.java	                        (rev 0)
+++ projects/jaxws-httpserver-httpspi/trunk/src/test/java/org/jboss/ws/httpserver_httpspi/EndpointBean.java	2010-08-22 11:12:45 UTC (rev 12830)
@@ -0,0 +1,89 @@
+/**
+ * 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.jboss.ws.httpserver_httpspi;
+
+import java.io.IOException;
+
+import javax.activation.DataHandler;
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.jws.WebService;
+import javax.xml.ws.WebServiceException;
+import javax.xml.ws.soap.MTOM;
+
+ at WebService(serviceName = "EndpointService",
+            endpointInterface = "org.jboss.ws.httpserver_httpspi.EndpointInterface",
+            targetNamespace = "http://org.apache.cxf/jaxws/endpoint/")
+ at MTOM
+public class EndpointBean implements EndpointInterface {
+
+    private int count;
+    private boolean initialized;
+
+    public String echo(String input) {
+        count++;
+        return input;
+    }
+
+    @PostConstruct
+    public void init() {
+        this.initialized = true;
+    }
+
+    @PreDestroy
+    public void destroy() {
+        // nothing to do
+    }
+
+    public int getCount() {
+        this.ensureInit();
+        return count;
+    }
+
+    public void getException() {
+        this.ensureInit();
+        throw new WebServiceException("Ooops");
+    }
+
+    public DHResponse echoDataHandler(DHRequest request) {
+        this.ensureInit();
+        DataHandler dataHandler = request.getDataHandler();
+
+        try {
+            if (!dataHandler.getContentType().equals("text/plain")) {
+                throw new WebServiceException("Wrong content type");
+            }
+            if (!dataHandler.getContent().equals("some string")) {
+                throw new WebServiceException("Wrong data");
+            }
+        } catch (IOException e) {
+            throw new WebServiceException(e);
+        }
+
+        DataHandler responseData = new DataHandler("Server data", "text/plain");
+        return new DHResponse(responseData);
+    }
+
+    private void ensureInit() {
+        if (!this.initialized) {
+            throw new IllegalStateException();
+        }
+    }
+
+}

Added: projects/jaxws-httpserver-httpspi/trunk/src/test/java/org/jboss/ws/httpserver_httpspi/EndpointInterface.java
===================================================================
--- projects/jaxws-httpserver-httpspi/trunk/src/test/java/org/jboss/ws/httpserver_httpspi/EndpointInterface.java	                        (rev 0)
+++ projects/jaxws-httpserver-httpspi/trunk/src/test/java/org/jboss/ws/httpserver_httpspi/EndpointInterface.java	2010-08-22 11:12:45 UTC (rev 12830)
@@ -0,0 +1,36 @@
+/**
+ * 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.jboss.ws.httpserver_httpspi;
+
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+
+ at WebService(targetNamespace = "http://org.apache.cxf/jaxws/endpoint/")
+ at SOAPBinding(style = SOAPBinding.Style.RPC)
+public interface EndpointInterface {
+
+    String echo(String input);
+
+    int getCount();
+
+    void getException();
+
+    DHResponse echoDataHandler(DHRequest request);
+
+}

Added: projects/jaxws-httpserver-httpspi/trunk/src/test/java/org/jboss/ws/httpserver_httpspi/PathUtilsTest.java
===================================================================
--- projects/jaxws-httpserver-httpspi/trunk/src/test/java/org/jboss/ws/httpserver_httpspi/PathUtilsTest.java	                        (rev 0)
+++ projects/jaxws-httpserver-httpspi/trunk/src/test/java/org/jboss/ws/httpserver_httpspi/PathUtilsTest.java	2010-08-22 11:12:45 UTC (rev 12830)
@@ -0,0 +1,86 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This 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.
+ *
+ * This software 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.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ws.httpserver_httpspi;
+
+import java.net.URI;
+
+import junit.framework.TestCase;
+
+public class PathUtilsTest extends TestCase
+{
+   public void testPath() {
+      assertEquals("", PathUtils.getPath("http://localhost:8080"));
+      assertEquals("", PathUtils.getPath("http://localhost:8080/foo"));
+      assertEquals("", PathUtils.getPath("http://localhost:8080/foo/"));
+      assertEquals("/bar", PathUtils.getPath("http://localhost:8080/foo/bar"));
+      assertEquals("/bar", PathUtils.getPath("http://localhost:8080/foo/bar/"));
+      assertEquals("/bar", PathUtils.getPath("http://localhost:8080/foo/bar?wsdl"));
+      assertEquals("/bar", PathUtils.getPath("http://localhost:8080/foo/bar/?wsdl"));
+      assertEquals("/bar", PathUtils.getPath("http://localhost:8080/foo/fooagain/bar"));
+      assertEquals("/bar", PathUtils.getPath("http://localhost:8080/foo/fooagain/bar?wsdl"));
+      assertEquals("/bar", PathUtils.getPath("http://localhost:8080/foo/fooagain/bar?wsdl&xsd=ff"));
+      assertEquals("/bar", PathUtils.getPath("http://localhost/foo/bar"));
+      assertEquals("/bar", PathUtils.getPath("https://localhost/foo/bar"));
+      
+   }
+   
+   public void testContextPath() {
+      assertEquals("/", PathUtils.getContextPath("http://localhost:8080"));
+      assertEquals("/foo", PathUtils.getContextPath("http://localhost:8080/foo"));
+      assertEquals("/foo", PathUtils.getContextPath("http://localhost:8080/foo/"));
+      assertEquals("/foo", PathUtils.getContextPath("http://localhost:8080/foo/bar"));
+      assertEquals("/foo", PathUtils.getContextPath("http://localhost:8080/foo/bar/"));
+      assertEquals("/foo/bar", PathUtils.getContextPath("http://localhost:8080/foo/bar/baragain"));
+      assertEquals("/foo", PathUtils.getContextPath("http://localhost:8080/foo/bar?wsdl&xsd=kk"));
+      assertEquals("/foo", PathUtils.getContextPath("http://localhost:8080/foo/bar/?wsdl&xsd=kk"));
+      assertEquals("/foo", PathUtils.getContextPath("http://localhost/foo/bar"));
+      assertEquals("/foo", PathUtils.getContextPath("https://localhost/foo/bar"));
+   }
+   
+   public void testURIPath() throws Exception {
+      assertEquals("", PathUtils.getPath(new URI("http", "", "localhost", 8080, "", "", "")));
+      assertEquals("", PathUtils.getPath(new URI("http", "", "localhost", 8080, "/foo", "", "")));
+      assertEquals("", PathUtils.getPath(new URI("http", "", "localhost", 8080, "/foo/", "", "")));
+      assertEquals("/bar", PathUtils.getPath(new URI("http", "", "localhost", 8080, "/foo/bar", "", "")));
+      assertEquals("/bar", PathUtils.getPath(new URI("http", "", "localhost", 8080, "/foo/bar/", "", "")));
+      assertEquals("/bar", PathUtils.getPath(new URI("http", "", "localhost", 8080, "/foo/bar", "wsdl", "")));
+      assertEquals("/bar", PathUtils.getPath(new URI("http", "", "localhost", 8080, "/foo/bar/", "wsdl", "")));
+      assertEquals("/bar", PathUtils.getPath(new URI("http", "", "localhost", 8080, "/foo/fooagain/bar", "", "")));
+      assertEquals("/bar", PathUtils.getPath(new URI("http", "", "localhost", 8080, "/foo/fooagain/bar", "wsdl", "")));
+      assertEquals("/bar", PathUtils.getPath(new URI("http", "", "localhost", 8080, "/foo/fooagain/bar", "wsdl&xsd=ff", "")));
+      assertEquals("/bar", PathUtils.getPath(new URI("http", "", "localhost", 0, "/foo/bar", "", "")));
+      assertEquals("/bar", PathUtils.getPath(new URI("https", "", "localhost", 0, "/foo/bar", "", "")));
+   }
+   
+   public void testURIContextPath() throws Exception {
+      assertEquals("/", PathUtils.getContextPath(new URI("http", "", "localhost", 8080, "", "", "")));
+      assertEquals("/foo", PathUtils.getContextPath(new URI("http", "", "localhost", 8080, "/foo", "", "")));
+      assertEquals("/foo", PathUtils.getContextPath(new URI("http", "", "localhost", 8080, "/foo/", "", "")));
+      assertEquals("/foo", PathUtils.getContextPath(new URI("http", "", "localhost", 8080, "/foo/bar", "", "")));
+      assertEquals("/foo", PathUtils.getContextPath(new URI("http", "", "localhost", 8080, "/foo/bar/", "", "")));
+      assertEquals("/foo/bar", PathUtils.getContextPath(new URI("http", "", "localhost", 8080, "/foo/bar/baragain", "", "")));
+      assertEquals("/foo", PathUtils.getContextPath(new URI("http", "", "localhost", 8080, "/foo/bar", "wsdl&xsd=kk", "")));
+      assertEquals("/foo", PathUtils.getContextPath(new URI("http", "", "localhost", 8080, "/foo/bar/", "wsdl&xsd=kk", "")));
+      assertEquals("/foo", PathUtils.getContextPath(new URI("http", "", "localhost", 0, "/foo/bar", "", "")));
+      assertEquals("/foo", PathUtils.getContextPath(new URI("https", "", "localhost", 0, "/foo/bar", "", "")));
+   }
+}



More information about the jbossws-commits mailing list