org.springframework.boot.context.properties.bind.validation.BindValidationException源码实例Demo

类org.springframework.boot.context.properties.bind.validation.BindValidationException源码实例Demo

下面列出了org.springframework.boot.context.properties.bind.validation.BindValidationException 类实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: liiklus   文件: RSocketConfigurationTest.java
@Test
void shouldRequireGatewayProfile() {
    applicationContextRunner = applicationContextRunner.withPropertyValues(
            "spring.profiles.active: not_gateway"
    );
    applicationContextRunner.run(context -> {
        assertThat(context).doesNotHaveBean(RSocketLiiklusService.class);
    });
    applicationContextRunner = applicationContextRunner.withPropertyValues(
            "spring.profiles.active: gateway"
    );
    applicationContextRunner.run(context -> {
        assertThat(context)
                .getFailure()
                .hasCauseInstanceOf(BindValidationException.class);
    });
}
 
源代码2 项目: liiklus   文件: RSocketConfigurationTest.java
@Test
void shouldValidateParameters() {
    applicationContextRunner = applicationContextRunner.withPropertyValues(
            "spring.profiles.active: gateway"
    );
    applicationContextRunner.run(context -> {
        assertThat(context)
                .getFailure()
                .hasCauseInstanceOf(BindValidationException.class);
    });
    applicationContextRunner = applicationContextRunner.withPropertyValues(
            "rsocket.host: localhost"
    );
    applicationContextRunner.run(context -> {
        assertThat(context)
                .getFailure()
                .hasCauseInstanceOf(BindValidationException.class);
    });
    applicationContextRunner = applicationContextRunner.withPropertyValues(
            "rsocket.port: 0"
    );
    applicationContextRunner.run(context -> {
        assertThat(context)
                .hasNotFailed();
    });
}
 
源代码3 项目: liiklus   文件: DynamoDBConfigurationTest.java
@Test
void shouldValidateProperties() {
    applicationContextRunner = applicationContextRunner.withPropertyValues(
            "storage.positions.type: DYNAMODB"
    );
    applicationContextRunner.run(context -> {
        assertThat(context)
                .getFailure()
                .hasCauseInstanceOf(BindValidationException.class);
    });
    applicationContextRunner = applicationContextRunner.withPropertyValues(
            "dynamodb.positionsTable: foo"
    );
    applicationContextRunner.run(context -> {
        assertThat(context).hasNotFailed();
    });
}
 
源代码4 项目: liiklus   文件: RedisPositionsConfigurationTest.java
@Test
void should_validate_properties() {
    applicationContextRunner = applicationContextRunner.withPropertyValues(
            "storage.positions.type: REDIS"
    );
    applicationContextRunner.run(context -> {
        assertThat(context)
                .getFailure()
                .hasCauseInstanceOf(BindValidationException.class);
    });
    applicationContextRunner = applicationContextRunner.withPropertyValues(
            "redis.host: host"
    );
    applicationContextRunner.run(context -> {
        assertThat(context)
                .getFailure()
                .hasCauseInstanceOf(BindValidationException.class);
    });
    applicationContextRunner = applicationContextRunner.withPropertyValues(
            "redis.port: 8888"
    );
    applicationContextRunner.run(context -> {
        assertThat(context).hasNotFailed();
    });
}
 
@Test
void shouldValidateProperties() {
    applicationContextRunner = applicationContextRunner.withPropertyValues(
            "spring.profiles.active: gateway",
            "storage.records.type: PULSAR"
    );
    applicationContextRunner.run(context -> {
        assertThat(context)
                .getFailure()
                .hasCauseInstanceOf(BindValidationException.class);
    });
    applicationContextRunner = applicationContextRunner.withPropertyValues(
            "pulsar.serviceUrl: host:6650"
    );
    applicationContextRunner.run(context -> {
        assertThat(context).hasSingleBean(PulsarRecordsStorage.class);
    });
}
 
@Test
void shouldValidateProperties() {
    applicationContextRunner = applicationContextRunner.withPropertyValues(
            "spring.profiles.active: gateway",
            "storage.records.type: KAFKA"
    );
    applicationContextRunner.run(context -> {
        assertThat(context)
                .getFailure()
                .hasCauseInstanceOf(BindValidationException.class);
    });
    applicationContextRunner = applicationContextRunner.withPropertyValues(
            "kafka.bootstrapServers: host:9092"
    );
    applicationContextRunner.run(context -> {
        assertThat(context).hasSingleBean(KafkaRecordsStorage.class);
    });
}
 
源代码7 项目: liiklus   文件: GRPCConfigurationTest.java
@Test
void shouldRequireGatewayProfile() {
    applicationContextRunner = applicationContextRunner.withPropertyValues(
            "spring.profiles.active: not_gateway"
    );
    applicationContextRunner.run(context -> {
        assertThat(context).doesNotHaveBean(GRPCLiiklusService.class);
    });
    applicationContextRunner = applicationContextRunner.withPropertyValues(
            "spring.profiles.active: gateway"
    );
    applicationContextRunner.run(context -> {
        assertThat(context)
                .getFailure()
                .hasCauseInstanceOf(BindValidationException.class);
    });
}
 
源代码8 项目: liiklus   文件: GRPCConfigurationTest.java
@Test
void shouldValidateParameters() {
    applicationContextRunner = applicationContextRunner.withPropertyValues(
            "spring.profiles.active: gateway"
    );
    applicationContextRunner.run(context -> {
        assertThat(context)
                .getFailure()
                .hasCauseInstanceOf(BindValidationException.class);
    });
    applicationContextRunner = applicationContextRunner.withPropertyValues(
            "grpc.port: 0"
    );
    applicationContextRunner.run(context -> {
        assertThat(context)
                .hasNotFailed();
    });
}
 
