1/* 2 * Copyright (C) 2007 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package libcore.sqlite; 18 19import java.io.File; 20import java.io.IOException; 21import java.sql.Connection; 22import java.sql.SQLException; 23 24/** 25 * Tests the SQLite.JDBCDriver. 26 */ 27public class OldJDBCDriverFunctionalTest extends AbstractSqlTest { 28 private File dbFile = null; 29 private String connectionURL = "empty"; 30 31 @Override protected void tearDown() throws SQLException { 32 super.tearDown(); 33 dbFile.delete(); 34 } 35 36 @Override protected String getConnectionURL() { 37 if (connectionURL.equals("empty")) { 38 String tmp = System.getProperty("java.io.tmpdir"); 39 File tmpDir = new File(tmp); 40 if (tmpDir.isDirectory()) { 41 try { 42 dbFile = File.createTempFile("JDBCDriverFunctionalTest", ".db", tmpDir); 43 } catch (IOException e) { 44 System.err.println("error creating temporary DB file."); 45 } 46 dbFile.deleteOnExit(); 47 } else { 48 System.err.println("java.io.tmpdir does not exist"); 49 } 50 51 connectionURL = "jdbc:sqlite:/" + dbFile.getPath(); 52 } 53 54 return connectionURL; 55 } 56 57 @Override protected String getDriverClassName() { 58 return "SQLite.JDBCDriver"; 59 } 60 61 @Override protected int getTransactionIsolation() { 62 return Connection.TRANSACTION_SERIALIZABLE; 63 } 64} 65