Skip to content

Commit 336ee34

Browse files
committed
fixed broken unit test
1 parent 133f09d commit 336ee34

File tree

3 files changed

+57
-13
lines changed

3 files changed

+57
-13
lines changed

marklogic-data-hub/src/main/java/com/marklogic/hub/HubConfig.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,7 @@ public AppConfig getAppConfig() {
537537
}
538538

539539
public Map<String, String> getCustomTokens(Map<String, String> customTokens) {
540+
customTokens.put("%%mlHost%%", host);
540541
customTokens.put("%%mlStagingAppserverName%%", stagingHttpName);
541542
customTokens.put("\"%%mlStagingPort%%\"", stagingPort.toString());
542543
customTokens.put("%%mlStagingDbName%%", stagingDbName);

marklogic-data-hub/src/main/resources/scaffolding/gradle_properties

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,6 @@ mlPassword=
2020
# mlManageUsername=
2121
# mlManagePassword=
2222

23-
# If specified, these values can override where the DHF thinks
24-
# MarkLogic default ports are at. You would only use this if you
25-
# have changed the ports on which MarkLogic listens
26-
#
27-
# mlAppServicesPort=8000
28-
# mlAdminPort=8001
29-
# mlManagePort=8002
30-
3123
# If specified, the admin username/password combo is used with the ML Management REST API for creating users and roles. This
3224
# user must have the manage-admin or admin role. A good practice is to use your admin account here to create app-specific
3325
# users and roles, which can then be used as mlManageUsername/mlManagePassword and mlUsername/mlPassword.
@@ -39,26 +31,34 @@ mlPassword=
3931
# mlAdminUsername=
4032
# mlAdminPassword=
4133

34+
# If specified, these values can override where the DHF thinks
35+
# MarkLogic default ports are at. You would only use this if you
36+
# have changed the ports on which MarkLogic listens
37+
#
38+
# mlAppServicesPort=8000
39+
# mlAdminPort=8001
40+
# mlManagePort=8002
41+
4242
mlStagingAppserverName=%%mlStagingAppserverName%%
43-
mlStagingPort=%%mlStagingPort%%
43+
mlStagingPort="%%mlStagingPort%%"
4444
mlStagingDbName=%%mlStagingDbName%%
4545
mlStagingForestsPerHost=%%mlStagingForestsPerHost%%
4646
mlStagingAuth=%%mlStagingAuth%%
4747

4848
mlFinalAppserverName=%%mlFinalAppserverName%%
49-
mlFinalPort=%%mlFinalPort%%
49+
mlFinalPort="%%mlFinalPort%%"
5050
mlFinalDbName=%%mlFinalDbName%%
5151
mlFinalForestsPerHost=%%mlFinalForestsPerHost%%
5252
mlFinalAuth=%%mlFinalAuth%%
5353

5454
mlTraceAppserverName=%%mlTraceAppserverName%%
55-
mlTracePort=%%mlTracePort%%
55+
mlTracePort="%%mlTracePort%%"
5656
mlTraceDbName=%%mlTraceDbName%%
5757
mlTraceForestsPerHost=%%mlTraceForestsPerHost%%
5858
mlTraceAuth=%%mlTraceAuth%%
5959

6060
mlJobAppserverName=%%mlJobAppserverName%%
61-
mlJobPort=%%mlJobPort%%
61+
mlJobPort="%%mlJobPort%%"
6262
mlJobDbName=%%mlJobDbName%%
6363
mlJobForestsPerHost=%%mlJobForestsPerHost%%
6464
mlJobAuth=%%mlJobAuth%%

marklogic-data-hub/src/test/java/com/marklogic/hub/HubProjectTest.java

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.marklogic.hub;
22

33
import org.apache.commons.io.FileUtils;
4+
import org.apache.commons.io.IOUtils;
45
import org.junit.AfterClass;
56
import org.junit.BeforeClass;
67
import org.junit.Test;
@@ -9,6 +10,7 @@
910
import java.io.File;
1011
import java.io.FileInputStream;
1112
import java.io.IOException;
13+
import java.io.InputStream;
1214
import java.util.Properties;
1315

1416
public class HubProjectTest extends HubTestBase {
@@ -43,6 +45,14 @@ public void testInit() throws IOException {
4345
config.traceForestsPerHost = 100;
4446
config.tracePort = 3333;
4547

48+
config.modulesForestsPerHost = 3;
49+
config.triggersForestsPerHost = 4;
50+
51+
config.schemasForestsPerHost = 5;
52+
53+
config.hubRoleName = "myrole";
54+
config.hubUserName = "myuser";
55+
4656
HubProject hp = new HubProject(config);
4757
hp.init();
4858

@@ -64,11 +74,36 @@ public void testInit() throws IOException {
6474
assertTrue(gradleProperties.exists());
6575
Properties props = new Properties();
6676
FileInputStream propsStream = new FileInputStream(gradleProperties);
67-
props.load(propsStream);
77+
String fileContents = IOUtils.toString(propsStream);
78+
fileContents = fileContents.replace("mlUsername=", "mlUsername=twituser");
79+
fileContents = fileContents.replace("mlPassword=", "mlPassword=twitpassword");
80+
fileContents = fileContents.replace("# mlManageUsername=", "mlManageUsername=manage-user");
81+
fileContents = fileContents.replace("# mlManagePassword=", "mlManagePassword=manage-password");
82+
fileContents = fileContents.replace("# mlAdminUsername=", "mlAdminUsername=admin-user");
83+
fileContents = fileContents.replace("# mlAdminPassword=", "mlAdminPassword=admin-password");
84+
fileContents = fileContents.replace("# mlAppServicesPort=8000", "mlAppServicesPort=9000");
85+
fileContents = fileContents.replace("# mlAdminPort=8001", "mlAdminPort=9001");
86+
fileContents = fileContents.replace("# mlManagePort=8002", "mlManagePort=9002");
87+
InputStream updatedStream = IOUtils.toInputStream(fileContents);
88+
89+
props.load(updatedStream);
6890
propsStream.close();
6991

7092
assertEquals(config.host, props.getProperty("mlHost"));
7193

94+
assertEquals("twituser", props.getProperty("mlUsername"));
95+
assertEquals("twitpassword", props.getProperty("mlPassword"));
96+
97+
assertEquals("manage-user", props.getProperty("mlManageUsername"));
98+
assertEquals("manage-password", props.getProperty("mlManagePassword"));
99+
100+
assertEquals("admin-user", props.getProperty("mlAdminUsername"));
101+
assertEquals("admin-password", props.getProperty("mlAdminPassword"));
102+
103+
assertEquals("9000", props.getProperty("mlAppServicesPort"));
104+
assertEquals("9001", props.getProperty("mlAdminPort"));
105+
assertEquals("9002", props.getProperty("mlManagePort"));
106+
72107
assertEquals(config.stagingHttpName, props.getProperty("mlStagingAppserverName"));
73108
assertEquals(config.stagingPort.toString(), props.getProperty("mlStagingPort"));
74109
assertEquals(config.stagingDbName, props.getProperty("mlStagingDbName"));
@@ -90,8 +125,16 @@ public void testInit() throws IOException {
90125
assertEquals(config.jobForestsPerHost.toString(), props.getProperty("mlJobForestsPerHost"));
91126

92127
assertEquals(config.modulesDbName, props.getProperty("mlModulesDbName"));
128+
assertEquals(config.modulesForestsPerHost.toString(), props.getProperty("mlModulesForestsPerHost"));
129+
93130
assertEquals(config.triggersDbName, props.getProperty("mlTriggersDbName"));
131+
assertEquals(config.triggersForestsPerHost.toString(), props.getProperty("mlTriggersForestsPerHost"));
132+
94133
assertEquals(config.schemasDbName, props.getProperty("mlSchemasDbName"));
134+
assertEquals(config.schemasForestsPerHost.toString(), props.getProperty("mlSchemasForestsPerHost"));
135+
136+
assertEquals(config.hubRoleName, props.getProperty("mlHubUserRole"));
137+
assertEquals(config.hubUserName, props.getProperty("mlHubUserName"));
95138

96139
File gradleLocalProperties = new File(projectPath, "gradle-local.properties");
97140
assertTrue(gradleLocalProperties.exists());

0 commit comments

Comments
 (0)