Skip to content

Commit

Permalink
[JENKINS-48995] - Stop storing TestNG parsers in XML
Browse files Browse the repository at this point in the history
  • Loading branch information
oleg-nenashev committed Jan 17, 2018
1 parent 8b93d29 commit c3b85cd
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 19 deletions.
Expand Up @@ -49,7 +49,6 @@
import org.kohsuke.stapler.StaplerRequest;

import com.tupilabs.testng.parser.Suite;
import com.tupilabs.testng.parser.TestNGParser;

/**
* @author Bruno P. Kinoshita - http://www.kinoshita.eti.br
Expand Down Expand Up @@ -158,7 +157,6 @@ public boolean isApplicable(Class<? extends AbstractProject> jobType) {
@Initializer(before = InitMilestone.PLUGINS_STARTED)
public static void addAliases() {
Items.XSTREAM2.addCompatibilityAlias("hudson.plugins.testlink.testng.Suite", Suite.class);
Items.XSTREAM2.addCompatibilityAlias("hudson.plugins.testlink.testng.TestNGParser", TestNGParser.class);
Items.XSTREAM2.addCompatibilityAlias("hudson.plugins.testlink.testng.Test",
com.tupilabs.testng.parser.Test.class);
Items.XSTREAM2.addCompatibilityAlias("hudson.plugins.testlink.testng.TestMethod",
Expand Down
Expand Up @@ -44,6 +44,8 @@
import com.tupilabs.testng.parser.Suite;
import com.tupilabs.testng.parser.TestNGParser;

import javax.annotation.Nonnull;

/**
* @author Bruno P. Kinoshita - http://www.kinoshita.eti.br
* @since 3.1
Expand All @@ -58,7 +60,7 @@ public abstract class AbstractTestNGResultSeeker extends ResultSeeker {

public static final String TEXT_XML_CONTENT_TYPE = "text/xml";

protected final TestNGParser parser = new TestNGParser();
protected transient TestNGParser _parser = null;

private boolean attachTestNGXML = false;

Expand All @@ -70,6 +72,14 @@ public AbstractTestNGResultSeeker(String includePattern, String keyCustomField,
this.markSkippedTestAsBlocked = markSkippedTestAsBlocked;
}

@Nonnull
protected TestNGParser getParser() {
if (_parser == null) {
_parser = new TestNGParser();
}
return _parser;
}

public void setAttachTestNGXML(boolean attachTestNGXML) {
this.attachTestNGXML = attachTestNGXML;
}
Expand Down
Expand Up @@ -103,7 +103,7 @@ public List<Suite> invoke(File workspace, VirtualChannel channel)

for(String xml : xmls) {
final File input = new File(workspace, xml);
List <Suite> suitz = parser.parse(input);
List <Suite> suitz = getParser().parse(input);
for(Suite suite : suitz){
suites.add(suite);
}
Expand Down
Expand Up @@ -37,7 +37,6 @@
import com.tupilabs.testng.parser.Suite;
import com.tupilabs.testng.parser.Test;
import com.tupilabs.testng.parser.TestMethod;
import com.tupilabs.testng.parser.TestNGParser;

import br.eti.kinoshita.testlinkjavaapi.constants.ExecutionStatus;
import hudson.Extension;
Expand All @@ -61,8 +60,6 @@
public class TestNGMethodNameDataProviderNameResultSeeker extends AbstractTestNGResultSeeker {

private static final long serialVersionUID = -3337191837294608305L;

private final TestNGParser parser = new TestNGParser();

private final String dataProviderNameKeyCustomField;

Expand Down Expand Up @@ -123,7 +120,7 @@ public List<Suite> invoke(File workspace, VirtualChannel channel)

for(String xml : xmls) {
final File input = new File(workspace, xml);
List <Suite> suitz = parser.parse(input);
List <Suite> suitz = getParser().parse(input);
for(Suite suite : suitz){
suites.add(suite);
}
Expand Down
Expand Up @@ -37,7 +37,6 @@
import com.tupilabs.testng.parser.Suite;
import com.tupilabs.testng.parser.Test;
import com.tupilabs.testng.parser.TestMethod;
import com.tupilabs.testng.parser.TestNGParser;

import br.eti.kinoshita.testlinkjavaapi.constants.ExecutionStatus;
import hudson.Extension;
Expand All @@ -61,9 +60,7 @@
public class TestNGMethodNameResultSeeker extends AbstractTestNGResultSeeker {

private static final long serialVersionUID = 3885800916930897675L;

private final TestNGParser parser = new TestNGParser();


/**
* @param includePattern
* @param keyCustomField
Expand Down Expand Up @@ -106,7 +103,7 @@ public List<Suite> invoke(File workspace, VirtualChannel channel)

for(String xml : xmls) {
final File input = new File(workspace, xml);
List <Suite> suitz = parser.parse(input);
List <Suite> suitz = getParser().parse(input);
for(Suite suite : suitz){
suites.add(suite);
}
Expand Down
Expand Up @@ -36,7 +36,6 @@
import com.tupilabs.testng.parser.Suite;
import com.tupilabs.testng.parser.Test;
import com.tupilabs.testng.parser.TestMethod;
import com.tupilabs.testng.parser.TestNGParser;

import br.eti.kinoshita.testlinkjavaapi.constants.ExecutionStatus;
import hudson.Extension;
Expand All @@ -61,8 +60,6 @@ public class TestNGSuiteNameResultSeeker extends AbstractTestNGResultSeeker {

private static final long serialVersionUID = 3998602647639013614L;

private final TestNGParser parser = new TestNGParser();

/**
* @param includePattern
* @param keyCustomField
Expand Down Expand Up @@ -105,7 +102,7 @@ public List<Suite> invoke(File workspace, VirtualChannel channel)

for(String xml : xmls) {
final File input = new File(workspace, xml);
List <Suite> suitz = parser.parse(input);
List <Suite> suitz = getParser().parse(input);
for(Suite suite : suitz){
suites.add(suite);
}
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/META-INF/hudson.remoting.ClassFilter
Expand Up @@ -7,3 +7,6 @@ br.eti.kinoshita.testlinkjavaapi.model.TestCaseStep
br.eti.kinoshita.testlinkjavaapi.model.CustomField
br.eti.kinoshita.testlinkjavaapi.model.Platform


#TestNG
com.tupilabs.testng.parser.
Expand Up @@ -39,7 +39,7 @@
import hudson.tasks.junit.TestResult;

/**
* Tests the JUnit parser for issue 8531.
* Tests the JUnit _parser for issue 8531.
*
* @author Bruno P. Kinoshita - http://www.kinoshita.eti.br
* @since 2.1
Expand Down
Expand Up @@ -37,7 +37,7 @@
import hudson.tasks.junit.TestResult;

/**
* Tests the JUnit parser for issue 9993.
* Tests the JUnit _parser for issue 9993.
*
* @author Bruno P. Kinoshita - http://www.kinoshita.eti.br
* @since 2.5
Expand Down
33 changes: 33 additions & 0 deletions src/test/java/hudson/plugins/testlink/result/ResultSeekerTest.java
@@ -0,0 +1,33 @@
package hudson.plugins.testlink.result;

import net.sf.json.JSONObject;
import org.junit.ClassRule;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.jvnet.hudson.test.For;
import org.jvnet.hudson.test.JenkinsRule;
import org.kohsuke.stapler.RequestImpl;
import org.mockito.Mock;

import javax.management.Descriptor;

@For(ResultSeeker.class)
@Ignore
public class ResultSeekerTest {

@ClassRule
public static JenkinsRule j = new JenkinsRule();

@ClassRule
public static TemporaryFolder f = new TemporaryFolder();

@Test
public void test() throws Exception {

for (hudson.model.Descriptor<? extends ResultSeeker> d : ResultSeeker.all()) {
System.out.println("Trying " + d.getDisplayName());
ResultSeeker s = d.newInstance(null, new JSONObject());
}
}
}

0 comments on commit c3b85cd

Please sign in to comment.