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  
26  /**
27   * This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-3530">MNG-3530</a>.
28   *
29   * Contains various tests for dynamism of interpolation expressions within the POM.
30   *
31   * @author <a href="mailto:brianf@apache.org">Brian Fox</a>
32   * @author jdcasey
33   *
34   */
35  public class MavenITmng3530DynamicPOMInterpolationTest
36      extends AbstractMavenIntegrationTestCase
37  {
38      private static final String BASEDIR = "/mng-3530/";
39  
40      public MavenITmng3530DynamicPOMInterpolationTest()
41      {   //Dynamic properties for forked lifecycles not supported in 3.0
42          super( "[2.1.0-M1,3.0-alpha-1)" );
43      }
44  
45      public void testitMNG3530_BuildPath()
46          throws Exception
47      {
48          File testDir = ResourceExtractor.simpleExtractResources( getClass(), BASEDIR + "build-path" );
49          File pluginDir = new File( testDir, "plugin" );
50          File projectDir = new File( testDir, "project" );
51  
52          // First, install the plugin that modifies the project.build.directory and
53          // validates that the modification propagated into the validation-mojo
54          // configuration. Once this is installed, we can run a project build that
55          // uses it to see how Maven will respond to a modification in the project build directory.
56          Verifier verifier = newVerifier( pluginDir.getAbsolutePath(), "remote" );
57          verifier.executeGoal( "install" );
58  
59          verifier.verifyErrorFreeLog();
60          verifier.resetStreams();
61  
62          // Now, build the project. If the plugin configuration doesn't recognize
63          // the update to the project.build.directory, it will fail the build.
64          verifier = newVerifier( projectDir.getAbsolutePath(), "remote" );
65  
66          verifier.executeGoal( "package" );
67          verifier.verifyErrorFreeLog();
68          verifier.resetStreams();
69      }
70  
71      public void testitMNG3530_POMProperty()
72          throws Exception
73      {
74          File testDir = ResourceExtractor.simpleExtractResources( getClass(), BASEDIR
75                                                                               + "pom-property" );
76          File pluginDir = new File( testDir, "plugin" );
77          File projectDir = new File( testDir, "project" );
78  
79          // First, install the plugin that modifies the myDirectory and
80          // validates that the modification propagated into the validation-mojo
81          // configuration. Once this is installed, we can run a project build that
82          // uses it to see how Maven will respond to a modification in the POM property.
83          Verifier verifier = newVerifier( pluginDir.getAbsolutePath(), "remote" );
84          verifier.executeGoal( "install" );
85  
86          verifier.verifyErrorFreeLog();
87          verifier.resetStreams();
88  
89          // Now, build the project. If the plugin configuration doesn't recognize
90          // the update to the myDirectory, it will fail the build.
91          verifier = newVerifier( projectDir.getAbsolutePath(), "remote" );
92  
93          verifier.executeGoal( "package" );
94          verifier.verifyErrorFreeLog();
95          verifier.resetStreams();
96      }
97  
98      public void testitMNG3530_ResourceDirectoryInterpolation()
99          throws Exception
100     {
101         File testDir = ResourceExtractor.simpleExtractResources( getClass(), BASEDIR
102                                                                              + "resource-object" );
103         File pluginDir = new File( testDir, "plugin" );
104         File projectDir = new File( testDir, "project" );
105 
106         // First, install the plugin which validates that all resource directory
107         // specifications have been interpolated.
108         Verifier verifier = newVerifier( pluginDir.getAbsolutePath(), "remote" );
109         verifier.executeGoal( "install" );
110 
111         verifier.verifyErrorFreeLog();
112         verifier.resetStreams();
113 
114         // Now, build the project. If the plugin finds an uninterpolated resource
115         // directory, it will fail the build.
116         verifier = newVerifier( projectDir.getAbsolutePath(), "remote" );
117 
118         verifier.executeGoal( "package" );
119         verifier.verifyErrorFreeLog();
120         verifier.resetStreams();
121     }
122 }