Search in sources :

Example 11 with KnownFailure

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

the class DatabaseMetaDataTest method test_supportsColumnAliasing.

/**
     * java.sql.DatabaseMetaData#supportsColumnAliasing()
     */
@KnownFailure("not supported. SQLException checking test fails")
public void test_supportsColumnAliasing() throws SQLException {
    insertNewRecord();
    String alias = "FIELD3";
    String selectQuery = "SELECT field1 AS " + alias + " FROM " + DatabaseCreator.TEST_TABLE1;
    ResultSet rs = statement.executeQuery(selectQuery);
    ResultSetMetaData rsmd = rs.getMetaData();
    if (meta.supportsColumnAliasing()) {
        // supports aliasing
        assertEquals("Wrong count of columns", 1, rsmd.getColumnCount());
        assertEquals("Aliasing is not supported", alias, rsmd.getColumnLabel(1));
    } else {
        // doesn't support aliasing
        assertEquals("Aliasing is supported", 0, rsmd.getColumnCount());
    }
    rs.close();
    //Exception checking
    conn.close();
    try {
        meta.supportsColumnAliasing();
        fail("SQLException not thrown");
    } catch (SQLException e) {
    //ok
    }
}
Also used : ResultSetMetaData(java.sql.ResultSetMetaData) SQLException(java.sql.SQLException) ResultSet(java.sql.ResultSet) KnownFailure(dalvik.annotation.KnownFailure)

Example 12 with KnownFailure

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

the class DatabaseMetaDataTest method test_getTablesLjava_lang_StringLjava_lang_StringLjava_lang_String$Ljava_lang_String.

/**
     * java.sql.DatabaseMetaData #getTables(java.lang.String,
     *        java.lang.String, java.lang.String, java.lang.String[])
     */
@KnownFailure("If no schema is associated: returns empty string where actually null be returned?. Ticket 98")
public void test_getTablesLjava_lang_StringLjava_lang_StringLjava_lang_String$Ljava_lang_String() throws SQLException {
    String[] tablesName = { VIEW_NAME, DatabaseCreator.TEST_TABLE1, DatabaseCreator.TEST_TABLE3 };
    String[] tablesType = { "TABLE", "VIEW" };
    Arrays.sort(tablesName);
    Arrays.sort(tablesType);
    // case 1. get all tables. There are two tables and one view in the
    // database
    ResultSet rs = meta.getTables(null, null, null, null);
    while (rs.next()) {
        assertTrue("Wrong table name", Arrays.binarySearch(tablesName, rs.getString("TABLE_NAME")) > -1);
        //No Schema associated
        assertNull("Wrong table schema: " + rs.getString("TABLE_SCHEM"), rs.getString("TABLE_SCHEM"));
        assertTrue("Wrong table type", Arrays.binarySearch(tablesType, rs.getString("TABLE_TYPE")) > -1);
        assertEquals("Wrong parameter REMARKS", "", rs.getString("REMARKS"));
    }
    rs.close();
    // case 2. get tables with specified types. There are no tables of such
    // types
    rs = meta.getTables(conn.getCatalog(), null, null, new String[] { "SYSTEM TABLE", "LOCAL TEMPORARY" });
    assertFalse("Some tables exist", rs.next());
    rs.close();
    // case 3. get tables with specified types. There is a table of such
    // types
    rs = meta.getTables(conn.getCatalog(), null, null, new String[] { "VIEW", "LOCAL TEMPORARY" });
    assertTrue("No tables exist", rs.next());
    assertEquals("Wrong table name", VIEW_NAME, rs.getString("TABLE_NAME"));
    assertNull("Wrong table schema: " + rs.getString("TABLE_SCHEM"), rs.getString("TABLE_SCHEM"));
    assertEquals("Wrong table type", "VIEW", rs.getString("TABLE_TYPE"));
    assertEquals("Wrong parameter REMARKS", "", rs.getString("REMARKS"));
    assertFalse("Wrong size of result set", rs.next());
    assertFalse("Some tables exist", rs.next());
    rs.close();
    // case 4. get all tables using tables pattern.
    // There are two tables and one view in the database
    rs = meta.getTables(null, null, "%", null);
    while (rs.next()) {
        assertTrue("Wrong table name", Arrays.binarySearch(tablesName, rs.getString("TABLE_NAME")) > -1);
        assertNull("Wrong table schema ", rs.getString("TABLE_SCHEM"));
        assertTrue("Wrong table type", Arrays.binarySearch(tablesType, rs.getString("TABLE_TYPE")) > -1);
        assertEquals("Wrong parameter REMARKS", "", rs.getString("REMARKS"));
    }
    rs.close();
    //Exception checking
    conn.close();
    try {
        meta.getTables(null, null, null, null);
        fail("SQLException not thrown");
    } catch (SQLException e) {
    //ok
    }
}
Also used : SQLException(java.sql.SQLException) ResultSet(java.sql.ResultSet) KnownFailure(dalvik.annotation.KnownFailure)

Example 13 with KnownFailure

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

the class DatabaseMetaDataTest method test_getTableTypes.

/**
     * java.sql.DatabaseMetaData#getTableTypes()
     */
