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.jaxws;
019:
020: import java.net.URL;
021: import java.util.logging.Logger;
022:
023: import javax.xml.namespace.QName;
024: import javax.xml.ws.Endpoint;
025: import javax.xml.ws.Holder;
026:
027: import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
028: import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
029:
030: import org.apache.locator.LocatorService;
031: import org.apache.locator.LocatorService_Service;
032: import org.apache.locator.types.QueryEndpoints;
033: import org.apache.locator_test.LocatorServiceImpl;
034: import org.junit.BeforeClass;
035: import org.junit.Test;
036:
037: public class LocatorClientServerTest extends
038: AbstractBusClientServerTestBase {
039:
040: static final Logger LOG = Logger
041: .getLogger(LocatorClientServerTest.class.getName());
042: private final QName serviceName = new QName(
043: "http://apache.org/locator", "LocatorService");
044:
045: public static class MyServer extends AbstractBusTestServerBase {
046:
047: protected void run() {
048: Object implementor = new LocatorServiceImpl();
049: String address = "http://localhost:6006/services/LocatorService";
050: Endpoint.publish(address, implementor);
051:
052: }
053:
054: public static void main(String[] args) {
055: try {
056: MyServer s = new MyServer();
057: s.start();
058: } catch (Exception ex) {
059: ex.printStackTrace();
060: System.exit(-1);
061: } finally {
062: LOG.info("done!");
063: }
064: }
065: }
066:
067: @BeforeClass
068: public static void startServers() throws Exception {
069: assertTrue("server did not launch correctly",
070: launchServer(MyServer.class));
071: }
072:
073: @Test
074: public void testLocatorService() throws Exception {
075: URL wsdl = getClass().getResource("/wsdl/locator.wsdl");
076: assertNotNull(wsdl);
077:
078: LocatorService_Service ss = new LocatorService_Service(wsdl,
079: serviceName);
080: LocatorService port = ss.getLocatorServicePort();
081:
082: port
083: .registerPeerManager(
084: new org.apache.cxf.ws.addressing.EndpointReferenceType(),
085: new Holder<org.apache.cxf.ws.addressing.EndpointReferenceType>(),
086: new Holder<java.lang.String>());
087:
088: port.deregisterPeerManager(new java.lang.String());
089:
090: port
091: .registerEndpoint(
092: null,
093: new org.apache.cxf.ws.addressing.EndpointReferenceType());
094:
095: port
096: .deregisterEndpoint(
097: null,
098: new org.apache.cxf.ws.addressing.EndpointReferenceType());
099:
100: port.lookupEndpoint(new javax.xml.namespace.QName("", ""));
101:
102: port.listEndpoints();
103:
104: port.queryEndpoints(new QueryEndpoints());
105:
106: }
107: }
|