incubator-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hamm...@apache.org
Subject cvs commit: incubator-altrmi status.xml
Date Sun, 16 Feb 2003 15:58:09 GMT
hammant     2003/02/16 07:58:09

  Added:       src/test/org/apache/altrmi/test/generator
                        BCELProxyGeneratorTestCase.java
                        TestInvocationHandler.java TestRemoteInterface.java
               src/test/org/apache/altrmi/test/invalidstate
                        BouncingServerTestCase.java
               src/test/org/apache/altrmi/test/misc
                        DefaultConnectionPingerTestCase.java
               src/test/org/apache/altrmi/test/mismatch
                        SocketMismatchTestCase.java
               src/test/org/apache/altrmi/test/piped
                        PipedCustomStreamTestCase.java
                        PipedObjectStreamTestCase.java
               src/test/org/apache/altrmi/test/proxies
                        CodedProxyTestCase.java
                        CodedProxyTestInterfaceProxy.java DynamicProxy.java
                        DynamicProxyTestCase.java NonProxyTestCase.java
               src/test/org/apache/altrmi/test/remotable
                        RemotableDescriptorTestCase.java
               src/test/org/apache/altrmi/test/rmi RmiTestCase.java
               src/test/org/apache/altrmi/test/socket
                        CallbackEnabledCustomStreamTestCase.java
                        CustomStreamJNDITestCase.java
                        CustomStreamOptmizedTestCase.java
                        CustomStreamTestCase.java
                        JSXObjectStreamTestCase.java
                        MyTestCallBackListener.java
                        ObjectStreamTestCase.java
               .        status.xml
  Log:
  First cut of AltRMI
  
  Revision  Changes    Path
  1.1                  incubator-altrmi/src/test/org/apache/altrmi/test/generator/BCELProxyGeneratorTestCase.java
  
  Index: BCELProxyGeneratorTestCase.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.altrmi.test.generator;
  
  import java.lang.reflect.Constructor;
  import java.lang.reflect.Method;
  
  import junit.framework.TestCase;
  
  import org.apache.altrmi.client.impl.DefaultProxyHelper;
  import org.apache.altrmi.client.impl.direct.DirectHostContext;
  import org.apache.altrmi.client.impl.ClientSideClassFactory;
  import org.apache.altrmi.common.ProxyGenerator;
  import org.apache.altrmi.generator.BCELProxyGeneratorImpl;
  import org.apache.altrmi.server.PublicationDescriptionItem;
  
  
  
  /**
   * Class BCELProxyGeneratorTest
   *     Unit testing of BCELProxyGeneratorImpl
   * @version     1.0
   * @author <a href="mailto:vinayc77@yahoo.com">Vinay Chandran</a>
   */
  public class BCELProxyGeneratorTestCase  extends TestCase
  { 
      private ProxyGenerator mProxyGenerator;
      private Class mGeneratedProxyClass;
      private Object mGeneratedProxyObject; 
  	private ClientSideClassFactory mAltrmiFactory;
      /************************ TestInterface *******************/
      public  static final Class mTestInterfaceClass=//org.apache.altrmi.test.TestInterface.class;
                                                       TestRemoteInterface.class;
      public BCELProxyGeneratorTestCase(String testName)
      {
          super(testName);
      }
   
      private Class _createNewClass()
      {
          if(mGeneratedProxyClass!=null)
              return mGeneratedProxyClass;
          mProxyGenerator.setGenName("Something");
          mProxyGenerator.setInterfacesToExpose(new PublicationDescriptionItem[]{
              new PublicationDescriptionItem(mTestInterfaceClass)});
          mProxyGenerator.setClassGenDir(".");
          mProxyGenerator.verbose(true);
          mProxyGenerator.generateClass(null);
          
          
          mGeneratedProxyClass=((BCELProxyGeneratorImpl)mProxyGenerator).getGeneratedClass("AltrmiGeneratedSomething_Main");
          return mGeneratedProxyClass;
      }
  
  
  
      /*
       * @see TestCase#setUp()
       */
      protected void setUp() throws Exception
      {
          try
          {
              mProxyGenerator =
                  (ProxyGenerator) Class
                      .forName("org.apache.altrmi.generator.BCELProxyGeneratorImpl")
                          .newInstance();
          }
          catch (Exception e)
          {
              e.printStackTrace();
  
              throw new RuntimeException("PrimaryGenerator Impl jar not in m_classpath");
          }
          //create the Proxy Class using the BCEL Generator
          _createNewClass();    
          mProxyGenerator.verbose(true);
  		//create the factory;
  		mAltrmiFactory=new ClientSideClassFactory();
      }
      
      
      /**
       * Method testGeneratedClassName.
       *     Checks whether 'Class' is created properly
       */
      public void testGeneratedClassNameOfProxy()
      {
          assertNotNull(mProxyGenerator);
          assertNotNull(mGeneratedProxyClass);
          assertEquals(mGeneratedProxyClass.getName().equals("AltrmiGeneratedSomething_Main"),true);
      }
  
      /**
       * Method testConstructorOfProxy.
       *     Test if the instance is created properly using the lone 
       *         Constructor embedded within the Proxy implementation
       * @throws Exception
       */
      public void testConstructorOfProxy() throws Exception
      {
          if(mGeneratedProxyClass==null)
              testGeneratedClassNameOfProxy();
          TestInvocationHandler invocationHandler =new TestInvocationHandler();
  		mAltrmiFactory.setHostContext(new DirectHostContext(invocationHandler));
          DefaultProxyHelper defaultProxyHelper = 
                              new DefaultProxyHelper(mAltrmiFactory,
                                                    invocationHandler,
                                                    "PublishedName",
                                                    "ObjectName",
                                                    new Long(1010),
                                                    new Long(3030));
      
          Constructor[] _constructors=  mGeneratedProxyClass.getConstructors();
          //there shld be only 1 constructor for the generated proxy
          // one that takes BaseServedObject as the argument
          assertEquals(_constructors.length,1);
      
          mGeneratedProxyObject = _constructors[0].newInstance(new Object[]{defaultProxyHelper});
          assertNotNull(mGeneratedProxyObject);
              
      }
      
      
      /**
       * Method testGetReferenceIDMethodOfProxy.
       *     Testing 
       * =================================
       * public Long altrmiGetReferenceID(Object factoryThatIsAsking) {
       *   return mBaseServedObject.getReferenceID(factoryThatIsAsking);
       *    }
       * =================================
       * @throws Exception
       */
      public void testGetReferenceIDMethodOfProxy() throws Exception
      {
          if(mGeneratedProxyObject==null)
              testConstructorOfProxy();
          
          Method _getReferenceIDMethod = mGeneratedProxyClass.getMethod("altrmiGetReferenceID",new Class[]{Object.class});
          assertNotNull(_getReferenceIDMethod);
          Object _ret = _getReferenceIDMethod.invoke(mGeneratedProxyObject,new Object[]{mAltrmiFactory});
          assertEquals(new Long(1010),_ret);
      }
  
      /**
       * Method testGeneratedMethodsPassOne.
       *     Testing
       * This test involves the crux of the stub-generation  
       * routine.
       * 1. Pass an test interface for stub-generation
       * 2. Test the created stub
       * @throws Exception
       */
      public void testGeneratedMethodsPassOne() throws Exception
      {
          if(mGeneratedProxyObject==null)
              testConstructorOfProxy();
          
          
          Method[] __fooMethods = mGeneratedProxyClass.getMethods();
          for(int i=0;i<__fooMethods.length;i++)
          {
              if(__fooMethods[i].getName().indexOf("test")==-1)
              {
                  continue;
              }
              //System.out.println("Testing method["+__fooMethods[i].getName()+"]");
              Object[] _arguments= new Object[__fooMethods[i].getParameterTypes().length];
              for(int j=0;j<_arguments.length;j++)
              {
                  
                  _arguments[j]=mTestInterfaceClass.getField(__fooMethods[i].getName()+"_arg"+j).get(null);
                  //System.out.println("argType["+__fooMethods[i].getParameterTypes()[j]+"]arg["+j+"]"+_arguments[j]);
              }
              if(__fooMethods[i].getParameterTypes().length==0)
                  _arguments=null;
              Object _ret=__fooMethods[i].invoke(mGeneratedProxyObject,_arguments);
              
              if(__fooMethods[i].getReturnType()!=Void.TYPE)
              {
                  assertEquals(mTestInterfaceClass.getField(__fooMethods[i].getName()+"_retValue").get(null),_ret);
              }
          }
      }
      
  }
  
  
  
  1.1                  incubator-altrmi/src/test/org/apache/altrmi/test/generator/TestInvocationHandler.java
  
  Index: TestInvocationHandler.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.altrmi.test.generator;
  
  import java.lang.reflect.Method;
  
  import org.apache.altrmi.client.impl.AbstractClientInvocationHandler;
  import org.apache.altrmi.common.Reply;
  import org.apache.altrmi.common.Request;
  import org.apache.altrmi.common.ExceptionReply;
  import org.apache.altrmi.common.MethodReply;
  import org.apache.altrmi.common.MethodRequest;
  import org.apache.altrmi.common.OpenConnectionReply;
  import org.apache.altrmi.common.OpenConnectionRequest;
  import org.apache.altrmi.server.ServerInvocationHandler;
  
  /**
   * TestInvocationHandler 
   * @version     1.0
   * @author <a href="mailto:vinayc77@yahoo.com">Vinay Chandran</a>
   */
  public class TestInvocationHandler extends AbstractClientInvocationHandler implements ServerInvocationHandler{
  
  
      public Reply handleInvocation(Request request)
      {
          return handleInvocation(request, "test");
      }
  
      public Reply handleInvocation(Request request, Object connectionDetails)
      {
          if(request instanceof OpenConnectionRequest)
          {
              return new OpenConnectionReply();
          }
          else if(request instanceof MethodRequest)
          {
              MethodRequest methodRequest = (MethodRequest) request;
              //System.out.println("methodRequest[" + methodRequest.getMethodSignature() + "]");
              Method[] methods = TestRemoteInterface.class.getMethods();
              for (int i = 0; i < methods.length; i++) 
              {
                  try
                  {
                      if (methodRequest.getMethodSignature().indexOf(methods[i].getName()) != -1)
                      {
                          Object[] _arguments=methodRequest.getArgs();
                          for(int j=0;j<_arguments.length;j++)
                          {    
                              
                              if(!TestRemoteInterface.class.getField(methods[i].getName() + "_arg"+j).get(null).equals(_arguments[j]))
                              {
                                  return new ExceptionReply(new Exception(methodRequest.getMethodSignature()+": arguments not marshalled correctly \n expected["+TestRemoteInterface.class.getField(methods[i].getName() + "_arg"+j).get(null)+"] received["+_arguments[j]+"]"));
                              }
                          }
                          MethodReply methodReply =null;
                          if(methods[i].getReturnType()!=Void.TYPE)
                          
                              methodReply =
                                  new MethodReply(
                                      TestRemoteInterface.class.getField(methods[i].getName() + "_retValue").get(null));
                          else
                              methodReply =new MethodReply();                
                          return methodReply;
                      }
                  }
                  catch(Exception e)
                  {
                      e.printStackTrace();
                      return new ExceptionReply(e);
                  }
              
              }
          }
          return null;
      }
      /*
       * @see AbstractClientInvocationHandler#tryReconnect()
       */
      protected boolean tryReconnect()
      {
          return true;
      }
      /*
       * @see ClientInvocationHandler#getLastRealRequest()
       */
      public long getLastRealRequest()
      {
          return 0;
      }
  
  }
  
  
  1.1                  incubator-altrmi/src/test/org/apache/altrmi/test/generator/TestRemoteInterface.java
  
  Index: TestRemoteInterface.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.altrmi.test.generator;
  /**
   * Interface TestRemoteInterface
   * Test Interface for which the stub would be generated
   *     The test is automated in the sense given the input args and expected
   *     return of the function and the testcase will test for the same .
   *     The method is invoked on the BCEL generated  proxy and then 
   *     the invocationhandler associated with the proxy  will
   *     be used to complete the test cycle for the client side stub
   * @version     1.0
   * @author <a href="mailto:vinayc77@yahoo.com">Vinay Chandran</a>
   */
  public interface TestRemoteInterface
  {
      
      String test0(String name);
      String test0_arg0="a for altrmi";
      String test0_retValue="b for bat";
      
      
      String test1(int me);
      String test1_retValue="c for cat";
      Integer test1_arg0=new Integer(1);
      
      
      int test2(int you,String str);
      Integer test2_retValue=new Integer(7654);
      Integer test2_arg0=new Integer(1);
      String test2_arg1=new String("d for dog");
      
      Integer test3();
      Integer test3_retValue=new Integer(1010);
      
      float test4();
      Float test4_retValue=new Float(100.10);
      
      
      byte test6(byte[] lotsofdata);
      byte[] test6_arg0=new byte[100];
      byte test6_retValue=(byte)10;
       
      double test5(int[] ia , String[] sa);
      int[] test5_arg0={1,2,3};
      String[] test5_arg1={"a","b","z"};
      Double test5_retValue=new Double(1010.4545);
      
      void test7();
      Float test7_arg0=new Float(10);
      
      StringBuffer test8(String something);
      String test8_arg0="";
      StringBuffer test8_retValue=new StringBuffer("I am here , Where are you?");
      
      StringBuffer test9( float f, double d1,Long d2 ,double s3,String s);
      Float test9_arg0=new Float(10);
      Double test9_arg1=new Double(1000);
      Long test9_arg2=new Long(1000);
      Double test9_arg3=new Double(1000);    
      String test9_arg4=new String("s for so long, are you a fool");
      StringBuffer test9_retValue=new StringBuffer("e for elephant");
      
      
      
      
      
  }
  
  
  1.1                  incubator-altrmi/src/test/org/apache/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.altrmi.test.invalidstate;
  
  import junit.framework.TestCase;
  import org.apache.altrmi.server.impl.socket.CompleteSocketCustomStreamServer;
  import org.apache.altrmi.server.PublicationDescription;
  import org.apache.altrmi.server.ServerException;
  import org.apache.altrmi.server.PublicationException;
  import org.apache.altrmi.test.TestInterfaceImpl;
  import org.apache.altrmi.test.TestInterface;
  import org.apache.altrmi.test.TestInterface3;
  import org.apache.altrmi.test.TestInterface2;
  import org.apache.altrmi.client.impl.ClientSideClassFactory;
  import org.apache.altrmi.client.impl.NeverConnectionPinger;
  import org.apache.altrmi.client.impl.DumbClientMonitor;
  import org.apache.altrmi.client.impl.socket.SocketCustomStreamHostContext;
  import org.apache.altrmi.client.HostContext;
  import org.apache.altrmi.client.ClientInvocationHandler;
  import org.apache.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();
  
          ClientSideClassFactory altrmiFactory = null;
          try
          {
  
              // Client side setup
              altrmiFactory = new ClientSideClassFactory();
              HostContext hc = new SocketCustomStreamHostContext("127.0.0.1", 12201);
  
              altrmiFactory.setHostContext(hc, false);
              ClientInvocationHandler ih = hc.getClientInvocationHandler();
              ih.setConnectionPinger(new NeverConnectionPinger());
              ih.setClientMonitor(new DumbClientMonitor());
              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 ServerException, PublicationException
      {
          CompleteSocketCustomStreamServer server = new CompleteSocketCustomStreamServer(12201);
          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;
      }
  
  }
  
  
  
  1.1                  incubator-altrmi/src/test/org/apache/altrmi/test/misc/DefaultConnectionPingerTestCase.java
  
  Index: DefaultConnectionPingerTestCase.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.altrmi.test.misc;
  
  import junit.framework.TestCase;
  import org.apache.altrmi.test.DummyInvocationHandler;
  import org.apache.altrmi.client.impl.DefaultConnectionPinger;
  import org.apache.altrmi.common.DefaultThreadPool;
  
  public class DefaultConnectionPingerTestCase extends TestCase
  {
  
      public DefaultConnectionPingerTestCase(String name)
      {
          super(name);
      }
  
      protected void setUp() throws Exception
      {
          super.setUp();
      }
  
      public void testBasic() throws Exception
      {
          DefaultConnectionPinger pinger = new DefaultConnectionPinger(1L,10000L);
          DummyInvocationHandler dummy = new DummyInvocationHandler();
          dummy.setThreadPool(new DefaultThreadPool());
          pinger.setInvocationHandler(dummy);
          pinger.start();
          Thread.sleep(1000);
          assertTrue("Should have pinged", dummy.isPinged());
          pinger.stop();
          dummy.reset();
          Thread.sleep(1000);
          assertTrue("Should have stopped pinging", !dummy.isPinged());
  
      }
  
  }
  
  
  
  1.1                  incubator-altrmi/src/test/org/apache/altrmi/test/mismatch/SocketMismatchTestCase.java
  
  Index: SocketMismatchTestCase.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.altrmi.test.mismatch;
  
  import junit.framework.TestCase;
  import org.apache.altrmi.server.impl.socket.CompleteSocketCustomStreamServer;
  import org.apache.altrmi.server.impl.socket.CompleteSocketObjectStreamServer;
  import org.apache.altrmi.server.impl.rmi.RmiServer;
  import org.apache.altrmi.server.PublicationDescription;
  import org.apache.altrmi.test.TestInterfaceImpl;
  import org.apache.altrmi.test.TestInterface;
  import org.apache.altrmi.test.TestInterface3;
  import org.apache.altrmi.test.TestInterface2;
  import org.apache.altrmi.client.impl.ClientSideClassFactory;
  import org.apache.altrmi.client.impl.rmi.RmiHostContext;
  import org.apache.altrmi.client.impl.socket.SocketCustomStreamHostContext;
  import org.apache.altrmi.client.impl.socket.SocketObjectStreamHostContext;
  import org.apache.altrmi.common.BadConnectionException;
  
  /**
   * Test Custom Stream over sockets.
   * @author Paul Hammant
   */
  public class SocketMismatchTestCase extends TestCase
  {
  
  
      public SocketMismatchTestCase(String name)
      {
          super(name);
      }
  
      public void testCustomStreamObjectStreamMismatch() throws Exception
      {
  
          // server side setup.
          CompleteSocketCustomStreamServer server = new CompleteSocketCustomStreamServer(12001);
          TestInterfaceImpl testServer = new TestInterfaceImpl();
          PublicationDescription pd = new PublicationDescription(TestInterface.class,
                  new Class[]{TestInterface3.class, TestInterface2.class});
          server.publish(testServer, "Hello", pd);
          server.start();
  
          ClientSideClassFactory altrmiFactory = null;
          try
          {
  
              // Client side setup
              altrmiFactory = new ClientSideClassFactory();
              altrmiFactory.setHostContext(new SocketObjectStreamHostContext("127.0.0.1", 12001), false);
              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();
  
              testClient.hello("hello");
              fail("CustomStreams and ObjectStreams cannot interoperate");
          }
          catch (BadConnectionException bce)
          {
              // expected.
          }
          finally
          {
  
              System.gc();
              Thread.yield();
  
              try
              {
                  altrmiFactory.close();
              }
              catch (Exception e)
              {
              }
              Thread.yield();
              server.stop();
              Thread.yield();
          }
      }
  
      public void dont_testObjectStreamCustomStreamMismatch() throws Exception
      {
  
          // server side setup.
          CompleteSocketObjectStreamServer server = new CompleteSocketObjectStreamServer(12002);
          TestInterfaceImpl testServer = new TestInterfaceImpl();
          PublicationDescription pd = new PublicationDescription(TestInterface.class,
                  new Class[]{TestInterface3.class, TestInterface2.class});
          server.publish(testServer, "Hello", pd);
          server.start();
  
          ClientSideClassFactory altrmiFactory = null;
          try
          {
  
              // Client side setup
              altrmiFactory = new ClientSideClassFactory();
              altrmiFactory.setHostContext(new SocketCustomStreamHostContext("127.0.0.1", 12002), false);
              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();
  
              testClient.hello("hello");
              fail("CustomStreams and ObjectStreams cannot interoperate");
          }
          catch (BadConnectionException bce)
          {
              // expected.
          }
          finally
          {
  
              System.gc();
              Thread.yield();
  
              try
              {
                  altrmiFactory.close();
              }
              catch (Exception e)
              {
              }
              Thread.yield();
              server.stop();
              Thread.yield();
          }
      }
  
  
      public void dont_testCustomStreamRmiMismatch() throws Exception
      {
  
          // server side setup.
          CompleteSocketCustomStreamServer server = new CompleteSocketCustomStreamServer(12003);
          TestInterfaceImpl testServer = new TestInterfaceImpl();
          PublicationDescription pd = new PublicationDescription(TestInterface.class,
                  new Class[]{TestInterface3.class, TestInterface2.class});
          server.publish(testServer, "Hello", pd);
          server.start();
  
          ClientSideClassFactory altrmiFactory = null;
          try
          {
  
              // Client side setup
              altrmiFactory = new ClientSideClassFactory();
              altrmiFactory.setHostContext(new RmiHostContext("127.0.0.1", 12003), false);
              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();
  
              testClient.hello("hello");
              fail("CustomStreams and RMI trasnports cannot interoperate");
          }
          catch (BadConnectionException bce)
          {
              // expected.
          }
          finally
          {
  
              System.gc();
              Thread.yield();
  
              try
              {
                  altrmiFactory.close();
              }
              catch (Exception e)
              {
              }
              Thread.yield();
              server.stop();
              Thread.yield();
          }
      }
  
      public void dont_testRmiCustomStreamMismatch() throws Exception
      {
  
          // server side setup.
          RmiServer server = new RmiServer("127.0.0.1", 12004);
          TestInterfaceImpl testServer = new TestInterfaceImpl();
          PublicationDescription pd = new PublicationDescription(TestInterface.class,
                  new Class[]{TestInterface3.class, TestInterface2.class});
          server.publish(testServer, "Hello", pd);
          server.start();
  
          ClientSideClassFactory altrmiFactory = null;
          try
          {
  
              // Client side setup
              altrmiFactory = new ClientSideClassFactory();
              altrmiFactory.setHostContext(new SocketCustomStreamHostContext("127.0.0.1", 12004), false);
              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();
  
              testClient.hello("hello");
              fail("CustomStreams and RMI trasnports cannot interoperate");
          }
          catch (BadConnectionException bce)
          {
              // expected.
          }
          finally
          {
  
              System.gc();
              Thread.yield();
  
              try
              {
                  altrmiFactory.close();
              }
              catch (Exception e)
              {
              }
              Thread.yield();
              server.stop();
              Thread.yield();
          }
      }
  
  }
  
  
  
  1.1                  incubator-altrmi/src/test/org/apache/altrmi/test/piped/PipedCustomStreamTestCase.java
  
  Index: PipedCustomStreamTestCase.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.altrmi.test.piped;
  
  import org.apache.altrmi.client.impl.ClientSideClassFactory;
  import org.apache.altrmi.client.impl.piped.PipedCustomStreamHostContext;
  import org.apache.altrmi.client.Factory;
  
  import org.apache.altrmi.server.impl.piped.PipedCustomStreamServer;
  import org.apache.altrmi.server.PublicationDescription;
  import org.apache.altrmi.test.TestInterface;
  import org.apache.altrmi.test.AbstractHelloTestCase;
  import org.apache.altrmi.test.TestInterfaceImpl;
  import org.apache.altrmi.test.TestInterface2;
  import org.apache.altrmi.test.TestInterface3;
  
  import java.io.PipedInputStream;
  import java.io.PipedOutputStream;
  
  /**
   * Test Piped Trasnport (Custom Stream)
   * @author Paul Hammant
   */
  public class PipedCustomStreamTestCase extends AbstractHelloTestCase
  {
  
  
      public PipedCustomStreamTestCase(String name)
      {
          super(name);
      }
  
      protected void setUp() throws Exception
      {
          super.setUp();
  
          // server side setup.
          server = new PipedCustomStreamServer();
          testServer = new TestInterfaceImpl();
          PublicationDescription pd = new PublicationDescription(TestInterface.class,
                  new Class[] { TestInterface3.class, TestInterface2.class });
          server.publish(testServer, "Hello", pd);
          server.start();
  
          // For piped, server and client can see each other
          PipedInputStream in = new PipedInputStream();
          PipedOutputStream out = new PipedOutputStream();
          ((PipedCustomStreamServer) server).makeNewConnection(in, out);
  
          // Client side setup
          altrmiFactory = new ClientSideClassFactory();
          altrmiFactory.setHostContext(new PipedCustomStreamHostContext(in, out));
          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();
      }
  
      protected void tearDown() throws Exception
      {
          testClient = null;
          System.gc();
          Thread.yield();
          altrmiFactory.close();
          Thread.yield();
          server.stop();
          Thread.yield();
          server = null;
          testServer = null;
          super.tearDown();
      }
  
  
  }
  
  
  
  1.1                  incubator-altrmi/src/test/org/apache/altrmi/test/piped/PipedObjectStreamTestCase.java
  
  Index: PipedObjectStreamTestCase.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.altrmi.test.piped;
  
  import org.apache.altrmi.client.impl.ClientSideClassFactory;
  import org.apache.altrmi.client.impl.piped.PipedObjectStreamHostContext;
  import org.apache.altrmi.client.Factory;
  
  import org.apache.altrmi.server.impl.piped.PipedObjectStreamServer;
  import org.apache.altrmi.server.PublicationDescription;
  import org.apache.altrmi.test.TestInterface;
  import org.apache.altrmi.test.AbstractHelloTestCase;
  import org.apache.altrmi.test.TestInterfaceImpl;
  import org.apache.altrmi.test.TestInterface3;
  import org.apache.altrmi.test.TestInterface2;
  
  import java.io.PipedInputStream;
  import java.io.PipedOutputStream;
  
  /**
   * Test Piped Trasnport (Object Stream)
   * @author Paul Hammant
   */
  public class PipedObjectStreamTestCase extends AbstractHelloTestCase
  {
  
  
      public PipedObjectStreamTestCase(String name)
      {
          super(name);
  
          // See http://developer.java.sun.com/developer/bugParade/bugs/4499841.html
          // This bug prevents ObjectStream from functioning correctly when used
          // by AltRMI.  You can still use the ObjectStream transports, but
          // should be aware of the limitations.  See testBugParadeBugNumber4499841()
          // in the parent class.
          testForBug4499841 = false;
  
      }
  
      protected void setUp() throws Exception
      {
          super.setUp();
  
          // server side setup.
          server = new PipedObjectStreamServer();
          testServer = new TestInterfaceImpl();
          PublicationDescription pd = new PublicationDescription(TestInterface.class,
                  new Class[] { TestInterface3.class, TestInterface2.class });
          server.publish(testServer, "Hello", pd);
          server.start();
  
          // For piped, server and client can see each other
          PipedInputStream in = new PipedInputStream();
          PipedOutputStream out = new PipedOutputStream();
          ((PipedObjectStreamServer) server).makeNewConnection(in, out);
  
          // Client side setup
          altrmiFactory = new ClientSideClassFactory();
          altrmiFactory.setHostContext(new PipedObjectStreamHostContext(in, out));
          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();
      }
  
      protected void tearDown() throws Exception
      {
  
          testClient = null;
          System.gc();
          Thread.yield();
          altrmiFactory.close();
          Thread.yield();
          server.stop();
          Thread.yield();
          server = null;
          testServer = null;
          super.tearDown();
      }
  
  
  }
  
  
  
  1.1                  incubator-altrmi/src/test/org/apache/altrmi/test/proxies/CodedProxyTestCase.java
  
  Index: CodedProxyTestCase.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.altrmi.test.proxies;
  
  import org.apache.altrmi.test.TestInterfaceImpl;
  import org.apache.altrmi.test.AbstractHelloCallBackTestCase;
  
  /**
   * Test Hand Coded Proxy for comparison sake
   * @author Paul Hammant
   */
  public class CodedProxyTestCase extends AbstractHelloCallBackTestCase
  {
  
  
      public CodedProxyTestCase(String name)
      {
          super(name);
      }
  
      protected void setUp() throws Exception
      {
          super.setUp();
  
          testServer = new TestInterfaceImpl();
          testClient = new CodedProxyTestInterfaceProxy( testServer );
  
      }
  
  }
  
  
  
  1.1                  incubator-altrmi/src/test/org/apache/altrmi/test/proxies/CodedProxyTestInterfaceProxy.java
  
  Index: CodedProxyTestInterfaceProxy.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.altrmi.test.proxies;
  
  import java.beans.PropertyVetoException;
  import java.io.IOException;
  import org.apache.altrmi.test.TestInterface;
  import org.apache.altrmi.test.TestInterface2;
  import org.apache.altrmi.test.TestObject;
  import org.apache.altrmi.test.TestCallBackListener;
  
  /**
   * Class CodedProxyTestInterfaceProxy
   *
   *
   * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
   * @version $Revision: 1.1 $
   */
  public class CodedProxyTestInterfaceProxy implements TestInterface
  {
  
      private TestInterface m_actualImpl;
  
      /**
       * Constructor CodedProxyTestInterfaceProxy
       *
       *
       * @param actualImpl
       *
       */
      public CodedProxyTestInterfaceProxy( TestInterface actualImpl )
      {
          m_actualImpl = actualImpl;
      }
  
      /**
       * Method hello
       *
       *
       * @param greeting
       *
       */
      public void hello( String greeting )
      {
          m_actualImpl.hello( greeting );
      }
  
      /**
       * Method hello2
       *
       *
       * @param greeting
       *
       */
      public int hello2( int greeting )
      {
          return m_actualImpl.hello2( greeting );
      }
  
      /**
       * Method hello3
       *
       *
       * @param greeting
       *
       * @return
       *
       * @throws IOException
       * @throws PropertyVetoException
       *
       */
      public boolean hello3( short greeting ) throws PropertyVetoException, IOException
      {
          return m_actualImpl.hello3( greeting );
      }
  
      /**
       * Method hello4
       *
       *
       * @param greeting1
       * @param greeting2
       *
       * @return
       *
       */
      public StringBuffer hello4( float greeting1, double greeting2 )
      {
          return m_actualImpl.hello4( greeting1, greeting2 );
      }
  
      /**
       * Method testSpeed
       *
       *
       */
      public void testSpeed()
      {
          m_actualImpl.testSpeed();
      }
  
      /**
       * Method makeTestInterface2
       *
       *
       * @param thingName
       *
       * @return
       *
       */
      public TestInterface2 makeTestInterface2( String thingName )
      {
          return m_actualImpl.makeTestInterface2( thingName );
      }
  
      /**
       * Method morphName
       *
       *
       * @param forThisImpl
       *
       */
      public void morphName( TestInterface2 forThisImpl )
      {
          m_actualImpl.morphName( forThisImpl );
      }
  
      /**
       * Method findTestInterface2ByName
       *
       *
       * @param nameToFind
       *
       * @return
       *
       */
      public TestInterface2 findTestInterface2ByName( String nameToFind )
      {
          return m_actualImpl.findTestInterface2ByName( nameToFind );
      }
  
      /**
       * Method getTestInterface2s
       *
       *
       * @return
       *
       */
      public TestInterface2[] getTestInterface2s()
      {
          return m_actualImpl.getTestInterface2s();
      }
  
      /**
       * Method getTestObjects
       * Helps ilustrate the bug http://developer.java.sun.com/developer/bugParade/bugs/4499841.html
       *
       * @return
       *
       */
      public TestObject[] getTestObjects()
      {
          return m_actualImpl.getTestObjects();
      }
  
      /**
       * Method changeTestObjectNames
       * Helps ilustrate the bug http://developer.java.sun.com/developer/bugParade/bugs/4499841.html
       *
       *
       */
      public void changeTestObjectNames()
      {
          m_actualImpl.changeTestObjectNames();
      }
  
      /**
       * Method makeNewTestObjectNames
       * Helps ilustrate the bug http://developer.java.sun.com/developer/bugParade/bugs/4499841.html
       *
       */
      public void makeNewTestObjectNames()
      {
          m_actualImpl.makeNewTestObjectNames();
      }
  
      public boolean addCallBackListener(TestCallBackListener testCallbackListener)
      {
          return m_actualImpl.addCallBackListener(testCallbackListener);
      }
  
      public void ping()
      {
          m_actualImpl.ping();
      }
  
      public String toString()
      {
          return m_actualImpl.toString();
      }
  
      public int hashCode()
      {
          return m_actualImpl.hashCode();
      }
  
  }
  
  
  
  1.1                  incubator-altrmi/src/test/org/apache/altrmi/test/proxies/DynamicProxy.java
  
  Index: DynamicProxy.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.altrmi.test.proxies;
  
  import java.lang.reflect.InvocationHandler;
  import java.lang.reflect.InvocationTargetException;
  import java.lang.reflect.Method;
  import java.lang.reflect.Proxy;
  
  /**
   * Directly copied from Avalon-Excalibur for comparison testing in AltRMI
   *
   *
   * @author <a href="mailto:peter@apache.org">Peter Donald</a>
   * @author <a href="mailto:Paul_Hammant@yahoo.com">Paul Hammant</a>
   * @version CVS $Revision: 1.1 $ $Date: 2003/02/16 15:58:08 $
   * @since 4.0b5
   */
  public final class DynamicProxy implements InvocationHandler
  {
  
      private transient Object m_object;
  
      /**
       * Private constructor that blocks instantiation outside this class.
       *
       * @param object the underlying object
       */
      private DynamicProxy( final Object object )
      {
          m_object = object;
      }
  
      /**
       * Create a proxy object that has all of it's underlying
       * interfaces implemented by proxy.
       *
       * @param object the underling object to proxy
       * @return the proxied object
       */
      public static Object newInstance( final Object object )
      {
          return newInstance( object, object.getClass().getInterfaces() );
      }
  
      /**
       * Create a proxy object that has specified interfaces implemented by proxy.
       *
       * @param object the underling object to proxy
       * @param interfaces
       * @return the proxied object
       */
      public static Object newInstance( final Object object, final Class[] interfaces )
      {
  
          final ClassLoader classLoader = object.getClass().getClassLoader();
          final DynamicProxy proxy = new DynamicProxy( object );
  
          return Proxy.newProxyInstance( classLoader, interfaces, proxy );
      }
  
      /**
       * Invoke the specified method on underlying object.
       * This is called by proxy object.
       *
       * @param proxy the proxy object
       * @param method the method invoked on proxy object
       * @param args the arguments supplied to method
       * @return the return value of method
       * @exception Throwable if an error occurs
       */
      public Object invoke( final Object proxy, final Method method, final Object[] args )
          throws Throwable
      {
  
          try
          {
              return method.invoke( m_object, args );
          }
          catch( final InvocationTargetException ite )
          {
              throw ite.getTargetException();
          }
      }
  }
  
  
  
  1.1                  incubator-altrmi/src/test/org/apache/altrmi/test/proxies/DynamicProxyTestCase.java
  
  Index: DynamicProxyTestCase.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.altrmi.test.proxies;
  
  import org.apache.altrmi.test.TestInterface;
  import org.apache.altrmi.test.TestInterfaceImpl;
  import org.apache.altrmi.test.AbstractHelloCallBackTestCase;
  
  /**
   * Test Dynamic Proxy (reflection) for comparison sake
   * @author Paul Hammant
   */
  public class DynamicProxyTestCase extends AbstractHelloCallBackTestCase
  {
  
      public DynamicProxyTestCase(String name)
      {
          super(name);
      }
  
      protected void setUp() throws Exception
      {
          super.setUp();
  
          testServer = new TestInterfaceImpl();
          testClient = (TestInterface) DynamicProxy.newInstance( testServer, new Class[]{TestInterface.class} );
  
      }
  
  }
  
  
  
  1.1                  incubator-altrmi/src/test/org/apache/altrmi/test/proxies/NonProxyTestCase.java
  
  Index: NonProxyTestCase.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.altrmi.test.proxies;
  
  import org.apache.altrmi.test.TestInterfaceImpl;
  import org.apache.altrmi.test.AbstractHelloCallBackTestCase;
  
  /**
   * Test Non Proxy for comparison sake
   * @author Paul Hammant
   */
  public class NonProxyTestCase extends AbstractHelloCallBackTestCase
  {
  
      public NonProxyTestCase(String name)
      {
          super(name);
      }
  
      protected void setUp() throws Exception
      {
          super.setUp();
  
          testServer = new TestInterfaceImpl();
          testClient = testServer;
  
      }
  
  }
  
  
  
  1.1                  incubator-altrmi/src/test/org/apache/altrmi/test/remotable/RemotableDescriptorTestCase.java
  
  Index: RemotableDescriptorTestCase.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.altrmi.test.remotable;
  
  import junit.framework.TestCase;
  
  import org.apache.altrmi.remotable.RemotableDescriptor;
  
  /**
   * <p>
   * Test RemotableDescriptor
   * </p>
   *
   * @author <a href="mailto:vinayc@apache.org">Vinay Chandran</a>
   */
  public class RemotableDescriptorTestCase extends TestCase
  {
      //
      //****************************
      //*********Testcase Constructor
      //****************************
      //
      public RemotableDescriptorTestCase(String name)
      {
          super(name);
      }
  
      //
      //****************************
      //*********Test cases
      //****************************
      //
      public void testDescriptor()
      {
          String pn_1 = "publishName1";
          String implObj_1 = "ImplObj1";
          Class[] interfaceToExpose_1 = new Class[] { String.class };
          String pn_2 = "publishName2";
          String implObj_2 = "ImplObj2";
          Class[] interfaceToExpose_2 = new Class[] { Integer.class };
  
          RemotableDescriptor remotableDescriptor =
              new RemotableDescriptor().add(pn_1, implObj_1, interfaceToExpose_1)
                                        .add(pn_2,implObj_2,interfaceToExpose_2);
          //1st elem
          assertEquals(true, remotableDescriptor.hasNext());
          RemotableDescriptor elem =
              (RemotableDescriptor) remotableDescriptor.next();
          assertNotNull(elem);
          assertEquals("publishName1", elem.getPublishName());
          assertEquals("ImplObj1", elem.getImplObj());
          //2nd elem
          assertEquals(true, remotableDescriptor.hasNext());
          elem =
              (RemotableDescriptor) remotableDescriptor.next();
          assertNotNull(elem);
          assertEquals("publishName2", elem.getPublishName());
          assertEquals("ImplObj2", elem.getImplObj());
      }
  }
  
  
  
  1.1                  incubator-altrmi/src/test/org/apache/altrmi/test/rmi/RmiTestCase.java
  
  Index: RmiTestCase.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.altrmi.test.rmi;
  
  import org.apache.altrmi.client.impl.ClientSideClassFactory;
  import org.apache.altrmi.client.impl.rmi.RmiHostContext;
  import org.apache.altrmi.client.Factory;
  
  import org.apache.altrmi.server.impl.rmi.RmiServer;
  import org.apache.altrmi.server.impl.AbstractServer;
  import org.apache.altrmi.server.PublicationDescription;
  import org.apache.altrmi.test.TestInterface;
  import org.apache.altrmi.test.AbstractHelloTestCase;
  import org.apache.altrmi.test.TestInterfaceImpl;
  import org.apache.altrmi.test.TestInterface3;
  import org.apache.altrmi.test.TestInterface2;
  
  import java.rmi.registry.LocateRegistry;
  
  import junit.framework.TestCase;
  
  
  /**
   * Test RMI transport
   *
   * This test only contains a single tesXXX() method because of
   * http://developer.java.sun.com/developer/bugParade/bugs/4267864.html
   *
   * @author Paul Hammant
   */
  public class RmiTestCase extends TestCase
  {
  
      private AbstractServer server;
      private TestInterfaceImpl testServer;
      private TestInterface testClient;
  
      public RmiTestCase(String name)
      {
          super(name);
      }
  
      protected void setUp() throws Exception
      {
          super.setUp();
  
          // server side setup.
          server = new RmiServer( "127.0.0.1", 10003 );
          testServer = new TestInterfaceImpl();
          PublicationDescription pd = new PublicationDescription(TestInterface.class,
                  new Class[] { TestInterface3.class, TestInterface2.class });
          server.publish(testServer, "Hello", pd);
          server.start();
  
          // Client side setup
          Factory af = new ClientSideClassFactory();
          af.setHostContext(new RmiHostContext( "127.0.0.1", 10003 ));
          testClient = (TestInterface) af.lookup("Hello");
  
          // just a kludge for unit testing given we are intrinsically dealing with
          // threads, AltRMI being a client/server thing
          Thread.yield();
      }
  
      protected void tearDown() throws Exception
      {
          server.stop();
          Thread.yield();
          server = null;
          testServer = null;
          super.tearDown();
      }
  
      public void testSpeed() throws Exception {
  
          for (int i = 1; i < 10000; i++ ) {
              testClient.testSpeed();
          }
  
      }
  
  }
  
  
  
  1.1                  incubator-altrmi/src/test/org/apache/altrmi/test/socket/CallbackEnabledCustomStreamTestCase.java
  
  Index: CallbackEnabledCustomStreamTestCase.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.altrmi.test.socket;
  
  import org.apache.altrmi.client.ClientMonitor;
  import org.apache.altrmi.client.ConnectionClosedException;
  import org.apache.altrmi.client.HostContext;
  import org.apache.altrmi.client.impl.ClientSideClassFactory;
  import org.apache.altrmi.client.impl.callback.socket.CallbackEnabledSocketCustomStreamHostContext;
  import org.apache.altrmi.common.InvocationException;
  import org.apache.altrmi.common.Request;
  import org.apache.altrmi.server.PublicationDescription;
  import org.apache.altrmi.server.impl.NullServerMonitor;
  import org.apache.altrmi.server.impl.callback.socket.CallbackEnabledSocketCustomStreamServer;
  import org.apache.altrmi.test.AbstractHelloCallBackTestCase;
  import org.apache.altrmi.test.TestInterface;
  import org.apache.altrmi.test.TestInterface2;
  import org.apache.altrmi.test.TestInterface3;
  import org.apache.altrmi.test.TestInterfaceImpl;
  
  import java.io.IOException;
  
  
  /**
   * Test Custom Stream over sockets.
   * @author <a href="mailto:vinayc77@yahoo.com">Vinay Chandran</a>
   * @author Paul Hammant
   */
  public class CallbackEnabledCustomStreamTestCase extends AbstractHelloCallBackTestCase
  {
  
      public CallbackEnabledCustomStreamTestCase(String name)
      {
          super(name);
      }
  
      protected void setUp() throws Exception
      {
          super.setUp();
  
          // server side setup.
          server = new CallbackEnabledSocketCustomStreamServer(10004);
          testServer = new TestInterfaceImpl();
          PublicationDescription pd = new PublicationDescription(TestInterface.class,
                  new Class[] { TestInterface3.class, TestInterface2.class });
          server.publish(testServer, "Hello", pd);
          server.setServerMonitor(new NullServerMonitor());
          server.start();
  
          // Client side setup
          altrmiFactory = new ClientSideClassFactory();
          HostContext hc = new CallbackEnabledSocketCustomStreamHostContext("127.0.0.1", 10004);
          hc.getClientInvocationHandler().setClientMonitor(new ClientMonitor() {
              public void methodCalled(Class clazz, String methodSignature, long duration, String annotation)
              {
              }
  
              public boolean methodLogging()
              {
                  return false;
              }
  
              public void serviceSuspended(Class clazz, Request altrmiRequest, int attempt, int suggestedWaitMillis)
              {
              }
  
              public void serviceAbend(Class clazz, int attempt, IOException cause)
              {
              }
  
              public void invocationFailure(Class clazz, String name, InvocationException ie)
              {
              }
  
              public void unexpectedClosedConnection(Class clazz, String name, ConnectionClosedException cce)
              {
              }
  
              public void unexpectedInterruption(Class clazz, String name, InterruptedException ie)
              {
              }
          });
          altrmiFactory.setHostContext(hc , false);
  
          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();
      }
  
      public void testCallBack() {
  
          // the curious thing about callbacks for the moment is that the generated class's lookup name
          // MUST match the short name of the implementation being used.  We will fix this later (TODO) -PH
  
          testClient.addCallBackListener(this);
          testServer.ping();
          assertNotNull(cbMessage);
          //TODO assertNotNull(cbServer);
  
      }
  
  
      protected void tearDown() throws Exception
      {
          testClient = null;
          System.gc();
          Thread.yield();
          altrmiFactory.close();
          Thread.yield();
          server.stop();
          Thread.yield();
          server = null;
          testServer = null;
          super.tearDown();
      }
  
  
  }
  
  
  
  1.1                  incubator-altrmi/src/test/org/apache/altrmi/test/socket/CustomStreamJNDITestCase.java
  
  Index: CustomStreamJNDITestCase.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.altrmi.test.socket;
  
  import org.apache.altrmi.server.impl.socket.CompleteSocketCustomStreamServer;
  import org.apache.altrmi.server.PublicationDescription;
  import org.apache.altrmi.test.TestInterface;
  import org.apache.altrmi.test.AbstractHelloTestCase;
  import org.apache.altrmi.test.TestInterfaceImpl;
  import org.apache.altrmi.test.TestInterface3;
  import org.apache.altrmi.test.TestInterface2;
  
  import javax.naming.Context;
  import javax.naming.InitialContext;
  import java.util.Hashtable;
  
  
  /**
   * Test Custom Stream over sockets, using JNDI on the client side ( a small change ).
   * @author Paul Hammant
   */
  public class CustomStreamJNDITestCase extends AbstractHelloTestCase
  {
  
      private Context jndiContext;
  
      public CustomStreamJNDITestCase(String name)
      {
          super(name);
      }
  
      protected void setUp() throws Exception
      {
          super.setUp();
  
          // server side setup.
          server = new CompleteSocketCustomStreamServer(10006);
          testServer = new TestInterfaceImpl();
          PublicationDescription pd = new PublicationDescription(TestInterface.class,
                  new Class[] { TestInterface3.class, TestInterface2.class });
          server.publish(testServer, "Hello", pd);
          server.start();
  
          // Client side setup
          // JNDI lookup.  Note there are no imports of Altrmi classes in this test.
          Hashtable env = new Hashtable();
  
          env.put(
              Context.INITIAL_CONTEXT_FACTORY,
              "org.apache.altrmi.client.impl.naming.DefaultInitialContextFactory" );
          env.put( Context.PROVIDER_URL, "altrmi://localhost:10006/SocketCustomStream" );
          env.put( "proxy.type", "ClientSideClasses" );
          env.put( "bean.type", "NotBeanOnly" );
          env.put( "optimize", "false" );
  
          jndiContext = new InitialContext( env );
  
          testClient = (TestInterface)jndiContext.lookup( "Hello" );
  
          // just a kludge for unit testing given we are intrinsically dealing with
          // threads, AltRMI being a client/server thing
          Thread.yield();
      }
  
      protected void tearDown() throws Exception
      {
          testClient = null;
          System.gc();
          Thread.yield();
          jndiContext.close();
          Thread.yield();
          server.stop();
          Thread.yield();
          server = null;
          testServer = null;
          super.tearDown();
      }
  
  
  }
  
  
  
  1.1                  incubator-altrmi/src/test/org/apache/altrmi/test/socket/CustomStreamOptmizedTestCase.java
  
  Index: CustomStreamOptmizedTestCase.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.altrmi.test.socket;
  
  import org.apache.altrmi.client.impl.socket.SocketCustomStreamHostContext;
  import org.apache.altrmi.client.impl.ClientSideClassFactory;
  
  import org.apache.altrmi.server.impl.socket.CompleteSocketCustomStreamServer;
  import org.apache.altrmi.server.PublicationDescription;
  import org.apache.altrmi.test.TestInterface;
  import org.apache.altrmi.test.AbstractHelloTestCase;
  import org.apache.altrmi.test.TestInterfaceImpl;
  import org.apache.altrmi.test.TestInterface3;
  import org.apache.altrmi.test.TestInterface2;
  
  
  /**
   * Test Custom Stream over sockets with optmization
   * @author Paul Hammant
   */
  public class CustomStreamOptmizedTestCase extends AbstractHelloTestCase
  {
  
      public CustomStreamOptmizedTestCase(String name)
      {
          super(name);
      }
  
      protected void setUp() throws Exception
      {
          super.setUp();
  
          // server side setup.
          server = new CompleteSocketCustomStreamServer(10001);
          testServer = new TestInterfaceImpl();
          PublicationDescription pd = new PublicationDescription(TestInterface.class,
                  new Class[] { TestInterface3.class, TestInterface2.class });
          server.publish(testServer, "Hello", pd);
          server.start();
  
          // Client side setup
          altrmiFactory = new ClientSideClassFactory();
          altrmiFactory.setHostContext(new SocketCustomStreamHostContext("127.0.0.1", 10001), true);
          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();
      }
  
      protected void tearDown() throws Exception
      {
          testClient = null;
          System.gc();
          Thread.yield();
          altrmiFactory.close();
          Thread.yield();
          server.stop();
          Thread.yield();
          server = null;
          testServer = null;
          super.tearDown();
      }
  
  
  }
  
  
  
  1.1                  incubator-altrmi/src/test/org/apache/altrmi/test/socket/CustomStreamTestCase.java
  
  Index: CustomStreamTestCase.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.altrmi.test.socket;
  
  import org.apache.altrmi.client.impl.socket.SocketCustomStreamHostContext;
  import org.apache.altrmi.client.impl.ClientSideClassFactory;
  import org.apache.altrmi.client.Factory;
  
  import org.apache.altrmi.server.impl.socket.CompleteSocketCustomStreamServer;
  import org.apache.altrmi.server.PublicationDescription;
  import org.apache.altrmi.test.TestInterface;
  import org.apache.altrmi.test.AbstractHelloTestCase;
  import org.apache.altrmi.test.TestInterfaceImpl;
  import org.apache.altrmi.test.TestInterface3;
  import org.apache.altrmi.test.TestInterface2;
  
  
  /**
   * Test Custom Stream over sockets.
   * @author Paul Hammant
   */
  public class CustomStreamTestCase extends AbstractHelloTestCase
  {
  
      public CustomStreamTestCase(String name)
      {
          super(name);
      }
  
      protected void setUp() throws Exception
      {
          super.setUp();
  
          // server side setup.
          server = new CompleteSocketCustomStreamServer(10001);
          testServer = new TestInterfaceImpl();
          PublicationDescription pd = new PublicationDescription(TestInterface.class,
                  new Class[] { TestInterface3.class, TestInterface2.class });
          server.publish(testServer, "Hello", pd);
          server.start();
  
          // Client side setup
          altrmiFactory = new ClientSideClassFactory();
          altrmiFactory.setHostContext(new SocketCustomStreamHostContext("127.0.0.1", 10001), false);
          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();
      }
  
  
      protected void tearDown() throws Exception
      {
          testClient = null;
          System.gc();
          Thread.yield();
          altrmiFactory.close();
          Thread.yield();
          server.stop();
          Thread.yield();
          server = null;
          testServer = null;
          super.tearDown();
      }
  
  
  }
  
  
  
  1.1                  incubator-altrmi/src/test/org/apache/altrmi/test/socket/JSXObjectStreamTestCase.java
  
  Index: JSXObjectStreamTestCase.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.altrmi.test.socket;
  
  import org.apache.altrmi.client.impl.socket.SocketObjectStreamHostContext;
  import org.apache.altrmi.client.impl.ClientSideClassFactory;
  import org.apache.altrmi.client.Factory;
  
  import org.apache.altrmi.server.impl.socket.CompleteSocketObjectStreamServer;
  import org.apache.altrmi.server.PublicationDescription;
  import org.apache.altrmi.test.TestInterface;
  import org.apache.altrmi.test.AbstractHelloTestCase;
  import org.apache.altrmi.test.TestInterfaceImpl;
  import org.apache.altrmi.test.TestInterface3;
  import org.apache.altrmi.test.TestInterface2;
  
  
  /**
   * Test Object Stream over sockets using JSX XML distribution.
   * Currently this test freezes so is excluded from test run.
   * @author Paul Hammant
   */
  public class JSXObjectStreamTestCase extends AbstractHelloTestCase
  {
  
      public JSXObjectStreamTestCase(String name)
      {
          super(name);
      }
  
      protected void setUp() throws Exception
      {
          super.setUp();
  
          // server side setup.
          server = new CompleteSocketObjectStreamServer(10009, "JSX.ObjIn", "JSX.ObjOut");
          testServer = new TestInterfaceImpl();
          PublicationDescription pd = new PublicationDescription(TestInterface.class,
                  new Class[] { TestInterface3.class, TestInterface2.class });
          server.publish(testServer, "Hello", pd);
          server.start();
  
          // Client side setup
          altrmiFactory = new ClientSideClassFactory();
          altrmiFactory.setHostContext(
                  new SocketObjectStreamHostContext("127.0.0.1", 10009, "JSX.ObjIn", "JSX.ObjOut"), false);
          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();
      }
  
      protected void tearDown() throws Exception
      {
          testClient = null;
          System.gc();
          Thread.yield();
          altrmiFactory.close();
          Thread.yield();
          server.stop();
          Thread.yield();
          server = null;
          testServer = null;
          super.tearDown();
      }
  
  
  }
  
  
  
  1.1                  incubator-altrmi/src/test/org/apache/altrmi/test/socket/MyTestCallBackListener.java
  
  Index: MyTestCallBackListener.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.altrmi.test.socket;
  
  import org.apache.altrmi.test.TestCallBackListener;
  import org.apache.altrmi.test.TestInterface;
  
  import java.util.HashMap;
  
  /**
   * Test Custom Stream over sockets.
   * @author Paul Hammant
   */
  public class MyTestCallBackListener implements TestCallBackListener
  {
      private final HashMap results;
  
      public MyTestCallBackListener(HashMap results)
      {
          this.results = results;
      }
  
      public void serverCallingClient(String message)
      {
          results.put("1", message);
      }
  
      public void serverCallingClient2(TestInterface testInterface)
      {
          results.put("2", testInterface.toString());
      }
  }
  
  
  
  
  1.1                  incubator-altrmi/src/test/org/apache/altrmi/test/socket/ObjectStreamTestCase.java
  
  Index: ObjectStreamTestCase.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.altrmi.test.socket;
  
  import org.apache.altrmi.client.impl.socket.SocketObjectStreamHostContext;
  import org.apache.altrmi.client.impl.ClientSideClassFactory;
  import org.apache.altrmi.client.Factory;
  
  import org.apache.altrmi.server.impl.socket.CompleteSocketObjectStreamServer;
  import org.apache.altrmi.server.PublicationDescription;
  import org.apache.altrmi.test.TestInterface;
  import org.apache.altrmi.test.AbstractHelloTestCase;
  import org.apache.altrmi.test.TestInterfaceImpl;
  import org.apache.altrmi.test.TestInterface3;
  import org.apache.altrmi.test.TestInterface2;
  
  
  /**
   * Test Object Stream over sockets.
   * @author Paul Hammant
   */
  public class ObjectStreamTestCase extends AbstractHelloTestCase
  {
  
      public ObjectStreamTestCase(String name)
      {
          super(name);
  
          // See http://developer.java.sun.com/developer/bugParade/bugs/4499841.html
          // This bug prevents ObjectStream from functioning correctly when used
          // by AltRMI.  You can still use the ObjectStream transports, but
          // should be aware of the limitations.  See testBugParadeBugNumber4499841()
          // in the parent class.
          testForBug4499841 = false;
  
      }
  
      protected void setUp() throws Exception
      {
          super.setUp();
  
          // server side setup.
          server = new CompleteSocketObjectStreamServer(10002);
          testServer = new TestInterfaceImpl();
          PublicationDescription pd = new PublicationDescription(TestInterface.class,
                  new Class[] { TestInterface3.class, TestInterface2.class });
          server.publish(testServer, "Hello", pd);
          server.start();
  
          // Client side setup
          altrmiFactory = new ClientSideClassFactory();
          altrmiFactory.setHostContext(new SocketObjectStreamHostContext("127.0.0.1", 10002), false);
          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();
      }
  
      protected void tearDown() throws Exception
      {
          testClient = null;
          System.gc();
          Thread.yield();
          altrmiFactory.close();
          Thread.yield();
          server.stop();
          Thread.yield();
          server = null;
          testServer = null;
          super.tearDown();
      }
  
  
  }
  
  
  
  1.1                  incubator-altrmi/status.xml
  
  Index: status.xml
  ===================================================================
  <?xml version="1.0"?>
  <status>
  
    <developers>
      <person name="Paul Hammant" email="" id="PH" />
      <!-- Add more people here -->
    </developers>
  
    <todo>
      <actions priority="high">
        <action context="docs" dev="PH">
          More of them.
        </action>
        <action context="feedback" dev="PH">
          Mail <link
            href="mailto:projects@incubator.apache.org">projects@incubator.apache.org</link>
          with feedback. Please specify a subject starting with '[AltRMI]'
        </action>
      </actions>
    </todo>
  
    <changes>
      <!-- Add new releases here -->
      <release version="0.9.1" date="Feb ?? 2003">
            <action dev="PH" type="add" context="admin">
              Initial Import
            </action>
      </release>
    </changes>
  </status>
  
  
  

Mime
View raw message