@KnownFailure("Ticket 98")
public void test_getTableTypes() throws SQLException {
    String[] tableTypes = { "LOCAL TEMPORARY", "TABLE", "VIEW" };
    ResultSet rs = meta.getTableTypes();
    while (rs.next()) {
        assertTrue("Wrong table type", Arrays.binarySearch(tableTypes, rs.getString("TABLE_TYPE")) > -1);
    }
    rs.close();
    //Exception checking
    conn.close();
    try {
        meta.getTableTypes();
        fail("SQLException not thrown");
    } catch (SQLException e) {
    //ok
    }
}
Also used : SQLException(java.sql.SQLException) ResultSet(java.sql.ResultSet) KnownFailure(dalvik.annotation.KnownFailure)

Example 14 with KnownFailure

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

the class DatabaseMetaDataTest method test_getPrimaryKeysLjava_lang_StringLjava_lang_StringLjava_lang_String.

/**
     * java.sql.DatabaseMetaData #getPrimaryKeys(java.lang.String,
     *        java.lang.String, java.lang.String)
     */
@KnownFailure(" Ticket 91 : relies on not supported features: getCatalog, keys")
public void test_getPrimaryKeysLjava_lang_StringLjava_lang_StringLjava_lang_String() throws SQLException {
    ResultSet rs = meta.getPrimaryKeys(conn.getCatalog(), null, DatabaseCreator.TEST_TABLE1);
    ResultSetMetaData rsmd = rs.getMetaData();
    assertTrue("Rows not obtained", rs.next());
    int col = rsmd.getColumnCount();
    assertEquals("Incorrect number of columns", 6, col);
    String[] columnNames = { "TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME", "COLUMN_NAME", "KEY_SEQ", "PK_NAME" };
    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", "", 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 sequence number", 1, rs.getShort("KEY_SEQ"));
    assertEquals("Incorrect primary key name", "primary", rs.getString("PK_NAME").toLowerCase());
    rs.close();
    //Exception checking
    conn.close();
    try {
        meta.getPrimaryKeys(conn.getCatalog(), null, DatabaseCreator.TEST_TABLE1);
        fail("SQLException not thrown");
    } catch (SQLException e) {
    //ok
    }
}
Also used : ResultSetMetaData(java.sql.ResultSetMetaData) SQLException(java.sql.SQLException) ResultSet(java.sql.ResultSet) KnownFailure(dalvik.annotation.KnownFailure)

Example 15 with KnownFailure

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

the class DatabaseMetaDataTest method test_getCrossReferenceLjava_lang_StringLjava_lang_StringLjava_lang_StringLjava_lang_StringLjava_lang_StringLjava_lang_String.

/**
     * java.sql.DatabaseMetaData #getCrossReference(java.lang.String,
     *        java.lang.String, java.lang.String, java.lang.String,
     *        java.lang.String, java.lang.String)
     */
@KnownFailure("(Ticket 91) Tables apply foreign key constraint. Catalogs not supported")
public void test_getCrossReferenceLjava_lang_StringLjava_lang_StringLjava_lang_StringLjava_lang_StringLjava_lang_StringLjava_lang_String() throws SQLException {
    ResultSet rs = meta.getCrossReference(conn.getCatalog(), null, DatabaseCreator.TEST_TABLE3, conn.getCatalog(), null, DatabaseCreator.TEST_TABLE1);
    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));
    }
    //      TODO getCatalog is not supported
    assertEquals("Incorrect primary key table catalog", conn.getCatalog(), rs.getString("PKTABLE_CAT"));
    assertEquals("Incorrect primary key table schema", "", rs.getString("PKTABLE_SCHEM"));
    assertEquals("Incorrect primary key table name", DatabaseCreator.TEST_TABLE3, rs.getString("PKTABLE_NAME"));
    assertEquals("Incorrect primary key column name", "fkey", rs.getString("PKCOLUMN_NAME"));
    // TODO getCatalog is not supported
    assertEquals("Incorrect foreign key table catalog", conn.getCatalog(), rs.getString("FKTABLE_CAT"));
    assertEquals("Incorrect foreign key table schema", "", rs.getString("FKTABLE_SCHEM"));
    assertEquals("Incorrect foreign key table name", DatabaseCreator.TEST_TABLE1, rs.getString("FKTABLE_NAME"));
    assertEquals("Incorrect foreign key column name", "fk", 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"));
    assertNull("Incorrect foreign key name", rs.getString("FK_NAME"));
    assertNull("Incorrect primary key name", rs.getString("PK_NAME"));
    assertEquals("Incorrect deferrability", DatabaseMetaData.importedKeyNotDeferrable, rs.getShort("DEFERRABILITY"));
    rs.close();
    // Exception checking
    conn.close();
    try {
        meta.getCrossReference(conn.getCatalog(), null, DatabaseCreator.TEST_TABLE3, conn.getCatalog(), null, DatabaseCreator.TEST_TABLE1);
        fail("SQLException not thrown");
    } catch (SQLException e) {
    // ok
    }
    // Exception checking
    conn.close();
    try {
        meta.getCrossReference(conn.getCatalog(), null, DatabaseCreator.TEST_TABLE3, conn.getCatalog(), null, DatabaseCreator.TEST_TABLE1);
        fail("SQLException not thrown");
    } catch (SQLException e) {
    // ok
    }
}
Also used : ResultSetMetaData(java.sql.ResultSetMetaData) 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