Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix formatting in ShadowSQLiteConnectionsTest #6712

Merged
merged 1 commit into from Sep 14, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -33,14 +33,15 @@ public class ShadowSQLiteConnectionTest {
private File databasePath;
private long ptr;
private SQLiteConnection conn;
private ShadowSQLiteConnection.Connections CONNECTIONS;
private ShadowSQLiteConnection.Connections connections;

@Before
public void setUp() throws Exception {
database = createDatabase("database.db");
SQLiteStatement createStatement = database.compileStatement(
"CREATE TABLE `routine` (`id` INTEGER PRIMARY KEY AUTOINCREMENT , `name` VARCHAR ,"
+ " `lastUsed` INTEGER DEFAULT 0 , UNIQUE (`name`)) ;");
SQLiteStatement createStatement =
database.compileStatement(
"CREATE TABLE `routine` (`id` INTEGER PRIMARY KEY AUTOINCREMENT , `name` VARCHAR ,"
+ " `lastUsed` INTEGER DEFAULT 0 , UNIQUE (`name`)) ;");
createStatement.execute();
conn = getSQLiteConnection();
}
Expand All @@ -55,18 +56,21 @@ public void testSqlConversion() {
assertThat(convertSQLWithLocalizedUnicodeCollator("select * from `routine`"))
.isEqualTo("select * from `routine`");

assertThat(convertSQLWithLocalizedUnicodeCollator(
"select * from `routine` order by name \n\r \f collate\f\n\tunicode"
+ "\n, id \n\n\t collate\n\t \n\flocalized"))
.isEqualTo("select * from `routine` order by name COLLATE NOCASE\n"
+ ", id COLLATE NOCASE");
assertThat(
convertSQLWithLocalizedUnicodeCollator(
"select * from `routine` order by name \n\r \f collate\f\n\tunicode"
+ "\n, id \n\n\t collate\n\t \n\flocalized"))
.isEqualTo(
"select * from `routine` order by name COLLATE NOCASE\n" + ", id COLLATE NOCASE");

assertThat(convertSQLWithLocalizedUnicodeCollator("select * from `routine` order by name"
+ " collate localized"))
assertThat(
convertSQLWithLocalizedUnicodeCollator(
"select * from `routine` order by name" + " collate localized"))
.isEqualTo("select * from `routine` order by name COLLATE NOCASE");

assertThat(convertSQLWithLocalizedUnicodeCollator("select * from `routine` order by name"
+ " collate unicode"))
assertThat(
convertSQLWithLocalizedUnicodeCollator(
"select * from `routine` order by name" + " collate unicode"))
.isEqualTo("select * from `routine` order by name COLLATE NOCASE");
}

Expand Down Expand Up @@ -102,13 +106,13 @@ public void nativeOpen_addsConnectionToPool() {
assertThat(conn).isNotNull();
assertWithMessage("open").that(conn.isOpen()).isTrue();
}

@Test
public void nativeClose_closesConnection() {
ShadowSQLiteConnection.nativeClose(ptr);
assertWithMessage("open").that(conn.isOpen()).isFalse();
}

@Test
public void reset_closesConnection() {
ShadowSQLiteConnection.reset();
Expand All @@ -118,18 +122,18 @@ public void reset_closesConnection() {
@Test
public void reset_clearsConnectionCache() {
final Map<Long, SQLiteConnection> connectionsMap =
ReflectionHelpers.getField(CONNECTIONS, "connectionsMap");
ReflectionHelpers.getField(connections, "connectionsMap");

assertWithMessage("connections before").that(connectionsMap).isNotEmpty();
ShadowSQLiteConnection.reset();

assertWithMessage("connections after").that(connectionsMap).isEmpty();
}

@Test
public void reset_clearsStatementCache() {
final Map<Long, SQLiteStatement> statementsMap =
ReflectionHelpers.getField(CONNECTIONS, "statementsMap");
ReflectionHelpers.getField(connections, "statementsMap");

assertWithMessage("statements before").that(statementsMap).isNotEmpty();
ShadowSQLiteConnection.reset();
Expand Down Expand Up @@ -198,7 +202,7 @@ private SQLiteConnection getSQLiteConnection() {
ShadowSQLiteConnection.nativeOpen(
databasePath.getPath(), 0, "test connection", false, false)
.longValue();
CONNECTIONS = ReflectionHelpers.getStaticField(ShadowSQLiteConnection.class, "CONNECTIONS");
return CONNECTIONS.getConnection(ptr);
connections = ReflectionHelpers.getStaticField(ShadowSQLiteConnection.class, "CONNECTIONS");
return connections.getConnection(ptr);
}
}