Esempio n. 1
0
  /** @return the test suite */
  public static Test suite() {
    TestSuite suite = new TestSuite();
    int count = 0;

    for (Enumeration e = (new LoadingTestCollector()).collectTests(); e.hasMoreElements(); ) {
      Object o = e.nextElement();

      if (!(o instanceof String)) continue;
      String s = (String) o;

      if (s.equals("org.argouml.util.DoAllTests")) continue;

      Class candidate;
      try {
        candidate = Class.forName(s);
      } catch (ClassNotFoundException exception) {
        System.err.println("Cannot load class: " + s);
        continue;
      }
      if (!Modifier.isAbstract(candidate.getModifiers())) {
        suite.addTest(new TestSuite(candidate));
        count++;
      }
    }
    System.out.println("Number of test classes found: " + count);

    return suite;
  }
 public static TestSuite suite() {
   TestSuite result = new TestSuite();
   result.addTestSuite(TestArrayBunchCME.class);
   result.addTestSuite(TestSetBunchCME.class);
   result.addTestSuite(TestHashedBunchCME.class);
   return result;
 }
Esempio n. 3
0
  /** {@inheritDoc} */
  @Override
  public void setName(String name) {
    if (copy != null) {
      copy.setName(name);
    }

    super.setName(name);
  }
  /**
   * Creates a test suite containing tests of this class in a specific order. We'll first execute
   * tests beginning with the "test" prefix and then go to ordered tests.We first execture tests for
   * receiving messagese, so that a volatile contact is created for the sender. we'll then be able
   * to retrieve this volatile contact and send them a message on our turn. We need to do things
   * this way as the contact corresponding to the tester agent has been removed in the previous test
   * and we no longer have it in our contact list.
   *
   * @return Test a testsuite containing all tests to execute.
   */
  public static Test suite() {
    TestSuite suite = new TestSuite(TestOperationSetBasicInstantMessaging.class);

    // the following 2 need to be run in the specified order.
    suite.addTest(new TestOperationSetBasicInstantMessaging("firstTestReceiveMessage"));
    suite.addTest(new TestOperationSetBasicInstantMessaging("thenTestSendMessage"));

    return suite;
  }
Esempio n. 5
0
  /**
   * Copies non-distributed test suite into distributed one.
   *
   * @param suite Test suite to copy.
   */
  public GridJunit3TestSuite(TestSuite suite) {
    super(suite.getName());

    if (copy == null) {
      copy = new TestSuite(suite.getName());
    }

    for (int i = 0; i < suite.testCount(); i++) {
      addTest(suite.testAt(i));
    }
  }
Esempio n. 6
0
 private Collection<TestResult> parseTestResultsFromFile(File file, Device device) {
   try {
     TestSuite testSuite = serializer.read(TestSuite.class, file, STRICT);
     List<TestCase> testCases = testSuite.getTestCases();
     if ((testCases == null) || testCases.isEmpty()) {
       return new ArrayList<>(0);
     }
     return transform(testCases, toTestResult(device));
   } catch (Exception e) {
     throw new RuntimeException("Error when parsing file: " + file.getAbsolutePath(), e);
   }
 }
Esempio n. 7
0
 /**
  * Executes the test suites defined for one server in a test run.
  *
  * @param testSuites list of test suites defined for an server.
  */
 private void executeTestClasses(List<String> testSuites) {
   // go  through all test suites
   for (String testSuiteName : testSuites) {
     // get the name of the next test suite
     System.out.println("Executing suite '" + testSuiteName + "'");
     // get the configuration for the test suite
     TestSuite testSuite = config.getTestSuite(testSuiteName);
     // get an iterator over all test classes
     Iterator<Class> testClassIt = testSuite.getTestClassesIterator();
     // go through all test classes
     while (testClassIt.hasNext()) {
       Class testClass = testClassIt.next();
       jUnitRunner.run(testClass);
     }
   }
 }
