You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by ha...@apache.org on 2002/08/18 14:04:50 UTC

cvs commit: jakarta-avalon-excalibur/altrmi/src/test/org/apache/excalibur/altrmi/test/socket CustomStreamTestCase.java ObjectStreamTestCase.java ObjectStreamSocketClientTest.java ObjectStreamSocketServerTest.java

hammant     2002/08/18 05:04:50

  Modified:    altrmi   base.xml build.xml
               altrmi/src/java/org/apache/excalibur/altrmi/server/impl/socket
                        AbstractCompleteSocketStreamServer.java
                        AbstractPartialSocketStreamServer.java
               altrmi/src/test/org/apache/excalibur/altrmi/test/piped
                        PipedTestCase.java
  Added:       altrmi/src/test/org/apache/excalibur/altrmi/test
                        AbstractHelloTestCase.java
                        SimpleHelloTestServerImpl.java
               altrmi/src/test/org/apache/excalibur/altrmi/test/direct
                        DirectMarshalledTestCase.java DirectTestCase.java
               altrmi/src/test/org/apache/excalibur/altrmi/test/socket
                        CustomStreamTestCase.java ObjectStreamTestCase.java
  Removed:     altrmi   direct.xml piped.xml
               altrmi/src/test/org/apache/excalibur/altrmi/test/piped
                        PipedTest.java PipedTestClient.java
               altrmi/src/test/org/apache/excalibur/altrmi/test/direct
                        DirectMarshalledTest.java
                        DirectMarshalledTestClient.java DirectTest.java
                        DirectTestClient.java
               altrmi/src/test/org/apache/excalibur/altrmi/test/socket
                        ObjectStreamSocketClientTest.java
                        ObjectStreamSocketServerTest.java
  Log:
  Rework from mainable tests to Unit tests.  Yeehaaa!
  
  Revision  Changes    Path
  1.4       +2 -2      jakarta-avalon-excalibur/altrmi/base.xml
  
  Index: base.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/base.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- base.xml	21 Apr 2002 09:42:01 -0000	1.3
  +++ base.xml	18 Aug 2002 12:04:49 -0000	1.4
  @@ -52,8 +52,8 @@
           <pathelement location="${build.home}/classes"/>
           <pathelement location="${build.home}/testclasses"/>            
         </classpath>
  -    </altrmiproxies>        
  -  
  +    </altrmiproxies> 
  +     
     </target>
   
   </project>
  
  
  
  1.31      +12 -1     jakarta-avalon-excalibur/altrmi/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/build.xml,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- build.xml	10 Aug 2002 21:14:32 -0000	1.30
  +++ build.xml	18 Aug 2002 12:04:49 -0000	1.31
  @@ -31,6 +31,15 @@
           <pathelement location="${junit.jar}"/>
           <path refid="project.class.path"/>
       </path>
  +    
  +    <path id="test.classpath2">
  +        <pathelement location="${build.testclasses}"/>
  +        <pathelement location="${junit.jar}"/>
  +        <pathelement location="build/genclasses"/>
  +        <path refid="project.class.path"/>
  +    </path>
  +    
  +    
       <property name="cp" refid="test.class.path"/>
   
       <target name="main" depends="compile, compile-test" description="Build the project"/>
  @@ -193,13 +202,15 @@
   
           <echo message="Performing Unit Tests" />
   
  +        <ant antfile="base.xml" target="generate"/>  
  +
           <mkdir dir="${build.tests}"/>
   
           <junit fork="true"
               haltonfailure="${junit.failonerror}"
               printsummary="yes"
               dir="${build.tests}">
  -            <classpath refid="test.class.path"/>
  +            <classpath refid="test.classpath2"/>
   
               <formatter type="xml"/>    <!-- xml reports for junitreport -->
               <formatter type="plain" usefile="false"/>  <!-- text reports for humans     -->
  
  
  
  1.5       +14 -2     jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/socket/AbstractCompleteSocketStreamServer.java
  
  Index: AbstractCompleteSocketStreamServer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/socket/AbstractCompleteSocketStreamServer.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- AbstractCompleteSocketStreamServer.java	16 Aug 2002 07:25:25 -0000	1.4
  +++ AbstractCompleteSocketStreamServer.java	18 Aug 2002 12:04:49 -0000	1.5
  @@ -88,11 +88,15 @@
       public void run()
       {
   
  +        boolean accepting = false;
           try
           {
               while( mState == STARTED )
               {
  +
  +                accepting = true;
                   Socket sock = mServerSocket.accept();
  +                accepting = false;
   
                   // see http://developer.java.sun.com/developer/bugParade/bugs/4508149.html
                   sock.setSoTimeout( 36000 );
  @@ -114,7 +118,15 @@
           }
           catch( IOException ioe )
           {
  -            System.err.println( "Some problem connecting client via sockets." );
  +            if (accepting & ioe.getMessage().equals("socket closed"))
  +            {
  +                // do nothing, server shut down during accept();
  +            }
  +            else
  +            {
  +                System.err.println( "Some problem connecting client via sockets: " + ioe.getMessage());
  +                ioe.printStackTrace();
  +            }
           }
       }
   
  
  
  
  1.3       +2 -2      jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/socket/AbstractPartialSocketStreamServer.java
  
  Index: AbstractPartialSocketStreamServer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/socket/AbstractPartialSocketStreamServer.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AbstractPartialSocketStreamServer.java	24 Apr 2002 12:43:02 -0000	1.2
  +++ AbstractPartialSocketStreamServer.java	18 Aug 2002 12:04:49 -0000	1.3
  @@ -59,7 +59,7 @@
           }
           catch( IOException ioe )
           {
  -            System.err.println( "Some problem connecting client via sockets." );
  +            System.err.println( "Some problem connecting client via sockets: " + ioe.getMessage());
               ioe.printStackTrace();
           }
       }
  
  
  
  1.2       +48 -146   jakarta-avalon-excalibur/altrmi/src/test/org/apache/excalibur/altrmi/test/piped/PipedTestCase.java
  
  Index: PipedTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/test/org/apache/excalibur/altrmi/test/piped/PipedTestCase.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PipedTestCase.java	14 Jul 2002 20:59:47 -0000	1.1
  +++ PipedTestCase.java	18 Aug 2002 12:04:49 -0000	1.2
  @@ -7,161 +7,63 @@
    */
   package org.apache.excalibur.altrmi.test.piped;
   
  -import junit.framework.TestCase;
  -import org.apache.excalibur.altrmi.server.*;
  -import org.apache.excalibur.altrmi.server.impl.piped.AbstractPipedServer;
  -import org.apache.excalibur.altrmi.server.impl.piped.PipedObjectStreamServer;
  -import org.apache.excalibur.altrmi.test.*;
  -import org.apache.excalibur.altrmi.client.AltrmiHostContext;
  -import org.apache.excalibur.altrmi.client.AltrmiFactory;
  +import org.apache.excalibur.altrmi.client.impl.ClientClassAltrmiFactory;
   import org.apache.excalibur.altrmi.client.impl.piped.PipedObjectStreamHostContext;
  -import org.apache.excalibur.altrmi.common.AltrmiConnectionException;
  -
  -import java.io.IOException;
  -import java.beans.PropertyVetoException;
  -import java.util.HashMap;
  -
  -public class PipedTestCase extends TestCase {
  +import org.apache.excalibur.altrmi.client.AltrmiFactory;
   
  -    HashMap results = new HashMap();
  +import org.apache.excalibur.altrmi.server.impl.piped.PipedObjectStreamServer;
  +import org.apache.excalibur.altrmi.test.TestInterface;
  +import org.apache.excalibur.altrmi.test.AbstractHelloTestCase;
  +import org.apache.excalibur.altrmi.test.SimpleHelloTestServerImpl;
  +
  +import java.io.PipedInputStream;
  +import java.io.PipedOutputStream;
  +
  +/**
  + * Test Piped Trasnport (Object Stream)
  + * @author Paul Hammant
  + */
  +public class PipedTestCase extends AbstractHelloTestCase
  +{
   
  -    String helloString = "Howdie!!!";
   
  -    public PipedTestCase(String name) {
  +    public PipedTestCase(String name)
  +    {
           super(name);
       }
   
  -    public void testClientSideBasic()
  -        throws Exception {
  -        String serverOrClientFactory = "C";
  -
  -        PipedTest pt = new PipedTest();
  -
  -        final PublicationDescription publicationDescription = new PublicationDescription( TestInterface.class,
  -                                                                new Class[]{
  -                                                                    TestInterface3.class,
  -                                                                    TestInterface2.class} );
  -
  -        final ClassRetriever classRetriever = pt.getClassRetriever(serverOrClientFactory, publicationDescription);
  -
  -        System.out.println( "Piped Test" );
  -
  -        final AbstractPipedServer ps = new PipedObjectStreamServer();
  -
  -        final TestInterface ti = new TestInterface() {
  -            public void hello(String greeting) {
  -                results.put("hello", greeting);
  -            }
  -
  -            public int hello2(int greeting) {
  -                return 0;
  -            }
  -
  -            public boolean hello3(short greeting) throws PropertyVetoException, IOException {
  -                return false;
  -            }
  -
  -            public StringBuffer hello4(float greeting1, double greeting2) {
  -                return null;
  -            }
  -
  -            public void testSpeed() {
  -            }
  -
  -            public String testSpeed2(String string) {
  -                return null;
  -            }
  -
  -            public TestInterface2 makeTestInterface2(String thingName) {
  -                return null;
  -            }
  -
  -            public void morphName(TestInterface2 forThisImpl) {
  -            }
  -
  -            public TestInterface2 findTestInterface2ByName(String nameToFind) {
  -                return null;
  -            }
  -
  -            public TestInterface2[] getTestInterface2s() {
  -                return new TestInterface2[0];
  -            }
  -
  -            public TestObject[] getTestObjects() {
  -                return new TestObject[0];
  -            }
  -
  -            public void changeTestObjectNames() {
  -            }
  -
  -            public void makeNewTestObjectNames() {
  -            }
  -        };
  -
  -        Runnable server = new Runnable() {
  -            public void run() {
  -              ps.setClassRetriever( classRetriever );
  -                try {
  -                    ps.publish( ti, "Hello", publicationDescription );
  -                } catch (PublicationException e) {
  -                    System.err.println("Publication exception " + e.getMessage());
  -                }
  -                ps.start();
  -            }
  -        };
  -
  -        Thread pipedTestServer = new Thread(server);
  -        pipedTestServer.start();
  -
  -        Thread.sleep(500);
  -
  -        PipedTestClient ptc = new JunitPipedTestClient( ps, serverOrClientFactory );
  -        Thread thread = new Thread( ptc );
  -
  -        thread.start();
  -
  -        Thread.sleep(5000);
  -
  -        thread.interrupt();
  -
  -        assertEquals("hello() method test", helloString, results.get("hello"));
  -
  +    protected void setUp() throws Exception
  +    {
  +        super.setUp();
  +
  +        // server side setup.
  +        server = new PipedObjectStreamServer();
  +        testServer = new SimpleHelloTestServerImpl();
  +        server.publish(testServer, "Hello", TestInterface.class);
  +        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 af = new ClientClassAltrmiFactory(false);
  +        af.setHostContext(new PipedObjectStreamHostContext(in, out));
  +        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();
       }
   
  -    class JunitPipedTestClient extends PipedTestClient {
  -        public JunitPipedTestClient(AbstractPipedServer pipedServer, String serverOrClient) {
  -            super(pipedServer, serverOrClient);
  -        }
  -
  -        public void run() {
  -            try
  -            {
  -
  -                AltrmiHostContext arhc = new PipedObjectStreamHostContext( in, out );
  -                mPipedServer.makeNewConnection( in, out );
  -
  -                AltrmiFactory af = null;
  -
  -                af = makeFactory();
  -
  -                af.setHostContext( arhc );
  -
  -                // hangs here ....?
  -                TestInterface ti = (TestInterface) af.lookup( "Hello" );
  -                ti.hello(helloString);
  -                af.close();
  -            }
  -            catch( IOException ioe )
  -            {
  -                results.put( "IOE", "Some problem during connection to server : "
  -                                    + ioe.getMessage() );
  -            }
  -            catch( AltrmiConnectionException ace )
  -            {
  -                results.put( "ACE", "Some problem during connection to server : "
  -                                    + ace.getMessage() );
  -            }
  -        }
  +    protected void tearDown() throws Exception
  +    {
  +        server.stop();
  +        Thread.yield();
  +        server = null;
  +        testServer = null;
  +        super.tearDown();
       }
   
   
  
  
  
  1.1                  jakarta-avalon-excalibur/altrmi/src/test/org/apache/excalibur/altrmi/test/AbstractHelloTestCase.java
  
  Index: AbstractHelloTestCase.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;
  
  import org.apache.excalibur.altrmi.server.impl.AbstractServer;
  
  import java.beans.PropertyVetoException;
  import java.io.IOException;
  
  import junit.framework.TestCase;
  
  /**
   * Extended by classes that name the transport.
   * @author Paul Hammant
   */
  public abstract class AbstractHelloTestCase extends TestCase {
  
      protected AbstractServer server;
      protected SimpleHelloTestServerImpl testServer;
      protected TestInterface testClient;
  
      public AbstractHelloTestCase(String name) {
          super(name);
      }
  
      public void testHelloCall() throws Exception {
          // lookup worked ?
          assertNotNull (testClient);
  
          // Invoke a method over AltRMI.
          testClient.hello("Hello!?");
  
          // test the server has logged the message.
          assertEquals("Hello!?",((SimpleHelloTestServerImpl) testServer).getStoredState("void:hello(String)"));
      }
  
      public void testHello2Call() throws Exception {
          // lookup worked ?
          assertNotNull (testClient);
  
          // Invoke a method over AltRMI.
          int retVal = testClient.hello2(11);
  
          // test our returned result
          assertEquals (11,retVal);
  
          // test the server has logged the message.
          assertEquals("11",((SimpleHelloTestServerImpl) testServer).getStoredState("int:hello2(int)"));
      }
  
      public void testHello3CallPart1() throws Exception {
          // lookup worked ?
          assertNotNull (testClient);
  
          // Invoke a method over AltRMI.
          boolean retVal = testClient.hello3((short)22);
  
          // test our returned result
          assertTrue (retVal);
  
          // test the server has logged the message.
          assertEquals("22",((SimpleHelloTestServerImpl) testServer).getStoredState("boolean:hello3(short)"));
      }
  
  
      public void testHello3CallPart2() throws Exception {
          // lookup worked ?
          assertNotNull (testClient);
  
          // Invoke a method over AltRMI.
          try {
              testClient.hello3((short)90);
              fail("Expected a Excaption to be throw for hardcoded test 90");
          } catch (PropertyVetoException e) {
              // expected
          } catch (IOException e) {
              fail("Wrong exception throw for hardcoded test 90");
          }
  
          // test the server has logged the message.
          assertEquals("90",((SimpleHelloTestServerImpl) testServer).getStoredState("boolean:hello3(short)"));
      }
  
      public void testHello3CallPart3() throws Exception {
          // lookup worked ?
          assertNotNull (testClient);
  
          // Invoke a method over AltRMI.
          try {
              testClient.hello3((short)91);
              fail("Expected a Excaption to be throw for hardcoded test 91");
          } catch (PropertyVetoException e) {
              fail("Wrong exception throw for hardcoded test 91");
          } catch (IOException e) {
              // expected
          }
  
          // test the server has logged the message.
          assertEquals("91",((SimpleHelloTestServerImpl) testServer).getStoredState("boolean:hello3(short)"));
      }
  
  }
  
  
  
  1.1                  jakarta-avalon-excalibur/altrmi/src/test/org/apache/excalibur/altrmi/test/SimpleHelloTestServerImpl.java
  
  Index: SimpleHelloTestServerImpl.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;
  
  import org.apache.excalibur.altrmi.test.TestInterface;
  import org.apache.excalibur.altrmi.test.TestInterface2;
  import org.apache.excalibur.altrmi.test.TestObject;
  
  import java.util.HashMap;
  import java.beans.PropertyVetoException;
  import java.io.IOException;
  
  public class SimpleHelloTestServerImpl implements TestInterface {
  
      HashMap storedState = new HashMap();
  
      public Object getStoredState(String key) {
          return storedState.get(key);
      }
  
      public void hello(String greeting) {
          storedState.put("void:hello(String)", greeting);
      }
  
      public int hello2(int greeting) {
          storedState.put("int:hello2(int)", "" + greeting);
          return greeting;
      }
  
      public boolean hello3(short greeting) throws PropertyVetoException, IOException {
          storedState.put("boolean:hello3(short)", "" + greeting);
          switch(greeting) {
              case 90:
                  throw new PropertyVetoException("Forced Exception Test", null);
              case 91:
                  throw new IOException("Forced Exception");
          }
          return true;
      }
  
      public StringBuffer hello4(float greeting1, double greeting2) {
          throw new UnsupportedOperationException();
      }
  
      public void testSpeed() {
          throw new UnsupportedOperationException();
      }
  
      public String testSpeed2(String string) {
          throw new UnsupportedOperationException();
      }
  
      public TestInterface2 makeTestInterface2(String thingName) {
          throw new UnsupportedOperationException();
      }
  
      public void morphName(TestInterface2 forThisImpl) {
          throw new UnsupportedOperationException();
      }
  
      public TestInterface2 findTestInterface2ByName(String nameToFind) {
          throw new UnsupportedOperationException();
      }
  
      public TestInterface2[] getTestInterface2s() {
          throw new UnsupportedOperationException();
      }
  
      public TestObject[] getTestObjects() {
          throw new UnsupportedOperationException();
      }
  
      public void changeTestObjectNames() {
      }
  
      public void makeNewTestObjectNames() {
      }
  
  }
  
  
  
  1.1                  jakarta-avalon-excalibur/altrmi/src/test/org/apache/excalibur/altrmi/test/direct/DirectMarshalledTestCase.java
  
  Index: DirectMarshalledTestCase.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.direct;
  
  import org.apache.excalibur.altrmi.client.impl.ClientClassAltrmiFactory;
  import org.apache.excalibur.altrmi.client.impl.direct.DirectMarshalledHostContext;
  import org.apache.excalibur.altrmi.client.AltrmiFactory;
  
  import org.apache.excalibur.altrmi.server.impl.direct.DirectMarshalledServer;
  import org.apache.excalibur.altrmi.test.TestInterface;
  import org.apache.excalibur.altrmi.test.AbstractHelloTestCase;
  import org.apache.excalibur.altrmi.test.SimpleHelloTestServerImpl;
  
  
  /**
   * Test Direct Marshalled Transport
   * @author Paul Hammant
   */
  public class DirectMarshalledTestCase extends AbstractHelloTestCase
  {
  
      public DirectMarshalledTestCase(String name)
      {
          super(name);
      }
  
      protected void setUp() throws Exception
      {
          super.setUp();
  
          // server side setup.
          server = new DirectMarshalledServer();
          testServer = new SimpleHelloTestServerImpl();
          server.publish(testServer, "Hello", TestInterface.class);
          server.start();
  
          // Client side setup
          AltrmiFactory af = new ClientClassAltrmiFactory(false);
          af.setHostContext(new DirectMarshalledHostContext((DirectMarshalledServer)server));
          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();
      }
  
  
  }
  
  
  
  1.1                  jakarta-avalon-excalibur/altrmi/src/test/org/apache/excalibur/altrmi/test/direct/DirectTestCase.java
  
  Index: DirectTestCase.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.direct;
  
  import org.apache.excalibur.altrmi.client.impl.ClientClassAltrmiFactory;
  import org.apache.excalibur.altrmi.client.impl.direct.DirectHostContext;
  import org.apache.excalibur.altrmi.client.AltrmiFactory;
  
  import org.apache.excalibur.altrmi.server.impl.direct.DirectServer;
  import org.apache.excalibur.altrmi.test.TestInterface;
  import org.apache.excalibur.altrmi.test.AbstractHelloTestCase;
  import org.apache.excalibur.altrmi.test.SimpleHelloTestServerImpl;
  
  
  /**
   * Test Direct Transport
   * @author Paul Hammant
   */
  public class DirectTestCase extends AbstractHelloTestCase
  {
  
      public DirectTestCase(String name)
      {
          super(name);
      }
  
      protected void setUp() throws Exception
      {
          super.setUp();
  
          // server side setup.
          server = new DirectServer();
          testServer = new SimpleHelloTestServerImpl();
          server.publish(testServer, "Hello", TestInterface.class);
          server.start();
  
          // Client side setup
          AltrmiFactory af = new ClientClassAltrmiFactory(false);
          af.setHostContext(new DirectHostContext(server));
          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();
      }
  
  
  }
  
  
  
  1.1                  jakarta-avalon-excalibur/altrmi/src/test/org/apache/excalibur/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.excalibur.altrmi.test.socket;
  
  import org.apache.excalibur.altrmi.client.impl.socket.SocketCustomStreamHostContext;
  import org.apache.excalibur.altrmi.client.impl.ClientClassAltrmiFactory;
  import org.apache.excalibur.altrmi.client.AltrmiFactory;
  
  import org.apache.excalibur.altrmi.server.impl.socket.CompleteSocketCustomStreamServer;
  import org.apache.excalibur.altrmi.test.TestInterface;
  import org.apache.excalibur.altrmi.test.AbstractHelloTestCase;
  import org.apache.excalibur.altrmi.test.SimpleHelloTestServerImpl;
  
  
  /**
   * 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 SimpleHelloTestServerImpl();
          server.publish(testServer, "Hello", TestInterface.class);
          server.start();
  
          // Client side setup
          AltrmiFactory af = new ClientClassAltrmiFactory(false);
          af.setHostContext(new SocketCustomStreamHostContext("127.0.0.1", 10001));
          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();
      }
  
  
  }
  
  
  
  1.1                  jakarta-avalon-excalibur/altrmi/src/test/org/apache/excalibur/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.excalibur.altrmi.test.socket;
  
  import org.apache.excalibur.altrmi.client.impl.socket.SocketObjectStreamHostContext;
  import org.apache.excalibur.altrmi.client.impl.ClientClassAltrmiFactory;
  import org.apache.excalibur.altrmi.client.AltrmiFactory;
  
  import org.apache.excalibur.altrmi.server.impl.socket.CompleteSocketObjectStreamServer;
  import org.apache.excalibur.altrmi.test.TestInterface;
  import org.apache.excalibur.altrmi.test.AbstractHelloTestCase;
  import org.apache.excalibur.altrmi.test.SimpleHelloTestServerImpl;
  
  
  /**
   * Test Object Stream over sockets.
   * @author Paul Hammant
   */
  public class ObjectStreamTestCase extends AbstractHelloTestCase
  {
  
      public ObjectStreamTestCase(String name)
      {
          super(name);
      }
  
      protected void setUp() throws Exception
      {
          super.setUp();
  
          // server side setup.
          server = new CompleteSocketObjectStreamServer(10002);
          testServer = new SimpleHelloTestServerImpl();
          server.publish(testServer, "Hello", TestInterface.class);
          server.start();
  
          // Client side setup
          AltrmiFactory af = new ClientClassAltrmiFactory(false);
          af.setHostContext(new SocketObjectStreamHostContext("127.0.0.1", 10002));
          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();
      }
  
  
  }
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>