Java 4278 update override properties article (#10555)
* JAVA-4278 Update "Override Properties" article * JAVA-4278 Update override properties article (use JUnit 5) Co-authored-by: mikr <michael.krimgen@ximedes.com>
This commit is contained in:
parent
15f373230f
commit
8df2f0f841
@ -1,15 +1,14 @@
|
||||
package com.baeldung.overrideproperties;
|
||||
|
||||
import com.baeldung.overrideproperties.resolver.PropertySourceResolver;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
@ContextConfiguration(initializers = PropertyOverrideContextInitializer.class, classes = Application.class)
|
||||
public class ContextPropertySourceResolverIntegrationTest {
|
||||
|
||||
|
@ -1,18 +1,17 @@
|
||||
package com.baeldung.overrideproperties;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||
|
||||
import com.baeldung.overrideproperties.resolver.PropertySourceResolver;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
@SpringBootTest
|
||||
@ActiveProfiles("test")
|
||||
@EnableWebMvc
|
||||
|
@ -12,6 +12,6 @@ public class PropertyOverrideContextInitializer implements ApplicationContextIni
|
||||
public void initialize(ConfigurableApplicationContext configurableApplicationContext) {
|
||||
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(configurableApplicationContext, "example.firstProperty=" + PROPERTY_FIRST_VALUE);
|
||||
|
||||
TestPropertySourceUtils.addPropertiesFilesToEnvironment(configurableApplicationContext, "context-override-application.properties");
|
||||
TestPropertySourceUtils.addPropertiesFilesToEnvironment(configurableApplicationContext, "classpath:context-override-application.properties");
|
||||
}
|
||||
}
|
||||
|
@ -1,16 +1,16 @@
|
||||
package com.baeldung.overrideproperties;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||
|
||||
import com.baeldung.overrideproperties.resolver.PropertySourceResolver;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
@SpringBootTest(properties = { "example.firstProperty=annotation" })
|
||||
@EnableWebMvc
|
||||
public class SpringBootPropertySourceResolverIntegrationTest {
|
||||
@ -23,8 +23,8 @@ public class SpringBootPropertySourceResolverIntegrationTest {
|
||||
final String firstProperty = propertySourceResolver.getFirstProperty();
|
||||
final String secondProperty = propertySourceResolver.getSecondProperty();
|
||||
|
||||
Assert.assertEquals("annotation", firstProperty);
|
||||
Assert.assertEquals("file", secondProperty);
|
||||
assertEquals("annotation", firstProperty);
|
||||
assertEquals("file", secondProperty);
|
||||
}
|
||||
|
||||
}
|
@ -1,17 +1,16 @@
|
||||
package com.baeldung.overrideproperties;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||
|
||||
import com.baeldung.overrideproperties.resolver.PropertySourceResolver;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
@SpringBootTest
|
||||
@EnableWebMvc
|
||||
public class TestResourcePropertySourceResolverIntegrationTest {
|
||||
|
Loading…
x
Reference in New Issue
Block a user