Author: slaws
Date: Tue Nov 20 06:44:05 2007
New Revision: 596694

URL: http://svn.apache.org/viewvc?rev=596694&view=rev
Log:
TUSCANY-1913
Remove the servlet wrapper from the port structure to allow the server to 
servlet to be re-registered and to allow the server to be shut down. Add a test 
case to add, remove and add a servlet to test this. 

Modified:
    
incubator/tuscany/java/sca/modules/host-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/TomcatServer.java
    
incubator/tuscany/java/sca/modules/host-tomcat/src/test/java/org/apache/tuscany/sca/http/tomcat/TomcatServerTestCase.java

Modified: 
incubator/tuscany/java/sca/modules/host-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/TomcatServer.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/host-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/TomcatServer.java?rev=596694&r1=596693&r2=596694&view=diff
==============================================================================
--- 
incubator/tuscany/java/sca/modules/host-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/TomcatServer.java
 (original)
+++ 
incubator/tuscany/java/sca/modules/host-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/TomcatServer.java
 Tue Nov 20 06:44:05 2007
@@ -351,6 +351,9 @@
         }
         if (md.wrapper instanceof ServletWrapper) {
             ServletWrapper servletWrapper = (ServletWrapper)md.wrapper;
+            
+            port.getConnector().getMapper().removeWrapper("localhost", "", 
mapping);
+
             try {
                context.removeServletMapping(mapping);
             } catch (NegativeArraySizeException e) {
@@ -361,6 +364,7 @@
             }
             context.removeChild(servletWrapper);
             servletWrapper.destroyServlet();
+            //logger.info("Remove Servlet mapping: " + suri);
             return servletWrapper.getServlet();
         } else {
             return null;

Modified: 
incubator/tuscany/java/sca/modules/host-tomcat/src/test/java/org/apache/tuscany/sca/http/tomcat/TomcatServerTestCase.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/host-tomcat/src/test/java/org/apache/tuscany/sca/http/tomcat/TomcatServerTestCase.java?rev=596694&r1=596693&r2=596694&view=diff
==============================================================================
--- 
incubator/tuscany/java/sca/modules/host-tomcat/src/test/java/org/apache/tuscany/sca/http/tomcat/TomcatServerTestCase.java
 (original)
+++ 
incubator/tuscany/java/sca/modules/host-tomcat/src/test/java/org/apache/tuscany/sca/http/tomcat/TomcatServerTestCase.java
 Tue Nov 20 06:44:05 2007
@@ -74,7 +74,7 @@
 
         public void destroy() {
         }
-    };
+    };      
 
     /**
      * Verifies requests are properly routed according to the servlet mapping
@@ -133,7 +133,41 @@
         read(client);
         service.stop();
         assertFalse(servlet.invoked);
+        
     }
+    
+    public void testRegisterUnregisterMapping() throws Exception {
+        TomcatServer service = new TomcatServer(workScheduler);
+        TestServlet servlet = new TestServlet();
+        service.addServletMapping("http://127.0.0.1:"; + HTTP_PORT + "/foo", 
servlet);
+        {
+            Socket client = new Socket("127.0.0.1", HTTP_PORT);
+            OutputStream os = client.getOutputStream();
+            os.write(REQUEST1.getBytes());
+            os.flush();
+            read(client);            
+        }
+        assertTrue(servlet.invoked);
+        service.removeServletMapping("http://127.0.0.1:"; + HTTP_PORT + "/foo");
+        {
+            Socket client = new Socket("127.0.0.1", HTTP_PORT);
+            OutputStream os = client.getOutputStream();
+            os.write(REQUEST1.getBytes());
+            os.flush();
+            read(client);            
+        }
+        servlet = new TestServlet();
+        service.addServletMapping("http://127.0.0.1:"; + HTTP_PORT + "/foo", 
servlet);
+        {
+            Socket client = new Socket("127.0.0.1", HTTP_PORT);
+            OutputStream os = client.getOutputStream();
+            os.write(REQUEST1.getBytes());
+            os.flush();
+            read(client);            
+        }
+        assertTrue(servlet.invoked);
+        service.stop();
+    } 
 
     public void testRequestSession() throws Exception {
         TomcatServer service = new TomcatServer(workScheduler);



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to