| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
package org.junit.jupiter.api.condition; |
| 12 |
|
| 13 |
import java.util.Arrays; |
| 14 |
|
| 15 |
import org.junit.jupiter.api.extension.ExecutionCondition; |
| 16 |
import org.junit.platform.commons.util.Preconditions; |
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
class EnabledOnJreCondition extends BooleanExecutionCondition<EnabledOnJre> { |
| 25 |
|
| 26 |
static final String ENABLED_ON_CURRENT_JRE = |
| 27 |
"Enabled on JRE version: " + System.getProperty("java.version"); |
| 28 |
|
| 29 |
static final String DISABLED_ON_CURRENT_JRE = |
| 30 |
"Disabled on JRE version: " + System.getProperty("java.version"); |
| 31 |
|
| 32 |
EnabledOnJreCondition() { |
| 33 |
super(EnabledOnJre.class, ENABLED_ON_CURRENT_JRE, DISABLED_ON_CURRENT_JRE, EnabledOnJre::disabledReason); |
| 34 |
} |
| 35 |
|
| 36 |
@Override |
| 37 |
boolean isEnabled(EnabledOnJre annotation) { |
| 38 |
JRE[] versions = annotation.value(); |
| 39 |
Preconditions.condition(versions.length > 0, "You must declare at least one JRE in @EnabledOnJre"); |
| 40 |
return Arrays.stream(versions).anyMatch(JRE::isCurrentVersion); |
| 41 |
} |
| 42 |
|
| 43 |
} |