Skip to content

Commit

Permalink
Switch to SQLite for the test suite.
Browse files Browse the repository at this point in the history
  • Loading branch information
io7m committed Sep 1, 2024
1 parent 7a8206b commit d986a3c
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 55 deletions.
22 changes: 11 additions & 11 deletions com.io7m.trasco.tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,28 +53,28 @@

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<artifactId>junit-jupiter-api</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<artifactId>junit-jupiter-engine</artifactId>
</dependency>

<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-commons</artifactId>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derbyshared</artifactId>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-engine</artifactId>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derbytools</artifactId>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
</dependency>

<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derbynet</artifactId>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@
import com.io7m.trasco.api.TrSchemaRevisionSet;
import com.io7m.trasco.vanilla.TrExecutors;
import com.io7m.trasco.vanilla.TrSchemaRevisionSetParsers;
import org.apache.derby.jdbc.EmbeddedConnectionPoolDataSource;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.sqlite.SQLiteConfig;
import org.sqlite.SQLiteDataSource;
import org.sqlite.SQLiteOpenMode;

import java.io.IOException;
import java.io.InputStream;
Expand All @@ -54,7 +56,7 @@
public final class TrExecutorTest
{
private Path database;
private EmbeddedConnectionPoolDataSource dataSource;
private SQLiteDataSource dataSource;
private TrExecutors executors;
private TrSchemaRevisionSetParsers parsers;
private ArrayDeque<TrEventType> events;
Expand All @@ -66,10 +68,16 @@ public void setup()
this.parsers = new TrSchemaRevisionSetParsers();
this.executors = new TrExecutors();
this.database = TrTestDirectories.createTempDirectory();
this.dataSource = new EmbeddedConnectionPoolDataSource();
this.dataSource.setDatabaseName(this.database.resolve("db").toString());
this.dataSource.setCreateDatabase("true");
this.dataSource.setConnectionAttributes("create=true");

final var dbFile =
this.database.resolve("db").toString();

final var config = new SQLiteConfig();
config.setOpenMode(SQLiteOpenMode.CREATE);

this.dataSource = new SQLiteDataSource(config);
this.dataSource.setUrl("jdbc:sqlite:" + dbFile);
this.dataSource.setDatabaseName(dbFile);
this.events = new ArrayDeque<TrEventType>();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ public void testSimple()
new TrStatement(
"""
create table schema_version (
version_lock char(1) not null default 'X',
version_number bigint not null,
version_lock integer not null default 1,
version_number integer not null,
constraint check_lock_primary primary key (version_lock),
constraint check_lock_locked check (version_lock = 'X')
constraint check_lock_locked check (version_lock = 1)
)
""".trim())
)
Expand All @@ -110,7 +110,7 @@ constraint check_lock_locked check (version_lock = 'X')
List.of(new TrStatement(
"""
create table example0 (
user_id char(16) for bit data not null primary key
user_id text not null primary key
)
""".trim()
))
Expand Down
3 changes: 2 additions & 1 deletion com.io7m.trasco.tests/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@
requires org.junit.jupiter.engine;
requires org.junit.platform.commons;
requires org.junit.platform.engine;
requires org.junit.platform.launcher;

requires org.xerial.sqlitejdbc;
requires com.io7m.trasco.api;
requires com.io7m.trasco.vanilla;
requires org.apache.derby.tools;
requires org.slf4j;

exports com.io7m.trasco.tests;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@

<Statement><![CDATA[
create table schema_version (
version_lock char(1) not null default 'X',
version_number bigint not null,
version_lock integer not null default 1,
version_number integer not null,
constraint check_lock_primary primary key (version_lock),
constraint check_lock_locked check (version_lock = 'X')
constraint check_lock_locked check (version_lock = 1)
)
]]>
</Statement>
Expand All @@ -24,7 +24,7 @@ create table schema_version (
<Schema versionCurrent="1">
<Statement><![CDATA[
create table example0 (
user_id char(16) for bit data not null primary key
user_id text not null primary key
)
]]></Statement>
</Schema>
Expand Down
41 changes: 12 additions & 29 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@
<com.io7m.seltzer.version>1.1.0</com.io7m.seltzer.version>

<!-- Third-party dependencies. -->
<derby.version>10.17.1.0</derby.version>
<jqwik.version>1.9.0</jqwik.version>
<junit.version>5.11.0</junit.version>
<org.xerial.sqlite-jdbc.version>3.46.0.1</org.xerial.sqlite-jdbc.version>
<org.junit.version>5.11.0</org.junit.version>
</properties>

<licenses>
Expand Down Expand Up @@ -168,6 +169,11 @@
<artifactId>com.io7m.jlexing.core</artifactId>
<version>3.2.0</version>
</dependency>
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>${org.xerial.sqlite-jdbc.version}</version>
</dependency>

<!-- Build metadata -->
<dependency>
Expand All @@ -183,24 +189,11 @@

<!-- Test suite -->
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<version>${derby.version}</version>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derbyshared</artifactId>
<version>${derby.version}</version>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derbytools</artifactId>
<version>${derby.version}</version>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derbynet</artifactId>
<version>${derby.version}</version>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>${junit.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>net.jqwik</groupId>
Expand All @@ -212,16 +205,6 @@
<artifactId>jqwik-api</artifactId>
<version>${jqwik.version}</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit.version}</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.version}</version>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down

0 comments on commit d986a3c

Please sign in to comment.