1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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 }