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: */package org.apache.cxf.tools.util;
19:
20: import org.junit.Assert;
21: import org.junit.Test;
22:
23: public class URIParserUtilTest extends Assert {
24:
25: @Test
26: public void testGetPackageName() {
27:
28: String packageName = URIParserUtil
29: .getPackageName("http://www.cxf.iona.com");
30: assertEquals(packageName, "com.iona.cxf");
31: packageName = URIParserUtil
32: .getPackageName("urn://www.class.iona.com");
33: assertEquals(packageName, "com.iona._class");
34: }
35:
36: @Test
37: public void testNormalize() throws Exception {
38: String uri = "wsdl/hello_world.wsdl";
39: assertEquals("file:wsdl/hello_world.wsdl", URIParserUtil
40: .normalize(uri));
41:
42: uri = "\\src\\wsdl/hello_world.wsdl";
43: assertEquals("file:/src/wsdl/hello_world.wsdl", URIParserUtil
44: .normalize(uri));
45:
46: uri = "wsdl\\hello_world.wsdl";
47: assertEquals("file:wsdl/hello_world.wsdl", URIParserUtil
48: .normalize(uri));
49:
50: uri = "http://hello.com";
51: assertEquals("http://hello.com", URIParserUtil.normalize(uri));
52:
53: uri = "file:///c:\\hello.wsdl";
54: assertEquals("file:/c:/hello.wsdl", URIParserUtil
55: .normalize(uri));
56:
57: uri = "c:\\hello.wsdl";
58: assertEquals("file:/c:/hello.wsdl", URIParserUtil
59: .normalize(uri));
60:
61: uri = "/c:\\hello.wsdl";
62: assertEquals("file:/c:/hello.wsdl", URIParserUtil
63: .normalize(uri));
64: }
65:
66: @Test
67: public void testGetAbsoluteURI() throws Exception {
68: String uri = "wsdl/hello_world.wsdl";
69: String uri2 = URIParserUtil.getAbsoluteURI(uri);
70: assertNotNull(uri2);
71: assertTrue(uri2.startsWith("file"));
72: assertTrue(uri2.contains(uri));
73: assertTrue(uri2.contains(new java.io.File("").toString()));
74:
75: uri = getClass().getResource("/schemas/wsdl/test.xsd")
76: .toString();
77: uri2 = URIParserUtil.getAbsoluteURI(uri);
78: assertNotNull(uri2);
79: assertTrue(uri2.startsWith("file"));
80: assertTrue(uri2.contains(uri));
81: assertTrue(uri2.contains(new java.io.File("").toString()));
82:
83: uri = "c:\\wsdl\\hello_world.wsdl";
84: uri2 = URIParserUtil.getAbsoluteURI(uri);
85: assertNotNull(uri2);
86: assertEquals("file:/c:/wsdl/hello_world.wsdl", uri2);
87:
88: uri = "/c:\\wsdl\\hello_world.wsdl";
89: uri2 = URIParserUtil.getAbsoluteURI(uri);
90: assertNotNull(uri2);
91: assertEquals("file:/c:/wsdl/hello_world.wsdl", uri2);
92:
93: uri = "http://hello/world.wsdl";
94: assertEquals(uri, URIParserUtil.getAbsoluteURI(uri));
95: }
96: }
|