Search in sources :

Example 1 with KnownFailure

use of dalvik.annotation.KnownFailure in project robovm by robovm.

the class UpdateFunctionalityTest2 method testUpdate7.

/**
     * UpdateFunctionalityTest2#testUpdate7(). Updates table using
     *        subquery in WHERE clause
     *
     *  TODO Foreign key functionality is not supported
     */
@KnownFailure("not supported")
public void testUpdate7() throws SQLException {
    DatabaseCreator.fillFKStrictTable(conn);
    statement.executeUpdate("UPDATE " + DatabaseCreator.FKSTRICT_TABLE + " SET value = 'updated' WHERE name_id = ANY (SELECT id FROM " + DatabaseCreator.PARENT_TABLE + " WHERE id > 1)");
    ResultSet r = statement.executeQuery("SELECT COUNT(*) FROM " + DatabaseCreator.FKSTRICT_TABLE + " WHERE value = 'updated';");
    r.next();
    assertEquals("Should be 1 row", 1, r.getInt(1));
    r.close();
}
Also used : ResultSet(java.sql.ResultSet) KnownFailure(dalvik.annotation.KnownFailure)

Example 2 with KnownFailure

use of dalvik.annotation.KnownFailure in project robovm by robovm.

the class DatabaseMetaDataNotSupportedTest method test_getColumnPrivilegesLjava_lang_StringLjava_lang_StringLjava_lang_StringLjava_lang_String.

@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, DatabaseCreator.TEST_TABLE1, "id");
    ResultSetMetaData rsmd = rs.getMetaData();
    assertFalse("Rows are obtained", rs.next());
    rs.close();
    String query = "GRANT REFERENCES(id) ON " + DatabaseCreator.TEST_TABLE1 + " TO " + Support_SQL.sqlLogin;
    statement.execute(query);
    rs = meta.getColumnPrivileges(conn.getCatalog(), null, DatabaseCreator.TEST_TABLE1, "id");
    rsmd = rs.getMetaData();
    assertTrue("Rows do not obtained", rs.next());
    int col = rsmd.getColumnCount();
    assertEquals("Incorrect number of columns", 8, col);
    String[] columnNames = { "TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME", "COLUMN_NAME", "GRANTOR", "GRANTEE", "PRIVILEGE", "IS_GRANTABLE" };
    for (int c = 1; c <= col; ++c) {
        assertEquals("Incorrect column name", columnNames[c - 1], rsmd.getColumnName(c));
    }
    assertEquals("Incorrect table catalogue", conn.getCatalog(), rs.getString("TABLE_CAT").toLowerCase());
    assertEquals("Incorrect table schema", null, rs.getString("TABLE_SCHEM"));
    assertEquals("Incorrect table name", DatabaseCreator.TEST_TABLE1, rs.getString("TABLE_NAME").toLowerCase());
    assertEquals("Incorrect column name", "id", rs.getString("COLUMN_NAME").toLowerCase());
    assertEquals("Incorrect grantor", Support_SQL.sqlLogin + "@" + Support_SQL.sqlHost, rs.getString("GRANTOR").toLowerCase());
    assertTrue("Incorrect grantee", rs.getString("GRANTEE").indexOf("root") != -1);
    assertEquals("Incorrect privilege", "references", rs.getString("PRIVILEGE").toLowerCase());
    query = "REVOKE REFERENCES(id) ON " + DatabaseCreator.TEST_TABLE1 + " FROM " + Support_SQL.sqlLogin;
    statement.execute(query);
    rs.close();
}
Also used : ResultSetMetaData(java.sql.ResultSetMetaData) ResultSet(java.sql.ResultSet) KnownFailure(dalvik.annotation.KnownFailure)

Example 3 with KnownFailure

use of dalvik.annotation.KnownFailure in project robovm by robovm.

the class DatabaseMetaDataNotSupportedTest method test_getVersionColumnsLjava_lang_StringLjava_lang_StringLjava_lang_String.

