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/mbuildcache-76")
27  public class Issue76Test {
28  
29      private static final String PROJECT_NAME = "org.apache.maven.caching.test:mbuildcache-76";
30  
31      @Test
32      void simple_build_change_version_build_install_again(Verifier verifier) throws VerificationException {
33          verifier.setAutoclean(false);
34  
35          verifier.setLogFileName("../log-1.txt");
36          verifier.executeGoal("install");
37          verifier.verifyErrorFreeLog();
38          verifier.verifyTextInLog("Saved Build to local file");
39          verifier.verifyArtifactPresent("org.apache.maven.caching.test", "mbuildcache-76", "0.0.1-SNAPSHOT", "jar");
40  
41          verifier.setLogFileName("../log-2.txt");
42          verifier.executeGoal("install");
43          verifier.verifyErrorFreeLog();
44          verifier.verifyTextInLog("Found cached build, restoring " + PROJECT_NAME + " from cache");
45  
46          verifier.setLogFileName("../log-3.txt");
47          verifier.getCliOptions().clear();
48          verifier.addCliOption("-DoldVersion=0.0.1-SNAPSHOT");
49          verifier.addCliOption("-DnewVersion=0.0.2-SNAPSHOT");
50          verifier.executeGoal("versions:set");
51          verifier.verifyErrorFreeLog();
52  
53          verifier.getCliOptions().clear();
54          verifier.setLogFileName("../log-4.txt");
55          verifier.executeGoal("install");
56          verifier.verifyErrorFreeLog();
57          verifier.verifyTextInLog("Saved Build to local file");
58          verifier.verifyArtifactPresent("org.apache.maven.caching.test", "mbuildcache-76", "0.0.2-SNAPSHOT", "jar");
59  
60          verifier.setLogFileName("../log-5.txt");
61          verifier.executeGoal("install");
62          verifier.verifyErrorFreeLog();
63          verifier.verifyTextInLog("Found cached build, restoring " + PROJECT_NAME + " from cache");
64      }
65  }