1 7 8 package test.wsdl.wrapperHolder; 9 10 import javax.xml.rpc.holders.ByteArrayHolder ; 11 import javax.xml.rpc.holders.LongWrapperHolder ; 12 13 public class ExampleSoapTestCase extends junit.framework.TestCase { 14 public ExampleSoapTestCase(java.lang.String name) { 15 super(name); 16 } 17 18 public void testWrapperHolderWSDL() throws Exception { 19 javax.xml.rpc.ServiceFactory serviceFactory = javax.xml.rpc.ServiceFactory.newInstance(); 20 java.net.URL url = new java.net.URL (new test.wsdl.wrapperHolder.DoExample_ServiceLocator().getWrapperHolderAddress() + "?WSDL"); 21 javax.xml.rpc.Service service = serviceFactory.createService(url, new test.wsdl.wrapperHolder.DoExample_ServiceLocator().getServiceName()); 22 assertTrue(service != null); 23 } 24 25 public void test1WrapperHolderDoExample() throws Exception { 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 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 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 in2 = new Long (3); 46 ByteArrayHolder out1 = new ByteArrayHolder (); 47 LongWrapperHolder out2 = new LongWrapperHolder (); 48 49 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 byteArrayAsList(final byte[] a) { 59 return new java.util.AbstractList () { 60 public Object get(int i) { 61 return new Byte (a[i]); 62 } 63 public int size() { 64 return a.length; 65 } 66 public Object set(int i, Object o) { 67 byte oldVal = a[i]; 68 a[i] = ((Byte ) o).byteValue(); 69 return new Byte (oldVal); 70 } 71 }; 72 } 73 } 74 | Popular Tags |