hammant     02/01/17 15:42:13

  Modified:    altrmi   altrmi-tests.xml
  Added:       altrmi/src/java/org/apache/commons/altrmi/test
                        CodedProxyTest.java DynamicProxy.java
                        DynamicProxyTest.java UnProxyTest.java
  Log:
  new tests
  
  Revision  Changes    Path
  1.5       +19 -1     jakarta-commons-sandbox/altrmi/altrmi-tests.xml
  
  Index: altrmi-tests.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/altrmi-tests.xml,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- altrmi-tests.xml  17 Jan 2002 12:14:28 -0000      1.4
  +++ altrmi-tests.xml  17 Jan 2002 23:42:13 -0000      1.5
  @@ -3,7 +3,7 @@
   
   <!--
           "Alt (to) RMI" component of the Jakarta Commons Subproject
  -        $Id: altrmi-tests.xml,v 1.4 2002/01/17 12:14:28 hammant Exp $
  +        $Id: altrmi-tests.xml,v 1.5 2002/01/17 23:42:13 hammant Exp $
   -->
   
   
  @@ -177,6 +177,24 @@
         <arg value="C"/>
       </java>      
     </target>
  +
  +  <target name="test5" depends="generate">
  +    <java classname="org.apache.commons.altrmi.test.DynamicProxyTest" fork="true">
  +      <classpath refid="testA.classpath"/>
  +    </java>      
  +  </target>
  +  
  +  <target name="test6" depends="generate">
  +    <java classname="org.apache.commons.altrmi.test.CodedProxyTest" fork="true">
  +      <classpath refid="testA.classpath"/>
  +    </java>      
  +  </target>  
  +
  +  <target name="test7" depends="generate">
  +    <java classname="org.apache.commons.altrmi.test.UnProxyTest" fork="true">
  +      <classpath refid="testA.classpath"/>
  +    </java>      
  +  </target>  
   
     <target name="test1b-serve">
       <java classname="org.apache.commons.altrmi.test.SocketServerTest" fork="true">
  
  
  
  1.1                  
jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/test/CodedProxyTest.java
  
  Index: CodedProxyTest.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 java.beans.PropertyVetoException;
  import java.io.IOException;
  
  
  /**
   * Class CodedProxyTest
   *
   *
   * @author Paul Hammant <a 
href="mailto:[EMAIL PROTECTED]";>[EMAIL PROTECTED]</a>
   * @version $Revision: 1.1 $
   */
  public class CodedProxyTest {
  
      /**
       * Method main
       *
       *
       * @param args
       *
       * @throws Exception
       *
       */
      public static void main(String[] args) throws Exception {
  
          System.out.println("CodedProxy Test");
  
          TestInterfaceImpl ti = new TestInterfaceImpl();
  
          TestInterface proxy = new CodedTestInterfaceProxy(ti);
  
          TestClient tc = new TestClient(proxy);
  
      }
  
      static class CodedTestInterfaceProxy implements TestInterface {
          private TestInterface mActualImpl;
  
          public CodedTestInterfaceProxy(TestInterface actualImpl) {
              mActualImpl = actualImpl;
          }
  
          /**
           * Method hello
           *
           *
           * @param greeting
           *
           */
          public void hello(String greeting) {
              mActualImpl.hello(greeting);
          }
  
          /**
           * Method hello2
           *
           *
           * @param greeting
           *
           */
          public void hello2(int greeting) {
              mActualImpl.hello2(greeting);
          }
  
          /**
           * Method hello3
           *
           *
           * @param greeting
           *
           * @return
           *
           * @throws IOException
           * @throws PropertyVetoException
           *
           */
          public boolean hello3(short greeting) throws PropertyVetoException, 
IOException {
              return mActualImpl.hello3(greeting);
          }
  
          /**
           * Method hello4
           *
           *
           * @param greeting1
           * @param greeting2
           *
           * @return
           *
           */
          public StringBuffer hello4(float greeting1, double greeting2) {
              return  mActualImpl.hello4(greeting1, greeting2);
          }
  
          /**
           * Method testSpeed
           *
           *
           */
          public void testSpeed() {
              mActualImpl.testSpeed();
          }
  
          /**
           * Method testSpeed2
           *
           *
           * @param string
           *
           * @return
           *
           */
          public String testSpeed2(String string) {
              return mActualImpl.testSpeed2(string);
          }
  
          /**
           * Method makeTestInterface2
           *
           *
           * @param thingName
           *
           * @return
           *
           */
          public TestInterface2 makeTestInterface2(String thingName) {
              return mActualImpl.makeTestInterface2(thingName);
          }
  
          /**
           * Method morphName
           *
           *
           * @param forThisImpl
           *
           */
          public void morphName(TestInterface2 forThisImpl) {
              mActualImpl.morphName(forThisImpl);
          }
  
          /**
           * Method findTestInterface2ByName
           *
           *
           * @param nameToFind
           *
           * @return
           *
           */
          public TestInterface2 findTestInterface2ByName(String nameToFind) {
              return mActualImpl.findTestInterface2ByName(nameToFind);
          }
  
          /**
           * Method getTestObjects
           * Helps ilustrate the bug 
http://developer.java.sun.com/developer/bugParade/bugs/4499841.html
           *
           * @return
           *
           */
          public TestObject[] getTestObjects() {
              return mActualImpl.getTestObjects();
          }
  
          /**
           * Method changeTestObjectNames
           * Helps ilustrate the bug 
http://developer.java.sun.com/developer/bugParade/bugs/4499841.html
           *
           *
           */
          public void changeTestObjectNames() {
              mActualImpl.changeTestObjectNames();
          }
  
          /**
           * Method makeNewTestObjectNames
           * Helps ilustrate the bug 
http://developer.java.sun.com/developer/bugParade/bugs/4499841.html
           *
           */
          public void makeNewTestObjectNames() {
              mActualImpl.makeNewTestObjectNames();
          }
      }
  
  }
  
  
  
  1.1                  
jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/test/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.commons.altrmi.test;
  
  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:[EMAIL PROTECTED]";>Peter Donald</a>
   * @author <a href="mailto:[EMAIL PROTECTED]";>Paul Hammant</a>
   * @version CVS $Revision: 1.1 $ $Date: 2002/01/17 23:42:13 $
   * @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
       * @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                  
jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/test/DynamicProxyTest.java
  
  Index: DynamicProxyTest.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;
  
  
  /**
   * Class DynamicProxyTest
   *
   *
   * @author Paul Hammant <a 
href="mailto:[EMAIL PROTECTED]";>[EMAIL PROTECTED]</a>
   * @version $Revision: 1.1 $
   */
  public class DynamicProxyTest {
  
      /**
       * Method main
       *
       *
       * @param args
       *
       * @throws Exception
       *
       */
      public static void main(String[] args) throws Exception {
  
          System.out.println("DynamicProxy Test");
  
          TestInterfaceImpl ti = new TestInterfaceImpl();
  
          Object proxy = DynamicProxy.newInstance(ti, new Class[] { 
TestInterface.class });
  
          TestClient tc = new TestClient((TestInterface) proxy);
  
      }
  
  }
  
  
  
  1.1                  
jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/test/UnProxyTest.java
  
  Index: UnProxyTest.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 java.beans.PropertyVetoException;
  import java.io.IOException;
  
  
  /**
   * Class UnProxyTest
   *
   *
   * @author Paul Hammant <a 
href="mailto:[EMAIL PROTECTED]";>[EMAIL PROTECTED]</a>
   * @version $Revision: 1.1 $
   */
  public class UnProxyTest {
  
      /**
       * Method main
       *
       *
       * @param args
       *
       * @throws Exception
       *
       */
      public static void main(String[] args) throws Exception {
  
          System.out.println("UnProxy Test");
  
          TestInterfaceImpl ti = new TestInterfaceImpl();
  
          TestClient tc = new TestClient(ti);
  
      }
  
  }
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to