コード例 #1
0
  public void testGetPropertyName() throws Exception {
    final String PROPERTY = "a('aa').b[1].c";

    // Should parse and result in the exact same property name
    Pair<Tree, CommonTokenStream> parsed = SupportParserHelper.parseEventProperty(PROPERTY);
    Tree propertyNameExprNode = parsed.getFirst();
    ASTUtil.dumpAST(propertyNameExprNode);
    String propertyName = ASTFilterSpecHelper.getPropertyName(propertyNameExprNode, 0);
    assertEquals(PROPERTY, propertyName);

    // Try AST with tokens separated, same property name
    parsed = SupportParserHelper.parseEventProperty("a(    'aa'   ). b [ 1 ] . c");
    propertyNameExprNode = parsed.getFirst();
    propertyName = ASTFilterSpecHelper.getPropertyName(propertyNameExprNode, 0);
    assertEquals(PROPERTY, propertyName);
  }
コード例 #2
0
 public void testGetPropertyNameEscaped() throws Exception {
   final String PROPERTY = "a\\.b\\.c";
   Pair<Tree, CommonTokenStream> parsed = SupportParserHelper.parseEventProperty(PROPERTY);
   Tree propertyNameExprNode = parsed.getFirst();
   ASTUtil.dumpAST(propertyNameExprNode);
   String propertyName = ASTFilterSpecHelper.getPropertyName(propertyNameExprNode, 0);
   assertEquals(PROPERTY, propertyName);
 }