org.springframework.boot.context.properties.ConfigurationPropertiesBindException Java Examples

The following examples show how to use org.springframework.boot.context.properties.ConfigurationPropertiesBindException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: KafkaBinderJaasInitializerListenerTest.java    From spring-cloud-stream-binder-kafka with Apache License 2.0 6 votes vote down vote up
@Test
public void testConfigurationWithUnknownControlFlag() throws Exception {
	ConfigFile configFile = new ConfigFile(
			new ClassPathResource("jaas-sample-kafka-only.conf").getURI());

	assertThatThrownBy(() -> SpringApplication.run(SimpleApplication.class,
			"--spring.cloud.stream.kafka.binder.jaas.options.useKeyTab=true",
			"--spring.cloud.stream.kafka.binder.jaas.controlFlag=unknown",
			"--spring.cloud.stream.kafka.binder.jaas.options.storeKey=true",
			"--spring.cloud.stream.kafka.binder.jaas.options.keyTab=/etc/security/keytabs/kafka_client.keytab",
			"--spring.cloud.stream.kafka.binder.jaas.options.principal=kafka-client-1@EXAMPLE.COM",
			"--spring.jmx.enabled=false"))
					.isInstanceOf(ConfigurationPropertiesBindException.class)
					.hasMessageContaining(
							"Error creating bean with name 'configurationProperties'");
}
 
Example #2
Source File: PropertiesInvalidInputTest.java    From code-examples with MIT License 5 votes vote down vote up
@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]");

}
 
Example #3
Source File: PropertiesInvalidInputTest.java    From code-examples with MIT License 5 votes vote down vote up
@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]");

}
 
Example #4
Source File: PropertiesInvalidInputTest.java    From code-examples with MIT License 5 votes vote down vote up
@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]");

}
 
Example #5
Source File: PropertiesInvalidInputTest.java    From code-examples with MIT License 5 votes vote down vote up
@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]");

}
 
Example #6
Source File: PropertiesInvalidInputTest.java    From code-examples with MIT License 5 votes vote down vote up
@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]");

}
 
Example #7
Source File: PropertiesInvalidInputTest.java    From code-examples with MIT License 5 votes vote down vote up
@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]");

}
 
Example #8
Source File: PropertiesInvalidInputTest.java    From code-examples with MIT License 5 votes vote down vote up
@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]");

}
 
Example #9
Source File: ServiceBrokerPropertiesBindingTest.java    From spring-cloud-open-service-broker with Apache License 2.0 5 votes vote down vote up
@Test
void bindInvalidProperties() {
	this.context.register(ServiceBrokerPropertiesConfiguration.class);
	TestPropertyValues.of("spring.cloud.openservicebroker.catalog.services[0].id:service-one-id")
			.applyTo(this.context);
	assertThrows(ConfigurationPropertiesBindException.class, this.context::refresh);
}
 
Example #10
Source File: BindingHandlerAdviseTests.java    From spring-cloud-stream with Apache License 2.0 5 votes vote down vote up
@Test(expected = ConfigurationPropertiesBindException.class)
public void validatedConfigProperties() {
	new SpringApplicationBuilder(ValidatedConfiguration.class).web(WebApplicationType.NONE)
			.run("--spring.jmx.enabled=false");

	fail();
}
 
Example #11
Source File: CxfAutoConfigurationTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@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");
}