Skip to content

Commit

Permalink
Use specific Exceptions in unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
spannm committed Jul 4, 2024
1 parent 8639218 commit dc85f8c
Show file tree
Hide file tree
Showing 36 changed files with 238 additions and 220 deletions.
5 changes: 3 additions & 2 deletions src/test/java/io/github/spannm/jackcess/BigIndexTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import io.github.spannm.jackcess.test.source.TestDbSource;
import org.junit.jupiter.params.ParameterizedTest;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
Expand All @@ -36,7 +37,7 @@ class BigIndexTest extends AbstractBaseTest {

@ParameterizedTest(name = "[{index}] {0}")
@TestDbReadOnlySource(COMP_INDEX)
void testComplexIndex(TestDb testDb) throws Exception {
void testComplexIndex(TestDb testDb) throws IOException {
try (// this file has an index with "compressed" entries and node pages
Database db = testDb.openMem()) {
TableImpl t = (TableImpl) db.getTable("Table1");
Expand All @@ -49,7 +50,7 @@ void testComplexIndex(TestDb testDb) throws Exception {

@ParameterizedTest(name = "[{index}] {0}")
@TestDbSource(BIG_INDEX)
void testBigIndex(TestDb testDb) throws Exception {
void testBigIndex(TestDb testDb) throws IOException {
// this file has an index with "compressed" entries and node pages
try (Database db = testDb.openMem()) {
TableImpl t = (TableImpl) db.getTable("Table1");
Expand Down
17 changes: 9 additions & 8 deletions src/test/java/io/github/spannm/jackcess/ComplexColumnTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import io.github.spannm.jackcess.test.source.TestDbSource;
import org.junit.jupiter.params.ParameterizedTest;

import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.util.Date;
Expand Down Expand Up @@ -57,7 +58,7 @@ class ComplexColumnTest extends AbstractBaseTest {

@ParameterizedTest(name = "[{index}] {0}")
@TestDbSource(COMPLEX_DATA)
void testVersions(TestDb testDb) throws Exception {
void testVersions(TestDb testDb) throws IOException {
try (Database db = testDb.openCopy()) {
db.setDateTimeType(DateTimeType.DATE);
db.setTimeZone(TEST_TZ);
Expand Down Expand Up @@ -143,7 +144,7 @@ void testVersions(TestDb testDb) throws Exception {

@ParameterizedTest(name = "[{index}] {0}")
@TestDbSource(COMPLEX_DATA)
void testAttachments(TestDb testDb) throws Exception {
void testAttachments(TestDb testDb) throws IOException {
try (Database db = testDb.openCopy()) {
Table t1 = db.getTable("Table1");
Column col = t1.getColumn("attach-data");
Expand Down Expand Up @@ -221,7 +222,7 @@ void testAttachments(TestDb testDb) throws Exception {

@ParameterizedTest(name = "[{index}] {0}")
@TestDbSource(COMPLEX_DATA)
void testMultiValues(TestDb testDb) throws Exception {
void testMultiValues(TestDb testDb) throws IOException {
try (Database db = testDb.openCopy()) {
Table t1 = db.getTable("Table1");
Column col = t1.getColumn("multi-value-data");
Expand Down Expand Up @@ -291,7 +292,7 @@ void testMultiValues(TestDb testDb) throws Exception {

@ParameterizedTest(name = "[{index}] {0}")
@TestDbSource(UNSUPPORTED_FIELDS)
void testUnsupported(TestDb testDb) throws Exception {
void testUnsupported(TestDb testDb) throws IOException {
try (Database db = testDb.openCopy()) {
Table t1 = db.getTable("Test");
Column col = t1.getColumn("UnknownComplex");
Expand Down Expand Up @@ -319,7 +320,7 @@ void testUnsupported(TestDb testDb) throws Exception {

private static void checkVersions(
int cValId, ComplexValueForeignKey complexValueFk,
String curValue, Object... versionInfos) throws Exception {
String curValue, Object... versionInfos) throws IOException {
assertEquals(cValId, complexValueFk.get());

List<Version> versions = complexValueFk.getVersions();
Expand All @@ -341,7 +342,7 @@ private static void checkVersions(

private static void checkAttachments(
int cValId, ComplexValueForeignKey complexValueFk,
String... fileNames) throws Exception {
String... fileNames) throws IOException {
assertEquals(cValId, complexValueFk.get());

List<Attachment> attachments = complexValueFk.getAttachments();
Expand All @@ -362,7 +363,7 @@ private static void checkAttachments(

private static void checkMultiValues(
int cValId, ComplexValueForeignKey complexValueFk,
Object... expectedValues) throws Exception {
Object... expectedValues) throws IOException {
assertEquals(cValId, complexValueFk.get());

List<SingleValue> values = complexValueFk.getMultiValues();
Expand All @@ -380,7 +381,7 @@ private static void checkMultiValues(

private static void checkUnsupportedValues(
int cValId, ComplexValueForeignKey complexValueFk,
String... expectedValues) throws Exception {
String... expectedValues) throws IOException {
assertEquals(cValId, complexValueFk.get());

List<UnsupportedValue> values = complexValueFk.getUnsupportedValues();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@
import io.github.spannm.jackcess.test.source.TestDbSource;
import org.junit.jupiter.params.ParameterizedTest;

import java.io.IOException;

class CursorBuilderTest extends AbstractBaseTest {

@ParameterizedTest(name = "[{index}] {0}")
@TestDbSource(INDEX_CURSOR)
void test(TestDb testDb) throws Exception {
void test(TestDb testDb) throws IOException {
try (Database db = CursorTest.createTestIndexTable(testDb)) {
Table table = db.getTable("test");
IndexImpl idx = (IndexImpl) table.getIndexes().get(0);
Expand Down
Loading

0 comments on commit dc85f8c

Please sign in to comment.