KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > wsdd > TestGlobalConfiguration


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.configuration.XMLStringProvider;
7 import org.apache.axis.server.AxisServer;
8
9 import java.util.List JavaDoc;
10
11 public class TestGlobalConfiguration extends TestCase
12 {
13     static final String JavaDoc PARAM_NAME = "testParam";
14     static final String JavaDoc PARAM_VAL = "testValue";
15     static final String JavaDoc ROLE = "http://test-role1";
16     static final String JavaDoc ROLE2 = "http://test-role2";
17
18     String JavaDoc doc =
19             "<deployment xmlns=\"http://xml.apache.org/axis/wsdd/\">\n" +
20             " <globalConfiguration>\n" +
21             " <parameter name=\"" + PARAM_NAME +
22                           "\" value=\"" + PARAM_VAL + "\"/>\n" +
23             " <role>" + ROLE + "</role>\n" +
24             " <role>" + ROLE2 + "</role>\n" +
25             " </globalConfiguration>\n" +
26             "</deployment>";
27
28     public TestGlobalConfiguration (String JavaDoc name) {
29         super(name);
30     }
31
32     public static Test suite() {
33         return new TestSuite(TestGlobalConfiguration.class);
34     }
35
36     protected void setup() {
37     }
38
39     public void testEngineProperties() throws Exception JavaDoc
40     {
41         XMLStringProvider provider = new XMLStringProvider(doc);
42         AxisServer server = new AxisServer(provider);
43
44         Object JavaDoc optVal = server.getOption(PARAM_NAME);
45         assertNotNull("Option value was null!", optVal);
46         assertEquals("Option was not expected value", optVal, PARAM_VAL);
47
48         optVal = server.getOption("someOptionWhichIsntSet");
49         assertNull("Got value for bad option!", optVal);
50
51         List JavaDoc roles = server.getActorURIs();
52         assertTrue("Engine roles did not contain " + ROLE,
53                    roles.contains(ROLE));
54         assertTrue("Engine roles did not contain " + ROLE2,
55                    roles.contains(ROLE2));
56     }
57     
58     public static void main(String JavaDoc[] args) throws Exception JavaDoc {
59         TestGlobalConfiguration tester = new TestGlobalConfiguration("foo");
60         tester.testEngineProperties();
61     }
62 }
63
Popular Tags