Skip to content

Commit

Permalink
Remove workaround for JDK 1.8.0_31
Browse files Browse the repository at this point in the history
------------------------------------------------------------------------
On behalf of the community, the JUnit Lambda Team thanks Klarna AB
(http://www.klarna.com) for supporting the JUnit crowdfunding campaign!
------------------------------------------------------------------------
  • Loading branch information
marcphilipp committed Jan 9, 2016
1 parent 920d5fe commit dfc6515
Showing 1 changed file with 16 additions and 8 deletions.
Expand Up @@ -10,6 +10,7 @@

package org.junit.gen5.engine.junit4;

import static java.text.MessageFormat.format;
import static java.util.Collections.singleton;
import static java.util.function.Predicate.isEqual;
import static org.assertj.core.api.Assertions.assertThat;
Expand All @@ -23,7 +24,7 @@
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Predicate;
import java.util.Set;

import org.junit.gen5.api.Test;
import org.junit.gen5.engine.TestDescriptor;
Expand Down Expand Up @@ -275,24 +276,31 @@ void resolvesCategoriesIntoTags() {
TestDescriptor runnerDescriptor = getOnlyElement(engineDescriptor.getChildren());
assertThat(runnerDescriptor.getTags()).containsOnly(new TestTag(Plain.class.getName()));

TestDescriptor failingTestDescriptor = findChildByName(runnerDescriptor, "failingTest");
TestDescriptor failingTestDescriptor = findChildByDisplayName(runnerDescriptor, "failingTest");
assertThat(failingTestDescriptor.getTags()).containsOnly(new TestTag(Plain.class.getName()),
new TestTag(Failing.class.getName()));

TestDescriptor ignoredWithoutReasonTestDescriptor = findChildByName(runnerDescriptor,
TestDescriptor ignoredWithoutReasonTestDescriptor = findChildByDisplayName(runnerDescriptor,
"ignoredTest1_withoutReason");
assertThat(ignoredWithoutReasonTestDescriptor.getTags()).containsOnly(new TestTag(Plain.class.getName()),
new TestTag(Skipped.class.getName()));

TestDescriptor ignoredWithReasonTestDescriptor = findChildByName(runnerDescriptor, "ignoredTest2_withReason");
TestDescriptor ignoredWithReasonTestDescriptor = findChildByDisplayName(runnerDescriptor,
"ignoredTest2_withReason");
assertThat(ignoredWithReasonTestDescriptor.getTags()).containsOnly(new TestTag(Plain.class.getName()),
new TestTag(Skipped.class.getName()), new TestTag(SkippedWithReason.class.getName()));
}

private TestDescriptor findChildByName(TestDescriptor runnerDescriptor, String name) {
Predicate<TestDescriptor> predicate = where(TestDescriptor::getDisplayName, isEqual(name));
return runnerDescriptor.getChildren().stream().filter(predicate).findAny().orElseThrow(() -> new AssertionError(
"No child with display name \"" + name + "\" in " + runnerDescriptor.getChildren()));
private TestDescriptor findChildByDisplayName(TestDescriptor runnerDescriptor, String displayName) {
// @formatter:off
Set<? extends TestDescriptor> children = runnerDescriptor.getChildren();
return children
.stream()
.filter(where(TestDescriptor::getDisplayName, isEqual(displayName)))
.findAny()
.orElseThrow(() ->
new AssertionError(format("No child with display name \"{0}\" in {1}", displayName, children)));
// @formatter:on
}

private File getClasspathRoot(Class<?> testClass) throws Exception {
Expand Down

0 comments on commit dfc6515

Please sign in to comment.