avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hamm...@apache.org
Subject cvs commit: jakarta-avalon-excalibur/altrmi/src/test/org/apache/excalibur/altrmi/test/hackers BouncingServerTestCase.java
Date Sun, 05 Jan 2003 22:38:26 GMT
hammant     2003/01/05 14:38:26

  Added:       altrmi/src/test/org/apache/excalibur/altrmi/test/invalidstate
                        BouncingServerTestCase.java
  Removed:     altrmi/src/test/org/apache/excalibur/altrmi/test/hackers
                        BouncingServerTestCase.java
  Log:
  Under advice fron Nicola, a package is renamed.
  
  Revision  Changes    Path
  1.1                  jakarta-avalon-excalibur/altrmi/src/test/org/apache/excalibur/altrmi/test/invalidstate/BouncingServerTestCase.java
  
  Index: BouncingServerTestCase.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.excalibur.altrmi.test.invalidstate;
  
  import junit.framework.TestCase;
  import org.apache.excalibur.altrmi.server.impl.socket.CompleteSocketCustomStreamServer;
  import org.apache.excalibur.altrmi.server.PublicationDescription;
  import org.apache.excalibur.altrmi.server.AltrmiServerException;
  import org.apache.excalibur.altrmi.server.PublicationException;
  import org.apache.excalibur.altrmi.test.TestInterfaceImpl;
  import org.apache.excalibur.altrmi.test.TestInterface;
  import org.apache.excalibur.altrmi.test.TestInterface3;
  import org.apache.excalibur.altrmi.test.TestInterface2;
  import org.apache.excalibur.altrmi.client.impl.ClientClassAltrmiFactory;
  import org.apache.excalibur.altrmi.client.impl.NeverConnectionPinger;
  import org.apache.excalibur.altrmi.client.impl.DumbConnectionListener;
  import org.apache.excalibur.altrmi.client.impl.socket.SocketCustomStreamHostContext;
  import org.apache.excalibur.altrmi.client.AltrmiHostContext;
  import org.apache.excalibur.altrmi.client.AltrmiClientInvocationHandler;
  import org.apache.excalibur.altrmi.common.NoSuchSessionException;
  
  
  /**
   * Tests concerning the bouncing of a server.
   * @author Paul Hammant
   */
  public class BouncingServerTestCase extends TestCase
  {
  
      public BouncingServerTestCase(String name)
      {
          super(name);
      }
  
      public void testBouncingOfServerCausesClientProblems() throws Exception
      {
  
          // server side setup.
          CompleteSocketCustomStreamServer server = startServer();
  
          ClientClassAltrmiFactory altrmiFactory = null;
          try
          {
  
              // Client side setup
              altrmiFactory = new ClientClassAltrmiFactory(false);
              AltrmiHostContext hc = new SocketCustomStreamHostContext("127.0.0.1", 12101);
  
              altrmiFactory.setHostContext(hc, false);
              AltrmiClientInvocationHandler ih = hc.getClientInvocationHandler();
              ih.setConnectionPinger(new NeverConnectionPinger());
              ih.setAltrmiConnectionListener(new DumbConnectionListener());
              TestInterface testClient = (TestInterface) altrmiFactory.lookup("Hello");
  
              // just a kludge for unit testing given we are intrinsically dealing with
              // threads, AltRMI being a client/server thing
              Thread.yield();
  
              int i = testClient.hello2(100);
  
              // Stop server and restarting (essentially binning sessions).
              server.stop();
              server = startServer();
  
              try
              {
                  i = testClient.hello2(123);
              }
              catch (NoSuchSessionException e)
              {
                  // expected
              }
  
  
          }
          finally
          {
              System.gc();
              Thread.yield();
              altrmiFactory.close();
              Thread.yield();
              server.stop();
              Thread.yield();
          }
      }
  
      private CompleteSocketCustomStreamServer startServer() throws AltrmiServerException,
PublicationException
      {
          CompleteSocketCustomStreamServer server = new CompleteSocketCustomStreamServer(12101);
          TestInterfaceImpl testServer = new TestInterfaceImpl();
          PublicationDescription pd = new PublicationDescription(TestInterface.class,
                  new Class[]{TestInterface3.class, TestInterface2.class});
          server.publish(testServer, "Hello", pd);
          server.start();
          return server;
      }
  
  }
  
  
  

--
To unsubscribe, e-mail:   <mailto:avalon-cvs-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-cvs-help@jakarta.apache.org>


Mime
View raw message