Ejemplo n.º 1
0
 public List<CompilationError> failCompile() {
   try {
     strategy.compile();
     throw AbstractTestCase.failure("Was expecting compilation to fail");
   } catch (CompilationException e) {
     return e.getErrors();
   } catch (Exception e) {
     throw AbstractTestCase.failure(e);
   }
 }
Ejemplo n.º 2
0
  public void render(final RenderBridge requestBridge) throws Throwable {

    //
    Collection<CompilationError> errors = null;
    try {
      boot();
    } catch (CompilationException e) {
      errors = e.getErrors();
    }

    //
    if (errors == null || errors.isEmpty()) {

      //
      if (errors != null) {
        requestBridge.purgeSession();
      }

      //
      try {
        TrimmingException.invoke(
            new TrimmingException.Callback() {
              public void call() throws Throwable {
                try {
                  runtime.getContext().invoke(requestBridge);
                } catch (ApplicationException e) {
                  throw e.getCause();
                }
              }
            });
      } catch (TrimmingException e) {
        if (config.isProd()) {
          throw e.getSource();
        } else {
          StringWriter writer = new StringWriter();
          PrintWriter printer = new PrintWriter(writer);
          renderThrowable(printer, e);
          requestBridge.setResponse(Response.ok(writer.getBuffer()));
        }
      } finally {
        requestBridge.close();
      }
    } else {
      try {
        StringWriter writer = new StringWriter();
        PrintWriter printer = new PrintWriter(writer);
        renderErrors(printer, errors);
        requestBridge.setResponse(Response.ok(writer.getBuffer()));
      } finally {
        requestBridge.close();
      }
    }
  }