1 | // Jomic - a viewer for comic book archives. |
2 | // Copyright (C) 2004-2011 Thomas Aglassinger |
3 | // |
4 | // This program is free software: you can redistribute it and/or modify |
5 | // it under the terms of the GNU General Public License as published by |
6 | // the Free Software Foundation, either version 3 of the License, or |
7 | // (at your option) any later version. |
8 | // |
9 | // This program is distributed in the hope that it will be useful, |
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | // GNU General Public License for more details. |
13 | // |
14 | // You should have received a copy of the GNU General Public License |
15 | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 | package net.sf.jomic.tests; |
17 | |
18 | import java.io.IOException; |
19 | |
20 | import jdepend.framework.JDepend; |
21 | import jdepend.framework.JavaPackage; |
22 | import junit.framework.TestCase; |
23 | import net.sf.jomic.Jomic; |
24 | |
25 | /** |
26 | * Test to check for package depedancy cycles. Based on an <a |
27 | * href="http://www.clarkware.com/software/JDepend.html#junit">example</a> coming with <a |
28 | * href="http://www.clarkware.com/software/JDepend.html">JDepend</a> . |
29 | * |
30 | * @author Thomas Aglassinger |
31 | */ |
32 | public class CycleTest extends TestCase |
33 | { |
34 | private JDepend jdepend; |
35 | |
36 | public CycleTest(String name) { |
37 | super(name); |
38 | } |
39 | |
40 | protected void setUp() |
41 | throws IOException { |
42 | jdepend = new JDepend(); |
43 | jdepend.addDirectory("source"); |
44 | } |
45 | |
46 | /** |
47 | * Tests that a package dependency cycle does not exist for any of the analyzed packages. |
48 | */ |
49 | public void testAllPackagesCycle() { |
50 | jdepend.analyze(); |
51 | assertEquals("dependancy cycles must be resolved", false, |
52 | jdepend.containsCycles()); |
53 | } |
54 | |
55 | /** |
56 | * Tests that a single package does not contain any package dependency cycles. |
57 | */ |
58 | public void testOnePackageCycle() { |
59 | jdepend.analyze(); |
60 | |
61 | JavaPackage p = jdepend.getPackage(Jomic.class.getPackage().getName()); |
62 | |
63 | assertNotNull(p); |
64 | assertEquals("Cycle exists: " + p.getName(), false, p.containsCycle()); |
65 | } |
66 | |
67 | protected void tearDown() { |
68 | jdepend = null; |
69 | } |
70 | } |