001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one
003: * or more contributor license agreements. See the NOTICE file
004: * distributed with this work for additional information
005: * regarding copyright ownership. The ASF licenses this file
006: * to you under the Apache License, Version 2.0 (the
007: * "License"); you may not use this file except in compliance
008: * with the License. You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing,
013: * software distributed under the License is distributed on an
014: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015: * KIND, either express or implied. See the License for the
016: * specific language governing permissions and limitations
017: * under the License.
018: */
019:
020: /**
021: *
022: */package org.apache.axis2.jaxws.sample;
023:
024: import javax.xml.ws.Holder;
025:
026: import junit.framework.TestCase;
027: import org.apache.axis2.jaxws.sample.wrap.sei.DocLitWrap;
028: import org.apache.axis2.jaxws.sample.wrap.sei.DocLitWrapService;
029: import org.apache.axis2.jaxws.TestLogger;
030: import org.test.sample.wrap.Header;
031: import org.test.sample.wrap.HeaderPart0;
032: import org.test.sample.wrap.HeaderPart1;
033: import org.test.sample.wrap.HeaderResponse;
034:
035: public class WrapTests extends TestCase {
036:
037: /**
038: *
039: */
040: public WrapTests() {
041: super ();
042: // TODO Auto-generated constructor stub
043: }
044:
045: /**
046: * @param arg0
047: */
048: public WrapTests(String arg0) {
049: super (arg0);
050: // TODO Auto-generated constructor stub
051: }
052:
053: public void testTwoWaySync() {
054: TestLogger.logger.debug("------------------------------");
055: TestLogger.logger.debug("Test : " + getName());
056: try {
057: String reqString = "Test twoWay Sync";
058: DocLitWrapService service = new DocLitWrapService();
059: DocLitWrap proxy = service.getDocLitWrapPort();
060: String response = proxy.twoWay(reqString);
061: TestLogger.logger.debug("Sync Response =" + response);
062: TestLogger.logger.debug("------------------------------");
063: } catch (Exception e) {
064: e.printStackTrace();
065: fail();
066: }
067: }
068:
069: public void testOneWayVoidWithNoInputParams() {
070: TestLogger.logger.debug("------------------------------");
071: TestLogger.logger.debug("Test : " + getName());
072: try {
073:
074: DocLitWrapService service = new DocLitWrapService();
075: DocLitWrap proxy = service.getDocLitWrapPort();
076: proxy.oneWayVoid();
077:
078: TestLogger.logger.debug("------------------------------");
079: } catch (Exception e) {
080: e.printStackTrace();
081: fail();
082: }
083: }
084:
085: public void testTwoWayHolder() {
086: TestLogger.logger.debug("------------------------------");
087: TestLogger.logger.debug("Test : " + getName());
088: try {
089: String holderString = new String("Test twoWay Sync");
090: Integer holderInteger = new Integer(0);
091: Holder<String> strHolder = new Holder<String>(holderString);
092: Holder<Integer> intHolder = new Holder<Integer>(
093: holderInteger);
094: DocLitWrapService service = new DocLitWrapService();
095: DocLitWrap proxy = service.getDocLitWrapPort();
096: proxy.twoWayHolder(strHolder, intHolder);
097: TestLogger.logger.debug("Holder Response String ="
098: + strHolder.value);
099: ;
100: TestLogger.logger.debug("Holder Response Integer ="
101: + intHolder.value);
102: TestLogger.logger.debug("------------------------------");
103: } catch (Exception e) {
104: e.printStackTrace();
105: fail();
106: }
107: }
108:
109: public void testTwoWayWithHeadersAndHolders() {
110: TestLogger.logger.debug("------------------------------");
111: TestLogger.logger.debug("Test : " + getName());
112: try {
113: Header header = new Header();
114: header.setOut(0);
115: HeaderPart0 hp0 = new HeaderPart0();
116: hp0
117: .setHeaderType("Client setup Header Type for HeaderPart0");
118: HeaderPart1 hp1 = new HeaderPart1();
119: hp1
120: .setHeaderType("Client setup Header Type for HeaderPart0");
121: Holder<HeaderPart0> holder = new Holder<HeaderPart0>(hp0);
122: DocLitWrapService service = new DocLitWrapService();
123: DocLitWrap proxy = service.getDocLitWrapPort();
124: HeaderResponse hr = proxy.header(header, holder, hp1);
125: hp0 = holder.value;
126: TestLogger.logger.debug("Holder Response String ="
127: + hp0.getHeaderType());
128: TestLogger.logger.debug("Header Response Long ="
129: + hr.getOut());
130: TestLogger.logger.debug("------------------------------");
131: } catch (Exception e) {
132: e.printStackTrace();
133: fail();
134: }
135: }
136:
137: public void testTwoWayHolderAsync() {
138: TestLogger.logger.debug("------------------------------");
139: TestLogger.logger.debug("Test : " + getName());
140: try {
141: String holderString = new String("Test twoWay Sync");
142: Integer holderInteger = new Integer(0);
143: Holder<String> strHolder = new Holder<String>(holderString);
144: Holder<Integer> intHolder = new Holder<Integer>(
145: holderInteger);
146: DocLitWrapService service = new DocLitWrapService();
147: DocLitWrap proxy = service.getDocLitWrapPort();
148: proxy.twoWayHolder(strHolder, intHolder);
149: TestLogger.logger.debug("Holder Response String ="
150: + strHolder.value);
151: ;
152: TestLogger.logger.debug("Holder Response Integer ="
153: + intHolder.value);
154: TestLogger.logger.debug("------------------------------");
155: } catch (Exception e) {
156: e.printStackTrace();
157: fail();
158: }
159: }
160:
161: /**
162: * This is a test of a doc/lit method that passes the
163: * request in a header. This can only be reproduced via
164: * annotations and WSGEN. WSImport will not allow this.
165: */
166: public void testEchoStringWSGEN1() {
167: TestLogger.logger.debug("------------------------------");
168: TestLogger.logger.debug("Test : " + getName());
169: try {
170: String request = "hello world";
171:
172: DocLitWrapService service = new DocLitWrapService();
173: DocLitWrap proxy = service.getDocLitWrapPort();
174: String response = proxy.echoStringWSGEN1(request);
175: assertTrue(response.equals(request));
176: TestLogger.logger.debug("------------------------------");
177: } catch (Exception e) {
178: e.printStackTrace();
179: fail();
180: }
181: }
182:
183: /**
184: * This is a test of a doc/lit method that passes the
185: * response in a header. This can only be reproduced via
186: * annotations and WSGEN. WSImport will not allow this.
187: */
188:
189: public void testEchoStringWSGEN2() {
190: TestLogger.logger.debug("------------------------------");
191: TestLogger.logger.debug("Test : " + getName());
192: try {
193: String request = "hello world 2";
194:
195: DocLitWrapService service = new DocLitWrapService();
196: DocLitWrap proxy = service.getDocLitWrapPort();
197: String response = proxy.echoStringWSGEN2(request);
198: assertTrue(response.equals(request));
199: TestLogger.logger.debug("------------------------------");
200: } catch (Exception e) {
201: e.printStackTrace();
202: fail();
203: }
204: }
205:
206: }
|