01: /*
02: * Copyright 2005-2007 The Kuali Foundation.
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.kuali.core.util.properties;
18:
19: import org.kuali.core.exceptions.PropertiesException;
20: import org.kuali.kfs.context.KualiTestBase;
21:
22: /**
23: * This class tests the FilePropertySource methods.
24: */
25: public class FilePropertySourceTest extends KualiTestBase {
26:
27: public final void testLoadProperties_defaultFileName() {
28: FilePropertySource fps = new FilePropertySource();
29:
30: boolean failedAsExpected = false;
31: try {
32: fps.loadProperties();
33: } catch (IllegalStateException e) {
34: failedAsExpected = true;
35: }
36:
37: assertTrue(failedAsExpected);
38: }
39:
40: public final void testLoadProperties_invalidFileName() {
41: FilePropertySource fps = new FilePropertySource();
42: fps.setFileName(" ");
43:
44: boolean failedAsExpected = false;
45: try {
46: fps.loadProperties();
47: } catch (IllegalStateException e) {
48: failedAsExpected = true;
49: }
50:
51: assertTrue(failedAsExpected);
52: }
53:
54: public final void testLoadProperties_unknownFileName() {
55: FilePropertySource fps = new FilePropertySource();
56: fps.setFileName("unknown");
57:
58: boolean failedAsExpected = false;
59: try {
60: fps.loadProperties();
61: } catch (PropertiesException e) {
62: failedAsExpected = true;
63: }
64:
65: assertTrue(failedAsExpected);
66: }
67:
68: public final void testLoadProperties_knownFileName_noSuffix() {
69: FilePropertySource fps = new FilePropertySource();
70: fps.setFileName("configuration");
71:
72: boolean failedAsExpected = false;
73: try {
74: fps.loadProperties();
75: } catch (PropertiesException e) {
76: failedAsExpected = true;
77: }
78:
79: assertTrue(failedAsExpected);
80: }
81: }
|