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.client;
20:
21: import java.io.File;
22: import java.net.MalformedURLException;
23: import java.net.URL;
24:
25: import javax.xml.namespace.QName;
26: import javax.xml.ws.Dispatch;
27: import javax.xml.ws.Service;
28: import javax.xml.ws.Service.Mode;
29: import javax.xml.ws.WebServiceException;
30:
31: import junit.framework.TestCase;
32: import org.apache.axis2.jaxws.TestLogger;
33:
34: public class ClientConfigTests extends TestCase {
35:
36: public ClientConfigTests(String name) {
37: super (name);
38: }
39:
40: public void testBadWsdlUrl() throws Exception {
41:
42: URL url = null;
43: String wsdlLocation = null;
44: try {
45: try {
46: String baseDir = new File(System.getProperty("basedir",
47: ".")).getCanonicalPath();
48: wsdlLocation = new File(
49: baseDir
50: + "/test-resources/wsdl/BadEndpointAddress.wsdl")
51: .getAbsolutePath();
52: } catch (Exception e) {
53: e.printStackTrace();
54: }
55: File file = new File(wsdlLocation);
56: url = file.toURL();
57: } catch (MalformedURLException e) {
58: e.printStackTrace();
59: }
60:
61: Service svc = Service.create(url, new QName(
62: "http://jaxws.axis2.apache.org", "EchoService"));
63: Dispatch dispatch = svc.createDispatch(new QName(
64: "http://jaxws.axis2.apache.org", "EchoPort"),
65: String.class, Mode.PAYLOAD);
66:
67: try {
68: dispatch.invoke("");
69:
70: // If an exception wasn't thrown, then it's an error.
71: fail();
72: } catch (WebServiceException e) {
73: // We should only get a WebServiceException here. Anything else
74: // is a failure.
75: TestLogger.logger
76: .debug("[pass] - the proper fault type was thrown");
77: }
78: }
79: }
|