Skip to content

Commit

Permalink
[FIXED JENKINS-14511] Added logs to testlink-plugin using j.u.l.
Browse files Browse the repository at this point in the history
  • Loading branch information
kinow committed Jul 20, 2012
1 parent 241d5a7 commit 1cc50eb
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
22 changes: 22 additions & 0 deletions src/main/java/hudson/plugins/testlink/TestLinkBuilder.java
Expand Up @@ -44,6 +44,8 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

import org.kohsuke.stapler.DataBoundConstructor;

Expand All @@ -63,6 +65,8 @@
*/
public class TestLinkBuilder extends AbstractTestLinkBuilder {

private static final Logger LOGGER = Logger.getLogger("hudson.plugins.testlink");

/**
* The Descriptor of this Builder. It contains the TestLink installation.
*/
Expand Down Expand Up @@ -91,6 +95,9 @@ public TestLinkBuilder(String testLinkName, String testProjectName,
@Override
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher,
BuildListener listener) throws InterruptedException, IOException {

LOGGER.log(Level.INFO, "TestLink builder started");

this.failure = false;

// TestLink installation
Expand All @@ -117,6 +124,12 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher,
final String buildName = expandVariable(build.getBuildVariableResolver(),
build.getEnvironment(listener), getBuildName());
final String buildNotes = Messages.TestLinkBuilder_Build_Notes();
if(LOGGER.isLoggable(Level.FINE)) {
LOGGER.log(Level.FINE, "TestLink project name: ["+testProjectName+"]");
LOGGER.log(Level.FINE, "TestLink plan name: ["+testPlanName+"]");
LOGGER.log(Level.FINE, "TestLink build name: ["+buildName+"]");
LOGGER.log(Level.FINE, "TestLink build notes: ["+buildNotes+"]");
}
// TestLink Site object
testLinkSite = this.getTestLinkSite(testLinkUrl, testLinkDevKey, testProjectName, testPlanName, buildName, buildNotes);
final String[] customFieldsNames = this.createArrayOfCustomFieldsNames(build.getBuildVariableResolver(), build.getEnvironment(listener));
Expand All @@ -141,6 +154,12 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher,
e.printStackTrace(listener.fatalError(e.getMessage()));
throw new AbortException(Messages.TestLinkBuilder_TestLinkCommunicationError());
}

if(LOGGER.isLoggable(Level.FINE)) {
for(TestCaseWrapper tcw : automatedTestCases) {
LOGGER.log(Level.FINE, "TestLink automated test case ID [" + tcw.getId() + "], name [" +tcw.getName()+ "]");
}
}

listener.getLogger().println(Messages.TestLinkBuilder_ExecutingSingleBuildSteps());
this.executeSingleBuildSteps(build, launcher, listener);
Expand All @@ -156,6 +175,7 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher,

if(getResultSeekers() != null) {
for (ResultSeeker resultSeeker : getResultSeekers()) {
LOGGER.log(Level.INFO, "Seeking test results. Using: " + resultSeeker.getDescriptor().getDisplayName());
resultSeeker.seek(automatedTestCases, build, launcher, listener, testLinkSite);
}
}
Expand Down Expand Up @@ -185,6 +205,8 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher,
}
}

LOGGER.log(Level.INFO, "TestLink builder finished");

// end
return Boolean.TRUE;
}
Expand Down
17 changes: 15 additions & 2 deletions src/main/java/hudson/plugins/testlink/result/ResultSeeker.java
Expand Up @@ -38,6 +38,8 @@
import java.io.IOException;
import java.io.Serializable;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.FileUtils;
Expand All @@ -58,6 +60,8 @@ public abstract class ResultSeeker implements Serializable, Describable<ResultSe

private static final long serialVersionUID = 3609106615463455486L;

private static final Logger LOGGER = Logger.getLogger("hudson.plugins.testlink");

/**
* Include pattern used when looking for results.
*/
Expand Down Expand Up @@ -184,6 +188,12 @@ protected String[] scan(final File directory, final String includes, final Build
throw new IOException(e);
}
}

if(LOGGER.isLoggable(Level.FINE)) {
for(String fileName : fileNames) {
LOGGER.log(Level.FINE, "Test result file found: " + fileName);
}
}

return fileNames;

Expand All @@ -197,13 +207,16 @@ protected CustomField getKeyCustomField(List<CustomField> customFields, String k

for (CustomField cf : customFields) {
boolean isKeyCustomField = cf.getName().equals(keyCustomFieldName);

if (isKeyCustomField) {
customField = cf;
break;
}

}

if(LOGGER.isLoggable(Level.FINE)) {
LOGGER.log(Level.FINE, "Key custom field used: " + customField);
}

return customField;
}

Expand Down

0 comments on commit 1cc50eb

Please sign in to comment.