@Test public void unknownFieldFailureMessageContainsDetailsOfPropertyOrigin() { this.context = new AnnotationConfigApplicationContext(); TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.context, "com.example.baz=spam"); this.context.register(TestConfiguration.class); try { this.context.refresh(); fail("Expected exception"); } catch (BeanCreationException ex) { RelaxedBindingNotWritablePropertyException bex = (RelaxedBindingNotWritablePropertyException) ex .getRootCause(); assertThat(bex.getMessage()) .startsWith("Failed to bind 'com.example.baz' from '" + TestPropertySourceUtils.INLINED_PROPERTIES_PROPERTY_SOURCE_NAME + "' to 'baz' " + "property on '" + TestConfiguration.class.getName()); } }
@Test public void unknownFieldFailureMessageContainsDetailsOfPropertyOrigin() { this.context = new AnnotationConfigApplicationContext(); EnvironmentTestUtils.addEnvironment(this.context, "com.example.baz:spam"); this.context.register(TestConfiguration.class); try { this.context.refresh(); fail("Expected exception"); } catch (BeanCreationException ex) { RelaxedBindingNotWritablePropertyException bex = (RelaxedBindingNotWritablePropertyException) ex .getRootCause(); assertThat(bex.getMessage(), startsWith("Failed to bind 'com.example.baz' from 'test' to 'baz' " + "property on '" + TestConfiguration.class.getName())); } }