1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.maven.plugins.shade.mojo;
21
22 import static org.junit.Assert.assertEquals;
23
24 import java.io.File;
25 import java.io.IOException;
26
27 import org.junit.Test;
28
29 public class RelativizePathTest
30 {
31 final static String[] PARENTS = { "rel-path-test-files/a/pom", "rel-path-test-files/a/b/pom",
32 "rel-path-test-files/a/b/c/pom", "rel-path-test-files/a/c/d/pom" };
33
34 final static String[] CHILDREN = { "rel-path-test-files/a/b/pom", "rel-path-test-files/a/pom",
35 "rel-path-test-files/a/b/c1/pom", "rel-path-test-files/a/c/d/pom" };
36
37 final static String[] ANSWER = { "../pom", "b/pom", "../c/pom", "pom" };
38
39 @Test
40 public void runTests() throws IOException
41 {
42 for ( int x = 0; x < PARENTS.length; x++ )
43 {
44 File parent = new File(PARENTS[x]).getCanonicalFile();
45 File child = new File(CHILDREN[x]).getCanonicalFile();
46 String answer = ANSWER[x];
47 String r = RelativizePath.convertToRelativePath( parent, child );
48 assertEquals(String.format("parent %s child %s", parent.toString(), child.toString()), answer, r );
49 }
50 }
51
52 }