01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with 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,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */
19: package org.apache.axis2.jaxws.spi;
20:
21: import javax.xml.namespace.QName;
22: import javax.xml.transform.Source;
23: import javax.xml.ws.Dispatch;
24: import javax.xml.ws.Service;
25: import javax.xml.ws.soap.SOAPBinding;
26:
27: import junit.framework.TestCase;
28:
29: import org.apache.axis2.jaxws.description.EndpointDescription;
30:
31: /**
32: * The client APIs should each implement the org.apache.axis2.jaxws.spi.BindingProvider
33: * interface. This suite should be used for any client APIs to verify that they
34: * maintain that behavior.
35: */
36: public class BindingProviderTests extends TestCase {
37:
38: public QName serviceQName;
39: public QName portQName;
40:
41: public BindingProviderTests(String name) {
42: super (name);
43:
44: serviceQName = new QName("http://test", "TestService");
45: portQName = new QName("http://test", "TestPort");
46: }
47:
48: /**
49: * A test to verify that the Dispatch objects implement the proper interface
50: */
51: public void testDisptachBindingProviderSPI() {
52: Service svc = Service.create(serviceQName);
53: svc.addPort(portQName, SOAPBinding.SOAP11HTTP_BINDING, "");
54:
55: Dispatch dsp = svc.createDispatch(portQName, Source.class,
56: Service.Mode.MESSAGE);
57:
58: // Make sure we can cast the object to the right interfaces
59: assertTrue(
60: "The Dispatch object should also be a javax.xml.ws.BindingProvider",
61: (dsp instanceof javax.xml.ws.BindingProvider));
62: assertTrue(
63: "The Dispatch object should also be a org.apache.axis2.jaxws.spi.BindingProvider",
64: dsp instanceof org.apache.axis2.jaxws.spi.BindingProvider);
65:
66: org.apache.axis2.jaxws.spi.BindingProvider bp = (org.apache.axis2.jaxws.spi.BindingProvider) dsp;
67:
68: ServiceDelegate sd = bp.getServiceDelegate();
69: assertTrue("The ServiceDescription was null", sd != null);
70:
71: EndpointDescription ed = bp.getEndpointDescription();
72: assertTrue("The EndpointDescription was null", ed != null);
73: }
74:
75: /**
76: * A test to verify that the proxy objects implement the proper interface.
77: */
78: public void testProxyBindingProviderSPI() {
79: Service svc = Service.create(serviceQName);
80: Sample s = svc.getPort(Sample.class);
81:
82: // Make sure we can cast the object to the right interfaces
83: assertTrue(
84: "The Proxy object should also be a javax.xml.ws.BindingProvider",
85: s instanceof javax.xml.ws.BindingProvider);
86: assertTrue(
87: "The Proxy object should also be a org.apache.axis2.jaxws.spi.BindingProvider",
88: s instanceof org.apache.axis2.jaxws.spi.BindingProvider);
89:
90: org.apache.axis2.jaxws.spi.BindingProvider bp = (org.apache.axis2.jaxws.spi.BindingProvider) s;
91:
92: ServiceDelegate sd = bp.getServiceDelegate();
93: assertTrue("The ServiceDescription was null", sd != null);
94:
95: EndpointDescription ed = bp.getEndpointDescription();
96: assertTrue("The EndpointDescription was null", ed != null);
97: }
98: }
|