Changeset 2027
- Timestamp:
- 03/11/08 11:13:11 (5 years ago)
- Location:
- XerialJ/trunk/sqlite-jdbc
- Files:
-
- 8 added
- 2 modified
-
pom.xml (modified) (1 diff)
-
src/test/java/org/sqlite (added)
-
src/test/java/org/sqlite/ConnectionTest.java (added)
-
src/test/java/org/sqlite/DBMetaDataTest.java (added)
-
src/test/java/org/sqlite/PrepStmtTest.java (added)
-
src/test/java/org/sqlite/RSMetaDataTest.java (added)
-
src/test/java/org/sqlite/StatementTest.java (added)
-
src/test/java/org/sqlite/TransactionTest.java (added)
-
src/test/java/org/sqlite/UDFTest.java (added)
-
src/test/java/org/xerial/db/sql/sqlite/SQLiteJDBCLoaderTest.java (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
XerialJ/trunk/sqlite-jdbc/pom.xml
r2026 r2027 14 14 <groupId>org.xerial</groupId> 15 15 <artifactId>sqlite-jdbc</artifactId> 16 <version>v042 </version>16 <version>v042.1-SNAPSHOT</version> 17 17 <name>SQLite JDBC</name> 18 18 <description>SQLite JDBC library</description> -
XerialJ/trunk/sqlite-jdbc/src/test/java/org/xerial/db/sql/sqlite/SQLiteJDBCLoaderTest.java
r1977 r2027 25 25 package org.xerial.db.sql.sqlite; 26 26 27 import static org.junit.Assert.assertEquals; 28 import static org.junit.Assert.assertTrue; 27 29 import static org.junit.Assert.fail; 28 30 … … 36 38 import org.junit.Before; 37 39 import org.junit.Test; 40 import org.sqlite.Function; 38 41 39 42 public class SQLiteJDBCLoaderTest 40 43 { 41 44 45 private Connection connection = null; 46 42 47 @Before 43 48 public void setUp() throws Exception 44 49 { 45 50 connection = null; 51 Class.forName("org.sqlite.JDBC"); 52 // create a database connection 53 connection = DriverManager.getConnection("jdbc:sqlite::memory:"); 46 54 } 47 55 48 56 @After 49 57 public void tearDown() throws Exception 50 {} 58 { 59 if (connection != null) 60 connection.close(); 61 } 51 62 52 63 @Test 53 64 public void query() throws ClassNotFoundException 54 65 { 55 // SQLiteJDBCLoader.initialize();56 57 // load the sqlite-JDBC driver into the current class loader58 Class.forName("org.sqlite.JDBC");59 60 Connection connection = null;61 66 try 62 67 { 63 // create a database connection64 connection = DriverManager.getConnection("jdbc:sqlite::memory:");65 68 Statement statement = connection.createStatement(); 66 69 statement.setQueryTimeout(30); // set timeout to 30 sec. … … 84 87 fail(e.getMessage()); 85 88 } 86 finally 87 { 88 try 89 } 90 91 @Test 92 public void function() throws SQLException 93 { 94 Function.create(connection, "total", new Function() { 95 @Override 96 protected void xFunc() throws SQLException 89 97 { 90 if (connection != null) 91 connection.close(); 98 int sum = 0; 99 for (int i = 0; i < args(); i++) 100 sum += value_int(i); 101 result(sum); 92 102 } 93 catch (SQLException e) 94 { 95 // connection close failed. 96 fail(e.getMessage()); 97 } 98 } 103 }); 104 105 ResultSet rs = connection.createStatement().executeQuery("select total(1, 2, 3, 4, 5)"); 106 assertTrue(rs.next()); 107 assertEquals(rs.getInt(1), 1 + 2 + 3 + 4 + 5); 99 108 } 109 100 110 }


