1
/*******************************************************************************
2
* Copyright (c) 2005 Contributors.
4
* This program and the accompanying materials are made available
5
* under the terms of the Eclipse Public License v1.0
6
* which accompanies this distribution and is available at
7
* http://eclipse.org/legal/epl-v10.html
10
* Alexandre Vasseur initial implementation
11
*******************************************************************************/
12
package org.aspectj.weaver.patterns;
14
import junit.framework.TestCase;
16
import java.util.HashSet;
18
import java.util.Iterator;
19
import java.io.LineNumberReader;
20
import java.io.FileReader;
23
* @author <a href="mailto:alex AT gnilux DOT com">Alexandre Vasseur</a>
25
public class VisitorTestCase extends TestCase {
27
private Set pointcuts = new HashSet();
28
private Set typePatterns = new HashSet();
30
protected void setUp() throws Exception {
32
LineNumberReader rp = new LineNumberReader(new FileReader("../weaver/testdata/visitor.pointcuts.txt"));
35
LineNumberReader rt = new LineNumberReader(new FileReader("../weaver/testdata/visitor.typepatterns.txt"));
36
feed(rt, typePatterns);
40
private void feed(LineNumberReader r, Set set) throws Exception {
41
for (String line = r.readLine(); line != null; line = r.readLine()) {
46
public void testPointcuts() {
47
if (pointcuts.isEmpty()) {
48
fail("Empty pointcuts file!");
50
for (Iterator iterator = pointcuts.iterator(); iterator.hasNext();) {
51
String pointcut = (String) iterator.next();
53
PatternNodeVisitor.DumpPointcutVisitor.check(pointcut);
54
} catch (Throwable t) {
56
fail("Failed on '"+pointcut+"': " +t.toString());
61
public void testTypePatterns() {
62
if (typePatterns.isEmpty()) {
63
fail("Empty typePatterns file!");
65
for (Iterator iterator = typePatterns.iterator(); iterator.hasNext();) {
66
String tp = (String) iterator.next();
68
TypePattern p = new PatternParser(tp).parseTypePattern();
69
PatternNodeVisitor.DumpPointcutVisitor.check(p, true);
70
} catch (Throwable t) {
71
fail("Failed on '"+tp+"': " +t.toString());