1 16 17 18 package org.apache.xmlrpc; 19 20 import junit.framework.TestCase; 21 22 29 abstract public class LocalServerRpcTest 30 extends TestCase 31 { 32 33 34 37 protected static final String HANDLER_NAME = "TestHandler"; 38 39 42 protected static final String REQUEST_PARAM_VALUE = "foobar"; 43 44 protected static int SERVER_PORT; 45 46 49 protected static final String REQUEST_PARAM_XML = 50 "<value>" + REQUEST_PARAM_VALUE + "</value>"; 51 52 55 protected static final String RPC_REQUEST = 56 "<?xml version=\"1.0\"?>\n" + 57 "<methodCall>\n" + 58 " <methodName>" + HANDLER_NAME + ".echo</methodName>\n" + 59 " <params><param>" + REQUEST_PARAM_XML + "</param></params>\n" + 60 "</methodCall>\n"; 61 62 public LocalServerRpcTest(String message) { 63 super(message); 64 } 65 66 protected WebServer webServer; 67 68 73 private void setUpWebServer(int port) { 74 webServer = new WebServer(port); 75 webServer.addHandler(HANDLER_NAME, new TestHandler()); 76 } 77 78 81 protected void setUpWebServer() { 82 setUpWebServer(SERVER_PORT); 83 } 84 85 88 protected void startWebServer() { 89 webServer.start(); 90 SERVER_PORT = webServer.serverSocket.getLocalPort(); 91 } 92 93 96 protected void stopWebServer() { 97 webServer.shutdown(); 98 } 99 100 protected class TestHandler { 101 public String echo(String message) { 102 return message; 103 } 104 } 105 } 106 | Popular Tags |