Search in sources :

Example 6 with KnownFailure

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

the class DatabaseMetaDataTest method test_getColumnsTableWithNoCatalogSchema.

/**
     * java.sql.DatabaseMetaData #getColumns(java.lang.String,
     *        java.lang.String, java.lang.String, java.lang.String)
     *
     */
@KnownFailure("Not supported ops applied: test fails on arguments: '', '', '%', '%' ")
public void test_getColumnsTableWithNoCatalogSchema() throws SQLException {
    try {
        ResultSet noSchemaTable = meta.getColumns("", "", DatabaseCreator.TEST_TABLE1, "fkey");
        assertNotNull(noSchemaTable);
        noSchemaTable.last();
        int size = noSchemaTable.getRow();
        assertEquals("Does not support empty string as input parameter or Wildcard %", 1, size);
    } catch (SQLException e) {
        fail("Unexpected exception: " + e.getMessage());
    }
    try {
        ResultSet noSchemaTable = meta.getColumns("", "", DatabaseCreator.TEST_TABLE1, "%");
        assertNotNull(noSchemaTable);
        noSchemaTable.last();
        int size = noSchemaTable.getRow();
        assertEquals("Does not support empty string as input parameter or Wildcard %", 5, size);
    } catch (SQLException e) {
        fail("Unexpected exception: " + e.getMessage());
    }
    try {
        ResultSet noSchemaTable = meta.getColumns("", "", "%", "%");
        assertNotNull(noSchemaTable);
        noSchemaTable.last();
        int size = noSchemaTable.getRow();
        assertEquals("Does not support double Wildcard '%' as input", 6, size);
    } catch (SQLException e) {
        fail("Unexpected exception: " + e.getMessage());
    }
    // Exception checking
    conn.close();
    try {
        meta.getColumns(null, null, DatabaseCreator.TEST_TABLE1, "%");
        fail("SQLException not thrown");
    } catch (SQLException e) {
    // ok
    }
}
Also used : SQLException(java.sql.SQLException) ResultSet(java.sql.ResultSet) KnownFailure(dalvik.annotation.KnownFailure)

Example 7 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 8 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 9 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 10 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)

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