1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.kuali.rice.kns.util.properties;
18
19 import org.junit.Test;
20 import org.kuali.rice.kns.exception.PropertiesException;
21 import org.kuali.rice.kns.util.properties.FilePropertySource;
22 import org.kuali.test.KNSTestCase;
23
24
25
26
27 public class FilePropertySourceTest extends KNSTestCase {
28
29 @Test public void testLoadProperties_defaultFileName() {
30 FilePropertySource fps = new FilePropertySource();
31
32 boolean failedAsExpected = false;
33 try {
34 fps.loadProperties();
35 }
36 catch (IllegalStateException e) {
37 failedAsExpected = true;
38 }
39
40 assertTrue(failedAsExpected);
41 }
42
43 @Test public void testLoadProperties_invalidFileName() {
44 FilePropertySource fps = new FilePropertySource();
45 fps.setFileName(" ");
46
47 boolean failedAsExpected = false;
48 try {
49 fps.loadProperties();
50 }
51 catch (IllegalStateException e) {
52 failedAsExpected = true;
53 }
54
55 assertTrue(failedAsExpected);
56 }
57
58 @Test public void testLoadProperties_unknownFileName() {
59 FilePropertySource fps = new FilePropertySource();
60 fps.setFileName("unknown");
61
62 boolean failedAsExpected = false;
63 try {
64 fps.loadProperties();
65 }
66 catch (PropertiesException e) {
67 failedAsExpected = true;
68 }
69
70 assertTrue(failedAsExpected);
71 }
72
73 @Test public void testLoadProperties_knownFileName_noSuffix() {
74 FilePropertySource fps = new FilePropertySource();
75 fps.setFileName("configuration");
76
77 boolean failedAsExpected = false;
78 try {
79 fps.loadProperties();
80 }
81 catch (PropertiesException e) {
82 failedAsExpected = true;
83 }
84
85 assertTrue(failedAsExpected);
86 }
87 }