EMMA Coverage Report (generated Mon Nov 29 14:43:38 PST 2010)
[all classes][com.jeantessier.classreader]

COVERAGE SUMMARY FOR SOURCE FILE [TestSymbolGathererWithStrategy.java]

nameclass, %method, %block, %line, %
TestSymbolGathererWithStrategy.java100% (9/9)100% (19/19)100% (668/668)100% (85/85)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class TestSymbolGathererWithStrategy100% (1/1)100% (11/11)100% (348/348)100% (54/54)
TestSymbolGathererWithStrategy (): void 100% (1/1)100% (3/3)100% (1/1)
access$000 (TestSymbolGathererWithStrategy): SymbolGathererStrategy 100% (1/1)100% (3/3)100% (1/1)
setUp (): void 100% (1/1)100% (16/16)100% (4/4)
testVisitClassfile_Matching (): void 100% (1/1)100% (51/51)100% (7/7)
testVisitClassfile_NotMatching (): void 100% (1/1)100% (32/32)100% (5/5)
testVisitField_info_Matching (): void 100% (1/1)100% (51/51)100% (7/7)
testVisitField_info_NotMatching (): void 100% (1/1)100% (32/32)100% (5/5)
testVisitLocalVariable_Matching (): void 100% (1/1)100% (45/45)100% (8/8)
testVisitLocalVariable_NotMatching (): void 100% (1/1)100% (32/32)100% (5/5)
testVisitMethod_info_Matching (): void 100% (1/1)100% (51/51)100% (7/7)
testVisitMethod_info_NotMatching (): void 100% (1/1)100% (32/32)100% (5/5)
     
class TestSymbolGathererWithStrategy$1100% (1/1)100% (1/1)100% (45/45)100% (6/6)
TestSymbolGathererWithStrategy$1 (TestSymbolGathererWithStrategy, Classfile):... 100% (1/1)100% (45/45)100% (6/6)
     
class TestSymbolGathererWithStrategy$2100% (1/1)100% (1/1)100% (56/56)100% (7/7)
TestSymbolGathererWithStrategy$2 (TestSymbolGathererWithStrategy, Classfile):... 100% (1/1)100% (56/56)100% (7/7)
     
class TestSymbolGathererWithStrategy$3100% (1/1)100% (1/1)100% (31/31)100% (4/4)
TestSymbolGathererWithStrategy$3 (TestSymbolGathererWithStrategy, Field_info)... 100% (1/1)100% (31/31)100% (4/4)
     
class TestSymbolGathererWithStrategy$4100% (1/1)100% (1/1)100% (42/42)100% (5/5)
TestSymbolGathererWithStrategy$4 (TestSymbolGathererWithStrategy, Field_info)... 100% (1/1)100% (42/42)100% (5/5)
     
