Search in sources :

Example 1 with CachingJupiterConfiguration

use of org.junit.jupiter.engine.config.CachingJupiterConfiguration in project junit5 by junit-team.

the class JupiterTestEngine method discover.

@Override
public TestDescriptor discover(EngineDiscoveryRequest discoveryRequest, UniqueId uniqueId) {
    JupiterConfiguration configuration = new CachingJupiterConfiguration(new DefaultJupiterConfiguration(discoveryRequest.getConfigurationParameters()));
    JupiterEngineDescriptor engineDescriptor = new JupiterEngineDescriptor(uniqueId, configuration);
    new DiscoverySelectorResolver().resolveSelectors(discoveryRequest, engineDescriptor);
    return engineDescriptor;
}
Also used : DiscoverySelectorResolver(org.junit.jupiter.engine.discovery.DiscoverySelectorResolver) CachingJupiterConfiguration(org.junit.jupiter.engine.config.CachingJupiterConfiguration) DefaultJupiterConfiguration(org.junit.jupiter.engine.config.DefaultJupiterConfiguration) JupiterConfiguration(org.junit.jupiter.engine.config.JupiterConfiguration) CachingJupiterConfiguration(org.junit.jupiter.engine.config.CachingJupiterConfiguration) DefaultJupiterConfiguration(org.junit.jupiter.engine.config.DefaultJupiterConfiguration) JupiterEngineDescriptor(org.junit.jupiter.engine.descriptor.JupiterEngineDescriptor)

Example 2 with CachingJupiterConfiguration

use of org.junit.jupiter.engine.config.CachingJupiterConfiguration in project graylog2-server by Graylog2.

the class ContainerMatrixTestEngine method discover.