@KnownFailure("Not supported ops applied")
public void test_getVersionColumnsLjava_lang_StringLjava_lang_StringLjava_lang_String() throws SQLException {
    DatabaseMetaDataTest.insertNewRecord();
    String triggerName = "updateTrigger";
    String triggerQuery = "CREATE TRIGGER " + triggerName + " AFTER UPDATE ON " + DatabaseCreator.TEST_TABLE1 + " FOR EACH ROW BEGIN INSERT INTO " + DatabaseCreator.TEST_TABLE3 + " SET fk = 10; END;";
    statementForward.execute(triggerQuery);
    String updateQuery = "UPDATE " + DatabaseCreator.TEST_TABLE1 + " SET field1='fffff' WHERE id=1";
    statementForward.execute(updateQuery);
    ResultSet rs = meta.getVersionColumns(conn.getCatalog(), null, DatabaseCreator.TEST_TABLE1);
    assertTrue("Result set is empty", rs.next());
    rs.close();
}
Also used : ResultSet(java.sql.ResultSet) KnownFailure(dalvik.annotation.KnownFailure)

Example 4 with KnownFailure

use of dalvik.annotation.KnownFailure in project robovm by robovm.

the class DatabaseMetaDataNotSupportedTest method test_getExportedKeysLjava_lang_StringLjava_lang_StringLjava_lang_String.

@KnownFailure("not supported")
public void test_getExportedKeysLjava_lang_StringLjava_lang_StringLjava_lang_String() throws SQLException {
    ResultSet rs = meta.getExportedKeys(conn.getCatalog(), null, DatabaseCreator.TEST_TABLE3);
    ResultSetMetaData rsmd = rs.getMetaData();
    assertTrue("Rows do not obtained", rs.next());
    int col = rsmd.getColumnCount();
    assertEquals("Incorrect number of columns", 14, col);
    String[] columnNames = { "PKTABLE_CAT", "PKTABLE_SCHEM", "PKTABLE_NAME", "PKCOLUMN_NAME", "FKTABLE_CAT", "FKTABLE_SCHEM", "FKTABLE_NAME", "FKCOLUMN_NAME", "KEY_SEQ", "UPDATE_RULE", "DELETE_RULE", "FK_NAME", "PK_NAME", "DEFERRABILITY" };
    for (int c = 1; c <= col; ++c) {
        assertEquals("Incorrect column name", columnNames[c - 1], rsmd.getColumnName(c));
    }
    assertEquals("Incorrect primary key table catalog", conn.getCatalog(), rs.getString("PKTABLE_CAT"));
    assertEquals("Incorrect primary key table schema", null, rs.getString("PKTABLE_SCHEM"));
    assertEquals("Incorrect primary key table name", DatabaseCreator.TEST_TABLE3, rs.getString("PKTABLE_NAME"));
    assertEquals("Incorrect primary key column name", "fk", rs.getString("PKCOLUMN_NAME"));
    assertEquals("Incorrect foreign key table catalog", conn.getCatalog(), rs.getString("FKTABLE_CAT"));
    assertEquals("Incorrect foreign key table schema", null, rs.getString("FKTABLE_SCHEM"));
    assertEquals("Incorrect foreign key table name", DatabaseCreator.TEST_TABLE1, rs.getString("FKTABLE_NAME"));
    assertEquals("Incorrect foreign key column name", "fkey", rs.getString("FKCOLUMN_NAME"));
    assertEquals("Incorrect sequence number within foreign key", 1, rs.getShort("KEY_SEQ"));
    assertEquals("Incorrect update rule value", DatabaseMetaData.importedKeyNoAction, rs.getShort("UPDATE_RULE"));
    assertEquals("Incorrect delete rule value", DatabaseMetaData.importedKeyNoAction, rs.getShort("DELETE_RULE"));
    assertNotNull("Incorrect foreign key name", rs.getString("FK_NAME"));
    assertEquals("Incorrect primary key name", null, rs.getString("PK_NAME"));
    assertEquals("Incorrect deferrability", DatabaseMetaData.importedKeyNotDeferrable, rs.getShort("DEFERRABILITY"));
    rs.close();
}
Also used : ResultSetMetaData(java.sql.ResultSetMetaData) ResultSet(java.sql.ResultSet) KnownFailure(dalvik.annotation.KnownFailure)

