01: package jdepend.framework;
02:
03: import java.io.File;
04: import java.io.IOException;
05: import java.util.Collection;
06:
07: /**
08: * @author <b>Mike Clark</b>
09: * @author Clarkware Consulting, Inc.
10: */
11:
12: public class PropertyConfiguratorTest extends JDependTestCase {
13:
14: public PropertyConfiguratorTest(String name) {
15: super (name);
16: }
17:
18: protected void setUp() {
19: super .setUp();
20:
21: System.setProperty("user.home", getTestDataDir());
22: }
23:
24: protected void tearDown() {
25: super .tearDown();
26: }
27:
28: public void testDefaultFilters() {
29: PropertyConfigurator c = new PropertyConfigurator();
30: assertFiltersExist(c.getFilteredPackages());
31: assertFalse(c.getAnalyzeInnerClasses());
32: }
33:
34: public void testFiltersFromFile() throws IOException {
35:
36: String file = getTestDataDir() + "jdepend.properties";
37:
38: PropertyConfigurator c = new PropertyConfigurator(
39: new File(file));
40:
41: assertFiltersExist(c.getFilteredPackages());
42: assertFalse(c.getAnalyzeInnerClasses());
43: }
44:
45: private void assertFiltersExist(Collection filters) {
46: assertEquals(5, filters.size());
47: assertTrue(filters.contains("java.*"));
48: assertTrue(filters.contains("javax.*"));
49: assertTrue(filters.contains("sun.*"));
50: assertTrue(filters.contains("com.sun.*"));
51: assertTrue(filters.contains("com.xyz.tests.*"));
52: }
53:
54: public void testDefaultPackages() throws IOException {
55: JDepend j = new JDepend();
56:
57: JavaPackage pkg = j.getPackage("com.xyz.a.neverchanges");
58: assertNotNull(pkg);
59: assertEquals(0, pkg.getVolatility());
60:
61: pkg = j.getPackage("com.xyz.b.neverchanges");
62: assertNotNull(pkg);
63: assertEquals(0, pkg.getVolatility());
64:
65: pkg = j.getPackage("com.xyz.c.neverchanges");
66: assertNull(pkg);
67: }
68: }
|