1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.core.impl.services;
17
18 import org.junit.Test;
19 import org.kuali.rice.core.api.exception.RiceRuntimeException;
20 import org.kuali.rice.core.impl.services.ConfigurationServiceImpl;
21
22 import static org.junit.Assert.assertTrue;
23
24
25
26
27 public class FilePropertySourceTest {
28
29 @Test public void testLoadProperties_defaultFileName() {
30 ConfigurationServiceImpl.FilePropertySource fps = new ConfigurationServiceImpl.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 ConfigurationServiceImpl.FilePropertySource fps = new ConfigurationServiceImpl.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 ConfigurationServiceImpl.FilePropertySource fps = new ConfigurationServiceImpl.FilePropertySource();
60 fps.setFileName("unknown");
61
62 boolean failedAsExpected = false;
63 try {
64 fps.loadProperties();
65 }
66 catch (RiceRuntimeException e) {
67 failedAsExpected = true;
68 }
69
70 assertTrue(failedAsExpected);
71 }
72
73 @Test public void testLoadProperties_knownFileName_noSuffix() {
74 ConfigurationServiceImpl.FilePropertySource fps = new ConfigurationServiceImpl.FilePropertySource();
75 fps.setFileName("configuration");
76
77 boolean failedAsExpected = false;
78 try {
79 fps.loadProperties();
80 }
81 catch (RiceRuntimeException e) {
82 failedAsExpected = true;
83 }
84
85 assertTrue(failedAsExpected);
86 }
87 }