numClients = 1;
return true;
}
});
registerHandler(new ArgHandlerString() {
@Override
public String getPurpose() {
return "Runs web mode via RMI to a set of BrowserManagerServers; "
+ "e.g. rmi://localhost/ie6,rmi://localhost/firefox";
}
@Override
public String getTag() {
return "-remoteweb";
}
@Override
public String[] getTagArgs() {
return new String[] {"rmiUrl"};
}
@Override
public boolean isUndocumented() {
return true;
}
@Override
public boolean setString(String str) {
String[] urls = str.split(",");
runStyle = RunStyleRemoteWeb.create(JUnitShell.this, urls);
numClients = urls.length;
return runStyle != null;
}
});
registerHandler(new ArgHandlerString() {
@Override
public String getPurpose() {
return "Runs web mode via HTTP to a set of Selenium servers; "
+ "e.g. localhost:4444/*firefox,remotehost:4444/*iexplore";
}
@Override
public String getTag() {
return "-selenium";
}
@Override
public String[] getTagArgs() {
return new String[] {"seleniumHost"};
}
@Override
public boolean setString(String str) {
String[] targets = str.split(",");
numClients = targets.length;
runStyle = RunStyleSelenium.create(JUnitShell.this, targets);
return runStyle != null;
}
});
registerHandler(new ArgHandlerString() {
@Override
public String getPurpose() {
return "Runs web mode via HTMLUnit given a list of browsers; "
+ "e.g. " + RunStyleHtmlUnit.getBrowserList();
}
@Override
public String getTag() {
return "-htmlunit";
}
@Override
public String[] getTagArgs() {
return new String[] {"browserNames"};
}
@Override
public boolean setString(String str) {
String[] targets = str.split(",");
try {
runStyle = new RunStyleHtmlUnit(JUnitShell.this, targets);
numClients = ((RunStyleHtmlUnit) runStyle).numBrowsers();
return true;
} catch (IllegalArgumentException ex) {
System.err.println(ex.getMessage());
return false;
}
}
});
registerHandler(new ArgHandlerString() {
@Override
public String getPurpose() {
return "Run external browsers in web mode (pass a comma separated list of executables.)";
}
@Override
public String getTag() {
return "-externalbrowser";
}
@Override
public String[] getTagArgs() {
return new String[] {"browserPaths"};
}
@Override
public boolean isUndocumented() {
return true;
}
@Override
public boolean setString(String str) {
String[] paths = str.split(",");
runStyle = new RunStyleExternalBrowser(JUnitShell.this, paths);
numClients = paths.length;
return runStyle != null;
}
});
// TODO: currently, only two values but soon may have multiple values.
registerHandler(new ArgHandlerString() {
@Override
public String getPurpose() {
return "Configure batch execution of tests";
}
@Override
public String getTag() {
return "-batch";
}
@Override
public String[] getTagArgs() {
return new String[] {"none|class|module"};
}
@Override
public boolean isUndocumented() {
return true;
}
@Override
public boolean setString(String str) {
if (str.equals("none")) {
batchingStrategy = new NoBatchingStrategy();
} else if (str.equals("class")) {
batchingStrategy = new ClassBatchingStrategy();
} else if (str.equals("module")) {
batchingStrategy = new ModuleBatchingStrategy();
} else {
return false;
}
return true;
}
});
registerHandler(new ArgHandler() {
@Override
public String[] getDefaultArgs() {
return null;
}
@Override
public String getPurpose() {
return "Causes the system to wait for a remote browser to connect";
}
@Override
public String getTag() {
return "-manual";
}
@Override
public String[] getTagArgs() {
return new String[] {"[numClients]"};
}
@Override
public int handle(String[] args, int tagIndex) {
int value = 1;
if (tagIndex + 1 < args.length) {
try {
// See if the next item is an integer.
value = Integer.parseInt(args[tagIndex + 1]);
if (value >= 1) {
setInt(value);
return 1;
}
} catch (NumberFormatException e) {
// fall-through
}
}
setInt(1);
return 0;
}
public void setInt(int value) {
runStyle = new RunStyleManual(JUnitShell.this, value);
numClients = value;
}
});
registerHandler(new ArgHandlerFlag() {
@Override
public String getPurpose() {
return "Causes the log window and browser windows to be displayed; useful for debugging";
}
@Override
public String getTag() {
return "-notHeadless";
}
@Override
public boolean setFlag() {
setHeadless(false);
return true;
}
});
registerHandler(new ArgHandlerString() {
@Override
public String getPurpose() {
return "Precompile modules as tests are running (speeds up remote tests but requires more memory)";
}
@Override
public String getTag() {
return "-precompile";
}
@Override
public String[] getTagArgs() {
return new String[] {"simple|all|parallel"};
}
@Override
public boolean isUndocumented() {
return true;
}
@Override
public boolean setString(String str) {
if (str.equals("simple")) {
compileStrategy = new SimpleCompileStrategy();
} else if (str.equals("all")) {
compileStrategy = new PreCompileStrategy();
} else if (str.equals("parallel")) {
compileStrategy = new ParallelCompileStrategy();
} else {
return false;
}
return true;
}
});
registerHandler(new ArgHandlerString() {
@Override
public String getPurpose() {
return "Specify the user agents to reduce the number of permutations for remote browser tests;"
+ " e.g. ie6,ie8,safari,gecko,gecko1_8,opera";
}