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