1 package org.apache.maven.cli;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.util.Properties;
23
24 import junit.framework.TestCase;
25
26
27
28
29
30
31
32 public class MavenCliTest
33 extends TestCase
34 {
35
36 public void testGetExecutionProperties()
37 throws Exception
38 {
39 System.setProperty( "test.property.1", "1.0" );
40 System.setProperty( "test.property.2", "2.0" );
41 Properties execProperties = new Properties();
42 Properties userProperties = new Properties();
43
44 MavenCli.populateProperties( ( new CLIManager() ).parse( new String[] {
45 "-Dtest.property.2=2.1",
46 "-Dtest.property.3=3.0" } ), execProperties, userProperties );
47
48 System.out.println( "Execution properties:\n\n" );
49 execProperties.list( System.out );
50
51 System.out.println( "\n\nUser properties:\n\n" );
52 userProperties.list( System.out );
53
54
55 String envPath = execProperties.getProperty( "env.PATH" );
56 String envPath2 = userProperties.getProperty( "env.PATH" );
57 if ( envPath == null )
58 {
59 envPath = execProperties.getProperty( "env.Path" );
60 envPath2 = userProperties.getProperty( "env.Path" );
61 }
62
63 assertNotNull( envPath );
64 assertNull( envPath2 );
65
66 assertEquals( "1.0", execProperties.getProperty( "test.property.1" ) );
67 assertNull( userProperties.getProperty( "test.property.1" ) );
68
69 assertEquals( "3.0", execProperties.getProperty( "test.property.3" ) );
70 assertEquals( "3.0", userProperties.getProperty( "test.property.3" ) );
71
72
73
74 }
75
76 public void testGetBuildProperties()
77 throws Exception
78 {
79 Properties properties = MavenCli.getBuildProperties();
80
81 assertNotNull( properties.getProperty( "version" ) );
82 assertNotNull( properties.getProperty( "buildNumber" ) );
83 assertNotNull( properties.getProperty( "timestamp" ) );
84 assertFalse( properties.getProperty( "version" ).equals( "${project.version}" ) );
85 assertFalse( properties.getProperty( "buildNumber" ).equals( "${buildNumber}" ) );
86 assertFalse( properties.getProperty( "timestamp" ).equals( "${timestamp}" ) );
87 }
88 }