Esempio n. 8
0
  /**
   * Handles test fail.
   *
   * @param result Test result.
   * @param origTest Original JUnit test.
   * @param e Exception thrown from grid.
   */
  private void handleFail(TestResult result, GridJunit3SerializableTest origTest, Throwable e) {
    // Simulate that all tests were run.
    origTest.getTest().run(result);

    // For the tests suite we assume that all tests failed because
    // entire test suite execution failed and there is no way to get
    // broken tests.
    if (origTest.getTest() instanceof GridJunit3TestSuiteProxy) {
      TestSuite suite = (((TestSuite) origTest.getTest()));

      for (int j = 0; j < suite.testCount(); j++) {
        result.addError(suite.testAt(j), e);
      }
    } else if (origTest.getTest() instanceof GridJunit3TestCaseProxy) {
      result.addError(origTest.getTest(), e);
    }
  }
 /**
  * Create TestSuite with all suites running all options.
  *
  * @param suites the String[] of paths to harness test suite files
  * @param options the String[][] of option sets to run (may be null)
  * @return Test with all TestSuites and TestCases specified in suites and options.
  */
 public static TestSuite suite(String name, String[] suites, String[][] options) {
   if (null == name) {
     name = AjcHarnessTestsUsingJUnit.class.getName();
   }
   TestSuite suite = new TestSuite(name);
   if (!HarnessJUnitUtil.isEmpty(suites)) {
     if (HarnessJUnitUtil.isEmpty(options)) {
       options = new String[][] {new String[0]};
     }
     for (int i = 0; i < suites.length; i++) {
       for (int j = 0; j < options.length; j++) {
         Test t = AjctestsAdapter.make(suites[i], options[j]);
         suite.addTest(t);
       }
     }
   }
   return suite;
 }
Esempio n. 10
0
  /**
   * Adds a test to be executed on the grid. In case of test suite, all tests inside of test suite
   * will be executed sequentially on some remote node.
   *
   * @param test Test to add.
   */
  @Override
  public void addTest(Test test) {
    if (copy == null) {
      copy = new TestSuite(getName());
    }

    // Add test to the list of local ones.
    if (test instanceof GridJunit3LocalTestSuite) {
      String testName = ((TestSuite) test).getName();

      if (!locTests.contains(testName)) {
        locTests.add(testName);
      }
    }

    if (test instanceof GridJunit3TestSuite) {
      copy.addTest(((GridJunit3TestSuite) test).copy);

      super.addTest(new GridJunit3TestSuiteProxy(((GridJunit3TestSuite) test).copy, factory));
    } else if (test instanceof GridJunit3TestSuiteProxy) {
      copy.addTest(((GridJunit3TestSuiteProxy) test).getOriginal());

      super.addTest(test);
    } else if (test instanceof GridJunit3TestCaseProxy) {
      copy.addTest(((GridJunit3TestCaseProxy) test).getGridGainJunit3OriginalTestCase());

      super.addTest(test);
    } else if (test instanceof TestSuite) {
      copy.addTest(test);

      super.addTest(new GridJunit3TestSuiteProxy((TestSuite) test, factory));
    } else {
      assert test instanceof TestCase
          : "Test must be either instance of TestSuite or TestCase: " + test;

      copy.addTest(test);

      super.addTest(factory.createProxy((TestCase) test));
    }
  }
Esempio n. 11
0
  public static Test suite() {
    TestSuite suite = new TestSuite();

    suite.addTest(new TestHistoryService("testCreateDB"));
    suite.addTest(new TestHistoryService("testWriteRecords"));
    suite.addTest(new TestHistoryService("testReadRecords"));
    suite.addTest(new TestHistoryService("testPurgeLocallyStoredHistory"));
    suite.addTest(new TestHistoryService("testCreatingHistoryIDFromFS"));
    suite.addTest(new TestHistoryService("testWriteRecordsWithMaxNumber"));

    return suite;
  }
  /**
   * Creates a test suite containing all tests of this class followed by test methods that we want
   * executed in a specified order.
   *
   * @return the Test suite to run
   */
  public static Test suite() {
    TestSuite suite = new TestSuite();

    // the following 2 need to be run in the specified order.
    // (postTestRemoveGroup() needs the group created from
    // postTestCreateGroup() )
    suite.addTest(new TestOperationSetPersistentPresence("postTestCreateGroup"));

    // rename
    suite.addTest(new TestOperationSetPersistentPresence("postTestRenameGroup"));

    suite.addTest(new TestOperationSetPersistentPresence("postTestRemoveGroup"));

    // create the contact list
    suite.addTest(new TestOperationSetPersistentPresence("prepareContactList"));

    suite.addTestSuite(TestOperationSetPersistentPresence.class);

    return suite;
  }
  /**
   * Creates a test suite containing all tests of this class followed by test methods that we want
   * executed in a specified order.
   *
   * @return Test
   */
  public static Test suite() {
    // return an (almost) empty suite if we're running in offline mode.
    if (IcqSlickFixture.onlineTestingDisabled) {
      TestSuite suite = new TestSuite();
      // the only test around here that we could run without net
      // connectivity
      suite.addTest(new TestOperationSetPresence("testSupportedStatusSetForCompleteness"));
      return suite;
    }

    TestSuite suite = new TestSuite(TestOperationSetPresence.class);

    // the following 2 need to be run in the specified order.
    // (postTestUnsubscribe() needs the subscription created from
    // postTestSubscribe() )
    suite.addTest(new TestOperationSetPresence("postTestSubscribe"));
    suite.addTest(new TestOperationSetPresence("postTestUnsubscribe"));

    // execute this test after postTestSubscribe
    // to be sure that AuthorizationHandler is installed
    suite.addTest(new TestOperationSetPresence("postTestReceiveAuthorizatinonRequest"));

    return suite;
  }
