~ubuntu-branches/ubuntu/natty/aspectj/natty

« back to all changes in this revision

Viewing changes to org.aspectj/modules/weaver/testsrc/org/aspectj/weaver/patterns/VisitorTestCase.java

  • Committer: Bazaar Package Importer
  • Author(s): Damien Raude-Morvan
  • Date: 2009-10-04 16:37:23 UTC
  • mfrom: (1.1.3 upstream) (3.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20091004163723-ck4y7j7fhjxskkie
Tags: 1.6.6+dfsg-1
* New upstream release.
  - Update 02_use_gjdoc.diff patch
* Update my email address

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*******************************************************************************
2
 
 * Copyright (c) 2005 Contributors.
3
 
 * All rights reserved. 
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 
8
 
 * 
9
 
 * Contributors:
10
 
 *   Alexandre Vasseur         initial implementation
11
 
 *******************************************************************************/
12
 
package org.aspectj.weaver.patterns;
13
 
 
14
 
import junit.framework.TestCase;
15
 
 
16
 
import java.util.HashSet;
17
 
import java.util.Set;
18
 
import java.util.Iterator;
19
 
import java.io.LineNumberReader;
20
 
import java.io.FileReader;
21
 
 
22
 
/**
23
 
 * @author <a href="mailto:alex AT gnilux DOT com">Alexandre Vasseur</a>
24
 
 */
25
 
public class VisitorTestCase extends TestCase {
26
 
 
27
 
    private Set pointcuts = new HashSet();
28
 
    private Set typePatterns = new HashSet();
29
 
 
30
 
    protected void setUp() throws Exception {
31
 
        super.setUp();
32
 
        LineNumberReader rp = new LineNumberReader(new FileReader("../weaver/testdata/visitor.pointcuts.txt"));
33
 
        feed(rp, pointcuts);
34
 
        rp.close();
35
 
        LineNumberReader rt = new LineNumberReader(new FileReader("../weaver/testdata/visitor.typepatterns.txt"));
36
 
        feed(rt, typePatterns);
37
 
        rt.close();
38
 
    }
39
 
 
40
 
    private void feed(LineNumberReader r, Set set) throws Exception {
41
 
        for (String line = r.readLine(); line != null; line = r.readLine()) {
42
 
            set.add(line);
43
 
        }
44
 
    }
45
 
 
46
 
    public void testPointcuts() {
47
 
        if (pointcuts.isEmpty()) {
48
 
            fail("Empty pointcuts file!");
49
 
        }
50
 
        for (Iterator iterator = pointcuts.iterator(); iterator.hasNext();) {
51
 
            String pointcut = (String) iterator.next();
52
 
            try  {
53
 
                PatternNodeVisitor.DumpPointcutVisitor.check(pointcut);
54
 
            } catch (Throwable t) {
55
 
                t.printStackTrace();
56
 
                fail("Failed on '"+pointcut+"': " +t.toString());
57
 
            }
58
 
        }
59
 
    }
60
 
 
61
 
    public void testTypePatterns() {
62
 
        if (typePatterns.isEmpty()) {
63
 
            fail("Empty typePatterns file!");
64
 
        }
65
 
        for (Iterator iterator = typePatterns.iterator(); iterator.hasNext();) {
66
 
            String tp = (String) iterator.next();
67
 
            try  {
68
 
                TypePattern p = new PatternParser(tp).parseTypePattern();
69
 
                PatternNodeVisitor.DumpPointcutVisitor.check(p, true);
70
 
            } catch (Throwable t) {
71
 
                fail("Failed on '"+tp+"': " +t.toString());
72
 
            }
73
 
        }
74
 
    }
75
 
}