1 7 package org.jboss.test.remoting.byvalue; 8 9 import org.jboss.remoting.Client; 10 import org.jboss.remoting.InvokerLocator; 11 import org.jboss.remoting.ServerInvocationHandler; 12 import org.jboss.remoting.invocation.NameBasedInvocation; 13 import org.jboss.remoting.transport.Connector; 14 import org.jboss.test.remoting.transport.mock.MockServerInvocationHandler; 15 16 import junit.framework.TestCase; 17 18 24 public class ByValueInvocationTestCase extends TestCase 25 { 26 public ByValueInvocationTestCase(String name) 27 { 28 super(name); 29 } 30 31 public static void setupConfiguration(InvokerLocator locator, ServerInvocationHandler invocationHandler) throws Exception 32 { 33 Connector connector = new Connector(); 34 connector.setInvokerLocator(locator.getLocatorURI()); 35 connector.start(); 36 connector.addInvocationHandler("mock", invocationHandler); 37 } 38 39 public void testInvocation() throws Throwable 40 { 41 InvokerLocator locator = new InvokerLocator("rmi://localhost:5400/?" + 42 InvokerLocator.BYVALUE + "=" + Boolean.TRUE.toString()); 43 ServerInvocationHandler invocationHandler = new MockServerInvocationHandler(); 44 45 ByValueInvocationTestCase.setupConfiguration(locator, invocationHandler); 47 48 Thread.sleep(3000); 49 50 Client remotingClient = new Client(locator, null); 52 ByValuePayload byValuePayload = new ByValuePayload(); 53 Object response = remotingClient.invoke(new NameBasedInvocation("testByValue", 54 new Object []{byValuePayload}, 55 new String []{byValuePayload.getClass().getName()}), 56 null); 57 58 System.out.println("Invocation response: " + response); 59 if(response instanceof Boolean ) 60 { 61 assertTrue("Result of testByValue is false.", ((Boolean ) response).booleanValue()); 62 } 63 else 64 { 65 assertTrue("Result of testByValue was not even of type Boolean.", false); 66 } 67 68 } 69 70 } | Popular Tags |