1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.scm.plugin;
20
21 import java.io.File;
22
23 import org.codehaus.plexus.util.FileUtils;
24 import org.junit.Before;
25 import org.junit.Test;
26 import org.junit.runner.RunWith;
27 import org.junit.runners.JUnit4;
28
29
30
31
32
33
34
35 @RunWith(JUnit4.class)
36 public class BootstrapMojoTest extends AbstractJUnit4MojoTestCase {
37 File checkoutDir;
38
39 File projectDir;
40
41 File goalDir;
42
43 BootstrapMojo bootstrapMojo;
44
45 @Before
46 public void setUp() throws Exception {
47 super.setUp();
48
49 checkoutDir = getTestFile("target/checkout");
50 FileUtils.forceDelete(checkoutDir);
51 checkoutDir.mkdirs();
52
53 projectDir = getTestFile("target/checkout/my/project");
54 projectDir.mkdirs();
55
56 goalDir = getTestFile("target/checkout/my/project/modules/1");
57 goalDir.mkdirs();
58
59 bootstrapMojo = new BootstrapMojo();
60 }
61
62 @Test
63 public void testDetermineWorkingDirectoryPath() throws Exception {
64
65 assertEquals(checkoutDir.getPath(), bootstrapMojo.determineWorkingDirectoryPath(checkoutDir, "", ""));
66 assertEquals(checkoutDir.getPath(), bootstrapMojo.determineWorkingDirectoryPath(checkoutDir, null, null));
67
68
69 assertEquals(projectDir.getPath(), bootstrapMojo.determineWorkingDirectoryPath(checkoutDir, "", "my/project"));
70
71
72 assertEquals(
73 projectDir.getPath(), bootstrapMojo.determineWorkingDirectoryPath(checkoutDir, "my/project", null));
74 assertEquals(
75 projectDir.getPath(), bootstrapMojo.determineWorkingDirectoryPath(checkoutDir, "my/project/", null));
76 assertEquals(
77 projectDir.getPath(),
78 bootstrapMojo.determineWorkingDirectoryPath(checkoutDir, "my" + File.separator + "project", null));
79
80
81 assertEquals(
82 goalDir.getPath(), bootstrapMojo.determineWorkingDirectoryPath(checkoutDir, "my/project", "modules/1"));
83 assertEquals(
84 goalDir.getPath(),
85 bootstrapMojo.determineWorkingDirectoryPath(checkoutDir, "my/project/", "modules/1/"));
86 assertEquals(
87 goalDir.getPath(),
88 bootstrapMojo.determineWorkingDirectoryPath(
89 checkoutDir, "my" + File.separator + "project", "modules" + File.separator + "1"));
90 }
91 }