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  import org.apache.maven.shared.utils.io.FileUtils;
24  
25  import java.io.File;
26  
27  public class MavenITmng5387ArtifactReplacementPlugin
28      extends AbstractMavenIntegrationTestCase
29  {
30  
31      private File testDir;
32  
33      public MavenITmng5387ArtifactReplacementPlugin()
34      {
35          super( "[3.1,)" );
36      }
37  
38      public void setUp()
39          throws Exception
40      {
41          super.setUp();
42  
43          testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-5387" );
44  
45      }
46  
47      protected void tearDown()
48          throws Exception
49      {
50  
51          super.tearDown();
52      }
53  
54      public void testArtifactReplacementExecution()
55          throws Exception
56      {
57          Verifier v0 = newVerifier( testDir.getAbsolutePath(), "remote" );
58          v0.setAutoclean( false );
59          v0.deleteDirectory( "target" );
60          v0.deleteArtifacts( "org.apache.maven.its.mng5387" );
61          v0.executeGoal( "install" );
62          v0.verifyErrorFreeLog();
63          v0.resetStreams();
64  
65          String path = v0.getArtifactPath( "org.apache.maven.its.mng5387", "mng5387-it", "0.0.1-SNAPSHOT", "txt", "c" );
66          String contents = FileUtils.fileRead( new File( path ), "utf-8" );
67          assertTrue( contents.contains( "This is the second file" ) );
68      }
69  }