BAEL-2510 Add nested properties section (#6212)
Add nested properties section to ConfigurationProperties article.
This commit is contained in:
committed by
Grzegorz Piwowarek
parent
4bd87241ce
commit
8ccec9a413
@@ -1,5 +1,8 @@
|
||||
package org.baeldung.properties;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -18,26 +21,36 @@ public class ConfigPropertiesIntegrationTest {
|
||||
|
||||
@Test
|
||||
public void whenSimplePropertyQueriedthenReturnsProperty() throws Exception {
|
||||
Assert.assertTrue("From address is read as null!", properties.getFrom() != null);
|
||||
Assert.assertEquals("Incorrectly bound hostName property", "host@mail.com", properties.getHostName());
|
||||
Assert.assertEquals("Incorrectly bound port property", 9000, properties.getPort());
|
||||
Assert.assertEquals("Incorrectly bound from property", "mailer@mail.com", properties.getFrom());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenListPropertyQueriedthenReturnsProperty() throws Exception {
|
||||
Assert.assertTrue("Couldn't bind list property!", properties.getDefaultRecipients().size() == 2);
|
||||
Assert.assertTrue("Incorrectly bound list property. Expected 2 entries!", properties.getDefaultRecipients().size() == 2);
|
||||
List<String> defaultRecipients = properties.getDefaultRecipients();
|
||||
Assert.assertTrue("Couldn't bind list property!", defaultRecipients.size() == 2);
|
||||
Assert.assertTrue("Incorrectly bound list property. Expected 2 entries!", defaultRecipients.size() == 2);
|
||||
Assert.assertEquals("Incorrectly bound list[0] property", "admin@mail.com", defaultRecipients.get(0));
|
||||
Assert.assertEquals("Incorrectly bound list[1] property", "owner@mail.com", defaultRecipients.get(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenMapPropertyQueriedthenReturnsProperty() throws Exception {
|
||||
Assert.assertTrue("Couldn't bind map property!", properties.getAdditionalHeaders() != null);
|
||||
Assert.assertTrue("Incorrectly bound map property. Expected 3 Entries!", properties.getAdditionalHeaders().size() == 3);
|
||||
Map<String, String> additionalHeaders = properties.getAdditionalHeaders();
|
||||
Assert.assertTrue("Couldn't bind map property!", additionalHeaders != null);
|
||||
Assert.assertTrue("Incorrectly bound map property. Expected 3 Entries!", additionalHeaders.size() == 3);
|
||||
Assert.assertEquals("Incorrectly bound map[redelivery] property", "true", additionalHeaders.get("redelivery"));
|
||||
Assert.assertEquals("Incorrectly bound map[secure] property", "true", additionalHeaders.get("secure"));
|
||||
Assert.assertEquals("Incorrectly bound map[p3] property", "value", additionalHeaders.get("p3"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenObjectPropertyQueriedthenReturnsProperty() throws Exception {
|
||||
Assert.assertTrue("Couldn't bind map property!", properties.getCredentials() != null);
|
||||
Assert.assertTrue("Incorrectly bound object property!", properties.getCredentials().getAuthMethod().equals("SHA1"));
|
||||
Assert.assertTrue("Incorrectly bound object property!", properties.getCredentials().getUsername().equals("john"));
|
||||
Assert.assertTrue("Incorrectly bound object property!", properties.getCredentials().getPassword().equals("password"));
|
||||
Credentials credentials = properties.getCredentials();
|
||||
Assert.assertTrue("Couldn't bind map property!", credentials != null);
|
||||
Assert.assertEquals("Incorrectly bound object property, authMethod", "SHA1", credentials.getAuthMethod());
|
||||
Assert.assertEquals("Incorrectly bound object property, username", "john", credentials.getUsername());
|
||||
Assert.assertEquals("Incorrectly bound object property, password", "password", credentials.getPassword());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user