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
25
26
27 public class IdeaMojoTestCase
28 extends TestCase
29 {
30 private IdeaMojo mojo;
31
32 protected void setUp()
33 throws Exception
34 {
35 mojo = new IdeaMojo();
36 }
37
38 public void testToRelative()
39 {
40 String relativePath;
41
42 relativePath = mojo.toRelative( "C:\\dev\\voca\\gateway",
43 "C:/dev/voca/gateway/parser/gateway-parser.iml" );
44 assertEquals( "Test toRelative child, backslash", "parser/gateway-parser.iml", relativePath );
45
46 relativePath = mojo.toRelative( "C:\\dev\\voca\\gateway\\",
47 "C:/dev/voca/gateway/parser/gateway-parser.iml" );
48 assertEquals( "Test toRelative child, trailing backslash", "parser/gateway-parser.iml", relativePath );
49
50 relativePath = mojo.toRelative( "C:/dev/voca/gateway",
51 "C:/dev/voca/gateway/parser/gateway-parser.iml" );
52 assertEquals( "Test toRelative child, slash", "parser/gateway-parser.iml", relativePath );
53
54 relativePath = mojo.toRelative( "C:/dev/voca/gateway/",
55 "C:/dev/voca/gateway/parser/gateway-parser.iml" );
56 assertEquals( "Test toRelative child, trailing slash", "parser/gateway-parser.iml", relativePath );
57
58
59 relativePath = mojo.toRelative( "C:\\foo\\master",
60 "C:\\foo\\child" );
61 assertEquals( "Test toRelative sibling, no trailing backspace", "../child", relativePath );
62
63 relativePath = mojo.toRelative( "C:\\foo\\master\\",
64 "C:\\foo\\child" );
65 assertEquals( "Test toRelative sibling, first trailing backspace", "../child", relativePath );
66
67 relativePath = mojo.toRelative( "C:\\foo\\master",
68 "C:\\foo\\child\\" );
69 assertEquals( "Test toRelative sibling, second trailing backspace", "../child", relativePath );
70
71 relativePath = mojo.toRelative( "C:\\foo\\master\\",
72 "C:\\foo\\child\\" );
73 assertEquals( "Test toRelative sibling, both trailing backspace", "../child", relativePath );
74
75
76 relativePath = mojo.toRelative( "/myproject/myproject",
77 "/myproject/myproject-module1/myproject-module1.iml" );
78 assertEquals( "Test parent matches prefix of child, no trailing slash", "../myproject-module1/myproject-module1.iml", relativePath );
79
80 relativePath = mojo.toRelative( "/myproject/myproject/",
81 "/myproject/myproject-module1/myproject-module1.iml" );
82 assertEquals( "Test parent matches prefix of child, trailing slash", "../myproject-module1/myproject-module1.iml", relativePath );
83 }
84 }