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   * This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-3831">MNG-3831</a>.
29   *
30   * @author Benjamin Bentmann
31   *
32   */
33  public class MavenITmng3831PomInterpolationTest
34      extends AbstractMavenIntegrationTestCase
35  {
36  
37      public MavenITmng3831PomInterpolationTest()
38      {
39          super( "(,2.0.2),(2.0.2,)" );
40      }
41  
42      /**
43       * Test that expressions of the form ${*} resolve correctly to POM values (ugly but real).
44       *
45       * @throws Exception in case of failure
46       */
47      public void testitMNG3831()
48          throws Exception
49      {
50          File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3831" );
51          File child = new File( testDir, "child" );
52  
53          Verifier verifier = newVerifier( child.getAbsolutePath() );
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.mng3831.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          assertEquals( "http://dist.org/", props.getProperty( prefix + "projectDistRepoUrl" ) );
80          assertEquals( "http://site.org/", props.getProperty( prefix + "projectDistSiteUrl" ) );
81  
82          assertEquals( "org.apache.maven.its.mng3831", props.getProperty( prefix + "parentGroupId" ) );
83          assertEquals( "parent", props.getProperty( prefix + "parentArtifactId" ) );
84          assertEquals( "1.0", props.getProperty( prefix + "parentVersion" ) );
85  
86          /*
87           * NOTE: We intentionally do not check whether the build paths have been basedir aligned, that's another
88           * story...
89           */
90          if ( matchesVersionRange( "(2.0.8,)" ) )
91          {
92              assertTrue( props.getProperty( prefix + "projectBuildOut" ).endsWith( "bin" ) );
93          }
94          assertTrue( props.getProperty( prefix + "projectSiteOut" ).endsWith( "doc" ) );
95      }
96  
97  }