1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
package org.kuali.rice.kns.datadictionary; |
18 |
|
|
19 |
|
import org.apache.log4j.Logger; |
20 |
|
import org.junit.After; |
21 |
|
import org.junit.Before; |
22 |
|
import org.junit.Test; |
23 |
|
import org.kuali.test.KNSTestCase; |
24 |
|
|
25 |
|
import static org.junit.Assert.assertTrue; |
26 |
|
import static org.junit.Assert.fail; |
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
|
|
| 0% |
Uncovered Elements: 46 (46) |
Complexity: 14 |
Complexity Density: 0.36 |
|
34 |
|
public class DataDictionaryBuilderTest extends KNSTestCase { |
35 |
|
protected final Logger LOG = Logger.getLogger(getClass()); |
36 |
|
|
37 |
|
static final String PACKAGE_CORE_BO = "org/kuali/rice/kns/bo/datadictionary/"; |
38 |
|
|
39 |
|
static final String PACKAGE_CORE_DOCUMENT = "org/kuali/rice/kns/document/datadictionary/"; |
40 |
|
|
41 |
|
static final String PACKAGE_KFS = "org/kuali/kfs/datadictionary/"; |
42 |
|
|
43 |
|
static final String PACKAGE_CHART = "org/kuali/module/chart/datadictionary/"; |
44 |
|
|
45 |
|
static final String PACKAGE_CG = "org/kuali/module/cg/datadictionary/"; |
46 |
|
|
47 |
|
static final String PACKAGE_KRA_BUDGET = "org/kuali/module/kra/budget/datadictionary/"; |
48 |
|
|
49 |
|
static final String PACKAGE_KRA_ROUTINGFORM = "org/kuali/module/kra/routingform/datadictionary/"; |
50 |
|
|
51 |
|
static final String TESTPACKAGE_INVALID = "org/kuali/rice/kns/datadictionary/test/invalid/"; |
52 |
|
|
53 |
|
DataDictionary dd = null; |
54 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
55 |
0
|
@Before... |
56 |
|
public void setUp() throws Exception { |
57 |
0
|
super.setUp(); |
58 |
|
|
59 |
0
|
dd = new DataDictionary(); |
60 |
|
} |
61 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
62 |
0
|
@After... |
63 |
|
public void tearDown() throws Exception { |
64 |
0
|
super.tearDown(); |
65 |
0
|
dd = null; |
66 |
|
} |
67 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.4 |
4
-
|
|
68 |
0
|
@Test... |
69 |
|
public final void testDataDictionaryBuilder_source_invalid() throws Exception { |
70 |
0
|
boolean failedAsExpected = false; |
71 |
|
|
72 |
0
|
try { |
73 |
0
|
dd.addConfigFileLocation(null); |
74 |
|
} catch (DataDictionaryException e) { |
75 |
0
|
failedAsExpected = true; |
76 |
|
} |
77 |
|
|
78 |
0
|
assertTrue(failedAsExpected); |
79 |
|
} |
80 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.33 |
4
-
|
|
81 |
0
|
@Test... |
82 |
|
public final void testDataDictionaryBuilder_source_unknownFile() throws Exception { |
83 |
0
|
String INPUT_FILE = TESTPACKAGE_INVALID + "foo.xml"; |
84 |
|
|
85 |
0
|
boolean failedAsExpected = false; |
86 |
|
|
87 |
0
|
try { |
88 |
0
|
dd.addConfigFileLocation(INPUT_FILE); |
89 |
|
} catch (DataDictionaryException e) { |
90 |
0
|
failedAsExpected = true; |
91 |
|
} |
92 |
|
|
93 |
0
|
assertTrue(failedAsExpected); |
94 |
|
} |
95 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.33 |
4
-
|
|
96 |
0
|
@Test... |
97 |
|
public final void testDataDictionaryBuilder_source_unknownPackage() throws Exception { |
98 |
0
|
String UNKNOWN_PACKAGE = TESTPACKAGE_INVALID + "foo/"; |
99 |
|
|
100 |
0
|
boolean failedAsExpected = false; |
101 |
|
|
102 |
0
|
try { |
103 |
0
|
dd.addConfigFileLocation(UNKNOWN_PACKAGE); |
104 |
|
} catch (DataDictionaryException e) { |
105 |
0
|
failedAsExpected = true; |
106 |
|
} |
107 |
|
|
108 |
0
|
assertTrue(failedAsExpected); |
109 |
|
} |
110 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 3 |
Complexity Density: 0.33 |
4
-
|
|
111 |
0
|
@Test... |
112 |
|
public final void testDataDictionaryBuilder_invalidXml() throws Exception { |
113 |
0
|
String INPUT_FILE = TESTPACKAGE_INVALID + "InvalidXml.xml"; |
114 |
|
|
115 |
0
|
boolean failedAsExpected = false; |
116 |
|
|
117 |
0
|
try { |
118 |
0
|
dd.addConfigFileLocation(INPUT_FILE); |
119 |
0
|
dd.parseDataDictionaryConfigurationFiles( false ); |
120 |
|
} catch (DataDictionaryException e) { |
121 |
0
|
failedAsExpected = true; |
122 |
|
} catch (Exception e) { |
123 |
0
|
LOG.error("Error loading DD files", e); |
124 |
0
|
fail("Data Dictionary file load failed but with wrong exception type '" + e.getClass().getName() + "'"); |
125 |
|
} |
126 |
|
|
127 |
0
|
assertTrue(failedAsExpected); |
128 |
|
} |
129 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 3 |
Complexity Density: 0.33 |
4
-
|
|
130 |
0
|
@Test... |
131 |
|
public final void testDataDictionaryBuilder_getInvalidDictionary() throws Exception { |
132 |
0
|
String INPUT_FILE = TESTPACKAGE_INVALID + "InvalidXml.xml"; |
133 |
|
|
134 |
0
|
boolean failedAsExpected = false; |
135 |
|
|
136 |
0
|
try { |
137 |
0
|
dd.addConfigFileLocation(INPUT_FILE); |
138 |
0
|
dd.parseDataDictionaryConfigurationFiles( false ); |
139 |
|
} catch (DataDictionaryException e) { |
140 |
0
|
failedAsExpected = true; |
141 |
|
} catch (Exception e) { |
142 |
0
|
LOG.error("Error loading DD files", e); |
143 |
0
|
fail("Data Dictionary file load failed but with wrong exception type '" + e.getClass().getName() + "'"); |
144 |
|
} |
145 |
|
|
146 |
0
|
assertTrue(failedAsExpected); |
147 |
|
} |
148 |
|
|
149 |
|
} |