|
| 1 | +package com.e_gineering.maven.gitflowhelper; |
| 2 | + |
| 3 | +import org.apache.maven.it.Verifier; |
| 4 | +import org.junit.Assert; |
| 5 | +import org.junit.Test; |
| 6 | +import org.junit.runner.RunWith; |
| 7 | +import org.junit.runners.BlockJUnit4ClassRunner; |
| 8 | + |
| 9 | +import java.io.File; |
| 10 | + |
| 11 | +@RunWith(BlockJUnit4ClassRunner.class) |
| 12 | +public class RetargetDeployIT extends AbstractIntegrationTest { |
| 13 | + |
| 14 | + @Test |
| 15 | + public void devTargetsSnapshot() throws Exception { |
| 16 | + Verifier verifier = createVerifier("/project-stub", "origin/develop", "3.0.0-SNAPSHOT"); |
| 17 | + |
| 18 | + verifier.executeGoal("deploy"); |
| 19 | + |
| 20 | + verifier.verifyErrorFreeLog(); |
| 21 | + verifier.resetStreams(); |
| 22 | + |
| 23 | + // Ensure the file exists in the repo. |
| 24 | + File artifactDir = new File(System.getProperty("basedir"), "target/it-repositories/snapshots/com/e-gineering/gitflow-helper-maven-plugin-test-stub/3.0.0-SNAPSHOT"); |
| 25 | + Assert.assertTrue(artifactDir.exists() && artifactDir.isDirectory() && artifactDir.list().length > 0); |
| 26 | + } |
| 27 | + |
| 28 | + @Test |
| 29 | + public void releaseTargetsTest() throws Exception { |
| 30 | + Verifier verifier = createVerifier("/project-stub", "origin/release/3.1.0", "3.1.0"); |
| 31 | + |
| 32 | + verifier.executeGoal("deploy"); |
| 33 | + |
| 34 | + verifier.verifyErrorFreeLog(); |
| 35 | + verifier.resetStreams(); |
| 36 | + |
| 37 | + // Ensure the file exists in the repo. |
| 38 | + File artifactDir = new File(System.getProperty("basedir"), "target/it-repositories/test-releases/com/e-gineering/gitflow-helper-maven-plugin-test-stub/3.1.0"); |
| 39 | + Assert.assertTrue(artifactDir.exists() && artifactDir.isDirectory() && artifactDir.list().length > 0); |
| 40 | + } |
| 41 | + |
| 42 | + @Test |
| 43 | + public void hotfixTargetsTest() throws Exception { |
| 44 | + Verifier verifier = createVerifier("/project-stub", "origin/hotfix/3.1.5", "3.1.5"); |
| 45 | + |
| 46 | + verifier.executeGoal("deploy"); |
| 47 | + |
| 48 | + verifier.verifyErrorFreeLog(); |
| 49 | + verifier.resetStreams(); |
| 50 | + |
| 51 | + // Ensure the file exists in the repo. |
| 52 | + File artifactDir = new File(System.getProperty("basedir"), "target/it-repositories/test-releases/com/e-gineering/gitflow-helper-maven-plugin-test-stub/3.1.5"); |
| 53 | + Assert.assertTrue(artifactDir.exists() && artifactDir.isDirectory() && artifactDir.list().length > 0); |
| 54 | + } |
| 55 | + |
| 56 | + @Test |
| 57 | + public void supportTargetsReleases() throws Exception { |
| 58 | + // Deploy a hotfix to the test-releases. |
| 59 | + Verifier verifier = createVerifier("/project-stub", "origin/hotfix/3.2.1", "3.2.1"); |
| 60 | + verifier.executeGoal("deploy"); |
| 61 | + verifier.verifyErrorFreeLog(); |
| 62 | + verifier.resetStreams(); |
| 63 | + |
| 64 | + File artifactDir = new File(System.getProperty("basedir"), "target/it-repositories/test-releases/com/e-gineering/gitflow-helper-maven-plugin-test-stub/3.2.1"); |
| 65 | + Assert.assertTrue(artifactDir.exists() && artifactDir.isDirectory() && artifactDir.list().length > 0); |
| 66 | + |
| 67 | + // Promote with the support branch |
| 68 | + verifier = createVerifier("/project-stub", "origin/support/3.2", "3.2.1"); |
| 69 | + verifier.executeGoal("deploy"); |
| 70 | + |
| 71 | + verifier.verifyErrorFreeLog(); |
| 72 | + verifier.resetStreams(); |
| 73 | + |
| 74 | + // Ensure the file exists in the repo. |
| 75 | + artifactDir = new File(System.getProperty("basedir"), "target/it-repositories/releases/com/e-gineering/gitflow-helper-maven-plugin-test-stub/3.2.1"); |
| 76 | + Assert.assertTrue(artifactDir.exists() && artifactDir.isDirectory() && artifactDir.list().length > 0); |
| 77 | + } |
| 78 | + |
| 79 | + @Test |
| 80 | + public void masterTargetsReleases() throws Exception { |
| 81 | + // Deploy a hotfix to the test-releases. |
| 82 | + Verifier verifier = createVerifier("/project-stub", "origin/release/3.3.0", "3.3.0"); |
| 83 | + verifier.executeGoal("deploy"); |
| 84 | + verifier.verifyErrorFreeLog(); |
| 85 | + verifier.resetStreams(); |
| 86 | + |
| 87 | + File artifactDir = new File(System.getProperty("basedir"), "target/it-repositories/test-releases/com/e-gineering/gitflow-helper-maven-plugin-test-stub/3.3.0"); |
| 88 | + Assert.assertTrue(artifactDir.exists() && artifactDir.isDirectory() && artifactDir.list().length > 0); |
| 89 | + |
| 90 | + // Promote with the support branch |
| 91 | + verifier = createVerifier("/project-stub", "origin/master", "3.3.0"); |
| 92 | + verifier.executeGoal("deploy"); |
| 93 | + |
| 94 | + verifier.verifyErrorFreeLog(); |
| 95 | + verifier.resetStreams(); |
| 96 | + |
| 97 | + // Ensure the file exists in the repo. |
| 98 | + artifactDir = new File(System.getProperty("basedir"), "target/it-repositories/releases/com/e-gineering/gitflow-helper-maven-plugin-test-stub/3.3.0"); |
| 99 | + Assert.assertTrue(artifactDir.exists() && artifactDir.isDirectory() && artifactDir.list().length > 0); |
| 100 | + } |
| 101 | + |
| 102 | + @Test |
| 103 | + public void othersUnsetRepos() throws Exception { |
| 104 | + // Deploy a hotfix to the test-releases. |
| 105 | + Verifier verifier = createVerifier("/project-stub", "feature/undeployable", "3.5.0-SNAPSHOT"); |
| 106 | + try { |
| 107 | + verifier.executeGoal("deploy"); |
| 108 | + verifier.verifyTextInLog("[INFO] Skipping artifact deployment"); |
| 109 | + } finally { |
| 110 | + verifier.resetStreams(); |
| 111 | + } |
| 112 | + } |
| 113 | +} |
0 commit comments