11package com .marklogic .hub ;
22
33import org .apache .commons .io .FileUtils ;
4+ import org .apache .commons .io .IOUtils ;
45import org .junit .AfterClass ;
56import org .junit .BeforeClass ;
67import org .junit .Test ;
910import java .io .File ;
1011import java .io .FileInputStream ;
1112import java .io .IOException ;
13+ import java .io .InputStream ;
1214import java .util .Properties ;
1315
1416public 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