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