From 472f7da614d2f06f0d8f29b66ffaf1631851a83b Mon Sep 17 00:00:00 2001 From: dev-mlb <19797865+dev-mlb@users.noreply.github.com> Date: Thu, 5 Oct 2023 10:54:08 -0400 Subject: [PATCH 1/2] update tests to extend UnitTest --- .../core/channels/AbstractSeekableByteChannelTest.java | 4 +++- .../emissary/core/channels/BufferedChannelFactoryTest.java | 4 +++- src/test/java/emissary/core/channels/ChannelTestHelper.java | 4 +++- .../java/emissary/core/channels/FileChannelFactoryTest.java | 4 +++- .../java/emissary/core/channels/FillChannelFactoryTest.java | 4 +++- .../emissary/core/channels/ImmutableChannelFactoryTest.java | 4 +++- .../emissary/core/channels/InMemoryChannelFactoryTest.java | 4 +++- .../core/channels/InputStreamChannelFactoryTest.java | 4 +++- .../emissary/core/channels/LoggingChannelFactoryTest.java | 4 +++- .../core/channels/LoggingInputStreamFactoryTest.java | 4 +++- .../core/channels/SeekableByteChannelHelperTest.java | 3 ++- .../emissary/core/channels/SegmentChannelFactoryTest.java | 4 +++- src/test/java/emissary/util/DisposeHelperTest.java | 5 +++-- 13 files changed, 38 insertions(+), 14 deletions(-) diff --git a/src/test/java/emissary/core/channels/AbstractSeekableByteChannelTest.java b/src/test/java/emissary/core/channels/AbstractSeekableByteChannelTest.java index 3f8c845df8..12cc1b03c5 100644 --- a/src/test/java/emissary/core/channels/AbstractSeekableByteChannelTest.java +++ b/src/test/java/emissary/core/channels/AbstractSeekableByteChannelTest.java @@ -1,5 +1,7 @@ package emissary.core.channels; +import emissary.test.core.junit5.UnitTest; + import org.junit.jupiter.api.Test; import java.io.IOException; @@ -13,7 +15,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; -class AbstractSeekableByteChannelTest { +class AbstractSeekableByteChannelTest extends UnitTest { private static class TestSeekableByteChannel extends AbstractSeekableByteChannel { private final long size; diff --git a/src/test/java/emissary/core/channels/BufferedChannelFactoryTest.java b/src/test/java/emissary/core/channels/BufferedChannelFactoryTest.java index 280ce15a6b..d236ff1d0e 100644 --- a/src/test/java/emissary/core/channels/BufferedChannelFactoryTest.java +++ b/src/test/java/emissary/core/channels/BufferedChannelFactoryTest.java @@ -1,5 +1,7 @@ package emissary.core.channels; +import emissary.test.core.junit5.UnitTest; + import org.junit.jupiter.api.Test; import java.io.IOException; @@ -7,7 +9,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows; -class BufferedChannelFactoryTest { +class BufferedChannelFactoryTest extends UnitTest { @Test void testCache() throws IOException { diff --git a/src/test/java/emissary/core/channels/ChannelTestHelper.java b/src/test/java/emissary/core/channels/ChannelTestHelper.java index ff56bec9b1..76d8347b38 100644 --- a/src/test/java/emissary/core/channels/ChannelTestHelper.java +++ b/src/test/java/emissary/core/channels/ChannelTestHelper.java @@ -1,5 +1,7 @@ package emissary.core.channels; +import emissary.test.core.junit5.UnitTest; + import org.apache.commons.io.IOUtils; import java.io.IOException; @@ -10,7 +12,7 @@ import static org.junit.jupiter.api.Assertions.assertArrayEquals; import static org.junit.jupiter.api.Assertions.assertEquals; -public class ChannelTestHelper { +public class ChannelTestHelper extends UnitTest { private ChannelTestHelper() {}; public static void checkByteArrayAgainstSbc(final byte[] bytesToVerify, final SeekableByteChannelFactory sbcf) diff --git a/src/test/java/emissary/core/channels/FileChannelFactoryTest.java b/src/test/java/emissary/core/channels/FileChannelFactoryTest.java index e174e8a7b0..e41e458a49 100644 --- a/src/test/java/emissary/core/channels/FileChannelFactoryTest.java +++ b/src/test/java/emissary/core/channels/FileChannelFactoryTest.java @@ -1,5 +1,7 @@ package emissary.core.channels; +import emissary.test.core.junit5.UnitTest; + import com.google.common.io.Files; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -17,7 +19,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; -class FileChannelFactoryTest { +class FileChannelFactoryTest extends UnitTest { private static final String TEST_STRING = "test data"; private static final byte[] TEST_BYTES = TEST_STRING.getBytes(StandardCharsets.US_ASCII); diff --git a/src/test/java/emissary/core/channels/FillChannelFactoryTest.java b/src/test/java/emissary/core/channels/FillChannelFactoryTest.java index c8b0bf8da4..24a9460e76 100644 --- a/src/test/java/emissary/core/channels/FillChannelFactoryTest.java +++ b/src/test/java/emissary/core/channels/FillChannelFactoryTest.java @@ -1,5 +1,7 @@ package emissary.core.channels; +import emissary.test.core.junit5.UnitTest; + import org.apache.commons.io.IOUtils; import org.junit.jupiter.api.Test; @@ -12,7 +14,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; -class FillChannelFactoryTest { +class FillChannelFactoryTest extends UnitTest { @Test void testCreate() { assertThrows(IllegalArgumentException.class, () -> FillChannelFactory.create(-1, (byte) 0)); diff --git a/src/test/java/emissary/core/channels/ImmutableChannelFactoryTest.java b/src/test/java/emissary/core/channels/ImmutableChannelFactoryTest.java index 89044be025..bfb52619aa 100644 --- a/src/test/java/emissary/core/channels/ImmutableChannelFactoryTest.java +++ b/src/test/java/emissary/core/channels/ImmutableChannelFactoryTest.java @@ -1,5 +1,7 @@ package emissary.core.channels; +import emissary.test.core.junit5.UnitTest; + import org.apache.commons.compress.utils.SeekableInMemoryByteChannel; import org.junit.jupiter.api.Test; @@ -13,7 +15,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; -class ImmutableChannelFactoryTest { +class ImmutableChannelFactoryTest extends UnitTest { private static final String TEST_STRING = "Test data"; @Test diff --git a/src/test/java/emissary/core/channels/InMemoryChannelFactoryTest.java b/src/test/java/emissary/core/channels/InMemoryChannelFactoryTest.java index 59daec99a6..fefcf3f845 100644 --- a/src/test/java/emissary/core/channels/InMemoryChannelFactoryTest.java +++ b/src/test/java/emissary/core/channels/InMemoryChannelFactoryTest.java @@ -1,5 +1,7 @@ package emissary.core.channels; +import emissary.test.core.junit5.UnitTest; + import org.apache.commons.compress.utils.SeekableInMemoryByteChannel; import org.junit.jupiter.api.Test; @@ -11,7 +13,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; -class InMemoryChannelFactoryTest { +class InMemoryChannelFactoryTest extends UnitTest { @Test void testCannotCreateFactoryWithNullByteArray() { diff --git a/src/test/java/emissary/core/channels/InputStreamChannelFactoryTest.java b/src/test/java/emissary/core/channels/InputStreamChannelFactoryTest.java index 6d7715e535..1fc530d32b 100644 --- a/src/test/java/emissary/core/channels/InputStreamChannelFactoryTest.java +++ b/src/test/java/emissary/core/channels/InputStreamChannelFactoryTest.java @@ -1,5 +1,7 @@ package emissary.core.channels; +import emissary.test.core.junit5.UnitTest; + import org.apache.commons.io.IOUtils; import org.junit.jupiter.api.Test; @@ -15,7 +17,7 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertThrows; -class InputStreamChannelFactoryTest { +class InputStreamChannelFactoryTest extends UnitTest { private static class TestInputStreamFactory implements InputStreamFactory { private final byte[] bytes; diff --git a/src/test/java/emissary/core/channels/LoggingChannelFactoryTest.java b/src/test/java/emissary/core/channels/LoggingChannelFactoryTest.java index 7bbff7f7b8..288df88326 100644 --- a/src/test/java/emissary/core/channels/LoggingChannelFactoryTest.java +++ b/src/test/java/emissary/core/channels/LoggingChannelFactoryTest.java @@ -1,5 +1,7 @@ package emissary.core.channels; +import emissary.test.core.junit5.UnitTest; + import ch.qos.logback.classic.Logger; import ch.qos.logback.classic.spi.ILoggingEvent; import ch.qos.logback.classic.spi.IThrowableProxy; @@ -22,7 +24,7 @@ import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue; -class LoggingChannelFactoryTest { +class LoggingChannelFactoryTest extends UnitTest { private ListAppender appender; private final Logger logger = (Logger) LoggerFactory.getLogger(LoggingChannelFactoryTest.class); diff --git a/src/test/java/emissary/core/channels/LoggingInputStreamFactoryTest.java b/src/test/java/emissary/core/channels/LoggingInputStreamFactoryTest.java index 7c85a5dda0..aae33470c8 100644 --- a/src/test/java/emissary/core/channels/LoggingInputStreamFactoryTest.java +++ b/src/test/java/emissary/core/channels/LoggingInputStreamFactoryTest.java @@ -1,5 +1,7 @@ package emissary.core.channels; +import emissary.test.core.junit5.UnitTest; + import ch.qos.logback.classic.Logger; import ch.qos.logback.classic.spi.ILoggingEvent; import ch.qos.logback.classic.spi.IThrowableProxy; @@ -20,7 +22,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; -class LoggingInputStreamFactoryTest { +class LoggingInputStreamFactoryTest extends UnitTest { private ListAppender appender = null; private final Logger logger = (Logger) LoggerFactory.getLogger(LoggingInputStreamFactoryTest.class); diff --git a/src/test/java/emissary/core/channels/SeekableByteChannelHelperTest.java b/src/test/java/emissary/core/channels/SeekableByteChannelHelperTest.java index cc83432237..240c7701f2 100644 --- a/src/test/java/emissary/core/channels/SeekableByteChannelHelperTest.java +++ b/src/test/java/emissary/core/channels/SeekableByteChannelHelperTest.java @@ -1,6 +1,7 @@ package emissary.core.channels; import emissary.core.BaseDataObject; +import emissary.test.core.junit5.UnitTest; import ch.qos.logback.classic.Level; import ch.qos.logback.classic.Logger; @@ -27,7 +28,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; -class SeekableByteChannelHelperTest { +class SeekableByteChannelHelperTest extends UnitTest { private static final String TEST_STRING = "test data"; private static final byte[] TEST_BYTES = TEST_STRING.getBytes(StandardCharsets.US_ASCII); diff --git a/src/test/java/emissary/core/channels/SegmentChannelFactoryTest.java b/src/test/java/emissary/core/channels/SegmentChannelFactoryTest.java index 72c00c495d..af0f69b980 100644 --- a/src/test/java/emissary/core/channels/SegmentChannelFactoryTest.java +++ b/src/test/java/emissary/core/channels/SegmentChannelFactoryTest.java @@ -1,5 +1,7 @@ package emissary.core.channels; +import emissary.test.core.junit5.UnitTest; + import org.junit.jupiter.api.Test; import java.io.IOException; @@ -10,7 +12,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows; -class SegmentChannelFactoryTest { +class SegmentChannelFactoryTest extends UnitTest { @Test void testCreate() throws IOException { final byte[] bytes = new byte[10]; diff --git a/src/test/java/emissary/util/DisposeHelperTest.java b/src/test/java/emissary/util/DisposeHelperTest.java index 49c46f50d6..bace960a87 100644 --- a/src/test/java/emissary/util/DisposeHelperTest.java +++ b/src/test/java/emissary/util/DisposeHelperTest.java @@ -2,6 +2,7 @@ import emissary.core.BaseDataObject; import emissary.core.IBaseDataObject; +import emissary.test.core.junit5.UnitTest; import ch.qos.logback.classic.Level; import ch.qos.logback.classic.Logger; @@ -20,7 +21,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; -class DisposeHelperTest { +class DisposeHelperTest extends UnitTest { private static final Runnable FIRST = () -> LoggerFactory.getLogger("DisposeHelperRunnable").warn("DisposeHelperTestFirstRunnable"); private static final Runnable SECOND = () -> LoggerFactory.getLogger("DisposeHelperRunnable").warn("DisposeHelperTestSecondRunnable"); @@ -47,7 +48,7 @@ void setup() { } @AfterEach - void tearDown() { + public void tearDown() { logger.detachAppender(appender); rLogger.detachAppender(appender); } From bcd0682e4552f8a9d2aa96bdc1d76e94a9dbfd52 Mon Sep 17 00:00:00 2001 From: dev-mlb <19797865+dev-mlb@users.noreply.github.com> Date: Sat, 7 Oct 2023 08:05:45 -0400 Subject: [PATCH 2/2] pr updates --- src/test/java/emissary/core/channels/ChannelTestHelper.java | 4 +--- src/test/java/emissary/util/DisposeHelperTest.java | 5 ++--- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/test/java/emissary/core/channels/ChannelTestHelper.java b/src/test/java/emissary/core/channels/ChannelTestHelper.java index 76d8347b38..ff56bec9b1 100644 --- a/src/test/java/emissary/core/channels/ChannelTestHelper.java +++ b/src/test/java/emissary/core/channels/ChannelTestHelper.java @@ -1,7 +1,5 @@ package emissary.core.channels; -import emissary.test.core.junit5.UnitTest; - import org.apache.commons.io.IOUtils; import java.io.IOException; @@ -12,7 +10,7 @@ import static org.junit.jupiter.api.Assertions.assertArrayEquals; import static org.junit.jupiter.api.Assertions.assertEquals; -public class ChannelTestHelper extends UnitTest { +public class ChannelTestHelper { private ChannelTestHelper() {}; public static void checkByteArrayAgainstSbc(final byte[] bytesToVerify, final SeekableByteChannelFactory sbcf) diff --git a/src/test/java/emissary/util/DisposeHelperTest.java b/src/test/java/emissary/util/DisposeHelperTest.java index bace960a87..cc6b43d2b2 100644 --- a/src/test/java/emissary/util/DisposeHelperTest.java +++ b/src/test/java/emissary/util/DisposeHelperTest.java @@ -2,7 +2,6 @@ import emissary.core.BaseDataObject; import emissary.core.IBaseDataObject; -import emissary.test.core.junit5.UnitTest; import ch.qos.logback.classic.Level; import ch.qos.logback.classic.Logger; @@ -21,7 +20,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; -class DisposeHelperTest extends UnitTest { +class DisposeHelperTest { private static final Runnable FIRST = () -> LoggerFactory.getLogger("DisposeHelperRunnable").warn("DisposeHelperTestFirstRunnable"); private static final Runnable SECOND = () -> LoggerFactory.getLogger("DisposeHelperRunnable").warn("DisposeHelperTestSecondRunnable"); @@ -48,7 +47,7 @@ void setup() { } @AfterEach - public void tearDown() { + void detach() { logger.detachAppender(appender); rLogger.detachAppender(appender); }