View Javadoc

1   package org.apache.maven.it;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import org.apache.maven.it.Verifier;
23  import org.apache.maven.it.util.ResourceExtractor;
24  import org.apache.maven.it.util.Os;
25  
26  import java.io.File;
27  import java.util.HashMap;
28  import java.util.Map;
29  import java.util.Properties;
30  
31  /**
32   * This is a test set for <a href="http://jira.codehaus.org/browse/MNG-3940">MNG-3940</a>.
33   * 
34   * @author Benjamin Bentmann
35   * @version $Id: MavenITmng3940EnvVarInterpolationTest.java 981712 2010-08-03 00:36:19Z bentmann $
36   */
37  public class MavenITmng3940EnvVarInterpolationTest
38      extends AbstractMavenIntegrationTestCase
39  {
40  
41      public MavenITmng3940EnvVarInterpolationTest()
42      {
43          super( "(2.0.10,2.1.0-M1),(2.1.0-M1,)" );
44      }
45  
46      /**
47       * Test that interpolation of environment variables respects the casing rules of the underlying OS (especially
48       * Windows).
49       */
50      public void testitMNG3940()
51          throws Exception
52      {
53          File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3940" );
54  
55          Map envVars = new HashMap();
56          /*
57           * NOTE: The POM is using MAVEN_MNG_3940 to reference the var (just as one would refer to PATH). On Windows,
58           * this must resolve case-insensitively so we use different character casing for the variable here.
59           */
60          if ( Os.isFamily( Os.FAMILY_WINDOWS ) )
61          {
62              envVars.put( "Maven_mng_3940", "PASSED" );
63          }
64          else
65          {
66              envVars.put( "MAVEN_MNG_3940", "PASSED" );
67          }
68          
69          Verifier verifier = newVerifier( testDir.getAbsolutePath() );
70          verifier.setAutoclean( false );
71          verifier.deleteDirectory( "target" );
72          verifier.executeGoal( "validate", envVars );
73          verifier.verifyErrorFreeLog();
74          verifier.resetStreams();
75  
76          verifier.assertFilePresent( "target/PASSED.properties" );
77          Properties props = verifier.loadProperties( "target/PASSED.properties" );
78          assertEquals( "PASSED", props.getProperty( "project.properties.envTest" ) );
79      }
80  
81  }