diff --git a/spring-all/src/main/java/org/baeldung/properties/core/ComponentInXmlUsingProperties.java b/spring-all/src/main/java/org/baeldung/properties/core/ComponentInXmlUsingProperties.java index f695326cd6..dbdcebcb36 100644 --- a/spring-all/src/main/java/org/baeldung/properties/core/ComponentInXmlUsingProperties.java +++ b/spring-all/src/main/java/org/baeldung/properties/core/ComponentInXmlUsingProperties.java @@ -16,7 +16,7 @@ public class ComponentInXmlUsingProperties implements InitializingBean { public ComponentInXmlUsingProperties(final String propertyValue) { super(); - System.out.println("Constructor Injection - Property Value resolted to: " + propertyValue); + System.out.println("Constructor Injection - Property Value resolved to: " + propertyValue); } // diff --git a/spring-all/src/test/java/org/baeldung/properties/core/ExternalPropertiesWithJavaIntegrationTest.java b/spring-all/src/test/java/org/baeldung/properties/core/ExternalPropertiesWithJavaIntegrationTest.java new file mode 100644 index 0000000000..bfc2f52579 --- /dev/null +++ b/spring-all/src/test/java/org/baeldung/properties/core/ExternalPropertiesWithJavaIntegrationTest.java @@ -0,0 +1,36 @@ +package org.baeldung.properties.core; + +import org.baeldung.properties.spring.PropertiesWithJavaConfig; +import org.baeldung.properties.spring.PropertiesWithJavaConfigOther; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.core.env.Environment; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { PropertiesWithJavaConfig.class, PropertiesWithJavaConfigOther.class }, loader = AnnotationConfigContextLoader.class) +public class ExternalPropertiesWithJavaIntegrationTest { + + @Autowired + private Environment env; + + @Value("${key.something}") + private String injectedProperty; + + @Value("${external.something}") + private String injectedExternalProperty; + + @Test + public final void givenContextIsInitialized_thenNoException() { + System.out.println("in test via @Value: " + injectedProperty); + System.out.println("in test Environment: " + env.getProperty("key.something")); + + System.out.println("in test via @Value - external: " + injectedExternalProperty); + System.out.println("in test Environment - external: " + env.getProperty("external.something")); + } + +} diff --git a/spring-all/src/test/java/org/baeldung/properties/core/ExternalPropertiesWithMultipleXmlsIntegrationTest.java b/spring-all/src/test/java/org/baeldung/properties/core/ExternalPropertiesWithMultipleXmlsIntegrationTest.java new file mode 100644 index 0000000000..6391b8d655 --- /dev/null +++ b/spring-all/src/test/java/org/baeldung/properties/core/ExternalPropertiesWithMultipleXmlsIntegrationTest.java @@ -0,0 +1,36 @@ +package org.baeldung.properties.core; + +import org.baeldung.properties.spring.PropertiesWithXmlConfigOne; +import org.baeldung.properties.spring.PropertiesWithXmlConfigTwo; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.core.env.Environment; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { PropertiesWithXmlConfigOne.class, PropertiesWithXmlConfigTwo.class }, loader = AnnotationConfigContextLoader.class) +public class ExternalPropertiesWithMultipleXmlsIntegrationTest { + + @Autowired + private Environment env; + + @Value("${key.something}") + private String injectedProperty; + + @Value("${external.something}") + private String injectedExternalProperty; + + @Test + public final void givenContextIsInitialized_thenNoException() { + System.out.println("in test via @Value: " + injectedProperty); + System.out.println("in test Environment: " + env.getProperty("key.something")); + + System.out.println("in test via @Value - external: " + injectedExternalProperty); + System.out.println("in test Environment - external: " + env.getProperty("external.something")); + } + +} diff --git a/spring-all/src/test/java/org/baeldung/properties/core/ExternalPropertiesWithXmlIntegrationTest.java b/spring-all/src/test/java/org/baeldung/properties/core/ExternalPropertiesWithXmlIntegrationTest.java new file mode 100644 index 0000000000..0d437842e6 --- /dev/null +++ b/spring-all/src/test/java/org/baeldung/properties/core/ExternalPropertiesWithXmlIntegrationTest.java @@ -0,0 +1,35 @@ +package org.baeldung.properties.core; + +import org.baeldung.properties.spring.PropertiesWithXmlConfig; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.core.env.Environment; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { PropertiesWithXmlConfig.class }, loader = AnnotationConfigContextLoader.class) +public class ExternalPropertiesWithXmlIntegrationTest { + + @Autowired + private Environment env; + + @Value("${key.something}") + private String injectedProperty; + + @Value("${external.something}") + private String injectedExternalProperty; + + @Test + public final void givenContextIsInitialized_thenNoException() { + System.out.println("in test via @Value: " + injectedProperty); + System.out.println("in test Environment: " + env.getProperty("key.something")); + + System.out.println("in test via @Value - external: " + injectedExternalProperty); + System.out.println("in test Environment - external: " + env.getProperty("external.something")); + } + +}