This project has retired. For details please refer to its
Attic page.
WSDLLocatorTest xref
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package org.apache.juddi.v3.client.mapping.wsdl;
16
17 import java.net.URISyntaxException;
18 import java.net.URL;
19
20 import org.apache.juddi.v3.client.ClassUtil;
21 import org.apache.juddi.v3.client.mapping.wsdl.WSDLLocatorImpl;
22 import org.junit.Assert;
23 import org.junit.Test;
24
25
26
27
28 public class WSDLLocatorTest {
29
30 @Test
31 public void testResolveAbsoluteURL() {
32 WSDLLocatorImpl wsdlLocatorImpl = new WSDLLocatorImpl(null);
33 URL url = wsdlLocatorImpl.constructImportUrl(null, "http://localhost/file.wsdl");
34 Assert.assertEquals("http://localhost/file.wsdl", url.toExternalForm());
35 }
36
37 @Test
38 public void testResolveAbsoluteURL2() {
39 WSDLLocatorImpl wsdlLocatorImpl = new WSDLLocatorImpl(null);
40 URL url = wsdlLocatorImpl.constructImportUrl("should get ignored", "http://localhost/file.wsdl");
41 Assert.assertEquals("http://localhost/file.wsdl", url.toExternalForm());
42 }
43
44 @Test
45 public void testResolveInCurrentDir() {
46 WSDLLocatorImpl wsdlLocatorImpl = new WSDLLocatorImpl(null);
47 URL wsdlFile = ClassUtil.getResource("wsdl/HelloWorld.wsdl", this.getClass());
48 if (wsdlFile==null) Assert.fail("Can not find HelloWorld.wsdl file");
49 String wsdlFileStr = wsdlFile.toExternalForm();
50 String wsdlDir = wsdlFileStr.substring(0,wsdlFileStr.lastIndexOf("/"));
51 URL url = wsdlLocatorImpl.constructImportUrl(wsdlFileStr, "child.wsdl");
52 Assert.assertEquals(wsdlDir + "/child.wsdl", url.toExternalForm());
53 }
54
55 @Test
56 public void testResolveInCurrentDir2() {
57 WSDLLocatorImpl wsdlLocatorImpl = new WSDLLocatorImpl(null);
58 URL wsdlFile = ClassUtil.getResource("wsdl/HelloWorld.wsdl", this.getClass());
59 if (wsdlFile==null) Assert.fail("Can not find HelloWorld.wsdl file");
60 String wsdlFileStr = wsdlFile.toExternalForm();
61 String wsdlDir = wsdlFileStr.substring(0,wsdlFileStr.lastIndexOf("/"));
62 URL url = wsdlLocatorImpl.constructImportUrl(wsdlFileStr, "./child.wsdl");
63 Assert.assertEquals(wsdlDir + "/child.wsdl", url.toExternalForm());
64 }
65
66 @Test
67 public void testResolveInParentDir() {
68 WSDLLocatorImpl wsdlLocatorImpl = new WSDLLocatorImpl(null);
69 URL wsdlFile = ClassUtil.getResource("wsdl/HelloWorld.wsdl", this.getClass());
70 if (wsdlFile==null) Assert.fail("Can not find HelloWorld.wsdl file");
71 String wsdlFileStr = wsdlFile.toExternalForm();
72 String wsdlDir = wsdlFileStr.substring(0,wsdlFileStr.lastIndexOf("/"));
73 wsdlDir = wsdlDir.substring(0, wsdlDir.lastIndexOf("/"));
74 URL url = wsdlLocatorImpl.constructImportUrl(wsdlFileStr, "../child.wsdl");
75 Assert.assertEquals(wsdlDir + "/child.wsdl", url.toExternalForm());
76 }
77
78 @Test
79 public void testResolveInParentDir2() throws URISyntaxException {
80 WSDLLocatorImpl wsdlLocatorImpl = new WSDLLocatorImpl(null);
81 URL wsdlFile = ClassUtil.getResource("wsdl/HelloWorld.wsdl", this.getClass());
82 if (wsdlFile==null) Assert.fail("Can not find HelloWorld.wsdl file");
83 String wsdlFileStr = wsdlFile.toExternalForm();
84 String wsdlDir = wsdlFileStr.substring(0,wsdlFileStr.lastIndexOf("/"));
85 wsdlDir = wsdlDir.substring(0, wsdlDir.lastIndexOf("/"));
86 wsdlDir = wsdlDir.substring(0, wsdlDir.lastIndexOf("/"));
87 URL url = wsdlLocatorImpl.constructImportUrl(wsdlFileStr, "../../child.wsdl");
88 Assert.assertEquals(wsdlDir + "/child.wsdl", url.toExternalForm());
89 }
90
91 }