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.buildcache.its;
20  
21  import org.apache.maven.buildcache.its.junit.IntegrationTest;
22  import org.apache.maven.it.VerificationException;
23  import org.apache.maven.it.Verifier;
24  import org.junit.jupiter.api.Test;
25  
26  @IntegrationTest("src/test/projects/core-extension")
27  public class CoreExtensionTest {
28  
29      private static final String PROJECT_NAME = "org.apache.maven.caching.test.simple:simple";
30  
31      @Test
32      void simple(Verifier verifier) throws VerificationException {
33          verifier.setAutoclean(false);
34  
35          verifier.setLogFileName("../log-1.txt");
36          verifier.executeGoal("verify");
37          verifier.verifyErrorFreeLog();
38  
39          verifier.setLogFileName("../log-2.txt");
40          verifier.executeGoal("verify");
41          verifier.verifyErrorFreeLog();
42          verifier.verifyTextInLog("Found cached build, restoring " + PROJECT_NAME + " from cache");
43      }
44  
45      @Test
46      void simple_build_change_version_reuse_build_cache(Verifier verifier) throws VerificationException {
47          verifier.setAutoclean(false);
48  
49          verifier.setLogFileName("../log-1.txt");
50          verifier.executeGoal("install");
51          verifier.verifyErrorFreeLog();
52          verifier.verifyTextInLog("Saved Build to local file");
53          verifier.verifyArtifactPresent("org.apache.maven.caching.test.simple", "simple", "0.0.1-SNAPSHOT", "jar");
54  
55          verifier.setLogFileName("../log-2.txt");
56          verifier.executeGoal("install");
57          verifier.verifyErrorFreeLog();
58          verifier.verifyArtifactPresent("org.apache.maven.caching.test.simple", "simple", "0.0.1-SNAPSHOT", "jar");
59          verifier.verifyTextInLog("Found cached build, restoring " + PROJECT_NAME + " from cache");
60  
61          verifier.setLogFileName("../log-3.txt");
62          verifier.getCliOptions().clear();
63          verifier.addCliOption("-DoldVersion=0.0.1-SNAPSHOT");
64          verifier.addCliOption("-DnewVersion=0.0.2-SNAPSHOT");
65          verifier.executeGoal("versions:set");
66          verifier.verifyErrorFreeLog();
67  
68          verifier.getCliOptions().clear();
69          verifier.addCliOption("-Dmaven.build.cache.alwaysRunPlugins=maven-install-plugin:install");
70          verifier.setLogFileName("../log-4.txt");
71          verifier.executeGoal("install");
72          verifier.verifyErrorFreeLog();
73          verifier.verifyArtifactPresent("org.apache.maven.caching.test.simple", "simple", "0.0.2-SNAPSHOT", "jar");
74          verifier.verifyTextInLog("Found cached build, restoring " + PROJECT_NAME + " from cache");
75      }
76  }