01: //
02: // Informa -- RSS Library for Java
03: // Copyright (c) 2002-2003 by Niko Schmuck
04: //
05: // Niko Schmuck
06: // http://sourceforge.net/projects/informa
07: // mailto:niko_schmuck@users.sourceforge.net
08: //
09: // This library is free software.
10: //
11: // You may redistribute it and/or modify it under the terms of the GNU
12: // Lesser General Public License as published by the Free Software Foundation.
13: //
14: // Version 2.1 of the license should be included with this distribution in
15: // the file LICENSE. If the license is not included with this distribution,
16: // you may find a copy at the FSF web site at 'www.gnu.org' or 'www.fsf.org',
17: // or you may write to the Free Software Foundation, 675 Mass Ave, Cambridge,
18: // MA 02139 USA.
19: //
20: // This library is distributed in the hope that it will be useful,
21: // but WITHOUT ANY WARRANTY; without even the implied waranty of
22: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23: // Lesser General Public License for more details.
24: //
25:
26: // $Id: InformaHibernateTestCase.java,v 1.3 2005/09/24 22:35:15 niko_schmuck Exp $
27:
28: package de.nava.informa.utils;
29:
30: import java.io.InputStream;
31: import java.util.Properties;
32:
33: import org.hibernate.Session;
34:
35: import org.apache.commons.logging.Log;
36: import org.apache.commons.logging.LogFactory;
37:
38: import de.nava.informa.impl.hibernate.SessionHandler;
39:
40: /**
41: * Base class for unit tests of classes related to
42: * the hibernate backend of the informa library.
43: *
44: * @author Niko Schmuck
45: */
46: public class InformaHibernateTestCase extends InformaTestCase {
47:
48: private static Log logger = LogFactory
49: .getLog(InformaHibernateTestCase.class);
50:
51: /**
52: * The name of the properties file containing test relevant settings.
53: * This file must be accessible from the CLASSPATH ('/' means
54: * default package).
55: */
56: public static final String PROP_FILENAME = "/hibernate-unittest.properties";
57:
58: protected static SessionHandler sessionHandler;
59: protected Session session;
60:
61: public InformaHibernateTestCase(String testcase_name,
62: String method_name) {
63: super (testcase_name, method_name);
64: }
65:
66: public void setUp() throws Exception {
67: super .setUp();
68: if (sessionHandler == null) {
69: // read in properties file
70: Properties props = new Properties();
71: InputStream in = this .getClass().getResourceAsStream(
72: PROP_FILENAME);
73: if (in != null)
74: props.load(in);
75: else
76: logger.warn("No test properties file (" + PROP_FILENAME
77: + ") found in CLASSPATH.");
78: // use those properties for hibernate connection
79: sessionHandler = SessionHandler.getInstance(props);
80: }
81: session = sessionHandler.getSession();
82: }
83:
84: public void tearDown() throws Exception {
85: session.close();
86: super.tearDown();
87: }
88:
89: }
|