diff --git a/com.io7m.usq.sqlite/src/main/java/com/io7m/usq/sqlite/internal/USQSQLiteCollection.java b/com.io7m.usq.sqlite/src/main/java/com/io7m/usq/sqlite/internal/USQSQLiteCollection.java index c18ad7e..fdaa688 100644 --- a/com.io7m.usq.sqlite/src/main/java/com/io7m/usq/sqlite/internal/USQSQLiteCollection.java +++ b/com.io7m.usq.sqlite/src/main/java/com/io7m/usq/sqlite/internal/USQSQLiteCollection.java @@ -197,13 +197,7 @@ private static USQSQLiteCollection connect( url.append("jdbc:sqlite:"); url.append(file); - final var config = new SQLiteConfig(); - config.setApplicationId(APPLICATION_ID); - config.enforceForeignKeys(true); - config.setJournalMode(SQLiteConfig.JournalMode.WAL); - config.setLockingMode(SQLiteConfig.LockingMode.NORMAL); - config.setSynchronous(SQLiteConfig.SynchronousMode.FULL); - + final var config = sqliteConfiguration(); final var dataSource = new SQLiteDataSource(config); dataSource.setUrl(url.toString()); return new USQSQLiteCollection(dataSource); @@ -221,13 +215,7 @@ private static void createOrUpgrade( url.append("jdbc:sqlite:"); url.append(file); - final var config = new SQLiteConfig(); - config.setApplicationId(APPLICATION_ID); - config.enforceForeignKeys(true); - config.setJournalMode(SQLiteConfig.JournalMode.WAL); - config.setLockingMode(SQLiteConfig.LockingMode.NORMAL); - config.setSynchronous(SQLiteConfig.SynchronousMode.FULL); - + final var config = sqliteConfiguration(); final var dataSource = new SQLiteDataSource(config); dataSource.setUrl(url.toString()); @@ -256,6 +244,17 @@ private static void createOrUpgrade( } } + private static SQLiteConfig sqliteConfiguration() + { + final var config = new SQLiteConfig(); + config.setApplicationId(APPLICATION_ID); + config.enforceForeignKeys(true); + config.setJournalMode(SQLiteConfig.JournalMode.WAL); + config.setLockingMode(SQLiteConfig.LockingMode.NORMAL); + config.setSynchronous(SQLiteConfig.SynchronousMode.FULL); + return config; + } + private static void publishTrEvent( final Consumer startupMessages, final TrEventType event) diff --git a/com.io7m.usq.tests/pom.xml b/com.io7m.usq.tests/pom.xml index b7add5a..0c20339 100644 --- a/com.io7m.usq.tests/pom.xml +++ b/com.io7m.usq.tests/pom.xml @@ -53,6 +53,10 @@ net.jqwik jqwik-api + + nl.jqno.equalsverifier + equalsverifier + org.slf4j diff --git a/com.io7m.usq.tests/src/main/java/com/io7m/usq/tests/USQMessageTest.java b/com.io7m.usq.tests/src/main/java/com/io7m/usq/tests/USQMessageTest.java new file mode 100644 index 0000000..d46a0f9 --- /dev/null +++ b/com.io7m.usq.tests/src/main/java/com/io7m/usq/tests/USQMessageTest.java @@ -0,0 +1,33 @@ +/* + * Copyright © 2024 Mark Raynsford https://www.io7m.com + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR + * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + +package com.io7m.usq.tests; + +import com.io7m.usq.api.USQMessage; +import nl.jqno.equalsverifier.EqualsVerifier; +import org.junit.jupiter.api.Test; + +public final class USQMessageTest +{ + @Test + public void testMessageEquals() + { + EqualsVerifier.forClass(USQMessage.class) + .withNonnullFields("id", "createdOn", "expiresOn", "metadata", "data") + .verify(); + } +} diff --git a/pom.xml b/pom.xml index 66fdc89..c24024a 100644 --- a/pom.xml +++ b/pom.xml @@ -164,6 +164,11 @@ jqwik-api ${jqwik.version} + + nl.jqno.equalsverifier + equalsverifier + 3.15.8 +