Java Code Examples for android.database.SQLException.getMessage()

The following are Jave code examples for showing how to use getMessage() of the android.database.SQLException class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: GitHub   File: ParserConfigurationTest.java   Source Code and License Vote up 6 votes
/**
 * Should try to use the legacy parser by default, which is be unable to handle the SQL script.
 */
public void testLegacyMigration() {

    try {
        Configuration configuration = new Configuration.Builder(getContext())
                .setDatabaseName("migration.db")
                .setDatabaseVersion(2)
                .create();

        DatabaseHelper helper = new DatabaseHelper(configuration);
        SQLiteDatabase db = helper.getWritableDatabase();
        helper.onUpgrade(db, 1, 2);

        fail("Should not be able to parse the SQL script.");

    } catch (SQLException e) {
        final String message = e.getMessage();

        assertNotNull(message);
        assertTrue(message.contains("syntax error"));
        assertTrue(message.contains("near \"MockMigration\""));
    }
}