KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > wsdl > document > TestServiceServiceTestCase


1 /**
2  * TestServiceServiceTestCase.java
3  *
4  * This file was auto-generated from WSDL
5  * by the Apache Axis WSDL2Java emitter.
6  */

7
8 package test.wsdl.document;
9
10 import org.apache.axis.utils.XMLUtils;
11 import org.w3c.dom.Element JavaDoc;
12
13 public class TestServiceServiceTestCase extends junit.framework.TestCase {
14     String JavaDoc xml = "<hello>world</hello>";
15     public TestServiceServiceTestCase(java.lang.String JavaDoc name) {
16         super(name);
17     }
18
19     public void testDocumentTestWSDL() throws Exception JavaDoc {
20         javax.xml.rpc.ServiceFactory JavaDoc serviceFactory = javax.xml.rpc.ServiceFactory.newInstance();
21         java.net.URL JavaDoc url = new java.net.URL JavaDoc(new test.wsdl.document.TestServiceServiceLocator().getDocumentTestAddress() + "?WSDL");
22         javax.xml.rpc.Service JavaDoc service = serviceFactory.createService(url, new test.wsdl.document.TestServiceServiceLocator().getServiceName());
23         assertTrue(service != null);
24     }
25
26     public void test1DocumentTestGetElement() throws Exception JavaDoc {
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 JavaDoc 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         // Time out after a minute
40
binding.setTimeout(60000);
41
42         // Test operation
43
org.w3c.dom.Element JavaDoc value = null;
44         value = binding.getElement();
45         // TBD - validate results
46
assertTrue(value != null);
47         assertTrue(XMLUtils.ElementToString(value).indexOf(xml)!=-1);
48     }
49
50     public void test2DocumentTestGetDocument() throws Exception JavaDoc {
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 JavaDoc 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         // Time out after a minute
64
binding.setTimeout(60000);
65
66         // Test operation
67
org.w3c.dom.Document JavaDoc value = null;
68         value = binding.getDocument();
69         // TBD - validate results
70
assertTrue(value != null);
71         assertTrue(XMLUtils.DocumentToString(value).indexOf(xml)!=-1);
72     }
73 }
74
Popular Tags