| 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; |
| 13 |
import java.net.URL; |
| 14 |
|
| 15 |
public class MimeRPCInteropTestCase extends junit.framework.TestCase { |
| 16 |
public MimeRPCInteropTestCase(java.lang.String name) { |
| 17 |
super(name); |
| 18 |
} |
| 19 |
|
| 20 |
public void testMimeRPCSoapPortWSDL() throws Exception { |
| 21 |
javax.xml.rpc.ServiceFactory serviceFactory = javax.xml.rpc.ServiceFactory.newInstance(); |
| 22 |
java.net.URL url = new java.net.URL(new test.wsdl.interop4.groupG.mime.rpc.MimeRPCInteropLocator().getMimeRPCSoapPortAddress() + "?WSDL"); |
| 23 |
javax.xml.rpc.Service 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 { |
| 28 |
if(url == null) { |
| 29 |
url = new URL(new test.wsdl.interop4.groupG.mime.rpc.MimeRPCInteropLocator().getMimeRPCSoapPortAddress()); |
| 30 |
} |
| 31 |
} |
| 32 |
|
| 33 |
public void test1MimeRPCSoapPortEchoAttachment() throws Exception { |
| 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 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 { |
| 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 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 { |
| 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 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 { |
| 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 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 url = null; |
| 114 |
|
| 115 |
public static void main(String[] args) throws Exception { |
| 116 |
if (args.length == 1) { |
| 117 |
url = new URL(args[0]); |
| 118 |
} else { |
| 119 |
url = new URL(new test.wsdl.interop4.groupG.mime.rpc.MimeRPCInteropLocator().getMimeRPCSoapPortAddress()); |
| 120 |
} |
| 121 |
junit.textui.TestRunner.run(new junit.framework.TestSuite(MimeRPCInteropTestCase.class)); |
| 122 |
} // main |
| 123 |
} |