KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > wsdl > interop4 > groupG > dime > rpc > DimeRPCInteropTestCase


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

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 JavaDoc;
14 import javax.activation.DataHandler JavaDoc;
15 import java.net.URL JavaDoc;
16 import java.util.Arrays JavaDoc;
17 import java.io.InputStream JavaDoc;
18 import java.io.IOException JavaDoc;
19 import java.io.OutputStream JavaDoc;
20 import java.io.ByteArrayInputStream JavaDoc;
21
22 public class DimeRPCInteropTestCase extends junit.framework.TestCase {
23     public DimeRPCInteropTestCase(java.lang.String JavaDoc name) {
24         super(name);
25     }
26
27     public void testDimeRPCSoapPortWSDL() throws Exception JavaDoc {
28         javax.xml.rpc.ServiceFactory JavaDoc serviceFactory = javax.xml.rpc.ServiceFactory.newInstance();
29         java.net.URL JavaDoc url = new java.net.URL JavaDoc(new test.wsdl.interop4.groupG.dime.rpc.DimeRPCInteropLocator().getDimeRPCSoapPortAddress() + "?WSDL");
30         javax.xml.rpc.Service JavaDoc 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 JavaDoc {
35         if(url == null) {
36             url = new URL JavaDoc(new test.wsdl.interop4.groupG.dime.rpc.DimeRPCInteropLocator().getDimeRPCSoapPortAddress());
37         }
38     }
39     public void test1DimeRPCSoapPortEchoAttachment() throws Exception JavaDoc {
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 JavaDoc 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         // Test operation
52
OctetStream input = new OctetStream("EchoAttachment".getBytes());
53         OctetStream output = null;
54         output = binding.echoAttachment(input);
55         // TBD - validate results
56
assertTrue(Arrays.equals(input.getBytes(), output.getBytes()));
57     }
58
59     public void test2DimeRPCSoapPortEchoAttachments() throws Exception JavaDoc {
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 JavaDoc 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         // Test operation
77
OctetStream[] output = null;
78         output = binding.echoAttachments(input);
79         // TBD - validate results
80
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 JavaDoc {
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 JavaDoc 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         // Test operation
98
byte[] output = null;
99         output = binding.echoAttachmentAsBase64(input);
100         // TBD - validate results
101
assertTrue(Arrays.equals(input.getBytes(), output));
102     }
103
104     public void test4DimeRPCSoapPortEchoBase64AsAttachment() throws Exception JavaDoc {
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 JavaDoc 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         // Test operation
118
OctetStream output = null;
119         output = binding.echoBase64AsAttachment(input);
120         // TBD - validate results
121
assertTrue(Arrays.equals(input, output.getBytes()));
122     }
123
124     public void test5DimeRPCSoapPortEchoUnrefAttachments() throws Exception JavaDoc {
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 JavaDoc 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 JavaDoc{
137             InputStream JavaDoc m_src;
138             String JavaDoc m_type;
139
140             public Src(InputStream JavaDoc data, String JavaDoc type){
141                 m_src=data;
142                 m_type=type;
143             }
144             public String JavaDoc getContentType(){
145                 return m_type;
146             }
147             public InputStream JavaDoc getInputStream() throws IOException JavaDoc{
148                 m_src.reset();
149                 return m_src;
150             }
151             public String JavaDoc getName(){
152                 return "Some-Data";
153             }
154             public OutputStream JavaDoc getOutputStream(){
155                 throw new UnsupportedOperationException JavaDoc("I don't give output streams");
156             }
157         }
158         ByteArrayInputStream JavaDoc ins=new ByteArrayInputStream JavaDoc("EchoUnrefAttachments".getBytes());
159         DataHandler JavaDoc dh=new DataHandler JavaDoc(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         // Test operation
165
binding.echoUnrefAttachments();
166         // TBD - validate results
167
Object JavaDoc attachments[] = ((org.apache.axis.client.Stub)binding).getAttachments();
168         assertEquals(1, attachments.length);
169     }
170
171     public void test6DimeRPCSoapPortEchoAttachmentAsString() throws Exception JavaDoc {
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 JavaDoc 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 JavaDoc input = "EchoAttachmentAsString";
184         
185         // Test operation
186
java.lang.String JavaDoc output = null;
187         output = binding.echoAttachmentAsString(input);
188         // TBD - validate results
189
assertEquals(input, output);
190     }
191
192     public static URL JavaDoc url = null;
193 }
194
Popular Tags