1 7 8 package test.wsdl.interop4.groupG.dime.rpc; 9 10 import org.apache.axis.attachments.OctetStream; 11 import org.apache.axis.client.Call; 12 13 import javax.activation.DataSource ; 14 import javax.activation.DataHandler ; 15 import java.net.URL ; 16 import java.util.Arrays ; 17 import java.io.InputStream ; 18 import java.io.IOException ; 19 import java.io.OutputStream ; 20 import java.io.ByteArrayInputStream ; 21 22 public class DimeRPCInteropTestCase extends junit.framework.TestCase { 23 public DimeRPCInteropTestCase(java.lang.String name) { 24 super(name); 25 } 26 27 public void testDimeRPCSoapPortWSDL() throws Exception { 28 javax.xml.rpc.ServiceFactory serviceFactory = javax.xml.rpc.ServiceFactory.newInstance(); 29 java.net.URL url = new java.net.URL (new test.wsdl.interop4.groupG.dime.rpc.DimeRPCInteropLocator().getDimeRPCSoapPortAddress() + "?WSDL"); 30 javax.xml.rpc.Service service = serviceFactory.createService(url, new test.wsdl.interop4.groupG.dime.rpc.DimeRPCInteropLocator().getServiceName()); 31 assertTrue(service != null); 32 } 33 34 protected void setUp() throws Exception { 35 if(url == null) { 36 url = new URL (new test.wsdl.interop4.groupG.dime.rpc.DimeRPCInteropLocator().getDimeRPCSoapPortAddress()); 37 } 38 } 39 public void test1DimeRPCSoapPortEchoAttachment() throws Exception { 40 test.wsdl.interop4.groupG.dime.rpc.AttachmentsPortType binding; 41 try { 42 binding = new test.wsdl.interop4.groupG.dime.rpc.DimeRPCInteropLocator().getDimeRPCSoapPort(url); 43 } 44 catch (javax.xml.rpc.ServiceException jre) { 45 if(jre.getLinkedCause()!=null) 46 jre.getLinkedCause().printStackTrace(); 47 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre); 48 } 49 assertTrue("binding is null", binding != null); 50 51 OctetStream input = new OctetStream("EchoAttachment".getBytes()); 53 OctetStream output = null; 54 output = binding.echoAttachment(input); 55 assertTrue(Arrays.equals(input.getBytes(), output.getBytes())); 57 } 58 59 public void test2DimeRPCSoapPortEchoAttachments() throws Exception { 60 test.wsdl.interop4.groupG.dime.rpc.AttachmentsPortType binding; 61 try { 62 binding = new test.wsdl.interop4.groupG.dime.rpc.DimeRPCInteropLocator().getDimeRPCSoapPort(url); 63 } 64 catch (javax.xml.rpc.ServiceException jre) { 65 if(jre.getLinkedCause()!=null) 66 jre.getLinkedCause().printStackTrace(); 67 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre); 68 } 69 assertTrue("binding is null", binding != null); 70 71 OctetStream[] input = new OctetStream[2]; 72 73 input[0] = new OctetStream("EchoAttachments0".getBytes()); 74 input[1] = new OctetStream("EchoAttachments1".getBytes()); 75 76 OctetStream[] output = null; 78 output = binding.echoAttachments(input); 79 assertTrue(Arrays.equals(input[0].getBytes(), output[0].getBytes())); 81 assertTrue(Arrays.equals(input[1].getBytes(), output[1].getBytes())); 82 } 83 84 public void test3DimeRPCSoapPortEchoAttachmentAsBase64() throws Exception { 85 test.wsdl.interop4.groupG.dime.rpc.AttachmentsPortType binding; 86 try { 87 binding = new test.wsdl.interop4.groupG.dime.rpc.DimeRPCInteropLocator().getDimeRPCSoapPort(url); 88 } 89 catch (javax.xml.rpc.ServiceException jre) { 90 if(jre.getLinkedCause()!=null) 91 jre.getLinkedCause().printStackTrace(); 92 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre); 93 } 94 assertTrue("binding is null", binding != null); 95 96 OctetStream input = new OctetStream("EchoAttachmentAsBase64".getBytes()); 97 byte[] output = null; 99 output = binding.echoAttachmentAsBase64(input); 100 assertTrue(Arrays.equals(input.getBytes(), output)); 102 } 103 104 public void test4DimeRPCSoapPortEchoBase64AsAttachment() throws Exception { 105 test.wsdl.interop4.groupG.dime.rpc.AttachmentsPortType binding; 106 try { 107 binding = new test.wsdl.interop4.groupG.dime.rpc.DimeRPCInteropLocator().getDimeRPCSoapPort(url); 108 } 109 catch (javax.xml.rpc.ServiceException jre) { 110 if(jre.getLinkedCause()!=null) 111 jre.getLinkedCause().printStackTrace(); 112 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre); 113 } 114 assertTrue("binding is null", binding != null); 115 116 byte[] input = "EchoBase64AsAttachment".getBytes(); 117 OctetStream output = null; 119 output = binding.echoBase64AsAttachment(input); 120 assertTrue(Arrays.equals(input, output.getBytes())); 122 } 123 124 public void test5DimeRPCSoapPortEchoUnrefAttachments() throws Exception { 125 test.wsdl.interop4.groupG.dime.rpc.AttachmentsPortType binding; 126 try { 127 binding = new test.wsdl.interop4.groupG.dime.rpc.DimeRPCInteropLocator().getDimeRPCSoapPort(url); 128 } 129 catch (javax.xml.rpc.ServiceException jre) { 130 if(jre.getLinkedCause()!=null) 131 jre.getLinkedCause().printStackTrace(); 132 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre); 133 } 134 assertTrue("binding is null", binding != null); 135 136 class Src implements DataSource { 137 InputStream m_src; 138 String m_type; 139 140 public Src(InputStream data, String type){ 141 m_src=data; 142 m_type=type; 143 } 144 public String getContentType(){ 145 return m_type; 146 } 147 public InputStream getInputStream() throws IOException { 148 m_src.reset(); 149 return m_src; 150 } 151 public String getName(){ 152 return "Some-Data"; 153 } 154 public OutputStream getOutputStream(){ 155 throw new UnsupportedOperationException ("I don't give output streams"); 156 } 157 } 158 ByteArrayInputStream ins=new ByteArrayInputStream ("EchoUnrefAttachments".getBytes()); 159 DataHandler dh=new DataHandler (new Src(ins,"application/octetstream")); 160 161 162 ((org.apache.axis.client.Stub)binding).addAttachment(dh); 163 ((org.apache.axis.client.Stub)binding)._setProperty(Call.ATTACHMENT_ENCAPSULATION_FORMAT, Call.ATTACHMENT_ENCAPSULATION_FORMAT_DIME); 164 binding.echoUnrefAttachments(); 166 Object attachments[] = ((org.apache.axis.client.Stub)binding).getAttachments(); 168 assertEquals(1, attachments.length); 169 } 170 171 public void test6DimeRPCSoapPortEchoAttachmentAsString() throws Exception { 172 test.wsdl.interop4.groupG.dime.rpc.AttachmentsPortType binding; 173 try { 174 binding = new test.wsdl.interop4.groupG.dime.rpc.DimeRPCInteropLocator().getDimeRPCSoapPort(url); 175 } 176 catch (javax.xml.rpc.ServiceException jre) { 177 if(jre.getLinkedCause()!=null) 178 jre.getLinkedCause().printStackTrace(); 179 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre); 180 } 181 assertTrue("binding is null", binding != null); 182 183 java.lang.String input = "EchoAttachmentAsString"; 184 185 java.lang.String output = null; 187 output = binding.echoAttachmentAsString(input); 188 assertEquals(input, output); 190 } 191 192 public static URL url = null; 193 } 194 | Popular Tags |