Esempio n. 14
0
 /** {@inheritDoc} */
 @Override
 public Enumeration<Test> tests() {
   return isDisabled ? copy.tests() : super.tests();
 }
Esempio n. 15
0
 /** {@inheritDoc} */
 @Override
 public Test testAt(int index) {
   return isDisabled ? copy.testAt(index) : super.testAt(index);
 }
Esempio n. 16
0
 /** {@inheritDoc} */
 @Override
 public int testCount() {
   return isDisabled ? copy.testCount() : super.testCount();
 }
  public static TestSuite getParameterBinaryOperatorTests() {
    TestSuite theSuite = new TestSuite();

    theSuite.setName("Parameter Binary Operator Test Suite");
    theSuite.addTest(BinaryOperatorWithParameterTest.getNumericParameterGreaterThanTest());
    theSuite.addTest(BinaryOperatorWithParameterTest.getNumericParameterGreaterThanEqualTest());
    theSuite.addTest(BinaryOperatorWithParameterTest.getNumericParameterLessThanTest());
    theSuite.addTest(BinaryOperatorWithParameterTest.getNumericParameterLessThanEqualTest());
    theSuite.addTest(BinaryOperatorWithParameterTest.getNumericParameterPlusTest());
    theSuite.addTest(
        BinaryOperatorWithParameterTest.getNumericParameterPlusTestWithBracketsBeforeComparison());
    theSuite.addTest(
        BinaryOperatorWithParameterTest.getNumericParameterPlusTestWithBracketsAfterComparison());
    theSuite.addTest(BinaryOperatorWithParameterTest.getNumericParameterMinusTest());
    theSuite.addTest(
        BinaryOperatorWithParameterTest.getNumericParameterMinusTestWithBracketsBeforeComparison());
    theSuite.addTest(
        BinaryOperatorWithParameterTest.getNumericParameterMinusTestWithBracketsAfterComparison());
    theSuite.addTest(BinaryOperatorWithParameterTest.getNumericParameterMultiplyTest());
    theSuite.addTest(
        BinaryOperatorWithParameterTest
            .getNumericParameterMultiplyTestWithBracketsBeforeComparison());
    theSuite.addTest(
        BinaryOperatorWithParameterTest
            .getNumericParameterMultiplyTestWithBracketsAfterComparison());
    theSuite.addTest(BinaryOperatorWithParameterTest.getNumericParameterDivideTest());
    theSuite.addTest(
        BinaryOperatorWithParameterTest
            .getNumericParameterDivideTestWithBracketsBeforeComparison());
    theSuite.addTest(
        BinaryOperatorWithParameterTest.getNumericParameterDivideTestWithBracketsAfterComparison());
    theSuite.addTest(BinaryOperatorWithParameterTest.getNumericTwoParameterMultipleOperators());
    theSuite.addTest(
        BinaryOperatorWithParameterTest
            .getNumericTwoParameterMultipleOperatorsWithBracketsAroundPlusMinus());
    theSuite.addTest(
        BinaryOperatorWithParameterTest
            .getNumericTwoParameterMultipleOperatorsWithBracketsAroundMultiply());
    return theSuite;
  }
  public boolean runSuite(String filename) throws Exception {
    if (this.verbose) {
      System.out.println(
          "Running test suite "
              + filename
              + " against "
              + this.host
              + ":"
              + this.port
              + " with "
              + this.browser);
    }
    TestSuite suite = new TestSuite();
    long start = System.currentTimeMillis();
    suite.numTestPasses = 0;
    suite.file = new File(filename);
    File suiteDirectory = suite.file.getParentFile();
    this.document = parseDocument(filename);
    Element table = (Element) this.document.getElementsByTagName("table").item(0);
    NodeList tableRows = table.getElementsByTagName("tr");
    Element tableNameRow = (Element) tableRows.item(0);
    suite.name = tableNameRow.getTextContent();
    suite.result = true;
    suite.tests = new Test[tableRows.getLength() - 1];
    for (int i = 1; i < tableRows.getLength(); i++) {
      Element tableRow = (Element) tableRows.item(i);
      Element cell = (Element) tableRow.getElementsByTagName("td").item(0);
      Element link = (Element) cell.getElementsByTagName("a").item(0);
      Test test = new Test();
      test.label = link.getTextContent();
      test.file = new File(suiteDirectory, link.getAttribute("href"));

      SeleniumHtmlClient subclient = new SeleniumHtmlClient();
      subclient.setHost(this.host);
      subclient.setPort(this.port);
      subclient.setBrowser(this.browser);
      // subclient.setResultsWriter(this.resultsWriter);
      subclient.setBaseUrl(this.baseUrl);
      subclient.setVerbose(this.verbose);
      subclient.runTest(test);
      if (test.result) {
        suite.numTestPasses++;
      }
      suite.result &= test.result;
      suite.tests[i - 1] = test;
    }
    long end = System.currentTimeMillis();

    suite.totalTime = (end - start) / 1000;

    if (this.resultsWriter != null) {
      this.resultsWriter.write("<html><head>\n");
      this.resultsWriter.write("<style type='text/css'>\n");
      this.resultsWriter.write(
          "body, table {font-family: Verdana, Arial, sans-serif;font-size: 12;}\n");
      this.resultsWriter.write("table {border-collapse: collapse;border: 1px solid #ccc;}\n");
      this.resultsWriter.write("th, td {padding-left: 0.3em;padding-right: 0.3em;}\n");
      this.resultsWriter.write("a {text-decoration: none;}\n");
      this.resultsWriter.write(".title {font-style: italic;}");
      this.resultsWriter.write(".selected {background-color: #ffffcc;}\n");
      this.resultsWriter.write(".status_done {background-color: #eeffee;}\n");
      this.resultsWriter.write(".status_passed {background-color: #ccffcc;}\n");
      this.resultsWriter.write(".status_failed {background-color: #ffcccc;}\n");
      this.resultsWriter.write(
          ".breakpoint {background-color: #cccccc;border: 1px solid black;}\n");
      this.resultsWriter.write("</style>\n");
      this.resultsWriter.write("<title>" + suite.name + "</title>\n");
      this.resultsWriter.write("</head><body>\n");
      this.resultsWriter.write("<h1>Test suite results </h1>\n\n");
      this.resultsWriter.write("<table>\n");
      this.resultsWriter.write(
          "<tr>\n<td>result:</td>\n<td>" + (suite.result ? "passed" : "failed") + "</td>\n</tr>\n");
      this.resultsWriter.write(
          "<tr>\n<td>totalTime:</td>\n<td>" + suite.totalTime + "</td>\n</tr>\n");
      this.resultsWriter.write(
          "<tr>\n<td>numTestTotal:</td>\n<td>" + suite.tests.length + "</td>\n</tr>\n");
      this.resultsWriter.write(
          "<tr>\n<td>numTestPasses:</td>\n<td>" + suite.numTestPasses + "</td>\n</tr>\n");
      int numTestFailures = suite.tests.length - suite.numTestPasses;
      this.resultsWriter.write(
          "<tr>\n<td>numTestFailures:</td>\n<td>" + numTestFailures + "</td>\n</tr>\n");
      this.resultsWriter.write("<tr>\n<td>numCommandPasses:</td>\n<td>0</td>\n</tr>\n");
      this.resultsWriter.write("<tr>\n<td>numCommandFailures:</td>\n<td>0</td>\n</tr>\n");
      this.resultsWriter.write("<tr>\n<td>numCommandErrors:</td>\n<td>0</td>\n</tr>\n");
      this.resultsWriter.write("<tr>\n<td>Selenium Version:</td>\n<td>2.24</td>\n</tr>\n");
      this.resultsWriter.write("<tr>\n<td>Selenium Revision:</td>\n<td>.1</td>\n</tr>\n");

      // test suite
      this.resultsWriter.write("<tr>\n<td>\n");
      this.resultsWriter.write(
          "<table id=\"suiteTable\" class=\"selenium\" border=\"1\" cellpadding=\"1\" cellspacing=\"1\"><tbody>\n");
      this.resultsWriter.write(
          "<tr class=\"title "
              + (suite.result ? "status_passed" : "status_failed")
              + "\"><td><b>Test Suite</b></td></tr>\n");

      int i = 0;
      for (Test test : suite.tests) {
        this.resultsWriter.write(
            "<tr class=\""
                + (test.result ? "status_passed" : "status_failed")
                + "\"><td><a href=\"#testresult"
                + i
                + "\">"
                + test.name
                + "</a></td></tr>");
        i++;
      }
      this.resultsWriter.write(
          "</tbody></table>\n</td>\n<td>&nbsp;</td>\n</tr>\n</table>\n<table>");
      int j = 0;
      for (Test test : suite.tests) {
        this.resultsWriter.write(
            "<tr><td><a name=\"testresult" + j + "\">" + test.file + "</a><br/><div>\n");
        this.resultsWriter.write("<table border=\"1\" cellpadding=\"1\" cellspacing=\"1\">\n");
        this.resultsWriter.write(
            "<thead>\n<tr class=\"title "
                + (test.result ? "status_passed" : "status_failed")
                + "\"><td rowspan=\"1\" colspan=\"3\">"
                + test.name
                + "</td></tr>");
        this.resultsWriter.write("</thead><tbody>\n");
        for (Command command : test.commands) {
          boolean result = command.result.startsWith("OK");
          boolean isAssert = command.cmd.startsWith("assert") || command.cmd.startsWith("verify");
          ;
          if (!isAssert) {
            this.resultsWriter.write(
                "<tr class=\"" + (result ? "status_done" : "") + "\">\n<td>\n");
          } else {
            this.resultsWriter.write(
                "<tr class=\"" + (result ? "status_passed" : "status_failed") + "\">\n<td>\n");
          }
          this.resultsWriter.write(command.cmd);
          this.resultsWriter.write("</td>\n");
          if (command.args != null) {
            for (String arg : Arrays.asList(command.args)) {
              this.resultsWriter.write("<td>" + arg + "</td>\n");
            }
          }
        }
        this.resultsWriter.write("</tr>\n");
        this.resultsWriter.write("</tbody></table>\n");
        this.resultsWriter.write("</div></td>\n<td>&nbsp;</td>\n</tr>");

        j++;
      }

      int k = 0;
      for (Test test : suite.tests) {

        k++;
      }

      this.resultsWriter.write("</tbody></table>\n</td><td>&nbsp;</td>\n</tr>\n</table>\n");
      this.resultsWriter.write("</body></html>");
    }
    return suite.result;
  }
