org.junit.platform.engine.TestEngine Java Examples

The following examples show how to use org.junit.platform.engine.TestEngine. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ConfigurableClassLoaderTest.java    From component-runtime with Apache License 2.0 6 votes vote down vote up
@Test
void jvmOnlyInParentSpi() throws IOException {
    final Predicate<String> parentClasses = name -> true;
    try (final URLClassLoader parent =
            new URLClassLoader(new URL[0], Thread.currentThread().getContextClassLoader());
            final ConfigurableClassLoader loader = new ConfigurableClassLoader("test", new URL[0], parent,
                    parentClasses, parentClasses.negate(), new String[0], new String[] {
                            new File(System.getProperty("java.home")).toPath().toAbsolutePath().toString() })) {

        // can be loaded cause in the JVM
        assertTrue(ServiceLoader.load(FileSystemProvider.class, loader).iterator().hasNext());

        // this is in the (test) classloader but not available to the classloader
        final List<TestEngine> junitEngines = StreamSupport
                .stream(ServiceLoader.load(TestEngine.class, loader).spliterator(), false)
                .collect(toList());
        assertTrue(junitEngines.isEmpty());
    }
}