Skip to content

Commit 555055f

Browse files
committed
Remove System.out.println in tests
1 parent f25db72 commit 555055f

File tree

3 files changed

+11
-22
lines changed

3 files changed

+11
-22
lines changed

src/test/java/hudson/plugins/git/AbstractGitTestCase.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,6 @@ protected FreeStyleProject setupSimpleProject(String branchString) throws Except
247247

248248
protected FreeStyleBuild build(final FreeStyleProject project, final Result expectedResult, final String...expectedNewlyCommittedFiles) throws Exception {
249249
final FreeStyleBuild build = project.scheduleBuild2(0).get();
250-
System.out.println(build.getLog());
251250
for(final String expectedNewlyCommittedFile : expectedNewlyCommittedFiles) {
252251
assertTrue(expectedNewlyCommittedFile + " file not found in workspace", build.getWorkspace().child(expectedNewlyCommittedFile).exists());
253252
}
@@ -259,7 +258,6 @@ protected FreeStyleBuild build(final FreeStyleProject project, final Result expe
259258

260259
protected FreeStyleBuild build(final FreeStyleProject project, final String parentDir, final Result expectedResult, final String...expectedNewlyCommittedFiles) throws Exception {
261260
final FreeStyleBuild build = project.scheduleBuild2(0).get();
262-
System.out.println(build.getLog());
263261
for(final String expectedNewlyCommittedFile : expectedNewlyCommittedFiles) {
264262
assertTrue(build.getWorkspace().child(parentDir).child(expectedNewlyCommittedFile).exists());
265263
}
@@ -271,7 +269,6 @@ protected FreeStyleBuild build(final FreeStyleProject project, final String pare
271269

272270
protected MatrixBuild build(final MatrixProject project, final Result expectedResult, final String...expectedNewlyCommittedFiles) throws Exception {
273271
final MatrixBuild build = project.scheduleBuild2(0).get();
274-
System.out.println(build.getLog());
275272
for(final String expectedNewlyCommittedFile : expectedNewlyCommittedFiles) {
276273
assertTrue(expectedNewlyCommittedFile + " file not found in workspace", build.getWorkspace().child(expectedNewlyCommittedFile).exists());
277274
}
@@ -312,15 +309,6 @@ public String invoke(File f, VirtualChannel channel) throws IOException, Interru
312309
});
313310
}
314311

315-
/* A utility method that displays a git repo. Useful to visualise merges. */
316-
public void showRepo(TestGitRepo repo, String msg) throws Exception {
317-
System.out.println("*********** "+msg+" ***********");
318-
try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
319-
int returnCode = new Launcher.LocalLauncher(listener).launch().cmds("git", "log","--all","--graph","--decorate","--oneline").pwd(repo.gitDir.getCanonicalPath()).stdout(out).join();
320-
System.out.println(out.toString());
321-
}
322-
}
323-
324312
public static class HasCredentialBuilder extends Builder {
325313

326314
private final String id;

src/test/java/hudson/plugins/git/CredentialsUserRemoteConfigTest.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ public void checkoutWithDifferentCredentials() throws Exception {
7878
+ " )"
7979
+ "}"));
8080
WorkflowRun b = r.assertBuildStatusSuccess(p.scheduleBuild2(0));
81-
System.out.println(JenkinsRule.getLog(b));
8281
r.assertLogContains("Warning: CredentialId \"github\" could not be found", b);
8382
}
8483

@@ -115,7 +114,6 @@ public void checkoutWithNoCredentialsStoredButUsed() throws Exception {
115114
+ " )"
116115
+ "}"));
117116
WorkflowRun b = r.assertBuildStatusSuccess(p.scheduleBuild2(0));
118-
System.out.println(JenkinsRule.getLog(b));
119117
r.assertLogContains("Warning: CredentialId \"github\" could not be found", b);
120118
}
121119

@@ -133,7 +131,6 @@ public void checkoutWithNoCredentialsSpecified() throws Exception {
133131
+ " )"
134132
+ "}"));
135133
WorkflowRun b = r.assertBuildStatusSuccess(p.scheduleBuild2(0));
136-
System.out.println(JenkinsRule.getLog(b));
137134
r.assertLogContains("No credentials specified", b);
138135
}
139136

