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