vinayc 2003/08/28 11:22:38
Added: integrationtests/src/test/org/apache/altrmi/test/proxies
CodedProxyTestCase.java
CodedProxyTestInterfaceProxy.java DynamicProxy.java
DynamicProxyTestCase.java NonProxyTestCase.java
Log:
Refactorize (includes modularize,mavenize & rest of the nice's)
Revision Changes Path
1.1
incubator-altrmi/integrationtests/src/test/org/apache/altrmi/test/proxies/CodedProxyTestCase.java
Index: CodedProxyTestCase.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 1997-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software
* itself, if and wherever such third-party acknowledgments
* normally appear.
*
* 4. The names "Incubator", "AltRMI", and "Apache Software Foundation"
* must not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.altrmi.test.proxies;
import org.apache.altrmi.test.TestInterfaceImpl;
import org.apache.altrmi.test.AbstractHelloCallBackTestCase;
/**
* Test Hand Coded Proxy for comparison sake
* @author Paul Hammant
*/
public class CodedProxyTestCase extends AbstractHelloCallBackTestCase
{
public CodedProxyTestCase(String name)
{
super(name);
}
protected void setUp() throws Exception
{
super.setUp();
testServer = new TestInterfaceImpl();
testClient = new CodedProxyTestInterfaceProxy( testServer );
}
}
1.1
incubator-altrmi/integrationtests/src/test/org/apache/altrmi/test/proxies/CodedProxyTestInterfaceProxy.java
Index: CodedProxyTestInterfaceProxy.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 1997-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software
* itself, if and wherever such third-party acknowledgments
* normally appear.
*
* 4. The names "Incubator", "AltRMI", and "Apache Software Foundation"
* must not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.altrmi.test.proxies;
import java.beans.PropertyVetoException;
import java.io.IOException;
import org.apache.altrmi.test.*;
/**
* Class CodedProxyTestInterfaceProxy
*
*
* @author Paul Hammant <a href="mailto:[EMAIL PROTECTED]">[EMAIL
PROTECTED]</a>
* @author Benjamin David Hall
* @version $Revision: 1.1 $
*/
public class CodedProxyTestInterfaceProxy implements TestInterface
{
private TestInterface m_actualImpl;
/**
* Constructor CodedProxyTestInterfaceProxy
*
*
* @param actualImpl
*
*/
public CodedProxyTestInterfaceProxy( TestInterface actualImpl )
{
m_actualImpl = actualImpl;
}
/**
* Method hello
*
*
* @param greeting
*
*/
public void hello( String greeting )
{
m_actualImpl.hello( greeting );
}
/**
* Method hello2
*
*
* @param greeting
*
*/
public int hello2( int greeting )
{
return m_actualImpl.hello2( greeting );
}
/**
* Method hello3
*
*
* @param greeting
*
* @return
*
* @throws IOException
* @throws PropertyVetoException
*
*/
public boolean hello3( short greeting ) throws PropertyVetoException,
IOException
{
return m_actualImpl.hello3( greeting );
}
/**
* Method hello4
*
*
* @param greeting1
* @param greeting2
*
* @return
*
*/
public StringBuffer hello4( float greeting1, double greeting2 )
{
return m_actualImpl.hello4( greeting1, greeting2 );
}
/**
* Method testSpeed
*
*
*/
public void testSpeed()
{
m_actualImpl.testSpeed();
}
/**
* Method makeTestInterface2
*
*
* @param thingName
*
* @return
*
*/
public TestInterface2 makeTestInterface2( String thingName )
{
return m_actualImpl.makeTestInterface2( thingName );
}
/**
* Method morphName
*
*
* @param forThisImpl
*
*/
public void morphName( TestInterface2 forThisImpl )
{
m_actualImpl.morphName( forThisImpl );
}
/**
* Method findTestInterface2ByName
*
*
* @param nameToFind
*
* @return
*
*/
public TestInterface2 findTestInterface2ByName( String nameToFind )
{
return m_actualImpl.findTestInterface2ByName( nameToFind );
}
/**
* Method getTestInterface2s
*
*
* @return
*
*/
public TestInterface2[] getTestInterface2s()
{
return m_actualImpl.getTestInterface2s();
}
/**
* Method getTestObjects
* Helps ilustrate the bug
http://developer.java.sun.com/developer/bugParade/bugs/4499841.html
*
* @return
*
*/
public TestObject[] getTestObjects()
{
return m_actualImpl.getTestObjects();
}
/**
* Method changeTestObjectNames
* Helps ilustrate the bug
http://developer.java.sun.com/developer/bugParade/bugs/4499841.html
*
*
*/
public void changeTestObjectNames()
{
m_actualImpl.changeTestObjectNames();
}
/**
* Method makeNewTestObjectNames
* Helps ilustrate the bug
http://developer.java.sun.com/developer/bugParade/bugs/4499841.html
*
*/
public void makeNewTestObjectNames()
{
m_actualImpl.makeNewTestObjectNames();
}
public boolean addCallBackListener(TestCallBackListener
testCallbackListener)
{
return m_actualImpl.addCallBackListener(testCallbackListener);
}
public void ping()
{
m_actualImpl.ping();
}
public byte bytes(byte b, byte[] array) {
return m_actualImpl.bytes(b, array);
}
public void throwSpecialException(int i)
{
m_actualImpl.throwSpecialException(i);
}
public void testLong(long l) {
}
public String toString()
{
return m_actualImpl.toString();
}
public int hashCode()
{
return m_actualImpl.hashCode();
}
}
1.1
incubator-altrmi/integrationtests/src/test/org/apache/altrmi/test/proxies/DynamicProxy.java
Index: DynamicProxy.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 1997-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software
* itself, if and wherever such third-party acknowledgments
* normally appear.
*
* 4. The names "Incubator", "AltRMI", and "Apache Software Foundation"
* must not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.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 Peter Donald
* @author Paul Hammant
* @version CVS $Revision: 1.1 $ $Date: 2003/08/28 18:22:38 $
* @since 4.0b5
*/
public final class DynamicProxy implements InvocationHandler
{
private transient Object m_object;
/**
* Private constructor that blockpublishing 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
incubator-altrmi/integrationtests/src/test/org/apache/altrmi/test/proxies/DynamicProxyTestCase.java
Index: DynamicProxyTestCase.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 1997-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software
* itself, if and wherever such third-party acknowledgments
* normally appear.
*
* 4. The names "Incubator", "AltRMI", and "Apache Software Foundation"
* must not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.altrmi.test.proxies;
import org.apache.altrmi.test.TestInterface;
import org.apache.altrmi.test.TestInterfaceImpl;
import org.apache.altrmi.test.AbstractHelloCallBackTestCase;
/**
* Test Dynamic Proxy (reflection) for comparison sake
* @author Paul Hammant
*/
public class DynamicProxyTestCase extends AbstractHelloCallBackTestCase
{
public DynamicProxyTestCase(String name)
{
super(name);
}
protected void setUp() throws Exception
{
super.setUp();
testServer = new TestInterfaceImpl();
testClient = (TestInterface) DynamicProxy.newInstance( testServer,
new Class[]{TestInterface.class} );
}
}
1.1
incubator-altrmi/integrationtests/src/test/org/apache/altrmi/test/proxies/NonProxyTestCase.java
Index: NonProxyTestCase.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 1997-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software
* itself, if and wherever such third-party acknowledgments
* normally appear.
*
* 4. The names "Incubator", "AltRMI", and "Apache Software Foundation"
* must not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.altrmi.test.proxies;
import org.apache.altrmi.test.TestInterfaceImpl;
import org.apache.altrmi.test.AbstractHelloCallBackTestCase;
/**
* Test Non Proxy for comparison sake
* @author Paul Hammant
*/
public class NonProxyTestCase extends AbstractHelloCallBackTestCase
{
public NonProxyTestCase(String name)
{
super(name);
}
protected void setUp() throws Exception
{
super.setUp();
testServer = new TestInterfaceImpl();
testClient = testServer;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]