private void runTest(AbstractTest test, String name, byte[] conf) {
    if (true) {
      // Create the repository directory
      File dir = new File(new File("target", "repository"), name + "-" + test);
      dir.mkdirs();

      try {
        // Copy the configuration file into the repository directory
        File xml = new File(dir, "repository.xml");
        OutputStream output = FileUtils.openOutputStream(xml);
        try {
          output.write(conf, 0, conf.length);
        } finally {
          output.close();
        }

        // Create the repository
        RepositoryImpl repository = createRepository(dir, xml);
        try {
          // Run the test
          DescriptiveStatistics statistics = runTest(test, repository);
          if (statistics.getN() > 0) {
            writeReport(test.toString(), name, statistics);
          }
        } finally {
          repository.shutdown();
        }
      } catch (Throwable t) {
        System.out.println("Unable to run " + test + ": " + t.getMessage());
        t.printStackTrace();
      } finally {
        //                FileUtils.deleteQuietly(dir);
      }
    }
  }
Example #2
0
 @Test
 public void transitiveUnionTest() {
   int number = 10;
   QuickFind quickFind = new QuickFind(number);
   Assert.assertFalse(quickFind.areConnected(1, 8));
   quickFind.union(0, 1);
   quickFind.union(8, 9);
   quickFind.union(0, 9);
   Assert.assertTrue(quickFind.areConnected(1, 8));
   super.printArray(quickFind.getId());
 }
Example #3
0
  @Override
  public boolean equals(Object obj) {
    if (this == obj) return true;
    if (obj == null) return false;
    if (getClass() != obj.getClass()) return false;
    Foo other = (Foo) obj;

    return AbstractTest.isEqual(this.someInt, other.someInt)
        && AbstractTest.isEqual(this.someString, other.someString)
        && AbstractTest.isEqual(this.someBar, other.someBar)
        && AbstractTest.isEqual(this.someEnum, other.someEnum)
        && AbstractTest.isEqual(this.someBytes, other.someBytes)
        && AbstractTest.isEqual(this.someBoolean, other.someBoolean)
        && AbstractTest.isEqual(this.someFloat, other.someFloat)
        && AbstractTest.isEqual(this.someDouble, other.someDouble)
        && AbstractTest.isEqual(this.someLong, other.someLong);
  }
  private DescriptiveStatistics runTest(AbstractTest test, Repository repository) throws Exception {
    DescriptiveStatistics statistics = new DescriptiveStatistics();

    test.setUp(repository, credentials);
    try {
      // Run a few iterations to warm up the system
      long warmupEnd = System.currentTimeMillis() + warmup * 1000;
      while (System.currentTimeMillis() < warmupEnd) {
        test.execute();
      }

      // Run test iterations, and capture the execution times
      long runtimeEnd = System.currentTimeMillis() + runtime * 1000;
      while (System.currentTimeMillis() < runtimeEnd) {
        statistics.addValue(test.execute());
      }
    } finally {
      test.tearDown();
    }

    return statistics;
  }
  // Prepare initial settings that will be tested.
  private static void initConfigParm() {
    // Set the configure parameters to be --enable-jeff via user-defined
    // options
    SWTBotShell shell = openProperties("Autotools", "Configure Settings");
    bot.treeWithLabel("Configure Settings").expandNode("configure").select("Advanced");
    SWTBotText text = bot.textWithLabel("Additional command-line options");
    text.typeText("--enable-jeff");
    bot.button("OK").click();
    bot.waitUntil(Conditions.shellCloses(shell), 120000);

    // Create new build configurations that will be used throughout tests
    projectExplorer.bot().tree().select(projectName);
    clickContextMenu(
        projectExplorer.bot().tree().select(projectName), "Build Configurations", "Manage...");
    shell = bot.shell(projectName + ": Manage Configurations");
    shell.activate();
    bot.button("New...").click();
    shell = bot.shell("Create New Configuration");
    shell.activate();
    SWTBotText t = bot.textWithLabel("Name:");
    t.setText("debug");
    AbstractTest.clickRadioButtonInGroup("Existing configuration", "Copy settings from");
    bot.button("OK").click();
    shell = bot.shell(projectName + ": Manage Configurations");
    shell.activate();
    bot.button("New...").click();
    shell = bot.shell("Create New Configuration");
    shell.activate();
    t = bot.textWithLabel("Name:");
    t.setText("default");
    AbstractTest.clickRadioButtonInGroup("Default configuration", "Copy settings from");
    bot.button("OK").click();
    shell = bot.shell(projectName + ": Manage Configurations");
    shell.activate();
    bot.button("OK").click();
    bot.waitUntil(Conditions.shellCloses(shell));
  }
 @Override
 @Before
 public void setUp() {
   super.setUp();
 }
 /**
  * Prepares the test class for execution of web tests. Builds a MockMvc instance. Call this method
  * from the concrete JUnit test class in the <code>@Before</code> setup method.
  */
 protected void setUp() {
   super.setUp();
   mvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).build();
 }