View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.maven.plugin.resources.remote.it;
20  
21  import java.io.File;
22  import java.io.IOException;
23  import java.net.URISyntaxException;
24  
25  import org.apache.maven.plugin.resources.remote.it.support.TestUtils;
26  import org.apache.maven.shared.verifier.VerificationException;
27  import org.apache.maven.shared.verifier.Verifier;
28  import org.codehaus.plexus.util.FileUtils;
29  import org.codehaus.plexus.util.Os;
30  import org.junit.Test;
31  
32  import static org.junit.Assert.assertFalse;
33  import static org.junit.Assert.assertTrue;
34  import static org.junit.Assume.assumeTrue;
35  
36  /**
37   * @author Benjamin Bentmann
38   */
39  public class IT_RunOnlyAtExecutionRoot extends AbstractIT {
40      @Test
41      public void test() throws IOException, URISyntaxException, VerificationException {
42          // Workaround for Windows + Maven-3.5.x/3.6.0 + Jenkins due to MNG-6261
43          assumeTrue(!(System.getenv("JENKINS_HOME") != null
44                  && Os.isFamily(Os.FAMILY_WINDOWS)
45                  && (System.getenv("MAVEN_HOME").contains("-3.5.")
46                          || System.getenv("MAVEN_HOME").contains("-3.6.0"))));
47  
48          File dir = TestUtils.getTestDir("run-only-at-execution-root");
49  
50          Verifier verifier;
51  
52          verifier = TestUtils.newVerifier(new File(dir, "resource-projects"));
53          verifier.addCliArgument("deploy");
54          verifier.execute();
55          verifier.setLogFileName("first.log");
56          verifier.verifyErrorFreeLog();
57  
58          verifier = TestUtils.newVerifier(dir);
59  
60          // I'm not sure what exactly the intention of the test was.
61          // Based on the name i assumed to be sure the remote-resources-plugin
62          // will be executed only at root level.
63          // This will fail, cause if an needed artifact is not there
64          // maven will fail.
65          // Might reconsider how to write a better testcase.
66          // verifier.deleteArtifacts( "org.apache.maven.plugin.rresource.it.mrr41" );
67  
68          // verifier.addCliArgument( "generate-resources" );
69          verifier.addCliArgument("package");
70          verifier.execute();
71          verifier.verifyErrorFreeLog();
72  
73          String depResource = "target/maven-shared-archive-resources/DEPENDENCIES";
74          File output = new File(dir, depResource);
75          assertTrue(output.exists());
76  
77          // aggregates in bulk, not per-child
78          assertFalse(new File(dir, "child1/" + depResource).exists());
79          assertFalse(new File(dir, "child2/" + depResource).exists());
80  
81          String content = FileUtils.fileRead(output);
82  
83          assertTrue(content.contains("Dependency Id: org.apache.maven.plugin.rresource.it.mrr41:release:1.0"));
84          assertTrue(content.contains("Dependency Id: org.apache.maven.plugin.rresource.it.mrr41:snapshot:1.0-SNAPSHOT"));
85      }
86  }