1 7 package org.jboss.test.remoting.transport.http; 8 9 import org.jboss.jrunit.extensions.ServerTestCase; 10 import org.jboss.remoting.InvokerLocator; 11 import org.jboss.remoting.transport.Connector; 12 import org.jboss.test.remoting.transport.web.ComplexObject; 13 import org.jboss.test.remoting.transport.web.WebInvocationHandler; 14 15 18 public class HTTPInvokerTestServer extends ServerTestCase implements HTTPInvokerConstants 19 { 20 public static final String RESPONSE_VALUE = "This is the return to SampleInvocationHandler invocation"; 22 public static final ComplexObject OBJECT_RESPONSE_VALUE = new ComplexObject(5, "dub", false); 23 24 public static final String NULL_RETURN_PARAM = "return_null"; 25 public static final String OBJECT_RETURN_PARAM = "return_object"; 26 27 private Connector connector = null; 28 29 public void setupServer() throws Exception 30 { 31 String locatorURI = transport + "://" + host + ":" + port; 32 InvokerLocator locator = new InvokerLocator(locatorURI); 33 System.out.println("Starting remoting server with locator uri of: " + locatorURI); 34 connector = new Connector(); 35 connector.setInvokerLocator(locator.getLocatorURI()); 36 connector.start(); 37 38 WebInvocationHandler invocationHandler = new WebInvocationHandler(); 39 connector.addInvocationHandler("sample", invocationHandler); 41 } 42 43 protected void setUp() throws Exception 44 { 45 setupServer(); 46 } 47 48 protected void tearDown() throws Exception 49 { 50 if(connector != null) 51 { 52 connector.stop(); 53 connector.destroy(); 54 } 55 } 56 57 public static void main(String [] args) 58 { 59 HTTPInvokerTestServer server = new HTTPInvokerTestServer(); 60 try 61 { 62 server.setUp(); 63 Thread.currentThread().sleep(300000); 64 } 65 catch(Exception e) 66 { 67 e.printStackTrace(); 68 } 69 finally 70 { 71 try 72 { 73 server.tearDown(); 74 } 75 catch(Exception e) 76 { 77 e.printStackTrace(); 78 } 79 } 80 } 81 82 } | Popular Tags |