View Javadoc
1   /*
2    * DatabaseConnectionTest.java   Mar 26, 2002
3    *
4    * The DbUnit Database Testing Framework
5    * Copyright (C)2002-2004, DbUnit.org
6    *
7    * This library is free software; you can redistribute it and/or
8    * modify it under the terms of the GNU Lesser General Public
9    * License as published by the Free Software Foundation; either
10   * version 2.1 of the License, or (at your option) any later version.
11   *
12   * This library is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this library; if not, write to the Free Software
19   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20   *
21   */
22  
23  package org.dbunit.database;
24  
25  import org.dbunit.DatabaseProfile;
26  import org.dbunit.PropertiesBasedJdbcDatabaseTester;
27  import org.dbunit.IDatabaseTester;
28  
29  /**
30   * @author Andres Almiray (aalmiray@users.sourceforge.net)
31   * @author Last changed by: $Author$
32   * @version $Revision$ $Date$
33   * @since 2.2.0
34   */
35  public class DefaultDatabaseTesterConnectionIT extends AbstractDatabaseTesterConnectionIT
36  {
37     private PropertiesBasedJdbcDatabaseTester databaseTester;
38  
39     public DefaultDatabaseTesterConnectionIT( String s )
40     {
41        super( s );
42     }
43  
44     protected IDatabaseTester getDatabaseTester() throws Exception
45     {
46        if( databaseTester == null ){
47           DatabaseProfile profile = getEnvironment().getProfile();
48           System.setProperty( PropertiesBasedJdbcDatabaseTester.DBUNIT_DRIVER_CLASS, profile.getDriverClass() );
49           System.setProperty( PropertiesBasedJdbcDatabaseTester.DBUNIT_CONNECTION_URL, profile.getConnectionUrl() );
50           System.setProperty( PropertiesBasedJdbcDatabaseTester.DBUNIT_USERNAME, profile.getUser() );
51           System.setProperty( PropertiesBasedJdbcDatabaseTester.DBUNIT_PASSWORD, profile.getPassword() );
52           System.setProperty( PropertiesBasedJdbcDatabaseTester.DBUNIT_SCHEMA, profile.getSchema() );
53           databaseTester = new PropertiesBasedJdbcDatabaseTester();
54        }
55        return databaseTester;
56     }
57  }