01: /**********************************************************************************
02: * $URL: https://source.sakaiproject.org/svn/metaobj/tags/sakai_2-4-1/metaobj-impl/api-impl/src/java/org/sakaiproject/metaobj/shared/SpringBaseTest.java $
03: * $Id: SpringBaseTest.java 14225 2006-09-05 17:39:44Z chmaurer@iupui.edu $
04: ***********************************************************************************
05: *
06: * Copyright (c) 2004, 2005, 2006 The Sakai Foundation.
07: *
08: * Licensed under the Educational Community License, Version 1.0 (the "License");
09: * you may not use this file except in compliance with the License.
10: * You may obtain a copy of the License at
11: *
12: * http://www.opensource.org/licenses/ecl1.php
13: *
14: * Unless required by applicable law or agreed to in writing, software
15: * distributed under the License is distributed on an "AS IS" BASIS,
16: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17: * See the License for the specific language governing permissions and
18: * limitations under the License.
19: *
20: **********************************************************************************/package org.sakaiproject.metaobj.shared;
21:
22: import java.io.IOException;
23: import java.io.InputStream;
24: import java.util.Properties;
25:
26: import junit.framework.TestCase;
27:
28: import org.apache.commons.logging.Log;
29: import org.apache.commons.logging.LogFactory;
30: import org.sakaiproject.metaobj.utils.ioc.ApplicationContextFactory;
31: import org.springframework.beans.factory.BeanFactory;
32:
33: /**
34: * Created by IntelliJ IDEA.
35: * User: John Ellis
36: * Date: May 6, 2004
37: * Time: 12:46:55 PM
38: * To change this template use File | Settings | File Templates.
39: */
40: public abstract class SpringBaseTest extends TestCase {
41: protected final Log logger = LogFactory.getLog(getClass());
42:
43: private BeanFactory beanFactory;
44:
45: protected SpringBaseTest(String s) {
46: super (s);
47: }
48:
49: protected SpringBaseTest() {
50: }
51:
52: public BeanFactory getBeanFactory() {
53: if (beanFactory == null) {
54: Properties props = new Properties();
55: InputStream in = this .getClass().getResourceAsStream(
56: "/test-context.properties");
57: try {
58: props.load(in);
59: } catch (IOException e) {
60: throw new RuntimeException(
61: "problem loading context.properties from classpath",
62: e);
63: }
64: beanFactory = ApplicationContextFactory.getInstance()
65: .createContext(props);
66: }
67: return beanFactory;
68: }
69:
70: }
|