01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.tc.object.bytecode.aspectwerkz;
05:
06: import com.tc.aspectwerkz.expression.ExpressionVisitor;
07:
08: import java.util.Arrays;
09:
10: import junit.framework.TestCase;
11:
12: /**
13: * Unit test for ExpressionHelper
14: */
15: public class ExpressionHelperTest extends TestCase {
16:
17: String[] rawExpressions = new String[] { "foo", "foo.bar",
18: "foo..bar" };
19: String[] withinExpressions = new String[] { "within(foo)",
20: "within(foo.bar)", "within(foo..bar)" };
21:
22: public void testCreateExpressionVisitors() {
23: ExpressionVisitor[] visitors = new ExpressionHelper()
24: .createExpressionVisitors(withinExpressions);
25: checkExpressionVisitors(withinExpressions, visitors);
26: }
27:
28: private void checkExpressionVisitors(String[] expressions,
29: ExpressionVisitor[] visitors) {
30: assertNotNull(visitors);
31: if (expressions == null) {
32: assertEquals(0, visitors.length);
33: } else {
34: assertEquals(expressions.length, visitors.length);
35: for (int i = 0; i < expressions.length; i++) {
36: ExpressionVisitor visitor = visitors[i];
37: assertNotNull(visitor);
38: }
39: }
40: }
41:
42: public void testExpressionPattern2WithinExpressionStringArray() {
43: String[] output = ExpressionHelper
44: .expressionPatterns2WithinExpressions(rawExpressions);
45: assertTrue(Arrays.equals(withinExpressions, output));
46: }
47:
48: }
|