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.proxy;
020:
021: import javax.xml.namespace.QName;
022: import javax.xml.ws.WebServiceException;
023:
024: import junit.framework.TestCase;
025: import org.apache.axis2.jaxws.proxy.soap12.Echo;
026: import org.apache.axis2.jaxws.proxy.soap12.SOAP12EchoService;
027: import org.apache.axis2.jaxws.TestLogger;
028:
029: /**
030: * A suite of tests to test dynamic proxy clients sending SOAP 1.2
031: * requests. The endpoint can accept different keys to determine
032: * what it should send back.
033: */
034: public class SOAP12ProxyTests extends TestCase {
035:
036: private static final String SEND_SOAP11_RESPONSE = "RESPONSE-SOAP11";
037: private static final String SEND_SOAP12_RESPONSE = "RESPONSE-SOAP12";
038:
039: public SOAP12ProxyTests(String name) {
040: super (name);
041: }
042:
043: /**
044: * Send a SOAP 1.2 request and expect a SOAP 1.2 response.
045: */
046: public void testSOAP12RequestSOAP12Response() throws Exception {
047: TestLogger.logger
048: .debug("---------------------------------------");
049: TestLogger.logger.debug("test: " + getName());
050:
051: // create the proxy instance. the WSDL used by this proxy
052: // should have a proper SOAP 1.2 binding configured
053: SOAP12EchoService service = new SOAP12EchoService();
054: Echo proxy = service.getPort(new QName(
055: "http://jaxws.axis2.apache.org/proxy/soap12",
056: "EchoPort"), Echo.class);
057:
058: // invoke the remote operation. send a key that tells the
059: // service send back a SOAP 1.2 response.
060: String response = proxy.echo(SEND_SOAP12_RESPONSE);
061: TestLogger.logger.debug("response returned [" + response + "]");
062:
063: // validate the results
064: assertNotNull(response);
065: assertTrue(!response.equals("FAIL"));
066: }
067:
068: /**
069: * Send a SOAP 1.2 request, but have the server send back a SOAP 1.1
070: * response. This should result in an exception.
071: */
072: // TODO fix and re-enable
073: public void _testSOAP12RequestSOAP11Response() {
074: TestLogger.logger
075: .debug("---------------------------------------");
076: TestLogger.logger.debug("test: " + getName());
077:
078: // create the proxy instance. the WSDL used by this proxy
079: // should have a proper SOAP 1.2 binding configured
080: SOAP12EchoService service = new SOAP12EchoService();
081: Echo proxy = service.getPort(new QName(
082: "http://jaxws.axis2.apache.org/proxy/soap12",
083: "EchoPort"), Echo.class);
084:
085: // invoke the remote operation. send a key that tells the
086: // service send back a SOAP 1.1 response. this should result
087: // in an error.
088: try {
089: String response = proxy.echo(SEND_SOAP11_RESPONSE);
090: TestLogger.logger.debug("response returned [" + response
091: + "]");
092:
093: // if we've gotten this far, then something went wrong.
094: fail();
095: } catch (WebServiceException wse) {
096: TestLogger.logger
097: .debug("an exception was thrown, as expected");
098: TestLogger.logger.debug(wse.getMessage());
099: }
100: }
101:
102: public void test() {
103: // NOOP
104: }
105:
106: }
|