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