src/test/java/jenkins/plugins/git/GitSampleRepoRule.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
import java.io.ByteArrayOutputStream;
3333
import java.io.File;
3434
import java.io.IOException;
35+
import java.util.logging.Level;
36+
import java.util.logging.Logger;
3537
import jenkins.scm.impl.mock.AbstractSampleDVCSRepoRule;
3638
import org.eclipse.jgit.lib.Constants;
3739
import org.eclipse.jgit.lib.RepositoryBuilder;
@@ -44,6 +46,8 @@ public final class GitSampleRepoRule extends AbstractSampleDVCSRepoRule {
4446

4547
private static boolean initialized = false;
4648

49+
private static final Logger LOGGER = Logger.getLogger(GitSampleRepoRule.class.getName());
50+
4751
public void git(String... cmds) throws Exception {
4852
run("git", cmds);
4953
}
@@ -74,10 +78,10 @@ public final boolean mkdirs(String rel) throws IOException {
7478
public void notifyCommit(JenkinsRule r) throws Exception {
7579
synchronousPolling(r);
7680
WebResponse webResponse = r.createWebClient().goTo("git/notifyCommit?url=" + bareUrl(), "text/plain").getWebResponse();
77-
System.out.println(webResponse.getContentAsString());
81+
LOGGER.log(Level.FINE, webResponse.getContentAsString());
7882
for (NameValuePair pair : webResponse.getResponseHeaders()) {
7983
if (pair.getName().equals("Triggered")) {
80-
System.out.println("Triggered: " + pair.getValue());
84+
LOGGER.log(Level.FINE, "Triggered: " + pair.getValue());
8185
}
8286
}
8387
r.waitUntilNoActivity();
@@ -101,24 +105,24 @@ public boolean gitVersionAtLeast(int neededMajor, int neededMinor, int neededPat
101105
try {
102106
int returnCode = new Launcher.LocalLauncher(procListener).launch().cmds("git", "--version").stdout(out).join();
103107
if (returnCode != 0) {
104-
System.out.println("Command 'git --version' returned " + returnCode);
108+
LOGGER.log(Level.WARNING, "Command 'git --version' returned " + returnCode);
105109
}
106110
} catch (IOException | InterruptedException ex) {
107-
System.out.println("Error checking git version " + ex);
111+
LOGGER.log(Level.WARNING, "Exception checking git version " + ex);
108112
}
109113
final String versionOutput = out.toString().trim();
110114
final String[] fields = versionOutput.split(" ")[2].replaceAll("msysgit.", "").replaceAll("windows.", "").split("\\.");
111115
final int gitMajor = Integer.parseInt(fields[0]);
112116
final int gitMinor = Integer.parseInt(fields[1]);
113117
final int gitPatch = Integer.parseInt(fields[2]);
114118
if (gitMajor < 1 || gitMajor > 3) {
115-
System.out.println("WARNING: Unexpected git major version " + gitMajor + " parsed from '" + versionOutput + "', field:'" + fields[0] + "'");
119+
LOGGER.log(Level.WARNING, "Unexpected git major version " + gitMajor + " parsed from '" + versionOutput + "', field:'" + fields[0] + "'");
116120
}
117121
if (gitMinor < 0 || gitMinor > 50) {
118-
System.out.println("WARNING: Unexpected git minor version " + gitMinor + " parsed from '" + versionOutput + "', field:'" + fields[1] + "'");
122+
LOGGER.log(Level.WARNING, "Unexpected git minor version " + gitMinor + " parsed from '" + versionOutput + "', field:'" + fields[1] + "'");
119123
}
120124
if (gitPatch < 0 || gitPatch > 20) {
121-
System.out.println("WARNING: Unexpected git patch version " + gitPatch + " parsed from '" + versionOutput + "', field:'" + fields[2] + "'");
125+
LOGGER.log(Level.WARNING, "Unexpected git patch version " + gitPatch + " parsed from '" + versionOutput + "', field:'" + fields[2] + "'");
122126
}
123127

124128
return gitMajor > neededMajor ||

0 commit comments

Comments
 (0)