// static method invocation
try
{
Object[] args = new Object[] { "This", " is", " a", " remoting", " test" };
RemotingRequest request = new RemotingRequest( RemoteTestMethods.class.getName(), "buildStaticString",
new Object[] { args } );
Object result = client.execute( request );
assertNotNull( result );
assertEquals( ContentStringBuilder.toString( args ), result );
}
catch ( IOException e )
{
e.printStackTrace();
fail( e.getMessage() );
}
// instance method invocations
try
{
Object[] args = new Object[] { "This", " is", " a", " remoting", " test" };
RemotingRequest request = new RemotingRequest( RemoteTestMethods.class.getName(), "buildString",
new Object[] { args } );
Object result = client.execute( request );
assertNotNull( result );
assertEquals( ContentStringBuilder.toString( args ), result );
Integer sum = Integer.valueOf( 3 );
request = new RemotingRequest( RemoteTestMethods.class.getName(), "add", new Object[] {
Integer.valueOf( 1 ), Integer.valueOf( 2 ) } );
result = client.execute( request );
assertNotNull( result );
assertEquals( sum, result );
request = new RemotingRequest( RemoteTestMethods.class.getName(), "add", new Object[] {
Integer.valueOf( 1 ), Integer.valueOf( 2 ) } );
result = client.execute( request );
assertNotNull( result );
assertEquals( sum, result );
request = new RemotingRequest( RemoteTestMethods.class.getName(), "subtract", new Object[] {
Integer.valueOf( 3 ), Integer.valueOf( 1 ) } );
result = client.execute( request );
assertNotNull( result );
assertEquals( Integer.valueOf( 2 ), result );
}
catch ( IOException e )
{
e.printStackTrace();
fail( e.getMessage() );
}
// default constructor invocation
try
{
RemotingRequest request = new RemotingRequest( RemoteTestMethods.class.getName(), "RemoteTestMethods",
new Object[] {} );
Object result = client.execute( request );
assertNotNull( result );
assertTrue( result instanceof RemoteTestMethods );
}
catch ( IOException e )
{
e.printStackTrace();
fail( e.getMessage() );
}
// parameterized constructor invocation
try
{
RemotingRequest request = new RemotingRequest( RemoteTestMethods.class.getName(), "RemoteTestMethods",
new Object[] { Boolean.TRUE } );
Object result = client.execute( request );
assertNotNull( result );
assertTrue( result instanceof RemoteTestMethods );
request = new RemotingRequest( RemoteTestMethods.class.getName(), "RemoteTestMethods",
new Object[] { Boolean.FALSE } );
result = client.execute( request );
assertNotNull( result );
assertTrue( result instanceof RemoteTestMethods );
request = new RemotingRequest( RemoteTestMethods.class.getName(), "RemoteTestMethods", new Object[] {
Boolean.TRUE, Boolean.FALSE } );
result = client.execute( request );
assertNotNull( result );
assertTrue( result instanceof RemoteTestMethods );
}