1 package org.apache.maven.plugins.invoker;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.io.File;
23 import java.util.Collections;
24 import java.util.List;
25
26 import org.apache.maven.plugin.testing.AbstractMojoTestCase;
27 import org.apache.maven.plugins.invoker.model.BuildJob;
28
29
30
31
32
33 public class InvokerMojoTest
34 extends AbstractMojoTestCase
35 {
36
37 public void testSingleInvokerTest()
38 throws Exception
39 {
40 InvokerMojo invokerMojo = new InvokerMojo();
41 String dirPath = getBasedir() + "/src/test/resources/unit";
42 List<String> goals = invokerMojo.getGoals( new File( dirPath ) );
43 assertEquals( 1, goals.size() );
44 setVariableValueToObject( invokerMojo, "projectsDirectory", new File( dirPath ) );
45 setVariableValueToObject( invokerMojo, "invokerTest", "*dummy*" );
46 BuildJob[] poms = invokerMojo.getBuildJobs();
47 assertEquals( 1, poms.length );
48 }
49
50 public void testMultiInvokerTest()
51 throws Exception
52 {
53 InvokerMojo invokerMojo = new InvokerMojo();
54 String dirPath = getBasedir() + "/src/test/resources/unit";
55 List<String> goals = invokerMojo.getGoals( new File( dirPath ) );
56 assertEquals( 1, goals.size() );
57 setVariableValueToObject( invokerMojo, "projectsDirectory", new File( dirPath ) );
58 setVariableValueToObject( invokerMojo, "invokerTest", "*dummy*,*terpolatio*" );
59 BuildJob[] poms = invokerMojo.getBuildJobs();
60 assertEquals( 2, poms.length );
61 }
62
63 public void testFullPatternInvokerTest()
64 throws Exception
65 {
66 InvokerMojo invokerMojo = new InvokerMojo();
67 String dirPath = getBasedir() + "/src/test/resources/unit";
68 List<String> goals = invokerMojo.getGoals( new File( dirPath ) );
69 assertEquals( 1, goals.size() );
70 setVariableValueToObject( invokerMojo, "projectsDirectory", new File( dirPath ) );
71 setVariableValueToObject( invokerMojo, "invokerTest", "*" );
72 BuildJob[] poms = invokerMojo.getBuildJobs();
73 assertEquals( 4, poms.length );
74 }
75
76 public void testAlreadyCloned()
77 throws Exception
78 {
79 assertFalse( AbstractInvokerMojo.alreadyCloned( "dir", Collections.<String>emptyList() ) );
80 assertTrue( AbstractInvokerMojo.alreadyCloned( "dir", Collections.singletonList( "dir" ) ) );
81 assertTrue( AbstractInvokerMojo.alreadyCloned( "dir" + File.separator + "sub",
82 Collections.singletonList( "dir" ) ) );
83 assertFalse( AbstractInvokerMojo.alreadyCloned( "dirs", Collections.singletonList( "dir" ) ) );
84 }
85
86 }