Esempio n. 1
0
 @SuppressWarnings("unchecked")
 @Override
 public void run(TestResult result) {
   result.startTest(this);
   ScriptRuntime runtime =
       new ScriptRuntime(script, environment, false, new HashMap<String, Object>());
   runtime.setLabelEvaluator(new EnvironmentLabelEvaluator(label));
   runtime.run();
   // map the exception (if any)
   if (runtime.getException() != null) {
     result.addError(this, runtime.getException());
   }
   // check all the validations that occurred
   List<Validation<?>> validations = (List<Validation<?>>) runtime.getContext().get("$validation");
   for (Validation<?> validation : validations) {
     if (validation.getSeverity() == Severity.ERROR
         || validation.getSeverity() == Severity.CRITICAL) {
       result.addFailure(this, new AssertionFailedError(validation.toString()));
       if (!addAllFailures) {
         break;
       }
     }
   }
   result.endTest(this);
 }
 private ExecutionContext getExpected(ExecutionEnvironment environment) {
   if (!environments.containsKey(environment)) {
     synchronized (environments) {
       if (!environments.containsKey(environment)) {
         Script script = getScript(environment);
         if (script == null) {
           environments.put(environment, null);
         } else {
           ScriptRuntime runtime = new ScriptRuntime(script, environment, false, null);
           runtime.run();
           if (runtime.getException() != null) {
             runtime.getException().printStackTrace();
             environments.put(environment, null);
           } else {
             environments.put(environment, runtime.getExecutionContext());
           }
         }
       }
     }
   }
   return environments.get(environment);
 }