Example 5 with KnownFailure

use of dalvik.annotation.KnownFailure in project robovm by robovm.

the class DatabaseMetaDataTest method test_getTypeInfo.

/**
     * java.sql.DatabaseMetaData#getTypeInfo()
     */
@KnownFailure("not supported")
public void test_getTypeInfo() throws SQLException {
    insertNewRecord();
    ResultSet rs = meta.getTypeInfo();
    final String[] names = { "TYPE_NAME", "DATA_TYPE", "PRECISION", "LITERAL_PREFIX", "LITERAL_SUFFIX", "CREATE_PARAMS", "NULLABLE", "CASE_SENSITIVE", "SEARCHABLE", "UNSIGNED_ATTRIBUTE", "FIXED_PREC_SCALE", "AUTO_INCREMENT", "LOCAL_TYPE_NAME", "MINIMUM_SCALE", "MAXIMUM_SCALE", "SQL_DATA_TYPE", "SQL_DATETIME_SUB", "NUM_PREC_RADIX" };
    Arrays.sort(names);
    for (int i = 0; i < rs.getMetaData().getColumnCount(); i++) {
        assertTrue("wrong column was return", Arrays.binarySearch(names, rs.getMetaData().getColumnName(i + 1)) > -1);
    }
    int[] types = { Types.ARRAY, Types.BIGINT, Types.BINARY, Types.BIT, Types.BLOB, Types.BOOLEAN, Types.CHAR, Types.CLOB, Types.DATALINK, Types.DATE, Types.DECIMAL, Types.DISTINCT, Types.DOUBLE, Types.FLOAT, Types.INTEGER, Types.JAVA_OBJECT, Types.LONGVARBINARY, Types.LONGVARCHAR, Types.NULL, Types.NUMERIC, Types.OTHER, Types.REAL, Types.REF, Types.SMALLINT, Types.STRUCT, Types.TIME, Types.TIMESTAMP, Types.TINYINT, Types.VARBINARY, Types.VARCHAR };
    Arrays.sort(types);
    while (rs.next()) {
        assertTrue("wrong type was return ", Arrays.binarySearch(types, rs.getInt("DATA_TYPE")) > -1);
    }
    rs.close();
    //Exception checking
    conn.close();
    try {
        meta.getTypeInfo();
        fail("SQLException not thrown");
    } catch (SQLException e) {
    //ok
    }
}
Also used : SQLException(java.sql.SQLException) ResultSet(java.sql.ResultSet) KnownFailure(dalvik.annotation.KnownFailure)

Aggregations

KnownFailure (dalvik.annotation.KnownFailure)39 ResultSet (java.sql.ResultSet)21 IOException (java.io.IOException)12 SQLException (java.sql.SQLException)12 ByteBuffer (java.nio.ByteBuffer)11 SSLEngine (javax.net.ssl.SSLEngine)11 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)10 ReadOnlyBufferException (java.nio.ReadOnlyBufferException)9 KeyManagementException (java.security.KeyManagementException)9 ResultSetMetaData (java.sql.ResultSetMetaData)9 SSLException (javax.net.ssl.SSLException)9 URL (java.net.URL)2 URLClassLoader (java.net.URLClassLoader)2 InvalidAlgorithmParameterException (java.security.InvalidAlgorithmParameterException)2 HashSet (java.util.HashSet)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 InputStream (java.io.InputStream)1