1 /*
2 *
3 * The DbUnit Database Testing Framework
4 * Copyright (C)2002-2004, DbUnit.org
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 */
21
22 package org.dbunit;
23
24 /**
25 * DatabaseTester that configures a DriverManager from environment properties.<br>
26 * This class defines a set of keys for system properties that need to be
27 * present in the environment before using it. Example:
28 * <xmp>
29 * System.setProperty( PropertiesBasedJdbcDatabaseTester.DBUNIT_DRIVER_CLASS,
30 * "com.mycompany.myDriver" );
31 * System.setProperty( PropertiesBasedJdbcDatabaseTester.DBUNIT_CONNECTION_URL,
32 * "jdbc:mydb://host/dbname" );
33 * System.setProperty( PropertiesBasedJdbcDatabaseTester.DBUNIT_USERNAME,
34 * "myuser" );
35 * System.setProperty( PropertiesBasedJdbcDatabaseTester.DBUNIT_PASSWORD,
36 * "mypasswd" );
37 * System.setProperty( PropertiesBasedJdbcDatabaseTester.DBUNIT_SCHEMA,
38 * "myschema" );
39 * </xmp>
40 *
41 * @author Andres Almiray(aalmiray@users.sourceforge.net)
42 * @author Felipe Leme (dbunit@felipeal.net)
43 * @author Last changed by: $Author$
44 * @version $Revision$ $Date$
45 * @since 2.2.0
46 */
47 public class PropertiesBasedJdbcDatabaseTester extends JdbcDatabaseTester
48 {
49
50 /** A key for property that defines the connection url */
51 public static final String DBUNIT_CONNECTION_URL = "dbunit.connectionUrl";
52 /** A key for property that defines the driver classname */
53 public static final String DBUNIT_DRIVER_CLASS = "dbunit.driverClass";
54 /** A key for property that defines the user's password */
55 public static final String DBUNIT_PASSWORD = "dbunit.password";
56 /** A key for property that defines the username */
57 public static final String DBUNIT_USERNAME = "dbunit.username";
58 /** A key for property that defines the database schema */
59 public static final String DBUNIT_SCHEMA = "dbunit.schema";
60
61 /**
62 * Creates a new {@link JdbcDatabaseTester} using specific {@link System#getProperty(String)}
63 * values as initialization parameters
64 * @throws Exception
65 */
66 public PropertiesBasedJdbcDatabaseTester() throws Exception
67 {
68 super( System.getProperty(DBUNIT_DRIVER_CLASS),
69 System.getProperty(DBUNIT_CONNECTION_URL),
70 System.getProperty(DBUNIT_USERNAME),
71 System.getProperty(DBUNIT_PASSWORD),
72 System.getProperty(DBUNIT_SCHEMA)
73 );
74 }
75
76 }