Package com.carrotsearch.randomizedtesting.annotations

Examples of com.carrotsearch.randomizedtesting.annotations.ParametersFactory


    for (Method m : classModel.getAnnotatedLeafMethods(ParametersFactory.class).keySet()) {
      Validation.checkThat(m)
        .isStatic()
        .isPublic();

      ParametersFactory pfAnnotation = m.getAnnotation(ParametersFactory.class);
      assert pfAnnotation != null;

      if (!Iterable.class.isAssignableFrom(m.getReturnType())) {
        throw new RuntimeException("@" + ParametersFactory.class.getSimpleName() + " annotated " +
            "methods must be public, static and returning Iterable<Object[]>:" + m);
      }

      List<Object[]> result = new ArrayList<Object[]>();
      try {
        for (Object [] p : (Iterable<Object[]>) m.invoke(null)) {
          result.add(p);
        }
      } catch (InvocationTargetException e) {
        Rethrow.rethrow(e.getCause());
      } catch (Throwable t) {
        throw new RuntimeException("Error collecting parameters from: " + m, t);
      }

      if (result.isEmpty()) {
        throw new InternalAssumptionViolatedException("Parameters set should not be empty. Ignoring tests.");
      }

      if (pfAnnotation.shuffle()) {
        Collections.shuffle(result, new Random(runnerRandomness.getSeed()));
      }

      parameters.addAll(result);
    }
View Full Code Here


    for (Method m : classModel.getAnnotatedLeafMethods(ParametersFactory.class).keySet()) {
      Validation.checkThat(m)
        .isStatic()
        .isPublic();

      ParametersFactory pfAnnotation = m.getAnnotation(ParametersFactory.class);
      assert pfAnnotation != null;

      if (!Iterable.class.isAssignableFrom(m.getReturnType())) {
        throw new RuntimeException("@" + ParametersFactory.class.getSimpleName() + " annotated " +
            "methods must be public, static and returning Iterable<Object[]>:" + m);
      }

      List<Object[]> result = new ArrayList<Object[]>();
      try {
        for (Object [] p : (Iterable<Object[]>) m.invoke(null)) {
          result.add(p);
        }
      } catch (InvocationTargetException e) {
        Rethrow.rethrow(e.getCause());
      } catch (Throwable t) {
        throw new RuntimeException("Error collecting parameters from: " + m, t);
      }

      if (result.isEmpty()) {
        throw new InternalAssumptionViolatedException("Parameters set should not be empty. Ignoring tests.");
      }

      if (pfAnnotation.shuffle()) {
        Collections.shuffle(result, new Random(runnerRandomness.getSeed()));
      }

      parameters.addAll(result);
    }
View Full Code Here

TOP

Related Classes of com.carrotsearch.randomizedtesting.annotations.ParametersFactory

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.