|
1 | 1 | package com.marklogic.appdeployer;
|
2 | 2 |
|
| 3 | +import java.util.Properties; |
| 4 | + |
3 | 5 | import org.junit.Assert;
|
4 | 6 | import org.junit.Test;
|
5 | 7 |
|
@@ -33,4 +35,58 @@ public void unrecognizedProperties() {
|
33 | 35 | assertEquals("Should use default", "localhost", config.getHost());
|
34 | 36 | assertEquals("Should use default", "admin", config.getRestAdminUsername());
|
35 | 37 | }
|
| 38 | + |
| 39 | + /** |
| 40 | + * As of 2016-01-18 |
| 41 | + */ |
| 42 | + @Test |
| 43 | + public void allProperties() { |
| 44 | + Properties p = new Properties(); |
| 45 | + p.setProperty("mlHost", "prophost"); |
| 46 | + p.setProperty("mlAppName", "propname"); |
| 47 | + p.setProperty("mlRestPort", "4321"); |
| 48 | + p.setProperty("mlTestRestPort", "8765"); |
| 49 | + p.setProperty("mlUsername", "propuser1"); |
| 50 | + p.setProperty("mlPassword", "proppassword"); |
| 51 | + p.setProperty("mlRestAdminUsername", "propuser2"); |
| 52 | + p.setProperty("mlRestAdminPassword", "proppassword2"); |
| 53 | + p.setProperty("mlContentForestsPerHost", "17"); |
| 54 | + p.setProperty("mlModulePermissions", "some-perm,read,some-perm,update"); |
| 55 | + p.setProperty("mlAdditionalBinaryExtensions", ".gradle,.properties"); |
| 56 | + p.setProperty("mlConfigDir", "src/test/resources/sample-app/empty-ml-config"); |
| 57 | + p.setProperty("mlSimpleSsl", "anyvalue"); |
| 58 | + |
| 59 | + sut = new DefaultAppConfigFactory(new SimplePropertySource(p)); |
| 60 | + AppConfig config = sut.newAppConfig(); |
| 61 | + |
| 62 | + assertEquals("prophost", config.getHost()); |
| 63 | + assertEquals("propname", config.getName()); |
| 64 | + assertEquals((Integer) 4321, config.getRestPort()); |
| 65 | + assertEquals((Integer) 8765, config.getTestRestPort()); |
| 66 | + assertEquals("propuser2", config.getRestAdminUsername()); |
| 67 | + assertEquals("proppassword2", config.getRestAdminPassword()); |
| 68 | + assertEquals((Integer) 17, config.getContentForestsPerHost()); |
| 69 | + assertEquals("some-perm,read,some-perm,update", config.getModulePermissions()); |
| 70 | + String[] extensions = config.getAdditionalBinaryExtensions(); |
| 71 | + assertEquals(".gradle", extensions[0]); |
| 72 | + assertEquals(".properties", extensions[1]); |
| 73 | + assertTrue(config.getConfigDir().getBaseDir().getAbsolutePath().contains("empty-ml-config")); |
| 74 | + assertNotNull(config.getRestSslContext()); |
| 75 | + assertNotNull(config.getRestSslHostnameVerifier()); |
| 76 | + } |
| 77 | + |
| 78 | + @Test |
| 79 | + public void mlUsernameAndPassword() { |
| 80 | + sut = new DefaultAppConfigFactory( |
| 81 | + new SimplePropertySource("mlUsername", "customuser", "mlPassword", "custompassword")); |
| 82 | + AppConfig config = sut.newAppConfig(); |
| 83 | + |
| 84 | + assertEquals("When mlRestAdminUsername is not set, mlUsername should be used", "customuser", |
| 85 | + config.getRestAdminUsername()); |
| 86 | + assertEquals("When mlRestAdminPassword is not set, mlPassword should be used", "custompassword", |
| 87 | + config.getRestAdminPassword()); |
| 88 | + |
| 89 | + assertNull("SSL context should be null by default", config.getRestSslContext()); |
| 90 | + assertNull("SSL hostname verifier should be null by default", config.getRestSslHostnameVerifier()); |
| 91 | + } |
36 | 92 | }
|
0 commit comments