Ejemplo n.º 1
0
  /**
   * @param clazz the test class
   * @throws InitializationError in case the initialization fails
   */
  public ProcessorSuiteRunner(Class<?> clazz) throws InitializationError {
    super(clazz);

    ProcessorSuite suite = clazz.getAnnotation(ProcessorSuite.class);

    if (null == suite) {
      throw new InitializationError(
          "The test class must be annotated with " + ProcessorSuite.class.getName());
    }

    if (suite.processorTypes().length == 0) {
      throw new InitializationError("ProcessorSuite#processorTypes must not be empty");
    }

    Constructor<? extends CommandLineEnhancer> cliEnhancerConstructor = null;
    if (suite.commandLineEnhancer() != CommandLineEnhancer.class) {
      try {
        cliEnhancerConstructor = suite.commandLineEnhancer().getConstructor();
      } catch (NoSuchMethodException e) {
        throw new InitializationError(
            suite.commandLineEnhancer().getName() + " does not have a default constructor.");
      } catch (SecurityException e) {
        throw new InitializationError(e);
      }
    }

    methods = initializeTestCases(suite, cliEnhancerConstructor);
  }
Ejemplo n.º 2
0
  private List<ProcessorTestCase> initializeTestCases(
      ProcessorSuite suite, Constructor<? extends CommandLineEnhancer> cliEnhancerConstructor) {
    List<ProcessorType> types = new ArrayList<ProcessorType>();

    for (ProcessorType compiler : suite.processorTypes()) {
      if (compiler.getIncluded().length > 0) {
        types.addAll(Arrays.asList(compiler.getIncluded()));
      } else {
        types.add(compiler);
      }
    }

    List<ProcessorTestCase> result = new ArrayList<ProcessorTestCase>(types.size());

    for (ProcessorType type : types) {
      result.add(new ProcessorTestCase(suite.baseDir(), type, cliEnhancerConstructor));
    }

    return result;
  }