Exemple #1
0
 @Test
 public void testMultipleErrors() throws Exception {
   DRLParser parser = parseResource("multiple_errors.drl");
   parser.compilationUnit();
   assertTrue(parser.hasErrors());
   assertEquals(2, parser.getErrors().size());
 }
Exemple #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());
 }
Exemple #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");
   }
 }
Exemple #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"));
  }
Exemple #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());
  }
Exemple #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());
  }
Exemple #7
0
 @Test
 public void testTempleteError() throws Exception {
   DRLParser parser = parseResource("template_test_error.drl");
   parser.compilationUnit();
   assertTrue(parser.hasErrors());
 }
Exemple #8
0
 @Test
 public void testLexicalError() throws Exception {
   DRLParser parser = parseResource("lex_error.drl");
   parser.compilationUnit();
   assertTrue(parser.hasErrors());
 }
Exemple #9
0
 @Test
 public void testPackageGarbage() throws Exception {
   DRLParser parser = parseResource("package_garbage.drl");
   parser.compilationUnit();
   assertTrue(parser.hasErrors());
 }
Exemple #10
0
 @Test
 public void testInvalidSyntax_Catches() throws Exception {
   DRLParser parser = parseResource("invalid_syntax.drl");
   parser.compilationUnit();
   assertTrue(parser.hasErrors());
 }
Exemple #11
0
 @Test
 public void testNotBindindShouldBarf() throws Exception {
   final DRLParser parser = parseResource("not_with_binding_error.drl");
   parser.compilationUnit();
   assertTrue(parser.hasErrors());
 }