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

COVERAGE SUMMARY FOR SOURCE FILE [TestNodeFactory.java]

nameclass, %method, %block, %line, %
TestNodeFactory.java100% (1/1)100% (29/29)100% (658/658)100% (148/148)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class TestNodeFactory100% (1/1)100% (29/29)100% (658/658)100% (148/148)
TestNodeFactory (): void 100% (1/1)100% (3/3)100% (1/1)
setUp (): void 100% (1/1)100% (8/8)100% (3/3)
testCreateClass (): void 100% (1/1)100% (35/35)100% (7/7)
testCreateClassInDefaultPackage (): void 100% (1/1)100% (17/17)100% (4/4)
testCreateClassNodeDefaultsToReferenced (): void 100% (1/1)100% (15/15)100% (4/4)
testCreateConcreteClassNode (): void 100% (1/1)100% (16/16)100% (4/4)
testCreateConcreteFeatureNode (): void 100% (1/1)100% (22/22)100% (5/5)
testCreateConcretePackageNode (): void 100% (1/1)100% (11/11)100% (3/3)
testCreateFeature (): void 100% (1/1)100% (36/36)100% (7/7)
testCreateFeatureInDefaultPackage (): void 100% (1/1)100% (24/24)100% (5/5)
testCreateFeatureNodeDefaultsToReferenced (): void 100% (1/1)100% (21/21)100% (5/5)
testCreateIllegalClass (): void 100% (1/1)100% (17/17)100% (4/4)
testCreateIllegalFeature (): void 100% (1/1)100% (24/24)100% (5/5)
testCreatePackage (): void 100% (1/1)100% (29/29)100% (6/6)
testCreatePackageNodeDefaultsToReferenced (): void 100% (1/1)100% (10/10)100% (3/3)
testCreateReferencedClassNode (): void 100% (1/1)100% (16/16)100% (4/4)
testCreateReferencedFeatureNode (): void 100% (1/1)100% (22/22)100% (5/5)
testCreateReferencedPackageNode (): void 100% (1/1)100% (11/11)100% (3/3)
testLookupClass (): void 100% (1/1)100% (15/15)100% (4/4)
testLookupFeature (): void 100% (1/1)100% (15/15)100% (4/4)
testLookupPackage (): void 100% (1/1)100% (15/15)100% (4/4)
testMakingClassNodeConcreteDoesNotChangeItsFeatures (): void 100% (1/1)100% (43/43)100% (8/8)
testMakingPackageNodeConcreteDoesNotChangeItsClasses (): void 100% (1/1)100% (43/43)100% (8/8)
testSwitchClassNodeFromConcreteToReferenced (): void 100% (1/1)100% (31/31)100% (7/7)
testSwitchClassNodeFromReferencedToConcrete (): void 100% (1/1)100% (31/31)100% (7/7)
testSwitchFeatureNodeFromConcreteToReferenced (): void 100% (1/1)100% (43/43)100% (9/9)
testSwitchFeatureNodeFromReferencedToConcrete (): void 100% (1/1)100% (43/43)100% (9/9)
testSwitchPackageNodeFromConcreteToReferenced (): void 100% (1/1)100% (21/21)100% (5/5)
testSwitchPackageNodeFromReferencedToConcrete (): void 100% (1/1)100% (21/21)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.dependency;
34 
35import junit.framework.*;
36 
37public class TestNodeFactory extends TestCase {
38    private NodeFactory factory;
39 
40    protected void setUp() throws Exception {
41        super.setUp();
42 
43        factory = new NodeFactory();
44    }
45 
46    public void testCreatePackage() {
47        PackageNode node = factory.createPackage("a");
48 
49        assertEquals("name", "a", node.getName());
50        assertEquals("classes", 0, node.getClasses().size());
51        assertEquals("inbounds", 0, node.getInboundDependencies().size());
52        assertEquals("outbounds", 0, node.getOutboundDependencies().size());
53    }
54 
55    public void testLookupPackage() {
56        Node node1 = factory.createPackage("a");
57        Node node2 = factory.createPackage("a");
58 
59        assertSame("factory returned different object for same key", node1, node2);
60    }
61 
62    public void testCreateClass() {
63        ClassNode node = factory.createClass("a.A");
64 
65        assertEquals("name", "a.A", node.getName());
66        assertEquals("package name", "a", node.getPackageNode().getName());
67        assertEquals("features", 0, node.getFeatures().size());
68        assertEquals("inbounds", 0, node.getInboundDependencies().size());
69        assertEquals("outbounds", 0, node.getOutboundDependencies().size());
70    }
71 
72    public void testCreateClassInDefaultPackage() {
73        ClassNode node = factory.createClass("A");
74 
75        assertEquals("name", "A", node.getName());
76        assertEquals("package name", "", node.getPackageNode().getName());
77    }
78 
79    public void testCreateIllegalClass() {
80        ClassNode node = factory.createClass("");
81 
82        assertEquals("name", "", node.getName());
83        assertEquals("package name", "", node.getPackageNode().getName());
84    }
85 
86    public void testLookupClass() {
87        Node node1 = factory.createClass("a.A");
88        Node node2 = factory.createClass("a.A");
89 
90        assertSame("factory returned different object for same key", node1, node2);
91    }
92 
93    public void testCreateFeature() {
94        FeatureNode node = factory.createFeature("a.A.a");
95 
96        assertEquals("name", "a.A.a", node.getName());
97        assertEquals("class name", "a.A", node.getClassNode().getName());
98        assertEquals("pacakge name", "a", node.getClassNode().getPackageNode().getName());
99        assertEquals("inbounds", 0, node.getInboundDependencies().size());
100        assertEquals("outbounds", 0, node.getOutboundDependencies().size());
101    }
102 
103    public void testLookupFeature() {
104        Node node1 = factory.createFeature("a.A.a");
105        Node node2 = factory.createFeature("a.A.a");
106 
107        assertSame("factory returned different object for same key", node1, node2);
108    }
109 
110    public void testCreateFeatureInDefaultPackage() {
111        FeatureNode node = factory.createFeature("A.a");
112 
113        assertEquals("name", "A.a", node.getName());
114        assertEquals("class name", "A", node.getClassNode().getName());
115        assertEquals("package name", "", node.getClassNode().getPackageNode().getName());
116    }
117 
118    public void testCreateIllegalFeature() {
119        FeatureNode node = factory.createFeature("");
120 
121        assertEquals("name", "", node.getName());
122        assertEquals("class name", "", node.getClassNode().getName());
123        assertEquals("package name", "", node.getClassNode().getPackageNode().getName());
124    }
125 
126    public void testCreateReferencedPackageNode() {
127        PackageNode node = factory.createPackage("a", false);
128 
129        assertFalse("Not referenced", node.isConfirmed());
130    }
131 
132    public void testCreateConcretePackageNode() {
133        PackageNode node = factory.createPackage("a", true);
134 
135        assertTrue("Not concrete", node.isConfirmed());
136    }
137 
138    public void testCreatePackageNodeDefaultsToReferenced() {
139        PackageNode node = factory.createPackage("a");
140 
141        assertFalse("Not referenced", node.isConfirmed());
142    }
143 
144    public void testCreateReferencedClassNode() {
145        ClassNode node = factory.createClass("a.A", false);
146 
147        assertFalse("Not referenced", node.isConfirmed());
148        assertFalse("Not referenced", node.getPackageNode().isConfirmed());
149    }
150 
151    public void testCreateConcreteClassNode() {
152        ClassNode node = factory.createClass("a.A", true);
153 
154        assertTrue("Not concrete", node.isConfirmed());
155        assertTrue("Not concrete", node.getPackageNode().isConfirmed());
156    }
157 
158    public void testCreateClassNodeDefaultsToReferenced() {
159        ClassNode node = factory.createClass("a.A");
160 
161        assertFalse("Not referenced", node.isConfirmed());
162        assertFalse("Not referenced", node.getPackageNode().isConfirmed());
163    }
164 
165    public void testCreateReferencedFeatureNode() {
166        FeatureNode node = factory.createFeature("a.A.a", false);
167 
168        assertFalse("Not referenced", node.isConfirmed());
169        assertFalse("Not referenced", node.getClassNode().isConfirmed());
170        assertFalse("Not referenced", node.getClassNode().getPackageNode().isConfirmed());
171    }
172 
173    public void testCreateConcreteFeatureNode() {
174        FeatureNode node = factory.createFeature("a.A.a", true);
175 
176        assertTrue("Not concrete", node.isConfirmed());
177        assertTrue("Not concrete", node.getClassNode().isConfirmed());
178        assertTrue("Not concrete", node.getClassNode().getPackageNode().isConfirmed());
179    }
180 
181    public void testCreateFeatureNodeDefaultsToReferenced() {
182        FeatureNode node = factory.createFeature("a.A.a");
183 
184        assertFalse("Not referenced", node.isConfirmed());
185        assertFalse("Not referenced", node.getClassNode().isConfirmed());
186        assertFalse("Not referenced", node.getClassNode().getPackageNode().isConfirmed());
187    }
188 
189    public void testSwitchPackageNodeFromReferencedToConcrete() {
190        PackageNode node;
191 
192        node = factory.createPackage("a", false);
193        assertFalse("Not referenced", node.isConfirmed());
194 
195        node = factory.createPackage("a", true);
196        assertTrue("Not concrete", node.isConfirmed());
197    }
198 
199    public void testSwitchPackageNodeFromConcreteToReferenced() {
200        PackageNode node;
201 
202        node = factory.createPackage("a", true);
203        assertTrue("Not concrete", node.isConfirmed());
204 
205        node = factory.createPackage("a", false);
206        assertTrue("Not concrete", node.isConfirmed());
207    }
208 
209    public void testMakingPackageNodeConcreteDoesNotChangeItsClasses() {
210        PackageNode node;
211 
212        node = factory.createPackage("a", false);
213        factory.createClass("a.A", false);
214        assertFalse("Not referenced", node.isConfirmed());
215        assertFalse("Not referenced", node.getClasses().iterator().next().isConfirmed());
216 
217        node = factory.createPackage("a", true);
218        assertTrue("Not concrete", node.isConfirmed());
219        assertFalse("Not referenced", node.getClasses().iterator().next().isConfirmed());
220    }
221 
222    public void testSwitchClassNodeFromReferencedToConcrete() {
223        ClassNode node;
224 
225        node = factory.createClass("a.A", false);
226        assertFalse("Not referenced", node.isConfirmed());
227        assertFalse("Not referenced", node.getPackageNode().isConfirmed());
228 
229        node = factory.createClass("a.A", true);
230        assertTrue("Not concrete", node.isConfirmed());
231        assertTrue("Not concrete", node.getPackageNode().isConfirmed());
232    }
233 
234    public void testSwitchClassNodeFromConcreteToReferenced() {
235        ClassNode node;
236 
237        node = factory.createClass("a.A", true);
238        assertTrue("Not concrete", node.isConfirmed());
239        assertTrue("Not concrete", node.getPackageNode().isConfirmed());
240 
241        node = factory.createClass("a.A", false);
242        assertTrue("Not concrete", node.isConfirmed());
243        assertTrue("Not concrete", node.getPackageNode().isConfirmed());
244    }
245 
246    public void testMakingClassNodeConcreteDoesNotChangeItsFeatures() {
247        ClassNode node;
248 
249        node = factory.createClass("a.A", false);
250        factory.createFeature("a.A.a", false);
251        assertFalse("Not referenced", node.isConfirmed());
252        assertFalse("Not referenced", node.getFeatures().iterator().next().isConfirmed());
253 
254        node = factory.createClass("a.A", true);
255        assertTrue("Not concrete", node.isConfirmed());
256        assertFalse("Not referenced", node.getFeatures().iterator().next().isConfirmed());
257    }
258 
259    public void testSwitchFeatureNodeFromReferencedToConcrete() {
260        FeatureNode node;
261 
262        node = factory.createFeature("a.A.a", false);
263        assertFalse("Not referenced", node.isConfirmed());
264        assertFalse("Not referenced", node.getClassNode().isConfirmed());
265        assertFalse("Not referenced", node.getClassNode().getPackageNode().isConfirmed());
266 
267        node = factory.createFeature("a.A.a", true);
268        assertTrue("Not concrete", node.isConfirmed());
269        assertTrue("Not concrete", node.getClassNode().isConfirmed());
270        assertTrue("Not concrete", node.getClassNode().getPackageNode().isConfirmed());
271    }
272 
273    public void testSwitchFeatureNodeFromConcreteToReferenced() {
274        FeatureNode node;
275 
276        node = factory.createFeature("a.A.a", true);
277        assertTrue("Not concrete", node.isConfirmed());
278        assertTrue("Not concrete", node.getClassNode().isConfirmed());
279        assertTrue("Not concrete", node.getClassNode().getPackageNode().isConfirmed());
280 
281        node = factory.createFeature("a.A.a", false);
282        assertTrue("Not concrete", node.isConfirmed());
283        assertTrue("Not concrete", node.getClassNode().isConfirmed());
284        assertTrue("Not concrete", node.getClassNode().getPackageNode().isConfirmed());
285    }
286}

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