diff options
Diffstat (limited to 'sql/src')
-rw-r--r-- | sql/src/test/java/tests/SQLite/AllTests.java | 1 | ||||
-rw-r--r-- | sql/src/test/java/tests/SQLite/ConstantsTest.java | 110 | ||||
-rw-r--r-- | sql/src/test/java/tests/SQLite/DatabaseTest.java | 5 | ||||
-rw-r--r-- | sql/src/test/java/tests/SQLite/StmtTest.java | 17 | ||||
-rw-r--r-- | sql/src/test/java/tests/java/sql/DatabaseMetaDataNotSupportedTest.java | 51 | ||||
-rwxr-xr-x | sql/src/test/java/tests/sql/PreparedStatementTest.java | 13 | ||||
-rw-r--r-- | sql/src/test/java/tests/sql/ResultSetGetterTests.java | 13 | ||||
-rw-r--r-- | sql/src/test/java/tests/sql/ResultSetTest.java | 49 | ||||
-rwxr-xr-x | sql/src/test/java/tests/sql/StatementTest.java | 66 |
9 files changed, 27 insertions, 298 deletions
diff --git a/sql/src/test/java/tests/SQLite/AllTests.java b/sql/src/test/java/tests/SQLite/AllTests.java index e2aa55c..ea8b841 100644 --- a/sql/src/test/java/tests/SQLite/AllTests.java +++ b/sql/src/test/java/tests/SQLite/AllTests.java @@ -28,7 +28,6 @@ public class AllTests { suite.addTestSuite(DatabaseTest.class); suite.addTestSuite(JDBCDriverFunctionalTest.class); suite.addTestSuite(JDBCDriverTest.class); - suite.addTestSuite(ConstantsTest.class); suite.addTestSuite(BlobTest.class); suite.addTestSuite(StmtTest.class); suite.addTestSuite(ExceptionTest.class); diff --git a/sql/src/test/java/tests/SQLite/ConstantsTest.java b/sql/src/test/java/tests/SQLite/ConstantsTest.java deleted file mode 100644 index 2a4961f..0000000 --- a/sql/src/test/java/tests/SQLite/ConstantsTest.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package tests.SQLite; - -import SQLite.Constants; -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; -import dalvik.annotation.TestTargetClass; - -import junit.framework.TestCase; - -@TestTargetClass(Constants.class) -public class ConstantsTest extends TestCase { - - /** - * @tests Constants#Constants() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "constructor test", - method = "Constants", - args = {} - ) - public void testConstants() { - Constants c = new Constants(); - - assertNotNull(c); - assertEquals(c.SQLITE_OK, 0); - assertEquals(c.SQLITE_ERROR, 1); - assertEquals(c.SQLITE_INTERNAL, 2); - assertEquals(c.SQLITE_PERM, 3); - assertEquals(c.SQLITE_ABORT, 4); - assertEquals(c.SQLITE_BUSY, 5); - assertEquals(c.SQLITE_LOCKED, 6); - assertEquals(c.SQLITE_NOMEM, 7); - assertEquals(c.SQLITE_READONLY, 8); - assertEquals(c.SQLITE_INTERRUPT, 9); - assertEquals(c.SQLITE_IOERR, 10); - assertEquals(c.SQLITE_CORRUPT, 11); - assertEquals(c.SQLITE_NOTFOUND, 12); - assertEquals(c.SQLITE_FULL, 13); - assertEquals(c.SQLITE_CANTOPEN, 14); - assertEquals(c.SQLITE_PROTOCOL, 15); - assertEquals(c.SQLITE_EMPTY, 16); - assertEquals(c.SQLITE_SCHEMA, 17); - assertEquals(c.SQLITE_TOOBIG, 18); - assertEquals(c.SQLITE_CONSTRAINT, 19); - assertEquals(c.SQLITE_MISMATCH, 20); - assertEquals(c.SQLITE_MISUSE, 21); - assertEquals(c.SQLITE_NOLFS, 22); - assertEquals(c.SQLITE_AUTH, 23); - assertEquals(c.SQLITE_FORMAT, 24); - assertEquals(c.SQLITE_RANGE, 25); - assertEquals(c.SQLITE_NOTADB, 26); - assertEquals(c.SQLITE_ROW, 100); - assertEquals(c.SQLITE_DONE, 101); - assertEquals(c.SQLITE_INTEGER, 1); - assertEquals(c.SQLITE_FLOAT, 2); - assertEquals(c.SQLITE_BLOB, 4); - assertEquals(c.SQLITE_NULL, 5); - assertEquals(c.SQLITE3_TEXT, 3); - assertEquals(c.SQLITE_NUMERIC, -1); - assertEquals(c.SQLITE_TEXT, 3); - assertEquals(c.SQLITE2_TEXT, -2); - assertEquals(c.SQLITE_ARGS, -3); - assertEquals(c.SQLITE_COPY, 0); - assertEquals(c.SQLITE_CREATE_INDEX, 1); - assertEquals(c.SQLITE_CREATE_TABLE, 2); - assertEquals(c.SQLITE_CREATE_TEMP_INDEX, 3); - assertEquals(c.SQLITE_CREATE_TEMP_TABLE, 4); - assertEquals(c.SQLITE_CREATE_TEMP_TRIGGER, 5); - assertEquals(c.SQLITE_CREATE_TEMP_VIEW, 6); - assertEquals(c.SQLITE_CREATE_TRIGGER, 7); - assertEquals(c.SQLITE_CREATE_VIEW, 8); - assertEquals(c.SQLITE_DELETE, 9); - assertEquals(c.SQLITE_DROP_INDEX, 10); - assertEquals(c.SQLITE_DROP_TABLE, 11); - assertEquals(c.SQLITE_DROP_TEMP_INDEX, 12); - assertEquals(c.SQLITE_DROP_TEMP_TABLE, 13); - assertEquals(c.SQLITE_DROP_TEMP_TRIGGER, 14); - assertEquals(c.SQLITE_DROP_TEMP_VIEW, 15); - assertEquals(c.SQLITE_DROP_TRIGGER, 16); - assertEquals(c.SQLITE_DROP_VIEW, 17); - assertEquals(c.SQLITE_INSERT, 18); - assertEquals(c.SQLITE_PRAGMA, 19); - assertEquals(c.SQLITE_READ, 20); - assertEquals(c.SQLITE_SELECT, 21); - assertEquals(c.SQLITE_TRANSACTION, 22); - assertEquals(c.SQLITE_UPDATE, 23); - assertEquals(c.SQLITE_ATTACH, 24); - assertEquals(c.SQLITE_DETACH, 25); - assertEquals(c.SQLITE_DENY, 1); - assertEquals(c.SQLITE_IGNORE, 2); - } -} diff --git a/sql/src/test/java/tests/SQLite/DatabaseTest.java b/sql/src/test/java/tests/SQLite/DatabaseTest.java index 95ce7c8..12a556d 100644 --- a/sql/src/test/java/tests/SQLite/DatabaseTest.java +++ b/sql/src/test/java/tests/SQLite/DatabaseTest.java @@ -1069,7 +1069,7 @@ public class DatabaseTest extends SQLiteTest { db.exec("insert into TEST values(4, 'Fiona', 'Apple'); ", null); db.trace((Trace) t); db.create_aggregate("myaggfunc", 1, aggFunction); - db.function_type("myaggfunc", Constants.SQLITE_TEXT); + db.function_type("myaggfunc", Constants.SQLITE3_TEXT); db.exec("PRAGMA show_datatypes = on", null); assertFalse(aggFunction.functionCalled); @@ -1125,7 +1125,7 @@ public class DatabaseTest extends SQLiteTest { null); db.create_function("sin", 1, sinFunc); - db.function_type("sin", Constants.SQLITE_NUMERIC); + db.function_type("sin", Constants.SQLITE_FLOAT); res = db.get_table("select sin(res) from TEST WHERE res = " + Double.toString(input)); @@ -2036,4 +2036,3 @@ public class DatabaseTest extends SQLiteTest { } } - diff --git a/sql/src/test/java/tests/SQLite/StmtTest.java b/sql/src/test/java/tests/SQLite/StmtTest.java index cb71243..7a37154 100644 --- a/sql/src/test/java/tests/SQLite/StmtTest.java +++ b/sql/src/test/java/tests/SQLite/StmtTest.java @@ -982,17 +982,6 @@ public class StmtTest extends SQLiteTest { } } - /** - * @throws Exception - * @tests {@link Stmt#column_type(int)} - */ - @TestTargetNew( - level = TestLevel.SUFFICIENT, - notes = "method test", - method = "column_type", - args = {int.class} - ) - @KnownFailure("For numeric, float and blob wrong type is returned") public void testColumn_type() throws Exception { db.exec(createAllTypes, null); db.exec(insertAllTypes, null); @@ -1033,10 +1022,8 @@ public class StmtTest extends SQLiteTest { assertEquals(Constants.SQLITE_NULL, st.column_type(29)); // Failing tests - assertTrue("NUMERIC".equalsIgnoreCase(st.column_decltype(12))); - assertEquals(Constants.SQLITE_NUMERIC, st.column_type(12)); // NUMERIC - // -> got - // INTEGER + assertTrue("INTEGER".equalsIgnoreCase(st.column_decltype(12))); + assertEquals(Constants.SQLITE_INTEGER, st.column_type(12)); assertTrue("FLOAT".equalsIgnoreCase(st.column_decltype(11))); assertEquals(Constants.SQLITE_FLOAT, st.column_type(11)); // FLOAT -> diff --git a/sql/src/test/java/tests/java/sql/DatabaseMetaDataNotSupportedTest.java b/sql/src/test/java/tests/java/sql/DatabaseMetaDataNotSupportedTest.java index b09b779..c03bd6f 100644 --- a/sql/src/test/java/tests/java/sql/DatabaseMetaDataNotSupportedTest.java +++ b/sql/src/test/java/tests/java/sql/DatabaseMetaDataNotSupportedTest.java @@ -941,23 +941,14 @@ public class DatabaseMetaDataNotSupportedTest extends TestCase { meta.ownInsertsAreVisible(100)); } - /** - * @tests {@link java.sql.DatabaseMetaData#ownUpdatesAreVisible(int)} - */ - @TestTargetNew( - level = TestLevel.NOT_FEASIBLE, - notes = "not supported. Verification with invalid parameters missed.", - method = "ownUpdatesAreVisible", - args = {int.class} - ) public void test_ownUpdatesAreVisibleI() throws SQLException { - assertFalse( + assertTrue( "result set's own updates are visible for TYPE_FORWARD_ONLY type", meta.ownUpdatesAreVisible(ResultSet.TYPE_FORWARD_ONLY)); - assertFalse( + assertTrue( "result set's own updates are visible for TYPE_SCROLL_INSENSITIVE type", meta.ownUpdatesAreVisible(ResultSet.TYPE_SCROLL_INSENSITIVE)); - assertFalse( + assertTrue( "result set's own updates are visible for TYPE_SCROLL_SENSITIVE type", meta.ownUpdatesAreVisible(ResultSet.TYPE_SCROLL_SENSITIVE)); assertFalse("result set's own updates are visible for unknown type", @@ -1090,18 +1081,8 @@ public class DatabaseMetaDataNotSupportedTest extends TestCase { } - /** - * @tests java.sql.DatabaseMetaData#supportsBatchUpdates() - */ - @TestTargetNew( - level = TestLevel.NOT_FEASIBLE, - notes = "not supported", - method = "supportsBatchUpdates", - args = {} - ) public void test_supportsBatchUpdates() throws SQLException { - // NOT_FEASIBLE: SQLITE does not implement this functionality - assertFalse(meta.supportsBatchUpdates()); + assertTrue(meta.supportsBatchUpdates()); } /** @@ -1792,32 +1773,12 @@ public class DatabaseMetaDataNotSupportedTest extends TestCase { assertFalse(meta.supportsTransactions()); } - /** - * @tests java.sql.DatabaseMetaData#supportsUnion() - */ - @TestTargetNew( - level = TestLevel.NOT_FEASIBLE, - notes = "not supported", - method = "supportsUnion", - args = {} - ) public void test_supportsUnion() throws SQLException { - // NOT_FEASIBLE: SQLITE does not implement this functionality - assertFalse(meta.supportsUnion()); + assertTrue(meta.supportsUnion()); } - /** - * @tests java.sql.DatabaseMetaData#supportsUnionAll() - */ - @TestTargetNew( - level = TestLevel.NOT_FEASIBLE, - notes = "not supported", - method = "supportsUnionAll", - args = {} - ) public void test_supportsUnionAll() throws SQLException { - // NOT_FEASIBLE: SQLITE does not implement this functionality - assertFalse(meta.supportsUnionAll()); + assertTrue(meta.supportsUnionAll()); } /** diff --git a/sql/src/test/java/tests/sql/PreparedStatementTest.java b/sql/src/test/java/tests/sql/PreparedStatementTest.java index 26147ed..1546d38 100755 --- a/sql/src/test/java/tests/sql/PreparedStatementTest.java +++ b/sql/src/test/java/tests/sql/PreparedStatementTest.java @@ -2981,16 +2981,6 @@ public class PreparedStatementTest extends SQLTest { } } - /** - * @test {@link java.sql.PreparedStatement#setCharacterStream(int, java.io.Reader, int)} - * - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "not supported", - method = "setCharacterStream", - args = {int.class, java.io.Reader.class, int.class} - ) public void testSetCharacterSteam() { ResultSet res = null; PreparedStatement ps = null; @@ -3002,9 +2992,6 @@ public class PreparedStatementTest extends SQLTest { assertNotNull("Error in test setup: file not found",file); Reader reader = new InputStreamReader(file); ps.setCharacterStream(1, reader, 100); - fail("Exception expected not supported"); - } catch (SQLException e) { - // ok } catch (Exception e) { fail("Error in test setup "+e.getMessage()); e.printStackTrace(); diff --git a/sql/src/test/java/tests/sql/ResultSetGetterTests.java b/sql/src/test/java/tests/sql/ResultSetGetterTests.java index 9b12fc1..fccfd94 100644 --- a/sql/src/test/java/tests/sql/ResultSetGetterTests.java +++ b/sql/src/test/java/tests/sql/ResultSetGetterTests.java @@ -299,7 +299,6 @@ public class ResultSetGetterTests extends SQLTest { method = "getBytes", args = {int.class} ) - @KnownFailure("last assertion fails: invalid conversion. Test passes on RI") public void testGetBytesIntVarbinary() throws SQLException { Statement st = null; @@ -347,7 +346,6 @@ public class ResultSetGetterTests extends SQLTest { method = "getBytes", args = {int.class} ) - @KnownFailure("last assertion fails: invalid conversion. Test passes on RI") public void testGetBytesIntBinary() throws SQLException { Statement st = null; @@ -511,18 +509,9 @@ public class ResultSetGetterTests extends SQLTest { } } - /** - * Test method for {@link java.sql.ResultSet#getConcurrency()}. - */ - @TestTargetNew( - level = TestLevel.SUFFICIENT, - notes = "Not fully supported: CONCUR_UPDATABLE not supported", - method = "getConcurrency", - args = {} - ) public void testGetConcurrency() { try { - assertEquals(ResultSet.CONCUR_READ_ONLY, res.getConcurrency()); + assertEquals(ResultSet.CONCUR_UPDATABLE, res.getConcurrency()); } catch (SQLException e) { fail("Unexpected exception: " + e.getMessage()); } diff --git a/sql/src/test/java/tests/sql/ResultSetTest.java b/sql/src/test/java/tests/sql/ResultSetTest.java index 796c6a4..5b6d74a 100644 --- a/sql/src/test/java/tests/sql/ResultSetTest.java +++ b/sql/src/test/java/tests/sql/ResultSetTest.java @@ -107,19 +107,6 @@ public class ResultSetTest extends SQLTest { } catch (SQLException e) { fail("Unexpected exception: " + e.getMessage()); } - - try { -// Go back in position with forward only cursor - assertEquals(ResultSet.TYPE_FORWARD_ONLY, target.getFetchDirection()); - target.absolute(2); - target.absolute(1); - fail("Should get SQLException"); - } catch (SQLException e) { - // ok - } - - - } /** @@ -598,42 +585,8 @@ public class ResultSetTest extends SQLTest { } - /** - * Test method for {@link java.sql.ResultSet#previous()}. - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "tests SQLException", - method = "previous", - args = {} - ) - public void testPrevious() { - + public void testPrevious() throws SQLException { try { - assertEquals(ResultSet.FETCH_FORWARD, target.getFetchDirection()); - target.last(); - target.previous(); - fail("Should get SQLException"); - } catch (SQLException e) { - // ok - } - } - - /** - * Test method for {@link java.sql.ResultSet#previous()}. - * @throws SQLException - */ - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "not supported", - method = "previous", - args = {} - ) - @KnownFailure("not supported") - public void testPrevious2() throws SQLException { - try { - assertSame(ResultSet.TYPE_SCROLL_INSENSITIVE, scrollableTarget.getFetchDirection()); - target.first(); target.previous(); assertTrue(target.isBeforeFirst()); diff --git a/sql/src/test/java/tests/sql/StatementTest.java b/sql/src/test/java/tests/sql/StatementTest.java index f884782..55bd7ab 100755 --- a/sql/src/test/java/tests/sql/StatementTest.java +++ b/sql/src/test/java/tests/sql/StatementTest.java @@ -692,29 +692,28 @@ public class StatementTest extends SQLTest { } } - /** - * @test java.sql.Statement#setMaxRows(int max) - * TODO not supported - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "not supported", - method = "setMaxRows", - args = {int.class} - ) - public void testSetMaxRows() { + public void testMaxRows() { Statement st = null; try { st = conn.createStatement(); - st.execute("select * from zoo;"); - for (int i = 0; i < 300; i += 50) { + for (int i = 0; i < 300; i += 50) { try { st.setMaxRows(i); assertEquals(i, st.getMaxRows()); - fail("Revise test implemenation for feature impl. has changed"); + ResultSet r = st.executeQuery("select * from zoo;"); + int rowCount = 0; + while (r.next()) { + ++rowCount; + } + if (i == 0) { + // 0 means unlimited. + assertTrue("rowCount=" + rowCount + " i=" + i, rowCount > i); + } else { + assertTrue("rowCount=" + rowCount + " i=" + i, rowCount <= i); + } + r.close(); } catch (SQLException sqle) { - assertEquals("not supported", sqle.getMessage()); -// fail("SQLException is thrown: " + sqle.getMessage()); + fail("SQLException is thrown: " + sqle.getMessage()); } } try { @@ -735,41 +734,6 @@ public class StatementTest extends SQLTest { } /** - * @test java.sql.Statement#getMaxRows() - * TODO not supported - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "not supported", - method = "getMaxRows", - args = {} - ) - public void testGetMaxRows() { - Statement st = null; - try { - st = conn.createStatement(); - for (int i = 200; i < 500; i += 50) { - try { - st.setMaxRows(i); - assertEquals(i, st.getMaxRows()); - fail("Revise test implemenation for feature impl. has changed"); - } catch (SQLException sqle) { - assertEquals("not supported", sqle.getMessage()); -// fail("SQLException is thrown: " + sqle.getMessage()); - } - } - } catch (SQLException e) { - fail("Can't create statement, SQLException is thrown: " - + e.getMessage()); - } finally { - try { - st.close(); - } catch (SQLException ee) { - } - } - } - - /** * @test java.sql.Statement#close() * not passed according to Java Docs: should release all resources * IMMEDIATELY |