コード例 #1
0
  @Test
  public void throw_parse_exception_if_script_has_errors() throws Exception {
    BugFreeBeanShell test =
        new BugFreeBeanShell() {
          @Override
          public void beanshellSetup() throws Exception {
            setBshFileName("src/test/resources/bsh/test1.bsh");
          }
        };
    test.setUp();

    try {
      test.exec();
      fail("A ScriptError shall be trown!");
    } catch (Throwable x) {
      then(x).isInstanceOf(ScriptException.class);
      then(((ScriptException) x).getErrorLineNumber()).isEqualTo(6);
      then(((ScriptException) x).getErrorSourceFile())
          .isEqualTo("src/test/resources/bsh/test1.bsh");
      then(((ScriptException) x).getErrorText()).isEqualTo(")");
    }
  }