dblevins    2004/12/17 20:55:44

  Modified:    modules/core/src/test/org/openejb/server/httpd
                        HttpServerTest.java
  Log:

  Added a StandardServiceStack which wraps the Deamon, Logger, AccessController,
  Pool and ServerService so that each is manageable as one unit.
  
  Added a new test to the HttpServerTest that uses the new StandardServiceStack
  
  Revision  Changes    Path
  1.2       +29 -3     
openejb/modules/core/src/test/org/openejb/server/httpd/HttpServerTest.java
  
  Index: HttpServerTest.java
  ===================================================================
  RCS file: 
/home/projects/openejb/scm/openejb/modules/core/src/test/org/openejb/server/httpd/HttpServerTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- HttpServerTest.java       17 Dec 2004 05:10:24 -0000      1.1
  +++ HttpServerTest.java       18 Dec 2004 01:55:44 -0000      1.2
  @@ -68,18 +68,44 @@
   
       public void testBareService() throws Exception {
           ServerService service = new HttpServer();
  -        ServiceDaemon daemon = new ServiceDaemon("HTTP", service, 
InetAddress.getByName("localhost"), 8000);
  +        ServiceDaemon daemon = new ServiceDaemon("HTTP", service, 
InetAddress.getByName("localhost"), 0);
  +        HttpURLConnection connection = null;
   
           try {
  +            daemon.setSoTimeout(100);
               daemon.doStart();
  -            URL url = new 
URL("http://localhost:8000/this/should/hit/something";);
   
  -            HttpURLConnection connection = (HttpURLConnection) 
url.openConnection();
  +            int port = daemon.getPort();
  +            URL url = new 
URL("http://localhost:"+port+"/this/should/hit/something";);
  +            connection = (HttpURLConnection) url.openConnection();
  +
               int responseCode = connection.getResponseCode();
               assertEquals("HTTP response code should be 500", responseCode, 
HttpURLConnection.HTTP_INTERNAL_ERROR);
           } finally {
  +            connection.disconnect();
               daemon.doStop();
           }
   
       }
  +
  +    public void testServiceStack() throws Exception {
  +        ServerService service = new HttpServer();
  +        StandardServiceStack serviceStack = new StandardServiceStack("HTTP", 
0, InetAddress.getByName("localhost"), null, 1,5, null, null, service);
  +        HttpURLConnection connection = null;
  +
  +        try {
  +            serviceStack.doStart();
  +            int port = serviceStack.getPort();
  +
  +            URL url = new 
URL("http://localhost:"+port+"/this/should/hit/something";);
  +
  +            connection = (HttpURLConnection) url.openConnection();
  +            int responseCode = connection.getResponseCode();
  +            assertEquals("HTTP response code should be 500", responseCode, 
HttpURLConnection.HTTP_INTERNAL_ERROR);
  +        } finally {
  +            connection.disconnect();
  +            serviceStack.doStop();
  +        }
  +    }
  +
   }
  
  
  

Reply via email to