Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce JupiterConfiguration interface
The new interface wraps around `ConfigurationParameters` instances and provides access to as well as conversion for well-known configuration parameters used by within the Jupiter engine.
- Loading branch information
1 parent
916dc35
commit d91e682
Showing
51 changed files
with
534 additions
and
408 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
72 changes: 72 additions & 0 deletions
72
...ter-engine/src/main/java/org/junit/jupiter/engine/config/DefaultJupiterConfiguration.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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,72 @@ | |||
/* | |||
* Copyright 2015-2018 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 | |||
* | |||
* http://www.eclipse.org/legal/epl-v20.html | |||
*/ | |||
|
|||
package org.junit.jupiter.engine.config; | |||
|
|||
import static org.apiguardian.api.API.Status.INTERNAL; | |||
|
|||
import java.util.Optional; | |||
|
|||
import org.apiguardian.api.API; | |||
import org.junit.jupiter.api.TestInstance.Lifecycle; | |||
import org.junit.jupiter.api.parallel.ExecutionMode; | |||
import org.junit.platform.commons.util.Preconditions; | |||
import org.junit.platform.commons.util.StringUtils; | |||
import org.junit.platform.engine.ConfigurationParameters; | |||
|
|||
@API(status = INTERNAL, since = "5.4") | |||
public class DefaultJupiterConfiguration implements JupiterConfiguration { | |||
|
|||
private final ConfigurationParameters configurationParameters; | |||
|
|||
public DefaultJupiterConfiguration(ConfigurationParameters configurationParameters) { | |||
this.configurationParameters = Preconditions.notNull(configurationParameters, | |||
"ConfigurationParameters must not be null"); | |||
} | |||
|
|||
@Override | |||
public Optional<String> getRawConfigurationParameter(String key) { | |||
return configurationParameters.get(key); | |||
} | |||
|
|||
@Override | |||
public boolean isParallelExecutionEnabled() { | |||
return configurationParameters.getBoolean(PARALLEL_EXECUTION_ENABLED_PROPERTY_NAME).orElse(false); | |||
} | |||
|
|||
@Override | |||
public boolean isExtensionAutoDetectionEnabled() { | |||
return configurationParameters.getBoolean(EXTENSIONS_AUTODETECTION_ENABLED_PROPERTY_NAME).orElse(false); | |||
} | |||
|
|||
@Override | |||
public ExecutionMode getDefaultExecutionMode() { | |||
EnumConfigurationParameterConverter<ExecutionMode> converter = new EnumConfigurationParameterConverter<>( | |||
ExecutionMode.class, "parallel execution mode"); | |||
return converter.get(configurationParameters, DEFAULT_EXECUTION_MODE_PROPERTY_NAME, ExecutionMode.SAME_THREAD); | |||
} | |||
|
|||
@Override | |||
public Lifecycle getDefaultTestInstanceLifecycle() { | |||
EnumConfigurationParameterConverter<Lifecycle> converter = new EnumConfigurationParameterConverter<>( | |||
Lifecycle.class, "test instance lifecycle mode"); | |||
return converter.get(configurationParameters, DEFAULT_TEST_INSTANCE_LIFECYCLE_PROPERTY_NAME, | |||
Lifecycle.PER_METHOD); | |||
} | |||
|
|||
@Override | |||
public Optional<String> getDeactivateExecutionConditionsPattern() { | |||
// @formatter:off | |||
return configurationParameters.get(DEACTIVATE_CONDITIONS_PATTERN_PROPERTY_NAME) | |||
.filter(StringUtils::isNotBlank) | |||
.map(String::trim); | |||
// @formatter:on | |||
} | |||
} |
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
42 changes: 42 additions & 0 deletions
42
junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/config/JupiterConfiguration.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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,42 @@ | |||
/* | |||
* Copyright 2015-2018 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 | |||
* | |||
* http://www.eclipse.org/legal/epl-v20.html | |||
*/ | |||
|
|||
package org.junit.jupiter.engine.config; | |||
|
|||
import static org.apiguardian.api.API.Status.INTERNAL; | |||
|
|||
import java.util.Optional; | |||
|
|||
import org.apiguardian.api.API; | |||
import org.junit.jupiter.api.TestInstance; | |||
import org.junit.jupiter.api.parallel.ExecutionMode; | |||
|
|||
@API(status = INTERNAL, since = "5.4") | |||
public interface JupiterConfiguration { | |||
|
|||
String DEACTIVATE_CONDITIONS_PATTERN_PROPERTY_NAME = "junit.jupiter.conditions.deactivate"; | |||
String PARALLEL_EXECUTION_ENABLED_PROPERTY_NAME = "junit.jupiter.execution.parallel.enabled"; | |||
String DEFAULT_EXECUTION_MODE_PROPERTY_NAME = "junit.jupiter.execution.parallel.mode.default"; | |||
String EXTENSIONS_AUTODETECTION_ENABLED_PROPERTY_NAME = "junit.jupiter.extensions.autodetection.enabled"; | |||
String DEFAULT_TEST_INSTANCE_LIFECYCLE_PROPERTY_NAME = "junit.jupiter.testinstance.lifecycle.default"; | |||
|
|||
Optional<String> getRawConfigurationParameter(String key); | |||
|
|||
boolean isParallelExecutionEnabled(); | |||
|
|||
boolean isExtensionAutoDetectionEnabled(); | |||
|
|||
ExecutionMode getDefaultExecutionMode(); | |||
|
|||
TestInstance.Lifecycle getDefaultTestInstanceLifecycle(); | |||
|
|||
Optional<String> getDeactivateExecutionConditionsPattern(); | |||
|
|||
} |
5 changes: 5 additions & 0 deletions
5
junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/config/package-info.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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,5 @@ | |||
/** | |||
* Configuration specific to the JUnit Jupiter test engine. | |||
*/ | |||
|
|||
package org.junit.jupiter.engine.config; |
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
Oops, something went wrong.