Package uk.ac.uea.threadr

Examples of uk.ac.uea.threadr.ThreadTest


    Class<?> clazz = obj.getClass();
    logger.fine(String.format("Testing: %s", clazz.getName()));
   
    /* Use every test provided to see if the class is thread safe. */
    for (Object t : tests) {
      ThreadTest test = (ThreadTest)t;
      ThreadSafety result = test.test(clazz);
      if (result != ThreadSafety.THREAD) {
        /* Any test that is not thread safe is failed. */
        failedTests.add(test.getClass());
      }
      /* If a result was returned, and it's worse than the stored one. */
      if (result != null
          && (result.val() < safety.val())) {
        safety = result; // Set the new safety result.
      }
    }
   
    /* Check the task can be serialised if it's VM safe. */
    if (safety == ThreadSafety.VM
      && !isSerialisabe(obj)) {
      /* If a task cannot be serialised, it's unsafe. */
      safety = ThreadSafety.SEQUENTIAL;
    }
   
    /* Print out the thread safeness of the class. */
    switch (safety) {
    case SEQUENTIAL:
      logger.info(String.format("Class %s - Sequential safe",
          clazz.getName()));
      break;
    case THREAD:
      logger.info(String.format("Class %s - Thread safe",
          clazz.getName()));
      break;
    case VM:
      logger.info(String.format("Class %s - Virtual Machine safe",
          clazz.getName()));
      break;
    default:
      logger.info(String.format("Unknown test result for class %s",
          clazz.getName()));
    }
    /* Print any failed tests to the loggers fine output. */
    if (failedTests.size() > 0) {
      StringBuilder errors = new StringBuilder("Failed tests:\n");
      for (Class<?> test : failedTests) {
        errors.append('\t').append(test.getName()).append('\n');
      }
     
      logger.fine(errors.toString());
    }
   
View Full Code Here


   * returned.
   */
  @Test
  public final void testAddTest() {
   
    ThreadTest test = new ReferenceTest();

    instance = new Threadr();
    instance.addTest(test);
   
    Set<? extends ThreadTest> tests = instance.getTests();
View Full Code Here

TOP

Related Classes of uk.ac.uea.threadr.ThreadTest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.