Debian Codegraph @

test/wsdd/TestAdminService.java

raw
1 package test.wsdd;
2
3 import junit.framework.Test;
4 import junit.framework.TestCase;
5 import junit.framework.TestSuite;
6 import org.apache.axis.Handler;
7 import org.apache.axis.client.AdminClient;
8 import org.apache.axis.client.Call;
9 import org.apache.axis.configuration.XMLStringProvider;
10 import org.apache.axis.deployment.wsdd.WSDDConstants;
11 import org.apache.axis.server.AxisServer;
12 import org.apache.axis.transport.local.LocalTransport;
13
14 import java.io.ByteArrayInputStream;
15
16 /**
17 * Test WSDD functions via the AdminService.
18 *
19 * @author Glen Daniels ([email protected])
20 */
21 public class TestAdminService extends TestCase
22 {
23 static final String HANDLER_NAME = "logger";
24 static final String PARAM_NAME = "testParam";
25 static final String PARAM_VAL = "testValue";
26
27 static final String deployDoc =
28 "<deployment xmlns=\"http://xml.apache.org/axis/wsdd/\" " +
29 "xmlns:java=\"" + WSDDConstants.URI_WSDD_JAVA + "\">\n" +
30 " <handler type=\"java:org.apache.axis.handlers.LogHandler\" " +
31 "name=\"" + HANDLER_NAME + "\">\n" +
32 " <parameter name=\"" + PARAM_NAME +
33 "\" value=\"" + PARAM_VAL + "\"/>\n" +
34 " </handler>\n" +
35 " <handler type=\"logger\" name=\"other\"/>\n" +
36 " <service name=\"AdminService\" provider=\"java:MSG\">\n" +
37 " <parameter name=\"className\" value=\"org.apache.axis.utils.Admin\"/>" +
38 " <parameter name=\"methodName\" value=\"AdminService\"/>\n" +
39 " </service>\n" +
40 "</deployment>";
41
42 static final String undeployDoc =
43 "<undeployment xmlns=\"http://xml.apache.org/axis/wsdd/\">\n" +
44 " <handler name=\"other\"/>\n" +
45 "</undeployment>";
46
47 public TestAdminService (String name) {
48 super(name);
49 }
50
51 public static Test suite() {
52 return new TestSuite(TestAdminService.class);
53 }
54
55 protected void setup() {
56 }
57
58 /**
59 * Load up a server with a couple of handlers as spec'ed above,
60 * then undeploy one of them. Confirm that all looks reasonable
61 * throughout.
62 */
63 public void testUndeployHandlerViaAdmin() throws Exception
64 {
65 XMLStringProvider provider = new XMLStringProvider(deployDoc);
66 AxisServer server = new AxisServer(provider);
67
68 Handler handler = server.getHandler("other");
69 assertNotNull("Couldn't get handler", handler);
70
71 AdminClient client = new AdminClient(true);
72 Call call = client.getCall();
73 LocalTransport transport = new LocalTransport(server);
74 transport.setRemoteService("AdminService");
75
76 call.setTransport(transport);
77 client.process(new ByteArrayInputStream(undeployDoc.getBytes()));
78
79 server.refreshGlobalOptions();
80
81 handler = server.getHandler("other");
82 assertNull("Undeployed handler is still available", handler);
83
84 handler = server.getHandler(HANDLER_NAME);
85 assertNotNull("Couldn't get handler (2nd time)", handler);
86 }
87
88 public static void main(String[] args) throws Exception {
89 TestAdminService tester = new TestAdminService("foo");
90 tester.testUndeployHandlerViaAdmin();
91 }
92 }