源代码9 项目: liiklus   文件: GRPCAuthConfigurationTest.java
@Test
void shouldValidateParametersHmac512() {
    applicationContextRunner = applicationContextRunner.withPropertyValues(
            "spring.profiles.active: not_gateway",
            "grpc.auth.alg: HMAC512"
    );
    applicationContextRunner.run(context -> {
        assertThat(context)
                .getFailure()
                .hasCauseInstanceOf(BindValidationException.class);
    });
}
 
源代码10 项目: liiklus   文件: GRPCAuthConfigurationTest.java
@Test
void shouldValidateParametersRsa512() {
    applicationContextRunner = applicationContextRunner.withPropertyValues(
            "spring.profiles.active: not_gateway",
            "grpc.auth.alg: RSA512"
    );
    applicationContextRunner.run(context -> {
        assertThat(context)
                .getFailure()
                .hasCauseInstanceOf(BindValidationException.class);
    });
}
 
源代码11 项目: code-examples   文件: PropertiesInvalidInputTest.java
@Test
void whenGivenNameEmpty_thenNotBlankValidationFails() {

    properties.put("app.properties.name", "");

    assertThatThrownBy(application::run)
            .isInstanceOf(ConfigurationPropertiesBindException.class)
            .hasRootCauseInstanceOf(BindValidationException.class)
            .hasStackTraceContaining("Field error in object 'app.properties' on field 'name'")
            .hasStackTraceContaining("[must not be blank]");

}
 
源代码12 项目: code-examples   文件: PropertiesInvalidInputTest.java
@Test
void whenGivenNameDoesNotContainBaseName_thenCustomAppPropertiesValidatorFails() {

    properties.put("app.properties.name", "My App");

    assertThatThrownBy(application::run)
            .isInstanceOf(ConfigurationPropertiesBindException.class)
            .hasRootCauseInstanceOf(BindValidationException.class)
            .hasStackTraceContaining("Field error in object 'app.properties' on field 'name'")
            .hasStackTraceContaining("[The application name must contain [Application] base name]");

}
 
源代码13 项目: code-examples   文件: PropertiesInvalidInputTest.java
@Test
void whenGivenReportIntervalInDaysMoreThan30_thenMaxValidationFails() {

    properties.put("app.properties.report.interval-in-days", "31");

    assertThatThrownBy(application::run)
            .isInstanceOf(ConfigurationPropertiesBindException.class)
            .hasRootCauseInstanceOf(BindValidationException.class)
            .hasStackTraceContaining("rejected value [31]");

}
 
源代码14 项目: code-examples   文件: PropertiesInvalidInputTest.java
@Test
void whenGivenReportIntervalInDaysLessThan7_thenMinValidationFails() {

    properties.put("app.properties.report.interval-in-days", "6");

    assertThatThrownBy(application::run)
            .isInstanceOf(ConfigurationPropertiesBindException.class)
            .hasRootCauseInstanceOf(BindValidationException.class)
            .hasStackTraceContaining("rejected value [6]");

}
 
源代码15 项目: code-examples   文件: PropertiesInvalidInputTest.java
@Test
void whenGivenReportEmailAddressIsNotWellFormed_thenEmailValidationFails() {

    properties.put("app.properties.report.email-address", "manager.analysisapp.com");

    assertThatThrownBy(application::run)
            .isInstanceOf(ConfigurationPropertiesBindException.class)
            .hasRootCauseInstanceOf(BindValidationException.class)
            .hasStackTraceContaining("rejected value [manager.analysisapp.com]");

}
 
源代码16 项目: code-examples   文件: PropertiesInvalidInputTest.java
@Test
void whenGivenReportEmailAddressDoesNotContainAnalysisappDomain_thenCustomEmailValidatorFails() {

    properties.put("app.properties.report.email-address", "[email protected]");

    assertThatThrownBy(application::run)
            .isInstanceOf(ConfigurationPropertiesBindException.class)
            .hasRootCauseInstanceOf(BindValidationException.class)
            .hasStackTraceContaining("Field error in object 'app.properties.report' on field 'emailAddress'")
            .hasStackTraceContaining("[The email address must contain [@analysisapp.com] domain]");

}
 
源代码17 项目: code-examples   文件: PropertiesInvalidInputTest.java
@Test
void whenGivenThirdPartyComponentNameIsEmpty_thenNotBlankValidationFails() {

    properties.put("app.third-party.properties.name", "");

    assertThatThrownBy(application::run)
            .isInstanceOf(ConfigurationPropertiesBindException.class)
            .hasRootCauseInstanceOf(BindValidationException.class)
            .hasStackTraceContaining("Field error in object 'app.third-party.properties' on field 'name'")
            .hasStackTraceContaining("[must not be blank]");

}
 
源代码18 项目: cxf   文件: CxfAutoConfigurationTest.java
@Test
public void customPathMustBeginWithASlash() {
    this.thrown.expect(UnsatisfiedDependencyException.class);
    this.thrown.expectCause(
        allOf(instanceOf(ConfigurationPropertiesBindException.class), hasProperty("cause", 
            allOf(instanceOf(BindException.class), hasProperty("cause",
                allOf(instanceOf(BindValidationException.class), 
                    hasProperty("message", containsString("Path must start with /"))))))));
    load(CxfAutoConfiguration.class, "cxf.path=invalid");
}
 
源代码评论
动弹
沙发等你来抢
 类所在包
 类方法
 同包方法