Skip to content

Commit c5c9a72

Browse files
Wrapped verifier.resetStreams() in finally blocks where absent. Added a few calls to verifier.resetStreams().
1 parent 629e702 commit c5c9a72

File tree

6 files changed

+200
-119
lines changed

6 files changed

+200
-119
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ the artifacts built by the first job into a jboss application server.
374374
## Building with IntelliJ IDEA notes
375375
### To Debug Tests:
376376
Configure the Maven commandline to include
377-
`-DforkMode=never` You will likely get warnings when you run maven with this argument.
377+
`-DforkMode=never` You will likely get warnings when you run maven without this argument.
378378

379379
### To inspect code-coverage results from Integration Tests:
380380
* Select the **Analyze** -> **Show Coverage Data** menu.

src/test/java/com/e_gineering/maven/gitflowhelper/DevelopBranchIT.java

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,13 @@ public void nonSnapshotDeployFails() throws Exception {
3232
public void snapshotDeploySuccess() throws Exception {
3333
Verifier verifier = createVerifier("/project-stub", "origin/develop", "1.0.0-SNAPSHOT");
3434

35-
verifier.executeGoal("deploy");
36-
37-
verifier.verifyErrorFreeLog();
35+
try {
36+
verifier.executeGoal("deploy");
3837

39-
verifier.resetStreams();
38+
verifier.verifyErrorFreeLog();
39+
} finally {
40+
verifier.resetStreams();
41+
}
4042
}
4143

4244
/**
@@ -48,18 +50,24 @@ public void snapshotDeploySuccess() throws Exception {
4850
public void attachExistingArtifacts() throws Exception {
4951
Verifier verifier = createVerifier("/project-stub", "origin/develop", "1.0.0-SNAPSHOT");
5052

51-
verifier.executeGoal("deploy");
52-
53-
verifier.verifyErrorFreeLog();
53+
try {
54+
verifier.executeGoal("deploy");
5455

55-
verifier.resetStreams();
56+
verifier.verifyErrorFreeLog();
57+
} finally {
58+
verifier.resetStreams();
59+
}
5660

5761

5862
// New verifier to attach existing artifacts
5963
verifier = createVerifier("/project-stub", "origin/develop", "1.0.0-SNAPSHOT");
6064

61-
verifier.executeGoal("gitflow-helper:attach-deployed");
65+
try {
66+
verifier.executeGoal("gitflow-helper:attach-deployed");
6267

63-
verifier.verifyErrorFreeLog();
68+
verifier.verifyErrorFreeLog();
69+
} finally {
70+
verifier.resetStreams();
71+
}
6472
}
6573
}

src/test/java/com/e_gineering/maven/gitflowhelper/EnforceVersionsIT.java

Lines changed: 55 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -97,39 +97,53 @@ public void dependencySuccesses() throws Exception {
9797
// Create a release version and get it deployed.
9898
Verifier verifier = createVerifier("/project-stub", "origin/release/1.0.0", "1.0.0");
9999

100-
verifier.executeGoal("deploy");
100+
try {
101+
verifier.executeGoal("deploy");
101102

102-
verifier.verifyErrorFreeLog();
103-
verifier.resetStreams();
103+
verifier.verifyErrorFreeLog();
104+
} finally {
105+
verifier.resetStreams();
106+
}
104107

105108
// Promote (deploy) from /origin/master
106109
verifier = createVerifier("/project-stub", "origin/master", "1.0.0");
107-
verifier.executeGoal("deploy");
110+
try {
111+
verifier.executeGoal("deploy");
108112

109-
verifier.verifyErrorFreeLog();
110-
verifier.resetStreams();
113+
verifier.verifyErrorFreeLog();
114+
} finally {
115+
verifier.resetStreams();
116+
}
111117

112118
// Build a project that depends upon the upstream project.
113119
verifier = createVerifier("/project-alt1-stub", "origin/release/1.0.0", "1.0.0");
114120
verifier.getCliOptions().add("-Ddependency.stub.version=1.0.0");
115121
verifier.getCliOptions().add("-Dplugin.stub.version=1.0.0");
116122

117-
verifier.executeGoal("deploy");
123+
try {
124+
verifier.executeGoal("deploy");
118125

119-
verifier.verifyErrorFreeLog();
120-
verifier.resetStreams();
126+
verifier.verifyErrorFreeLog();
127+
} finally {
128+
verifier.resetStreams();
129+
}
121130

122131
verifier = createVerifier("/project-alt1-stub", "origin/master", "1.0.0");
123-
verifier.getCliOptions().add("-Ddependency.stub.version=1.0.0");
124-
verifier.getCliOptions().add("-Dplugin.stub.version=1.0.0");
132+
try {
133+
verifier.getCliOptions().add("-Ddependency.stub.version=1.0.0");
134+
verifier.getCliOptions().add("-Dplugin.stub.version=1.0.0");
125135

126-
verifier.executeGoal("deploy");
136+
verifier.executeGoal("deploy");
127137

128-
verifier.verifyTextInLog("gitflow-helper-maven-plugin: Enabling MasterPromoteExtension. GIT_BRANCH: [origin/master] matches masterBranchPattern");
129-
verifier.verifyTextInLog("[INFO] Setting release artifact repository to: [releases]");
130-
verifier.verifyTextInLog("[INFO] Resolving & Reattaching existing artifacts from stageDeploymentRepository [test-releases]");
131-
verifier.verifyErrorFreeLog();
132-
verifier.resetStreams();
138+
verifier.verifyTextInLog(
139+
"gitflow-helper-maven-plugin: Enabling MasterPromoteExtension. GIT_BRANCH: [origin/master] matches masterBranchPattern");
140+
verifier.verifyTextInLog("[INFO] Setting release artifact repository to: [releases]");
141+
verifier.verifyTextInLog(
142+
"[INFO] Resolving & Reattaching existing artifacts from stageDeploymentRepository [test-releases]");
143+
verifier.verifyErrorFreeLog();
144+
} finally {
145+
verifier.resetStreams();
146+
}
133147
}
134148

135149
@Test(expected= VerificationException.class)
@@ -138,18 +152,23 @@ public void dependencySnapshotFail() throws Exception {
138152

139153
// Create a release version and get it deployed.
140154
Verifier verifier = createVerifier("/project-stub", "origin/release/1.0.0", "1.0.0");
155+
try {
156+
verifier.executeGoal("deploy");
141157

142-
verifier.executeGoal("deploy");
143-
144-
verifier.verifyErrorFreeLog();
145-
verifier.resetStreams();
158+
verifier.verifyErrorFreeLog();
159+
} finally {
160+
verifier.resetStreams();
161+
}
146162

147163
// Promote (deploy) from /origin/master
148164
verifier = createVerifier("/project-stub", "origin/master", "1.0.0");
149-
verifier.executeGoal("deploy");
165+
try {
166+
verifier.executeGoal("deploy");
150167

151-
verifier.verifyErrorFreeLog();
152-
verifier.resetStreams();
168+
verifier.verifyErrorFreeLog();
169+
} finally {
170+
verifier.resetStreams();
171+
}
153172

154173
// Build a project that depends upon the upstream project.
155174
verifier = createVerifier("/project-alt1-stub", "origin/release/1.0.0", "1.0.0");
@@ -169,18 +188,23 @@ public void pluginSnapshotFail() throws Exception {
169188

170189
// Create a release version and get it deployed.
171190
Verifier verifier = createVerifier("/project-stub", "origin/release/1.0.0", "1.0.0");
191+
try {
192+
verifier.executeGoal("deploy");
172193

173-
verifier.executeGoal("deploy");
174-
175-
verifier.verifyErrorFreeLog();
176-
verifier.resetStreams();
194+
verifier.verifyErrorFreeLog();
195+
} finally {
196+
verifier.resetStreams();
197+
}
177198

178199
// Promote (deploy) from /origin/master
179200
verifier = createVerifier("/project-stub", "origin/master", "1.0.0");
180-
verifier.executeGoal("deploy");
201+
try {
202+
verifier.executeGoal("deploy");
181203

182-
verifier.verifyErrorFreeLog();
183-
verifier.resetStreams();
204+
verifier.verifyErrorFreeLog();
205+
} finally {
206+
verifier.resetStreams();
207+
}
184208

185209
// Build a project that depends upon the upstream project.
186210
verifier = createVerifier("/project-alt1-stub", "origin/release/1.0.0", "1.0.0");

src/test/java/com/e_gineering/maven/gitflowhelper/MasterSupportBranchIT.java

Lines changed: 63 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@ public class MasterSupportBranchIT extends AbstractIntegrationTest {
1616
public void releaseVersionSuccess() throws Exception {
1717
Verifier verifier = createVerifier("/project-stub", "origin/master", "1.0.0");
1818

19-
verifier.executeGoal("gitflow-helper:enforce-versions");
20-
21-
verifier.verifyErrorFreeLog();
22-
verifier.verifyTextInLog("GitBranchInfo:");
19+
try {
20+
verifier.executeGoal("gitflow-helper:enforce-versions");
2321

24-
verifier.resetStreams();
22+
verifier.verifyErrorFreeLog();
23+
verifier.verifyTextInLog("GitBranchInfo:");
24+
} finally {
25+
verifier.resetStreams();
26+
}
2527
}
2628

2729
@Test(expected = VerificationException.class)
@@ -31,10 +33,12 @@ public void snapshotVersionFailure() throws Exception {
3133
try {
3234
verifier.executeGoal("gitflow-helper:enforce-versions");
3335
} finally {
34-
verifier.verifyTextInLog("GitBranchInfo:");
35-
verifier.verifyTextInLog("The maven project or one of its parents is currently a snapshot version.");
36-
37-
verifier.resetStreams();
36+
try {
37+
verifier.verifyTextInLog("GitBranchInfo:");
38+
verifier.verifyTextInLog("The maven project or one of its parents is currently a snapshot version.");
39+
} finally {
40+
verifier.resetStreams();
41+
}
3842
}
3943
}
4044

@@ -43,62 +47,78 @@ public void promotionOfRelease() throws Exception {
4347
// Create a release version and get it deployed.
4448
Verifier verifier = createVerifier("/project-stub", "origin/release/1.0.0", "1.0.0");
4549

46-
verifier.executeGoal("deploy");
50+
try {
51+
verifier.executeGoal("deploy");
4752

48-
verifier.verifyErrorFreeLog();
49-
verifier.resetStreams();
53+
verifier.verifyErrorFreeLog();
54+
} finally {
55+
verifier.resetStreams();
56+
}
5057

5158
// Promote (deploy) from /origin/master
5259
verifier = createVerifier("/project-stub", "origin/master", "1.0.0");
5360

54-
verifier.executeGoal("deploy");
55-
5661
try {
57-
verifier.verifyTextInLog("Compiling");
58-
throw new VerificationException(PROMOTION_FAILED_MESSAGE);
59-
} catch (VerificationException ve) {
60-
if (ve.getMessage().equals(PROMOTION_FAILED_MESSAGE)) {
61-
throw ve;
62+
verifier.executeGoal("deploy");
63+
64+
try {
65+
verifier.verifyTextInLog("Compiling");
66+
throw new VerificationException(PROMOTION_FAILED_MESSAGE);
67+
} catch (VerificationException ve) {
68+
if (ve.getMessage().equals(PROMOTION_FAILED_MESSAGE)) {
69+
throw ve;
70+
}
71+
// Otherwise, it's the VerificationException from looking for "Compiling", and that's expected to fail.
6272
}
63-
// Otherwise, it's the VerificationException from looking for "Compiling", and that's expected to fail.
64-
}
6573

66-
verifier.verifyTextInLog("gitflow-helper-maven-plugin: Enabling MasterPromoteExtension. GIT_BRANCH: [origin/master] matches masterBranchPattern");
67-
verifier.verifyTextInLog("[INFO] Setting release artifact repository to: [releases]");
68-
verifier.verifyTextInLog("[INFO] Resolving & Reattaching existing artifacts from stageDeploymentRepository [test-releases");
69-
verifier.verifyErrorFreeLog();
70-
verifier.resetStreams();
74+
verifier.verifyTextInLog(
75+
"gitflow-helper-maven-plugin: Enabling MasterPromoteExtension. GIT_BRANCH: [origin/master] matches masterBranchPattern");
76+
verifier.verifyTextInLog("[INFO] Setting release artifact repository to: [releases]");
77+
verifier.verifyTextInLog(
78+
"[INFO] Resolving & Reattaching existing artifacts from stageDeploymentRepository [test-releases");
79+
verifier.verifyErrorFreeLog();
80+
} finally {
81+
verifier.resetStreams();
82+
}
7183
}
7284

7385
@Test
7486
public void dontPruneExplicitlyInvokedPlugins() throws Exception {
7587
// Create a release version and get it deployed.
7688
Verifier verifier = createVerifier("/project-stub", "origin/release/1.1.0", "1.1.0");
7789

78-
verifier.executeGoal("deploy");
90+
try {
91+
verifier.executeGoal("deploy");
7992

80-
verifier.verifyErrorFreeLog();
81-
verifier.resetStreams();
93+
verifier.verifyErrorFreeLog();
94+
} finally {
95+
verifier.resetStreams();
96+
}
8297

8398
// Promote (deploy) from /origin/master
8499
verifier = createVerifier("/project-stub", "origin/master", "1.1.0");
85100

86-
verifier.executeGoals(Arrays.asList("jar:jar", "deploy"));
87101
try {
88-
verifier.verifyTextInLog("Compiling");
89-
throw new VerificationException(PROMOTION_FAILED_MESSAGE);
90-
} catch (VerificationException ve) {
91-
if (ve.getMessage().equals(PROMOTION_FAILED_MESSAGE)) {
92-
throw ve;
102+
verifier.executeGoals(Arrays.asList("jar:jar", "deploy"));
103+
try {
104+
verifier.verifyTextInLog("Compiling");
105+
throw new VerificationException(PROMOTION_FAILED_MESSAGE);
106+
} catch (VerificationException ve) {
107+
if (ve.getMessage().equals(PROMOTION_FAILED_MESSAGE)) {
108+
throw ve;
109+
}
110+
// Otherwise, it's the VerificationException from looking for "Compiling", and that's expected to fail.
93111
}
94-
// Otherwise, it's the VerificationException from looking for "Compiling", and that's expected to fail.
95-
}
96112

97-
verifier.verifyTextInLog("Building jar:"); // This should still be there.
98-
verifier.verifyTextInLog("gitflow-helper-maven-plugin: Enabling MasterPromoteExtension. GIT_BRANCH: [origin/master] matches masterBranchPattern");
99-
verifier.verifyTextInLog("[INFO] Setting release artifact repository to: [releases]");
100-
verifier.verifyTextInLog("[INFO] Resolving & Reattaching existing artifacts from stageDeploymentRepository [test-releases");
101-
verifier.verifyErrorFreeLog();
102-
verifier.resetStreams();
113+
verifier.verifyTextInLog("Building jar:"); // This should still be there.
114+
verifier.verifyTextInLog(
115+
"gitflow-helper-maven-plugin: Enabling MasterPromoteExtension. GIT_BRANCH: [origin/master] matches masterBranchPattern");
116+
verifier.verifyTextInLog("[INFO] Setting release artifact repository to: [releases]");
117+
verifier.verifyTextInLog(
118+
"[INFO] Resolving & Reattaching existing artifacts from stageDeploymentRepository [test-releases");
119+
verifier.verifyErrorFreeLog();
120+
} finally {
121+
verifier.resetStreams();
122+
}
103123
}
104124
}

src/test/java/com/e_gineering/maven/gitflowhelper/ReleaseBranchIT.java

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,13 @@ public void snapshotDeployFails() throws Exception {
3636
public void deploySuccess() throws Exception {
3737
Verifier verifier = createVerifier("/project-stub", "origin/release/1.0.0", "1.0.0");
3838

39-
verifier.executeGoal("deploy");
40-
41-
verifier.verifyErrorFreeLog();
39+
try {
40+
verifier.executeGoal("deploy");
4241

43-
verifier.resetStreams();
42+
verifier.verifyErrorFreeLog();
43+
} finally {
44+
verifier.resetStreams();
45+
}
4446
}
4547

4648
/**
@@ -52,19 +54,25 @@ public void deploySuccess() throws Exception {
5254
public void attachExistingArtifacts() throws Exception {
5355
Verifier verifier = createVerifier("/project-stub", "origin/release/1.0.0", "1.0.0");
5456

55-
verifier.executeGoal("deploy");
56-
57-
verifier.verifyErrorFreeLog();
57+
try {
58+
verifier.executeGoal("deploy");
5859

59-
verifier.resetStreams();
60+
verifier.verifyErrorFreeLog();
61+
} finally {
62+
verifier.resetStreams();
63+
}
6064

6165
// Now re-attach in another verifier.
6266
verifier = createVerifier("/project-stub", "origin/release/1.0.0", "1.0.0");
6367

64-
// Allow -SNAPSHOT builds of the plugin to succeed while still asserting the version match.
65-
verifier.getCliOptions().add("-DenforceNonSnapshots=false");
66-
verifier.executeGoal("gitflow-helper:attach-deployed");
68+
try {
69+
// Allow -SNAPSHOT builds of the plugin to succeed while still asserting the version match.
70+
verifier.getCliOptions().add("-DenforceNonSnapshots=false");
71+
verifier.executeGoal("gitflow-helper:attach-deployed");
6772

68-
verifier.verifyErrorFreeLog();
73+
verifier.verifyErrorFreeLog();
74+
} finally {
75+
verifier.resetStreams();
76+
}
6977
}
7078
}

0 commit comments

Comments
 (0)