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 java.io.File;
23  
24  import org.apache.maven.it.util.ResourceExtractor;
25  
26  public class MavenITmng5530MojoExecutionScopeTest
27      extends AbstractMavenIntegrationTestCase
28  {
29      public MavenITmng5530MojoExecutionScopeTest()
30      {
31          super( "[3.2.1,)" );
32      }
33  
34      public void test_copyfiles()
35          throws Exception
36      {
37          File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-5530-mojo-execution-scope" );
38          File pluginDir = new File( testDir, "plugin" );
39          File projectDir = new File( testDir, "basic" );
40  
41          Verifier verifier;
42  
43          // install the test plugin
44          verifier = newVerifier( pluginDir.getAbsolutePath(), "remote" );
45          verifier.executeGoal( "install" );
46          verifier.resetStreams();
47          verifier.verifyErrorFreeLog();
48  
49          // build the test project
50          verifier = newVerifier( projectDir.getAbsolutePath(), "remote" );
51          verifier.executeGoal( "package" );
52          verifier.resetStreams();
53          verifier.verifyErrorFreeLog();
54  
55          // verifier.assertFilePresent( "target/execution-failure.txt" );
56          verifier.assertFilePresent( "target/execution-success.txt" );
57          verifier.assertFilePresent( "target/execution-before.txt" );
58      }
59  
60      public void test_copyfiles_multithreaded()
61          throws Exception
62      {
63          File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-5530-mojo-execution-scope" );
64          File pluginDir = new File( testDir, "plugin" );
65          File projectDir = new File( testDir, "basic" );
66  
67          Verifier verifier;
68  
69          // install the test plugin
70          verifier = newVerifier( pluginDir.getAbsolutePath(), "remote" );
71          verifier.executeGoal( "install" );
72          verifier.resetStreams();
73          verifier.verifyErrorFreeLog();
74  
75          // build the test project
76          verifier = newVerifier( projectDir.getAbsolutePath(), "remote" );
77          verifier.getCliOptions().add( "--builder multithreaded -T 1" );
78          verifier.executeGoal( "package" );
79          verifier.resetStreams();
80          verifier.verifyErrorFreeLog();
81  
82          // verifier.assertFilePresent( "target/execution-failure.txt" );
83          verifier.assertFilePresent( "target/execution-success.txt" );
84          verifier.assertFilePresent( "target/execution-before.txt" );
85      }
86  
87      public void testExtension()
88          throws Exception
89      {
90          File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-5530-mojo-execution-scope" );
91          File extensionDir = new File( testDir, "extension" );
92          File pluginDir = new File( testDir, "extension-plugin" );
93          File projectDir = new File( testDir, "extension-project" );
94  
95          Verifier verifier;
96  
97          // install the test extension
98          verifier = newVerifier( extensionDir.getAbsolutePath(), "remote" );
99          verifier.executeGoal( "install" );
100         verifier.resetStreams();
101         verifier.verifyErrorFreeLog();
102 
103         // install the test plugin
104         verifier = newVerifier( pluginDir.getAbsolutePath(), "remote" );
105         verifier.executeGoal( "install" );
106         verifier.resetStreams();
107         verifier.verifyErrorFreeLog();
108 
109         // build the test project
110         verifier = newVerifier( projectDir.getAbsolutePath(), "remote" );
111         verifier.addCliOption( "-Dmaven.ext.class.path=" + new File( extensionDir, "target/classes" ).getAbsolutePath() );
112         verifier.setForkJvm( true ); // verifier does not support custom realms in embedded mode
113         verifier.executeGoal( "package" );
114         verifier.resetStreams();
115         verifier.verifyErrorFreeLog();
116     }
117 
118 }