01: /**
02: *
03: * Licensed to the Apache Software Foundation (ASF) under one or more
04: * contributor license agreements. See the NOTICE file distributed with
05: * this work for additional information regarding copyright ownership.
06: * The ASF licenses this file to You under the Apache License, Version 2.0
07: * (the "License"); you may not use this file except in compliance with
08: * the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: */package org.apache.openejb.client;
18:
19: import junit.framework.TestCase;
20:
21: import javax.xml.ws.spi.Provider;
22: import javax.xml.ws.spi.ServiceDelegate;
23: import javax.xml.ws.Endpoint;
24: import javax.xml.ws.EndpointReference;
25: import javax.xml.ws.WebServiceFeature;
26: import javax.xml.ws.wsaddressing.W3CEndpointReference;
27: import javax.xml.namespace.QName;
28: import javax.xml.transform.Source;
29: import java.net.URL;
30: import java.util.List;
31:
32: import org.w3c.dom.Element;
33:
34: public class JaxWsProviderWrapperTest extends TestCase {
35: public void test() throws Exception {
36: System.setProperty(Provider.JAXWSPROVIDER_PROPERTY,
37: MockProvider.class.getName());
38: Provider provider = Provider.provider();
39: assertNotNull("provider is null", provider);
40: assertFalse(
41: "provider should not be an instance of ProviderWrapper",
42: provider instanceof JaxWsProviderWrapper);
43:
44: JaxWsProviderWrapper.beforeCreate(null);
45: try {
46: provider = Provider.provider();
47: assertNotNull("provider is null", provider);
48: assertTrue(
49: "provider should be an instance of ProviderWrapper",
50: provider instanceof JaxWsProviderWrapper);
51: JaxWsProviderWrapper providerWrapper = (JaxWsProviderWrapper) provider;
52:
53: // check delegate
54: Provider delegate = providerWrapper.getDelegate();
55: assertNotNull("providerWrapper delegate is null", delegate);
56: assertFalse(
57: "providerWrapper delegate should not be an instance of ProviderWrapper",
58: delegate instanceof JaxWsProviderWrapper);
59: } finally {
60: JaxWsProviderWrapper.afterCreate();
61: }
62: }
63:
64: @SuppressWarnings({"UnusedDeclaration"})
65: public static class MockProvider extends Provider {
66: public ServiceDelegate createServiceDelegate(URL url,
67: QName qName, Class aClass) {
68: return null;
69: }
70:
71: public Endpoint createEndpoint(String string, Object object) {
72: return null;
73: }
74:
75: public Endpoint createAndPublishEndpoint(String string,
76: Object object) {
77: return null;
78: }
79:
80: public W3CEndpointReference createW3CEndpointReference(
81: String address, QName serviceName, QName portName,
82: List<Element> metadata, String wsdlDocumentLocation,
83: List<Element> referenceParameters) {
84: return null;
85: }
86:
87: public EndpointReference readEndpointReference(Source source) {
88: return null;
89: }
90:
91: public <T> T getPort(EndpointReference endpointReference,
92: Class<T> serviceEndpointInterface,
93: WebServiceFeature... features) {
94: return null;
95: }
96: }
97: }
|