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: package org.apache.axis2.jaxws.xmlhttp.clientTests.dispatch.string;
020:
021: import javax.xml.namespace.QName;
022: import javax.xml.ws.Dispatch;
023: import javax.xml.ws.Service;
024: import javax.xml.ws.http.HTTPBinding;
025:
026: import junit.framework.TestCase;
027: import org.apache.axis2.jaxws.TestLogger;
028:
029: public class DispatchXPayloadString extends TestCase {
030:
031: public String HOSTPORT = "http://localhost:8080";
032:
033: private String ENDPOINT_URL = HOSTPORT
034: + "/axis2/services/XPayloadStringProvider";
035: private QName SERVICE_NAME = new QName(
036: "http://ws.apache.org/axis2", "XPayloadStringProvider");
037: private QName PORT_NAME = new QName("http://ws.apache.org/axis2",
038: "XPayloadStringProviderPort");
039:
040: private static String XML_TEXT = "<p:echo xmlns:p=\"http://sample\">hello world</p:echo>";
041: private static String XML_TEXT_NPE = "<p:echo xmlns:p=\"http://sample\">NPE</p:echo>";
042:
043: public Dispatch<String> getDispatch() {
044: Service service = Service.create(SERVICE_NAME);
045: service.addPort(PORT_NAME, HTTPBinding.HTTP_BINDING,
046: ENDPOINT_URL);
047: Dispatch<String> dispatch = service.createDispatch(PORT_NAME,
048: String.class, Service.Mode.PAYLOAD);
049: return dispatch;
050: }
051:
052: /**
053: * Simple XML/HTTP Payload Test
054: * @throws Exception
055: */
056: public void testSimple() throws Exception {
057: Dispatch<String> dispatch = getDispatch();
058: String request = XML_TEXT;
059: TestLogger.logger.debug("Request = " + request);
060: String response = dispatch.invoke(request);
061: TestLogger.logger.debug("Response = " + response);
062: assertTrue(response != null);
063: assertTrue(request.equals(response));
064: }
065:
066: /**
067: * TODO Need to fix the implementation and test
068: * @throws Exception
069: */
070: public void _testEmpty() throws Exception {
071: Dispatch<String> dispatch = getDispatch();
072: String request = "";
073: TestLogger.logger.debug("Request = " + request);
074: String response = dispatch.invoke(request);
075: TestLogger.logger.debug("Response = " + response);
076: assertTrue(response != null);
077: assertTrue(request.equals(response));
078: }
079:
080: /**
081: * TODO Need to fix the implementation and test
082: * @throws Exception
083: */
084: public void _testNull() throws Exception {
085: Dispatch<String> dispatch = getDispatch();
086: String request = null;
087: TestLogger.logger.debug("Request = " + request);
088: String response = dispatch.invoke(request);
089: TestLogger.logger.debug("Response = " + response);
090: assertTrue(response != null);
091: assertTrue(request.equals(response));
092: }
093:
094: /**
095: * TODO Need to fix the implementation and test
096: * @throws Exception
097: */
098: public void _testException() throws Exception {
099: Dispatch<String> dispatch = getDispatch();
100: String request = XML_TEXT_NPE;
101: TestLogger.logger.debug("Request = " + request);
102: String response = dispatch.invoke(request);
103: TestLogger.logger.debug("Response = " + response);
104: assertTrue(response != null);
105: assertTrue(request.equals(response));
106: }
107: }
|