"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "junit-platform-launcher/src/main/java/org/junit/platform/launcher/TestPlan.java" between
junit5-r5.3.2.tar.gz and junit5-r5.4.0.tar.gz

About: JUnit 5 is a unit testing framework for the Java programming language.

TestPlan.java  (junit5-r5.3.2):TestPlan.java  (junit5-r5.4.0)
/* /*
* Copyright 2015-2018 the original author or authors. * Copyright 2015-2019 the original author or authors.
* *
* All rights reserved. This program and the accompanying materials are * All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v2.0 which * made available under the terms of the Eclipse Public License v2.0 which
* accompanies this distribution and is available at * accompanies this distribution and is available at
* *
* http://www.eclipse.org/legal/epl-v20.html * http://www.eclipse.org/legal/epl-v20.html
*/ */
package org.junit.platform.launcher; package org.junit.platform.launcher;
import static java.util.Collections.emptySet; import static java.util.Collections.emptySet;
import static java.util.Collections.unmodifiableSet; import static java.util.Collections.unmodifiableSet;
import static org.apiguardian.api.API.Status.DEPRECATED;
import static org.apiguardian.api.API.Status.INTERNAL; import static org.apiguardian.api.API.Status.INTERNAL;
import static org.apiguardian.api.API.Status.STABLE; import static org.apiguardian.api.API.Status.STABLE;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
skipping to change at line 50 skipping to change at line 51
* a number of helpful methods to retrieve the * a number of helpful methods to retrieve the
* {@linkplain #getParent(TestIdentifier) parent}, * {@linkplain #getParent(TestIdentifier) parent},
* {@linkplain #getChildren(TestIdentifier) children}, and * {@linkplain #getChildren(TestIdentifier) children}, and
* {@linkplain #getDescendants(TestIdentifier) descendants} of an identifier. * {@linkplain #getDescendants(TestIdentifier) descendants} of an identifier.
* *
* <p>While the contained instances of {@link TestIdentifier} are immutable, * <p>While the contained instances of {@link TestIdentifier} are immutable,
* instances of this class contain mutable state. For example, when a dynamic * instances of this class contain mutable state. For example, when a dynamic
* test is registered at runtime, it is added to the original test plan and * test is registered at runtime, it is added to the original test plan and
* reported to {@link TestExecutionListener} implementations. * reported to {@link TestExecutionListener} implementations.
* *
* <p>This class is not intended to be extended by clients.
*
* @since 1.0 * @since 1.0
* @see Launcher * @see Launcher
* @see TestExecutionListener * @see TestExecutionListener
*/ */
@API(status = STABLE, since = "1.0") @API(status = STABLE, since = "1.0")
public final class TestPlan { public class TestPlan {
private final Set<TestIdentifier> roots = Collections.synchronizedSet(new LinkedHashSet<>(4)); private final Set<TestIdentifier> roots = Collections.synchronizedSet(new LinkedHashSet<>(4));
private final Map<String, Set<TestIdentifier>> children = new ConcurrentH ashMap<>(32); private final Map<String, Set<TestIdentifier>> children = new ConcurrentH ashMap<>(32);
private final Map<String, TestIdentifier> allIdentifiers = new Concurrent HashMap<>(32); private final Map<String, TestIdentifier> allIdentifiers = new Concurrent HashMap<>(32);
private final boolean containsTests; private final boolean containsTests;
/** /**
skipping to change at line 85 skipping to change at line 88
*/ */
@API(status = INTERNAL, since = "1.0") @API(status = INTERNAL, since = "1.0")
public static TestPlan from(Collection<TestDescriptor> engineDescriptors) { public static TestPlan from(Collection<TestDescriptor> engineDescriptors) {
Preconditions.notNull(engineDescriptors, "Cannot create TestPlan from a null collection of TestDescriptors"); Preconditions.notNull(engineDescriptors, "Cannot create TestPlan from a null collection of TestDescriptors");
TestPlan testPlan = new TestPlan(engineDescriptors.stream().anyMa tch(TestDescriptor::containsTests)); TestPlan testPlan = new TestPlan(engineDescriptors.stream().anyMa tch(TestDescriptor::containsTests));
Visitor visitor = descriptor -> testPlan.add(TestIdentifier.from( descriptor)); Visitor visitor = descriptor -> testPlan.add(TestIdentifier.from( descriptor));
engineDescriptors.forEach(engineDescriptor -> engineDescriptor.ac cept(visitor)); engineDescriptors.forEach(engineDescriptor -> engineDescriptor.ac cept(visitor));
return testPlan; return testPlan;
} }
private TestPlan(boolean containsTests) { @API(status = INTERNAL, since = "1.4")
protected TestPlan(boolean containsTests) {
this.containsTests = containsTests; this.containsTests = containsTests;
} }
/** /**
* Add the supplied {@link TestIdentifier} to this test plan. * Add the supplied {@link TestIdentifier} to this test plan.
* *
* @param testIdentifier the identifier to add; never {@code null} * @param testIdentifier the identifier to add; never {@code null}
* @deprecated without replacement since this method was intended to be i nternal.
*/ */
@Deprecated
@API(status = DEPRECATED, since = "1.4")
public void add(TestIdentifier testIdentifier) { public void add(TestIdentifier testIdentifier) {
Preconditions.notNull(testIdentifier, "testIdentifier must not be null"); Preconditions.notNull(testIdentifier, "testIdentifier must not be null");
allIdentifiers.put(testIdentifier.getUniqueId(), testIdentifier); allIdentifiers.put(testIdentifier.getUniqueId(), testIdentifier);
if (testIdentifier.getParentId().isPresent()) { if (testIdentifier.getParentId().isPresent()) {
String parentId = testIdentifier.getParentId().get(); String parentId = testIdentifier.getParentId().get();
Set<TestIdentifier> directChildren = children.computeIfAb sent(parentId, Set<TestIdentifier> directChildren = children.computeIfAb sent(parentId,
key -> Collections.synchronizedSet(new LinkedHash Set<>(16))); key -> Collections.synchronizedSet(new LinkedHash Set<>(16)));
directChildren.add(testIdentifier); directChildren.add(testIdentifier);
} }
else { else {
skipping to change at line 200 skipping to change at line 207
Preconditions.notNull(parent, "parent must not be null"); Preconditions.notNull(parent, "parent must not be null");
Set<TestIdentifier> result = new LinkedHashSet<>(16); Set<TestIdentifier> result = new LinkedHashSet<>(16);
Set<TestIdentifier> children = getChildren(parent); Set<TestIdentifier> children = getChildren(parent);
result.addAll(children); result.addAll(children);
for (TestIdentifier child : children) { for (TestIdentifier child : children) {
result.addAll(getDescendants(child)); result.addAll(getDescendants(child));
} }
return unmodifiableSet(result); return unmodifiableSet(result);
} }
/**
* Return whether this test plan contains any tests.
*
* <p>A test plan contains tests, if at least one of the contained engine
* descriptors {@linkplain TestDescriptor#containsTests(TestDescriptor)
* contains tests}.
*
* @return {@code true} if this test plan contains tests
* @see TestDescriptor#containsTests(TestDescriptor)
*/
public boolean containsTests() { public boolean containsTests() {
return containsTests; return containsTests;
} }
} }
 End of changes. 9 change blocks. 
3 lines changed or deleted 21 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)