tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dblev...@apache.org
Subject svn commit: r629307 - /openejb/trunk/openejb3/server/openejb-http/src/test/java/org/apache/openejb/server/httpd/HttpEjbServerTest.java
Date Wed, 20 Feb 2008 01:36:23 GMT
Author: dblevins
Date: Tue Feb 19 17:36:18 2008
New Revision: 629307

URL: http://svn.apache.org/viewvc?rev=629307&view=rev
Log:
Revert back to using the random available port strategy

Modified:
    openejb/trunk/openejb3/server/openejb-http/src/test/java/org/apache/openejb/server/httpd/HttpEjbServerTest.java

Modified: openejb/trunk/openejb3/server/openejb-http/src/test/java/org/apache/openejb/server/httpd/HttpEjbServerTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-http/src/test/java/org/apache/openejb/server/httpd/HttpEjbServerTest.java?rev=629307&r1=629306&r2=629307&view=diff
==============================================================================
--- openejb/trunk/openejb3/server/openejb-http/src/test/java/org/apache/openejb/server/httpd/HttpEjbServerTest.java
(original)
+++ openejb/trunk/openejb3/server/openejb-http/src/test/java/org/apache/openejb/server/httpd/HttpEjbServerTest.java
Tue Feb 19 17:36:18 2008
@@ -25,6 +25,7 @@
 import org.apache.openejb.OpenEJB;
 import org.apache.openejb.core.ServerFederation;
 import org.apache.openejb.server.ServiceException;
+import org.apache.openejb.server.ServiceDaemon;
 import org.apache.openejb.server.ejbd.EjbServer;
 import org.apache.openejb.test.TestManager;
 import org.apache.openejb.test.entity.bmp.BmpTestSuite;
@@ -70,15 +71,15 @@
     }
 
     public static class HttpEjbTestServer implements org.apache.openejb.test.TestServer {
-        // private ServiceDaemon serviceDaemon;
+        private ServiceDaemon serviceDaemon;
     	HttpServer httpServer;
-        private int port = 8080;
+        private int port;
 
         public void init(Properties props) {
             try {
                 EjbServer ejbServer = new EjbServer();
                 ServerServiceAdapter adapter = new ServerServiceAdapter(ejbServer);
-                httpServer = new JettyHttpServer(adapter);
+                httpServer = new OpenEJBHttpServer(adapter);
 
                 props.put("openejb.deployments.classpath", "true");
                 OpenEJB.init(props, new ServerFederation());
@@ -86,7 +87,9 @@
                 
                 httpServer.init(props);
 
-                // serviceDaemon = new ServiceDaemon(httpServer, 0, "localhost");
+                // Binding to port 0 means that the OS will
+                // randomly pick an *available* port and bind to it
+                serviceDaemon = new ServiceDaemon(httpServer, 0, "localhost");
 
             } catch (Exception e) {
                 throw new RuntimeException("Unable to initialize Test Server.", e);
@@ -95,9 +98,12 @@
 
         public void start() {
             try {
-                // serviceDaemon.start();
-            	httpServer.start();
-                // port = serviceDaemon.getPort();
+                serviceDaemon.start();
+                httpServer.start();
+
+                // Here we figure out which port the OS picked for us
+                // so we can use it in the getContextEnvironment method
+                port = serviceDaemon.getPort();
             } catch (ServiceException e) {
                 throw new RuntimeException("Unable to start Test Server.", e);
             }
@@ -105,7 +111,7 @@
 
         public void stop() {
             try {
-                // serviceDaemon.stop();
+                serviceDaemon.stop();
             	httpServer.stop();
             } catch (ServiceException e) {
                 throw new RuntimeException("Unable to stop Test Server.", e);



Mime
View raw message