01: package org.objectweb.celtix.bus.wsdl;
02:
03: import java.net.URL;
04: import junit.framework.TestCase;
05:
06: public class WSDLManagerInstrumentationTest extends TestCase {
07: private static final String DEFINITION_NAME = "Definition: {http://objectweb.org/hello_world_soap_http}HelloWorld ";
08: private static final String SERVICE_NAME1 = DEFINITION_NAME
09: + "Service: {http://objectweb.org/hello_world_soap_http}SOAPServiceAddressing";
10: private static final String PORTTYPE_NAME = DEFINITION_NAME
11: + "PortType: {http://objectweb.org/hello_world_soap_http}Greeter";
12: private static final String BINDING_NAME = DEFINITION_NAME
13: + "Binding: {http://objectweb.org/hello_world_soap_http}Greeter_SOAPBinding";
14:
15: private static final String[] OPERATIONS = { "sayHi", "greetMe",
16: "greetMeSometime", "greetMeOneWay", "testDocLitFault",
17: "testDocLitBare" };
18:
19: private static final String DEFINITION = "HelloWorld";
20:
21: private static final String PORTTYPE = "Greeter";
22:
23: private WSDLManagerImpl wsdlManager;
24: private WSDLManagerInstrumentation wi;
25:
26: private void loadWSDL() throws Exception {
27: URL url = getClass().getResource("/wsdl/hello_world.wsdl");
28: wsdlManager = new WSDLManagerImpl(null);
29: wsdlManager.getDefinition(url);
30: wi = new WSDLManagerInstrumentation(wsdlManager);
31: }
32:
33: public void testGetServices() throws Exception {
34: loadWSDL();
35:
36: String[] services = wi.getServices();
37: assertEquals("The Services number is not right", 4,
38: services.length);
39: assertTrue("Get wrong Service Name ", services[2]
40: .compareTo(SERVICE_NAME1) == 0);
41: }
42:
43: public void testGetBindings() throws Exception {
44: loadWSDL();
45:
46: String[] bindings = wi.getBindings();
47:
48: assertEquals("The bindings number is not right", 1,
49: bindings.length);
50: assertTrue("Get wrong binding Name ", bindings[0]
51: .compareTo(BINDING_NAME) == 0);
52: }
53:
54: public void testGetPortTypes() throws Exception {
55: loadWSDL();
56:
57: String[] ports = wi.getPorts();
58: assertEquals("The bindings number is not right", 1,
59: ports.length);
60: assertTrue("Get wrong binding Name ", ports[0]
61: .compareTo(PORTTYPE_NAME) == 0);
62: }
63:
64: public void testGetOperation() throws Exception {
65: loadWSDL();
66:
67: String[] operations = wi.getOperation(DEFINITION, PORTTYPE);
68: assertEquals("The operation number is not right",
69: OPERATIONS.length, operations.length);
70: for (int i = 0; i < operations.length; i++) {
71: assertTrue("Get wrong operation Name ", operations[i]
72: .compareTo("Operation: " + OPERATIONS[i]) == 0);
73: }
74:
75: }
76:
77: public void testGetEndpoints() throws Exception {
78:
79: }
80:
81: }
|