{
// Use the command line parser to evaluate the command line with standard handling behaviour (print errors
// and usage then exist if there are errors).
// Any options and trailing name=value pairs are also injected into the test context properties object,
// to override any defaults that may have been set up.
ParsedProperties options =
new ParsedProperties(CommandLineParser.processCommandLine(args,
new CommandLineParser(
new String[][]
{
{ "b", "The broker URL.", "broker", "false" },
{ "h", "The virtual host to use.", "virtual host", "false" },
{ "o", "The name of the directory to output test timings to.", "dir", "false" },
{
"e", "The test execution engine to use. Default is interop.", "engine", "interop",
"^interop$|^fanout$", "true"
},
{ "t", "Terminate test clients on completion of tests.", null, "false" },
{ "-csv", "Output test results in CSV format.", null, "false" },
{ "-xml", "Output test results in XML format.", null, "false" },
{
"-trefaddr", "To specify an alternative to hostname for time singal reference.",
"address", "false"
},
{
"c", "The number of tests to run concurrently.", "num", "false",
MathUtils.SEQUENCE_REGEXP
},
{ "r", "The number of times to repeat each test.", "num", "false" },
{
"d", "The length of time to run the tests for.", "duration", "false",
MathUtils.DURATION_REGEXP
},
{
"f", "The maximum rate to call the tests at.", "frequency", "false",
"^([1-9][0-9]*)/([1-9][0-9]*)$"
},
{ "s", "The size parameter to run tests with.", "size", "false", MathUtils.SEQUENCE_REGEXP },
{ "v", "Verbose mode.", null, "false" },
{ "n", "A name for this test run, used to name the output file.", "name", "true" }
}), testContextProperties));
// Extract the command line options.
String brokerUrl = options.getProperty("b");
String virtualHost = options.getProperty("h");
String reportDir = options.getProperty("o");
reportDir = (reportDir == null) ? "." : reportDir;
String testEngine = options.getProperty("e");
TestEngine engine = "fanout".equals(testEngine) ? TestEngine.FANOUT : TestEngine.INTEROP;
boolean terminate = options.getPropertyAsBoolean("t");
boolean csvResults = options.getPropertyAsBoolean("-csv");
boolean xmlResults = options.getPropertyAsBoolean("-xml");
String threadsString = options.getProperty("c");
Integer repetitions = options.getPropertyAsInteger("r");
String durationString = options.getProperty("d");
String paramsString = options.getProperty("s");
boolean verbose = options.getPropertyAsBoolean("v");
String testRunName = options.getProperty("n");
int[] threads = (threadsString == null) ? null : MathUtils.parseSequence(threadsString);
int[] params = (paramsString == null) ? null : MathUtils.parseSequence(paramsString);
Long duration = (durationString == null) ? null : MathUtils.parseDuration(durationString);
// If broker or virtual host settings were specified as command line options, override the defaults in the
// test context properties with them.
// Collection all of the test cases to be run.
Collection<Class<? extends FrameworkBaseCase>> testCaseClasses =
new ArrayList<Class<? extends FrameworkBaseCase>>();
// Scan for available test cases using a classpath scanner.
// ClasspathScanner.getMatches(DistributedTestCase.class, "^Test.*", true);
// Hard code the test classes till the classpath scanner is fixed.
// Collections.addAll(testCaseClasses, InteropTestCase1DummyRun.class, InteropTestCase2BasicP2P.class,
// InteropTestCase3BasicPubSub.class);
// Parse all of the free arguments as test cases to run.
for (int i = 1; true; i++)
{
String nextFreeArg = options.getProperty(Integer.toString(i));
// Terminate the loop once all free arguments have been consumed.
if (nextFreeArg == null)
{
break;