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