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.Arrays;
26  
27  public class MavenITmng6562WarnDefaultBindings
28      extends AbstractMavenIntegrationTestCase
29  {
30  
31      public MavenITmng6562WarnDefaultBindings()
32      {
33          super( "[4.0.0-alpha-1,)" );
34      }
35  
36      public void testItShouldNotWarn()
37          throws Exception
38      {
39          File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-6562-default-bindings" );
40  
41          String phase = "validate";
42          Verifier verifier = newVerifier( testDir.getAbsolutePath(), false );
43          verifier.setAutoclean( false );
44          verifier.setLogFileName( phase + ".txt" );
45          verifier.setForkJvm( true ); // required due to --fail-on-severity
46          verifier.addCliOption( "-fos" );
47          verifier.addCliOption( "WARN" ); // ALSO NO WARNINGS
48          verifier.executeGoals( Arrays.asList( phase ) );
49          verifier.resetStreams();
50  
51          verifier.verifyErrorFreeLog();
52      }
53  
54  
55      public void testItShouldNotWarn2()
56                      throws Exception
57      {
58          File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-6562-default-bindings" );
59  
60          String phase = "process-resources";
61          Verifier verifier = newVerifier( testDir.getAbsolutePath(), false );
62          verifier.setAutoclean( false );
63          verifier.setLogFileName( phase + ".txt" );
64          verifier.setForkJvm( true ); // required due to --fail-on-severity
65          verifier.addCliOption( "-fos" );
66          verifier.addCliOption( "WARN" ); // ALSO NO WARNINGS
67          verifier.executeGoals( Arrays.asList( phase ) );
68          verifier.resetStreams();
69  
70          verifier.verifyErrorFreeLog();
71      }
72  
73      public void testItShouldWarnForCompilerPlugin()
74                      throws Exception
75      {
76          File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-6562-default-bindings" );
77  
78          String phase = "compile";
79          Verifier verifier = newVerifier( testDir.getAbsolutePath(), false );
80          verifier.setAutoclean( false );
81          verifier.setLogFileName( phase +".txt" );
82          verifier.executeGoals( Arrays.asList( phase ) );
83          verifier.resetStreams();
84  
85          verifier.verifyTextInLog( "Version not locked for default bindings plugins [maven-compiler-plugin]"
86                  + ", you should define versions in pluginManagement section of your pom.xml or parent" );
87      }
88  
89      public void testItShouldWarnForCompilerPlugin2()
90                      throws Exception
91      {
92          File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-6562-default-bindings" );
93  
94          String phase = "process-test-resources";
95          Verifier verifier = newVerifier( testDir.getAbsolutePath(), false );
96          verifier.setAutoclean( false );
97          verifier.setLogFileName( phase +".txt" );
98          verifier.executeGoals( Arrays.asList( phase ) );
99          verifier.resetStreams();
100         verifier.verifyErrorFreeLog();
101 
102         verifier.verifyTextInLog( "Version not locked for default bindings plugins [maven-compiler-plugin]"
103                 + ", you should define versions in pluginManagement section of your pom.xml or parent" );
104     }
105 
106     public void testItShouldWarnForCompilerPlugin3()
107                     throws Exception
108     {
109         File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-6562-default-bindings" );
110 
111         String phase = "test-compile";
112         Verifier verifier = newVerifier( testDir.getAbsolutePath(), false );
113         verifier.setAutoclean( false );
114         verifier.setLogFileName( phase +".txt" );
115         verifier.executeGoals( Arrays.asList( phase ) );
116         verifier.resetStreams();
117         verifier.verifyErrorFreeLog();
118 
119         verifier.verifyTextInLog( "Version not locked for default bindings plugins [maven-compiler-plugin]"
120                 + ", you should define versions in pluginManagement section of your pom.xml or parent" );
121     }
122 
123     public void testItShouldWarnForCompilerPluginAndSurefirePlugin()
124                     throws Exception
125     {
126         File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-6562-default-bindings" );
127 
128         String phase = "test";
129         Verifier verifier = newVerifier( testDir.getAbsolutePath(), false );
130         verifier.setAutoclean( false );
131         verifier.setLogFileName( phase +".txt" );
132         verifier.executeGoals( Arrays.asList( phase ) );
133         verifier.resetStreams();
134         verifier.verifyErrorFreeLog();
135 
136         verifier.verifyTextInLog( "Version not locked for default bindings plugins [maven-compiler-plugin, maven-surefire-plugin]"
137                 + ", you should define versions in pluginManagement section of your pom.xml or parent" );
138     }
139 
140 }