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