=== modified file 'java/testsuite/ndbj/SelectCountTest.java'
--- a/java/testsuite/ndbj/SelectCountTest.java	2008-05-19 20:13:45 +0000
+++ b/java/testsuite/ndbj/SelectCountTest.java	2008-05-20 03:50:10 +0000
@@ -1,6 +1,7 @@
 package testsuite.ndbj;
 
 import java.math.BigInteger;
+import java.util.Random;
 
 import testsuite.BaseNdbjTestCase;
 
@@ -27,43 +28,48 @@
 			"(`"+col1+"` INT PRIMARY KEY, `"+col2+"` VARCHAR(256)) ENGINE=ndbcluster;");
 	}
 
-	/*
-	 * Test method for 'com.mysql.ndbapi.Ndb.destroy()'
+	/**
+	 * Test for NdbTransaction.selectCount().
 	 */
-//	public void testInsertAndReadAndUpdateAndReadAndDeleteAndRead() {
-//		// TODO Auto-generated method stub
-//	}
+	public void testCount() throws NdbApiException {
+		BigInteger count;
 
-	public void testInsert() throws NdbApiException {
+		// insert many rows
 		trans = ndb.startTransaction();
-
-		for (int i=0; i< SELECT_COUNT; i++) {
+		for (int i=0; i < SELECT_COUNT; i++) {
 			NdbOperation op = trans.getInsertOperation(theTableName);
 			op.equalInt(col1,i);
 			String input = "jim" + i;
 			op.setString(col2,input);
 		}
-
 		trans.execute(ExecType.Commit, AbortOption.AbortOnError, true);
-
 		trans.close();
 
+		// check that the correct number of rows were inserted
 		trans = ndb.startTransaction();
-
 		// TODO: Fix BigInteger selectCount() issues
-		BigInteger count = trans.selectCount(theTableName);
-		assertEquals((count.compareTo(BigInteger.ZERO) < 0), false);
-
+		count = trans.selectCount(theTableName);
+		assertEquals(SELECT_COUNT, count.intValue());
 		trans.close();
 
+		// delete a random number of rows
+		int rows = 100 + new Random().nextInt(SELECT_COUNT / 2);
+
 		trans = ndb.startTransaction();
 
-		for (int i=0;i<SELECT_COUNT; i++) {
+		for (int i = 0; i < rows; ++i) {
 			NdbOperation op = trans.getDeleteOperation(theTableName);
 			op.equalInt(col1,i);
 		}
 
 		trans.execute(ExecType.Commit, AbortOption.AbortOnError, true);
 		trans.close();
+
+		// check count again
+		trans = ndb.startTransaction();
+		count = trans.selectCount(theTableName);
+		trans.execute(ExecType.Commit, AbortOption.AbortOnError, true);
+		trans.close();
+		assertEquals(SELECT_COUNT - rows, count.intValue());
 	}
 }



