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.apache.maven.plugin.testing.AbstractMojoTestCase;
24 import org.codehaus.plexus.util.FileUtils;
25
26
27
28
29
30
31
32 public class BootstrapMojoTest extends AbstractMojoTestCase {
33 File checkoutDir;
34
35 File projectDir;
36
37 File goalDir;
38
39 BootstrapMojo bootstrapMojo;
40
41 protected void setUp() throws Exception {
42 super.setUp();
43
44 checkoutDir = getTestFile("target/checkout");
45 FileUtils.forceDelete(checkoutDir);
46 checkoutDir.mkdirs();
47
48 projectDir = getTestFile("target/checkout/my/project");
49 projectDir.mkdirs();
50
51 goalDir = getTestFile("target/checkout/my/project/modules/1");
52 goalDir.mkdirs();
53
54 bootstrapMojo = new BootstrapMojo();
55 }
56
57 public void testDetermineWorkingDirectoryPath() throws Exception {
58
59 assertEquals(checkoutDir.getPath(), bootstrapMojo.determineWorkingDirectoryPath(checkoutDir, "", ""));
60 assertEquals(checkoutDir.getPath(), bootstrapMojo.determineWorkingDirectoryPath(checkoutDir, null, null));
61
62
63 assertEquals(projectDir.getPath(), bootstrapMojo.determineWorkingDirectoryPath(checkoutDir, "", "my/project"));
64
65
66 assertEquals(
67 projectDir.getPath(), bootstrapMojo.determineWorkingDirectoryPath(checkoutDir, "my/project", null));
68 assertEquals(
69 projectDir.getPath(), bootstrapMojo.determineWorkingDirectoryPath(checkoutDir, "my/project/", null));
70 assertEquals(
71 projectDir.getPath(),
72 bootstrapMojo.determineWorkingDirectoryPath(checkoutDir, "my" + File.separator + "project", null));
73
74
75 assertEquals(
76 goalDir.getPath(), bootstrapMojo.determineWorkingDirectoryPath(checkoutDir, "my/project", "modules/1"));
77 assertEquals(
78 goalDir.getPath(),
79 bootstrapMojo.determineWorkingDirectoryPath(checkoutDir, "my/project/", "modules/1/"));
80 assertEquals(
81 goalDir.getPath(),
82 bootstrapMojo.determineWorkingDirectoryPath(
83 checkoutDir, "my" + File.separator + "project", "modules" + File.separator + "1"));
84 }
85 }