001: package org.objectweb.celtix.systest.soapheader;
002:
003: import java.lang.reflect.UndeclaredThrowableException;
004: import java.net.URL;
005:
006: import javax.xml.namespace.QName;
007: import javax.xml.ws.Holder;
008:
009: import junit.framework.Test;
010: import junit.framework.TestSuite;
011:
012: import org.objectweb.celtix.systest.common.ClientServerSetupBase;
013: import org.objectweb.celtix.systest.common.ClientServerTestBase;
014: import org.objectweb.header_test.SOAPHeaderService;
015: import org.objectweb.header_test.TestHeader;
016: import org.objectweb.header_test.types.TestHeader1;
017: import org.objectweb.header_test.types.TestHeader1Response;
018: import org.objectweb.header_test.types.TestHeader2;
019: import org.objectweb.header_test.types.TestHeader2Response;
020: import org.objectweb.header_test.types.TestHeader3;
021: import org.objectweb.header_test.types.TestHeader3Response;
022: import org.objectweb.header_test.types.TestHeader5;
023:
024: public class HeaderClientServerTest extends ClientServerTestBase {
025:
026: private final QName serviceName = new QName(
027: "http://objectweb.org/header_test", "SOAPHeaderService");
028: private final QName portName = new QName(
029: "http://objectweb.org/header_test", "SOAPHeaderPort");
030:
031: private TestHeader proxy;
032:
033: public static Test suite() throws Exception {
034: TestSuite suite = new TestSuite(HeaderClientServerTest.class);
035: return new ClientServerSetupBase(suite) {
036: public void startServers() throws Exception {
037: assertTrue("server did not launch correctly",
038: launchServer(Server.class));
039: }
040: };
041: }
042:
043: public void setUp() throws Exception {
044: super .setUp();
045:
046: URL wsdl = getClass().getResource("/wsdl/soapheader_test.wsdl");
047: assertNotNull(wsdl);
048:
049: SOAPHeaderService service = new SOAPHeaderService(wsdl,
050: serviceName);
051: assertNotNull(service);
052: proxy = service.getPort(portName, TestHeader.class);
053: }
054:
055: public void tearDown() {
056: proxy = null;
057: }
058:
059: public void testInHeader() throws Exception {
060: try {
061: TestHeader1 val = new TestHeader1();
062: for (int idx = 0; idx < 2; idx++) {
063: TestHeader1Response returnVal = proxy.testHeader1(val,
064: val);
065: assertNotNull(returnVal);
066: assertEquals(TestHeader1.class.getSimpleName(),
067: returnVal.getResponseType());
068: }
069: } catch (UndeclaredThrowableException ex) {
070: throw (Exception) ex.getCause();
071: }
072: }
073:
074: public void testOutHeader() throws Exception {
075: try {
076: TestHeader2 in = new TestHeader2();
077: String val = new String(TestHeader2Response.class
078: .getSimpleName());
079: Holder<TestHeader2Response> out = new Holder<TestHeader2Response>();
080: Holder<TestHeader2Response> outHeader = new Holder<TestHeader2Response>();
081: for (int idx = 0; idx < 2; idx++) {
082: val += idx;
083: in.setRequestType(val);
084: proxy.testHeader2(in, out, outHeader);
085:
086: assertEquals(val, out.value.getResponseType());
087: assertEquals(val, outHeader.value.getResponseType());
088: }
089: } catch (UndeclaredThrowableException ex) {
090: throw (Exception) ex.getCause();
091: }
092: }
093:
094: public void testInOutHeader() throws Exception {
095:
096: try {
097: TestHeader3 in = new TestHeader3();
098: String val = new String(TestHeader3.class.getSimpleName());
099: Holder<TestHeader3> inoutHeader = new Holder<TestHeader3>();
100: for (int idx = 0; idx < 2; idx++) {
101: val += idx;
102: in.setRequestType(val);
103: inoutHeader.value = new TestHeader3();
104: TestHeader3Response returnVal = proxy.testHeader3(in,
105: inoutHeader);
106: //inoutHeader copied to return
107: //in copied to inoutHeader
108: assertNotNull(returnVal);
109: assertNull(returnVal.getResponseType());
110: assertEquals(val, inoutHeader.value.getRequestType());
111:
112: in.setRequestType(null);
113: inoutHeader.value.setRequestType(val);
114: returnVal = proxy.testHeader3(in, inoutHeader);
115: assertNotNull(returnVal);
116: assertEquals(val, returnVal.getResponseType());
117: assertNull(inoutHeader.value.getRequestType());
118: }
119: } catch (UndeclaredThrowableException ex) {
120: throw (Exception) ex.getCause();
121: }
122: }
123:
124: public void testReturnHeader() throws Exception {
125:
126: try {
127: TestHeader5 in = new TestHeader5();
128: String val = new String(TestHeader5.class.getSimpleName());
129: for (int idx = 0; idx < 2; idx++) {
130: val += idx;
131: in.setRequestType(val);
132: TestHeader5 returnVal = proxy.testHeader5(in);
133:
134: //in copied to return
135: assertNotNull(returnVal);
136: assertEquals(val, returnVal.getRequestType());
137: }
138: } catch (UndeclaredThrowableException ex) {
139: throw (Exception) ex.getCause();
140: }
141: }
142:
143: public static void main(String[] args) {
144: junit.textui.TestRunner.run(HeaderClientServerTest.class);
145: }
146: }
|