Skip to content

Commit 03a718d

Browse files
committed
bz-63446 [junitlauncher] Create the right number of listeners in the test definition representing the fork mode of "testclasses"
Patch contributed by [email protected] as an attachment to the linked bugzilla
1 parent 0259c0b commit 03a718d

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

WHATSNEW

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ Fixed bugs:
77
* FTP task no longer duplicates a check for a file being a symlink.
88
Bugzilla Report 63259
99

10+
* junitlauncher task, when used in fork mode with "<testclasses>",
11+
used to create the wrong number of listeners per test class. This
12+
has now been fixed.
13+
Bugzilla Report 63446
14+
1015

1116
Changes from Ant 1.10.5 TO Ant 1.10.6
1217
=====================================

src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/confined/TestClasses.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,13 @@ protected void toForkedRepresentation(final JUnitLauncherTask task, final XMLStr
110110

111111
public static List<TestDefinition> fromForkedRepresentation(final XMLStreamReader reader) throws XMLStreamException {
112112
reader.require(XMLStreamConstants.START_ELEMENT, null, LD_XML_ELM_TEST_CLASSES);
113-
final TestClasses testDefinition = new TestClasses();
113+
final List<TestDefinition> testDefinitions = new ArrayList<>();
114114
// read out as multiple SingleTestClass representations
115115
while (reader.nextTag() != XMLStreamConstants.END_ELEMENT) {
116+
final SingleTestClass testDefinition = new SingleTestClass();
116117
reader.require(XMLStreamConstants.START_ELEMENT, null, Constants.LD_XML_ELM_TEST);
117118
final String testClassName = requireAttributeValue(reader, LD_XML_ATTR_CLASS_NAME);
118-
testDefinition.add(new StringResource(testClassName + ".class"));
119+
testDefinition.setName(testClassName);
119120
final String halt = reader.getAttributeValue(null, LD_XML_ATTR_HALT_ON_FAILURE);
120121
if (halt != null) {
121122
testDefinition.setHaltOnFailure(Boolean.parseBoolean(halt));
@@ -137,9 +138,10 @@ public static List<TestDefinition> fromForkedRepresentation(final XMLStreamReade
137138
testDefinition.addConfiguredListener(ListenerDefinition.fromForkedRepresentation(reader));
138139
}
139140
reader.require(XMLStreamConstants.END_ELEMENT, null, Constants.LD_XML_ELM_TEST);
141+
testDefinitions.add(testDefinition);
140142
}
141143
reader.require(XMLStreamConstants.END_ELEMENT, null, LD_XML_ELM_TEST_CLASSES);
142-
return Collections.singletonList(testDefinition);
144+
return Collections.unmodifiableList(testDefinitions);
143145
}
144146

145147
private static String requireAttributeValue(final XMLStreamReader reader, final String attrName) throws XMLStreamException {

0 commit comments

Comments
 (0)