OSDN Git Service

git-svn-id: http://www.xerial.org/svn/project/XerialJ/trunk/sqlite-jdbc@1944 ae02f08e...
authorleo <leo@ae02f08e-27ec-0310-ae8c-8ba02fe2eafd>
Fri, 11 Jan 2008 11:24:20 +0000 (11:24 +0000)
committerleo <leo@ae02f08e-27ec-0310-ae8c-8ba02fe2eafd>
Fri, 11 Jan 2008 11:24:20 +0000 (11:24 +0000)
src/test/java/org/xerial/db/sql/sqlite/SQLiteJDBCLoaderTest.java

index 1b9d352..8b385f5 100644 (file)
@@ -24,6 +24,8 @@
 //--------------------------------------
 package org.xerial.db.sql.sqlite;
 
+import static org.junit.Assert.fail;
+
 import java.sql.Connection;
 import java.sql.DriverManager;
 import java.sql.ResultSet;
@@ -51,47 +53,48 @@ public class SQLiteJDBCLoaderTest
     public void query() throws ClassNotFoundException
     {
         SQLiteJDBCLoader.initialize();
-          
-         // load the sqlite-JDBC driver into the current class loader
-         Class.forName("org.sqlite.JDBC");
-         
-         Connection connection = null;
-         try
-         {
-             // create a database connection
-             connection = DriverManager.getConnection("jdbc:sqlite::memory:");
-             Statement statement = connection.createStatement();
-             statement.setQueryTimeout(30);  // set timeout to 30 sec.
 
-             statement.executeUpdate("create table person ( id integer, name string)");
-             statement.executeUpdate("insert into person values(1, 'leo')");
-             statement.executeUpdate("insert into person values(2, 'yui')");
-             
-             ResultSet rs = statement.executeQuery("select * from person order by id");
-             while(rs.next())
-             {
-                 // read the result set
-                 int id = rs.getInt(1);
-                 String name = rs.getString(2);
-             }
-         }
-         catch(SQLException e)
-         {
-             // if e.getMessage() is "out of memory", it probably means no
-                // database file is found
-            
-         }
-         finally
-         {
+        // load the sqlite-JDBC driver into the current class loader
+        Class.forName("org.sqlite.JDBC");
+
+        Connection connection = null;
+        try
+        {
+            // create a database connection
+            connection = DriverManager.getConnection("jdbc:sqlite::memory:");
+            Statement statement = connection.createStatement();
+            statement.setQueryTimeout(30); // set timeout to 30 sec.
+
+            statement.executeUpdate("create table person ( id integer, name string)");
+            statement.executeUpdate("insert into person values(1, 'leo')");
+            statement.executeUpdate("insert into person values(2, 'yui')");
+
+            ResultSet rs = statement.executeQuery("select * from person order by id");
+            while (rs.next())
+            {
+                // read the result set
+                int id = rs.getInt(1);
+                String name = rs.getString(2);
+            }
+        }
+        catch (SQLException e)
+        {
+            // if e.getMessage() is "out of memory", it probably means no
+            // database file is found
+            fail(e.getMessage());
+        }
+        finally
+        {
             try
             {
-               if(connection != null)
-                  connection.close();
+                if (connection != null)
+                    connection.close();
             }
-            catch(SQLException e)
+            catch (SQLException e)
             {
                 // connection close failed.
+                fail(e.getMessage());
             }
-         }
-      }
+        }
+    }
 }