1 7 8 package test.wsdl.document; 9 10 import org.apache.axis.utils.XMLUtils; 11 import org.w3c.dom.Element ; 12 13 public class TestServiceServiceTestCase extends junit.framework.TestCase { 14 String xml = "<hello>world</hello>"; 15 public TestServiceServiceTestCase(java.lang.String name) { 16 super(name); 17 } 18 19 public void testDocumentTestWSDL() throws Exception { 20 javax.xml.rpc.ServiceFactory serviceFactory = javax.xml.rpc.ServiceFactory.newInstance(); 21 java.net.URL url = new java.net.URL (new test.wsdl.document.TestServiceServiceLocator().getDocumentTestAddress() + "?WSDL"); 22 javax.xml.rpc.Service service = serviceFactory.createService(url, new test.wsdl.document.TestServiceServiceLocator().getServiceName()); 23 assertTrue(service != null); 24 } 25 26 public void test1DocumentTestGetElement() throws Exception { 27 test.wsdl.document.DocumentTestSoapBindingStub binding; 28 try { 29 binding = (test.wsdl.document.DocumentTestSoapBindingStub) 30 new test.wsdl.document.TestServiceServiceLocator().getDocumentTest(); 31 } 32 catch (javax.xml.rpc.ServiceException jre) { 33 if(jre.getLinkedCause()!=null) 34 jre.getLinkedCause().printStackTrace(); 35 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre); 36 } 37 assertNotNull("binding is null", binding); 38 39 binding.setTimeout(60000); 41 42 org.w3c.dom.Element value = null; 44 value = binding.getElement(); 45 assertTrue(value != null); 47 assertTrue(XMLUtils.ElementToString(value).indexOf(xml)!=-1); 48 } 49 50 public void test2DocumentTestGetDocument() throws Exception { 51 test.wsdl.document.DocumentTestSoapBindingStub binding; 52 try { 53 binding = (test.wsdl.document.DocumentTestSoapBindingStub) 54 new test.wsdl.document.TestServiceServiceLocator().getDocumentTest(); 55 } 56 catch (javax.xml.rpc.ServiceException jre) { 57 if(jre.getLinkedCause()!=null) 58 jre.getLinkedCause().printStackTrace(); 59 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre); 60 } 61 assertNotNull("binding is null", binding); 62 63 binding.setTimeout(60000); 65 66 org.w3c.dom.Document value = null; 68 value = binding.getDocument(); 69 assertTrue(value != null); 71 assertTrue(XMLUtils.DocumentToString(value).indexOf(xml)!=-1); 72 } 73 } 74 | Popular Tags |