01: /*
02: * Copyright 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: package edu.iu.uis.eden.messaging.resourceloading;
17:
18: import java.util.Properties;
19:
20: import junit.framework.TestCase;
21:
22: import org.junit.Test;
23: import org.kuali.rice.config.Config;
24: import org.kuali.rice.config.ConfigurationException;
25: import org.kuali.rice.config.SimpleConfig;
26: import org.kuali.rice.core.Core;
27: import org.kuali.rice.resourceloader.GlobalResourceLoader;
28: import org.kuali.rice.resourceloader.ResourceLoader;
29:
30: public class KSBResourceLoaderFactoryTest extends TestCase {
31:
32: @Test
33: public void testCreateKSBResourceLoader() throws Exception {
34: String me = "TestME";
35: Properties props = new Properties();
36: props.put(Config.MESSAGE_ENTITY, me);
37: Config config = new SimpleConfig(props);
38: config.parseConfig();
39: Core.init(config);
40:
41: ResourceLoader rl = KSBResourceLoaderFactory
42: .createRootKSBResourceLoader();
43: assertNotNull(rl.getResourceLoader(KSBResourceLoaderFactory
44: .getSpringResourceLoaderName()));
45: assertNotNull(rl.getResourceLoader(KSBResourceLoaderFactory
46: .getRemoteResourceLoaderName()));
47: assertNotNull(GlobalResourceLoader
48: .getResourceLoader(KSBResourceLoaderFactory
49: .getSpringResourceLoaderName()));
50: assertNotNull(GlobalResourceLoader
51: .getResourceLoader(KSBResourceLoaderFactory
52: .getRemoteResourceLoaderName()));
53: }
54:
55: @Test
56: public void testCreateKSBResourceLoaderNoMessageEntity()
57: throws Exception {
58:
59: Properties props = new Properties();
60: Config config = new SimpleConfig(props);
61: config.parseConfig();
62: Core.init(config);
63:
64: boolean errorThrown = false;
65: try {
66: KSBResourceLoaderFactory.createRootKSBResourceLoader();
67: fail("should have thrown configuration exception with no message entity present");
68: } catch (ConfigurationException ce) {
69: errorThrown = true;
70: }
71: assertTrue(errorThrown);
72: }
73:
74: }
|