01: // You can redistribute this software and/or modify it under the terms of
02: // the Ozone Library License version 1 published by ozone-db.org.
03: //
04: // The original code and portions created by SMB are
05: // Copyright (C) 1997-2001 by SMB GmbH. All rights reserved.
06: //
07: // $Id: OpenXmlTestCase.java,v 1.2 2002/02/09 18:46:47 per_nyfelt Exp $
08:
09: package test.openxml;
10:
11: import java.io.File;
12: import java.io.FileInputStream;
13: import java.util.Properties;
14:
15: import junit.framework.TestCase;
16: import org.ozoneDB.ExternalDatabase;
17:
18: /**
19: * This is the fixture for the openXml tests
20: * @author Per Nyfelt
21: */
22: public class OpenXmlTestCase extends TestCase {
23:
24: /** the datbase used for all tests */
25: protected ExternalDatabase db;
26: protected String xmlTestDataFileName = OpenXmlTestSuite.xmlTestDataFileName;
27:
28: public OpenXmlTestCase(String name) {
29: super (name);
30: }
31:
32: public void setUp() throws Exception {
33: Properties props = loadProps(OpenXmlTestSuite.propertiesFileName);
34: String dbURI = props.getProperty("dbURI");
35: db = ExternalDatabase.openDatabase(dbURI);
36: db.reloadClasses();
37:
38: }
39:
40: public void tearDown() throws Exception {
41: db.close();
42: }
43:
44: /**
45: * Helper method to load the OpenXmlTestCase.properties file
46: *
47: * @return the loaded properties
48: */
49: private Properties loadProps(String propsFileName) {
50: Properties defaultProps = new Properties();
51:
52: // set default parameters
53: defaultProps.put("dbURI", "ozonedb:remote://localhost:3333");
54: Properties props = new Properties(defaultProps);
55:
56: // now load the props file
57: try {
58: props.load(new FileInputStream(new File(propsFileName)));
59: } catch (Exception e) {
60: System.out
61: .println("Didn't find props file, using defaults");
62: props.list(System.out);
63: }
64: return props;
65: }
66: }
|