1 package org.apache.maven.it;
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.Properties;
24
25 import org.apache.maven.it.util.ResourceExtractor;
26
27
28
29
30
31 public class MavenITmng5889FindBasedir
32 extends AbstractMavenIntegrationTestCase
33 {
34 public MavenITmng5889FindBasedir()
35 {
36 super( "[3.5.0,3.5.1)" );
37 }
38
39 protected MavenITmng5889FindBasedir( String constraint )
40 {
41 super( constraint );
42 }
43
44
45
46
47
48
49 public void testMvnFileLongOption()
50 throws Exception
51 {
52 runCoreExtensionWithOption( "--file", null );
53 }
54
55
56
57
58
59
60 public void testMvnFileShortOption()
61 throws Exception
62 {
63 runCoreExtensionWithOption( "-f", null );
64 }
65
66
67
68
69
70
71 public void testMvnFileLongOptionModule()
72 throws Exception
73 {
74 runCoreExtensionWithOption( "--file", "module" );
75 }
76
77
78
79
80
81
82 public void testMvnFileShortOptionModule()
83 throws Exception
84 {
85 runCoreExtensionWithOption( "-f", "module" );
86 }
87
88 private void runCoreExtensionWithOption( String option, String subdir )
89 throws Exception
90 {
91 runCoreExtensionWithOption( option, subdir, true );
92 }
93
94 protected void runCoreExtensionWithOption( String option, String subdir, boolean pom )
95 throws Exception
96 {
97 File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-5889-find.mvn" );
98
99 File basedir = new File( testDir, "../mng-" + ( pom ? "5889" : "6223" ) + "-find.mvn" + option + ( pom ? "Pom" : "Dir" ) );
100 basedir.mkdir();
101
102 if ( subdir != null )
103 {
104 testDir = new File( testDir, subdir );
105 basedir = new File( basedir, subdir );
106 basedir.mkdirs();
107 }
108
109 Verifier verifier = newVerifier( basedir.getAbsolutePath() );
110 verifier.getCliOptions().add( "-Dexpression.outputFile=" + new File( basedir, "expression.properties" ).getAbsolutePath() );
111 verifier.getCliOptions().add( option );
112 verifier.getCliOptions().add( ( pom ? new File( testDir, "pom.xml" ) : testDir ).getAbsolutePath() );
113 verifier.setForkJvm( true );
114 verifier.executeGoal( "validate" );
115 verifier.verifyErrorFreeLog();
116 verifier.resetStreams();
117
118 Properties props = verifier.loadProperties( "expression.properties" );
119 assertEquals( "ok", props.getProperty( "project.properties.jvm-config" ) );
120 assertEquals( "ok", props.getProperty( "project.properties.maven-config" ) );
121 }
122 }