1 4 package com.tc.object.bytecode.aspectwerkz; 5 6 import com.tc.aspectwerkz.expression.ExpressionContext; 7 import com.tc.aspectwerkz.expression.ExpressionVisitor; 8 import com.tc.aspectwerkz.reflect.ClassInfo; 9 10 import junit.framework.TestCase; 11 12 15 public class ExpressionInfoTest extends TestCase { 16 17 private ClassInfo classInfo; 18 19 21 public void setUp() throws Exception { 22 ClassInfoFactory classInfoFactory = new ClassInfoFactory(); 23 classInfo = classInfoFactory.getClassInfo(com.tc.object.bytecode.aspectwerkz.Target.class.getName()); 24 } 25 26 35 public void testWithinClass() throws Exception { 36 ExpressionHelper eh = new ExpressionHelper(); 37 ExpressionContext ctxt = eh.createWithinExpressionContext(this.classInfo); 38 39 String expression = ExpressionHelper.expressionPattern2WithinExpression("com.tc.object.bytecode.aspectwerkz.*"); 40 assertTrue(checkMatch(expression, ctxt)); 41 42 expression = ExpressionHelper.expressionPattern2WithinExpression("com.tc.object.bytecode.*"); 43 assertFalse(checkMatch(expression, ctxt)); 44 45 expression = ExpressionHelper.expressionPattern2WithinExpression("com.tc.object.bytecode..*"); 46 assertTrue(checkMatch(expression, ctxt)); 47 48 expression = ExpressionHelper.expressionPattern2WithinExpression("java.lang..*"); 49 assertFalse(checkMatch(expression, ctxt)); 50 51 expression = ExpressionHelper.expressionPattern2WithinExpression("*.tc..*"); 52 assertTrue(checkMatch(expression, ctxt)); 53 54 expression = ExpressionHelper.expressionPattern2WithinExpression("*.object.bytecode.aspectwerkz.*"); 55 assertFalse(checkMatch(expression, ctxt)); 56 57 expression = ExpressionHelper.expressionPattern2WithinExpression("*..object.bytecode.aspectwerkz.*"); 58 assertTrue(checkMatch(expression, ctxt)); 59 60 expression = ExpressionHelper.expressionPattern2WithinExpression("*.*.object.bytecode..*"); 61 assertTrue(checkMatch(expression, ctxt)); 62 } 63 64 private boolean checkMatch(String expression, ExpressionContext ctxt) { 65 ExpressionVisitor visitor = new ExpressionHelper().createExpressionVisitor(expression); 66 return visitor.match(ctxt); 67 } 68 } | Popular Tags |