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 ProConClientTest.java ProConServerTest.java TestConsumer.java TestConsumerImpl.java TestProvider.java TestProviderImpl.java
Date Mon, 18 Feb 2002 21:40:28 GMT
hammant     02/02/18 13:40:28

  Modified:    altrmi   PROPOSAL tests.xml
  Added:       altrmi   tests2.xml
               altrmi/src/java/org/apache/commons/altrmi/test
                        ProConClientTest.java ProConServerTest.java
                        TestConsumer.java TestConsumerImpl.java
                        TestProvider.java TestProviderImpl.java
  Log:
  Vinays new tests
  
  Revision  Changes    Path
  1.13      +2 -3      jakarta-commons-sandbox/altrmi/PROPOSAL
  
  Index: PROPOSAL
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/PROPOSAL,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- PROPOSAL	26 Jan 2002 15:22:16 -0000	1.12
  +++ PROPOSAL	18 Feb 2002 21:40:28 -0000	1.13
  @@ -94,7 +94,8 @@
   
     - Classes providing client side implementation of the transported 
       interface(s) can be either on the client side or the server side (and 
  -    duly transported) at time of lookup.
  +    duly transported) at time of lookup.  On the server side, the proxy classes
  +    cal be generated in advance (Ant Task) or at runtime - javac is invoked.
       
   6) Choice of castability of generated proxy class.
   
  @@ -185,8 +186,6 @@
   
        
   3) Client and Server code for secure conversations.
  -
  -4) Keep alive / ping concept.
   
   
   Initial committers:
  
  
  
  1.7       +2 -2      jakarta-commons-sandbox/altrmi/tests.xml
  
  Index: tests.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/tests.xml,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- tests.xml	1 Feb 2002 00:17:00 -0000	1.6
  +++ tests.xml	18 Feb 2002 21:40:28 -0000	1.7
  @@ -3,7 +3,7 @@
   
   <!--
           "Alt (to) RMI" component of the Jakarta Commons Subproject
  -        $Id: tests.xml,v 1.6 2002/02/01 00:17:00 hammant Exp $
  +        $Id: tests.xml,v 1.7 2002/02/18 21:40:28 hammant Exp $
   -->
   
   
  @@ -43,7 +43,7 @@
     <path id="testA.classpath">
       <pathelement location="${build.home}/classes"/>
       <pathelement location="${build.home}/classes2"/>
  -    <pathelement location="lib/JSX0.9.7.1.jar"/>
  +    <pathelement location="lib/JSX0.9.8.1.jar"/>
     </path>  
     
     <path id="testB1.classpath">
  
  
  
  1.1                  jakarta-commons-sandbox/altrmi/tests2.xml
  
  Index: tests2.xml
  ===================================================================
  <project name="Alt (to) RMI" default="generate" basedir=".">
  
  
  <!--
          "Alt (to) RMI" component of the Jakarta Commons Subproject
          $Id: tests2.xml,v 1.1 2002/02/18 21:40:28 hammant Exp $
  -->
  
  
  <!-- ========== Initialize Properties ===================================== -->
  
  
    <property file="build.properties"/>                <!-- Component local   -->
    <property file="../build.properties"/>             <!-- Commons local     -->
    <property file="${user.home}/build.properties"/>   <!-- User local        -->
   
  
  <!-- ========== Component Declarations ==================================== -->
  
  
    <!-- The base directory for compilation targets -->
    <property name="build.home"              value="build"/>
  
  
  <!-- ========== Compiler Defaults ========================================= -->
  
  
    <!-- Should Java compilations set the 'debug' compiler option? -->
    <property name="compile.debug"           value="true"/>
  
    <!-- Should Java compilations set the 'deprecation' compiler option? -->
    <property name="compile.deprecation"     value="true"/>
  
    <!-- Should Java compilations set the 'optimize' compiler option? -->
    <property name="compile.optimize"        value="true"/>
  
    <!-- Construct compile classpath -->
    <path id="compile.classpath">
      <pathelement location="${build.home}/classes"/>
    </path>
    
    <!-- For running of tests -->
    <path id="testA.classpath">
      <pathelement location="${build.home}/classes"/>
      <pathelement location="${build.home}/classes2"/>
      <pathelement location="lib/JSX0.9.7.1.jar"/>
    </path>  
    
    <path id="testB1.classpath">
      <pathelement location="${build.home}/classes"/>
      <pathelement location="${build.home}/classes3"/>
    </path>    
      
    <path id="testB2.classpath">
      <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">
      <classpath refid="compile.classpath" />
    </taskdef>
    
  
  <!-- ========== Executable Targets ======================================== -->
  
    <target name="prepare"
     description="Prepare build directory">
      <mkdir dir="${build.home}"/>
      <mkdir dir="${build.home}/classes2"/>  
      <delete>
        <fileset dir="${build.home}/classes2" includes="*" defaultexcludes="no"/>
      </delete>
      <mkdir dir="${build.home}/genjava"/>
      <delete>
        <fileset dir="${build.home}/genjava" includes="*" defaultexcludes="no"/>
      </delete>
      <mkdir dir="${build.home}/genjava2"/>
      <delete>
        <fileset dir="${build.home}/genjava2" includes="*" defaultexcludes="no"/>
      </delete>
      <mkdir dir="${build.home}/classes3"/>  
      <delete>
        <fileset dir="${build.home}/classes3" includes="*" defaultexcludes="no"/>
      </delete>
    </target>
  
    <target name="generate" depends="prepare">
       
      <altrmiinterfaces genname="P" srcgendir="${build.home}/genjava" 
          classgendir="${build.home}/classes2" 
          classesorinterfaces="org.apache.commons.altrmi.test.TestProvider" 
          additionalfacades="">
        <classpath>
          <pathelement location="${build.home}/classes"/>
        </classpath>
      </altrmiinterfaces>      
  	<altrmiinterfaces genname="C" srcgendir="${build.home}/genjava" 
          classgendir="${build.home}/classes2" 
          classesorinterfaces="org.apache.commons.altrmi.test.TestConsumer" 
          additionalfacades="">
        <classpath>
          <pathelement location="${build.home}/classes"/>
        </classpath>
      </altrmiinterfaces>          
    
    </target>
    
    <target name="procon-serve">
      <java classname="org.apache.commons.altrmi.test.ProConServerTest" fork="true">
        <classpath refid="testB1.classpath"/>
        <arg value="S"/>
        <arg value="ObjectStream"/>
      </java>      
    </target>
    
    <target name="procon-client" depends="generate">
      <java classname="org.apache.commons.altrmi.test.ProConClientTest" fork="true">
        <classpath refid="testB2.classpath"/>
        <arg value="S"/>
        <arg value="ObjectStream"/>
      </java>      
    </target>  
  
  </project>
  
  
  
  1.1                  jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/test/ProConClientTest.java
  
  Index: ProConClientTest.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.test;
  
  
  
  import org.apache.commons.altrmi.client.AltrmiHostContext;
  import org.apache.commons.altrmi.client.AltrmiFactory;
  import org.apache.commons.altrmi.common.AltrmiConnectionException;
  import org.apache.commons.altrmi.client.impl.socket.SocketObjectStreamHostContext;
  import org.apache.commons.altrmi.client.impl.socket.SocketCustomStreamHostContext;
  import org.apache.commons.altrmi.client.impl.ServerClassAltrmiFactory;
  import org.apache.commons.altrmi.client.impl.ClientClassAltrmiFactory;
  
  import java.io.IOException;
  
  
  /**
   * Class ProConClientTest
   *
   *
   * @author Vinay Chandrasekharan 
   */
  public class ProConClientTest {
  
      /**
       * Method main
       *
       *
       * @param args
       *
       * @throws Exception
       *
       */
      public static void main(String[] args) throws Exception {
  
          System.out.println("Stream over Socket Client");
  
          AltrmiHostContext arhc;
  
          if (args[1].equals("ObjectStream")) {
              System.out.println("(Object Stream)");
  
              arhc = new SocketObjectStreamHostContext("127.0.0.1", 1234);
          } else if (args[1].equals("JSX")) {
              System.out.println("(JSX Object Stream)");
  
              arhc = new SocketObjectStreamHostContext("127.0.0.1", 1234, "JSX.ObjIn",
                                                       "JSX.ObjOut");
          } else {
              System.out.println("(Custom Stream)");
  
              arhc = new SocketCustomStreamHostContext("127.0.0.1", 1235);
          }
  
          AltrmiFactory af = null;
  
          if (args[0].equals("S")) {
              af = new ServerClassAltrmiFactory(false);
          } else {
              af = new ClientClassAltrmiFactory(false);
          }
  
          af.setHostContext(arhc);
  
          //list
          System.out.println("Listing Published Objects At Server...");
  
          String[] listOfPublishedObjectsOnServer = af.list();
  
          for (int i = 0; i < listOfPublishedObjectsOnServer.length; i++) {
              System.out.println("..[" + i + "]:" + listOfPublishedObjectsOnServer[i]);
          }
  
          TestProvider tpi = (TestProvider) af.lookup("P");
          TestConsumer tci = (TestConsumer) af.lookup("C");
  
  		System.out.println("Provider.getName(0)"+tpi.getName(0));
  		System.out.println("Consumer.getProviderName(0)"+tci.getProviderName(tpi));
          af.close();
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/test/ProConServerTest.java
  
  Index: ProConServerTest.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.test;
  
  
  
  import org.apache.commons.altrmi.server.impl.socket.CompleteSocketObjectStreamServer;
  import org.apache.commons.altrmi.server.impl.socket.CompleteSocketCustomStreamServer;
  import org.apache.commons.altrmi.server.impl.classretrievers.JarFileClassRetriever;
  import org.apache.commons.altrmi.server.impl.AbstractServer;
  
  import java.io.IOException;
  
  
  /**
   * Class ProConServerTest
   *
   *
   * @author Vinay Chandrasekharan
   */
  public class ProConServerTest {
  
      /**
       * Method main
       *
       *
       * @param args
       *
       * @throws Exception
       *
       */
      public static void main(String[] args) throws Exception {
  
          System.out.println("Stream over Socket Server");
  
          AbstractServer as;
  
          if (args[1].equals("ObjectStream")) {
              System.out.println("(Object Stream)");
              as = new CompleteSocketObjectStreamServer(1234);
          } else if (args[1].equals("JSX")) {
              System.out.println("(JSX Object Stream)");
              as = new CompleteSocketObjectStreamServer(1234, "JSX.ObjIn", "JSX.ObjOut");
          } else {
  
              // CustomStream
              System.out.println("(Custom Stream)");
  
              as = new CompleteSocketCustomStreamServer(1235);
          }
  
          if (args[0].equals("S")) {
              as.setClassRetriever(new JarFileClassRetriever("build/classes2"));
          }
  //provider
          TestProvider tpi = new TestProviderImpl();
          as.publish(tpi, "P", TestProvider.class);
  //consumer
          TestConsumer tci = new TestConsumerImpl();
          as.publish(tci, "C", TestConsumer.class);
  //start
          as.start();
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/test/TestConsumer.java
  
  Index: TestConsumer.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.test;
  
  
  
  /**
   * Interface Consumer
   *
   *
   * @author Vinay Chandrasekharan
   */
  public interface TestConsumer
  {
  	String getProviderName(TestProvider provider);
  }
  
  
  
  1.1                  jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/test/TestConsumerImpl.java
  
  Index: TestConsumerImpl.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.test;
  
  
  
  /**
   * Impl Consumer
   *
   *
   * @author Vinay Chandrasekharan
   */
  public class TestConsumerImpl implements TestConsumer
  {
  	public String getProviderName(TestProvider  provider)
  	{
  		System.out.println("TestConsumerImpl.getName() with provider["+provider.getClass()+"]");
  		return "CONSUMER:"+provider.getName(0);
  	}
  }
  
  
  
  1.1                  jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/test/TestProvider.java
  
  Index: TestProvider.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.test;
  
  
  
  /**
   * Interface Provider
   *
   *
   * @author Vinay Chandrasekharan
   */
  public interface TestProvider extends java.io.Serializable
  {
  	String getName(int ID);
  }
  
  
  
  1.1                  jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/test/TestProviderImpl.java
  
  Index: TestProviderImpl.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.test;
  
  
  
  /**
   * Impl Provider
   *
   *
   * @author Vinay Chandrasekharan
   */
  public class TestProviderImpl implements TestProvider
  {
  	public String getName(int ID)
  	{
  		System.out.println("TestProviderImpl.getName()");
  		return "SAME:"+ID;
  	}
  }
  
  
  

--
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