Skip to content

Commit

Permalink
Fix error in the tests after the merge conflict resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
Destrolaric committed Apr 18, 2023
1 parent 79fa812 commit 469887c
Showing 1 changed file with 56 additions and 5 deletions.
61 changes: 56 additions & 5 deletions src/test/java/org/sqlite/DBMetaDataTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
import java.util.Map;
import java.util.Properties;
import org.junit.jupiter.api.*;
import org.junit.jupiter.api.condition.DisabledInNativeImage;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;

/** These tests are designed to stress Statements on memory databases. */
public class DBMetaDataTest {
Expand Down Expand Up @@ -417,7 +420,21 @@ public void getColumns() throws SQLException {
assertThat(rs.next()).isFalse();

rs = meta.getColumns(null, null, "%", "%");
// SYSTEM TABLE "sqlite_schema"

// SYSTEM TABLE "sqlite_schema" for main
assertThat(rs.next()).isTrue();
assertThat(rs.getString("TABLE_NAME")).isEqualTo("sqlite_schema");
assertThat(rs.getString("COLUMN_NAME")).isEqualTo("type");
assertThat(rs.next()).isTrue();
assertThat(rs.getString("COLUMN_NAME")).isEqualTo("name");
assertThat(rs.next()).isTrue();
assertThat(rs.getString("COLUMN_NAME")).isEqualTo("tbl_name");
assertThat(rs.next()).isTrue();
assertThat(rs.getString("COLUMN_NAME")).isEqualTo("rootpage");
assertThat(rs.next()).isTrue();
assertThat(rs.getString("COLUMN_NAME")).isEqualTo("sql");

// SYSTEM TABLE "sqlite_schema" for temp
assertThat(rs.next()).isTrue();
assertThat(rs.getString("TABLE_NAME")).isEqualTo("sqlite_schema");
assertThat(rs.getString("COLUMN_NAME")).isEqualTo("type");
Expand All @@ -429,6 +446,7 @@ public void getColumns() throws SQLException {
assertThat(rs.getString("COLUMN_NAME")).isEqualTo("rootpage");
assertThat(rs.next()).isTrue();
assertThat(rs.getString("COLUMN_NAME")).isEqualTo("sql");

// TABLE "test"
assertThat(rs.next()).isTrue();
assertThat(rs.getString("TABLE_NAME")).isEqualTo("test");
Expand Down Expand Up @@ -2041,8 +2059,19 @@ public void getColumnsForAttachedDatabaseTables() throws SQLException {
assertThat(rs.next()).isFalse();
rs.close();


rs = meta.getColumns(null, "db2", "%", "%");
assertThat(rs.next()).isTrue();
assertThat(rs.getString("TABLE_NAME")).isEqualTo("sqlite_schema");
assertThat(rs.getString("COLUMN_NAME")).isEqualTo("type");
assertThat(rs.next()).isTrue();
assertThat(rs.getString("COLUMN_NAME")).isEqualTo("name");
assertThat(rs.next()).isTrue();
assertThat(rs.getString("COLUMN_NAME")).isEqualTo("tbl_name");
assertThat(rs.next()).isTrue();
assertThat(rs.getString("COLUMN_NAME")).isEqualTo("rootpage");
assertThat(rs.next()).isTrue();
assertThat(rs.getString("COLUMN_NAME")).isEqualTo("sql");

// TABLE "test2"
assertThat(rs.next()).isTrue();
assertThat(rs.getString("TABLE_NAME")).isEqualTo("test2");
Expand Down Expand Up @@ -2077,14 +2106,18 @@ public void getColumnsForAttachedDatabaseTables() throws SQLException {


rs = meta.getColumns(null, null, "%", "%");
assertReadsAllColumns(rs);
assertReadsAllColumns(rs, 3);
rs = meta.getColumns(null, "%", "%", "%");
assertReadsAllColumns(rs);
assertReadsAllColumns(rs, 3);
rs = meta.getColumns(null, "\\%", "%", "%");
assertThat(rs.next()).isFalse();
}

private void assertReadsAllColumns(ResultSet rs) throws SQLException {
private void assertReadsAllColumns(ResultSet rs, int schemasNumber) throws SQLException {
for (int i = 0; i < schemasNumber; i++) {
// When full pattern used we acquire system table for each individual schema
assertSystemSchema(rs);
}
// TABLE "test"
assertThat(rs.next()).isTrue();
assertThat(rs.getString("TABLE_NAME")).isEqualTo("test");
Expand All @@ -2097,6 +2130,8 @@ private void assertReadsAllColumns(ResultSet rs) throws SQLException {
assertThat(rs.getString("COLUMN_NAME")).isEqualTo("intvalue");
assertThat(rs.next()).isTrue();
assertThat(rs.getString("COLUMN_NAME")).isEqualTo("realvalue");
assertThat(rs.next()).isTrue();
assertThat(rs.getString("COLUMN_NAME")).isEqualTo("charvalue");
// TABLE "test2"
assertThat(rs.next()).isTrue();
assertThat(rs.getString("TABLE_NAME")).isEqualTo("test2");
Expand All @@ -2121,6 +2156,8 @@ private void assertReadsAllColumns(ResultSet rs) throws SQLException {
assertThat(rs.getString("COLUMN_NAME")).isEqualTo("intvalue");
assertThat(rs.next()).isTrue();
assertThat(rs.getString("COLUMN_NAME")).isEqualTo("realvalue");
assertThat(rs.next()).isTrue();
assertThat(rs.getString("COLUMN_NAME")).isEqualTo("charvalue");
// VIEW "testView2"
assertThat(rs.next()).isTrue();
assertThat(rs.getString("TABLE_NAME")).isEqualTo("testView2");
Expand Down Expand Up @@ -2241,4 +2278,18 @@ public void exit() throws SQLException {
testDB.deleteOnExit();
}
}

private void assertSystemSchema(ResultSet rs) throws SQLException {
assertThat(rs.next()).isTrue();
assertThat(rs.getString("TABLE_NAME")).isEqualTo("sqlite_schema");
assertThat(rs.getString("COLUMN_NAME")).isEqualTo("type");
assertThat(rs.next()).isTrue();
assertThat(rs.getString("COLUMN_NAME")).isEqualTo("name");
assertThat(rs.next()).isTrue();
assertThat(rs.getString("COLUMN_NAME")).isEqualTo("tbl_name");
assertThat(rs.next()).isTrue();
assertThat(rs.getString("COLUMN_NAME")).isEqualTo("rootpage");
assertThat(rs.next()).isTrue();
assertThat(rs.getString("COLUMN_NAME")).isEqualTo("sql");
}
}

0 comments on commit 469887c

Please sign in to comment.