use of dalvik.annotation.KnownFailure in project robovm by robovm.
the class DatabaseMetaDataNotSupportedTest method test_getIndexInfoLjava_lang_StringLjava_lang_StringLjava_lang_StringZZ.
@KnownFailure("not supported")
public void test_getIndexInfoLjava_lang_StringLjava_lang_StringLjava_lang_StringZZ() throws SQLException {
boolean unique = false;
ResultSet rs = meta.getIndexInfo(conn.getCatalog(), null, DatabaseCreator.TEST_TABLE1, unique, true);
ResultSetMetaData rsmd = rs.getMetaData();
assertTrue("Rows do not obtained", rs.next());
int col = rsmd.getColumnCount();
assertEquals("Incorrect number of columns", 13, col);
String[] columnNames = { "TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME", "NON_UNIQUE", "INDEX_QUALIFIER", "INDEX_NAME", "TYPE", "ORDINAL_POSITION", "COLUMN_NAME", "ASC_OR_DESC", "CARDINALITY", "PAGES", "FILTER_CONDITION" };
for (int c = 1; c <= col; ++c) {
assertEquals("Incorrect column name", columnNames[c - 1], rsmd.getColumnName(c));
}
assertEquals("Incorrect table catalog", conn.getCatalog(), rs.getString("TABLE_CAT"));
assertEquals("Incorrect table schema", null, rs.getString("TABLE_SCHEM"));
assertEquals("Incorrect table name", DatabaseCreator.TEST_TABLE1, rs.getString("TABLE_NAME"));
assertEquals("Incorrect state of uniquess", unique, rs.getBoolean("NON_UNIQUE"));
assertEquals("Incorrect index catalog", "", rs.getString("INDEX_QUALIFIER"));
assertEquals("Incorrect index name", "primary", rs.getString("INDEX_NAME").toLowerCase());
assertEquals("Incorrect index type", DatabaseMetaData.tableIndexOther, rs.getShort("TYPE"));
assertEquals("Incorrect column sequence number within index", 1, rs.getShort("ORDINAL_POSITION"));
assertEquals("Incorrect column name", "id", rs.getString("COLUMN_NAME"));
assertEquals("Incorrect column sort sequence", "a", rs.getString("ASC_OR_DESC").toLowerCase());
assertEquals("Incorrect cardinality", 1, rs.getInt("CARDINALITY"));
assertEquals("Incorrect value of pages", 0, rs.getInt("PAGES"));
assertEquals("Incorrect filter condition", null, rs.getString("FILTER_CONDITION"));
rs.close();
}
use of dalvik.annotation.KnownFailure in project robovm by robovm.
the class DatabaseMetaDataNotSupportedTest method test_getTablePrivilegesLjava_lang_StringLjava_lang_StringLjava_lang_String.
@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
ResultSet privileges = meta.getTablePrivileges(conn.getCatalog(), "%", DatabaseCreator.TEST_TABLE3);
assertFalse("Some privilegies exist", privileges.next());
privileges.close();
// case 2. Get privileges when no privilegies exist for all tables
privileges = meta.getTablePrivileges(null, null, null);
assertFalse("Some privilegies exist", privileges.next());
privileges.close();
// case 3. grant CREATE and SELECT privileges ang get them
HashSet<String> expectedPrivs = new HashSet<String>();
expectedPrivs.add("CREATE");
expectedPrivs.add("SELECT");
String query = "GRANT CREATE, SELECT ON " + DatabaseCreator.TEST_TABLE3 + " TO " + Support_SQL.sqlUser;
statement.execute(query);
privileges = meta.getTablePrivileges(conn.getCatalog(), null, DatabaseCreator.TEST_TABLE3);
while (privileges.next()) {
assertEquals("Wrong catalog name", Support_SQL.sqlCatalog, privileges.getString("TABLE_CAT"));
assertNull("Wrong schema", privileges.getString("TABLE_SCHEM"));
assertEquals("Wrong table name", DatabaseCreator.TEST_TABLE3, privileges.getString("TABLE_NAME"));
assertTrue("Wrong privilege " + privileges.getString("PRIVILEGE"), expectedPrivs.remove(privileges.getString("PRIVILEGE")));
assertEquals("Wrong grantor", Support_SQL.sqlLogin + "@" + Support_SQL.sqlHost, privileges.getString("GRANTOR"));
assertEquals("Wrong grantee", Support_SQL.sqlUser + "@%", privileges.getString("GRANTEE"));
assertNull("Wrong value of IS_GRANTABLE", privileges.getString("IS_GRANTABLE"));
}
privileges.close();
assertTrue("Wrong privileges were returned", expectedPrivs.isEmpty());
query = "REVOKE CREATE, SELECT ON " + DatabaseCreator.TEST_TABLE3 + " FROM " + Support_SQL.sqlUser;
statement.execute(query);
// case 4. grant all privileges ang get them
String[] privs = new String[] { "ALTER", "CREATE", "CREATE VIEW", "DELETE", "DROP", "INDEX", "INSERT", "REFERENCES", "SELECT", "SHOW VIEW", "UPDATE" };
expectedPrivs = new HashSet<String>();
for (int i = 0; i < privs.length; i++) {
expectedPrivs.add(privs[i]);
}
query = "GRANT ALL ON " + DatabaseCreator.TEST_TABLE3 + " TO " + Support_SQL.sqlUser;
statement.execute(query);
privileges = meta.getTablePrivileges(conn.getCatalog(), null, DatabaseCreator.TEST_TABLE3);
while (privileges.next()) {
assertEquals("Wrong catalog name", Support_SQL.sqlCatalog, privileges.getString("TABLE_CAT"));
assertNull("Wrong schema", privileges.getString("TABLE_SCHEM"));
assertEquals("Wrong table name", DatabaseCreator.TEST_TABLE3, privileges.getString("TABLE_NAME"));
assertTrue("Wrong privilege " + privileges.getString("PRIVILEGE"), expectedPrivs.remove(privileges.getString("PRIVILEGE")));
assertEquals("Wrong grantor", Support_SQL.sqlLogin + "@" + Support_SQL.sqlHost, privileges.getString("GRANTOR"));
assertEquals("Wrong grantee", Support_SQL.sqlUser + "@%", privileges.getString("GRANTEE"));
assertNull("Wrong value of IS_GRANTABLE", privileges.getString("IS_GRANTABLE"));
}
privileges.close();
assertTrue("Wrong privileges were returned", expectedPrivs.isEmpty());
query = "REVOKE ALL ON " + DatabaseCreator.TEST_TABLE3 + " FROM " + Support_SQL.sqlUser;
statement.execute(query);
// case 5. check no privelegies after revoke
privileges = meta.getTablePrivileges(conn.getCatalog(), "%", DatabaseCreator.TEST_TABLE3);
assertFalse("Some privilegies exist", privileges.next());
privileges.close();
privileges = meta.getTablePrivileges(null, null, null);
assertFalse("Some privilegies exist", privileges.next());
privileges.close();
}
use of dalvik.annotation.KnownFailure in project robovm by robovm.
the class DatabaseMetaDataNotSupportedTest method test_allTablesAreSelectable.
@KnownFailure("Not supported ops applied")
public void test_allTablesAreSelectable() throws SQLException {
// grant SELECT privileges
String query = "GRANT CREATE, SELECT ON " + DatabaseCreator.TEST_TABLE1 + " TO " + Support_SQL.sqlUser;
statement.execute(query);
Connection userConn = Support_SQL.getConnection(Support_SQL.sqlUrl, Support_SQL.sqlUser, Support_SQL.sqlUser);
DatabaseMetaData userMeta = userConn.getMetaData();
ResultSet userTab = userMeta.getTables(null, null, null, null);
assertTrue("Tables are not obtained", userTab.next());
assertEquals("Incorrect name of obtained table", DatabaseCreator.TEST_TABLE1.toLowerCase(), userTab.getString("TABLE_NAME").toLowerCase());
assertTrue("Not all of obtained tables are selectable", userMeta.allTablesAreSelectable());
userTab.close();
// revoke SELECT privileges
query = "REVOKE SELECT ON " + DatabaseCreator.TEST_TABLE1 + " FROM " + Support_SQL.sqlUser;
statement.execute(query);
userTab = userMeta.getTables(null, null, null, null);
assertTrue("Tables are not obtained", userTab.next());
assertEquals("Incorrect name of obtained table", DatabaseCreator.TEST_TABLE1.toLowerCase(), userTab.getString("TABLE_NAME").toLowerCase());
assertFalse("No SELECT privileges", userMeta.allTablesAreSelectable());
userTab.close();
// revoke CREATE privileges
query = "REVOKE CREATE ON " + DatabaseCreator.TEST_TABLE1 + " FROM " + Support_SQL.sqlUser;
statement.execute(query);
userConn.close();
}
use of dalvik.annotation.KnownFailure in project robovm by robovm.
the class DatabaseMetaDataTest method test_getColumnsArbitrary.
/**
* java.sql.DatabaseMetaData #getColumns(java.lang.String,
* java.lang.String, java.lang.String, java.lang.String)
*
*/
@KnownFailure("Not supported : pattern with %")
public void test_getColumnsArbitrary() throws SQLException {
ResultSet setAllNull = null;
ResultSet setMixed = null;
ResultSet allArbitrary = null;
String[] tablesName = { DatabaseCreator.TEST_TABLE1, DatabaseCreator.TEST_TABLE3 };
Arrays.sort(tablesName);
int setSize = 0;
try {
allArbitrary = meta.getColumns("%", "%", "%", "%");
assertNotNull(allArbitrary);
checkColumnsShape(allArbitrary);
setSize = crossCheckGetColumnsAndResultSetMetaData(allArbitrary, false);
assertEquals(6, setSize);
setMixed = meta.getColumns(null, null, "%", "%");
assertNotNull(setMixed);
checkColumnsShape(setMixed);
setSize = crossCheckGetColumnsAndResultSetMetaData(setMixed, false);
assertEquals(6, setSize);
} catch (SQLException e) {
fail("Unexpected exception: " + e.getMessage());
}
// Exception testing
conn.close();
try {
meta.getColumns(null, null, DatabaseCreator.TEST_TABLE1, "%");
fail("SQLException not thrown");
} catch (SQLException e) {
// ok
}
}
use of dalvik.annotation.KnownFailure in project robovm by robovm.
the class DatabaseMetaDataTest method test_getImportedKeysLjava_lang_StringLjava_lang_StringLjava_lang_String.
@KnownFailure("Keys are not supported: Ticket 91")
public void test_getImportedKeysLjava_lang_StringLjava_lang_StringLjava_lang_String() throws SQLException {
ResultSet rs = meta.getImportedKeys(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"));
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"));
// 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();
//Exception checking
conn.close();
try {
meta.getImportedKeys(conn.getCatalog(), null, DatabaseCreator.TEST_TABLE1);
fail("SQLException not thrown");
} catch (SQLException e) {
//ok
}
}
Aggregations