class TestSymbolGathererWithStrategy$5100% (1/1)100% (1/1)100% (31/31)100% (4/4)
TestSymbolGathererWithStrategy$5 (TestSymbolGathererWithStrategy, Method_info... 100% (1/1)100% (31/31)100% (4/4)
     
class TestSymbolGathererWithStrategy$6100% (1/1)100% (1/1)100% (42/42)100% (5/5)
TestSymbolGathererWithStrategy$6 (TestSymbolGathererWithStrategy, Method_info... 100% (1/1)100% (42/42)100% (5/5)
     
class TestSymbolGathererWithStrategy$7100% (1/1)100% (1/1)100% (24/24)100% (3/3)
TestSymbolGathererWithStrategy$7 (TestSymbolGathererWithStrategy, LocalVariab... 100% (1/1)100% (24/24)100% (3/3)
     
class TestSymbolGathererWithStrategy$8100% (1/1)100% (1/1)100% (49/49)100% (5/5)
TestSymbolGathererWithStrategy$8 (TestSymbolGathererWithStrategy, LocalVariab... 100% (1/1)100% (49/49)100% (5/5)

1/*
2 *  Copyright (c) 2001-2009, Jean Tessier
3 *  All rights reserved.
4 *  
5 *  Redistribution and use in source and binary forms, with or without
6 *  modification, are permitted provided that the following conditions
7 *  are met:
8 *  
9 *      * Redistributions of source code must retain the above copyright
10 *        notice, this list of conditions and the following disclaimer.
11 *  
12 *      * Redistributions in binary form must reproduce the above copyright
13 *        notice, this list of conditions and the following disclaimer in the
14 *        documentation and/or other materials provided with the distribution.
15 *  
16 *      * Neither the name of Jean Tessier nor the names of his contributors
17 *        may be used to endorse or promote products derived from this software
18 *        without specific prior written permission.
19 *  
20 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 *  A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR
24 *  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 *  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27 *  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28 *  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29 *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30 *  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32 
33package com.jeantessier.classreader;
34 
35import org.jmock.*;
36import org.jmock.integration.junit3.*;
37 
38public class TestSymbolGathererWithStrategy extends MockObjectTestCase {
39    private SymbolGathererStrategy mockStrategy;
40 
41    private SymbolGatherer sut;
42 
43    protected void setUp() throws Exception {
44        super.setUp();
45 
46        mockStrategy = mock(SymbolGathererStrategy.class);
47 
48        sut = new SymbolGatherer(mockStrategy);
49    }
50 
51    public void testVisitClassfile_NotMatching() {
52        final Classfile mockClassfile = mock(Classfile.class);
53 
54        checking(new Expectations() {{
55            one (mockStrategy).isMatching(mockClassfile); will(returnValue(false));
56            
57            one (mockClassfile).getAttributes();
58            one (mockClassfile).getAllFields();
59            one (mockClassfile).getAllMethods();
60        }});
61 
62        sut.visitClassfile(mockClassfile);
63 
64        assertTrue("Added non-matching class " + sut.getCollection(), sut.getCollection().isEmpty());
65    }
66 
67    public void testVisitClassfile_Matching() {
68        final String expectedName = "Foobar";
69 
70        final Classfile mockClassfile = mock(Classfile.class);
71 
72        checking(new Expectations() {{
73            one (mockStrategy).isMatching(mockClassfile); will(returnValue(true));
74            one (mockClassfile).getClassName(); will(returnValue(expectedName));
75 
76            one (mockClassfile).getAttributes();
77            one (mockClassfile).getAllFields();
78            one (mockClassfile).getAllMethods();
79        }});
80 
81        sut.visitClassfile(mockClassfile);
82 
83        assertEquals("Wrong size for " + sut.getCollection(), 1, sut.getCollection().size());
84        assertTrue("Missing class name " + sut.getCollection(), sut.getCollection().contains(expectedName));
85    }
86 
87    public void testVisitField_info_NotMatching() {
88        final Field_info mockField = mock(Field_info.class);
89 
90        checking(new Expectations() {{
91            one (mockStrategy).isMatching(mockField); will(returnValue(false));
92 
93            one (mockField).getAttributes();
94        }});
95 
96        sut.visitField_info(mockField);
97 
98        assertTrue("Added non-matching class " + sut.getCollection(), sut.getCollection().isEmpty());
99    }
100 
101    public void testVisitField_info_Matching() {
102        final String expectedName = "Foobar.foobar";
103 
104        final Field_info mockField = mock(Field_info.class);
105 
106        checking(new Expectations() {{
107            one (mockStrategy).isMatching(mockField); will(returnValue(true));
108            one (mockField).getFullSignature(); will(returnValue(expectedName));
109 
110            one (mockField).getAttributes();
111        }});
112 
113        sut.visitField_info(mockField);
114 
115        assertEquals("Wrong size for " + sut.getCollection(), 1, sut.getCollection().size());
116        assertTrue("Missing class name " + sut.getCollection(), sut.getCollection().contains(expectedName));
117    }
118 
119    public void testVisitMethod_info_NotMatching() {
120        final Method_info mockMethod = mock(Method_info.class);
121 
122        checking(new Expectations() {{
123            one (mockStrategy).isMatching(mockMethod); will(returnValue(false));
124 
125            one (mockMethod).getAttributes();
126        }});
127 
128        sut.visitMethod_info(mockMethod);
129 
130        assertTrue("Added non-matching class " + sut.getCollection(), sut.getCollection().isEmpty());
131    }
132 
133    public void testVisitMethod_info_Matching() {
134        final String expectedName = "Foobar.foobar";
135 
136        final Method_info mockMethod = mock(Method_info.class);
137 
138        checking(new Expectations() {{
139            one (mockStrategy).isMatching(mockMethod); will(returnValue(true));
140            one (mockMethod).getFullSignature(); will(returnValue(expectedName));
141 
142            one (mockMethod).getAttributes();
143        }});
144 
145        sut.visitMethod_info(mockMethod);
146 
147        assertEquals("Wrong size for " + sut.getCollection(), 1, sut.getCollection().size());
148        assertTrue("Missing class name " + sut.getCollection(), sut.getCollection().contains(expectedName));
149    }
150 
151 
152    public void testVisitLocalVariable_NotMatching() {
153        final LocalVariable mockLocalVariable = mock(LocalVariable.class);
154 
155        checking(new Expectations() {{
156            one (mockStrategy).isMatching(mockLocalVariable); will(returnValue(false));
157        }});
158 
159        sut.visitLocalVariable(mockLocalVariable);
160 
161        assertTrue("Added non-matching class " + sut.getCollection(), sut.getCollection().isEmpty());
162    }
163 
164    public void testVisitLocalVariable_Matching() {
165        final String expectedName = "Foobar.foobar";
166 
167        final Method_info mockMethod = mock(Method_info.class);
168        final LocalVariable mockLocalVariable = mock(LocalVariable.class);
169 
170        checking(new Expectations() {{
171            one (mockStrategy).isMatching(mockLocalVariable); will(returnValue(true));
172            one (mockMethod).getFullSignature(); will(returnValue(expectedName));
173            one (mockLocalVariable).getName(); will(returnValue(expectedName));
174        }});
175 
176        sut.setCurrentMethodForTesting(mockMethod);
177        sut.visitLocalVariable(mockLocalVariable);
178 
179        assertEquals("Wrong size for " + sut.getCollection(), 1, sut.getCollection().size());
180    }
181}

[all classes][com.jeantessier.classreader]
EMMA 2.0.5312 (C) Vladimir Roubtsov