1 7 package org.jboss.test.remoting.handler.mbean; 8 9 import javax.management.MBeanServer ; 10 import javax.management.MBeanServerFactory ; 11 import javax.management.ObjectName ; 12 import org.jboss.jrunit.extensions.ServerTestCase; 13 import org.jboss.remoting.InvokerLocator; 14 import org.jboss.remoting.transport.Connector; 15 16 19 public class ServerTest extends ServerTestCase 20 { 21 private static String transport = "socket"; 23 private static String host = "localhost"; 24 private static int port = 5400; 25 26 private String locatorURI = transport + "://" + host + ":" + port; 27 private Connector connector; 28 29 public static final String RESPONSE_VALUE = "This is the return from the TestServer invocation"; 31 32 public void setupServer() throws Exception 33 { 34 MBeanServer server = MBeanServerFactory.createMBeanServer(); 35 36 InvokerLocator locator = new InvokerLocator(locatorURI); 37 System.out.println("Starting remoting server with locator uri of: " + locatorURI); 38 connector = new Connector(); 39 connector.setInvokerLocator(locator.getLocatorURI()); 40 connector.start(); 41 42 server.registerMBean(connector, new ObjectName ("test:type=connector,transport=socket")); 43 44 MBeanHandler handler = new MBeanHandler(); 46 ObjectName objName = new ObjectName ("test:type=handler"); 47 server.registerMBean(handler, objName); 48 49 connector.addInvocationHandler("test", objName); 50 } 51 52 public void setUp() throws Exception 53 { 54 setupServer(); 55 } 56 57 public void tearDown() throws Exception 58 { 59 if(connector != null) 60 { 61 connector.stop(); 62 connector.destroy(); 63 } 64 } 65 66 72 public static void main(String [] args) 73 { 74 ServerTest serverTest = new ServerTest(); 75 try 76 { 77 serverTest.setUp(); 78 } 79 catch(Exception e) 80 { 81 e.printStackTrace(); 82 } 83 } 84 } | Popular Tags |