1 package org.wamblee.support.persistence;
3 import java.sql.Connection;
5 import javax.sql.DataSource;
8 import org.wamblee.support.persistence.Database;
9 import org.wamblee.support.persistence.DatabaseBuilder;
10 import org.wamblee.support.persistence.DatabaseProvider;
11 import org.wamblee.support.persistence.ExternalDatabase;
13 import static junit.framework.TestCase.*;
15 public class ExternalDatabaseTest {
18 public void testExternalDB() throws Exception {
19 // Connect to inmemory db using External database class.
21 Database inmemory = DatabaseBuilder
22 .getDatabase(DatabaseProvider.CAPABILITY_IN_MEMORY);
26 System.setProperty(ExternalDatabase.DB_URL_PROP, inmemory
27 .getExternalJdbcUrl());
28 System.setProperty(ExternalDatabase.DB_USER_PROP, inmemory
30 System.setProperty(ExternalDatabase.DB_PASSWORD_PROP, inmemory
33 Database external = DatabaseBuilder
34 .getDatabase(DatabaseProvider.CAPABILITY_EXTERNAL);
35 assertTrue(external instanceof ExternalDatabase);
37 DataSource ds = external.start();
38 Connection conn = ds.getConnection();
40 System.out.println("Database name: "
41 + conn.getMetaData().getDatabaseProductName());