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: */package org.apache.cxf.systest.coloc;
019:
020: import javax.xml.namespace.QName;
021:
022: import static junit.framework.Assert.assertEquals;
023:
024: import org.apache.hello_world_soap_http.BadRecordLitFault;
025: import org.apache.hello_world_soap_http.Greeter;
026: import org.apache.hello_world_soap_http.GreeterImpl;
027: import org.apache.hello_world_soap_http.NoSuchCodeLitFault;
028: import org.junit.Before; //import org.junit.Ignore;
029: import org.junit.Test;
030:
031: /**
032: * This class invokes the service described in /wsdl/greeter_control.wsdl.
033: * This WSDL contains operations with in-out parameters.
034: * It sets up the a client in "getPort()" to send requests to the
035: * server which is listening on port 9001 (SOAP/HTTP).
036: * The subclass defines where CXF configuration and the
037: * target server (transport, etc).
038: *
039: */
040: public abstract class AbstractWrappedDocLitTest extends
041: AbstractColocTest {
042: static final QName SERVICE_NAME = new QName(
043: "http://apache.org/hello_world_soap_http", "SOAPService");
044: static final QName PORT_NAME = new QName(
045: "http://apache.org/hello_world_soap_http", "SoapPort");
046: static final String WSDL_LOCATION = "/wsdl/hello_world.wsdl";
047:
048: private Greeter port;
049: private GreeterImpl impl = new GreeterImpl();
050:
051: @Before
052: public void setUp() throws Exception {
053: super .setUp();
054: port = getPort(getServiceQname(), getPortQName(),
055: getWsdlLocation(), Greeter.class);
056: }
057:
058: @Test
059: public void testTwoWayOperation() {
060: for (int idx = 0; idx < 2; idx++) {
061: verifySayHi(port);
062: verifyGreetMe(port);
063: }
064: }
065:
066: @Test
067: public void testOneWayOperation() {
068: for (int idx = 0; idx < 2; idx++) {
069: verifyGreetMeOneway(port);
070: }
071: }
072:
073: @Test
074: public void testFault() {
075: for (int idx = 0; idx < 2; idx++) {
076: verifyTestDocLitFault(port);
077: }
078: }
079:
080: protected void verifyTestDocLitFault(Greeter proxy) {
081: try {
082: proxy.testDocLitFault(BadRecordLitFault.class
083: .getSimpleName());
084: fail("Should throw a BadRecordLitFault Exception");
085: } catch (BadRecordLitFault brlf) {
086: assertEquals(BadRecordLitFault.class.getSimpleName(), brlf
087: .getFaultInfo());
088: } catch (NoSuchCodeLitFault nsclf) {
089: fail("Should not throw a NoSuchCodeLitFault Exception");
090: }
091: }
092:
093: protected void verifyGreetMeOneway(Greeter proxy) {
094: int count = impl.getInvocationCount();
095: proxy.greetMeOneWay("oneWay");
096: assertTrue("Count Should not be same", count != impl
097: .getInvocationCount());
098: }
099:
100: protected void verifySayHi(Greeter greeterPort) {
101: String resp = greeterPort.sayHi();
102: assertEquals("Bonjour", resp);
103: }
104:
105: protected void verifyGreetMe(Greeter greeterPort) {
106: String resp = greeterPort.greetMe("BART");
107: assertEquals("Hello BART", resp);
108: }
109:
110: protected Object getServiceImpl() {
111: return impl;
112: }
113:
114: protected String getWsdlLocation() {
115: return WSDL_LOCATION;
116: }
117:
118: protected QName getServiceQname() {
119: return SERVICE_NAME;
120: }
121:
122: protected QName getPortQName() {
123: return PORT_NAME;
124: }
125:
126: protected boolean isFaultCodeCheckEnabled() {
127: return false;
128: }
129: }
|