Ejemplo n.º 1
0
 public void testMutlipleOutObjects() throws Exception {
   fContext.setConfigProperty("createTwoObjects", true);
   ExecutionDiagnostic diagnostic = fExecutor.execute(fContext, fInput, fOutput);
   assertEquals(Diagnostic.OK, diagnostic.getSeverity());
   assertOutputObject(fOutput);
   assertEquals(2, fOutput.getContents().size());
 }
Ejemplo n.º 2
0
  public void testLogging() throws Exception {
    StringBufferLog log = new StringBufferLog();
    fContext.setLog(log);

    final ExecutionDiagnostic diagnostic = fExecutor.execute(fContext, fInput, fOutput);
    assertEquals(Diagnostic.OK, diagnostic.getSeverity());
    assertTrue(log.getContents().contains("Hello")); // $NON-NLS-1$
  }
Ejemplo n.º 3
0
  public void testAssertFailed() throws Exception {
    fContext.setConfigProperty("assertFail", Boolean.TRUE); // $NON-NLS-1$
    ExecutionDiagnostic diagnostic = fExecutor.execute(fContext, fInput, fOutput);

    assertEquals(Diagnostic.ERROR, diagnostic.getSeverity());
    assertEquals(ExecutionDiagnostic.FATAL_ASSERTION, diagnostic.getCode());
    assertFalse(diagnostic.getStackTrace().isEmpty());
    assertTrue(fOutput.getContents().isEmpty());
  }
Ejemplo n.º 4
0
  public void testInterruption() throws Exception {
    final EvaluationMonitor monitor =
        new EvaluationMonitor() {
          boolean canceled = false;

          public void cancel() {
            canceled = true;
          }

          public boolean isCanceled() {
            return canceled;
          }
        };

    Log log =
        new Log() {
          public void log(int level, String message, Object param) {
            monitor.cancel();
          }

          public void log(int level, String message) {
            monitor.cancel();
          }

          public void log(String message, Object param) {
            monitor.cancel();
          }

          public void log(String message) {
            monitor.cancel();
          }
        };

    fContext.setMonitor(monitor);
    fContext.setLog(log);

    final ExecutionDiagnostic diagnostic = fExecutor.execute(fContext, fInput, fOutput);
    assertEquals(Diagnostic.CANCEL, diagnostic.getSeverity());
    assertEquals(ExecutionDiagnostic.USER_INTERRUPTED, diagnostic.getCode());
    assertEquals(1, diagnostic.getStackTrace().size());
  }
Ejemplo n.º 5
0
  public void testStackTrace() throws Exception {
    // provoke an exception
    fContext.setConfigProperty("assertFail", Boolean.TRUE); // $NON-NLS-1$
    ExecutionDiagnostic diagnostic = fExecutor.execute(fContext, fInput, fOutput);
    assertEquals(2, diagnostic.getStackTrace().size());

    StringWriter strWr = new StringWriter();
    diagnostic.printStackTrace(new PrintWriter(strWr));
    strWr.flush();

    StringWriter expected = new StringWriter();
    PrintWriter pwr = new PrintWriter(expected);
    pwr.println("	at Ecore2Ecore::checkAssert(Ecore2Ecore.qvto:27)"); // $NON-NLS-1$
    pwr.print("	at Ecore2Ecore::main(Ecore2Ecore.qvto:12)"); // $NON-NLS-1$
    pwr.flush();

    assertEquals(expected.toString(), strWr.toString());
  }