Skip to content

Commit

Permalink
Mild refactoring, more tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
io7m committed Apr 27, 2024
1 parent 74b376c commit 5f82046
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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());

Expand Down Expand Up @@ -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<String> startupMessages,
final TrEventType event)
Expand Down
4 changes: 4 additions & 0 deletions com.io7m.usq.tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@
<groupId>net.jqwik</groupId>
<artifactId>jqwik-api</artifactId>
</dependency>
<dependency>
<groupId>nl.jqno.equalsverifier</groupId>
<artifactId>equalsverifier</artifactId>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright © 2024 Mark Raynsford <[email protected]> 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();
}
}
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,11 @@
<artifactId>jqwik-api</artifactId>
<version>${jqwik.version}</version>
</dependency>
<dependency>
<groupId>nl.jqno.equalsverifier</groupId>
<artifactId>equalsverifier</artifactId>
<version>3.15.8</version>
</dependency>

<!-- Logging -->
<dependency>
Expand Down

0 comments on commit 5f82046

Please sign in to comment.