コード例 #1
0
 public String getErrorMessage(RecognitionException e) {
   if (null == walker) {
     return e.toString();
   } else {
     return getErrorMessage(walker, e);
   }
 }
コード例 #2
0
 @Test
 public void testTheKitty() {
   try {
     runTestWithString("sduhfdkufdhkjs;");
     fail("Should have thrownb an exception");
   } catch (RecognitionException e) {
     System.out.println("Expected " + e.toString());
   } catch (Exception e) {
     System.out.println("UnExpected " + e.toString());
     fail(e.getMessage());
   }
 }
コード例 #3
0
 @Test
 public void duplicatedAliasTestFrom() {
   String statement = "SELECT * FROM T1 MyAlias JOIN T2 AS MyAlias";
   try {
     traverseStatement(statement);
     fail("Parsing statement " + statement + " should fail.");
   } catch (RecognitionException e) {
     assertTrue(e instanceof FailedPredicateException);
     LOG.debug("duplicatedAliasTestFrom(), exception: " + e);
     // walker.reportError(e);
     String errorMessage = queryUtil.getErrorMessage(e);
     LOG.debug("");
     LOG.debug("duplicatedAliasTestFrom(), error message: " + errorMessage);
     assertTrue(e.toString().contains("more than once as alias in a from"));
     assertTrue(errorMessage.contains("more than once as alias in a from"));
   } catch (Exception e) {
     fail(
         "Parsing statement "
             + statement
             + " should fail with RecognitionException, but was: "
             + e.getClass());
   }
 }