forked from junit-team/junit5
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add include/exclude-based filtering for auto-detected extensions (jun…
…it-team#4120) Two new configuration parameters allow configured comma-separated lists of includes and excludes for auto-detected extension registration: * `junit.jupiter.extensions.autodetection.include` * `junit.jupiter.extensions.autodetection.exclude` Resolves junit-team#3717. --------- Co-authored-by: Marc Philipp <[email protected]>
- Loading branch information
1 parent
efa1527
commit 16c6f72
Showing
18 changed files
with
441 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
junit-platform-commons/src/main/java/org/junit/platform/commons/util/ServiceLoaderUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright 2015-2024 the original author or authors. | ||
* | ||
* All rights reserved. This program and the accompanying materials are | ||
* made available under the terms of the Eclipse Public License v2.0 which | ||
* accompanies this distribution and is available at | ||
* | ||
* https://www.eclipse.org/legal/epl-v20.html | ||
*/ | ||
|
||
package org.junit.platform.commons.util; | ||
|
||
import java.util.ServiceLoader; | ||
import java.util.function.Predicate; | ||
import java.util.stream.Stream; | ||
import java.util.stream.StreamSupport; | ||
|
||
import org.apiguardian.api.API; | ||
|
||
/** | ||
* Collection of utilities for working with {@link ServiceLoader}. | ||
* | ||
* <h2>DISCLAIMER</h2> | ||
* | ||
* <p>These utilities are intended solely for usage within the JUnit framework | ||
* itself. <strong>Any usage by external parties is not supported.</strong> | ||
* Use at your own risk! | ||
* | ||
* @since 5.11 | ||
*/ | ||
@API(status = API.Status.INTERNAL, since = "5.11") | ||
public class ServiceLoaderUtils { | ||
|
||
private ServiceLoaderUtils() { | ||
/* no-op */ | ||
} | ||
|
||
/** | ||
* Filters the supplied service loader using the supplied predicate. | ||
* | ||
* @param <T> the type of the service | ||
* @param serviceLoader the service loader to be filtered | ||
* @param providerPredicate the predicate to filter the loaded services | ||
* @return a stream of loaded services that match the predicate | ||
*/ | ||
public static <T> Stream<T> filter(ServiceLoader<T> serviceLoader, | ||
Predicate<? super Class<? extends T>> providerPredicate) { | ||
return StreamSupport.stream(serviceLoader.spliterator(), false).filter(it -> { | ||
@SuppressWarnings("unchecked") | ||
Class<? extends T> type = (Class<? extends T>) it.getClass(); | ||
return providerPredicate.test(type); | ||
}); | ||
} | ||
|
||
} |
Oops, something went wrong.