Esempio n. 19
0
  /**
   * Runs all tests belonging to this test suite on the grid.
   *
   * @param result Test result collector.
   */
  @Override
  public void run(TestResult result) {
    if (isDisabled) {
      copy.run(result);
    } else {
      GridTestRouter router = createRouter();

      Grid grid = startGrid();

      try {
        List<GridTaskFuture<?>> futs = new ArrayList<GridTaskFuture<?>>(testCount());

        List<GridJunit3SerializableTest> tests =
            new ArrayList<GridJunit3SerializableTest>(testCount());

        for (int i = 0; i < testCount(); i++) {
          Test junit = testAt(i);

          GridJunit3SerializableTest test;

          if (junit instanceof TestSuite) {
            test = new GridJunit3SerializableTestSuite((TestSuite) junit);
          } else {
            assert junit instanceof TestCase
                : "Test must be either TestSuite or TestCase: " + junit;

            test = new GridJunit3SerializableTestCase((TestCase) junit);
          }

          tests.add(test);

          if (clsLdr == null) {
            clsLdr = U.detectClassLoader(junit.getClass());
          }

          futs.add(
              grid.execute(
                  new GridJunit3Task(junit.getClass(), clsLdr),
                  new GridJunit3Argument(router, test, locTests.contains(test.getName())),
                  timeout));
        }

        for (int i = 0; i < testCount(); i++) {
          GridTaskFuture<?> fut = futs.get(i);

          GridJunit3SerializableTest origTest = tests.get(i);

          try {
            GridJunit3SerializableTest resTest = (GridJunit3SerializableTest) fut.get();

            origTest.setResult(resTest);

            origTest.getTest().run(result);
          } catch (GridException e) {
            handleFail(result, origTest, e);
          }
        }
      } finally {
        stopGrid();
      }
    }
  }