KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > wsdl > interop4 > groupG > mime > rpc > MimeRPCInteropTestCase


1 /**
2  * MimeRPCInteropTestCase.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.mime.rpc;
9
10 import org.apache.axis.attachments.OctetStream;
11
12 import java.util.Arrays JavaDoc;
13 import java.net.URL JavaDoc;
14
15 public class MimeRPCInteropTestCase extends junit.framework.TestCase {
16     public MimeRPCInteropTestCase(java.lang.String JavaDoc name) {
17         super(name);
18     }
19
20     public void testMimeRPCSoapPortWSDL() throws Exception JavaDoc {
21         javax.xml.rpc.ServiceFactory JavaDoc serviceFactory = javax.xml.rpc.ServiceFactory.newInstance();
22         java.net.URL JavaDoc url = new java.net.URL JavaDoc(new test.wsdl.interop4.groupG.mime.rpc.MimeRPCInteropLocator().getMimeRPCSoapPortAddress() + "?WSDL");
23         javax.xml.rpc.Service JavaDoc service = serviceFactory.createService(url, new test.wsdl.interop4.groupG.mime.rpc.MimeRPCInteropLocator().getServiceName());
24         assertTrue(service != null);
25     }
26
27     protected void setUp() throws Exception JavaDoc {
28         if(url == null) {
29             url = new URL JavaDoc(new test.wsdl.interop4.groupG.mime.rpc.MimeRPCInteropLocator().getMimeRPCSoapPortAddress());
30         }
31     }
32
33     public void test1MimeRPCSoapPortEchoAttachment() throws Exception JavaDoc {
34         test.wsdl.interop4.groupG.mime.rpc.AttachmentsPortType binding;
35         try {
36             binding = new test.wsdl.interop4.groupG.mime.rpc.MimeRPCInteropLocator().getMimeRPCSoapPort(url);
37         } catch (javax.xml.rpc.ServiceException JavaDoc jre) {
38             if (jre.getLinkedCause() != null)
39                 jre.getLinkedCause().printStackTrace();
40             throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre);
41         }
42         assertTrue("binding is null", binding != null);
43
44         // Test operation
45
OctetStream input = new OctetStream("EchoAttachment".getBytes());
46         OctetStream output = null;
47         output = binding.echoAttachment(input);
48         // TBD - validate results
49
assertTrue(Arrays.equals(input.getBytes(), output.getBytes()));
50     }
51
52     public void test2MimeRPCSoapPortEchoAttachments() throws Exception JavaDoc {
53         test.wsdl.interop4.groupG.mime.rpc.AttachmentsPortType binding;
54         try {
55             binding = new test.wsdl.interop4.groupG.mime.rpc.MimeRPCInteropLocator().getMimeRPCSoapPort(url);
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         assertTrue("binding is null", binding != null);
62
63         OctetStream[] input = new OctetStream[2];
64
65         input[0] = new OctetStream("EchoAttachments0".getBytes());
66         input[1] = new OctetStream("EchoAttachments1".getBytes());
67         
68         // Test operation
69
OctetStream[] output = null;
70         output = binding.echoAttachments(input);
71         // TBD - validate results
72
assertTrue(Arrays.equals(input[0].getBytes(), output[0].getBytes()));
73         assertTrue(Arrays.equals(input[1].getBytes(), output[1].getBytes()));
74     }
75
76     public void test3MimeRPCSoapPortEchoAttachmentAsBase64() throws Exception JavaDoc {
77         test.wsdl.interop4.groupG.mime.rpc.AttachmentsPortType binding;
78         try {
79             binding = new test.wsdl.interop4.groupG.mime.rpc.MimeRPCInteropLocator().getMimeRPCSoapPort(url);
80         } catch (javax.xml.rpc.ServiceException JavaDoc jre) {
81             if (jre.getLinkedCause() != null)
82                 jre.getLinkedCause().printStackTrace();
83             throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre);
84         }
85         assertTrue("binding is null", binding != null);
86         OctetStream input = new OctetStream("EchoAttachmentAsBase64".getBytes());
87         // Test operation
88
byte[] output = null;
89         output = binding.echoAttachmentAsBase64(input);
90         // TBD - validate results
91
assertTrue(Arrays.equals(input.getBytes(), output));
92     }
93
94     public void test4MimeRPCSoapPortEchoBase64AsAttachment() throws Exception JavaDoc {
95         test.wsdl.interop4.groupG.mime.rpc.AttachmentsPortType binding;
96         try {
97             binding = new test.wsdl.interop4.groupG.mime.rpc.MimeRPCInteropLocator().getMimeRPCSoapPort(url);
98         } catch (javax.xml.rpc.ServiceException JavaDoc jre) {
99             if (jre.getLinkedCause() != null)
100                 jre.getLinkedCause().printStackTrace();
101             throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre);
102         }
103         assertTrue("binding is null", binding != null);
104
105         byte[] input = "EchoBase64AsAttachment".getBytes();
106         // Test operation
107
OctetStream output = null;
108         output = binding.echoBase64AsAttachment(input);
109         // TBD - validate results
110
assertTrue(Arrays.equals(input, output.getBytes()));
111     }
112
113     public static URL JavaDoc url = null;
114     
115     public static void main(String JavaDoc[] args) throws Exception JavaDoc {
116         if (args.length == 1) {
117             url = new URL JavaDoc(args[0]);
118         } else {
119             url = new URL JavaDoc(new test.wsdl.interop4.groupG.mime.rpc.MimeRPCInteropLocator().getMimeRPCSoapPortAddress());
120         }
121         junit.textui.TestRunner.run(new junit.framework.TestSuite(MimeRPCInteropTestCase.class));
122     } // main
123
}
124
Popular Tags