Search in sources :

Example 1 with IParser

use of org.eclipse.xtext.parser.IParser in project xtext-core by eclipse.

the class ParseErrorHandlingTest method testExpectNoSuchMethodException.

@Test
public void testExpectNoSuchMethodException() throws Exception {
    IParser parser = get(IParser.class);
    ParserRule parserRule = XtextFactory.eINSTANCE.createParserRule();
    parserRule.setName("ruleDoesNotExist");
    try {
        parser.parse(parserRule, new StringReader("empty"));
        fail("Expected WrappedException");
    } catch (ParseException e) {
        assertTrue(e.getCause() instanceof WrappedException);
        WrappedException cause = (WrappedException) e.getCause();
        assertTrue(cause.getCause() instanceof NoSuchMethodException);
    }
}
Also used : ParserRule(org.eclipse.xtext.ParserRule) WrappedException(org.eclipse.emf.common.util.WrappedException) StringReader(java.io.StringReader) ParseException(org.eclipse.xtext.parser.ParseException) IParser(org.eclipse.xtext.parser.IParser) Test(org.junit.Test)

Aggregations

StringReader (java.io.StringReader)1 WrappedException (org.eclipse.emf.common.util.WrappedException)1 ParserRule (org.eclipse.xtext.ParserRule)1 IParser (org.eclipse.xtext.parser.IParser)1 ParseException (org.eclipse.xtext.parser.ParseException)1 Test (org.junit.Test)1