1 package org.apache.maven.plugin.idea;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import junit.framework.TestCase;
23
24 import java.io.File;
25
26
27
28
29 public class IdeaMojoTestCase
30 extends TestCase
31 {
32 private IdeaMojo mojo;
33
34 protected void setUp()
35 throws Exception
36 {
37 mojo = new IdeaMojo();
38 }
39
40 public void testToRelative()
41 {
42 String relativePath;
43
44 relativePath = mojo.toRelative( "C:\\dev\\voca\\gateway",
45 "C:/dev/voca/gateway/parser/gateway-parser.iml" );
46 assertEquals( "Test toRelative child, backslash", "parser/gateway-parser.iml", relativePath );
47
48 relativePath = mojo.toRelative( "C:\\dev\\voca\\gateway\\",
49 "C:/dev/voca/gateway/parser/gateway-parser.iml" );
50 assertEquals( "Test toRelative child, trailing backslash", "parser/gateway-parser.iml", relativePath );
51
52 relativePath = mojo.toRelative( "C:/dev/voca/gateway",
53 "C:/dev/voca/gateway/parser/gateway-parser.iml" );
54 assertEquals( "Test toRelative child, slash", "parser/gateway-parser.iml", relativePath );
55
56 relativePath = mojo.toRelative( "C:/dev/voca/gateway/",
57 "C:/dev/voca/gateway/parser/gateway-parser.iml" );
58 assertEquals( "Test toRelative child, trailing slash", "parser/gateway-parser.iml", relativePath );
59
60
61 relativePath = mojo.toRelative( "C:\\foo\\master",
62 "C:\\foo\\child" );
63 assertEquals( "Test toRelative sibling, no trailing backspace", "../child", relativePath );
64
65 relativePath = mojo.toRelative( "C:\\foo\\master\\",
66 "C:\\foo\\child" );
67 assertEquals( "Test toRelative sibling, first trailing backspace", "../child", relativePath );
68
69 relativePath = mojo.toRelative( "C:\\foo\\master",
70 "C:\\foo\\child\\" );
71 assertEquals( "Test toRelative sibling, second trailing backspace", "../child", relativePath );
72
73 relativePath = mojo.toRelative( "C:\\foo\\master\\",
74 "C:\\foo\\child\\" );
75 assertEquals( "Test toRelative sibling, both trailing backspace", "../child", relativePath );
76
77
78 relativePath = mojo.toRelative( "/myproject/myproject",
79 "/myproject/myproject-module1/myproject-module1.iml" );
80 assertEquals( "Test parent matches prefix of child, no trailing slash", "../myproject-module1/myproject-module1.iml", relativePath );
81
82 relativePath = mojo.toRelative( "/myproject/myproject/",
83 "/myproject/myproject-module1/myproject-module1.iml" );
84 assertEquals( "Test parent matches prefix of child, trailing slash", "../myproject-module1/myproject-module1.iml", relativePath );
85 }
86 }