1 package org.apache.maven.scm.plugin;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.maven.plugin.testing.AbstractMojoTestCase;
23 import org.codehaus.plexus.util.FileUtils;
24
25 import java.io.File;
26
27
28
29
30
31
32
33 public class BootstrapMojoTest
34 extends AbstractMojoTestCase
35 {
36 File checkoutDir;
37
38 File projectDir;
39
40 File goalDir;
41
42 BootstrapMojo bootstrapMojo;
43
44 protected void setUp()
45 throws Exception
46 {
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 public void testDetermineWorkingDirectoryPath()
63 throws Exception
64 {
65
66 assertEquals( checkoutDir.getPath(), bootstrapMojo.determineWorkingDirectoryPath( checkoutDir, "", "" ) );
67 assertEquals( checkoutDir.getPath(), bootstrapMojo.determineWorkingDirectoryPath( checkoutDir, null, null ) );
68
69
70 assertEquals( projectDir.getPath(),
71 bootstrapMojo.determineWorkingDirectoryPath( checkoutDir, "", "my/project" ) );
72
73
74 assertEquals( projectDir.getPath(),
75 bootstrapMojo.determineWorkingDirectoryPath( checkoutDir, "my/project", null ) );
76 assertEquals( projectDir.getPath(),
77 bootstrapMojo.determineWorkingDirectoryPath( checkoutDir, "my/project/", null ) );
78 assertEquals( projectDir.getPath(), bootstrapMojo.determineWorkingDirectoryPath( checkoutDir, "my" + File
79 .separator + "project", null ) );
80
81
82 assertEquals( goalDir.getPath(),
83 bootstrapMojo.determineWorkingDirectoryPath( checkoutDir, "my/project", "modules/1" ) );
84 assertEquals( goalDir.getPath(),
85 bootstrapMojo.determineWorkingDirectoryPath( checkoutDir, "my/project/", "modules/1/" ) );
86 assertEquals( goalDir.getPath(), bootstrapMojo.determineWorkingDirectoryPath( checkoutDir,
87 "my" + File.separator + "project",
88 "modules" + File.separator +
89 "1" ) );
90 }
91
92
93 }