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

Ron Sigal ron_sigal at yahoo.com
Thu Jul 20 03:29:25 EDT 2006


  User: rsigal  
  Date: 06/07/20 03:29:25

  Added:       src/tests/org/jboss/test/remoting/transport/multiplex   
                        LateClientShutdownTestClient.java
                        LateClientShutdownTestServer.java
                        LateClientShutdownTestCase.java
  Log:
  JBREM-551:  Added test case for situation in which Connector shuts down and then Client tries to disconnect.  Client should be able to disconnect without exceptions being thrown.
  
  Revision  Changes    Path
  1.1      date: 2006/07/20 07:29:25;  author: rsigal;  state: Exp;JBossRemoting/src/tests/org/jboss/test/remoting/transport/multiplex/LateClientShutdownTestClient.java
  
  Index: LateClientShutdownTestClient.java
  ===================================================================
  /*
   * JBoss, Home of Professional Open Source
   * Copyright 2006, JBoss Inc., and individual contributors as indicated
   * by the @authors tag. See the copyright.txt in the distribution for a
   * full listing of individual contributors.
   *
   * This is free software; you can redistribute it and/or modify it
   * under the terms of the GNU Lesser General Public License as
   * published by the Free Software Foundation; either version 2.1 of
   * the License, or (at your option) any later version.
   *
   * This software is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
   * Lesser General Public License for more details.
   *
   * You should have received a copy of the GNU Lesser General Public
   * License along with this software; if not, write to the Free
   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
   */
  package org.jboss.test.remoting.transport.multiplex;
  
  import java.util.HashMap;
  
  import org.jboss.remoting.Client;
  import org.jboss.remoting.InvokerLocator;
  
  import junit.framework.TestCase;
  
  /**
   * This class tests what happens when a 
   * <p>
   * <ol>
   *  <li>a <code>Connector</code> starts;
   *  <li>a <code>Client</code> connects to the <code>Connector</code>;
   *  <li>the <code>Connector</code> stops; and 
   *  <li>then the <code>Client</code> disconnects.
   * </ol>
   * <p>
   * The <code>Client</code> should be able to disconnect gracefully, without exceptions.
   * <p>
   * @author <a href="mailto:ron.sigal at jboss.com">Ron Sigal</a>
   * <p>
   * Copyright (c) Jul 20, 2006
   * </p>
   */
  public class LateClientShutdownTestClient extends TestCase
  {
     public void testShutdown()
     {
        HashMap conf = new HashMap();
        conf.put(InvokerLocator.FORCE_REMOTE, "true");
        try
        {
           Client client = new Client(new InvokerLocator(LateClientShutdownTestServer.serverLocatorURI), conf);
           System.out.println("connecting client");
           client.connect();
           System.out.println("client connected");
           Thread.sleep(5000);
           System.out.println("client disconnecting");
           client.disconnect();
           System.out.println("client disconnected");
        }
        catch (Exception e)
        {
           e.printStackTrace();
           fail();
        }
     }
  }
  
  
  
  1.1      date: 2006/07/20 07:29:25;  author: rsigal;  state: Exp;JBossRemoting/src/tests/org/jboss/test/remoting/transport/multiplex/LateClientShutdownTestServer.java
  
  Index: LateClientShutdownTestServer.java
  ===================================================================
  /*
   * JBoss, Home of Professional Open Source
   * Copyright 2006, JBoss Inc., and individual contributors as indicated
   * by the @authors tag. See the copyright.txt in the distribution for a
   * full listing of individual contributors.
   *
   * This is free software; you can redistribute it and/or modify it
   * under the terms of the GNU Lesser General Public License as
   * published by the Free Software Foundation; either version 2.1 of
   * the License, or (at your option) any later version.
   *
   * This software is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
   * Lesser General Public License for more details.
   *
   * You should have received a copy of the GNU Lesser General Public
   * License along with this software; if not, write to the Free
   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
   */
  package org.jboss.test.remoting.transport.multiplex;
  
  import org.jboss.jrunit.extensions.ServerTestCase;
  import org.jboss.remoting.transport.Connector;
  
  public class LateClientShutdownTestServer extends ServerTestCase
  {
     public static String serverLocatorURI = "multiplex://localhost:4455";
     
     static class Server extends Thread
     {
        public void run()
        {
           Connector connector = new Connector(serverLocatorURI);
           try
           {
              connector.create();
              connector.start();
              System.out.println("server started");
              Thread.sleep(4000);
              connector.stop();
              System.out.println("server stopped");
           }
           catch (Exception e)
           {
              e.printStackTrace();
           }
        }
     }
     
     public void setUp()
     {
        new Server().start();
        System.out.println("server started");
     }
     
     public static void main(String[] args)
     {
        new Server().start();
     }
  }
  
  
  
  1.1      date: 2006/07/20 07:29:25;  author: rsigal;  state: Exp;JBossRemoting/src/tests/org/jboss/test/remoting/transport/multiplex/LateClientShutdownTestCase.java
  
  Index: LateClientShutdownTestCase.java
  ===================================================================
  /*
   * JBoss, Home of Professional Open Source
   * Copyright 2006, JBoss Inc., and individual contributors as indicated
   * by the @authors tag. See the copyright.txt in the distribution for a
   * full listing of individual contributors.
   *
   * This is free software; you can redistribute it and/or modify it
   * under the terms of the GNU Lesser General Public License as
   * published by the Free Software Foundation; either version 2.1 of
   * the License, or (at your option) any later version.
   *
   * This software is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
   * Lesser General Public License for more details.
   *
   * You should have received a copy of the GNU Lesser General Public
   * License along with this software; if not, write to the Free
   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
   */
  package org.jboss.test.remoting.transport.multiplex;
  
  import org.jboss.jrunit.harness.TestDriver;
  
  public class LateClientShutdownTestCase extends TestDriver
  {
     public void declareTestClasses()
     {
        addTestClasses(LateClientShutdownTestClient.class.getName(),
                       1,
                       LateClientShutdownTestServer.class.getName());
  
     }
     
     protected long getResultsTimeout()
     {
        return 200000;
     }
  }
  
  
  



More information about the jboss-cvs-commits mailing list