Debian Codegraph @

src/test/java/org/jboss/modules/PathUtilsTest.java

raw
1 /*
2 * JBoss, Home of Professional Open Source.
3 * Copyright 2015 Red Hat, Inc., and individual contributors
4 * as indicated by the @author tags.
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
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 */
18
19 package org.jboss.modules;
20
21 import static org.jboss.modules.PathUtils.*;
22
23 import org.junit.Test;
24
25 import static org.junit.Assert.*;
26
27 /**
28 * Test to verify the PathUtils functionality.
29 *
30 * @author <a href="mailto:[email protected]">Richard Opalka</a>
31 */
32 public class PathUtilsTest {
33
34 @Test
35 public void testIsChild() {
36 assertTrue(isChild("app.war/", "app.war/W"));
37 assertTrue(isDirectChild("app.war/", "app.war/W"));
38 assertTrue(isChild("app.war/", "app.war/FOO/BAR"));
39 assertFalse(isDirectChild("app.war/", "app.war/FOO/BAR"));
40 assertTrue(isChild("app.war", "app.war/W"));
41 assertTrue(isDirectChild("app.war", "app.war/W"));
42 assertTrue(isChild("app.war", "app.war/FOO/BAR"));
43 assertFalse(isDirectChild("app.war", "app.war/FOO/BAR"));
44 assertFalse(isDirectChild("app.war", "app.war/"));
45 assertFalse(isChild("app.war", "app.war/"));
46 }
47
48 @Test
49 public void testBasicNames() {
50 assertEquals("basic/main", basicModuleNameToPath("basic"));
51 assertEquals("a/b/main", basicModuleNameToPath("a.b"));
52 assertEquals("a/b/c", basicModuleNameToPath("a.b:c"));
53 assertEquals("a/b/c.d", basicModuleNameToPath("a.b:c.d"));
54 assertEquals("a/b/c:d", basicModuleNameToPath("a.b:c:d"));
55 assertEquals("a/b/c.d", basicModuleNameToPath("a.b:c/d"));
56 assertEquals("a.b/c.d", basicModuleNameToPath("a/b:c.d"));
57 assertEquals("a:b/c.d", basicModuleNameToPath("a\\:b:c.d"));
58
59 assertNull(basicModuleNameToPath("."));
60 assertNull(basicModuleNameToPath(".."));
61 assertNull(basicModuleNameToPath("./"));
62 assertNull(basicModuleNameToPath("/foo"));
63 assertNull(basicModuleNameToPath(".foo"));
64 assertNull(basicModuleNameToPath("foo/."));
65 assertNull(basicModuleNameToPath("foo/"));
66 assertNull(basicModuleNameToPath("foo:"));
67 assertNull(basicModuleNameToPath("foo//bar"));
68 assertNull(basicModuleNameToPath("foo..bar"));
69 }
70 }