[jboss-cvs] JBossRemoting/src/tests/org/jboss/test/remoting/lifecycle ...

Tom Elrod telrod at belmont.prod.atl2.jboss.com
Wed Aug 30 11:50:46 EDT 2006


  User: telrod  
  Date: 06/08/30 11:50:46

  Modified:    src/tests/org/jboss/test/remoting/lifecycle 
                        InvokerLifecycleTestCase.java
  Log:
  JBREM-594 - fixed problem where Connector not cleaning up when exception encountered during create or start.
  
  Revision  Changes    Path
  1.4       +57 -1     JBossRemoting/src/tests/org/jboss/test/remoting/lifecycle/InvokerLifecycleTestCase.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: InvokerLifecycleTestCase.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossRemoting/src/tests/org/jboss/test/remoting/lifecycle/InvokerLifecycleTestCase.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -b -r1.3 -r1.4
  --- InvokerLifecycleTestCase.java	30 Dec 2005 05:26:42 -0000	1.3
  +++ InvokerLifecycleTestCase.java	30 Aug 2006 15:50:46 -0000	1.4
  @@ -22,11 +22,13 @@
   
   package org.jboss.test.remoting.lifecycle;
   
  +import junit.framework.TestCase;
   import org.jboss.remoting.InvalidConfigurationException;
   import org.jboss.remoting.InvokerLocator;
   import org.jboss.remoting.transport.Connector;
   
  -import junit.framework.TestCase;
  +import java.net.InetAddress;
  +import java.net.ServerSocket;
   
   /**
    * @author <a href="mailto:tom at jboss.org">Tom Elrod</a>
  @@ -94,4 +96,58 @@
         assertTrue("Did not get InvalidConfiguration which is as expected.", true);
   
      }
  +
  +   public void testStopConnector() throws Exception
  +   {
  +      // secure a server port to ensure is not available to connector
  +      InetAddress inetAddress = InetAddress.getByName("localhost");
  +      ServerSocket socket = new ServerSocket(3333, 0, inetAddress);
  +
  +      InvokerLocator serverLocator = new InvokerLocator("socket://localhost:3333");
  +      Connector connector = new Connector(serverLocator);
  +      try
  +      {
  +         connector.start();
  +         assertTrue("Should not have been able to start connector.  Should have gotten bind exception.", false);
  +      }
  +      catch (Exception e)
  +      {
  +         System.out.println("Got exception as expected.");
  +      }
  +      connector.stop();
  +
  +      // have stopped, so free up port and restart
  +      socket.close();
  +
  +      // should not be able to start
  +      connector.start();
  +
  +      // startup must have been ok, now need to take down
  +      connector.stop();
  +      connector.destroy();
  +
  +      // start the whole process over
  +      socket = new ServerSocket(3333, 0, inetAddress);
  +      connector = new Connector(serverLocator);
  +      try
  +      {
  +         connector.start();
  +         assertTrue("Should not have been able to start connector.  Should have gotten bind exception.", false);
  +      }
  +      catch (Exception e)
  +      {
  +         System.out.println("Got exception as expected.");
  +      }
  +      connector.stop();
  +      // this time, are also going to explicitly call destroy
  +      connector.destroy();
  +
  +      // now close socket to release hold on port
  +      socket.close();
  +      Connector connector2 = new Connector(serverLocator);
  +      connector2.start();
  +      assertTrue("Able to start second connector.", true);
  +
  +
  +   }
   }
  \ No newline at end of file
  
  
  



More information about the jboss-cvs-commits mailing list