1 /*
   2  * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 package org.openjdk.jmh.runner.options;
  26 
  27 import org.junit.Assert;
  28 import org.junit.Before;
  29 import org.junit.Test;
  30 import org.openjdk.jmh.annotations.Mode;
  31 import org.openjdk.jmh.annotations.Threads;
  32 import org.openjdk.jmh.profile.ClassloaderProfiler;
  33 import org.openjdk.jmh.profile.CompilerProfiler;
  34 import org.openjdk.jmh.results.format.ResultFormatType;
  35 
  36 import java.io.ByteArrayOutputStream;
  37 import java.io.IOException;
  38 import java.io.ObjectOutputStream;
  39 import java.util.Collection;
  40 import java.util.concurrent.TimeUnit;
  41 
  42 public class TestOptions {
  43 
  44     private Options EMPTY_BUILDER;
  45     private CommandLineOptions EMPTY_CMDLINE;
  46 
  47     @Before
  48     public void setUp() throws Exception {
  49         EMPTY_CMDLINE = new CommandLineOptions();
  50         EMPTY_BUILDER = new OptionsBuilder().build();
  51     }
  52 
  53     @Test
  54     public void testSerializable_Cmdline() throws IOException {
  55         ObjectOutputStream oos = new ObjectOutputStream(new ByteArrayOutputStream());
  56         oos.writeObject(EMPTY_CMDLINE);
  57         oos.flush();
  58     }
  59 
  60     @Test
  61     public void testSerializable_Builder() throws IOException {
  62         ObjectOutputStream oos = new ObjectOutputStream(new ByteArrayOutputStream());
  63         oos.writeObject(EMPTY_BUILDER);
  64         oos.flush();
  65     }
  66 
  67     @Test
  68     public void testIncludes() throws Exception {
  69         CommandLineOptions cmdLine = new CommandLineOptions(".*", ".*test.*", "test");
  70         Options builder = new OptionsBuilder().include(".*").include(".*test.*").include("test").build();
  71         Assert.assertEquals(builder.getIncludes(), cmdLine.getIncludes());
  72     }
  73 
  74     @Test
  75     public void testIncludes_Default() throws Exception {
  76         Assert.assertEquals(EMPTY_BUILDER.getIncludes(), EMPTY_CMDLINE.getIncludes());
  77     }
  78 
  79     @Test
  80     public void testExcludes() throws Exception {
  81         CommandLineOptions cmdLine = new CommandLineOptions("-e", ".*", "-e", ".*test.*", "-e", "test");
  82         Options builder = new OptionsBuilder().exclude(".*").exclude(".*test.*").exclude("test").build();
  83         Assert.assertEquals(builder.getExcludes(), cmdLine.getExcludes());
  84     }
  85 
  86     @Test
  87     public void testExcludes_Default() throws Exception {
  88         Assert.assertEquals(EMPTY_BUILDER.getExcludes(), EMPTY_CMDLINE.getExcludes());
  89     }
  90 
  91     @Test
  92     public void testOutput() throws Exception {
  93         CommandLineOptions cmdLine = new CommandLineOptions("-o", "sample.out");
  94         Options builder = new OptionsBuilder().output("sample.out").build();
  95         Assert.assertEquals(builder.getOutput(), cmdLine.getOutput());
  96     }
  97 
  98     @Test
  99     public void testOutput_Default() throws Exception {
 100         Assert.assertEquals(EMPTY_BUILDER.getOutput(), EMPTY_CMDLINE.getOutput());
 101     }
 102 
 103     @Test
 104     public void testResultFormats() throws Exception {
 105         for (ResultFormatType type : ResultFormatType.values()) {
 106             CommandLineOptions cmdLine = new CommandLineOptions("-rf", type.toString());
 107             Options builder = new OptionsBuilder().resultFormat(type).build();
 108             Assert.assertEquals(builder.getResultFormat(), cmdLine.getResultFormat());
 109         }
 110     }
 111 
 112     @Test
 113     public void testResultFormats_UC() throws Exception {
 114         for (ResultFormatType type : ResultFormatType.values()) {
 115             CommandLineOptions cmdLine = new CommandLineOptions("-rf", type.toString().toUpperCase());
 116             Options builder = new OptionsBuilder().resultFormat(type).build();
 117             Assert.assertEquals(builder.getResultFormat(), cmdLine.getResultFormat());
 118         }
 119     }
 120 
 121     @Test
 122     public void testResultFormats_LC() throws Exception {
 123         for (ResultFormatType type : ResultFormatType.values()) {
 124             CommandLineOptions cmdLine = new CommandLineOptions("-rf", type.toString().toLowerCase());
 125             Options builder = new OptionsBuilder().resultFormat(type).build();
 126             Assert.assertEquals(builder.getResultFormat(), cmdLine.getResultFormat());
 127         }
 128     }
 129 
 130     @Test
 131     public void testResultFormats_Default() throws Exception {
 132         Assert.assertEquals(EMPTY_BUILDER.getResultFormat(), EMPTY_CMDLINE.getResultFormat());
 133     }
 134 
 135     @Test
 136     public void testResult() throws Exception {
 137         CommandLineOptions cmdLine = new CommandLineOptions("-rff", "sample.out");
 138         Options builder = new OptionsBuilder().result("sample.out").build();
 139         Assert.assertEquals(builder.getOutput(), cmdLine.getOutput());
 140     }
 141 
 142     @Test
 143     public void testResult_Default() throws Exception {
 144         Assert.assertEquals(EMPTY_BUILDER.getResult(), EMPTY_CMDLINE.getResult());
 145     }
 146 
 147     @Test
 148     public void testGC_Set() throws Exception {
 149         CommandLineOptions cmdLine = new CommandLineOptions("-gc");
 150         Options builder = new OptionsBuilder().shouldDoGC(true).build();
 151         Assert.assertEquals(builder.getOutput(), cmdLine.getOutput());
 152     }
 153 
 154     @Test
 155     public void testGC_True() throws Exception {
 156         CommandLineOptions cmdLine = new CommandLineOptions("-gc", "true");
 157         Options builder = new OptionsBuilder().shouldDoGC(true).build();
 158         Assert.assertEquals(builder.getOutput(), cmdLine.getOutput());
 159     }
 160 
 161     @Test
 162     public void testGC_False() throws Exception {
 163         CommandLineOptions cmdLine = new CommandLineOptions("-gc", "false");
 164         Options builder = new OptionsBuilder().shouldDoGC(false).build();
 165         Assert.assertEquals(builder.getOutput(), cmdLine.getOutput());
 166     }
 167 
 168     @Test
 169     public void testGC_Default() throws Exception {
 170         Assert.assertEquals(EMPTY_BUILDER.shouldDoGC(), EMPTY_CMDLINE.shouldDoGC());
 171     }
 172 
 173     @Test
 174     public void testProfilers() throws Exception {
 175         // TODO: Should be able to accept multiple values without concat?
 176         CommandLineOptions cmdLine = new CommandLineOptions("-prof", "cl,comp");
 177         Options builder = new OptionsBuilder().addProfiler(ClassloaderProfiler.class).addProfiler(CompilerProfiler.class).build();
 178         Assert.assertEquals(builder.getProfilers(), cmdLine.getProfilers());
 179     }
 180 
 181     @Test
 182     public void testProfilers_Default() throws Exception {
 183         Assert.assertEquals(EMPTY_BUILDER.getProfilers(), EMPTY_CMDLINE.getProfilers());
 184     }
 185 
 186     @Test
 187     public void testVerbose() throws Exception {
 188         for (VerboseMode mode : VerboseMode.values()) {
 189             CommandLineOptions cmdLine = new CommandLineOptions("-v", mode.toString());
 190             Options builder = new OptionsBuilder().verbosity(mode).build();
 191             Assert.assertEquals(builder.verbosity(), cmdLine.verbosity());
 192         }
 193     }
 194 
 195     @Test
 196     public void testVerbose_LC() throws Exception {
 197         for (VerboseMode mode : VerboseMode.values()) {
 198             CommandLineOptions cmdLine = new CommandLineOptions("-v", mode.toString().toLowerCase());
 199             Options builder = new OptionsBuilder().verbosity(mode).build();
 200             Assert.assertEquals(builder.verbosity(), cmdLine.verbosity());
 201         }
 202     }
 203 
 204     @Test
 205     public void testVerbose_UC() throws Exception {
 206         for (VerboseMode mode : VerboseMode.values()) {
 207             CommandLineOptions cmdLine = new CommandLineOptions("-v", mode.toString().toUpperCase());
 208             Options builder = new OptionsBuilder().verbosity(mode).build();
 209             Assert.assertEquals(builder.verbosity(), cmdLine.verbosity());
 210         }
 211     }
 212 
 213     @Test
 214     public void testVerbose_Default() throws Exception {
 215         Assert.assertEquals(EMPTY_BUILDER.verbosity(), EMPTY_CMDLINE.verbosity());
 216     }
 217 
 218     @Test
 219     public void testSFOE_Set() throws Exception {
 220         CommandLineOptions cmdLine = new CommandLineOptions("-foe");
 221         Options builder = new OptionsBuilder().shouldFailOnError(true).build();
 222         Assert.assertEquals(builder.shouldFailOnError(), cmdLine.shouldFailOnError());
 223     }
 224 
 225     @Test
 226     public void testSFOE_True() throws Exception {
 227         CommandLineOptions cmdLine = new CommandLineOptions("-foe", "true");
 228         Options builder = new OptionsBuilder().shouldFailOnError(true).build();
 229         Assert.assertEquals(builder.shouldFailOnError(), cmdLine.shouldFailOnError());
 230     }
 231 
 232     @Test
 233     public void testSFOE_False() throws Exception {
 234         CommandLineOptions cmdLine = new CommandLineOptions("-foe", "false");
 235         Options builder = new OptionsBuilder().shouldFailOnError(false).build();
 236         Assert.assertEquals(builder.shouldFailOnError(), cmdLine.shouldFailOnError());
 237     }
 238 
 239     @Test
 240     public void testSFOE_Default() throws Exception {
 241         Assert.assertEquals(EMPTY_BUILDER.shouldFailOnError(), EMPTY_CMDLINE.shouldFailOnError());
 242     }
 243 
 244     @Test
 245     public void testThreads_Set() throws Exception {
 246         CommandLineOptions cmdLine = new CommandLineOptions("-t", "2");
 247         Options builder = new OptionsBuilder().threads(2).build();
 248         Assert.assertEquals(builder.getThreads(), cmdLine.getThreads());
 249     }
 250 
 251     @Test
 252     public void testThreads_Max() throws Exception {
 253         CommandLineOptions cmdLine = new CommandLineOptions("-t", "max");
 254         Options builder = new OptionsBuilder().threads(Threads.MAX).build();
 255         Assert.assertEquals(builder.getThreads(), cmdLine.getThreads());
 256     }
 257 
 258     @Test
 259     public void testThreads_Default() throws Exception {
 260         Assert.assertEquals(EMPTY_BUILDER.getThreads(), EMPTY_CMDLINE.getThreads());
 261     }
 262 
 263     @Test
 264     public void testThreadGroups() throws Exception {
 265         CommandLineOptions cmdLine = new CommandLineOptions("-tg", "3,4");
 266         Options builder = new OptionsBuilder().threadGroups(3, 4).build();
 267         Assert.assertEquals(builder.getThreads(), cmdLine.getThreads());
 268     }
 269 
 270     @Test
 271     public void testThreadGroups_Default() throws Exception {
 272         Assert.assertEquals(EMPTY_BUILDER.getThreadGroups(), EMPTY_CMDLINE.getThreadGroups());
 273     }
 274 
 275     @Test
 276     public void testSynchIterations_Set() throws Exception {
 277         CommandLineOptions cmdLine = new CommandLineOptions("-si");
 278         Options builder = new OptionsBuilder().syncIterations(true).build();
 279         Assert.assertEquals(builder.shouldSyncIterations(), cmdLine.shouldSyncIterations());
 280     }
 281 
 282     @Test
 283     public void testSynchIterations_True() throws Exception {
 284         CommandLineOptions cmdLine = new CommandLineOptions("-si", "true");
 285         Options builder = new OptionsBuilder().syncIterations(true).build();
 286         Assert.assertEquals(builder.shouldSyncIterations(), cmdLine.shouldSyncIterations());
 287     }
 288 
 289     @Test
 290     public void testSynchIterations_False() throws Exception {
 291         CommandLineOptions cmdLine = new CommandLineOptions("-si", "false");
 292         Options builder = new OptionsBuilder().syncIterations(false).build();
 293         Assert.assertEquals(builder.shouldSyncIterations(), cmdLine.shouldSyncIterations());
 294     }
 295 
 296     @Test
 297     public void testSynchIterations_Default() throws Exception {
 298         Assert.assertEquals(EMPTY_BUILDER.shouldSyncIterations(), EMPTY_CMDLINE.shouldSyncIterations());
 299     }
 300 
 301     @Test
 302     public void testWarmupIterations() throws Exception {
 303         CommandLineOptions cmdLine = new CommandLineOptions("-wi", "34");
 304         Options builder = new OptionsBuilder().warmupIterations(34).build();
 305         Assert.assertEquals(builder.getWarmupIterations(), cmdLine.getWarmupIterations());
 306     }
 307 
 308     @Test
 309     public void testWarmupIterations_Default() throws Exception {
 310         Assert.assertEquals(EMPTY_BUILDER.getWarmupIterations(), EMPTY_CMDLINE.getWarmupIterations());
 311     }
 312 
 313     @Test
 314     public void testWarmupTime() throws Exception {
 315         CommandLineOptions cmdLine = new CommandLineOptions("-w", "34ms");
 316         Options builder = new OptionsBuilder().warmupTime(TimeValue.milliseconds(34)).build();
 317         Assert.assertEquals(builder.getWarmupTime(), cmdLine.getWarmupTime());
 318     }
 319 
 320     @Test
 321     public void testWarmupTime_Default() throws Exception {
 322         Assert.assertEquals(EMPTY_BUILDER.getWarmupTime(), EMPTY_CMDLINE.getWarmupTime());
 323     }
 324 
 325     @Test
 326     public void testRuntimeIterations() throws Exception {
 327         CommandLineOptions cmdLine = new CommandLineOptions("-i", "34");
 328         Options builder = new OptionsBuilder().measurementIterations(34).build();
 329         Assert.assertEquals(builder.getMeasurementIterations(), cmdLine.getMeasurementIterations());
 330     }
 331 
 332     @Test
 333     public void testRuntimeIterations_Default() throws Exception {
 334         Assert.assertEquals(EMPTY_BUILDER.getMeasurementIterations(), EMPTY_CMDLINE.getMeasurementIterations());
 335     }
 336 
 337     @Test
 338     public void testRuntime() throws Exception {
 339         CommandLineOptions cmdLine = new CommandLineOptions("-r", "34ms");
 340         Options builder = new OptionsBuilder().measurementTime(TimeValue.milliseconds(34)).build();
 341         Assert.assertEquals(builder.getMeasurementTime(), cmdLine.getMeasurementTime());
 342     }
 343 
 344     @Test
 345     public void testRuntime_Default() throws Exception {
 346         Assert.assertEquals(EMPTY_BUILDER.getMeasurementTime(), EMPTY_CMDLINE.getMeasurementTime());
 347     }
 348 
 349     @Test
 350     public void testWarmupMicros() throws Exception {
 351         CommandLineOptions cmdLine = new CommandLineOptions("-wmb", ".*", "-wmb", ".*test.*", "-wmb", "test");
 352         Options builder = new OptionsBuilder().includeWarmup(".*").includeWarmup(".*test.*").includeWarmup("test").build();
 353         Assert.assertEquals(builder.getWarmupIncludes(), cmdLine.getWarmupIncludes());
 354     }
 355 
 356     @Test
 357     public void testWarmupMicros_Default() throws Exception {
 358         Assert.assertEquals(EMPTY_BUILDER.getWarmupIncludes(), EMPTY_CMDLINE.getWarmupIncludes());
 359     }
 360 
 361     @Test
 362     public void testBenchModes() throws Exception {
 363         // TODO: Accept multiple options instead of concatenation?
 364         CommandLineOptions cmdLine = new CommandLineOptions("-bm", Mode.AverageTime.shortLabel() + "," + Mode.Throughput.shortLabel());
 365         Options builder = new OptionsBuilder().mode(Mode.AverageTime).mode(Mode.Throughput).build();
 366         Assert.assertEquals(builder.getBenchModes(), cmdLine.getBenchModes());
 367     }
 368 
 369     @Test
 370     public void testBenchModes_Default() throws Exception {
 371         Assert.assertEquals(EMPTY_BUILDER.getBenchModes(), EMPTY_CMDLINE.getBenchModes());
 372     }
 373 
 374     @Test
 375     public void testTimeunit() throws Exception {
 376         CommandLineOptions cmdLine = new CommandLineOptions("-tu", "ns");
 377         Options builder = new OptionsBuilder().timeUnit(TimeUnit.NANOSECONDS).build();
 378         Assert.assertEquals(builder.getTimeUnit(), cmdLine.getTimeUnit());
 379     }
 380 
 381     @Test
 382     public void testTimeunit_Default() throws Exception {
 383         Assert.assertEquals(EMPTY_BUILDER.getTimeUnit(), EMPTY_CMDLINE.getTimeUnit());
 384     }
 385 
 386     @Test
 387     public void testOPI() throws Exception {
 388         CommandLineOptions cmdLine = new CommandLineOptions("-opi", "42");
 389         Options builder = new OptionsBuilder().operationsPerInvocation(42).build();
 390         Assert.assertEquals(builder.getTimeUnit(), cmdLine.getTimeUnit());
 391     }
 392 
 393     @Test
 394     public void testOPI_Default() throws Exception {
 395         Assert.assertEquals(EMPTY_BUILDER.getOperationsPerInvocation(), EMPTY_CMDLINE.getOperationsPerInvocation());
 396     }
 397 
 398     @Test
 399     public void testFork() throws Exception {
 400         CommandLineOptions cmdLine = new CommandLineOptions("-f");
 401         Options builder = new OptionsBuilder().forks(1).build();
 402         Assert.assertEquals(builder.getForkCount(), cmdLine.getForkCount());
 403     }
 404 
 405     @Test
 406     public void testFork_0() throws Exception {
 407         CommandLineOptions cmdLine = new CommandLineOptions("-f", "0");
 408         Options builder = new OptionsBuilder().forks(0).build();
 409         Assert.assertEquals(builder.getForkCount(), cmdLine.getForkCount());
 410     }
 411 
 412     @Test
 413     public void testFork_1() throws Exception {
 414         CommandLineOptions cmdLine = new CommandLineOptions("-f", "1");
 415         Options builder = new OptionsBuilder().forks(1).build();
 416         Assert.assertEquals(builder.getForkCount(), cmdLine.getForkCount());
 417     }
 418 
 419     @Test
 420     public void testFork_Default() throws Exception {
 421         Assert.assertEquals(EMPTY_BUILDER.getForkCount(), EMPTY_CMDLINE.getForkCount());
 422     }
 423 
 424     @Test
 425     public void testWarmupFork_0() throws Exception {
 426         CommandLineOptions cmdLine = new CommandLineOptions("-wf", "0");
 427         Options builder = new OptionsBuilder().warmupForks(0).build();
 428         Assert.assertEquals(builder.getWarmupForkCount(), cmdLine.getWarmupForkCount());
 429     }
 430 
 431     @Test
 432     public void testWarmupFork_1() throws Exception {
 433         CommandLineOptions cmdLine = new CommandLineOptions("-wf", "1");
 434         Options builder = new OptionsBuilder().warmupForks(1).build();
 435         Assert.assertEquals(builder.getWarmupForkCount(), cmdLine.getWarmupForkCount());
 436     }
 437 
 438     @Test
 439     public void testWarmupFork_Default() throws Exception {
 440         Assert.assertEquals(EMPTY_BUILDER.getWarmupForkCount(), EMPTY_CMDLINE.getWarmupForkCount());
 441     }
 442 
 443     @Test
 444     public void testJvm() throws Exception {
 445         CommandLineOptions cmdLine = new CommandLineOptions("--jvm", "sample.jar");
 446         Options builder = new OptionsBuilder().jvm("sample.jar").build();
 447         Assert.assertEquals(builder.getJvm(), cmdLine.getJvm());
 448     }
 449 
 450     @Test
 451     public void testJvm_Default() throws Exception {
 452         Assert.assertEquals(EMPTY_BUILDER.getJvm(), EMPTY_CMDLINE.getJvm());
 453     }
 454 
 455     @Test
 456     public void testJvmArgs() throws Exception {
 457         CommandLineOptions cmdLine = new CommandLineOptions("--jvmArgs", "sample.jar");
 458         Options builder = new OptionsBuilder().jvmArgs("sample.jar").build();
 459         Assert.assertEquals(builder.getJvmArgs(), cmdLine.getJvmArgs());
 460     }
 461 
 462     @Test
 463     public void testJvmArgs_Default() throws Exception {
 464         Assert.assertEquals(EMPTY_BUILDER.getJvmArgs(), EMPTY_CMDLINE.getJvmArgs());
 465     }
 466 
 467     @Test
 468     public void testJvmArgsAppend() throws Exception {
 469         CommandLineOptions cmdLine = new CommandLineOptions("--jvmArgsAppend", "sample.jar");
 470         Options builder = new OptionsBuilder().jvmArgsAppend("sample.jar").build();
 471         Assert.assertEquals(builder.getJvmArgsAppend(), cmdLine.getJvmArgsAppend());
 472     }
 473 
 474     @Test
 475     public void testJvmArgsAppend_Default() throws Exception {
 476         Assert.assertEquals(EMPTY_BUILDER.getJvmArgsAppend(), EMPTY_CMDLINE.getJvmArgsAppend());
 477     }
 478 
 479     @Test
 480     public void testJvmArgsPrepend() throws Exception {
 481         CommandLineOptions cmdLine = new CommandLineOptions("--jvmArgsPrepend", "sample.jar");
 482         Options builder = new OptionsBuilder().jvmArgsPrepend("sample.jar").build();
 483         Assert.assertEquals(builder.getJvmArgsPrepend(), cmdLine.getJvmArgsPrepend());
 484     }
 485 
 486     @Test
 487     public void testJvmArgsPrepend_Default() throws Exception {
 488         Assert.assertEquals(EMPTY_BUILDER.getJvmArgsPrepend(), EMPTY_CMDLINE.getJvmArgsPrepend());
 489     }
 490 
 491     @Test
 492     public void testBatchSize() throws Exception {
 493         CommandLineOptions cmdLine = new CommandLineOptions("-bs", "42");
 494         Options builder = new OptionsBuilder().measurementBatchSize(42).build();
 495         Assert.assertEquals(builder.getMeasurementBatchSize(), cmdLine.getMeasurementBatchSize());
 496     }
 497 
 498     @Test
 499     public void testBatchSize_Default() throws Exception {
 500         Assert.assertEquals(EMPTY_BUILDER.getMeasurementBatchSize(), EMPTY_CMDLINE.getMeasurementBatchSize());
 501     }
 502 
 503     @Test
 504     public void testWarmupBatchSize() throws Exception {
 505         CommandLineOptions cmdLine = new CommandLineOptions("-wbs", "43");
 506         Options builder = new OptionsBuilder().warmupBatchSize(43).build();
 507         Assert.assertEquals(builder.getWarmupBatchSize(), cmdLine.getWarmupBatchSize());
 508     }
 509 
 510     @Test
 511     public void testWarmupBatchSize_Default() throws Exception {
 512         Assert.assertEquals(EMPTY_BUILDER.getWarmupBatchSize(), EMPTY_CMDLINE.getWarmupBatchSize());
 513     }
 514 
 515     @Test
 516     public void testParam_Default() {
 517         Assert.assertEquals(EMPTY_BUILDER.getParameter("sample"), EMPTY_CMDLINE.getParameter("sample"));
 518     }
 519 
 520     @Test
 521     public void testParam() throws Exception {
 522         CommandLineOptions cmdLine = new CommandLineOptions("-p", "x=1,2,3");
 523         Options builder = new OptionsBuilder().param("x", "1", "2", "3").build();
 524 
 525         Collection<String> bp = builder.getParameter("x").get();
 526         Collection<String> cp = cmdLine.getParameter("x").get();
 527 
 528         for (String b : bp) {
 529             Assert.assertTrue("CP does not contain: " + b, cp.contains(b));
 530         }
 531         for (String c : cp) {
 532             Assert.assertTrue("BP does not contain: " + c, bp.contains(c));
 533         }
 534     }
 535 
 536     @Test
 537     public void testTimeout() throws Exception {
 538         CommandLineOptions cmdLine = new CommandLineOptions("-to", "34ms");
 539         Options builder = new OptionsBuilder().timeout(TimeValue.milliseconds(34)).build();
 540         Assert.assertEquals(builder.getTimeout(), cmdLine.getTimeout());
 541     }
 542 
 543     @Test
 544     public void testTimeout_Default() throws Exception {
 545         Assert.assertEquals(EMPTY_BUILDER.getTimeout(), EMPTY_CMDLINE.getTimeout());
 546     }
 547 
 548 }