KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > wsdl > wrapperHolder > ExampleSoapTestCase


1 /**
2  * DoExampleTestCase.java
3  *
4  * This file was auto-generated from WSDL
5  * by the Apache Axis 1.2beta3 Aug 03, 2004 (01:17:01 CEST) WSDL2Java emitter.
6  */

7
8 package test.wsdl.wrapperHolder;
9
10 import javax.xml.rpc.holders.ByteArrayHolder JavaDoc;
11 import javax.xml.rpc.holders.LongWrapperHolder JavaDoc;
12
13 public class ExampleSoapTestCase extends junit.framework.TestCase {
14     public ExampleSoapTestCase(java.lang.String JavaDoc name) {
15         super(name);
16     }
17
18     public void testWrapperHolderWSDL() throws Exception JavaDoc {
19         javax.xml.rpc.ServiceFactory JavaDoc serviceFactory = javax.xml.rpc.ServiceFactory.newInstance();
20         java.net.URL JavaDoc url = new java.net.URL JavaDoc(new test.wsdl.wrapperHolder.DoExample_ServiceLocator().getWrapperHolderAddress() + "?WSDL");
21         javax.xml.rpc.Service JavaDoc service = serviceFactory.createService(url, new test.wsdl.wrapperHolder.DoExample_ServiceLocator().getServiceName());
22         assertTrue(service != null);
23     }
24
25     public void test1WrapperHolderDoExample() throws Exception JavaDoc {
26         test.wsdl.wrapperHolder.ExampleSoapStub binding;
27         try {
28             binding = (test.wsdl.wrapperHolder.ExampleSoapStub)
29                           new test.wsdl.wrapperHolder.DoExample_ServiceLocator().getWrapperHolder();
30         }
31         catch (javax.xml.rpc.ServiceException JavaDoc jre) {
32             if(jre.getLinkedCause()!=null)
33                 jre.getLinkedCause().printStackTrace();
34             throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre);
35         }
36         assertNotNull("binding is null", binding);
37
38         // Time out after a minute
39
binding.setTimeout(60000);
40
41         byte[][] in1 = new byte[][] {
42             { (byte) 0xbe, (byte) 0xef, (byte) 0xcc },
43             { (byte) 0xee, (byte) 0xff, (byte) 0xaa },
44         };
45         Long JavaDoc in2 = new Long JavaDoc(3);
46         ByteArrayHolder JavaDoc out1 = new ByteArrayHolder JavaDoc();
47         LongWrapperHolder JavaDoc out2 = new LongWrapperHolder JavaDoc();
48
49         // Test operation
50
binding.doExample(in1, in2, out1, out2);
51
52         assertEquals("Unexpected value for ByteArrayHolder",
53                      byteArrayAsList(in1[0]), byteArrayAsList(out1.value));
54         assertEquals("Unexpected value for LongWrapperHolder ",
55                      in2, out2.value);
56     }
57
58     private static java.util.List JavaDoc byteArrayAsList(final byte[] a) {
59         return new java.util.AbstractList JavaDoc() {
60             public Object JavaDoc get(int i) {
61                 return new Byte JavaDoc(a[i]);
62             }
63             public int size() {
64                 return a.length;
65             }
66             public Object JavaDoc set(int i, Object JavaDoc o) {
67                 byte oldVal = a[i];
68                 a[i] = ((Byte JavaDoc) o).byteValue();
69                 return new Byte JavaDoc(oldVal);
70             }
71         };
72     }
73 }
74
Popular Tags