Example #1
0
 @Test
 public void testMultipleErrors() throws Exception {
   DRLParser parser = parseResource("multiple_errors.drl");
   parser.compilationUnit();
   assertTrue(parser.hasErrors());
   assertEquals(2, parser.getErrors().size());
 }
Example #2
0
 @Test
 public void testEvalWithSemicolon() throws Exception {
   DRLParser parser = parseResource("eval_with_semicolon.drl");
   parser.compilationUnit();
   assertTrue(parser.hasErrors());
   assertEquals(1, parser.getErrorMessages().size());
   assertEquals("ERR 102", parser.getErrors().get(0).getErrorCode());
 }
Example #3
0
 @Test
 public void testCommaMisuse() throws Exception {
   final DRLParser parser = parseResource("comma_misuse.drl");
   try {
     parser.compilationUnit();
     assertTrue("Parser should have raised errors", parser.hasErrors());
   } catch (NullPointerException npe) {
     fail("Should not raise NPE");
   }
 }
Example #4
0
  @Test
  public void testNPEOnParser() throws Exception {
    final DRLParser parser = parseResource("npe_on_parser.drl");
    parser.compilationUnit();
    assertTrue("Parser should have raised errors", parser.hasErrors());

    assertEquals(1, parser.getErrors().size());

    assertTrue(parser.getErrors().get(0).getErrorCode().equals("ERR 102"));
  }
Example #5
0
  @Test
  public void testErrorMessageForMisplacedParenthesis() throws Exception {
    final DRLParser parser = parseResource("misplaced_parenthesis.drl");
    parser.compilationUnit();

    assertTrue("Parser should have raised errors", parser.hasErrors());

    assertEquals(1, parser.getErrors().size());

    assertEquals("ERR 102", parser.getErrors().get(0).getErrorCode());
  }
Example #6
0
  @Test
  public void testExpanderErrorsAfterExpansion() throws Exception {

    String name = "expander_post_errors.dslr";
    Expander expander = new DefaultExpander();
    String expanded = expander.expand(this.getReader(name));

    DRLParser parser = parse(name, expanded);
    parser.compilationUnit();
    assertTrue(parser.hasErrors());

    assertEquals(1, parser.getErrors().size());
    DroolsParserException err = (DroolsParserException) parser.getErrors().get(0);
    assertEquals(6, err.getLineNumber());
  }
Example #7
0
 @Test
 public void testTempleteError() throws Exception {
   DRLParser parser = parseResource("template_test_error.drl");
   parser.compilationUnit();
   assertTrue(parser.hasErrors());
 }
Example #8
0
 @Test
 public void testLexicalError() throws Exception {
   DRLParser parser = parseResource("lex_error.drl");
   parser.compilationUnit();
   assertTrue(parser.hasErrors());
 }
Example #9
0
 @Test
 public void testPackageGarbage() throws Exception {
   DRLParser parser = parseResource("package_garbage.drl");
   parser.compilationUnit();
   assertTrue(parser.hasErrors());
 }
Example #10
0
 @Test
 public void testInvalidSyntax_Catches() throws Exception {
   DRLParser parser = parseResource("invalid_syntax.drl");
   parser.compilationUnit();
   assertTrue(parser.hasErrors());
 }
Example #11
0
 @Test
 public void testNotBindindShouldBarf() throws Exception {
   final DRLParser parser = parseResource("not_with_binding_error.drl");
   parser.compilationUnit();
   assertTrue(parser.hasErrors());
 }