Skip to content

Commit

Permalink
Added tests for verifying BOMs for dependencies of "MappingSupportSQL…
Browse files Browse the repository at this point in the history
…iteDatabase"

*This commit is related to issue #529 [1]*

[1] #529
  • Loading branch information
JaniruTEC committed Jun 4, 2024
1 parent 0937ba3 commit 93417c3
Showing 1 changed file with 92 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package org.cryptomator.data.db

import androidx.sqlite.db.SupportSQLiteDatabase
import androidx.sqlite.db.SupportSQLiteOpenHelper
import androidx.sqlite.db.SupportSQLiteQuery
import androidx.sqlite.db.SupportSQLiteStatement
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import org.junit.Assert.assertEquals
Expand All @@ -13,6 +16,95 @@ import java.lang.reflect.Method
@SmallTest
class DatabaseOpenHelperFactoryTest {

@Test //For org.cryptomator.data.db.sqlmapping.MappingSupportSQLiteDatabase
fun verifySupportSQLiteDatabase() {
val bom = setOf(
"androidx.sqlite.db.SupportSQLiteDatabase.beginTransaction(): void",
"androidx.sqlite.db.SupportSQLiteDatabase.beginTransactionNonExclusive(): void",
"androidx.sqlite.db.SupportSQLiteDatabase.beginTransactionWithListener(android.database.sqlite.SQLiteTransactionListener): void",
"androidx.sqlite.db.SupportSQLiteDatabase.beginTransactionWithListenerNonExclusive(android.database.sqlite.SQLiteTransactionListener): void",
"java.lang.AutoCloseable.close(): void",
"androidx.sqlite.db.SupportSQLiteDatabase.compileStatement(java.lang.String): androidx.sqlite.db.SupportSQLiteStatement",
"androidx.sqlite.db.SupportSQLiteDatabase.delete(java.lang.String, java.lang.String, [Ljava.lang.Object;): int",
"androidx.sqlite.db.SupportSQLiteDatabase.disableWriteAheadLogging(): void",
"androidx.sqlite.db.SupportSQLiteDatabase.enableWriteAheadLogging(): boolean",
"androidx.sqlite.db.SupportSQLiteDatabase.endTransaction(): void",
"androidx.sqlite.db.SupportSQLiteDatabase.execPerConnectionSQL(java.lang.String, [Ljava.lang.Object;): void",
"androidx.sqlite.db.SupportSQLiteDatabase.execSQL(java.lang.String): void",
"androidx.sqlite.db.SupportSQLiteDatabase.execSQL(java.lang.String, [Ljava.lang.Object;): void",
"androidx.sqlite.db.SupportSQLiteDatabase.getAttachedDbs(): java.util.List",
"androidx.sqlite.db.SupportSQLiteDatabase.getMaximumSize(): long",
"androidx.sqlite.db.SupportSQLiteDatabase.getPageSize(): long",
"androidx.sqlite.db.SupportSQLiteDatabase.getPath(): java.lang.String",
"androidx.sqlite.db.SupportSQLiteDatabase.getVersion(): int",
"androidx.sqlite.db.SupportSQLiteDatabase.inTransaction(): boolean",
"androidx.sqlite.db.SupportSQLiteDatabase.insert(java.lang.String, int, android.content.ContentValues): long",
"androidx.sqlite.db.SupportSQLiteDatabase.isDatabaseIntegrityOk(): boolean",
"androidx.sqlite.db.SupportSQLiteDatabase.isDbLockedByCurrentThread(): boolean",
"androidx.sqlite.db.SupportSQLiteDatabase.isExecPerConnectionSQLSupported(): boolean",
"androidx.sqlite.db.SupportSQLiteDatabase.isOpen(): boolean",
"androidx.sqlite.db.SupportSQLiteDatabase.isReadOnly(): boolean",
"androidx.sqlite.db.SupportSQLiteDatabase.isWriteAheadLoggingEnabled(): boolean",
"androidx.sqlite.db.SupportSQLiteDatabase.needUpgrade(int): boolean",
"androidx.sqlite.db.SupportSQLiteDatabase.query(androidx.sqlite.db.SupportSQLiteQuery): android.database.Cursor",
"androidx.sqlite.db.SupportSQLiteDatabase.query(java.lang.String): android.database.Cursor",
"androidx.sqlite.db.SupportSQLiteDatabase.query(androidx.sqlite.db.SupportSQLiteQuery, android.os.CancellationSignal): android.database.Cursor",
"androidx.sqlite.db.SupportSQLiteDatabase.query(java.lang.String, [Ljava.lang.Object;): android.database.Cursor",
"androidx.sqlite.db.SupportSQLiteDatabase.setForeignKeyConstraintsEnabled(boolean): void",
"androidx.sqlite.db.SupportSQLiteDatabase.setLocale(java.util.Locale): void",
"androidx.sqlite.db.SupportSQLiteDatabase.setMaxSqlCacheSize(int): void",
"androidx.sqlite.db.SupportSQLiteDatabase.setMaximumSize(long): long",
"androidx.sqlite.db.SupportSQLiteDatabase.setPageSize(long): void",
"androidx.sqlite.db.SupportSQLiteDatabase.setTransactionSuccessful(): void",
"androidx.sqlite.db.SupportSQLiteDatabase.setVersion(int): void",
"androidx.sqlite.db.SupportSQLiteDatabase.update(java.lang.String, int, android.content.ContentValues, java.lang.String, [Ljava.lang.Object;): int",
"androidx.sqlite.db.SupportSQLiteDatabase.yieldIfContendedSafely(): boolean",
"androidx.sqlite.db.SupportSQLiteDatabase.yieldIfContendedSafely(long): boolean"
)
assertEquals(bom, SupportSQLiteDatabase::class.java.getFieldAndMethodNames())
}

@Test //For org.cryptomator.data.db.sqlmapping.MappingSupportSQLiteDatabase.MappingSupportSQLiteStatement
fun verifySupportSQLiteStatement() {
val bom = setOf(
"androidx.sqlite.db.SupportSQLiteProgram.bindBlob(int, [B): void",
"androidx.sqlite.db.SupportSQLiteProgram.bindDouble(int, double): void",
"androidx.sqlite.db.SupportSQLiteProgram.bindLong(int, long): void",
"androidx.sqlite.db.SupportSQLiteProgram.bindNull(int): void",
"androidx.sqlite.db.SupportSQLiteProgram.bindString(int, java.lang.String): void",
"androidx.sqlite.db.SupportSQLiteProgram.clearBindings(): void",
"java.lang.AutoCloseable.close(): void",
"androidx.sqlite.db.SupportSQLiteStatement.execute(): void",
"androidx.sqlite.db.SupportSQLiteStatement.executeInsert(): long",
"androidx.sqlite.db.SupportSQLiteStatement.executeUpdateDelete(): int",
"androidx.sqlite.db.SupportSQLiteStatement.simpleQueryForLong(): long",
"androidx.sqlite.db.SupportSQLiteStatement.simpleQueryForString(): java.lang.String"
)
assertEquals(bom, SupportSQLiteStatement::class.java.getFieldAndMethodNames())
}

@Test //For org.cryptomator.data.db.sqlmapping.MappingSupportSQLiteDatabase.MappingSupportSQLiteQuery
fun verifySupportSQLiteQuery() {
val bom = setOf(
"androidx.sqlite.db.SupportSQLiteQuery.bindTo(androidx.sqlite.db.SupportSQLiteProgram): void",
"androidx.sqlite.db.SupportSQLiteQuery.getArgCount(): int",
"androidx.sqlite.db.SupportSQLiteQuery.getSql(): java.lang.String"
)
assertEquals(bom, SupportSQLiteQuery::class.java.getFieldAndMethodNames())
}

@Test //For org.cryptomator.data.db.sqlmapping.MappingSupportSQLiteOpenHelper
fun verifySupportSQLiteOpenHelper() {
val bom = setOf(
"androidx.sqlite.db.SupportSQLiteOpenHelper.close(): void",
"androidx.sqlite.db.SupportSQLiteOpenHelper.getDatabaseName(): java.lang.String",
"androidx.sqlite.db.SupportSQLiteOpenHelper.getReadableDatabase(): androidx.sqlite.db.SupportSQLiteDatabase",
"androidx.sqlite.db.SupportSQLiteOpenHelper.getWritableDatabase(): androidx.sqlite.db.SupportSQLiteDatabase",
"androidx.sqlite.db.SupportSQLiteOpenHelper.setWriteAheadLoggingEnabled(boolean): void"
)
assertEquals(bom, SupportSQLiteOpenHelper::class.java.getFieldAndMethodNames())
}

@Test //For org.cryptomator.data.db.PatchedCallback
fun verifySupportSQLiteOpenHelperCallback() {
val bom = setOf(
Expand Down

0 comments on commit 93417c3

Please sign in to comment.