@Test public void checkSetup() { Main cli = new Main(); assertTrue(cli.checkSetup().size() > 0); cli.driver = "driver"; cli.username = "username"; cli.password = "pwd"; cli.url = "url"; cli.changeLogFile = "file"; cli.classpath = "classpath"; assertTrue(cli.checkSetup().size() > 0); cli.command = "BadCommand"; assertTrue(cli.checkSetup().size() > 0); cli.command = "migrate"; assertEquals(0, cli.checkSetup().size()); String[] noArgCommand = { "migrate", "migrateSQL", "update", "updateSQL", "futureRollbackSQL", "updateTestingRollback", "listLocks", "dropAll", "releaseLocks", "validate", "help", "generateChangeLog", "clearCheckSums", "changelogSync", "changelogSyncSQL", "markNextChangeSetRan", "markNextChangeSetRanSQL" }; cli.commandParams.clear(); cli.commandParams.add("--logLevel=debug"); for(int i=0; i<noArgCommand.length; i++) { cli.command = noArgCommand[i]; assertEquals(1, cli.checkSetup().size()); } cli.command = "update"; cli.commandParams.clear(); cli.changeLogParameters.clear(); cli.changeLogParameters.put("engine", "myisam"); assertEquals(0, cli.checkSetup().size()); cli.commandParams.clear(); for(int i=0; i<noArgCommand.length; i++) { cli.command = noArgCommand[i]; assertEquals(0, cli.checkSetup().size()); } String[] singleArgCommand = { "updateCount", "updateCountSQL", "rollback", "rollbackToDate", "rollbackCount", "rollbackSQL", "rollbackToDateSQL", "rollbackCountSQL", "tag", "dbDoc" }; cli.commandParams.add("--logLevel=debug"); for(int i=0; i<singleArgCommand.length; i++) { cli.command = singleArgCommand[i]; assertEquals(1, cli.checkSetup().size()); } cli.commandParams.clear(); cli.commandParams.add("someCommandValue"); for(int i=0; i<singleArgCommand.length; i++) { cli.command = singleArgCommand[i]; assertEquals(0, cli.checkSetup().size()); } cli.command = "status"; cli.commandParams.clear(); assertEquals(0, cli.checkSetup().size()); cli.commandParams.add("--verbose"); assertEquals(0, cli.checkSetup().size()); cli.commandParams.clear(); cli.commandParams.add("--logLevel=debug"); assertEquals(1, cli.checkSetup().size()); String[] multiArgCommand = { "diff", "diffChangeLog" }; cli.commandParams.clear(); for(int i=0; i<multiArgCommand.length; i++) { cli.command = multiArgCommand[i]; assertEquals(0, cli.checkSetup().size()); } String[] cmdParms = { "--referenceUsername=USERNAME", "--referencePassword=PASSWORD", "--referenceUrl=URL", "--referenceDriver=DRIVER"}; for (String param : cmdParms) { cli.commandParams.add(param); } assertEquals(0, cli.checkSetup().size()); cli.commandParams.add("--logLevel=debug"); assertEquals(1, cli.checkSetup().size()); }
protected List<String> checkSetup() { List<String> messages = new ArrayList<String>(); if (command == null) { messages.add("Command not passed"); } else if (!isCommand(command)) { messages.add("Unknown command: " + command); } else { if (url == null) { messages.add("--url is required"); } if (isChangeLogRequired(command) && changeLogFile == null) { messages.add("--changeLogFile is required"); } if (isNoArgCommand(command) && !commandParams.isEmpty()) { messages.add("unexpected command parameters: "+commandParams); } else { validateCommandParameters(messages); } } return messages; }
Main { protected List<String> checkSetup() { List<String> messages = new ArrayList<String>(); if (command == null) { messages.add("Command not passed"); } else if (!isCommand(command)) { messages.add("Unknown command: " + command); } else { if (url == null) { messages.add("--url is required"); } if (isChangeLogRequired(command) && changeLogFile == null) { messages.add("--changeLogFile is required"); } if (isNoArgCommand(command) && !commandParams.isEmpty()) { messages.add("unexpected command parameters: "+commandParams); } else { validateCommandParameters(messages); } } return messages; } }
Main { protected List<String> checkSetup() { List<String> messages = new ArrayList<String>(); if (command == null) { messages.add("Command not passed"); } else if (!isCommand(command)) { messages.add("Unknown command: " + command); } else { if (url == null) { messages.add("--url is required"); } if (isChangeLogRequired(command) && changeLogFile == null) { messages.add("--changeLogFile is required"); } if (isNoArgCommand(command) && !commandParams.isEmpty()) { messages.add("unexpected command parameters: "+commandParams); } else { validateCommandParameters(messages); } } return messages; } Main(); }
Main { protected List<String> checkSetup() { List<String> messages = new ArrayList<String>(); if (command == null) { messages.add("Command not passed"); } else if (!isCommand(command)) { messages.add("Unknown command: " + command); } else { if (url == null) { messages.add("--url is required"); } if (isChangeLogRequired(command) && changeLogFile == null) { messages.add("--changeLogFile is required"); } if (isNoArgCommand(command) && !commandParams.isEmpty()) { messages.add("unexpected command parameters: "+commandParams); } else { validateCommandParameters(messages); } } return messages; } Main(); static void main(String args[]); boolean isWindows(); }
Main { protected List<String> checkSetup() { List<String> messages = new ArrayList<String>(); if (command == null) { messages.add("Command not passed"); } else if (!isCommand(command)) { messages.add("Unknown command: " + command); } else { if (url == null) { messages.add("--url is required"); } if (isChangeLogRequired(command) && changeLogFile == null) { messages.add("--changeLogFile is required"); } if (isNoArgCommand(command) && !commandParams.isEmpty()) { messages.add("unexpected command parameters: "+commandParams); } else { validateCommandParameters(messages); } } return messages; } Main(); static void main(String args[]); boolean isWindows();  }