KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > openxml > OpenXmlTestCase


1 // You can redistribute this software and/or modify it under the terms of
2
// the Ozone Library License version 1 published by ozone-db.org.
3
//
4
// The original code and portions created by SMB are
5
// Copyright (C) 1997-2001 by SMB GmbH. All rights reserved.
6
//
7
// $Id: OpenXmlTestCase.java,v 1.1 2003/11/02 17:29:30 per_nyfelt Exp $
8

9 package test.openxml;
10
11 import java.io.File JavaDoc;
12 import java.io.FileInputStream JavaDoc;
13 import java.util.Properties JavaDoc;
14
15 import junit.framework.TestCase;
16 import org.ozoneDB.ExternalDatabase;
17
18
19 /**
20  * This is the fixture for the openXml tests
21  * @author Per Nyfelt
22  */

23 public class OpenXmlTestCase extends TestCase {
24
25     /** the datbase used for all tests */
26     protected ExternalDatabase db;
27     protected String JavaDoc xmlTestDataFileName = OpenXmlTestSuite.xmlTestDataFileName;
28
29     public OpenXmlTestCase(String JavaDoc name) {
30         super(name);
31     }
32
33     public void setUp() throws Exception JavaDoc {
34         Properties JavaDoc props = loadProps(OpenXmlTestSuite.propertiesFileName);
35         String JavaDoc dbURI = props.getProperty("dbURI");
36         db = ExternalDatabase.openDatabase(dbURI);
37         db.reloadClasses();
38
39     }
40
41     public void tearDown() throws Exception JavaDoc {
42         db.close();
43     }
44
45     /**
46      * Helper method to load the OpenXmlTestCase.properties file
47      *
48      * @return the loaded properties
49      */

50     private Properties JavaDoc loadProps(String JavaDoc propsFileName) {
51         Properties JavaDoc defaultProps = new Properties JavaDoc();
52
53         // set default parameters
54
defaultProps.put("dbURI", "ozonedb:remote://localhost:3333");
55         Properties JavaDoc props = new Properties JavaDoc(defaultProps);
56
57         // now load the props file
58
try {
59             props.load(new FileInputStream JavaDoc(new File JavaDoc(propsFileName)));
60         } catch (Exception JavaDoc e) {
61             System.out.println("Didn't find props file, using defaults");
62             props.list(System.out);
63         }
64         return props;
65     }
66 }
67
Popular Tags