JAVA-1526: Remove spring-boot-json-properties from spring-boot-properties

This commit is contained in:
Krzysztof Woyke
2020-05-20 14:37:43 +02:00
parent 5ab3de4965
commit 8afe64de3e
10 changed files with 6 additions and 298 deletions
@@ -1,59 +0,0 @@
package com.baeldung.properties;
import java.util.Arrays;
import org.hamcrest.Matchers;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@ContextConfiguration(classes = ConfigPropertiesDemoApplication.class, initializers = JsonPropertyContextInitializer.class)
public class JsonPropertiesIntegrationTest {
@Autowired
private JsonProperties jsonProperties;
@Autowired
private CustomJsonProperties customJsonProperties;
@Test
public void whenPropertiesLoadedViaJsonPropertySource_thenLoadFlatValues() {
Assert.assertEquals("mailer@mail.com", jsonProperties.getHost());
Assert.assertEquals(9090, jsonProperties.getPort());
Assert.assertTrue(jsonProperties.isResend());
}
@Test
public void whenPropertiesLoadedViaJsonPropertySource_thenLoadListValues() {
Assert.assertThat(jsonProperties.getTopics(), Matchers.is(Arrays.asList("spring", "boot")));
}
@Test
public void whenPropertiesLoadedViaJsonPropertySource_thenNestedLoadedAsMap() {
Assert.assertEquals("sender", jsonProperties.getSender()
.get("name"));
Assert.assertEquals("street", jsonProperties.getSender()
.get("address"));
}
@Test
public void whenLoadedIntoEnvironment_thenFlatValuesPopulated() {
Assert.assertEquals("mailer@mail.com", customJsonProperties.getHost());
Assert.assertEquals(9090, customJsonProperties.getPort());
Assert.assertTrue(customJsonProperties.isResend());
}
@Test
public void whenLoadedIntoEnvironment_thenValuesLoadedIntoClassObject() {
Assert.assertNotNull(customJsonProperties.getSender());
Assert.assertEquals("sender", customJsonProperties.getSender()
.getName());
Assert.assertEquals("street", customJsonProperties.getSender()
.getAddress());
}
}
@@ -17,6 +17,6 @@ public class PriorityProviderIntegrationTest {
@Test
public void givenPropertyFileWhenConstructorInjectionUsedThenValueInjected() {
assertThat(priorityProvider.getPriority()).isEqualTo("Properties file");
assertThat(priorityProvider.getPriority()).isEqualTo("high");
}
}