AI 144808: am: CL 144804 am: CL 144802 Bringing SQL down to zero broken tests. Restructuring
some overengineered tests, so they are able to execute
in the CTS host and our CoreTestRunner.
Original author: jorgp
Merged from: //branches/cupcake/...
Original author: android-build
Automated import of CL 144808
diff --git a/libcore/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/DriverManagerTest.java b/libcore/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/DriverManagerTest.java
index 024ee0a..6d13654 100644
--- a/libcore/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/DriverManagerTest.java
+++ b/libcore/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/DriverManagerTest.java
@@ -17,7 +17,6 @@
package org.apache.harmony.sql.tests.java.sql;
-import dalvik.annotation.BrokenTest;
import dalvik.annotation.KnownFailure;
import dalvik.annotation.TestTargetClass;
import dalvik.annotation.TestTargets;
diff --git a/libcore/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/DriverPropertyInfoTest.java b/libcore/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/DriverPropertyInfoTest.java
index e442987..0f92491 100644
--- a/libcore/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/DriverPropertyInfoTest.java
+++ b/libcore/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/DriverPropertyInfoTest.java
@@ -41,20 +41,6 @@
public class DriverPropertyInfoTest extends TestCase {
/*
- * Public statics test
- */
- @TestTargetNew(
- level = TestLevel.ADDITIONAL,
- notes = "Empty test",
- method = "!",
- args = {}
- )
- @BrokenTest("empty")
- public void testPublicStatics() {
-
- } // end method testPublicStatics
-
- /*
* Constructor test
*/
@TestTargetNew(
diff --git a/libcore/sql/src/test/java/tests/SQLite/DatabaseTest.java b/libcore/sql/src/test/java/tests/SQLite/DatabaseTest.java
index 8bea69d..95ce7c8 100644
--- a/libcore/sql/src/test/java/tests/SQLite/DatabaseTest.java
+++ b/libcore/sql/src/test/java/tests/SQLite/DatabaseTest.java
@@ -1054,7 +1054,7 @@
args = {FunctionContext.class, String[].class}
)
})
- @AndroidOnly("Aggregation function not called")
+ @KnownFailure("Aggregation function not called")
public void testCreate_aggregate() {
TestTrace t = new TestTrace();
diff --git a/libcore/sql/src/test/java/tests/SQLite/FunctionContextTest.java b/libcore/sql/src/test/java/tests/SQLite/FunctionContextTest.java
index 249af54..ef76307 100644
--- a/libcore/sql/src/test/java/tests/SQLite/FunctionContextTest.java
+++ b/libcore/sql/src/test/java/tests/SQLite/FunctionContextTest.java
@@ -213,7 +213,7 @@
method = "set_result_zeroblob",
args = {int.class}
)
- @AndroidOnly("ZeroBlob not supported")
+ @KnownFailure("ZeroBlob not supported")
public void testSet_result_zeroblob() throws Exception,
UnsupportedEncodingException {
Stmt st = null;
diff --git a/libcore/sql/src/test/java/tests/SQLite/StmtTest.java b/libcore/sql/src/test/java/tests/SQLite/StmtTest.java
index b60fe2b..87e95a5 100644
--- a/libcore/sql/src/test/java/tests/SQLite/StmtTest.java
+++ b/libcore/sql/src/test/java/tests/SQLite/StmtTest.java
@@ -21,8 +21,8 @@
import SQLite.Exception;
import SQLite.Stmt;
import SQLite.TableResult;
-import dalvik.annotation.AndroidOnly;
import dalvik.annotation.BrokenTest;
+import dalvik.annotation.KnownFailure;
import dalvik.annotation.TestLevel;
import dalvik.annotation.TestTargetNew;
import dalvik.annotation.TestTargetClass;
@@ -1001,7 +1001,7 @@
method = "column_type",
args = {int.class}
)
- @AndroidOnly("For numeric, float and blob wrong type is returned")
+ @KnownFailure("For numeric, float and blob wrong type is returned")
public void testColumn_type() throws Exception {
db.exec(createAllTypes, null);
db.exec(insertAllTypes, null);
@@ -1066,7 +1066,7 @@
method = "column_count",
args = {}
)
- @AndroidOnly("Wrong value is returned in case of a prepared statment to "+
+ @KnownFailure("Wrong value is returned in case of a prepared statment to "+
"which a '*' bound ")
public void testColumn_count() throws Exception {
diff --git a/libcore/sql/src/test/java/tests/java/sql/AllTests.java b/libcore/sql/src/test/java/tests/java/sql/AllTests.java
index 8c1e51a..c6a2bff 100644
--- a/libcore/sql/src/test/java/tests/java/sql/AllTests.java
+++ b/libcore/sql/src/test/java/tests/java/sql/AllTests.java
@@ -33,16 +33,15 @@
TestSuite suite = tests.TestSuiteFactory.createTestSuite("All tests for package tests.java.sql;");
// $JUnit-BEGIN$
- suite.addTest(DatabaseMetaDataTest.suite());
- suite.addTest(MultiThreadAccessTest.suite());
- suite.addTest(StressTest.suite());
- suite.addTest(UpdateFunctionalityTest.suite());
- suite.addTest(SelectFunctionalityTest.suite());
- suite.addTest(UpdateFunctionalityTest2.suite());
- suite.addTest(DeleteFunctionalityTest.suite());
- suite.addTest(DatabaseMetaDataTest.suite());
- suite.addTest(DatabaseMetaDataNotSupportedTest.suite());
- suite.addTest(InsertFunctionalityTest.suite());
+ suite.addTestSuite(MultiThreadAccessTest.class);
+ suite.addTestSuite(tests.java.sql.StressTest.class);
+ suite.addTestSuite(tests.java.sql.UpdateFunctionalityTest.class);
+ suite.addTestSuite(tests.java.sql.SelectFunctionalityTest.class);
+ suite.addTestSuite(tests.java.sql.UpdateFunctionalityTest2.class);
+ suite.addTestSuite(tests.java.sql.DeleteFunctionalityTest.class);
+ suite.addTestSuite(tests.java.sql.DatabaseMetaDataTest.class);
+ suite.addTestSuite(tests.java.sql.DatabaseMetaDataNotSupportedTest.class);
+ suite.addTestSuite(tests.java.sql.InsertFunctionalityTest.class);
// $JUnit-END$
return suite;
diff --git a/libcore/sql/src/test/java/tests/java/sql/DatabaseMetaDataNotSupportedTest.java b/libcore/sql/src/test/java/tests/java/sql/DatabaseMetaDataNotSupportedTest.java
index 9f262d9..887a717 100644
--- a/libcore/sql/src/test/java/tests/java/sql/DatabaseMetaDataNotSupportedTest.java
+++ b/libcore/sql/src/test/java/tests/java/sql/DatabaseMetaDataNotSupportedTest.java
@@ -56,80 +56,77 @@
protected static Statement statementForward;
private static int id = 1;
- public static Test suite() {
- TestSetup setup = new TestSetup(new TestSuite(
- DatabaseMetaDataTest.class)) {
- protected void setUp() {
- Support_SQL.loadDriver();
- try {
- conn = Support_SQL.getConnection();
- meta = conn.getMetaData();
- statement = conn.createStatement();
- createTestTables();
- } catch (SQLException e) {
- System.out.println("Error in test setup: "+e.getMessage());
- }
- }
+
+ public void setUp() throws Exception {
+ super.setUp();
+ Support_SQL.loadDriver();
+ try {
+ conn = Support_SQL.getConnection();
+ meta = conn.getMetaData();
+ statement = conn.createStatement();
+ createTestTables();
+ } catch (SQLException e) {
+ System.out.println("Error in test setup: "+e.getMessage());
+ }
+ }
- protected void tearDown() {
- try {
- conn = Support_SQL.getConnection();
- meta = conn.getMetaData();
- statement = conn.createStatement();
- deleteTestTables();
- } catch (SQLException e) {
- System.out.println("Error in teardown: "+e.getMessage());
- } finally {
- try {
- conn.close();
- } catch (SQLException e) {
- }
- }
+ public void tearDown() throws Exception {
+ try {
+ conn = Support_SQL.getConnection();
+ meta = conn.getMetaData();
+ statement = conn.createStatement();
+ deleteTestTables();
+ } catch (SQLException e) {
+ System.out.println("Error in teardown: "+e.getMessage());
+ } finally {
+ try {
+ conn.close();
+ } catch (SQLException e) {
}
+ }
+ super.tearDown();
+ }
- private void createTestTables() {
- try {
- ResultSet userTab = meta.getTables(null, null, null, null);
- while (userTab.next()) {
- String tableName = userTab.getString("TABLE_NAME");
- if (tableName.equals(DatabaseCreator.TEST_TABLE1)) {
- statement.execute(DatabaseCreator.DROP_TABLE1);
- } else if (tableName
- .equals(DatabaseCreator.TEST_TABLE3)) {
- statement.execute(DatabaseCreator.DROP_TABLE3);
- } else if (tableName.equals(VIEW_NAME)) {
- statement.execute(DROP_VIEW_QUERY);
- }
- }
- userTab.close();
- statement.execute(DatabaseCreator.CREATE_TABLE3);
- statement.execute(DatabaseCreator.CREATE_TABLE1);
- statement.execute(CREATE_VIEW_QUERY);
- meta = conn.getMetaData();
- } catch (SQLException e) {
- fail("Unexpected SQLException " + e.toString());
- }
- }
-
- private void deleteTestTables() {
- try {
+ private void createTestTables() {
+ try {
+ ResultSet userTab = meta.getTables(null, null, null, null);
+ while (userTab.next()) {
+ String tableName = userTab.getString("TABLE_NAME");
+ if (tableName.equals(DatabaseCreator.TEST_TABLE1)) {
statement.execute(DatabaseCreator.DROP_TABLE1);
+ } else if (tableName
+ .equals(DatabaseCreator.TEST_TABLE3)) {
statement.execute(DatabaseCreator.DROP_TABLE3);
+ } else if (tableName.equals(VIEW_NAME)) {
statement.execute(DROP_VIEW_QUERY);
- } catch (SQLException e) {
- fail("Unexpected SQLException " + e.toString());
- } finally {
- try {
- if (! conn.isClosed()) {
- conn.close();
- }
- } catch (SQLException e) {
-
- }
}
}
- };
- return setup;
+ userTab.close();
+ statement.execute(DatabaseCreator.CREATE_TABLE3);
+ statement.execute(DatabaseCreator.CREATE_TABLE1);
+ statement.execute(CREATE_VIEW_QUERY);
+ meta = conn.getMetaData();
+ } catch (SQLException e) {
+ fail("Unexpected SQLException " + e.toString());
+ }
+ }
+
+ private void deleteTestTables() {
+ try {
+ statement.execute(DatabaseCreator.DROP_TABLE1);
+ statement.execute(DatabaseCreator.DROP_TABLE3);
+ statement.execute(DROP_VIEW_QUERY);
+ } catch (SQLException e) {
+ fail("Unexpected SQLException " + e.toString());
+ } finally {
+ try {
+ if (! conn.isClosed()) {
+ conn.close();
+ }
+ } catch (SQLException e) {
+
+ }
+ }
}
/**
@@ -143,6 +140,7 @@
)
public void test_allProceduresAreCallable() throws SQLException {
// NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.allProceduresAreCallable());
}
/**
@@ -222,6 +220,7 @@
)
public void test_dataDefinitionIgnoredInTransactions() throws SQLException {
// NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.dataDefinitionIgnoredInTransactions());
}
/**
@@ -235,6 +234,7 @@
)
public void test_deletesAreDetectedI() throws SQLException {
// NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.deletesAreDetected(0));
}
/**
@@ -246,8 +246,10 @@
method = "doesMaxRowSizeIncludeBlobs",
args = {}
)
+ @KnownFailure("not supported")
public void test_doesMaxRowSizeIncludeBlobs() throws SQLException {
// NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.doesMaxRowSizeIncludeBlobs());
}
/**
@@ -342,6 +344,7 @@
method = "getIndexInfo",
args = {java.lang.String.class, java.lang.String.class, java.lang.String.class, boolean.class, boolean.class}
)
+ @KnownFailure("not supported")
public void test_getIndexInfoLjava_lang_StringLjava_lang_StringLjava_lang_StringZZ()
throws SQLException {
boolean unique = false;
@@ -394,10 +397,11 @@
*/
@TestTargetNew(
level = TestLevel.NOT_FEASIBLE,
- notes = "not supported. not supported. Received result wasn't checked.",
+ notes = "not supported. Received result wasn't checked.",
method = "getColumnPrivileges",
args = {java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class}
)
+ @KnownFailure("not supported. Privileges are not supported.")
public void test_getColumnPrivilegesLjava_lang_StringLjava_lang_StringLjava_lang_StringLjava_lang_String()
throws SQLException {
ResultSet rs = meta.getColumnPrivileges(conn.getCatalog(), null,
@@ -457,6 +461,7 @@
method = "getExportedKeys",
args = {java.lang.String.class, java.lang.String.class, java.lang.String.class}
)
+ @KnownFailure("not supported")
public void test_getExportedKeysLjava_lang_StringLjava_lang_StringLjava_lang_String()
throws SQLException {
ResultSet rs = meta.getExportedKeys(conn.getCatalog(), null,
@@ -521,6 +526,7 @@
public void test_getProcedureColumnsLjava_lang_StringLjava_lang_StringLjava_lang_StringLjava_lang_String()
throws SQLException {
// NOT_FEASIBLE: SQLITE does not implement this functionality
+ meta.getProcedureColumns("", "", "", "");
}
/**
@@ -547,6 +553,7 @@
method = "getProcedureTerm",
args = {}
)
+ @KnownFailure("Exception test fails")
public void test_getProcedureTerm() throws SQLException {
assertTrue("Incorrect procedure term", "".equals(meta
.getProcedureTerm().trim()));
@@ -571,6 +578,7 @@
method = "getSchemaTerm",
args = {}
)
+ @KnownFailure("Exception test fails")
public void test_getSchemaTerm() throws SQLException {
String term = meta.getSchemaTerm();
assertNotNull("Incorrect schema term", term );
@@ -626,10 +634,11 @@
*/
@TestTargetNew(
level = TestLevel.NOT_FEASIBLE,
- notes = "not supported. not supported. Received result wasn't checked.",
+ notes = "not supported. Received result wasn't checked.",
method = "getTablePrivileges",
args = {java.lang.String.class, java.lang.String.class, java.lang.String.class}
)
+ @KnownFailure("not supported. Privileges are not supported.")
public void test_getTablePrivilegesLjava_lang_StringLjava_lang_StringLjava_lang_String()
throws SQLException {
// case 1. Get privileges when no privilegies exist for one table
@@ -783,6 +792,7 @@
method = "isCatalogAtStart",
args = {}
)
+ @KnownFailure("Exception test fails")
public void test_isCatalogAtStart() throws SQLException {
assertFalse(
"catalog doesn't appear at the start of a fully qualified table name",
@@ -808,8 +818,10 @@
method = "locatorsUpdateCopy",
args = {}
)
+ @KnownFailure("not supported")
public void test_locatorsUpdateCopy() throws SQLException {
// NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.locatorsUpdateCopy());
}
/**
@@ -823,6 +835,7 @@
)
public void test_nullPlusNonNullIsNull() throws SQLException {
// NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.nullPlusNonNullIsNull());
}
/**
@@ -836,6 +849,7 @@
)
public void test_nullsAreSortedAtEnd() throws SQLException {
// NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.nullsAreSortedAtEnd());
}
/**
@@ -849,6 +863,7 @@
)
public void test_nullsAreSortedAtStart() throws SQLException {
// NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.nullsAreSortedAtStart());
}
/**
@@ -862,6 +877,7 @@
)
public void test_nullsAreSortedHigh() throws SQLException {
// NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.nullsAreSortedHigh());
}
/**
@@ -875,6 +891,7 @@
)
public void test_nullsAreSortedLow() throws SQLException {
// NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.nullsAreSortedLow());
}
/**
@@ -933,9 +950,7 @@
method = "ownUpdatesAreVisible",
args = {int.class}
)
- @KnownFailure("Not supported ops applied")
public void test_ownUpdatesAreVisibleI() throws SQLException {
- // NOT_FEASIBLE not supported
assertFalse(
"result set's own updates are visible for TYPE_FORWARD_ONLY type",
meta.ownUpdatesAreVisible(ResultSet.TYPE_FORWARD_ONLY));
@@ -959,7 +974,7 @@
args = {}
)
public void test_storesLowerCaseIdentifiers() throws SQLException {
- // NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.storesLowerCaseIdentifiers());
}
/**
@@ -972,7 +987,7 @@
args = {}
)
public void test_storesLowerCaseQuotedIdentifiers() throws SQLException {
- // NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.storesLowerCaseQuotedIdentifiers());
}
/**
@@ -986,6 +1001,7 @@
)
public void test_storesUpperCaseIdentifiers() throws SQLException {
// NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.storesUpperCaseIdentifiers());
}
/**
@@ -999,6 +1015,7 @@
)
public void test_storesUpperCaseQuotedIdentifiers() throws SQLException {
// NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.storesUpperCaseQuotedIdentifiers());
}
/**
@@ -1010,8 +1027,10 @@
method = "supportsANSI92EntryLevelSQL",
args = {}
)
+ @KnownFailure("not supported")
public void test_supportsANSI92EntryLevelSQL() throws SQLException {
// NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.supportsANSI92EntryLevelSQL());
}
/**
@@ -1025,6 +1044,7 @@
)
public void test_supportsANSI92FullSQL() throws SQLException {
// NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.supportsANSI92FullSQL());
}
/**
@@ -1038,6 +1058,7 @@
)
public void test_supportsANSI92IntermediateSQL() throws SQLException {
// NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.supportsANSI92IntermediateSQL());
}
/**
@@ -1051,6 +1072,7 @@
)
public void test_supportsAlterTableWithAddColumn() throws SQLException {
// NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.supportsAlterTableWithAddColumn());
}
/**
@@ -1064,6 +1086,8 @@
)
public void test_supportsAlterTableWithDropColumn() throws SQLException {
// NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.supportsAlterTableWithDropColumn());
+
}
/**
@@ -1077,6 +1101,7 @@
)
public void test_supportsBatchUpdates() throws SQLException {
// NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.supportsBatchUpdates());
}
/**
@@ -1090,6 +1115,7 @@
)
public void test_supportsCatalogsInDataManipulation() throws SQLException {
// NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.supportsCatalogsInDataManipulation());
}
/**
@@ -1103,6 +1129,7 @@
)
public void test_supportsCatalogsInIndexDefinitions() throws SQLException {
// NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.supportsCatalogsInIndexDefinitions());
}
/**
@@ -1117,6 +1144,7 @@
public void test_supportsCatalogsInPrivilegeDefinitions()
throws SQLException {
// NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.supportsCatalogsInPrivilegeDefinitions());
}
/**
@@ -1130,6 +1158,7 @@
)
public void test_supportsCatalogsInProcedureCalls() throws SQLException {
// NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.supportsCatalogsInProcedureCalls());
}
/**
@@ -1143,6 +1172,7 @@
)
public void test_supportsCatalogsInTableDefinitions() throws SQLException {
// NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.supportsCatalogsInTableDefinitions());
}
/**
@@ -1156,6 +1186,7 @@
)
public void test_supportsConvert() throws SQLException {
// NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.supportsConvert());
}
/**
@@ -1169,6 +1200,7 @@
)
public void test_supportsConvertII() throws SQLException {
// NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.supportsConvert());
}
/**
@@ -1182,6 +1214,7 @@
)
public void test_supportsCoreSQLGrammar() throws SQLException {
// NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.supportsCoreSQLGrammar());
}
/**
@@ -1195,6 +1228,7 @@
)
public void test_supportsCorrelatedSubqueries() throws SQLException {
// NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.supportsCorrelatedSubqueries());
}
/**
@@ -1206,9 +1240,11 @@
method = "supportsDataDefinitionAndDataManipulationTransactions",
args = {}
)
+ @KnownFailure("not supported")
public void test_supportsDataDefinitionAndDataManipulationTransactions()
throws SQLException {
// NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.supportsDataDefinitionAndDataManipulationTransactions());
}
/**
@@ -1223,6 +1259,7 @@
public void test_supportsDataManipulationTransactionsOnly()
throws SQLException {
// NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.supportsDataManipulationTransactionsOnly());
}
/**
@@ -1237,6 +1274,7 @@
public void test_supportsDifferentTableCorrelationNames()
throws SQLException {
// NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.supportsDifferentTableCorrelationNames());
}
@@ -1251,6 +1289,7 @@
)
public void test_supportsExtendedSQLGrammar() throws SQLException {
// NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.supportsExtendedSQLGrammar());
}
/**
@@ -1264,6 +1303,7 @@
)
public void test_supportsFullOuterJoins() throws SQLException {
// NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.supportsFullOuterJoins());
}
/**
@@ -1277,6 +1317,7 @@
)
public void test_supportsGetGeneratedKeys() throws SQLException {
// NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.supportsGetGeneratedKeys());
}
/**
@@ -1290,6 +1331,7 @@
)
public void test_supportsGroupByBeyondSelect() throws SQLException {
// NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.supportsGroupByBeyondSelect());
}
/**
@@ -1303,6 +1345,7 @@
)
public void test_supportsIntegrityEnhancementFacility() throws SQLException {
// NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.supportsIntegrityEnhancementFacility());
}
/**
@@ -1316,6 +1359,7 @@
)
public void test_supportsLikeEscapeClause() throws SQLException {
// NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.supportsLikeEscapeClause());
}
/**
@@ -1329,6 +1373,7 @@
)
public void test_supportsLimitedOuterJoins() throws SQLException {
// NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.supportsLimitedOuterJoins());
}
/**
@@ -1340,8 +1385,10 @@
method = "supportsMinimumSQLGrammar",
args = {}
)
+ @KnownFailure("not supported")
public void test_supportsMinimumSQLGrammar() throws SQLException {
// NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.supportsMinimumSQLGrammar());
}
/**
@@ -1355,6 +1402,7 @@
)
public void test_supportsMixedCaseIdentifiers() throws SQLException {
// NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.supportsMixedCaseIdentifiers());
}
/**
@@ -1368,6 +1416,7 @@
)
public void test_supportsMixedCaseQuotedIdentifiers() throws SQLException {
// NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.supportsMixedCaseQuotedIdentifiers());
}
/**
@@ -1381,6 +1430,7 @@
)
public void test_supportsMultipleOpenResults() throws SQLException {
// NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.supportsMultipleOpenResults());
}
/**
@@ -1394,6 +1444,7 @@
)
public void test_supportsMultipleResultSets() throws SQLException {
// NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.supportsMultipleResultSets());
}
/**
@@ -1407,6 +1458,7 @@
)
public void test_supportsMultipleTransactions() throws SQLException {
// NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.supportsMultipleTransactions());
}
/**
@@ -1420,6 +1472,7 @@
)
public void test_supportsNamedParameters() throws SQLException {
// NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.supportsNamedParameters());
}
/**
@@ -1433,6 +1486,7 @@
)
public void test_supportsOpenCursorsAcrossCommit() throws SQLException {
// NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.supportsOpenCursorsAcrossCommit());
}
/**
@@ -1446,6 +1500,7 @@
)
public void test_supportsOpenCursorsAcrossRollback() throws SQLException {
// NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.supportsOpenCursorsAcrossRollback());
}
/**
@@ -1459,6 +1514,7 @@
)
public void test_supportsOpenStatementsAcrossCommit() throws SQLException {
// NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.supportsOpenStatementsAcrossCommit());
}
/**
@@ -1472,6 +1528,7 @@
)
public void test_supportsOpenStatementsAcrossRollback() throws SQLException {
// NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.supportsOpenStatementsAcrossRollback());
}
/**
@@ -1485,6 +1542,7 @@
)
public void test_supportsOuterJoins() throws SQLException {
// NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.supportsOuterJoins());
}
/**
@@ -1498,6 +1556,7 @@
)
public void test_supportsPositionedDelete() throws SQLException {
// NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.supportsPositionedDelete());
}
/**
@@ -1511,6 +1570,7 @@
)
public void test_supportsPositionedUpdate() throws SQLException {
// NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.supportsPositionedUpdate());
}
/**
@@ -1524,6 +1584,7 @@
)
public void test_supportsResultSetConcurrencyII() throws SQLException {
// NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.supportsResultSetConcurrency(0,0));
}
/**
@@ -1537,6 +1598,7 @@
)
public void test_supportsResultSetHoldabilityI() throws SQLException {
// NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.supportsResultSetHoldability(0));
}
/**
@@ -1548,14 +1610,15 @@
method = "supportsResultSetType",
args = {int.class}
)
+ @KnownFailure("not supported")
public void test_supportsResultSetTypeI() throws SQLException {
// NOT_FEASIBLE not supported
-// assertFalse("database supports TYPE_FORWARD_ONLY type", meta
-// .supportsResultSetType(ResultSet.TYPE_FORWARD_ONLY));
-// assertTrue("database doesn't support TYPE_SCROLL_INSENSITIVE type",
-// meta.supportsResultSetType(ResultSet.TYPE_SCROLL_INSENSITIVE));
-// assertFalse("database supports TYPE_SCROLL_SENSITIVE type", meta
-// .supportsResultSetType(ResultSet.TYPE_SCROLL_SENSITIVE));
+ assertTrue("database supports TYPE_FORWARD_ONLY type", meta
+ .supportsResultSetType(ResultSet.TYPE_FORWARD_ONLY));
+ assertFalse("database doesn't support TYPE_SCROLL_INSENSITIVE type",
+ meta.supportsResultSetType(ResultSet.TYPE_SCROLL_INSENSITIVE));
+ assertFalse("database supports TYPE_SCROLL_SENSITIVE type", meta
+ .supportsResultSetType(ResultSet.TYPE_SCROLL_SENSITIVE));
assertFalse("database supports unknown type", meta
.supportsResultSetType(100));
}
@@ -1571,6 +1634,7 @@
)
public void test_supportsSavepoints() throws SQLException {
// NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.supportsSavepoints());
}
/**
@@ -1584,6 +1648,7 @@
)
public void test_supportsSchemasInDataManipulation() throws SQLException {
// NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.supportsSchemasInDataManipulation());
}
/**
@@ -1597,6 +1662,7 @@
)
public void test_supportsSchemasInIndexDefinitions() throws SQLException {
// NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.supportsSchemasInIndexDefinitions());
}
/**
@@ -1624,6 +1690,7 @@
)
public void test_supportsSchemasInProcedureCalls() throws SQLException {
// NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.supportsSchemasInProcedureCalls());
}
/**
@@ -1637,6 +1704,7 @@
)
public void test_supportsSchemasInTableDefinitions() throws SQLException {
// NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.supportsSchemasInTableDefinitions());
}
/**
@@ -1650,6 +1718,7 @@
)
public void test_supportsStatementPooling() throws SQLException {
// NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.supportsStatementPooling());
}
/**
@@ -1663,6 +1732,7 @@
)
public void test_supportsStoredProcedures() throws SQLException {
// NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.supportsStoredProcedures());
}
/**
@@ -1674,8 +1744,10 @@
method = "supportsSubqueriesInComparisons",
args = {}
)
+ @KnownFailure("not supported")
public void test_supportsSubqueriesInComparisons() throws SQLException {
// NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.supportsSubqueriesInComparisons());
}
/**
@@ -1687,8 +1759,9 @@
method = "supportsSubqueriesInIns",
args = {}
)
+ @KnownFailure("not supported")
public void test_supportsSubqueriesInIns() throws SQLException {
- // NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.supportsSubqueriesInIns());
}
/**
@@ -1702,6 +1775,7 @@
)
public void test_supportsSubqueriesInQuantifieds() throws SQLException {
// NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.supportsSubqueriesInQuantifieds());
}
/**
@@ -1713,8 +1787,9 @@
method = "supportsTransactions",
args = {}
)
+ @KnownFailure("not supported")
public void test_supportsTransactions() throws SQLException {
- // NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.supportsTransactions());
}
/**
@@ -1728,6 +1803,7 @@
)
public void test_supportsUnion() throws SQLException {
// NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.supportsUnion());
}
/**
@@ -1741,6 +1817,7 @@
)
public void test_supportsUnionAll() throws SQLException {
// NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.supportsUnionAll());
}
/**
@@ -1754,6 +1831,7 @@
)
public void test_usesLocalFilePerTable() throws SQLException {
// NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.usesLocalFilePerTable());
}
/**
@@ -1765,8 +1843,10 @@
method = "usesLocalFiles",
args = {}
)
+ @KnownFailure("not supported")
public void test_usesLocalFiles() throws SQLException {
// NOT_FEASIBLE: SQLITE does not implement this functionality
+ assertFalse(meta.usesLocalFiles());
}
/**
@@ -1999,6 +2079,7 @@
method = "getMaxTableNameLength",
args = {}
)
+ @KnownFailure("Exception test fails")
public void test_getMaxTableNameLength() throws SQLException {
assertTrue("Now supported", meta
.getMaxTableNameLength() == 0);
@@ -2023,6 +2104,7 @@
method = "getMaxTablesInSelect",
args = {}
)
+ @KnownFailure("Exception test fails")
public void test_getMaxTablesInSelect() throws SQLException {
assertTrue("Tables in select is now supported: change test implementation\"",
meta.getMaxTablesInSelect() == 0);
@@ -2047,6 +2129,7 @@
method = "getMaxUserNameLength",
args = {}
)
+ @KnownFailure("Exception test fails")
public void test_getMaxUserNameLength() throws SQLException {
assertTrue("Usernames are now supported: change test implementation",
meta.getMaxUserNameLength() == 0);
diff --git a/libcore/sql/src/test/java/tests/java/sql/DatabaseMetaDataTest.java b/libcore/sql/src/test/java/tests/java/sql/DatabaseMetaDataTest.java
index cf36629..c0f0dfe 100755
--- a/libcore/sql/src/test/java/tests/java/sql/DatabaseMetaDataTest.java
+++ b/libcore/sql/src/test/java/tests/java/sql/DatabaseMetaDataTest.java
@@ -63,36 +63,38 @@
private static int id = 1;
- public static Test suite() {
- TestSetup setup = new TestSetup(new TestSuite(
- DatabaseMetaDataTest.class)) {
- protected void setUp() {
- Support_SQL.loadDriver();
- try {
- conn = Support_SQL.getConnection();
- meta = conn.getMetaData();
- statement = conn.createStatement();
- createTestTables();
- } catch (SQLException e) {
- System.out.println("Error in test setup: "+e.getMessage());
- }
- }
+ public void setUp() throws Exception {
+ super.setUp();
+ Support_SQL.loadDriver();
+ try {
+ conn = Support_SQL.getConnection();
+ meta = conn.getMetaData();
+ statement = conn.createStatement();
+ statementForward = conn.createStatement(
+ ResultSet.TYPE_FORWARD_ONLY,
+ ResultSet.CONCUR_READ_ONLY);
+ createTestTables();
+ } catch (SQLException e) {
+ System.out.println("Error in test setup: "+e.getMessage());
+ }
+ }
- protected void tearDown() {
- try {
- conn = Support_SQL.getConnection();
- meta = conn.getMetaData();
- statement = conn.createStatement();
- deleteTestTables();
- } catch (SQLException e) {
- System.out.println("Error in teardown: "+e.getMessage());
- } finally {
- try {
- conn.close();
- } catch (SQLException e) {
- }
- }
+ protected void tearDown() throws Exception {
+ try {
+ conn = Support_SQL.getConnection();
+ meta = conn.getMetaData();
+ statement = conn.createStatement();
+ deleteTestTables();
+ } catch (SQLException e) {
+ System.out.println("Error in teardown: "+e.getMessage());
+ } finally {
+ try {
+ conn.close();
+ } catch (SQLException e) {
}
+ }
+ super.tearDown();
+ }
private void createTestTables() {
try {
@@ -135,10 +137,7 @@
}
}
}
- };
- return setup;
- }
-
+ /*
public void setUp() {
try {
super.setUp();
@@ -147,7 +146,7 @@
statement = conn.createStatement();
statementForward = conn.createStatement(
ResultSet.TYPE_FORWARD_ONLY,
- ResultSet.CONCUR_UPDATABLE);
+ ResultSet.CONCUR_READ_ONLY);
meta = conn.getMetaData();
assertFalse(conn.isClosed());
@@ -161,6 +160,7 @@
}
}
+ */
/**
* @tests {@link java.sql.DatabaseMetaData #getBestRowIdentifier(java.lang.String,
@@ -168,7 +168,7 @@
*/
@TestTargetNew(
level = TestLevel.SUFFICIENT,
- notes = "Not All variants of parameters can be tested: updates on resultSets are not supported.",
+ notes = "Not all variants of parameters can be tested: updates on resultSets are not supported.",
method = "getBestRowIdentifier",
args = {java.lang.String.class, java.lang.String.class, java.lang.String.class, int.class, boolean.class}
)
@@ -177,15 +177,20 @@
ResultSet result = statementForward.executeQuery("SELECT * FROM "
+ DatabaseCreator.TEST_TABLE1);
- // TODO not supported
- // try {
- // result.moveToInsertRow();
- // result.updateInt("id", 1234567);
- // result.updateString("field1", "test1");
- // result.insertRow();
- // } catch (SQLException e) {
- // fail("Unexpected SQLException " + e.toString());
- // }
+ //Updatable ResultSet not supported, converted to normal insert statement
+ statementForward.executeUpdate("INSERT INTO " + DatabaseCreator.TEST_TABLE1
+ + " (id, field1) VALUES( 1234567, 'test1');");
+ /* not supported
+ try {
+ result.moveToInsertRow();
+ result.updateInt("id", 1234567);
+ result.updateString("field1", "test1");
+ result.insertRow();
+ } catch (SQLException e) {
+ fail("Unexpected SQLException " + e.toString());
+ }
+ */
+
result.close();
diff --git a/libcore/sql/src/test/java/tests/java/sql/DeleteFunctionalityTest.java b/libcore/sql/src/test/java/tests/java/sql/DeleteFunctionalityTest.java
index 6209548..b43e312 100755
--- a/libcore/sql/src/test/java/tests/java/sql/DeleteFunctionalityTest.java
+++ b/libcore/sql/src/test/java/tests/java/sql/DeleteFunctionalityTest.java
@@ -42,84 +42,65 @@
private static Statement statement = null;
- protected void setUp() throws Exception {
+ public void setUp() throws Exception {
super.setUp();
+ Support_SQL.loadDriver();
+ conn = Support_SQL.getConnection();
+ statement = conn.createStatement();
+ createTestTables();
DatabaseCreator.fillParentTable(conn);
}
- protected void tearDown() throws Exception {
- statement.execute("DELETE FROM " + DatabaseCreator.FKSTRICT_TABLE);
- statement.execute("DELETE FROM " + DatabaseCreator.FKCASCADE_TABLE);
- statement.execute("DELETE FROM " + DatabaseCreator.PARENT_TABLE);
- statement.execute("DELETE FROM " + DatabaseCreator.TEST_TABLE5);
+ public void tearDown() throws Exception {
+ deleteTestTables();
+ statement.close();
+ conn.close();
super.tearDown();
}
- public static Test suite() {
- TestSetup setup = new TestSetup(new TestSuite(
- DeleteFunctionalityTest.class)) {
- protected void setUp() throws Exception {
- Support_SQL.loadDriver();
- try {
- conn = Support_SQL.getConnection();
- statement = conn.createStatement();
- createTestTables();
- } catch (SQLException e) {
- fail("Unexpected SQLException " + e.toString());
- }
- }
- protected void tearDown() throws Exception {
- deleteTestTables();
- statement.close();
- conn.close();
- }
+ public void createTestTables() {
+ try {
+ DatabaseMetaData meta = conn.getMetaData();
+ ResultSet userTab = meta.getTables(null, null, null, null);
- private void createTestTables() {
- try {
- DatabaseMetaData meta = conn.getMetaData();
- ResultSet userTab = meta.getTables(null, null, null, null);
-
- while (userTab.next()) {
- String tableName = userTab.getString("TABLE_NAME");
- if (tableName.equals(DatabaseCreator.PARENT_TABLE)) {
- statement
- .execute(DatabaseCreator.DROP_TABLE_PARENT);
- } else if (tableName
- .equals(DatabaseCreator.FKCASCADE_TABLE)) {
- statement
- .execute(DatabaseCreator.DROP_TABLE_FKCASCADE);
- } else if (tableName
- .equals(DatabaseCreator.FKSTRICT_TABLE)) {
- statement
- .execute(DatabaseCreator.DROP_TABLE_FKSTRICT);
- } else if (tableName
- .equals(DatabaseCreator.TEST_TABLE5)) {
- statement.execute(DatabaseCreator.DROP_TABLE5);
- }
- }
- userTab.close();
- statement.execute(DatabaseCreator.CREATE_TABLE_PARENT);
- statement.execute(DatabaseCreator.CREATE_TABLE_FKSTRICT);
- statement.execute(DatabaseCreator.CREATE_TABLE_FKCASCADE);
- statement.execute(DatabaseCreator.CREATE_TABLE5);
- } catch (SQLException e) {
- fail("Unexpected SQLException " + e.toString());
- }
- }
-
- private void deleteTestTables() {
- try {
- statement.execute(DatabaseCreator.DROP_TABLE_FKCASCADE);
- statement.execute(DatabaseCreator.DROP_TABLE_FKSTRICT);
- statement.execute(DatabaseCreator.DROP_TABLE_PARENT);
+ while (userTab.next()) {
+ String tableName = userTab.getString("TABLE_NAME");
+ if (tableName.equals(DatabaseCreator.PARENT_TABLE)) {
+ statement
+ .execute(DatabaseCreator.DROP_TABLE_PARENT);
+ } else if (tableName
+ .equals(DatabaseCreator.FKCASCADE_TABLE)) {
+ statement
+ .execute(DatabaseCreator.DROP_TABLE_FKCASCADE);
+ } else if (tableName
+ .equals(DatabaseCreator.FKSTRICT_TABLE)) {
+ statement
+ .execute(DatabaseCreator.DROP_TABLE_FKSTRICT);
+ } else if (tableName
+ .equals(DatabaseCreator.TEST_TABLE5)) {
statement.execute(DatabaseCreator.DROP_TABLE5);
- } catch (SQLException e) {
- fail("Unexpected SQLException " + e.toString());
}
}
- };
- return setup;
+ userTab.close();
+ statement.execute(DatabaseCreator.CREATE_TABLE_PARENT);
+ statement.execute(DatabaseCreator.CREATE_TABLE_FKSTRICT);
+ statement.execute(DatabaseCreator.CREATE_TABLE_FKCASCADE);
+ statement.execute(DatabaseCreator.CREATE_TABLE5);
+ } catch (SQLException e) {
+ fail("Unexpected SQLException " + e.toString());
+ }
+ }
+
+ public void deleteTestTables() {
+ try {
+ statement.execute(DatabaseCreator.DROP_TABLE_FKCASCADE);
+ statement.execute(DatabaseCreator.DROP_TABLE_FKSTRICT);
+ statement.execute(DatabaseCreator.DROP_TABLE_PARENT);
+ statement.execute(DatabaseCreator.DROP_TABLE5);
+ } catch (SQLException e) {
+ fail("Unexpected SQLException " + e.toString());
+ }
}
/**
diff --git a/libcore/sql/src/test/java/tests/java/sql/InsertFunctionalityTest.java b/libcore/sql/src/test/java/tests/java/sql/InsertFunctionalityTest.java
index 4d26751..5929c63 100755
--- a/libcore/sql/src/test/java/tests/java/sql/InsertFunctionalityTest.java
+++ b/libcore/sql/src/test/java/tests/java/sql/InsertFunctionalityTest.java
@@ -43,100 +43,76 @@
private static Statement statement = null;
- protected void setUp() throws Exception {
+ public void setUp() throws Exception {
super.setUp();
Support_SQL.loadDriver();
conn = Support_SQL.getConnection();
+ statement = conn.createStatement();
+ createTestTables();
}
- protected void tearDown() throws Exception {
- statement.execute("DELETE FROM " + DatabaseCreator.SIMPLE_TABLE2);
- statement.execute("DELETE FROM " + DatabaseCreator.SIMPLE_TABLE1);
- statement.execute("DELETE FROM " + DatabaseCreator.FKSTRICT_TABLE);
- statement.execute("DELETE FROM " + DatabaseCreator.FKCASCADE_TABLE);
- statement.execute("DELETE FROM " + DatabaseCreator.PARENT_TABLE);
- statement.execute("DELETE FROM " + DatabaseCreator.TEST_TABLE5);
+ public void tearDown() throws Exception {
+ deleteTestTables();
+ statement.close();
+ conn.close();
super.tearDown();
}
- public static Test suite() {
- TestSetup setup = new TestSetup(new TestSuite(
- InsertFunctionalityTest.class)) {
- protected void setUp() throws Exception {
- Support_SQL.loadDriver();
- try {
- conn = Support_SQL.getConnection();
- statement = conn.createStatement();
- createTestTables();
- } catch (SQLException e) {
- fail("Unexpected SQLException " + e.toString());
- }
- }
+ public void createTestTables() {
+ try {
+ DatabaseMetaData meta = conn.getMetaData();
+ ResultSet userTab = meta.getTables(null, null, null, null);
- protected void tearDown() throws Exception {
- deleteTestTables();
- statement.close();
- conn.close();
- }
-
- private void createTestTables() {
- try {
- DatabaseMetaData meta = conn.getMetaData();
- ResultSet userTab = meta.getTables(null, null, null, null);
-
- while (userTab.next()) {
- String tableName = userTab.getString("TABLE_NAME");
- if (tableName.equals(DatabaseCreator.PARENT_TABLE)) {
- statement
- .execute(DatabaseCreator.DROP_TABLE_PARENT);
- } else if (tableName
- .equals(DatabaseCreator.FKCASCADE_TABLE)) {
- statement
- .execute(DatabaseCreator.DROP_TABLE_FKCASCADE);
- } else if (tableName
- .equals(DatabaseCreator.FKSTRICT_TABLE)) {
- statement
- .execute(DatabaseCreator.DROP_TABLE_FKSTRICT);
- } else if (tableName
- .equals(DatabaseCreator.SIMPLE_TABLE1)) {
- statement
- .execute(DatabaseCreator.DROP_TABLE_SIMPLE1);
- } else if (tableName
- .equals(DatabaseCreator.SIMPLE_TABLE2)) {
- statement
- .execute(DatabaseCreator.DROP_TABLE_SIMPLE2);
- } else if (tableName
- .equals(DatabaseCreator.TEST_TABLE5)) {
- statement.execute(DatabaseCreator.DROP_TABLE5);
- }
- }
- userTab.close();
- statement.execute(DatabaseCreator.CREATE_TABLE_PARENT);
- statement.execute(DatabaseCreator.CREATE_TABLE_FKSTRICT);
- statement.execute(DatabaseCreator.CREATE_TABLE_FKCASCADE);
- statement.execute(DatabaseCreator.CREATE_TABLE_SIMPLE2);
- statement.execute(DatabaseCreator.CREATE_TABLE_SIMPLE1);
- statement.execute(DatabaseCreator.CREATE_TABLE5);
- } catch (SQLException e) {
- fail("Unexpected SQLException " + e.toString());
- }
- }
-
- private void deleteTestTables() {
- try {
- statement.execute(DatabaseCreator.DROP_TABLE_FKCASCADE);
- statement.execute(DatabaseCreator.DROP_TABLE_FKSTRICT);
- statement.execute(DatabaseCreator.DROP_TABLE_PARENT);
- statement.execute(DatabaseCreator.DROP_TABLE_SIMPLE2);
- statement.execute(DatabaseCreator.DROP_TABLE_SIMPLE1);
+ while (userTab.next()) {
+ String tableName = userTab.getString("TABLE_NAME");
+ if (tableName.equals(DatabaseCreator.PARENT_TABLE)) {
+ statement
+ .execute(DatabaseCreator.DROP_TABLE_PARENT);
+ } else if (tableName
+ .equals(DatabaseCreator.FKCASCADE_TABLE)) {
+ statement
+ .execute(DatabaseCreator.DROP_TABLE_FKCASCADE);
+ } else if (tableName
+ .equals(DatabaseCreator.FKSTRICT_TABLE)) {
+ statement
+ .execute(DatabaseCreator.DROP_TABLE_FKSTRICT);
+ } else if (tableName
+ .equals(DatabaseCreator.SIMPLE_TABLE1)) {
+ statement
+ .execute(DatabaseCreator.DROP_TABLE_SIMPLE1);
+ } else if (tableName
+ .equals(DatabaseCreator.SIMPLE_TABLE2)) {
+ statement
+ .execute(DatabaseCreator.DROP_TABLE_SIMPLE2);
+ } else if (tableName
+ .equals(DatabaseCreator.TEST_TABLE5)) {
statement.execute(DatabaseCreator.DROP_TABLE5);
- } catch (SQLException e) {
- fail("Unexpected SQLException " + e.toString());
}
}
- };
- return setup;
+ userTab.close();
+ statement.execute(DatabaseCreator.CREATE_TABLE_PARENT);
+ statement.execute(DatabaseCreator.CREATE_TABLE_FKSTRICT);
+ statement.execute(DatabaseCreator.CREATE_TABLE_FKCASCADE);
+ statement.execute(DatabaseCreator.CREATE_TABLE_SIMPLE2);
+ statement.execute(DatabaseCreator.CREATE_TABLE_SIMPLE1);
+ statement.execute(DatabaseCreator.CREATE_TABLE5);
+ } catch (SQLException e) {
+ fail("Unexpected SQLException " + e.toString());
+ }
+ }
+
+ public void deleteTestTables() {
+ try {
+ statement.execute(DatabaseCreator.DROP_TABLE_FKCASCADE);
+ statement.execute(DatabaseCreator.DROP_TABLE_FKSTRICT);
+ statement.execute(DatabaseCreator.DROP_TABLE_PARENT);
+ statement.execute(DatabaseCreator.DROP_TABLE_SIMPLE2);
+ statement.execute(DatabaseCreator.DROP_TABLE_SIMPLE1);
+ statement.execute(DatabaseCreator.DROP_TABLE5);
+ } catch (SQLException e) {
+ fail("Unexpected SQLException " + e.toString());
+ }
}
/**
@@ -149,7 +125,6 @@
method = "execute",
args = {java.lang.String.class}
)
- @KnownFailure(" SQLite.Exception: error in prepare/compile")
public void testInsert1() throws SQLException {
DatabaseCreator.fillParentTable(conn);
DatabaseCreator.fillFKStrictTable(conn);
@@ -171,7 +146,6 @@
method = "execute",
args = {java.lang.String.class}
)
- @KnownFailure(" SQLite.Exception: error in prepare/compile")
public void testInsert2() throws SQLException {
DatabaseCreator.fillParentTable(conn);
DatabaseCreator.fillFKStrictTable(conn);
@@ -212,7 +186,6 @@
args = {java.lang.String.class}
)
})
- @KnownFailure(" SQLite.Exception: error in prepare/compile")
public void testInsert3() throws SQLException {
DatabaseCreator.fillParentTable(conn);
DatabaseCreator.fillFKStrictTable(conn);
@@ -244,7 +217,6 @@
args = {java.lang.String.class}
)
})
- @KnownFailure(" SQLite.Exception: error in prepare/compile")
public void testInsert4() throws SQLException {
DatabaseCreator.fillSimpleTable1(conn);
statement.execute("INSERT INTO " + DatabaseCreator.SIMPLE_TABLE2
@@ -299,7 +271,6 @@
method = "executeQuery",
args = {java.lang.String.class}
)
- @KnownFailure(" SQLite.Exception: error in prepare")
public void testInsertPrepared() throws SQLException {
PreparedStatement stat = conn.prepareStatement("INSERT INTO "
+ DatabaseCreator.TEST_TABLE5 + " VALUES(?, ?)");
diff --git a/libcore/sql/src/test/java/tests/java/sql/MultiThreadAccessTest.java b/libcore/sql/src/test/java/tests/java/sql/MultiThreadAccessTest.java
index 9675fce..f306996 100755
--- a/libcore/sql/src/test/java/tests/java/sql/MultiThreadAccessTest.java
+++ b/libcore/sql/src/test/java/tests/java/sql/MultiThreadAccessTest.java
@@ -50,81 +50,71 @@
private ThreadPool threadPool;
- protected void setUp() throws Exception {
+ public void setUp() throws Exception {
+ super.setUp();
+ Support_SQL.loadDriver();
+ try {
+ conn = Support_SQL.getConnection();
+ statement = conn.createStatement();
+ createTestTables();
+ } catch (SQLException e) {
+ fail("Unexpected SQLException " + e.toString());
+ }
threadPool = new ThreadPool(numThreads);
}
- protected void tearDown() throws Exception {
- threadPool.join();
+ public void tearDown() throws Exception {
+ threadPool.join();
+ deleteTestTables();
+ conn.close();
+ statement.close();
+ super.tearDown();
}
- public static Test suite() {
- TestSetup setup = new TestSetup(new TestSuite(
- MultiThreadAccessTest.class)) {
- protected void setUp() throws Exception {
- Support_SQL.loadDriver();
- try {
- conn = Support_SQL.getConnection();
- statement = conn.createStatement();
- createTestTables();
- } catch (SQLException e) {
- fail("Unexpected SQLException " + e.toString());
- }
- }
+ public void createTestTables() {
+ try {
+ ResultSet userTab = conn.getMetaData().getTables(null,
+ null, null, null);
- protected void tearDown() throws Exception {
- deleteTestTables();
- conn.close();
- statement.close();
- }
-
- private void createTestTables() {
- try {
- ResultSet userTab = conn.getMetaData().getTables(null,
- null, null, null);
-
- while (userTab.next()) {
- String tableName = userTab.getString("TABLE_NAME");
- if (tableName.equals(DatabaseCreator.TEST_TABLE1)) {
- statement.execute(DatabaseCreator.DROP_TABLE1);
- } else if (tableName
- .equals(DatabaseCreator.TEST_TABLE2)) {
- statement.execute(DatabaseCreator.DROP_TABLE2);
- } else if (tableName
- .equals(DatabaseCreator.TEST_TABLE4)) {
- statement.execute(DatabaseCreator.DROP_TABLE4);
- } else if (tableName
- .equals(DatabaseCreator.TEST_TABLE3)) {
- statement.execute(DatabaseCreator.DROP_TABLE3);
- }
- }
-
- userTab.close();
- statement.execute(DatabaseCreator.CREATE_TABLE3);
- statement.execute(DatabaseCreator.CREATE_TABLE4);
- statement.execute(DatabaseCreator.CREATE_TABLE1);
- statement.execute(DatabaseCreator.CREATE_TABLE2);
-
- DatabaseCreator.fillTestTable1(conn, numOfRecords);
- DatabaseCreator.fillTestTable2(conn, numOfRecords);
- DatabaseCreator.fillTestTable4(conn, numOfRecords);
- } catch (SQLException e) {
- fail("Unexpected SQLException " + e.toString());
- }
- }
-
- private void deleteTestTables() {
- try {
+ while (userTab.next()) {
+ String tableName = userTab.getString("TABLE_NAME");
+ if (tableName.equals(DatabaseCreator.TEST_TABLE1)) {
statement.execute(DatabaseCreator.DROP_TABLE1);
+ } else if (tableName
+ .equals(DatabaseCreator.TEST_TABLE2)) {
statement.execute(DatabaseCreator.DROP_TABLE2);
- statement.execute(DatabaseCreator.DROP_TABLE3);
+ } else if (tableName
+ .equals(DatabaseCreator.TEST_TABLE4)) {
statement.execute(DatabaseCreator.DROP_TABLE4);
- } catch (SQLException e) {
- fail("Unexpected SQLException " + e.toString());
+ } else if (tableName
+ .equals(DatabaseCreator.TEST_TABLE3)) {
+ statement.execute(DatabaseCreator.DROP_TABLE3);
}
}
- };
- return setup;
+
+ userTab.close();
+ statement.execute(DatabaseCreator.CREATE_TABLE3);
+ statement.execute(DatabaseCreator.CREATE_TABLE4);
+ statement.execute(DatabaseCreator.CREATE_TABLE1);
+ statement.execute(DatabaseCreator.CREATE_TABLE2);
+
+ DatabaseCreator.fillTestTable1(conn, numOfRecords);
+ DatabaseCreator.fillTestTable2(conn, numOfRecords);
+ DatabaseCreator.fillTestTable4(conn, numOfRecords);
+ } catch (SQLException e) {
+ fail("Unexpected SQLException " + e.toString());
+ }
+ }
+
+ public void deleteTestTables() {
+ try {
+ statement.execute(DatabaseCreator.DROP_TABLE1);
+ statement.execute(DatabaseCreator.DROP_TABLE2);
+ statement.execute(DatabaseCreator.DROP_TABLE3);
+ statement.execute(DatabaseCreator.DROP_TABLE4);
+ } catch (SQLException e) {
+ fail("Unexpected SQLException " + e.toString());
+ }
}
/**
diff --git a/libcore/sql/src/test/java/tests/java/sql/SelectFunctionalityTest.java b/libcore/sql/src/test/java/tests/java/sql/SelectFunctionalityTest.java
index 5c8f189..29f6898 100755
--- a/libcore/sql/src/test/java/tests/java/sql/SelectFunctionalityTest.java
+++ b/libcore/sql/src/test/java/tests/java/sql/SelectFunctionalityTest.java
@@ -54,90 +54,78 @@
private static Time time;
- protected void setUp() throws Exception {
- super.setUp();
+ public void setUp() throws Exception {
+ super.setUp();
+ Support_SQL.loadDriver();
+ try {
+ conn = Support_SQL.getConnection();
+ statement = conn.createStatement();
+ createTestTables();
+ } catch (SQLException e) {
+ fail("Unexpected SQLException " + e.toString());
+ }
}
- protected void tearDown() throws Exception {
+ public void tearDown() throws Exception {
+ deleteTestTables();
+ conn.close();
+ statement.close();
super.tearDown();
}
- public static Test suite() {
- TestSetup setup = new TestSetup(new TestSuite(
- SelectFunctionalityTest.class)) {
- protected void setUp() throws Exception {
- Support_SQL.loadDriver();
- try {
- conn = Support_SQL.getConnection();
- statement = conn.createStatement();
- createTestTables();
- } catch (SQLException e) {
- fail("Unexpected SQLException " + e.toString());
- }
- }
+ private void createTestTables() {
+ try {
+ ResultSet userTab = conn.getMetaData().getTables(null,
+ null, null, null);
- protected void tearDown() throws Exception {
- deleteTestTables();
- conn.close();
- statement.close();
- }
-
- private void createTestTables() {
- try {
- ResultSet userTab = conn.getMetaData().getTables(null,
- null, null, null);
-
- while (userTab.next()) {
- String tableName = userTab.getString("TABLE_NAME");
- if (tableName.equals(DatabaseCreator.TEST_TABLE2)) {
- statement.execute(DatabaseCreator.DROP_TABLE2);
- } else if (tableName
- .equals(DatabaseCreator.SALESPEOPLE_TABLE)) {
- statement
- .execute(DatabaseCreator.DROP_TABLE_SALESPEOPLE);
- } else if (tableName
- .equals(DatabaseCreator.CUSTOMERS_TABLE)) {
- statement
- .execute(DatabaseCreator.DROP_TABLE_CUSTOMERS);
- } else if (tableName
- .equals(DatabaseCreator.ORDERS_TABLE)) {
- statement
- .execute(DatabaseCreator.DROP_TABLE_ORDERS);
- }
- }
- userTab.close();
-
- statement.execute(DatabaseCreator.CREATE_TABLE2);
- statement.execute(DatabaseCreator.CREATE_TABLE_SALESPEOPLE);
- statement.execute(DatabaseCreator.CREATE_TABLE_CUSTOMERS);
- statement.execute(DatabaseCreator.CREATE_TABLE_ORDERS);
-
- long currentTime = Calendar.getInstance().getTimeInMillis();
- date = new Date(currentTime);
- time = new Time(currentTime);
-
- DatabaseCreator.fillTestTable2(conn, 1, 5, currentTime);
- DatabaseCreator.fillCustomersTable(conn);
- DatabaseCreator.fillOrdersTable(conn);
- DatabaseCreator.fillSalesPeopleTable(conn);
-
- } catch (SQLException e) {
- fail("Unexpected SQLException " + e.toString());
- }
- }
-
- private void deleteTestTables() {
- try {
+ while (userTab.next()) {
+ String tableName = userTab.getString("TABLE_NAME");
+ if (tableName.equals(DatabaseCreator.TEST_TABLE2)) {
statement.execute(DatabaseCreator.DROP_TABLE2);
- statement.execute(DatabaseCreator.DROP_TABLE_SALESPEOPLE);
- statement.execute(DatabaseCreator.DROP_TABLE_CUSTOMERS);
- statement.execute(DatabaseCreator.DROP_TABLE_ORDERS);
- } catch (SQLException e) {
- fail("Unexpected SQLException " + e.toString());
+ } else if (tableName
+ .equals(DatabaseCreator.SALESPEOPLE_TABLE)) {
+ statement
+ .execute(DatabaseCreator.DROP_TABLE_SALESPEOPLE);
+ } else if (tableName
+ .equals(DatabaseCreator.CUSTOMERS_TABLE)) {
+ statement
+ .execute(DatabaseCreator.DROP_TABLE_CUSTOMERS);
+ } else if (tableName
+ .equals(DatabaseCreator.ORDERS_TABLE)) {
+ statement
+ .execute(DatabaseCreator.DROP_TABLE_ORDERS);
}
}
- };
- return setup;
+ userTab.close();
+
+ statement.execute(DatabaseCreator.CREATE_TABLE2);
+ statement.execute(DatabaseCreator.CREATE_TABLE_SALESPEOPLE);
+ statement.execute(DatabaseCreator.CREATE_TABLE_CUSTOMERS);
+ statement.execute(DatabaseCreator.CREATE_TABLE_ORDERS);
+
+ long currentTime = Calendar.getInstance().getTimeInMillis();
+ date = new Date(currentTime);
+ time = new Time(currentTime);
+
+ DatabaseCreator.fillTestTable2(conn, 1, 5, currentTime);
+ DatabaseCreator.fillCustomersTable(conn);
+ DatabaseCreator.fillOrdersTable(conn);
+ DatabaseCreator.fillSalesPeopleTable(conn);
+
+ } catch (SQLException e) {
+ fail("Unexpected SQLException " + e.toString());
+ }
+ }
+
+ private void deleteTestTables() {
+ try {
+ statement.execute(DatabaseCreator.DROP_TABLE2);
+ statement.execute(DatabaseCreator.DROP_TABLE_SALESPEOPLE);
+ statement.execute(DatabaseCreator.DROP_TABLE_CUSTOMERS);
+ statement.execute(DatabaseCreator.DROP_TABLE_ORDERS);
+ } catch (SQLException e) {
+ fail("Unexpected SQLException " + e.toString());
+ }
}
/**
diff --git a/libcore/sql/src/test/java/tests/java/sql/StressTest.java b/libcore/sql/src/test/java/tests/java/sql/StressTest.java
index 2f1b26b..d005a79 100755
--- a/libcore/sql/src/test/java/tests/java/sql/StressTest.java
+++ b/libcore/sql/src/test/java/tests/java/sql/StressTest.java
@@ -16,7 +16,6 @@
package tests.java.sql;
-import dalvik.annotation.BrokenTest;
import dalvik.annotation.TestTargetClass;
import dalvik.annotation.TestTargets;
import dalvik.annotation.TestLevel;
@@ -25,7 +24,6 @@
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.Driver;
-import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -38,10 +36,7 @@
import tests.support.DatabaseCreator;
import tests.support.Support_SQL;
import tests.support.ThreadPool;
-import junit.extensions.TestSetup;
-import junit.framework.Test;
import junit.framework.TestCase;
-import junit.framework.TestSuite;
@TestTargetClass(Statement.class)
public class StressTest extends TestCase {
@@ -50,72 +45,69 @@
private static Connection conn;
private static Statement statement;
-
- public static Test suite() {
- TestSetup setup = new TestSetup(new TestSuite(StressTest.class)) {
-
- protected void setUp() throws Exception {
- Support_SQL.loadDriver();
- conn = Support_SQL.getConnection();
- statement = conn.createStatement();
- createTestTables();
- }
-
- protected void tearDown() throws Exception {
- dropTestTables();
- statement.close();
- conn.close();
- }
-
- private void createTestTables() {
- try {
- DatabaseMetaData meta = conn.getMetaData();
- ResultSet userTab = meta.getTables(null, null, null, null);
-
- while (userTab.next()) {
- String tableName = userTab.getString("TABLE_NAME");
- if (tableName.equals(DatabaseCreator.TEST_TABLE2)) {
- statement.execute(DatabaseCreator.DROP_TABLE2);
- }
- }
- statement.execute(DatabaseCreator.CREATE_TABLE2);
- } catch (SQLException sql) {
- fail("Unexpected SQLException " + sql.toString());
- }
- return;
- }
-
- private void dropTestTables() {
- try {
- statement.execute(DatabaseCreator.DROP_TABLE2);
- } catch (SQLException sql) {
- fail("Unexpected SQLException " + sql.toString());
- }
- return;
- }
- };
- return setup;
- }
-
- /**
- * @see junit.framework.TestCase#setUp()
- */
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+
+ public void setUp() throws Exception {
+ super.setUp();
+ Support_SQL.loadDriver();
+ conn = Support_SQL.getConnection();
+ statement = conn.createStatement();
+ createTestTables();
vc.clear();
}
- /**
- * @see junit.framework.TestCase#tearDown()
- */
- @Override
protected void tearDown() throws Exception {
closeConnections();
- statement.execute("DELETE FROM " + DatabaseCreator.TEST_TABLE2);
+ statement.close();
+ conn.close();
super.tearDown();
}
+ private void createTestTables() {
+ try {
+ DatabaseMetaData meta = conn.getMetaData();
+ ResultSet userTab = meta.getTables(null, null, null, null);
+
+ while (userTab.next()) {
+ String tableName = userTab.getString("TABLE_NAME");
+ if (tableName.equals(DatabaseCreator.TEST_TABLE2)) {
+ statement.execute(DatabaseCreator.DROP_TABLE2);
+ }
+ }
+ statement.execute(DatabaseCreator.CREATE_TABLE2);
+ } catch (SQLException sql) {
+ fail("Unexpected SQLException " + sql.toString());
+ }
+ return;
+ }
+
+ private void dropTestTables() {
+ try {
+ statement.execute(DatabaseCreator.DROP_TABLE2);
+ } catch (SQLException sql) {
+ fail("Unexpected SQLException " + sql.toString());
+ }
+ return;
+ }
+
+// /**
+// * @see junit.framework.TestCase#setUp()
+// */
+// @Override
+// protected void setUp() throws Exception {
+// super.setUp();
+// vc.clear();
+// }
+//
+// /**
+// * @see junit.framework.TestCase#tearDown()
+// */
+// @Override
+// protected void tearDown() throws Exception {
+// closeConnections();
+// statement.execute("DELETE FROM " + DatabaseCreator.TEST_TABLE2);
+// super.tearDown();
+// }
+
/**
* @tests StressTest#testManyConnectionsUsingOneThread(). Create many
* connections to the DataBase using one thread.
@@ -228,9 +220,6 @@
clazz = Driver.class,
args = {String.class, Properties.class}
)
- @BrokenTest("Error in ThreadPool implementation threads do not get"
- +" more tasks (only one): there seems to be a deadlock or something."
- )
public void testInsertOfManyRowsUsingManyThreads() {
Logger.global.info("java.sql stress test: multiple threads and many operations.");
diff --git a/libcore/sql/src/test/java/tests/java/sql/UpdateFunctionalityTest.java b/libcore/sql/src/test/java/tests/java/sql/UpdateFunctionalityTest.java
index 2a94f08..1824590 100755
--- a/libcore/sql/src/test/java/tests/java/sql/UpdateFunctionalityTest.java
+++ b/libcore/sql/src/test/java/tests/java/sql/UpdateFunctionalityTest.java
@@ -45,80 +45,64 @@
private static Statement statement;
- protected void setUp() throws Exception {
+ public void setUp() throws Exception {
super.setUp();
+ Support_SQL.loadDriver();
+ try {
+ conn = Support_SQL.getConnection();
+ statement = conn.createStatement();
+ createTestTables();
+ } catch (SQLException e) {
+ fail("Unexpected SQLException " + e.toString());
+ }
DatabaseCreator.fillTestTable1(conn, numberOfRecords);
DatabaseCreator.fillTestTable2(conn, numberOfRecords);
}
- protected void tearDown() throws Exception {
- String deleteQuery1 = "DELETE FROM " + DatabaseCreator.TEST_TABLE1;
- String deleteQuery2 = "DELETE FROM " + DatabaseCreator.TEST_TABLE2;
-
- statement.execute(deleteQuery1);
- statement.execute(deleteQuery2);
+ public void tearDown() throws Exception {
+ deleteTestTables();
+ statement.close();
+ conn.close();
+
super.tearDown();
}
- public static Test suite() {
- TestSetup setup = new TestSetup(new TestSuite(
- UpdateFunctionalityTest.class)) {
- protected void setUp() throws Exception {
- Support_SQL.loadDriver();
- try {
- conn = Support_SQL.getConnection();
- statement = conn.createStatement();
- createTestTables();
- } catch (SQLException e) {
- fail("Unexpected SQLException " + e.toString());
- }
- }
+ protected void createTestTables() {
+ try {
+ DatabaseMetaData meta = conn.getMetaData();
+ ResultSet userTab = meta.getTables(null, null, null, null);
- protected void tearDown() throws Exception {
- deleteTestTables();
- statement.close();
- conn.close();
- }
-
- private void createTestTables() {
- try {
- DatabaseMetaData meta = conn.getMetaData();
- ResultSet userTab = meta.getTables(null, null, null, null);
-
- while (userTab.next()) {
- String tableName = userTab.getString("TABLE_NAME");
- if (tableName.equals(DatabaseCreator.TEST_TABLE1)) {
- statement.execute(DatabaseCreator.DROP_TABLE1);
- } else if (tableName
- .equals(DatabaseCreator.TEST_TABLE2)) {
- statement.execute(DatabaseCreator.DROP_TABLE2);
- } else if (tableName
- .equals(DatabaseCreator.TEST_TABLE3)) {
- statement.execute(DatabaseCreator.DROP_TABLE3);
- }
- }
- userTab.close();
-
- statement.execute(DatabaseCreator.CREATE_TABLE3);
- statement.execute(DatabaseCreator.CREATE_TABLE2);
- statement.execute(DatabaseCreator.CREATE_TABLE1);
-
- } catch (SQLException e) {
- fail("Unexpected SQLException " + e.toString());
- }
- }
-
- private void deleteTestTables() {
- try {
+ while (userTab.next()) {
+ String tableName = userTab.getString("TABLE_NAME");
+ if (tableName.equals(DatabaseCreator.TEST_TABLE1)) {
statement.execute(DatabaseCreator.DROP_TABLE1);
+ } else if (tableName
+ .equals(DatabaseCreator.TEST_TABLE2)) {
statement.execute(DatabaseCreator.DROP_TABLE2);
+ } else if (tableName
+ .equals(DatabaseCreator.TEST_TABLE3)) {
statement.execute(DatabaseCreator.DROP_TABLE3);
- } catch (SQLException e) {
- fail("Unexpected SQLException " + e.toString());
}
}
- };
- return setup;
+ userTab.close();
+
+ statement.execute(DatabaseCreator.CREATE_TABLE3);
+ statement.execute(DatabaseCreator.CREATE_TABLE2);
+ statement.execute(DatabaseCreator.CREATE_TABLE1);
+
+ } catch (SQLException e) {
+ fail("Unexpected SQLException " + e.toString());
+ }
+ }
+
+ protected void deleteTestTables() {
+ try {
+ statement.execute(DatabaseCreator.DROP_TABLE1);
+ statement.execute(DatabaseCreator.DROP_TABLE2);
+ statement.execute(DatabaseCreator.DROP_TABLE3);
+ } catch (SQLException e) {
+ fail("Unexpected SQLException " + e.toString());
+ }
}
/**
diff --git a/libcore/sql/src/test/java/tests/java/sql/UpdateFunctionalityTest2.java b/libcore/sql/src/test/java/tests/java/sql/UpdateFunctionalityTest2.java
index f14bbfa..6b1f13b 100755
--- a/libcore/sql/src/test/java/tests/java/sql/UpdateFunctionalityTest2.java
+++ b/libcore/sql/src/test/java/tests/java/sql/UpdateFunctionalityTest2.java
@@ -43,101 +43,83 @@
private static Connection conn = null;
private static Statement statement = null;
-
- protected void setUp() throws Exception {
- super.setUp();
+
+ public void setUp() throws Exception {
+ super.setUp();
+ Support_SQL.loadDriver();
+ try {
+ conn = Support_SQL.getConnection();
+ statement = conn.createStatement();
+ createTestTables();
+ } catch (SQLException e) {
+ fail("Unexpected SQLException " + e.toString());
+ }
DatabaseCreator.fillParentTable(conn);
DatabaseCreator.fillSimpleTable3(conn);
DatabaseCreator.fillSimpleTable1(conn);
}
- protected void tearDown() throws Exception {
- statement.execute("DELETE FROM " + DatabaseCreator.SIMPLE_TABLE3);
- statement.execute("DELETE FROM " + DatabaseCreator.SIMPLE_TABLE1);
- statement.execute("DELETE FROM " + DatabaseCreator.FKSTRICT_TABLE);
- statement.execute("DELETE FROM " + DatabaseCreator.FKCASCADE_TABLE);
- statement.execute("DELETE FROM " + DatabaseCreator.PARENT_TABLE);
- statement.execute("DELETE FROM " + DatabaseCreator.TEST_TABLE5);
+ public void tearDown() throws Exception {
+ deleteTestTables();
+ statement.close();
+ conn.close();
super.tearDown();
}
- public static Test suite() {
- TestSetup setup = new TestSetup(new TestSuite(
- UpdateFunctionalityTest2.class)) {
- protected void setUp() throws Exception {
- Support_SQL.loadDriver();
- try {
- conn = Support_SQL.getConnection();
- statement = conn.createStatement();
- createTestTables();
- } catch (SQLException e) {
- fail("Unexpected SQLException " + e.toString());
- }
- }
+ private void createTestTables() {
+ try {
+ DatabaseMetaData meta = conn.getMetaData();
+ ResultSet userTab = meta.getTables(null, null, null, null);
- protected void tearDown() throws Exception {
- deleteTestTables();
- statement.close();
- conn.close();
- }
-
- private void createTestTables() {
- try {
- DatabaseMetaData meta = conn.getMetaData();
- ResultSet userTab = meta.getTables(null, null, null, null);
-
- while (userTab.next()) {
- String tableName = userTab.getString("TABLE_NAME");
- if (tableName.equals(DatabaseCreator.PARENT_TABLE)) {
- statement
- .execute(DatabaseCreator.DROP_TABLE_PARENT);
- } else if (tableName
- .equals(DatabaseCreator.FKCASCADE_TABLE)) {
- statement
- .execute(DatabaseCreator.DROP_TABLE_FKCASCADE);
- } else if (tableName
- .equals(DatabaseCreator.FKSTRICT_TABLE)) {
- statement
- .execute(DatabaseCreator.DROP_TABLE_FKSTRICT);
- } else if (tableName
- .equals(DatabaseCreator.SIMPLE_TABLE1)) {
- statement
- .execute(DatabaseCreator.DROP_TABLE_SIMPLE1);
- } else if (tableName
- .equals(DatabaseCreator.SIMPLE_TABLE3)) {
- statement
- .execute(DatabaseCreator.DROP_TABLE_SIMPLE3);
- } else if (tableName
- .equals(DatabaseCreator.TEST_TABLE5)) {
- statement.execute(DatabaseCreator.DROP_TABLE5);
- }
- }
- userTab.close();
- statement.execute(DatabaseCreator.CREATE_TABLE_PARENT);
- statement.execute(DatabaseCreator.CREATE_TABLE_FKSTRICT);
- statement.execute(DatabaseCreator.CREATE_TABLE_FKCASCADE);
- statement.execute(DatabaseCreator.CREATE_TABLE_SIMPLE3);
- statement.execute(DatabaseCreator.CREATE_TABLE_SIMPLE1);
- statement.execute(DatabaseCreator.CREATE_TABLE5);
- } catch (SQLException e) {
- fail("Unexpected SQLException " + e.toString());
- }
- }
-
- private void deleteTestTables() {
- try {
- statement.execute(DatabaseCreator.DROP_TABLE_FKCASCADE);
- statement.execute(DatabaseCreator.DROP_TABLE_FKSTRICT);
- statement.execute(DatabaseCreator.DROP_TABLE_PARENT);
- statement.execute(DatabaseCreator.DROP_TABLE_SIMPLE3);
- statement.execute(DatabaseCreator.DROP_TABLE_SIMPLE1);
+ while (userTab.next()) {
+ String tableName = userTab.getString("TABLE_NAME");
+ if (tableName.equals(DatabaseCreator.PARENT_TABLE)) {
+ statement
+ .execute(DatabaseCreator.DROP_TABLE_PARENT);
+ } else if (tableName
+ .equals(DatabaseCreator.FKCASCADE_TABLE)) {
+ statement
+ .execute(DatabaseCreator.DROP_TABLE_FKCASCADE);
+ } else if (tableName
+ .equals(DatabaseCreator.FKSTRICT_TABLE)) {
+ statement
+ .execute(DatabaseCreator.DROP_TABLE_FKSTRICT);
+ } else if (tableName
+ .equals(DatabaseCreator.SIMPLE_TABLE1)) {
+ statement
+ .execute(DatabaseCreator.DROP_TABLE_SIMPLE1);
+ } else if (tableName
+ .equals(DatabaseCreator.SIMPLE_TABLE3)) {
+ statement
+ .execute(DatabaseCreator.DROP_TABLE_SIMPLE3);
+ } else if (tableName
+ .equals(DatabaseCreator.TEST_TABLE5)) {
statement.execute(DatabaseCreator.DROP_TABLE5);
- } catch (SQLException e) {
- fail("Unexpected SQLException " + e.toString());
}
}
- };
- return setup;
+ userTab.close();
+ statement.execute(DatabaseCreator.CREATE_TABLE_PARENT);
+ statement.execute(DatabaseCreator.CREATE_TABLE_FKSTRICT);
+ statement.execute(DatabaseCreator.CREATE_TABLE_FKCASCADE);
+ statement.execute(DatabaseCreator.CREATE_TABLE_SIMPLE3);
+ statement.execute(DatabaseCreator.CREATE_TABLE_SIMPLE1);
+ statement.execute(DatabaseCreator.CREATE_TABLE5);
+ } catch (SQLException e) {
+ fail("Unexpected SQLException " + e.toString());
+ }
+ }
+
+ private void deleteTestTables() {
+ try {
+ statement.execute(DatabaseCreator.DROP_TABLE_FKCASCADE);
+ statement.execute(DatabaseCreator.DROP_TABLE_FKSTRICT);
+ statement.execute(DatabaseCreator.DROP_TABLE_PARENT);
+ statement.execute(DatabaseCreator.DROP_TABLE_SIMPLE3);
+ statement.execute(DatabaseCreator.DROP_TABLE_SIMPLE1);
+ statement.execute(DatabaseCreator.DROP_TABLE5);
+ } catch (SQLException e) {
+ fail("Unexpected SQLException " + e.toString());
+ }
}
/**
diff --git a/libcore/sql/src/test/java/tests/sql/AllTests.java b/libcore/sql/src/test/java/tests/sql/AllTests.java
index 4f4b7a9..4d59cd4 100644
--- a/libcore/sql/src/test/java/tests/sql/AllTests.java
+++ b/libcore/sql/src/test/java/tests/sql/AllTests.java
@@ -35,7 +35,7 @@
suite.addTest(org.apache.harmony.sql.tests.javax.sql.AllTests.suite());
suite.addTest(tests.java.sql.AllTests.suite());
- // These don't do blackbox testing *and* crash JUnit on the JDK
+ // These don't do blackbox testing *and* crash JUnit on the RI
// suite.addTest(tests.SQLite.AllTests.suite());
suite.addTestSuite(tests.sql.ConnectionTest.class);