Skip to content

Commit 94993b1

Browse files
authored
Merge pull request #6 from Pricetx/master
JUnit fixes (localhost hardcoded)
2 parents 55d4cc1 + 3d5da73 commit 94993b1

2 files changed

Lines changed: 83 additions & 68 deletions

File tree

src/test/java/com/ffxivcensus/gatherer/ConsoleTest.java

Lines changed: 43 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ public class ConsoleTest {
4444
* The database to use
4545
*/
4646
private static String dbName;
47+
/**
48+
* Hostname of database, e.g. mysql://host.example.com:3306
49+
*/
50+
private static String dbHost;
4751

4852
/**
4953
* Before running drop the table.
@@ -100,32 +104,33 @@ public void cleanUpStreams() {
100104
/**
101105
* Make a run of the console application with the following options.
102106
* <ul>
103-
* <li>Start ID = 0</li>
104-
* <li>End ID = 100</li>
105-
* <li>Thread limit = 10</li>
106-
* <li>Table Name = tblplayers_test</li>
107-
* <li>Log mounts</li>
108-
* <li>Log minions</li>
109-
* <li>Do not store progress indicators</li>
110-
* <li>User specified DB name.</li>
107+
* <li>Start ID = 0</li>
108+
* <li>End ID = 100</li>
109+
* <li>Thread limit = 10</li>
110+
* <li>Table Name = tblplayers_test</li>
111+
* <li>Log mounts</li>
112+
* <li>Log minions</li>
113+
* <li>Do not store progress indicators</li>
114+
* <li>User specified DB name.</li>
111115
* </ul>
116+
*
112117
* @throws Exception
113118
*/
114119
@Test
115120
public void testConsole() throws Exception {
116121

117-
String[] args = {"-s", "0", "-f", "100", "-t", "10","-T","tblplayers_test","-d",dbName,"-bPq"};
122+
String[] args = {"-s", "0", "-f", "100", "-t", "10", "-T", "tblplayers_test", "-d", dbName,"-U",dbHost, "-bPq"};
118123

119124
GathererController gc = Console.run(args);
120125
//Test that options have set attributes correctly
121126
assertFalse(gc.isStoreProgression()); //b
122127
assertTrue(gc.isStoreMinions()); //P
123128
assertTrue(gc.isQuiet()); //q
124129
assertFalse(gc.isVerbose()); //q
125-
assertEquals("tblplayers_test",gc.getTableName());
126-
assertEquals(gc.getStartId(),0);
127-
assertEquals(gc.getEndId(),100);
128-
assertEquals(gc.getThreadLimit(),10);
130+
assertEquals("tblplayers_test", gc.getTableName());
131+
assertEquals(gc.getStartId(), 0);
132+
assertEquals(gc.getEndId(), 100);
133+
assertEquals(gc.getThreadLimit(), 10);
129134

130135
assertTrue(outContent.toString().contains("Starting parse of range 0 to 100 using 10 threads"));
131136
assertTrue(outContent.toString().contains("Run completed, 101 character IDs scanned"));
@@ -136,31 +141,32 @@ public void testConsole() throws Exception {
136141
/**
137142
* Make a run of the console application with the following options.
138143
* <ul>
139-
* <li>Start ID = 100</li>
140-
* <li>End ID = 200</li>
141-
* <li>Thread limit = 32</li>
142-
* <li>Print duds</li>
143-
* <li>User specified db name</li>
144-
* <li>User specified db credentials</li>
145-
* <li>Verbose mode</li>
144+
* <li>Start ID = 100</li>
145+
* <li>End ID = 200</li>
146+
* <li>Thread limit = 32</li>
147+
* <li>Print duds</li>
148+
* <li>User specified db name</li>
149+
* <li>User specified db credentials</li>
150+
* <li>Verbose mode</li>
146151
* </ul>
152+
*
147153
* @throws Exception
148154
*/
149155
@Test
150156
public void testConsoleFullOptions() throws Exception {
151157

152-
String[] args = {"--start=100", "--finish=200", "--threads", "32","-v","-d",dbName,"-U","mysql://localhost:3306","-u",dbUser,"-p",dbPassword};
158+
String[] args = {"--start=100", "--finish=200", "--threads", "32", "-v", "-d", dbName, "-U", dbHost, "-u", dbUser, "-p", dbPassword};
153159
GathererController gc = Console.run(args);
154160

155-
assertEquals(gc.getStartId(),100);
156-
assertEquals(gc.getEndId(),200);
157-
assertEquals(gc.getThreadLimit(),32);
161+
assertEquals(gc.getStartId(), 100);
162+
assertEquals(gc.getEndId(), 200);
163+
assertEquals(gc.getThreadLimit(), 32);
158164
assertTrue(gc.isVerbose());
159165
}
160166

161167

162168
@Test
163-
public void TestConsoleHelpDefault() throws Exception{
169+
public void TestConsoleHelpDefault() throws Exception {
164170

165171
String strHelp = "usage: java -jar XIVStats-Gatherer-Java.jar [-bmqvxFPS] -s startid -f";
166172

@@ -172,7 +178,7 @@ public void TestConsoleHelpDefault() throws Exception{
172178
}
173179

174180
@Test
175-
public void TestConsoleHelpOnFail() throws Exception{
181+
public void TestConsoleHelpOnFail() throws Exception {
176182

177183
String strHelp = "usage: java -jar XIVStats-Gatherer-Java.jar [-bmqvxFPS] -s startid -f";
178184
//Test for a help dialog displayed upon failure
@@ -184,7 +190,7 @@ public void TestConsoleHelpOnFail() throws Exception{
184190
}
185191

186192
@Test
187-
public void TestConsoleHelp() throws Exception{
193+
public void TestConsoleHelp() throws Exception {
188194

189195
String strHelp = "usage: java -jar XIVStats-Gatherer-Java.jar [-bmqvxFPS] -s startid -f";
190196

@@ -196,36 +202,36 @@ public void TestConsoleHelp() throws Exception{
196202
}
197203

198204
@Test
199-
public void testMain(){
200-
String[] args = {"-s","1100", "-f","1400"};
205+
public void testMain() {
206+
String[] args = {"-s", "1100", "-f", "1400"};
201207
Console.main(args);
202208
//Check output
203209
assertFalse(outContent.toString().contains("does not exist."));
204210
}
205211

206212
@Test
207-
public void testDefault(){
208-
String[] args = {"-s","500","-f","600"};
213+
public void testDefault() {
214+
String[] args = {"-s", "500", "-f", "600"};
209215
GathererController gc = Console.run(args);
210216
//Check output
211217
assertFalse(outContent.toString().contains("does not exist."));
212218
}
213219

214220
@Test
215-
public void testPrintFails(){
216-
String[] args = {"-s","700","-f","800","-qF"};
221+
public void testPrintFails() {
222+
String[] args = {"-s", "700", "-f", "800", "-qF"};
217223
GathererController gc = Console.run(args);
218224
//Check output
219225
assertFalse(outContent.toString().contains("written to database successfully."));
220226
assertTrue(outContent.toString().contains("does not exist."));
221227
}
222228

223229
@Test
224-
public void testSplitTables(){
225-
String[] args = {"-s","900","-f","1000","-x","_test","-S"};
230+
public void testSplitTables() {
231+
String[] args = {"-s", "900", "-f", "1000", "-x", "_test", "-S"};
226232
GathererController gc = Console.run(args);
227233
assertTrue(gc.isSplitTables());
228-
assertEquals(gc.getTableSuffix(),"_test");
234+
assertEquals(gc.getTableSuffix(), "_test");
229235
}
230236

231237
//Utility methods
@@ -283,6 +289,7 @@ public static void readConfig() throws ParserConfigurationException, IOException
283289

284290
String url = "jdbc:" + elementJDBC.getElementsByTagName("url").item(0).getTextContent() + "/" + elementJDBC.getElementsByTagName("database").item(0).getTextContent();
285291
dbUrl = url;
292+
dbHost = elementJDBC.getElementsByTagName("url").item(0).getTextContent();
286293
dbUser = elementJDBC.getElementsByTagName("username").item(0).getTextContent();
287294
dbPassword = elementJDBC.getElementsByTagName("password").item(0).getTextContent();
288295
dbName = elementJDBC.getElementsByTagName("database").item(0).getTextContent();

0 commit comments

Comments
 (0)