cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r587253 - in /incubator/cxf/branches/2.0.x-fixes: ./ systests/src/test/java/org/apache/cxf/systest/http_jetty/EngineLifecycleTest.java
Date Mon, 22 Oct 2007 21:06:24 GMT
Author: dkulp
Date: Mon Oct 22 14:06:24 2007
New Revision: 587253

URL: http://svn.apache.org/viewvc?rev=587253&view=rev
Log:
Merged revisions 586917 via svnmerge from 
https://svn.apache.org/repos/asf/incubator/cxf/trunk

........
  r586917 | bimargulies | 2007-10-21 13:10:23 -0400 (Sun, 21 Oct 2007) | 3 lines
  
  The server socket might be null when we go to turn on reuse address. I don't know why, but
that's 
  apparently just how Jetty works.
........

Modified:
    incubator/cxf/branches/2.0.x-fixes/   (props changed)
    incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/http_jetty/EngineLifecycleTest.java

Propchange: incubator/cxf/branches/2.0.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/http_jetty/EngineLifecycleTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/http_jetty/EngineLifecycleTest.java?rev=587253&r1=587252&r2=587253&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/http_jetty/EngineLifecycleTest.java
(original)
+++ incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/http_jetty/EngineLifecycleTest.java
Mon Oct 22 14:06:24 2007
@@ -20,12 +20,15 @@
 
 import java.io.File;
 import java.io.FileInputStream;
+import java.io.IOException;
 import java.io.InputStream;
 import java.net.HttpURLConnection;
+import java.net.InetAddress;
 import java.net.ServerSocket;
-import java.net.SocketException;
+import java.net.Socket;
 import java.net.URL;
 import java.net.URLConnection;
+import java.net.UnknownHostException;
 import java.util.Properties;
 
 
@@ -41,6 +44,7 @@
 import org.junit.Assert;
 import org.junit.Ignore;
 import org.junit.Test;
+import org.mortbay.jetty.Connector;
 import org.mortbay.jetty.Handler;
 import org.mortbay.jetty.webapp.WebAppContext;
 import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
@@ -164,7 +168,7 @@
         shutdownService();
     }
     
-    private void setReuseAddrForServer(int port) throws SocketException {
+    private void setReuseAddrForServer(int port) throws IOException {
         Bus bus = (Bus)applicationContext.getBean("cxf");
         boolean turnedOnReuseAddr = false;
         ServerRegistry sr = bus.getExtension(ServerRegistry.class);
@@ -172,8 +176,11 @@
             ServerImpl si = (ServerImpl) server;
             JettyHTTPDestination jhd = (JettyHTTPDestination) si.getDestination();
             JettyHTTPServerEngine e = (JettyHTTPServerEngine) jhd.getEngine();
-            if (e.getConnector().getPort() == port) {
-                ServerSocket socket = (ServerSocket)e.getConnector().getConnection();
+            Connector connector = e.getConnector();
+            if (connector.getPort() == port) {
+                connector.open();  // it might not be opened. 
+                ServerSocket socket = (ServerSocket)connector.getConnection();
+                assertNotNull("connector must have socket", socket);
                 socket.setReuseAddress(true);
                 turnedOnReuseAddr = true;
             }
@@ -181,6 +188,19 @@
         assertTrue(turnedOnReuseAddr); // insure that we actually found the server for 8801
and did the deed.
         
     }
+    
+    private void verifyNoServer(int port) {
+        try {
+            Socket socket = new Socket(InetAddress.getLocalHost(), port);
+            socket.close();
+        } catch (UnknownHostException e) {
+            fail("Unknown host for local address");
+        } catch (IOException e) {
+            return; // this is what we want.
+        }
+        fail("Server on port " + port + " accepted a connection.");
+        
+    }
 
     /**
      * 
@@ -195,6 +215,8 @@
         invokeService();    
         invokeService8801();
         shutdownService();
+        verifyNoServer(8808);
+        verifyNoServer(8801);
 
         setUpBus(true);
         setReuseAddrForServer(8801);
@@ -204,6 +226,9 @@
         getTestHtml();
         
         shutdownService();
+        verifyNoServer(8808);
+        verifyNoServer(8801);
+
     }
 
 }



Mime
View raw message