Skip to content

Commit

Permalink
update tests to extend UnitTest
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-mlb committed Oct 5, 2023
1 parent 01ad754 commit 472f7da
Show file tree
Hide file tree
Showing 13 changed files with 38 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package emissary.core.channels;

import emissary.test.core.junit5.UnitTest;

import org.junit.jupiter.api.Test;

import java.io.IOException;
Expand All @@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package emissary.core.channels;

import emissary.test.core.junit5.UnitTest;

import org.junit.jupiter.api.Test;

import java.io.IOException;
import java.util.Random;

import static org.junit.jupiter.api.Assertions.assertThrows;

class BufferedChannelFactoryTest {
class BufferedChannelFactoryTest extends UnitTest {
@Test
void testCache() throws IOException {

Expand Down
4 changes: 3 additions & 1 deletion src/test/java/emissary/core/channels/ChannelTestHelper.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package emissary.core.channels;

import emissary.test.core.junit5.UnitTest;

import org.apache.commons.io.IOUtils;

import java.io.IOException;
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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);

Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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));
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<ILoggingEvent> appender;
private final Logger logger = (Logger) LoggerFactory.getLogger(LoggingChannelFactoryTest.class);

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<ILoggingEvent> appender = null;
private final Logger logger = (Logger) LoggerFactory.getLogger(LoggingInputStreamFactoryTest.class);

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package emissary.core.channels;

import emissary.test.core.junit5.UnitTest;

import org.junit.jupiter.api.Test;

import java.io.IOException;
Expand All @@ -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];
Expand Down
5 changes: 3 additions & 2 deletions src/test/java/emissary/util/DisposeHelperTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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");
Expand All @@ -47,7 +48,7 @@ void setup() {
}

@AfterEach
void tearDown() {
public void tearDown() {
logger.detachAppender(appender);
rLogger.detachAppender(appender);
}
Expand Down

0 comments on commit 472f7da

Please sign in to comment.