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  
25  import java.io.File;
26  import java.util.Properties;
27  
28  /**
29   * 
30   * @author Benjamin Bentmann
31   * @version $Id: MavenIT0139InterpolationWithProjectPrefixTest.java 981712 2010-08-03 00:36:19Z bentmann $
32   */
33  public class MavenIT0139InterpolationWithProjectPrefixTest
34      extends AbstractMavenIntegrationTestCase
35  {
36      public MavenIT0139InterpolationWithProjectPrefixTest()
37      {
38          super( ALL_MAVEN_VERSIONS );
39      }
40  
41      /**
42       * Test that expressions of the form ${project.*} resolve correctly to POM values.
43       */
44      public void testit0139()
45          throws Exception
46      {
47          File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/it0139" );
48          File child = new File( testDir, "child" );
49  
50          Verifier verifier = newVerifier( child.getAbsolutePath() );
51          verifier.setAutoclean( false );
52          verifier.deleteDirectory( "target" );
53          verifier.executeGoal( "initialize" );
54          verifier.verifyErrorFreeLog();
55          verifier.resetStreams();
56          
57          Properties props = verifier.loadProperties( "target/interpolated.properties" );
58          String prefix = "project.properties.";
59  
60          assertEquals( child.getCanonicalFile(), new File( props.getProperty( prefix + "projectDir" ) ).getCanonicalFile() );
61  
62          assertEquals( "org.apache.maven.its.it0139.child", props.getProperty( prefix + "projectGroupId" ) );
63          assertEquals( "child", props.getProperty( prefix + "projectArtifactId" ) );
64          assertEquals( "2.0-alpha-1", props.getProperty( prefix + "projectVersion" ) );
65          assertEquals( "jar", props.getProperty( prefix + "projectPackaging" ) );
66  
67          assertEquals( "child-name", props.getProperty( prefix + "projectName" ) );
68          assertEquals( "child-desc", props.getProperty( prefix + "projectDesc" ) );
69          assertEquals( "http://child.org/", props.getProperty( prefix + "projectUrl" ) );
70          assertEquals( "2008", props.getProperty( prefix + "projectYear" ) );
71          assertEquals( "child-org-name", props.getProperty( prefix + "projectOrgName" ) );
72  
73          assertEquals( "2.0.0", props.getProperty( prefix + "projectPrereqMvn" ) );
74          assertEquals( "http://scm.org/", props.getProperty( prefix + "projectScmUrl" ) );
75          assertEquals( "http://issue.org/", props.getProperty( prefix + "projectIssueUrl" ) );
76          assertEquals( "http://ci.org/", props.getProperty( prefix + "projectCiUrl" ) );
77          assertEquals( "child-dist-repo", props.getProperty( prefix + "projectDistRepoName" ) );
78  
79          assertEquals( "org.apache.maven.its.it0139", props.getProperty( prefix + "parentGroupId" ) );
80          assertEquals( "parent", props.getProperty( prefix + "parentArtifactId" ) );
81          assertEquals( "1.0", props.getProperty( prefix + "parentVersion" ) );
82  
83          /*
84           * NOTE: We intentionally do not check whether the build paths have been basedir aligned, that's another
85           * story...
86           */
87          if ( matchesVersionRange( "(2.0.8,)" ) )
88          {
89              assertTrue( props.getProperty( prefix + "projectBuildOut" ).endsWith( "bin" ) );
90          }
91          assertTrue( props.getProperty( prefix + "projectSiteOut" ).endsWith( "doc" ) );
92      }
93  
94  }