| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
package org.junit.jupiter.api.condition; |
| 12 |
|
| 13 |
import static org.junit.jupiter.api.condition.EnabledOnJreCondition.DISABLED_ON_CURRENT_JRE; |
| 14 |
import static org.junit.jupiter.api.condition.EnabledOnJreCondition.ENABLED_ON_CURRENT_JRE; |
| 15 |
|
| 16 |
import org.junit.jupiter.api.extension.ExecutionCondition; |
| 17 |
import org.junit.platform.commons.util.Preconditions; |
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
class EnabledForJreRangeCondition extends BooleanExecutionCondition<EnabledForJreRange> { |
| 26 |
|
| 27 |
EnabledForJreRangeCondition() { |
| 28 |
super(EnabledForJreRange.class, ENABLED_ON_CURRENT_JRE, DISABLED_ON_CURRENT_JRE, |
| 29 |
EnabledForJreRange::disabledReason); |
| 30 |
} |
| 31 |
|
| 32 |
@Override |
| 33 |
boolean isEnabled(EnabledForJreRange annotation) { |
| 34 |
JRE min = annotation.min(); |
| 35 |
JRE max = annotation.max(); |
| 36 |
|
| 37 |
Preconditions.condition((min != JRE.JAVA_8 || max != JRE.OTHER), |
| 38 |
"You must declare a non-default value for min or max in @EnabledForJreRange"); |
| 39 |
Preconditions.condition(max.compareTo(min) >= 0, |
| 40 |
"@EnabledForJreRange.min must be less than or equal to @EnabledForJreRange.max"); |
| 41 |
|
| 42 |
return JRE.isCurrentVersionWithinRange(min, max); |
| 43 |
} |
| 44 |
|
| 45 |
} |