Java 类org.springframework.boot.autoconfigure.condition.ConditionalOnJava.Range 实例源码

项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:OnJavaCondition.java   
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
        AnnotatedTypeMetadata metadata) {
    Map<String, Object> attributes = metadata
            .getAnnotationAttributes(ConditionalOnJava.class.getName());
    Range range = (Range) attributes.get("range");
    JavaVersion version = (JavaVersion) attributes.get("value");
    return getMatchOutcome(range, JVM_VERSION, version);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ConditionalOnJavaTests.java   
@Test
public void boundsTests() throws Exception {
    testBounds(Range.EQUAL_OR_NEWER, JavaVersion.SEVEN, JavaVersion.SIX, true);
    testBounds(Range.EQUAL_OR_NEWER, JavaVersion.SEVEN, JavaVersion.SEVEN, true);
    testBounds(Range.EQUAL_OR_NEWER, JavaVersion.SEVEN, JavaVersion.EIGHT, false);
    testBounds(Range.OLDER_THAN, JavaVersion.SEVEN, JavaVersion.SIX, false);
    testBounds(Range.OLDER_THAN, JavaVersion.SEVEN, JavaVersion.SEVEN, false);
    testBounds(Range.OLDER_THAN, JavaVersion.SEVEN, JavaVersion.EIGHT, true);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ConditionalOnJavaTests.java   
@Test
public void equalOrNewerMessage() throws Exception {
    ConditionOutcome outcome = this.condition.getMatchOutcome(Range.EQUAL_OR_NEWER,
            JavaVersion.SEVEN, JavaVersion.SIX);
    assertThat(outcome.getMessage())
            .isEqualTo("Required JVM version " + "1.6 or newer found 1.7");
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ConditionalOnJavaTests.java   
@Test
public void olderThanMessage() throws Exception {
    ConditionOutcome outcome = this.condition.getMatchOutcome(Range.OLDER_THAN,
            JavaVersion.SEVEN, JavaVersion.SIX);
    assertThat(outcome.getMessage())
            .isEqualTo("Required JVM version " + "older than 1.6 found 1.7");
}
项目:spring-boot-concourse    文件:OnJavaCondition.java   
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
        AnnotatedTypeMetadata metadata) {
    Map<String, Object> attributes = metadata
            .getAnnotationAttributes(ConditionalOnJava.class.getName());
    Range range = (Range) attributes.get("range");
    JavaVersion version = (JavaVersion) attributes.get("value");
    return getMatchOutcome(range, JVM_VERSION, version);
}
项目:spring-boot-concourse    文件:ConditionalOnJavaTests.java   
@Test
public void boundsTests() throws Exception {
    testBounds(Range.EQUAL_OR_NEWER, JavaVersion.SEVEN, JavaVersion.SIX, true);
    testBounds(Range.EQUAL_OR_NEWER, JavaVersion.SEVEN, JavaVersion.SEVEN, true);
    testBounds(Range.EQUAL_OR_NEWER, JavaVersion.SEVEN, JavaVersion.EIGHT, false);
    testBounds(Range.OLDER_THAN, JavaVersion.SEVEN, JavaVersion.SIX, false);
    testBounds(Range.OLDER_THAN, JavaVersion.SEVEN, JavaVersion.SEVEN, false);
    testBounds(Range.OLDER_THAN, JavaVersion.SEVEN, JavaVersion.EIGHT, true);
}
项目:spring-boot-concourse    文件:ConditionalOnJavaTests.java   
@Test
public void equalOrNewerMessage() throws Exception {
    ConditionOutcome outcome = this.condition.getMatchOutcome(Range.EQUAL_OR_NEWER,
            JavaVersion.SEVEN, JavaVersion.SIX);
    assertThat(outcome.getMessage())
            .isEqualTo("Required JVM version " + "1.6 or newer found 1.7");
}
项目:spring-boot-concourse    文件:ConditionalOnJavaTests.java   
@Test
public void olderThanMessage() throws Exception {
    ConditionOutcome outcome = this.condition.getMatchOutcome(Range.OLDER_THAN,
            JavaVersion.SEVEN, JavaVersion.SIX);
    assertThat(outcome.getMessage())
            .isEqualTo("Required JVM version " + "older than 1.6 found 1.7");
}
项目:contestparser    文件:OnJavaCondition.java   
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
        AnnotatedTypeMetadata metadata) {
    Map<String, Object> attributes = metadata
            .getAnnotationAttributes(ConditionalOnJava.class.getName());
    Range range = (Range) attributes.get("range");
    JavaVersion version = (JavaVersion) attributes.get("value");
    return getMatchOutcome(range, JVM_VERSION, version);
}
项目:contestparser    文件:ConditionalOnJavaTests.java   
@Test
public void boundsTests() throws Exception {
    testBounds(Range.EQUAL_OR_NEWER, JavaVersion.SEVEN, JavaVersion.SIX, true);
    testBounds(Range.EQUAL_OR_NEWER, JavaVersion.SEVEN, JavaVersion.SEVEN, true);
    testBounds(Range.EQUAL_OR_NEWER, JavaVersion.SEVEN, JavaVersion.EIGHT, false);
    testBounds(Range.OLDER_THAN, JavaVersion.SEVEN, JavaVersion.SIX, false);
    testBounds(Range.OLDER_THAN, JavaVersion.SEVEN, JavaVersion.SEVEN, false);
    testBounds(Range.OLDER_THAN, JavaVersion.SEVEN, JavaVersion.EIGHT, true);
}
项目:contestparser    文件:ConditionalOnJavaTests.java   
@Test
public void equalOrNewerMessage() throws Exception {
    ConditionOutcome outcome = this.condition.getMatchOutcome(Range.EQUAL_OR_NEWER,
            JavaVersion.SEVEN, JavaVersion.SIX);
    assertThat(outcome.getMessage(),
            equalTo("Required JVM version " + "1.6 or newer found 1.7"));
}
项目:contestparser    文件:ConditionalOnJavaTests.java   
@Test
public void olderThanMessage() throws Exception {
    ConditionOutcome outcome = this.condition.getMatchOutcome(Range.OLDER_THAN,
            JavaVersion.SEVEN, JavaVersion.SIX);
    assertThat(outcome.getMessage(),
            equalTo("Required JVM version " + "older than 1.6 found 1.7"));
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:OnJavaCondition.java   
protected ConditionOutcome getMatchOutcome(Range range, JavaVersion runningVersion,
        JavaVersion version) {
    boolean match = runningVersion.isWithin(range, version);
    return new ConditionOutcome(match, getMessage(range, runningVersion, version));
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:OnJavaCondition.java   
private String getMessage(Range range, JavaVersion runningVersion,
        JavaVersion version) {
    String expected = String.format(
            range == Range.EQUAL_OR_NEWER ? "%s or newer" : "older than %s", version);
    return "Required JVM version " + expected + " found " + runningVersion;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ConditionalOnJavaTests.java   
private void testBounds(Range range, JavaVersion runningVersion, JavaVersion version,
        boolean expected) {
    ConditionOutcome outcome = this.condition.getMatchOutcome(range, runningVersion,
            version);
    assertThat(outcome.isMatch()).as(outcome.getMessage()).isEqualTo(expected);
}
项目:spring-boot-concourse    文件:OnJavaCondition.java   
protected ConditionOutcome getMatchOutcome(Range range, JavaVersion runningVersion,
        JavaVersion version) {
    boolean match = runningVersion.isWithin(range, version);
    return new ConditionOutcome(match, getMessage(range, runningVersion, version));
}
项目:spring-boot-concourse    文件:OnJavaCondition.java   
private String getMessage(Range range, JavaVersion runningVersion,
        JavaVersion version) {
    String expected = String.format(
            range == Range.EQUAL_OR_NEWER ? "%s or newer" : "older than %s", version);
    return "Required JVM version " + expected + " found " + runningVersion;
}
项目:spring-boot-concourse    文件:ConditionalOnJavaTests.java   
private void testBounds(Range range, JavaVersion runningVersion, JavaVersion version,
        boolean expected) {
    ConditionOutcome outcome = this.condition.getMatchOutcome(range, runningVersion,
            version);
    assertThat(outcome.isMatch()).as(outcome.getMessage()).isEqualTo(expected);
}
项目:contestparser    文件:OnJavaCondition.java   
protected ConditionOutcome getMatchOutcome(Range range, JavaVersion runningVersion,
        JavaVersion version) {
    boolean match = runningVersion.isWithin(range, version);
    return new ConditionOutcome(match, getMessage(range, runningVersion, version));
}
项目:contestparser    文件:OnJavaCondition.java   
private String getMessage(Range range, JavaVersion runningVersion,
        JavaVersion version) {
    String expected = String.format(
            range == Range.EQUAL_OR_NEWER ? "%s or newer" : "older than %s", version);
    return "Required JVM version " + expected + " found " + runningVersion;
}
项目:contestparser    文件:ConditionalOnJavaTests.java   
private void testBounds(Range range, JavaVersion runningVersion, JavaVersion version,
        boolean expected) {
    ConditionOutcome outcome = this.condition.getMatchOutcome(range, runningVersion,
            version);
    assertThat(outcome.getMessage(), outcome.isMatch(), equalTo(expected));
}