persistence work
This commit is contained in:
parent
393c1eac14
commit
446bf7fbbd
25
spring-all/src/main/java/org/baeldung/properties/external/ExternalPropertiesWithJavaConfig.java
vendored
Normal file
25
spring-all/src/main/java/org/baeldung/properties/external/ExternalPropertiesWithJavaConfig.java
vendored
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
package org.baeldung.properties.external;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.context.annotation.PropertySource;
|
||||||
|
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@ComponentScan("org.baeldung.properties.core")
|
||||||
|
@PropertySource("classpath:foo.properties")
|
||||||
|
public class ExternalPropertiesWithJavaConfig {
|
||||||
|
|
||||||
|
public ExternalPropertiesWithJavaConfig() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
// beans
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
|
||||||
|
return new PropertySourcesPlaceholderConfigurer();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -7,9 +7,9 @@ import org.springframework.context.annotation.ImportResource;
|
|||||||
@Configuration
|
@Configuration
|
||||||
@ImportResource("classpath:configForProperties.xml")
|
@ImportResource("classpath:configForProperties.xml")
|
||||||
@ComponentScan("org.baeldung.core")
|
@ComponentScan("org.baeldung.core")
|
||||||
public class PropertiesWithXmlConfig {
|
public class ExternalPropertiesWithXmlConfig {
|
||||||
|
|
||||||
public PropertiesWithXmlConfig() {
|
public ExternalPropertiesWithXmlConfig() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
@ -7,9 +7,9 @@ import org.springframework.context.annotation.ImportResource;
|
|||||||
@Configuration
|
@Configuration
|
||||||
@ImportResource("classpath:configForPropertiesOne.xml")
|
@ImportResource("classpath:configForPropertiesOne.xml")
|
||||||
@ComponentScan("org.baeldung.core")
|
@ComponentScan("org.baeldung.core")
|
||||||
public class PropertiesWithXmlConfigOne {
|
public class ExternalPropertiesWithXmlConfigOne {
|
||||||
|
|
||||||
public PropertiesWithXmlConfigOne() {
|
public ExternalPropertiesWithXmlConfigOne() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
@ -5,9 +5,9 @@ import org.springframework.context.annotation.ImportResource;
|
|||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@ImportResource("classpath:basicConfigForPropertiesTwo.xml")
|
@ImportResource("classpath:basicConfigForPropertiesTwo.xml")
|
||||||
public class PropertiesWithXmlConfigTwo {
|
public class ExternalPropertiesWithXmlConfigTwo {
|
||||||
|
|
||||||
public PropertiesWithXmlConfigTwo() {
|
public ExternalPropertiesWithXmlConfigTwo() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
@ -1,9 +1,7 @@
|
|||||||
package org.baeldung.properties.spring;
|
package org.baeldung.properties.spring;
|
||||||
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.PropertySource;
|
import org.springframework.context.annotation.PropertySource;
|
||||||
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
|
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@PropertySource("classpath:foo.properties")
|
@PropertySource("classpath:foo.properties")
|
||||||
@ -13,11 +11,4 @@ public class BasicPropertiesWithJavaConfig {
|
|||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
// beans
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
|
|
||||||
return new PropertySourcesPlaceholderConfigurer();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
@ -1,13 +1,11 @@
|
|||||||
package org.baeldung.properties.external;
|
package org.baeldung.properties.spring;
|
||||||
|
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.PropertySource;
|
import org.springframework.context.annotation.PropertySource;
|
||||||
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
|
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@ComponentScan("org.baeldung.properties.core")
|
|
||||||
@PropertySource("classpath:foo.properties")
|
@PropertySource("classpath:foo.properties")
|
||||||
public class PropertiesWithJavaConfig {
|
public class PropertiesWithJavaConfig {
|
||||||
|
|
@ -0,0 +1,29 @@
|
|||||||
|
package org.baeldung.properties.basic;
|
||||||
|
|
||||||
|
import org.baeldung.properties.spring.BasicPropertiesWithJavaConfig;
|
||||||
|
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 = { BasicPropertiesWithJavaConfig.class }, loader = AnnotationConfigContextLoader.class)
|
||||||
|
public class BasicPropertiesWithJavaIntegrationTest {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private Environment env;
|
||||||
|
|
||||||
|
@Value("${key.something}")
|
||||||
|
private String injectedProperty;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public final void givenContextIsInitialized_thenNoException() {
|
||||||
|
System.out.println("in test via @Value: " + injectedProperty);
|
||||||
|
System.out.println("in test Environment: " + env.getProperty("key.something"));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
package org.baeldung.properties.basic;
|
||||||
|
|
||||||
|
import org.baeldung.properties.spring.BasicPropertiesWithJavaConfig;
|
||||||
|
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 = { BasicPropertiesWithJavaConfig.class, PropertiesWithJavaConfigOther.class }, loader = AnnotationConfigContextLoader.class)
|
||||||
|
public class ExtendedPropertiesWithJavaIntegrationTest {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private Environment env;
|
||||||
|
|
||||||
|
@Value("${key.something}")
|
||||||
|
private String injectedProperty;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public final void givenContextIsInitialized_thenNoException() {
|
||||||
|
System.out.println("in test via @Value: " + injectedProperty);
|
||||||
|
System.out.println("in test Environment: " + env.getProperty("key.something"));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,7 +1,6 @@
|
|||||||
package org.baeldung.properties.basic;
|
package org.baeldung.properties.basic;
|
||||||
|
|
||||||
import org.baeldung.properties.spring.BasicPropertiesWithJavaConfig;
|
import org.baeldung.properties.spring.PropertiesWithJavaConfig;
|
||||||
import org.baeldung.properties.spring.PropertiesWithJavaConfigOther;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@ -12,7 +11,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
|||||||
import org.springframework.test.context.support.AnnotationConfigContextLoader;
|
import org.springframework.test.context.support.AnnotationConfigContextLoader;
|
||||||
|
|
||||||
@RunWith(SpringJUnit4ClassRunner.class)
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
@ContextConfiguration(classes = { BasicPropertiesWithJavaConfig.class, PropertiesWithJavaConfigOther.class }, loader = AnnotationConfigContextLoader.class)
|
@ContextConfiguration(classes = { PropertiesWithJavaConfig.class }, loader = AnnotationConfigContextLoader.class)
|
||||||
public class PropertiesWithJavaIntegrationTest {
|
public class PropertiesWithJavaIntegrationTest {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
@ -12,7 +12,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
|||||||
import org.springframework.test.context.support.AnnotationConfigContextLoader;
|
import org.springframework.test.context.support.AnnotationConfigContextLoader;
|
||||||
|
|
||||||
@RunWith(SpringJUnit4ClassRunner.class)
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
@ContextConfiguration(classes = { PropertiesWithJavaConfig.class, PropertiesWithJavaConfigOther.class }, loader = AnnotationConfigContextLoader.class)
|
@ContextConfiguration(classes = { ExternalPropertiesWithJavaConfig.class, PropertiesWithJavaConfigOther.class }, loader = AnnotationConfigContextLoader.class)
|
||||||
@Ignore("manual only")
|
@Ignore("manual only")
|
||||||
public class ExternalPropertiesWithJavaIntegrationTest {
|
public class ExternalPropertiesWithJavaIntegrationTest {
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
|||||||
import org.springframework.test.context.support.AnnotationConfigContextLoader;
|
import org.springframework.test.context.support.AnnotationConfigContextLoader;
|
||||||
|
|
||||||
@RunWith(SpringJUnit4ClassRunner.class)
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
@ContextConfiguration(classes = { PropertiesWithXmlConfigOne.class, PropertiesWithXmlConfigTwo.class }, loader = AnnotationConfigContextLoader.class)
|
@ContextConfiguration(classes = { ExternalPropertiesWithXmlConfigOne.class, ExternalPropertiesWithXmlConfigTwo.class }, loader = AnnotationConfigContextLoader.class)
|
||||||
@Ignore("manual only")
|
@Ignore("manual only")
|
||||||
public class ExternalPropertiesWithMultipleXmlsIntegrationTest {
|
public class ExternalPropertiesWithMultipleXmlsIntegrationTest {
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
|||||||
import org.springframework.test.context.support.AnnotationConfigContextLoader;
|
import org.springframework.test.context.support.AnnotationConfigContextLoader;
|
||||||
|
|
||||||
@RunWith(SpringJUnit4ClassRunner.class)
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
@ContextConfiguration(classes = { PropertiesWithXmlConfig.class }, loader = AnnotationConfigContextLoader.class)
|
@ContextConfiguration(classes = { ExternalPropertiesWithXmlConfig.class }, loader = AnnotationConfigContextLoader.class)
|
||||||
@Ignore("manual only")
|
@Ignore("manual only")
|
||||||
public class ExternalPropertiesWithXmlIntegrationTest {
|
public class ExternalPropertiesWithXmlIntegrationTest {
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package org.baeldung.test;
|
package org.baeldung.test;
|
||||||
|
|
||||||
import org.baeldung.properties.basic.PropertiesWithJavaIntegrationTest;
|
import org.baeldung.properties.basic.ExtendedPropertiesWithJavaIntegrationTest;
|
||||||
import org.baeldung.properties.basic.PropertiesWithMultipleXmlsIntegrationTest;
|
import org.baeldung.properties.basic.PropertiesWithMultipleXmlsIntegrationTest;
|
||||||
import org.baeldung.properties.basic.PropertiesWithXmlIntegrationTest;
|
import org.baeldung.properties.basic.PropertiesWithXmlIntegrationTest;
|
||||||
import org.baeldung.properties.external.ExternalPropertiesWithJavaIntegrationTest;
|
import org.baeldung.properties.external.ExternalPropertiesWithJavaIntegrationTest;
|
||||||
@ -16,7 +16,7 @@ import org.junit.runners.Suite.SuiteClasses;
|
|||||||
ExternalPropertiesWithJavaIntegrationTest.class,
|
ExternalPropertiesWithJavaIntegrationTest.class,
|
||||||
ExternalPropertiesWithMultipleXmlsIntegrationTest.class,
|
ExternalPropertiesWithMultipleXmlsIntegrationTest.class,
|
||||||
ExternalPropertiesWithXmlIntegrationTest.class,
|
ExternalPropertiesWithXmlIntegrationTest.class,
|
||||||
PropertiesWithJavaIntegrationTest.class,
|
ExtendedPropertiesWithJavaIntegrationTest.class,
|
||||||
PropertiesWithMultipleXmlsIntegrationTest.class,
|
PropertiesWithMultipleXmlsIntegrationTest.class,
|
||||||
})// @formatter:on
|
})// @formatter:on
|
||||||
public final class IntegrationTestSuite {
|
public final class IntegrationTestSuite {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user