1 20 package org.apache.derbyTesting.junit; 21 22 import java.sql.*; 23 24 25 import junit.extensions.TestSetup; 26 import junit.framework.Test; 27 28 31 public abstract class BaseJDBCTestSetup 32 extends TestSetup { 33 34 public BaseJDBCTestSetup(Test test) { 35 super(test); 36 } 37 38 44 private Connection conn; 45 46 49 public final TestConfiguration getTestConfiguration() 50 { 51 return TestConfiguration.getCurrent(); 52 } 53 54 66 public final Connection getConnection() throws SQLException 67 { 68 if (conn != null) 69 { 70 if (!conn.isClosed()) 71 return conn; 72 conn = null; 73 } 74 return conn = getTestConfiguration().openDefaultConnection(); 75 } 76 77 81 public void println(final String text) { 82 if (getTestConfiguration().isVerbose()) { 83 System.out.println("DEBUG: " + text); 84 } 85 } 86 87 92 protected void tearDown() 93 throws java.lang.Exception 94 { 95 JDBC.cleanup(conn); 96 conn = null; 97 } 98 } | Popular Tags |