KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > de > nava > informa > utils > InformaHibernateTestCase


1 //
2
// Informa -- RSS Library for Java
3
// Copyright (c) 2002-2003 by Niko Schmuck
4
//
5
// Niko Schmuck
6
// http://sourceforge.net/projects/informa
7
// mailto:niko_schmuck@users.sourceforge.net
8
//
9
// 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
27 // $Id: InformaHibernateTestCase.java,v 1.2 2004/06/28 19:14:31 niko_schmuck Exp $
28

29 package de.nava.informa.utils;
30
31 import java.io.InputStream JavaDoc;
32 import java.util.Properties JavaDoc;
33
34 import net.sf.hibernate.Session;
35
36 import org.apache.commons.logging.Log;
37 import org.apache.commons.logging.LogFactory;
38
39 import de.nava.informa.impl.hibernate.SessionHandler;
40
41 /**
42  * Base class for unit tests of classes related to
43  * the hibernate backend of the informa library.
44  *
45  * @author Niko Schmuck
46  */

47 public class InformaHibernateTestCase extends InformaTestCase {
48
49   private static Log logger = LogFactory.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 JavaDoc PROP_FILENAME = "/hibernate-unittest.properties";
57
58   protected static SessionHandler sessionHandler;
59   protected Session session;
60
61   public InformaHibernateTestCase(String JavaDoc testcase_name, String JavaDoc method_name) {
62     super(testcase_name, method_name);
63   }
64
65   public void setUp() throws Exception JavaDoc {
66     super.setUp();
67     if (sessionHandler == null) {
68       // read in properties file
69
Properties JavaDoc props = new Properties JavaDoc();
70       InputStream JavaDoc in = this.getClass().getResourceAsStream(PROP_FILENAME);
71       if (in != null)
72         props.load(in);
73       else
74         logger.warn("No test properties file (" + PROP_FILENAME +
75                     ") found in CLASSPATH.");
76       // use those properties for hibernate connection
77
sessionHandler = SessionHandler.getInstance(props);
78     }
79     session = sessionHandler.getSession();
80   }
81
82   public void tearDown() throws Exception JavaDoc {
83     session.close();
84     super.tearDown();
85   }
86
87 }
88
Popular Tags