@Test public void testInvalidSyntax_Catches() throws Exception { DRLParser parser = parseResource("invalid_syntax.drl"); parser.compilationUnit(); assertTrue(parser.hasErrors()); }
@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 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 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" ); } }
@Test(timeout=10*1000) public void testCheckRuleHeaderLocationDetermination3() { String input = "rule \"Hello World\" ruleflow-group \"hello\" s"; DRLParser parser = getParser(input); parser.enableEditorInterface(); try { parser.compilationUnit(); } catch (Exception ex) { } assertEquals(Location.LOCATION_RULE_HEADER, getLastIntegerValue(parser .getEditorInterface().get(0).getContent())); }
@Test(timeout=10*1000) public void testCheckRuleHeaderLocationDetermination_dialect1() { String input = "rule MyRule \n" + " dialect \"java\""; DRLParser parser = getParser(input); parser.enableEditorInterface(); try { parser.compilationUnit(); } catch (Exception ex) { } assertEquals(Location.LOCATION_RULE_HEADER, getLastIntegerValue(parser .getEditorInterface().get(0).getContent())); }
@Test(timeout=10*1000) public void testCheckRuleHeaderLocationDetermination() { String input = "rule MyRule "; DRLParser parser = getParser(input); parser.enableEditorInterface(); try { parser.compilationUnit(); } catch (Exception ex) { } assertEquals(Location.LOCATION_RULE_HEADER, getLastIntegerValue(parser .getEditorInterface().get(0).getContent())); }
@Test(timeout=10*1000) public void testCheckQueryLocationDetermination_RULE_HEADER1() { String input = "query MyQuery "; DRLParser parser = getParser(input); parser.enableEditorInterface(); try { parser.compilationUnit(); } catch (Exception ex) { } assertEquals(Location.LOCATION_RULE_HEADER, getLastIntegerValue(parser .getEditorInterface().get(0).getContent())); }
@Test(timeout=10*1000) public void testCheckQueryLocationDetermination_RULE_HEADER2() { String input = "query \"MyQuery\" "; DRLParser parser = getParser(input); parser.enableEditorInterface(); try { parser.compilationUnit(); } catch (Exception ex) { } assertEquals(Location.LOCATION_RULE_HEADER, getLastIntegerValue(parser .getEditorInterface().get(0).getContent())); }
@Test(timeout=10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START6() { String input = "rule MyRule \n" + " when \n" + " Class ( \n" + " "; DRLParser parser = getParser(input); parser.enableEditorInterface(); try { parser.compilationUnit(); } catch (Exception ex) { } assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START, getLastIntegerValue(parser.getEditorInterface().get(0) .getContent())); }
@Test(timeout=10*1000) public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START21() { String input = "rule MyRule \n" + " when \n" + " not Class ("; DRLParser parser = getParser(input); parser.enableEditorInterface(); try { parser.compilationUnit(); } catch (Exception ex) { } assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START, getLastIntegerValue(parser.getEditorInterface().get(0) .getContent())); }
@Test(timeout=10*1000) public void testCheckRHSLocationDetermination_startOfNewlINE() { String input = "rule MyRule \n" + " when\n" + " Class ( )\n" + " then\n" + " assert(null);\n" + " "; DRLParser parser = getParser(input); parser.enableEditorInterface(); try { parser.compilationUnit(); } catch (Exception ex) { } assertEquals(Location.LOCATION_RHS, getLastIntegerValue(parser .getEditorInterface().get(0).getContent())); }
@Test(timeout=10*1000) public void testCheckRuleHeaderLocationDetermination_dialect2() { String input = "rule MyRule \n" + " dialect \"mvel\""; DRLParser parser = getParser(input); parser.enableEditorInterface(); try { parser.compilationUnit(); } catch (Exception ex) { } assertEquals(Location.LOCATION_RULE_HEADER, getLastIntegerValue(parser .getEditorInterface().get(0).getContent())); }
@Test(timeout=10*1000) public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR22() { String input = "rule MyRule \n" + " when \n" + " Class ( ) or "; DRLParser parser = getParser(input); parser.enableEditorInterface(); try { parser.compilationUnit(); } catch (Exception ex) { } assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_AND_OR, getLastIntegerValue(parser.getEditorInterface().get(0) .getContent())); }