1 package org.apache.maven.shared.release.exec;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import static org.mockito.Matchers.eq;
23 import static org.mockito.Matchers.isA;
24 import static org.mockito.Matchers.isNull;
25 import static org.mockito.Mockito.reset;
26 import static org.mockito.Mockito.spy;
27 import static org.mockito.Mockito.verify;
28
29 import java.io.File;
30 import java.util.ArrayList;
31 import java.util.Arrays;
32 import java.util.List;
33
34 import junit.framework.TestCase;
35
36 import org.apache.maven.shared.release.ReleaseResult;
37 import org.apache.maven.shared.release.env.ReleaseEnvironment;
38
39 public class AbstractMavenExecutorTest
40 extends TestCase
41 {
42
43 public void testGoalSeparation()
44 throws MavenExecutorException
45 {
46 AbstractMavenExecutor executor = spy( new AbstractMavenExecutorSpy() );
47
48 executor.executeGoals( null, null, true, null, null );
49 verify( executor ).executeGoals( isNull( File.class ), eq( new ArrayList<String>() ),
50 isA( ReleaseEnvironment.class ), eq( true ), isNull( String.class ),
51 isNull( String.class ), isNull( ReleaseResult.class ) );
52 reset( executor );
53
54 executor.executeGoals( null, " clean verify ", true, null, null );
55 verify( executor ).executeGoals( isNull( File.class ),
56 eq( Arrays.asList( new String[] { "clean", "verify" } ) ),
57 isA( ReleaseEnvironment.class ), eq( true ), isNull( String.class ),
58 isNull( String.class ), isNull( ReleaseResult.class ) );
59 reset( executor );
60
61 executor.executeGoals( null, ",clean,verify,", true, null, null );
62 verify( executor ).executeGoals( isNull( File.class ),
63 eq( Arrays.asList( new String[] { "clean", "verify" } ) ),
64 isA( ReleaseEnvironment.class ), eq( true ), isNull( String.class ),
65 isNull( String.class ), isNull( ReleaseResult.class ) );
66 reset( executor );
67
68 executor.executeGoals( null, "\nclean\nverify\n", true, null, null );
69 verify( executor ).executeGoals( isNull( File.class ),
70 eq( Arrays.asList( new String[] { "clean", "verify" } ) ),
71 isA( ReleaseEnvironment.class ), eq( true ), isNull( String.class ),
72 isNull( String.class ), isNull( ReleaseResult.class ) );
73 reset( executor );
74
75 executor.executeGoals( null, "\rclean\rverify\r", true, null, null );
76 verify( executor ).executeGoals( isNull( File.class ),
77 eq( Arrays.asList( new String[] { "clean", "verify" } ) ),
78 isA( ReleaseEnvironment.class ), eq( true ), isNull( String.class ),
79 isNull( String.class ), isNull( ReleaseResult.class ) );
80 reset( executor );
81
82 executor.executeGoals( null, "\r\nclean\r\nverify\r\n", true, null, null );
83 verify( executor ).executeGoals( isNull( File.class ),
84 eq( Arrays.asList( new String[] { "clean", "verify" } ) ),
85 isA( ReleaseEnvironment.class ), eq( true ), isNull( String.class ),
86 isNull( String.class ), isNull( ReleaseResult.class ) );
87 reset( executor );
88
89 executor.executeGoals( null, "\tclean\tverify\t", true, null, null );
90 verify( executor ).executeGoals( isNull( File.class ),
91 eq( Arrays.asList( new String[] { "clean", "verify" } ) ),
92 isA( ReleaseEnvironment.class ), eq( true ), isNull( String.class ),
93 isNull( String.class ), isNull( ReleaseResult.class ) );
94 reset( executor );
95 }
96
97 protected class AbstractMavenExecutorSpy
98 extends AbstractMavenExecutor
99 {
100
101 @Override
102 protected void executeGoals( File workingDirectory, List<String> goals, ReleaseEnvironment releaseEnvironment,
103 boolean interactive, String additionalArguments, String pomFileName,
104 ReleaseResult result )
105 throws MavenExecutorException
106 {
107 }
108 }
109 }