commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hamm...@apache.org
Subject cvs commit: jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/test PipeTest.java
Date Mon, 28 Jan 2002 10:27:06 GMT
hammant     02/01/28 02:27:06

  Modified:    altrmi   tests.xml
               altrmi/src/java/org/apache/commons/altrmi/client/impl
                        ServerClassAltrmiFactory.java
               altrmi/src/java/org/apache/commons/altrmi/common
                        AltrmiReply.java
               altrmi/src/java/org/apache/commons/altrmi/server/impl
                        AbstractServer.java
               altrmi/src/java/org/apache/commons/altrmi/server/impl/classretrievers
                        AbstractClassRetriever.java
               altrmi/src/java/org/apache/commons/altrmi/test PipeTest.java
  Added:       altrmi/src/java/org/apache/commons/altrmi/common
                        ClassRetrievalFailedReply.java
  Log:
  Tests for dynamic proxy generation
  
  Revision  Changes    Path
  1.5       +18 -1     jakarta-commons-sandbox/altrmi/tests.xml
  
  Index: tests.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/tests.xml,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- tests.xml	26 Jan 2002 15:22:16 -0000	1.4
  +++ tests.xml	28 Jan 2002 10:27:06 -0000	1.5
  @@ -3,7 +3,7 @@
   
   <!--
           "Alt (to) RMI" component of the Jakarta Commons Subproject
  -        $Id: tests.xml,v 1.4 2002/01/26 15:22:16 hammant Exp $
  +        $Id: tests.xml,v 1.5 2002/01/28 10:27:06 hammant Exp $
   -->
   
   
  @@ -55,6 +55,13 @@
       <pathelement location="${build.home}/classes"/>
     </path>    
     
  +  <path id="testC1.classpath">
  +    <pathelement location="${build.home}/classes"/>
  +    <pathelement location="D:/jdk1.4/lib/tools.jar"/>
  +  </path>
  +  
  +  
  +  
     
   
     <taskdef name="altrmiinterfaces" classname="org.apache.commons.altrmi.generator.ant.AltrmiInterfaceTask">
  @@ -220,6 +227,16 @@
       <java classname="org.apache.commons.altrmi.test.PipeTest" fork="true">
         <classpath refid="testB1.classpath"/>
         <arg value="S"/>
  +    </java>      
  +  </target>
  +
  +  <target name="pipedc" depends="generate">
  +  
  +    <echo>ee ${java.home}</echo>
  +  
  +    <java classname="org.apache.commons.altrmi.test.PipeTest" fork="true">
  +      <classpath refid="testC1.classpath"/>
  +      <arg value="D"/>
       </java>      
     </target>
   
  
  
  
  1.8       +6 -2      jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/client/impl/ServerClassAltrmiFactory.java
  
  Index: ServerClassAltrmiFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/client/impl/ServerClassAltrmiFactory.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ServerClassAltrmiFactory.java	21 Jan 2002 20:10:34 -0000	1.7
  +++ ServerClassAltrmiFactory.java	28 Jan 2002 10:27:06 -0000	1.8
  @@ -23,6 +23,7 @@
   import org.apache.commons.altrmi.common.RequestFailedReply;
   import org.apache.commons.altrmi.common.AltrmiAuthentication;
   import org.apache.commons.altrmi.common.ExceptionReply;
  +import org.apache.commons.altrmi.common.ClassRetrievalFailedReply;
   
   import java.util.HashMap;
   
  @@ -35,7 +36,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.7 $
  + * @version $Revision: 1.8 $
    */
   public class ServerClassAltrmiFactory extends AbstractAltrmiFactory {
   
  @@ -138,7 +139,10 @@
                           if (ar instanceof RequestFailedReply) {
                               throw new AltrmiConnectionException(((RequestFailedReply) ar)
                                   .getFailureReason());
  -                        }    //TODO others.
  +                        } else if (ar instanceof ClassRetrievalFailedReply) {
  +                            ClassRetrievalFailedReply crfr = (ClassRetrievalFailedReply)
ar;
  +                            throw new AltrmiConnectionException("Exception on server side
");
  +                        }  //TODO others.
                       }
   
                       cr = (ClassReply) ar;
  
  
  
  1.5       +2 -1      jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/common/AltrmiReply.java
  
  Index: AltrmiReply.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/common/AltrmiReply.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- AltrmiReply.java	19 Jan 2002 13:30:19 -0000	1.4
  +++ AltrmiReply.java	28 Jan 2002 10:27:06 -0000	1.5
  @@ -21,7 +21,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.4 $
  + * @version $Revision: 1.5 $
    */
   public abstract class AltrmiReply implements Externalizable {
   
  @@ -41,6 +41,7 @@
       public static final int SUSPENDEDREPLY = 104;
       public static final int ENDCONNECTIONREPLY = 105;
       public static final int NOSUCHREFERENCEREPLY = 106;
  +    public static final int CLASSRETRIEVALFAILEDREPLY = 107;
   
       /**
        * Method getReplyCode.  This is quicker than instanceof for type checking.
  
  
  
  1.1                  jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/common/ClassRetrievalFailedReply.java
  
  Index: ClassRetrievalFailedReply.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.commons.altrmi.common;
  
  /**
   * Class RequestFailedReply
   *
   *
   * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
   * @version $Revision: 1.1 $
   */
  public final class ClassRetrievalFailedReply extends AltrmiReply {
  
      /**
       * Constructor RequestFailedReply
       *
       *
       * @param failureReason
       *
       */
      public ClassRetrievalFailedReply() {
      }
  
      /**
       * Method getReplyCode.  This is quicker than instanceof for type checking.
       *
       *
       * @return
       *
       */
      public int getReplyCode() {
          return CLASSRETRIEVALFAILEDREPLY;
      }
  
  }
  
  
  
  1.14      +3 -2      jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/AbstractServer.java
  
  Index: AbstractServer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/AbstractServer.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- AbstractServer.java	27 Jan 2002 15:47:40 -0000	1.13
  +++ AbstractServer.java	28 Jan 2002 10:27:06 -0000	1.14
  @@ -35,6 +35,7 @@
   import org.apache.commons.altrmi.common.AltrmiInvocationException;
   import org.apache.commons.altrmi.common.OpenConnectionReply;
   import org.apache.commons.altrmi.common.PingReply;
  +import org.apache.commons.altrmi.common.ClassRetrievalFailedReply;
   import org.apache.commons.altrmi.server.ClassRetrievalException;
   import org.apache.commons.altrmi.server.ClassRetriever;
   import org.apache.commons.altrmi.server.ServerInvocationHandler;
  @@ -57,7 +58,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.13 $
  + * @version $Revision: 1.14 $
    */
   public abstract class AbstractServer extends AbstractMethodHandler implements AltrmiServer
{
   
  @@ -366,7 +367,7 @@
                                         mClassRetriever
                                             .getInterfaceImplementationBytes(publishedThing));
               } catch (ClassRetrievalException e) {
  -                return new ExceptionReply(new ClassNotFoundException("AltRMI Server exception
- " + publishedThing + " not found"));
  +                return new ClassRetrievalFailedReply();
               }
           } else if (request.getRequestCode() == AltrmiRequest.OPENCONNECTIONREQUEST) {
               Long session = getNewSession();
  
  
  
  1.2       +4 -0      jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/classretrievers/AbstractClassRetriever.java
  
  Index: AbstractClassRetriever.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/classretrievers/AbstractClassRetriever.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AbstractClassRetriever.java	27 Jan 2002 15:47:40 -0000	1.1
  +++ AbstractClassRetriever.java	28 Jan 2002 10:27:06 -0000	1.2
  @@ -66,6 +66,10 @@
                   "Generated class not found in classloader specified : " + e.getMessage());
           }
   
  +        if (is == null) {
  +            throw new ClassRetrievalException("Generated class not found in classloader
specified.");
  +        }
  +
           ByteArrayOutputStream baos = new ByteArrayOutputStream();
           int i = 0;
   
  
  
  
  1.8       +30 -5     jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/test/PipeTest.java
  
  Index: PipeTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/test/PipeTest.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- PipeTest.java	25 Jan 2002 16:40:14 -0000	1.7
  +++ PipeTest.java	28 Jan 2002 10:27:06 -0000	1.8
  @@ -12,6 +12,9 @@
   import org.apache.commons.altrmi.server.impl.piped.AbstractPipedServer;
   import org.apache.commons.altrmi.server.impl.piped.PipedObjectStreamServer;
   import org.apache.commons.altrmi.server.impl.classretrievers.JarFileClassRetriever;
  +import org.apache.commons.altrmi.server.impl.classretrievers.NoClassRetriever;
  +import org.apache.commons.altrmi.server.impl.classretrievers.DynamicGeneratorClassRetriever;
  +import org.apache.commons.altrmi.server.ClassRetriever;
   import org.apache.commons.altrmi.client.AltrmiHostContext;
   import org.apache.commons.altrmi.client.impl.socket.SocketObjectStreamHostContext;
   import org.apache.commons.altrmi.client.AltrmiFactory;
  @@ -23,6 +26,7 @@
   import java.io.IOException;
   import java.io.PipedInputStream;
   import java.io.PipedOutputStream;
  +import java.io.File;
   
   
   /**
  @@ -30,7 +34,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.7 $
  + * @version $Revision: 1.8 $
    */
   public class PipeTest {
   
  @@ -52,10 +56,30 @@
           mServerOrClientFactory = args[0];
   
           AbstractPipedServer ps = new PipedObjectStreamServer();
  +
  +        TestInterfaceImpl ti = new TestInterfaceImpl();
  +
  +        ClassRetriever cr = new NoClassRetriever();
           if (mServerOrClientFactory.equals("S")) {
  -            ps.setClassRetriever(new JarFileClassRetriever("build/classes2"));
  +            cr = new JarFileClassRetriever("build/classes2");
  +        } else if (mServerOrClientFactory.equals("D")) {
  +            DynamicGeneratorClassRetriever dr = new DynamicGeneratorClassRetriever();
  +
  +            File source = new File("testSource");
  +            source.mkdir();
  +            File gen = new File("testGenerated");
  +            gen.mkdir();
  +
  +            dr.setAltrmiClasspath("build/classes");
  +            dr.setSrcGenDir(source.getAbsolutePath());
  +            dr.setClassGenDir(gen.getAbsolutePath());
  +
  +            dr.generate(ti,"Hello",TestInterface.class, TestInterface2.class);
  +            cr = dr;
  +
           }
  -        TestInterfaceImpl ti = new TestInterfaceImpl();
  +        ps.setClassRetriever(cr);
  +
   
           ps.publish(ti, "Hello", TestInterface.class, TestInterface2.class);
           ps.start();
  @@ -71,7 +95,7 @@
        *
        *
        * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  -     * @version $Revision: 1.7 $
  +     * @version $Revision: 1.8 $
        */
       static class PipedTestClient implements Runnable {
   
  @@ -101,7 +125,8 @@
                   AltrmiHostContext arhc = new PipedObjectStreamHostContext(in, out);
                   mPipedServer.makeNewConnection(in, out);
                   AltrmiFactory af = null;
  -                if (mServerOrClientFactory.equals("S")) {
  +                if (mServerOrClientFactory.equals("S")
  +                    | mServerOrClientFactory.equals("D")) {
                       af = new ServerClassAltrmiFactory(false);
                   } else {
                       af = new ClientClassAltrmiFactory(false);
  
  
  

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


Mime
View raw message