cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r463122 - in /incubator/cayenne/main/trunk/integration-test/itest-common/src/main/java/org/apache/cayenne/itest: ItestDBUtils.java RowTemplate.java
Date Thu, 12 Oct 2006 03:17:09 GMT
Author: aadamchik
Date: Wed Oct 11 20:17:08 2006
New Revision: 463122

URL: http://svn.apache.org/viewvc?view=rev&rev=463122
Log:
added itest utility method to check table row count

Modified:
    incubator/cayenne/main/trunk/integration-test/itest-common/src/main/java/org/apache/cayenne/itest/ItestDBUtils.java
    incubator/cayenne/main/trunk/integration-test/itest-common/src/main/java/org/apache/cayenne/itest/RowTemplate.java

Modified: incubator/cayenne/main/trunk/integration-test/itest-common/src/main/java/org/apache/cayenne/itest/ItestDBUtils.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/integration-test/itest-common/src/main/java/org/apache/cayenne/itest/ItestDBUtils.java?view=diff&rev=463122&r1=463121&r2=463122
==============================================================================
--- incubator/cayenne/main/trunk/integration-test/itest-common/src/main/java/org/apache/cayenne/itest/ItestDBUtils.java
(original)
+++ incubator/cayenne/main/trunk/integration-test/itest-common/src/main/java/org/apache/cayenne/itest/ItestDBUtils.java
Wed Oct 11 20:17:08 2006
@@ -110,6 +110,22 @@
         }
     }
 
+    public int getRowCount(String table) throws SQLException {
+        String sql = "select count(*) from " + table;
+        
+        final int[] result = new int[1];
+        RowTemplate template = new RowTemplate(this) {
+
+            @Override
+            void readRow(ResultSet rs, String sql) throws SQLException {
+                result[0] = rs.getInt(1);
+            }
+        };
+
+        template.execute(sql);
+        return result[0];
+    }
+
     public Object getObject(String table, String column) throws SQLException {
         final String sql = "select " + column + " from " + table;
 

Modified: incubator/cayenne/main/trunk/integration-test/itest-common/src/main/java/org/apache/cayenne/itest/RowTemplate.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/integration-test/itest-common/src/main/java/org/apache/cayenne/itest/RowTemplate.java?view=diff&rev=463122&r1=463121&r2=463122
==============================================================================
--- incubator/cayenne/main/trunk/integration-test/itest-common/src/main/java/org/apache/cayenne/itest/RowTemplate.java
(original)
+++ incubator/cayenne/main/trunk/integration-test/itest-common/src/main/java/org/apache/cayenne/itest/RowTemplate.java
Wed Oct 11 20:17:08 2006
@@ -21,6 +21,11 @@
 import java.sql.ResultSet;
 import java.sql.SQLException;
 
+/**
+ * A JDBC template for reading a single row from the database.
+ * 
+ * @author Andrus Adamchik
+ */
 abstract class RowTemplate extends ResultSetTemplate {
 
     public RowTemplate(ItestDBUtils parent) {



Mime
View raw message