@Override
public TestDescriptor discover(EngineDiscoveryRequest discoveryRequest, UniqueId uniqueId) {
    JupiterConfiguration configuration = new CachingJupiterConfiguration(new DefaultJupiterConfiguration(discoveryRequest.getConfigurationParameters()));
    final ContainerMatrixEngineDescriptor engineDescriptor = new ContainerMatrixEngineDescriptor(uniqueId, "Graylog Container Matrix Tests", configuration);
    Reflections reflections = new Reflections("org.graylog", "org.graylog2");
    final Set<Class<?>> annotated = reflections.getTypesAnnotatedWith(ContainerMatrixTestsConfiguration.class);
    final Set<Integer> extraPorts = getExtraPorts(annotated);
    final List<URL> mongoDBFixtures = getMongoDBFixtures(annotated);
    if (testAgainstRunningESMongoDB()) {
        // if you test from inside an IDE against running containers
        ContainerMatrixTestsDescriptor testsDescriptor = new ContainerMatrixTestWithRunningESMongoTestsDescriptor(engineDescriptor, extraPorts, mongoDBFixtures);
        new ContainerMatrixTestsDiscoverySelectorResolver(engineDescriptor).resolveSelectors(discoveryRequest, testsDescriptor);
        engineDescriptor.addChild(testsDescriptor);
    } else {
        // for full tests, create all combinations of tests. First differentiate for maven builds.
        getMavenProjectDirProvider(annotated).forEach(mavenProjectDirProvider -> getPluginJarsProvider(annotated).forEach(pluginJarsProvider -> {
            MavenProjectDirProvider mpdp = instantiateFactory(mavenProjectDirProvider);
            PluginJarsProvider pjp = instantiateFactory(pluginJarsProvider);
            // now add all grouped tests for Lifecycle.VM
            getSearchServerVersions(annotated).stream().map(SearchServer::getSearchVersion).forEach(searchVersion -> getMongoVersions(annotated).forEach(mongoVersion -> {
                ContainerMatrixTestsDescriptor testsDescriptor = new ContainerMatrixTestsDescriptor(engineDescriptor, Lifecycle.VM, mavenProjectDirProvider, mpdp.getUniqueId(), pluginJarsProvider, pjp.getUniqueId(), searchVersion, mongoVersion, extraPorts, mongoDBFixtures);
                new ContainerMatrixTestsDiscoverySelectorResolver(engineDescriptor).resolveSelectors(discoveryRequest, testsDescriptor);
                engineDescriptor.addChild(testsDescriptor);
            }));
            // add separate test classes (Lifecycle.CLASS)
            getSearchServerVersions(annotated).stream().map(SearchServer::getSearchVersion).forEach(esVersion -> getMongoVersions(annotated).forEach(mongoVersion -> {
                ContainerMatrixTestsDescriptor testsDescriptor = new ContainerMatrixTestsDescriptor(engineDescriptor, Lifecycle.CLASS, mavenProjectDirProvider, mpdp.getUniqueId(), pluginJarsProvider, pjp.getUniqueId(), esVersion, mongoVersion, extraPorts, new ArrayList<>());
                new ContainerMatrixTestsDiscoverySelectorResolver(engineDescriptor).resolveSelectors(discoveryRequest, testsDescriptor);
                engineDescriptor.addChild(testsDescriptor);
            }));
        }));
    }
    return engineDescriptor;
}
Also used : Arrays(java.util.Arrays) ThrowableCollector(org.junit.platform.engine.support.hierarchical.ThrowableCollector) URL(java.net.URL) ContainerMatrixTestsDescriptor(org.junit.jupiter.engine.descriptor.ContainerMatrixTestsDescriptor) JupiterConfiguration(org.junit.jupiter.engine.config.JupiterConfiguration) Reflections(org.reflections.Reflections) ContainerMatrixTestWithRunningESMongoTestsDescriptor(org.junit.jupiter.engine.descriptor.ContainerMatrixTestWithRunningESMongoTestsDescriptor) Function(java.util.function.Function) ArrayList(java.util.ArrayList) JupiterEngineExecutionContext(org.junit.jupiter.engine.execution.JupiterEngineExecutionContext) ContainerMatrixTestsConfiguration(org.graylog.testing.containermatrix.annotations.ContainerMatrixTestsConfiguration) ContainerMatrixTestsDiscoverySelectorResolver(org.junit.jupiter.engine.discovery.ContainerMatrixTestsDiscoverySelectorResolver) LinkedList(java.util.LinkedList) EngineDiscoveryRequest(org.junit.platform.engine.EngineDiscoveryRequest) Lifecycle(org.graylog.testing.completebackend.Lifecycle) DefaultJupiterConfiguration(org.junit.jupiter.engine.config.DefaultJupiterConfiguration) Resources(com.google.common.io.Resources) MavenProjectDirProvider(org.graylog.testing.completebackend.MavenProjectDirProvider) ContainerMatrixEngineDescriptor(org.junit.jupiter.engine.descriptor.ContainerMatrixEngineDescriptor) Set(java.util.Set) HierarchicalTestExecutorService(org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutorService) UniqueId(org.junit.platform.engine.UniqueId) Collectors(java.util.stream.Collectors) CachingJupiterConfiguration(org.junit.jupiter.engine.config.CachingJupiterConfiguration) PluginJarsProvider(org.graylog.testing.completebackend.PluginJarsProvider) JupiterThrowableCollectorFactory(org.junit.jupiter.engine.support.JupiterThrowableCollectorFactory) AnnotationSupport(org.junit.platform.commons.support.AnnotationSupport) List(java.util.List) Stream(java.util.stream.Stream) ContainerMatrixHierarchicalTestEngine(org.junit.platform.engine.support.hierarchical.ContainerMatrixHierarchicalTestEngine) StringUtils.isBlank(org.apache.commons.lang3.StringUtils.isBlank) Paths(java.nio.file.Paths) Optional(java.util.Optional) ExecutionRequest(org.junit.platform.engine.ExecutionRequest) TestDescriptor(org.junit.platform.engine.TestDescriptor) ContainerMatrixTestsDescriptor(org.junit.jupiter.engine.descriptor.ContainerMatrixTestsDescriptor) ContainerMatrixEngineDescriptor(org.junit.jupiter.engine.descriptor.ContainerMatrixEngineDescriptor) CachingJupiterConfiguration(org.junit.jupiter.engine.config.CachingJupiterConfiguration) MavenProjectDirProvider(org.graylog.testing.completebackend.MavenProjectDirProvider) URL(java.net.URL) ContainerMatrixTestsDiscoverySelectorResolver(org.junit.jupiter.engine.discovery.ContainerMatrixTestsDiscoverySelectorResolver) PluginJarsProvider(org.graylog.testing.completebackend.PluginJarsProvider) JupiterConfiguration(org.junit.jupiter.engine.config.JupiterConfiguration) DefaultJupiterConfiguration(org.junit.jupiter.engine.config.DefaultJupiterConfiguration) CachingJupiterConfiguration(org.junit.jupiter.engine.config.CachingJupiterConfiguration) DefaultJupiterConfiguration(org.junit.jupiter.engine.config.DefaultJupiterConfiguration) Reflections(org.reflections.Reflections) ContainerMatrixTestWithRunningESMongoTestsDescriptor(org.junit.jupiter.engine.descriptor.ContainerMatrixTestWithRunningESMongoTestsDescriptor)

Aggregations

CachingJupiterConfiguration (org.junit.jupiter.engine.config.CachingJupiterConfiguration)2 DefaultJupiterConfiguration (org.junit.jupiter.engine.config.DefaultJupiterConfiguration)2 JupiterConfiguration (org.junit.jupiter.engine.config.JupiterConfiguration)2 Resources (com.google.common.io.Resources)1 URL (java.net.URL)1 Paths (java.nio.file.Paths)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Optional (java.util.Optional)1 Set (java.util.Set)1 Function (java.util.function.Function)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1 StringUtils.isBlank (org.apache.commons.lang3.StringUtils.isBlank)1 Lifecycle (org.graylog.testing.completebackend.Lifecycle)1 MavenProjectDirProvider (org.graylog.testing.completebackend.MavenProjectDirProvider)1 PluginJarsProvider (org.graylog.testing.completebackend.PluginJarsProvider)1 ContainerMatrixTestsConfiguration (org.graylog.testing.containermatrix.annotations.ContainerMatrixTestsConfiguration)1