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

Ron Sigal ron_sigal at yahoo.com
Mon Nov 12 01:53:47 EST 2007


  User: rsigal  
  Date: 07/11/12 01:53:47

  Modified:    src/tests/org/jboss/test/remoting/shutdown  Tag:
                        remoting_2_x ShutdownTestParent.java
  Log:
  JBREM-800, JBREM-807, JBREM-821: (1) Adjusted timing; (2) added new unit test to verify that server can shut down even if client is alive.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.5   +52 -15    JBossRemoting/src/tests/org/jboss/test/remoting/shutdown/ShutdownTestParent.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ShutdownTestParent.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossRemoting/src/tests/org/jboss/test/remoting/shutdown/ShutdownTestParent.java,v
  retrieving revision 1.1.2.4
  retrieving revision 1.1.2.5
  diff -u -b -r1.1.2.4 -r1.1.2.5
  --- ShutdownTestParent.java	7 Nov 2007 08:41:48 -0000	1.1.2.4
  +++ ShutdownTestParent.java	12 Nov 2007 06:53:47 -0000	1.1.2.5
  @@ -40,7 +40,7 @@
    * (http://jira.jboss.com/jira/browse/JBREM-674)
    * 
    * @author <a href="ron.sigal at jboss.com">Ron Sigal</a>
  - * @version $Revision: 1.1.2.4 $
  + * @version $Revision: 1.1.2.5 $
    * <p>
    * Copyright Jan 19, 2007
    * </p>
  @@ -64,12 +64,10 @@
       * This test case verifies that the test really works.  In particular,
       * a non-daemon thread is created in the client JVM that prevents it
       * from shutting down in the expected time frame.
  -    * 
  -    * @throws Throwable
       */
      public void testHangingClient() throws Throwable
      {
  -      log.info("entering testHangingClient()");
  +      log.info("entering " + getName());
         
         port = PortUtil.findFreePort(InetAddress.getLocalHost().getHostName());
         String command = "java -cp \"" +  System.getProperty("java.class.path") + "\" ";
  @@ -79,24 +77,25 @@
         String clientCommand = command + getHangingClientClassName() + " " + getTransport();
         clientCommand += " " + getClientArgs();
         new Executor(serverCommand, true).start();
  -      Thread.sleep(1000);
  +      Thread.sleep(10000);
         new Executor(clientCommand, false).start();
         Thread.sleep(8000);
  -      assertTrue(serverSuccessful);
  +      log.info("testing client");
         assertFalse(clientSuccessful);
  +      Thread.sleep(22000);
  +      log.info("testing server");
  +      assertTrue(serverSuccessful);
         log.info(getName() + " PASSES");
      }
      
      
      /**
  -    * This unit verifies that a JVM with a client, and another JVM with a server,
  +    * This test verifies that a JVM with a client, and another JVM with a server,
       * both terminate.
  -    * 
  -    * @throws Throwable
       */
      public void testClosingClient() throws Throwable
      {
  -      log.info("entering testClosingClient()");
  +      log.info("entering " + getName());
         
         port = PortUtil.findFreePort(InetAddress.getLocalHost().getHostName());
         String command = "java -cp \"" +  System.getProperty("java.class.path") + "\" ";
  @@ -106,11 +105,42 @@
         String clientCommand = command + getClosingClientClassName() + " " + getTransport();
         clientCommand += " " + getClientArgs();
         new Executor(serverCommand, true).start();
  -      Thread.sleep(1000);
  +      Thread.sleep(10000);
         new Executor(clientCommand, false).start();
  -      Thread.sleep(6000);
  -      assertTrue(serverSuccessful);
  +      Thread.sleep(8000);
  +      log.info("testing client");
         assertTrue(clientSuccessful);
  +      Thread.sleep(22000);
  +      log.info("testing server");
  +      assertTrue(serverSuccessful);
  +      log.info(getName() + " PASSES");
  +   }
  +   
  +   
  +   /**
  +    * This test verifies that a server can shut down even if the client does not.
  +    */
  +   public void testOpenClient() throws Throwable
  +   {
  +      log.info("entering " + getName());
  +      
  +      port = PortUtil.findFreePort(InetAddress.getLocalHost().getHostName());
  +      String command = "java -cp \"" +  System.getProperty("java.class.path") + "\" ";
  +      command += getJVMArguments() + " -Dport=" + port + " ";
  +      String serverCommand = command + ShutdownTestServer.class.getName() + " " + getTransport();
  +      serverCommand += " " + getServerArgs();
  +      String clientCommand = command + OpenClient.class.getName() + " " + getTransport();
  +      clientCommand += " " + getClientArgs();
  +      new Executor(serverCommand, true).start();
  +      Thread.sleep(10000);
  +      Executor clientExecutor = new Executor(clientCommand, false);
  +      clientExecutor.start();
  +      Thread.sleep(30000);
  +      log.info("testing client");
  +      assertFalse(clientSuccessful);
  +      log.info("testing server");
  +      assertTrue(serverSuccessful);
  +      clientExecutor.destroy();
         log.info(getName() + " PASSES");
      }
      
  @@ -148,11 +178,12 @@
      abstract protected String getTransport();
      
      
  -   class Executor
  +   public class Executor
      {
         private String command;
         private boolean server;
         private boolean successful;
  +      private Process process;
         
         public Executor(String command, boolean server)
         {
  @@ -182,6 +213,7 @@
                  {
                     log.info("executing: " + finalCommand);
                     final Process local = Runtime.getRuntime().exec(finalCommand);
  +                  process = local;
                     
                     final BufferedReader errStream = new BufferedReader(new InputStreamReader(local.getErrorStream()));
                     final BufferedReader inStream = new BufferedReader(new InputStreamReader(local.getInputStream()));
  @@ -236,5 +268,10 @@
               }
            }.start();
         }
  +        
  +      public void destroy()
  +      {
  +         process.destroy();
  +      }
      }
   }
  \ No newline at end of file
  
  
  



More information about the jboss-cvs-commits mailing list