[jbossws-commits] JBossWS SVN: r10904 - in stack/native/branches/ropalka/modules: core/src/main/java/org/jboss/ws/core/jaxws/spi/http and 1 other directories.

jbossws-commits at lists.jboss.org jbossws-commits at lists.jboss.org
Wed Oct 14 04:44:17 EDT 2009


Author: richard.opalka at jboss.com
Date: 2009-10-14 04:44:17 -0400 (Wed, 14 Oct 2009)
New Revision: 10904

Modified:
   stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/EndpointImpl.java
   stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/http/NettyRequestHandlerImpl.java
   stack/native/branches/ropalka/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/endpoint/jse/UsecasesTestCase.java
Log:
[JBWS-2674][JBWS-2754] providing more test cases

Modified: stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/EndpointImpl.java
===================================================================
--- stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/EndpointImpl.java	2009-10-13 17:22:20 UTC (rev 10903)
+++ stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/EndpointImpl.java	2009-10-14 08:44:17 UTC (rev 10904)
@@ -80,7 +80,9 @@
    public EndpointImpl(String bindingId, Object implementor, WebServiceFeature[] features)
    {
       if (implementor == null)
+      {
          throw new IllegalArgumentException("Implementor cannot be null");
+      }
 
       this.implementor = implementor;
       this.bindingProvider = new BindingProviderImpl(bindingId);
@@ -90,13 +92,13 @@
    @Override
    public Binding getBinding()
    {
-      return bindingProvider.getBinding();
+      return this.bindingProvider.getBinding();
    }
 
    @Override
    public Object getImplementor()
    {
-      return implementor;
+      return this.implementor;
    }
 
    /**
@@ -107,7 +109,7 @@
     * @param address specifying the address to use. The address must be compatible with the binding specified at the time the endpoint was created.
     */
    @Override
-   public void publish(String addr)
+   public void publish(final String addr)
    {
       log.debug("publish: " + addr);
 
@@ -121,17 +123,16 @@
       }
 
       // Check with the security manger
-      checkPublishEndpointPermission();
+      this.checkPublishEndpointPermission();
 
-      // Create and start the HTTP server
-      SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
-      HttpServer httpServer = spiProvider.getSPI(HttpServerFactory.class).getHttpServer();
+      // Get HTTP server
+      final SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
+      final HttpServer httpServer = spiProvider.getSPI(HttpServerFactory.class).getHttpServer();
 
-      String path = address.getPath();
-      String contextRoot = "/" + new StringTokenizer(path, "/").nextToken();
-      HttpContext context = httpServer.createContext(contextRoot);
+      final String contextRoot = this.getContextRoot();
+      final HttpContext context = httpServer.createContext(contextRoot);
 
-      publish(context);
+      this.publish(context);
    }
 
    /**
@@ -157,14 +158,14 @@
 
       if (context instanceof HttpContext)
       {
-         serverContext = (HttpContext)context;
-         if (address == null)
+         this.serverContext = (HttpContext)context;
+         if (this.address == null)
          {
-            address = getAddressFromConfigAndContext(serverContext); // TODO: is it necessary?
+            this.address = getAddressFromConfigAndContext(serverContext); // TODO: is it necessary?
          }
-         HttpServer httpServer = serverContext.getHttpServer();
-         httpServer.publish(serverContext, this);
-         isPublished = true;
+         HttpServer httpServer = this.serverContext.getHttpServer();
+         httpServer.publish(this.serverContext, this);
+         this.isPublished = true;
       }
       else
       {
@@ -218,17 +219,17 @@
    @Override
    public boolean isPublished()
    {
-      return isPublished;
+      return this.isPublished;
    }
 
    @Override
    public List<Source> getMetadata()
    {
-      return metadata;
+      return this.metadata;
    }
 
    @Override
-   public void setMetadata(List<Source> list)
+   public void setMetadata(final List<Source> list)
    {
       log.info("Ignore metadata, not implemented"); // TODO:
       this.metadata = list;
@@ -237,7 +238,7 @@
    @Override
    public Executor getExecutor()
    {
-      return executor;
+      return this.executor;
    }
 
    @Override
@@ -250,13 +251,13 @@
    @Override
    public Map<String, Object> getProperties()
    {
-      return properties;
+      return this.properties;
    }
 
    @Override
    public void setProperties(Map<String, Object> map)
    {
-      properties = map;
+      this.properties = map;
    }
 
    private void checkPublishEndpointPermission()
@@ -305,7 +306,12 @@
    
    public String getPath()
    {
-      return this.address.getPath();
+      String path = this.address.getPath();
+      while (path.endsWith("/"))
+      {
+         path = path.substring(0, path.length() - 1);
+      }
+      return path;
    }
    
    public int getPort()
@@ -313,11 +319,28 @@
       return this.address.getPort();
    }
    
+   public String getContextRoot()
+   {
+      final StringTokenizer st = new StringTokenizer(this.getPath(), "/");
+      
+      String contextRoot = "/";
+      
+      if (st.hasMoreTokens())
+      {
+         contextRoot += st.nextToken();
+      }
+      
+      return contextRoot;
+   }
+   
    public String getPathWithoutContext()
    {
       // TODO: optimize this method
       StringTokenizer st = new StringTokenizer(this.getPath(), "/");
-      st.nextToken();
+      if (st.hasMoreTokens())
+      {
+         st.nextToken();
+      }
       StringBuilder sb = new StringBuilder();
       while (st.hasMoreTokens())
       {

Modified: stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/http/NettyRequestHandlerImpl.java
===================================================================
--- stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/http/NettyRequestHandlerImpl.java	2009-10-13 17:22:20 UTC (rev 10903)
+++ stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/http/NettyRequestHandlerImpl.java	2009-10-14 08:44:17 UTC (rev 10904)
@@ -103,6 +103,7 @@
          {
             requestPath = requestPath.substring(0, paramIndex);
          }
+         requestPath = this.getRequestPath(requestPath);
          String httpMethod = request.getMethod().getName();
          statusCode = handle(requestPath, httpMethod, getInputStream(content), outputStream, invCtx);
       }
@@ -122,46 +123,22 @@
       return new ChannelBufferInputStream(content);
    }
 
-   private int handle(String requestPath, String httpMethod, InputStream inputStream, OutputStream outputStream,
-         InvocationContext invCtx) throws IOException
+   private int handle(final String requestPath, final String httpMethod, final InputStream inputStream, final OutputStream outputStream,
+         final InvocationContext invCtx) throws IOException
    {
-      boolean handlerExists = false;
-      requestPath = truncateHostName(requestPath);
-      NettyCallbackHandlerImpl handler = (NettyCallbackHandlerImpl) this.getCallback(requestPath);
+      final NettyCallbackHandlerImpl handler = (NettyCallbackHandlerImpl) this.getCallback(requestPath);
       if (handler != null)
       {
-         handlerExists = true;
-         if (LOG.isDebugEnabled())
-            LOG.debug("Handling request path: " + requestPath);
+         NettyRequestHandlerImpl.LOG.debug("Handling " + httpMethod + " request for " + requestPath);
 
          return handler.handle(httpMethod, inputStream, outputStream, invCtx);
       }
-      if (handlerExists == false)
-         LOG.warn("No callback handler registered for path: " + requestPath);
-
-      return 500;
-   }
-
-   private String truncateHostName(String s)
-   {
-      String retVal = s;
-      if (s.startsWith("http"))
+      else
       {
-         try
-         {
-            retVal = new URL(s).getPath();
-         }
-         catch (MalformedURLException mue)
-         {
-            LOG.error(mue.getMessage(), mue);
-         }
-      }
+         NettyRequestHandlerImpl.LOG.warn("No callback handler registered for path: " + requestPath);
 
-      while (retVal.endsWith("/"))
-      {
-         retVal = retVal.substring(0, retVal.length() - 1);
+         return 501;
       }
-      return retVal;
    }
 
    private void writeResponse(MessageEvent e, HttpRequest request, String content, int statusCode,
@@ -223,6 +200,30 @@
       }
    }
 
+   // TODO: https://jira.jboss.org/jira/browse/NETTY-239
+   private String getRequestPath(String s)
+   {
+      String retVal = s;
+      if (s.startsWith("http"))
+      {
+         try
+         {
+            retVal = new URL(s).getPath();
+         }
+         catch (MalformedURLException mue)
+         {
+            LOG.error(mue.getMessage(), mue);
+         }
+      }
+
+      while (retVal.endsWith("/"))
+      {
+         retVal = retVal.substring(0, retVal.length() - 1);
+      }
+      return retVal;
+   }
+
+   // TODO: https://jira.jboss.org/jira/browse/NETTY-237
    private List<String> removeProhibitedCharacters(List<String> values)
    {
       List<String> retVal = new LinkedList<String>();
@@ -234,9 +235,9 @@
       return retVal;
    }
 
+   // TODO: https://jira.jboss.org/jira/browse/NETTY-237
    private String removeProhibitedCharacters(String s)
    {
-      // TODO: https://jira.jboss.org/jira/browse/NETTY-237
       String retVal = s;
 
       retVal = retVal.replace('\r', ' ');

Modified: stack/native/branches/ropalka/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/endpoint/jse/UsecasesTestCase.java
===================================================================
--- stack/native/branches/ropalka/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/endpoint/jse/UsecasesTestCase.java	2009-10-13 17:22:20 UTC (rev 10903)
+++ stack/native/branches/ropalka/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/endpoint/jse/UsecasesTestCase.java	2009-10-14 08:44:17 UTC (rev 10904)
@@ -53,10 +53,10 @@
    
    private static int port1 = 8871;
    private static int port2 = 8872;
-   
-   public void testDifferentPorts() throws Exception
+
+   public void testDifferentPortsSameContext() throws Exception
    {
-      String publishURL1 = "http://" + getServerHost() + ":" + port1 + "/jaxws-endpoint";
+      String publishURL1 = "http://" + getServerHost() + ":" + port1 + "/jaxws-endpoint/";
       Endpoint endpoint1 = publishEndpoint1(Endpoint1Impl.class, publishURL1);
 
       String publishURL2 = "http://" + getServerHost() + ":" + port2 + "/jaxws-endpoint";
@@ -69,9 +69,24 @@
       endpoint2.stop();
    }
 
+   public void testDifferentPortsNoContext() throws Exception
+   {
+      String publishURL1 = "http://" + getServerHost() + ":" + port1 + "/";
+      Endpoint endpoint1 = publishEndpoint1(Endpoint1Impl.class, publishURL1);
+
+      String publishURL2 = "http://" + getServerHost() + ":" + port2;
+      Endpoint endpoint2 = publishEndpoint2(new Endpoint1Impl(), publishURL2);
+
+      invokeEndpoint1(publishURL1);
+      invokeEndpoint1(publishURL2);
+
+      endpoint1.stop();
+      endpoint2.stop();
+   }
+
    public void testDifferentPortsAndLongPaths() throws Exception
    {
-      String publishURL1 = "http://" + getServerHost() + ":" + port1 + "/jaxws-endpoint/endpoint/long/path";
+      String publishURL1 = "http://" + getServerHost() + ":" + port1 + "/jaxws-endpoint/endpoint/long/path/";
       Endpoint endpoint1 = publishEndpoint3(Endpoint1Impl.class, publishURL1);
 
       String publishURL2 = "http://" + getServerHost() + ":" + port2 + "/jaxws-endpoint/endpoint/long/path";
@@ -86,7 +101,7 @@
 
    public void testSamePortsAndAlmostIdenticalLongPaths() throws Exception
    {
-      String publishURL1 = "http://" + getServerHost() + ":" + port1 + "/jaxws-endpoint/endpoint/number1";
+      String publishURL1 = "http://" + getServerHost() + ":" + port1 + "/jaxws-endpoint/endpoint/number1/";
       Endpoint endpoint1 = publishEndpoint2(Endpoint1Impl.class, publishURL1);
 
       String publishURL2 = "http://" + getServerHost() + ":" + port1 + "/jaxws-endpoint/endpoint/number11";
@@ -101,7 +116,7 @@
 
    public void testDifferentPortsAndIdenticalPaths() throws Exception
    {
-      String publishURL1 = "http://" + getServerHost() + ":" + port1 + "/jaxws-endpoint/endpoint/number1";
+      String publishURL1 = "http://" + getServerHost() + ":" + port1 + "/jaxws-endpoint/endpoint/number1/";
       Endpoint endpoint1 = publishEndpoint1(Endpoint1Impl.class, publishURL1);
 
       String publishURL2 = "http://" + getServerHost() + ":" + port2 + "/jaxws-endpoint/endpoint/number1";



More information about the jbossws-commits mailing list