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/04/23 00:15:42 UTC
cvs commit: jakarta-avalon-excalibur/altrmi/src/test/org/apache/excalibur/altrmi/test CodedProxyTest.java DirectMarshalledTest.java DirectTest.java DynamicProxy.java DynamicProxyTest.java PipeTest.java RmiClientTest.java RmiServerTest.java UnProxyTest.java
hammant 02/04/22 15:15:41
Modified: altrmi piped.xml
Added: altrmi direct.xml proxies.xml rmi.xml
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/piped
PipedTest.java PipedTestClient.java
altrmi/src/test/org/apache/excalibur/altrmi/test/proxies
CodedProxyTest.java
CodedProxyTestInterfaceProxy.java DynamicProxy.java
DynamicProxyTest.java UnProxyTest.java
altrmi/src/test/org/apache/excalibur/altrmi/test/rmi
RmiClientTest.java RmiServerTest.java
Removed: altrmi/src/test/org/apache/excalibur/altrmi/test
CodedProxyTest.java DirectMarshalledTest.java
DirectTest.java DynamicProxy.java
DynamicProxyTest.java PipeTest.java
RmiClientTest.java RmiServerTest.java
UnProxyTest.java
Log:
work on tests - some resurected from commons existence
Revision Changes Path
1.3 +3 -3 jakarta-avalon-excalibur/altrmi/piped.xml
Index: piped.xml
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/piped.xml,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- piped.xml 18 Apr 2002 06:35:00 -0000 1.2
+++ piped.xml 22 Apr 2002 22:15:40 -0000 1.3
@@ -43,7 +43,7 @@
<ant antfile="base.xml" target="generate"/>
- <java classname="org.apache.excalibur.altrmi.test.PipeTest" fork="true">
+ <java classname="org.apache.excalibur.altrmi.test.piped.PipedTest" fork="true">
<classpath refid="test.classpath"/>
<arg value="C"/>
</java>
@@ -53,7 +53,7 @@
<ant antfile="base.xml" target="generate"/>
- <java classname="org.apache.excalibur.altrmi.test.PipeTest" fork="true">
+ <java classname="org.apache.excalibur.altrmi.test.piped.PipedTest" fork="true">
<classpath refid="test.classpath"/>
<arg value="S"/>
</java>
@@ -64,7 +64,7 @@
<ant antfile="base.xml" target="generate"/>
- <java classname="org.apache.excalibur.altrmi.test.PipeTest" fork="true">
+ <java classname="org.apache.excalibur.altrmi.test.piped.PipedTest" fork="true">
<classpath refid="test.classpath"/>
<arg value="D"/>
</java>
1.1 jakarta-avalon-excalibur/altrmi/direct.xml
Index: direct.xml
===================================================================
<project name="Alt (to) RMI" default="usage" basedir=".">
<!-- ========== Initialize Properties ===================================== -->
<property file="ant.properties"/> <!-- Component local -->
<property file="${user.home}/ant.properties"/> <!-- User local -->
<!-- ========== Component Declarations ==================================== -->
<!-- The base directory for compilation targets -->
<property name="build.home" value="build"/>
<!-- ========== Compiler Defaults ========================================= -->
<!-- For running of tests -->
<path id="test.classpath">
<pathelement location="${build.home}/classes"/>
<pathelement location="${build.home}/genclasses"/>
<pathelement location="${build.home}/testclasses"/>
<pathelement location="${avalon-framework.jar}"/>
</path>
<!-- ========== Executable Targets ======================================== -->
<target name="usage" description="Usage">
<echo>
Usage: Run this in two shells.
One with target server, the other with target client.
</echo>
</target>
<target name="direct" description="Direct Server (Client side classes)">
<java classname="org.apache.excalibur.altrmi.test.direct.DirectTest" fork="true">
<classpath refid="test.classpath"/>
<arg value="C"/>
</java>
</target>
<target name="direct-marshalled" description="Direct Marshalled Server (Client side classes)">
<java classname="org.apache.excalibur.altrmi.test.direct.DirectMarshalledTest" fork="true">
<classpath refid="test.classpath"/>
<arg value="C"/>
</java>
</target>
</project>
1.1 jakarta-avalon-excalibur/altrmi/proxies.xml
Index: proxies.xml
===================================================================
<project name="Alt (to) RMI" default="usage" basedir=".">
<!-- ========== Initialize Properties ===================================== -->
<property file="ant.properties"/> <!-- Component local -->
<property file="${user.home}/ant.properties"/> <!-- User local -->
<!-- ========== Component Declarations ==================================== -->
<!-- The base directory for compilation targets -->
<property name="build.home" value="build"/>
<!-- ========== Compiler Defaults ========================================= -->
<!-- For running of tests -->
<path id="test.classpath">
<pathelement location="${build.home}/classes"/>
<pathelement location="${build.home}/genclasses"/>
<pathelement location="${build.home}/testclasses"/>
<pathelement location="${avalon-framework.jar}"/>
</path>
<!-- ========== Executable Targets ======================================== -->
<target name="usage" description="Usage">
<echo>
Usage: Run this in two shells.
One with target server, the other with target client.
</echo>
</target>
<target name="dynamic-proxy" description="Dynamic Proxy Test">
<java classname="org.apache.excalibur.altrmi.test.proxies.DynamicProxyTest" fork="true">
<classpath refid="test.classpath"/>
<arg value="C"/>
</java>
</target>
<target name="coded-proxy" description="Coded Proxy Test">
<java classname="org.apache.excalibur.altrmi.test.proxies.CodedProxyTest" fork="true">
<classpath refid="test.classpath"/>
<arg value="C"/>
</java>
</target>
<target name="un-proxy" description="Un-Proxy Test">
<java classname="org.apache.excalibur.altrmi.test.proxies.UnProxyTest" fork="true">
<classpath refid="test.classpath"/>
<arg value="C"/>
</java>
</target>
</project>
1.1 jakarta-avalon-excalibur/altrmi/rmi.xml
Index: rmi.xml
===================================================================
<project name="Alt (to) RMI" default="usage" basedir=".">
<!-- ========== Initialize Properties ===================================== -->
<property file="ant.properties"/> <!-- Component local -->
<property file="${user.home}/ant.properties"/> <!-- User local -->
<!-- ========== Component Declarations ==================================== -->
<!-- The base directory for compilation targets -->
<property name="build.home" value="build"/>
<!-- ========== Compiler Defaults ========================================= -->
<!-- For running of tests -->
<path id="test.classpath">
<pathelement location="${build.home}/classes"/>
<pathelement location="${build.home}/genclasses"/>
<pathelement location="${build.home}/testclasses"/>
<pathelement location="${avalon-framework.jar}"/>
</path>
<!-- ========== Executable Targets ======================================== -->
<target name="usage" description="Usage">
<echo>
Usage: Run this in two shells.
One with target server, the other with target client.
</echo>
</target>
<target name="server" description="RMI Server (Client side classes)">
<rmic base="${build.home}/classes"
classname="org.apache.excalibur.altrmi.server.impl.rmi.RmiInovcationAdapter"
stubVersion="1.2">
<classpath refid="test.classpath" />
</rmic>
<java classname="org.apache.excalibur.altrmi.test.rmi.RmiServerTest" fork="true">
<classpath refid="test.classpath"/>
<arg value="C"/>
</java>
</target>
<target name="client" description="RMI Client (Client side classes)">
<ant antfile="base.xml" target="generate"/>
<java classname="org.apache.excalibur.altrmi.test.rmi.RmiClientTest" fork="true">
<classpath refid="test.classpath"/>
<arg value="C"/>
</java>
</target>
</project>
1.1 jakarta-avalon-excalibur/altrmi/src/test/org/apache/excalibur/altrmi/test/direct/DirectMarshalledTest.java
Index: DirectMarshalledTest.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.server.impl.direct.DirectServer;
import org.apache.excalibur.altrmi.server.impl.adapters.InvocationHandlerAdapter;
import org.apache.excalibur.altrmi.server.impl.adapters.MarshalledInvocationHandlerAdapter;
import org.apache.excalibur.altrmi.server.impl.direct.DirectMarshalledServer;
import org.apache.excalibur.altrmi.server.impl.classretrievers.JarFileClassRetriever;
import org.apache.excalibur.altrmi.server.PublicationDescription;
import org.apache.excalibur.altrmi.common.AltrmiInvocationHandler;
import org.apache.excalibur.altrmi.common.AltrmiConnectionException;
import org.apache.excalibur.altrmi.common.AltrmiMarshalledInvocationHandler;
import org.apache.excalibur.altrmi.client.AltrmiHostContext;
import org.apache.excalibur.altrmi.client.AltrmiFactory;
import org.apache.excalibur.altrmi.client.impl.direct.DirectHostContext;
import org.apache.excalibur.altrmi.client.impl.direct.DirectMarshalledHostContext;
import org.apache.excalibur.altrmi.client.impl.ServerClassAltrmiFactory;
import org.apache.excalibur.altrmi.client.impl.ClientClassAltrmiFactory;
import org.apache.excalibur.altrmi.test.TestInterfaceImpl;
import org.apache.excalibur.altrmi.test.TestInterface;
import org.apache.excalibur.altrmi.test.TestInterface2;
import org.apache.excalibur.altrmi.test.TestClient;
import java.io.IOException;
/**
* Class DirectTest
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
* @version $Revision: 1.1 $
*/
public class DirectMarshalledTest
{
private static String mServerOrClientFactory;
/**
* Method main
*
*
* @param args
*
* @throws Exception
*
*/
public static void main(String[] args) throws Exception
{
System.out.println("Direct Test");
String serverOrClientFactory = args[0];
DirectMarshalledServer ds = new DirectMarshalledServer();
if (serverOrClientFactory.equals("S"))
{
ds.setClassRetriever(new JarFileClassRetriever("build/classes2"));
}
TestInterfaceImpl ti = new TestInterfaceImpl();
ds.publish(ti, "Hello",
new PublicationDescription(TestInterface.class, TestInterface2.class));
ds.start();
DirectMarshalledTestClient dtc = new DirectMarshalledTestClient(ds, serverOrClientFactory);
Thread thread = new Thread(dtc);
thread.start();
}
}
1.1 jakarta-avalon-excalibur/altrmi/src/test/org/apache/excalibur/altrmi/test/direct/DirectMarshalledTestClient.java
Index: DirectMarshalledTestClient.java
===================================================================
/*
* Created by IntelliJ IDEA.
* User: Paulh
* Date: 22-Apr-02
* Time: 22:40:06
* To change template for new class use
* Code Style | Class Templates options (Tools | IDE Options).
*/
package org.apache.excalibur.altrmi.test.direct;
import org.apache.excalibur.altrmi.common.AltrmiMarshalledInvocationHandler;
import org.apache.excalibur.altrmi.common.AltrmiConnectionException;
import org.apache.excalibur.altrmi.client.AltrmiHostContext;
import org.apache.excalibur.altrmi.client.AltrmiFactory;
import org.apache.excalibur.altrmi.client.impl.direct.DirectMarshalledHostContext;
import org.apache.excalibur.altrmi.client.impl.ServerClassAltrmiFactory;
import org.apache.excalibur.altrmi.client.impl.ClientClassAltrmiFactory;
import org.apache.excalibur.altrmi.test.TestInterface;
import org.apache.excalibur.altrmi.test.TestClient;
import java.io.IOException;
/**
* Class DirectTestClient
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
* @version $Revision: 1.1 $
*/
public class DirectMarshalledTestClient implements Runnable
{
private AltrmiMarshalledInvocationHandler mInvocationHandler;
private String mServerOrClientFactory;
/**
* Constructor DirectTestClient
*
*
* @param ih
*
*/
public DirectMarshalledTestClient(AltrmiMarshalledInvocationHandler ih, String serverOrClient)
{
mInvocationHandler = ih;
mServerOrClientFactory = serverOrClient;
}
/**
* Method run
*
*
*/
public void run()
{
try
{
AltrmiHostContext arhc = new DirectMarshalledHostContext(mInvocationHandler);
AltrmiFactory af = null;
if (mServerOrClientFactory.equals("S"))
{
af = new ServerClassAltrmiFactory(false);
}
else
{
af = new ClientClassAltrmiFactory(false);
}
af.setHostContext(arhc);
TestInterface ti = (TestInterface) af.lookup("Hello");
TestClient tc = new TestClient(ti);
af.close();
}
catch (IOException ioe)
{
System.err.println("Some problem during connection to server : "
+ ioe.getMessage());
}
catch (AltrmiConnectionException ace)
{
System.err.println("Some problem during connection to server : "
+ ace.getMessage());
}
}
}
1.1 jakarta-avalon-excalibur/altrmi/src/test/org/apache/excalibur/altrmi/test/direct/DirectTest.java
Index: DirectTest.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.server.impl.direct.DirectServer;
import org.apache.excalibur.altrmi.server.impl.adapters.InvocationHandlerAdapter;
import org.apache.excalibur.altrmi.server.impl.classretrievers.JarFileClassRetriever;
import org.apache.excalibur.altrmi.server.PublicationDescription;
import org.apache.excalibur.altrmi.common.AltrmiInvocationHandler;
import org.apache.excalibur.altrmi.common.AltrmiConnectionException;
import org.apache.excalibur.altrmi.client.AltrmiHostContext;
import org.apache.excalibur.altrmi.client.AltrmiFactory;
import org.apache.excalibur.altrmi.client.impl.direct.DirectHostContext;
import org.apache.excalibur.altrmi.client.impl.ServerClassAltrmiFactory;
import org.apache.excalibur.altrmi.client.impl.ClientClassAltrmiFactory;
import org.apache.excalibur.altrmi.test.TestInterfaceImpl;
import org.apache.excalibur.altrmi.test.TestInterface;
import org.apache.excalibur.altrmi.test.TestInterface2;
import org.apache.excalibur.altrmi.test.TestClient;
import java.io.IOException;
/**
* Class DirectTest
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
* @version $Revision: 1.1 $
*/
public class DirectTest
{
/**
* Method main
*
*
* @param args
*
* @throws Exception
*
*/
public static void main(String[] args) throws Exception
{
System.out.println("Direct Test");
String serverOrClientFactory = args[0];
DirectServer ds = new DirectServer();
if (serverOrClientFactory.equals("S"))
{
ds.setClassRetriever(new JarFileClassRetriever("build/classes2"));
}
TestInterfaceImpl ti = new TestInterfaceImpl();
ds.publish(ti, "Hello",
new PublicationDescription(TestInterface.class, TestInterface2.class));
ds.start();
DirectTestClient dtc = new DirectTestClient(ds, serverOrClientFactory);
Thread thread = new Thread(dtc);
thread.start();
}
}
1.1 jakarta-avalon-excalibur/altrmi/src/test/org/apache/excalibur/altrmi/test/direct/DirectTestClient.java
Index: DirectTestClient.java
===================================================================
/*
* Created by IntelliJ IDEA.
* User: Paulh
* Date: 22-Apr-02
* Time: 22:36:30
* To change template for new class use
* Code Style | Class Templates options (Tools | IDE Options).
*/
package org.apache.excalibur.altrmi.test.direct;
import org.apache.excalibur.altrmi.common.AltrmiInvocationHandler;
import org.apache.excalibur.altrmi.common.AltrmiConnectionException;
import org.apache.excalibur.altrmi.client.AltrmiHostContext;
import org.apache.excalibur.altrmi.client.AltrmiFactory;
import org.apache.excalibur.altrmi.client.impl.direct.DirectHostContext;
import org.apache.excalibur.altrmi.client.impl.ServerClassAltrmiFactory;
import org.apache.excalibur.altrmi.client.impl.ClientClassAltrmiFactory;
import org.apache.excalibur.altrmi.test.TestInterface;
import org.apache.excalibur.altrmi.test.TestClient;
import java.io.IOException;
/**
* Class DirectTestClient
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
* @version $Revision: 1.1 $
*/
public class DirectTestClient implements Runnable
{
private AltrmiInvocationHandler mInvocationHandler;
private String mServerOrClientFactory;
/**
* Constructor DirectTestClient
*
*
* @param ih
*
*/
public DirectTestClient(AltrmiInvocationHandler ih, String serverOrClient)
{
mInvocationHandler = ih;
mServerOrClientFactory = serverOrClient;
}
/**
* Method run
*
*
*/
public void run()
{
try
{
AltrmiHostContext arhc = new DirectHostContext(mInvocationHandler);
AltrmiFactory af = null;
if (mServerOrClientFactory.equals("S"))
{
af = new ServerClassAltrmiFactory(false);
}
else
{
af = new ClientClassAltrmiFactory(false);
}
af.setHostContext(arhc);
TestInterface ti = (TestInterface) af.lookup("Hello");
TestClient tc = new TestClient(ti);
af.close();
}
catch (IOException ioe)
{
System.err.println("Some problem during connection to server : "
+ ioe.getMessage());
}
catch (AltrmiConnectionException ace)
{
System.err.println("Some problem during connection to server : "
+ ace.getMessage());
}
}
}
1.1 jakarta-avalon-excalibur/altrmi/src/test/org/apache/excalibur/altrmi/test/piped/PipedTest.java
Index: PipedTest.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.piped;
import org.apache.excalibur.altrmi.server.impl.piped.AbstractPipedServer;
import org.apache.excalibur.altrmi.server.impl.piped.PipedObjectStreamServer;
import org.apache.excalibur.altrmi.server.impl.classretrievers.JarFileClassRetriever;
import org.apache.excalibur.altrmi.server.impl.classretrievers.NoClassRetriever;
import org.apache.excalibur.altrmi.server.impl.classretrievers.DynamicGeneratorClassRetriever;
import org.apache.excalibur.altrmi.server.ClassRetriever;
import org.apache.excalibur.altrmi.server.PublicationDescription;
import org.apache.excalibur.altrmi.client.AltrmiHostContext;
import org.apache.excalibur.altrmi.client.impl.socket.SocketObjectStreamHostContext;
import org.apache.excalibur.altrmi.client.AltrmiFactory;
import org.apache.excalibur.altrmi.common.AltrmiConnectionException;
import org.apache.excalibur.altrmi.client.impl.piped.PipedObjectStreamHostContext;
import org.apache.excalibur.altrmi.client.impl.ServerClassAltrmiFactory;
import org.apache.excalibur.altrmi.client.impl.ClientClassAltrmiFactory;
import org.apache.excalibur.altrmi.test.*;
import java.io.IOException;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
import java.io.File;
/**
* Class PipedTest
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
* @version $Revision: 1.1 $
*/
public class PipedTest
{
private static String serverOrClientFactory;
/**
* Method main
*
*
* @param args
*
* @throws Exception
*
*/
public static void main(String[] args) throws Exception
{
System.out.println("Piped Test");
serverOrClientFactory = args[0];
AbstractPipedServer ps = new PipedObjectStreamServer();
TestInterfaceImpl ti = new TestInterfaceImpl();
ClassRetriever cr = new NoClassRetriever();
PublicationDescription pd = new PublicationDescription(TestInterface.class,
new Class[]{
TestInterface3.class,
TestInterface2.class });
if (serverOrClientFactory.equals("S"))
{
cr = new JarFileClassRetriever("build" + File.separator + "classes2");
}
else if (serverOrClientFactory.equals("D"))
{
DynamicGeneratorClassRetriever dr =
new DynamicGeneratorClassRetriever(new File("build" + File.separator
+ "classes").toURL());
File source = new File("testSource");
source.mkdir();
File gen = new File("testGenerated");
gen.mkdir();
dr.setAltrmiClasspath("build" + File.separator + "classes");
dr.setSrcGenDir(source.getAbsolutePath());
dr.setClassGenDir(gen.getAbsolutePath());
dr.generate("Hello", pd, null);
cr = dr;
}
ps.setClassRetriever(cr);
ps.publish(ti, "Hello",pd);
ps.start();
PipedTestClient ptc = new PipedTestClient(ps, serverOrClientFactory);
Thread thread = new Thread(ptc);
thread.start();
}
}
1.1 jakarta-avalon-excalibur/altrmi/src/test/org/apache/excalibur/altrmi/test/piped/PipedTestClient.java
Index: PipedTestClient.java
===================================================================
/*
* Created by IntelliJ IDEA.
* User: Paulh
* Date: 22-Apr-02
* Time: 22:46:38
* To change template for new class use
* Code Style | Class Templates options (Tools | IDE Options).
*/
package org.apache.excalibur.altrmi.test.piped;
import org.apache.excalibur.altrmi.server.impl.piped.AbstractPipedServer;
import org.apache.excalibur.altrmi.client.AltrmiHostContext;
import org.apache.excalibur.altrmi.client.AltrmiFactory;
import org.apache.excalibur.altrmi.client.impl.piped.PipedObjectStreamHostContext;
import org.apache.excalibur.altrmi.client.impl.ServerClassAltrmiFactory;
import org.apache.excalibur.altrmi.client.impl.ClientClassAltrmiFactory;
import org.apache.excalibur.altrmi.test.TestInterface;
import org.apache.excalibur.altrmi.test.TestClient;
import org.apache.excalibur.altrmi.common.AltrmiConnectionException;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
import java.io.IOException;
/**
* Class PipedTestClient
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
* @version $Revision: 1.1 $
*/
public class PipedTestClient implements Runnable
{
private AbstractPipedServer mPipedServer;
private String mServerOrClientFactory;
/**
* Constructor PipedTestClient
*
*
* @param pipedServer
*
*/
public PipedTestClient(AbstractPipedServer pipedServer, String serverOrClient)
{
mPipedServer = pipedServer;
mServerOrClientFactory = serverOrClient;
}
/**
* Method run
*
*
*/
public void run()
{
try
{
PipedInputStream in = new PipedInputStream();
PipedOutputStream out = new PipedOutputStream();
AltrmiHostContext arhc = new PipedObjectStreamHostContext(in, out);
mPipedServer.makeNewConnection(in, out);
AltrmiFactory af = null;
if (mServerOrClientFactory.equals("S") | mServerOrClientFactory.equals("D"))
{
af = new ServerClassAltrmiFactory(false);
}
else
{
af = new ClientClassAltrmiFactory(false);
}
af.setHostContext(arhc);
TestInterface ti = (TestInterface) af.lookup("Hello");
TestClient tc = new TestClient(ti);
af.close();
}
catch (IOException ioe)
{
System.err.println("Some problem during connection to server : "
+ ioe.getMessage());
}
catch (AltrmiConnectionException ace)
{
System.err.println("Some problem during connection to server : "
+ ace.getMessage());
}
}
}
1.1 jakarta-avalon-excalibur/altrmi/src/test/org/apache/excalibur/altrmi/test/proxies/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.excalibur.altrmi.test.proxies;
import org.apache.excalibur.altrmi.test.TestClient;
import org.apache.excalibur.altrmi.test.TestInterface;
import org.apache.excalibur.altrmi.test.TestInterfaceImpl;
/**
* Class CodedProxyTest
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</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");
TestInterface ti = new TestInterfaceImpl();
TestInterface proxy = new CodedProxyTestInterfaceProxy(ti);
TestClient tc = new TestClient(proxy);
}
}
1.1 jakarta-avalon-excalibur/altrmi/src/test/org/apache/excalibur/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.excalibur.altrmi.test.proxies;
import org.apache.excalibur.altrmi.test.TestInterface;
import org.apache.excalibur.altrmi.test.TestInterface2;
import org.apache.excalibur.altrmi.test.TestObject;
import java.beans.PropertyVetoException;
import java.io.IOException;
/**
* 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 mActualImpl;
/**
* Constructor CodedProxyTestInterfaceProxy
*
*
* @param actualImpl
*
*/
public CodedProxyTestInterfaceProxy(TestInterface actualImpl)
{
mActualImpl = actualImpl;
}
/**
* Method hello
*
*
* @param greeting
*
*/
public void hello(String greeting)
{
mActualImpl.hello(greeting);
}
/**
* Method hello2
*
*
* @param greeting
*
*/
public int hello2(int greeting)
{
return 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 getTestInterface2s
*
*
* @return
*
*/
public TestInterface2[] getTestInterface2s()
{
return mActualImpl.getTestInterface2s();
}
/**
* 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-avalon-excalibur/altrmi/src/test/org/apache/excalibur/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.excalibur.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: 2002/04/22 22:15:40 $
* @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 jakarta-avalon-excalibur/altrmi/src/test/org/apache/excalibur/altrmi/test/proxies/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.excalibur.altrmi.test.proxies;
import org.apache.excalibur.altrmi.test.TestInterfaceImpl;
import org.apache.excalibur.altrmi.test.TestInterface;
import org.apache.excalibur.altrmi.test.TestClient;
/**
* Class DynamicProxyTest
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</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-avalon-excalibur/altrmi/src/test/org/apache/excalibur/altrmi/test/proxies/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.excalibur.altrmi.test.proxies;
import org.apache.excalibur.altrmi.test.TestInterfaceImpl;
import org.apache.excalibur.altrmi.test.TestClient;
import java.beans.PropertyVetoException;
import java.io.IOException;
/**
* Class UnProxyTest
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</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);
}
}
1.1 jakarta-avalon-excalibur/altrmi/src/test/org/apache/excalibur/altrmi/test/rmi/RmiClientTest.java
Index: RmiClientTest.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.rmi;
import org.apache.excalibur.altrmi.test.AbstractClientTest;
import org.apache.excalibur.altrmi.client.AltrmiHostContext;
import org.apache.excalibur.altrmi.client.impl.rmi.RmiHostContext;
import org.apache.excalibur.altrmi.common.AltrmiConnectionException;
/**
* Class RmiClientTest
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
* @version $Revision: 1.1 $
*/
public class RmiClientTest extends AbstractClientTest
{
protected AltrmiHostContext makeHostContext(String[] args) throws AltrmiConnectionException {
return new RmiHostContext("127.0.0.1", 4321);
}
/**
* Method main
*
*
* @param args
*
* @throws Exception
*
*/
public static void main(String[] args) throws Exception
{
AbstractClientTest act = new RmiClientTest();
act.test(args);
}
}
1.1 jakarta-avalon-excalibur/altrmi/src/test/org/apache/excalibur/altrmi/test/rmi/RmiServerTest.java
Index: RmiServerTest.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.rmi;
import org.apache.excalibur.altrmi.server.impl.rmi.RmiServer;
import org.apache.excalibur.altrmi.server.impl.classretrievers.JarFileClassRetriever;
import org.apache.excalibur.altrmi.server.impl.AbstractServer;
import org.apache.excalibur.altrmi.server.PublicationDescription;
import org.apache.excalibur.altrmi.server.AltrmiServerException;
import org.apache.excalibur.altrmi.test.TestInterfaceImpl;
import org.apache.excalibur.altrmi.test.TestInterface;
import org.apache.excalibur.altrmi.test.TestInterface2;
import org.apache.excalibur.altrmi.test.AbstractServerTest;
import java.io.IOException;
import java.net.MalformedURLException;
/**
* Class RmiServerTest
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
* @version $Revision: 1.1 $
*/
public class RmiServerTest extends AbstractServerTest
{
protected AbstractServer makeAbstractServer(String[] args) throws AltrmiServerException, MalformedURLException
{
AbstractServer as = new RmiServer("127.0.0.1", 4321);
if (args[0].equals("S"))
{
as.setClassRetriever(new JarFileClassRetriever("build/classes2"));
}
return as;
}
/**
* Method main
*
*
* @param args
*
* @throws Exception
*
*/
public static void main(String[] args) throws Exception
{
System.out.println("AltRMI over RMI Server");
AbstractServerTest ast = new RmiServerTest();
ast.launch(args);
}
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>