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.ws.rm;
019:
020: import java.util.logging.Logger;
021:
022: import javax.xml.ws.Endpoint;
023:
024: import org.apache.cxf.Bus;
025: import org.apache.cxf.BusFactory;
026: import org.apache.cxf.bus.spring.SpringBusFactory;
027: import org.apache.cxf.systest.ws.util.ConnectionHelper;
028: import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
029: import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
030: import org.apache.hello_world_soap_http.DocLitBare;
031: import org.apache.hello_world_soap_http.DocLitBareGreeterImpl;
032: import org.apache.hello_world_soap_http.SOAPServiceAddressingDocLitBare;
033: import org.apache.hello_world_soap_http.types.BareDocumentResponse;
034: import org.junit.BeforeClass;
035: import org.junit.Test;
036:
037: /**
038: * Tests the addition of WS-RM properties to application messages and the
039: * exchange of WS-RM protocol messages.
040: */
041: public class DecoupledBareTest extends AbstractBusClientServerTestBase {
042:
043: private static final Logger LOG = Logger
044: .getLogger(DecoupledBareTest.class.getName());
045:
046: public static class Server extends AbstractBusTestServerBase {
047:
048: protected void run() {
049: SpringBusFactory bf = new SpringBusFactory();
050: Bus bus = bf
051: .createBus("/org/apache/cxf/systest/ws/rm/decoupled_bare.xml");
052: BusFactory.setDefaultBus(bus);
053:
054: Object implementor = new DocLitBareGreeterImpl();
055: String address = "http://localhost:7600/SoapContext/SoapPort";
056: Endpoint.publish(address, implementor);
057: LOG.info("Published server endpoint.");
058: }
059:
060: public static void main(String[] args) {
061: try {
062: Server s = new Server();
063: s.start();
064: } catch (Exception ex) {
065: ex.printStackTrace();
066: System.exit(-1);
067: } finally {
068: System.out.println("done!");
069: }
070: }
071: }
072:
073: @BeforeClass
074: public static void startServers() throws Exception {
075: assertTrue("server did not launch correctly",
076: launchServer(Server.class));
077: }
078:
079: @Test
080: public void testDecoupled() throws Exception {
081: SpringBusFactory bf = new SpringBusFactory();
082: bus = bf
083: .createBus("/org/apache/cxf/systest/ws/rm/decoupled_bare.xml");
084: BusFactory.setDefaultBus(bus);
085:
086: SOAPServiceAddressingDocLitBare service = new SOAPServiceAddressingDocLitBare();
087: assertNotNull(service);
088:
089: DocLitBare greeter = service.getSoapPort();
090:
091: ConnectionHelper.setKeepAliveConnection(greeter, true);
092:
093: BareDocumentResponse bareres = greeter
094: .testDocLitBare("MySimpleDocument");
095: assertNotNull("no response for operation testDocLitBare",
096: bareres);
097: assertEquals("CXF", bareres.getCompany());
098: assertTrue(bareres.getId() == 1);
099: }
100: }
|