diff --git a/common/common-image/src/test/java/com/twelvemonkeys/image/AffineTransformOpTest.java b/common/common-image/src/test/java/com/twelvemonkeys/image/AffineTransformOpTest.java
index 057dabb9..93d99a8a 100644
--- a/common/common-image/src/test/java/com/twelvemonkeys/image/AffineTransformOpTest.java
+++ b/common/common-image/src/test/java/com/twelvemonkeys/image/AffineTransformOpTest.java
@@ -31,9 +31,7 @@
package com.twelvemonkeys.image;
import static java.lang.Math.min;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.*;
import java.awt.color.ColorSpace;
import java.awt.geom.AffineTransform;
@@ -49,7 +47,7 @@ import java.util.List;
import javax.imageio.ImageTypeSpecifier;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* AffineTransformOpTest.
@@ -146,12 +144,12 @@ public class AffineTransformOpTest {
BufferedImage jreResult = jreOp.filter(image, null);
BufferedImage tmResult = tmOp.filter(image, null);
- assertNotNull("No result!", tmResult);
- assertEquals("Bad type", jreResult.getType(), tmResult.getType());
- assertEquals("Incorrect color model", jreResult.getColorModel(), tmResult.getColorModel());
+ assertNotNull(tmResult, "No result!");
+ assertEquals(jreResult.getType(), tmResult.getType(), "Bad type");
+ assertEquals(jreResult.getColorModel(), tmResult.getColorModel(), "Incorrect color model");
- assertEquals("Incorrect width", jreResult.getWidth(), tmResult.getWidth());
- assertEquals("Incorrect height", jreResult.getHeight(), tmResult.getHeight());
+ assertEquals(jreResult.getWidth(), tmResult.getWidth(), "Incorrect width");
+ assertEquals(jreResult.getHeight(), tmResult.getHeight(), "Incorrect height");
}
}
@@ -164,7 +162,7 @@ public class AffineTransformOpTest {
BufferedImage image = spec.createBufferedImage(width, height);
BufferedImage tmResult = tmOp.filter(image, null);
- assertNotNull("No result!", tmResult);
+ assertNotNull(tmResult, "No result!");
BufferedImage jreResult = null;
@@ -176,18 +174,18 @@ public class AffineTransformOpTest {
}
if (jreResult != null) {
- assertEquals("Bad type", jreResult.getType(), tmResult.getType());
- assertEquals("Incorrect color model", jreResult.getColorModel(), tmResult.getColorModel());
+ assertEquals(jreResult.getType(), tmResult.getType(), "Bad type");
+ assertEquals(jreResult.getColorModel(), tmResult.getColorModel(), "Incorrect color model");
- assertEquals("Incorrect width", jreResult.getWidth(), tmResult.getWidth());
- assertEquals("Incorrect height", jreResult.getHeight(), tmResult.getHeight());
+ assertEquals(jreResult.getWidth(), tmResult.getWidth(), "Incorrect width");
+ assertEquals(jreResult.getHeight(), tmResult.getHeight(), "Incorrect height");
}
else {
- assertEquals("Bad type", spec.getBufferedImageType(), tmResult.getType());
- assertEquals("Incorrect color model", spec.getColorModel(), tmResult.getColorModel());
+ assertEquals(spec.getBufferedImageType(), tmResult.getType(), "Bad type");
+ assertEquals(spec.getColorModel(), tmResult.getColorModel(), "Incorrect color model");
- assertEquals("Incorrect width", height, tmResult.getWidth());
- assertEquals("Incorrect height", width, tmResult.getHeight());
+ assertEquals(height, tmResult.getWidth(), "Incorrect width");
+ assertEquals(width, tmResult.getHeight(), "Incorrect height");
}
}
}
@@ -236,12 +234,12 @@ public class AffineTransformOpTest {
}
if (jreResult != null) {
- assertEquals("Incorrect width", jreResult.getWidth(), tmResult.getWidth());
- assertEquals("Incorrect height", jreResult.getHeight(), tmResult.getHeight());
+ assertEquals(jreResult.getWidth(), tmResult.getWidth(), "Incorrect width");
+ assertEquals(jreResult.getHeight(), tmResult.getHeight(), "Incorrect height");
}
else {
- assertEquals("Incorrect width", height, tmResult.getWidth());
- assertEquals("Incorrect height", width, tmResult.getHeight());
+ assertEquals(height, tmResult.getWidth(), "Incorrect width");
+ assertEquals(width, tmResult.getHeight(), "Incorrect height");
}
}
}
@@ -277,12 +275,12 @@ public class AffineTransformOpTest {
}
if (jreResult != null) {
- assertEquals("Incorrect width", jreResult.getWidth(), tmResult.getWidth());
- assertEquals("Incorrect height", jreResult.getHeight(), tmResult.getHeight());
+ assertEquals(jreResult.getWidth(), tmResult.getWidth(), "Incorrect width");
+ assertEquals(jreResult.getHeight(), tmResult.getHeight(), "Incorrect height");
}
else {
- assertEquals("Incorrect width", height, tmResult.getWidth());
- assertEquals("Incorrect height", width, tmResult.getHeight());
+ assertEquals(height, tmResult.getWidth(), "Incorrect width");
+ assertEquals(width, tmResult.getHeight(), "Incorrect height");
}
}
}
diff --git a/common/common-image/src/test/java/com/twelvemonkeys/image/BufferedImageFactoryTest.java b/common/common-image/src/test/java/com/twelvemonkeys/image/BufferedImageFactoryTest.java
index 4bb5d00a..f3f3c900 100644
--- a/common/common-image/src/test/java/com/twelvemonkeys/image/BufferedImageFactoryTest.java
+++ b/common/common-image/src/test/java/com/twelvemonkeys/image/BufferedImageFactoryTest.java
@@ -30,17 +30,16 @@
package com.twelvemonkeys.image;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
import java.awt.*;
import java.awt.color.*;
import java.awt.image.*;
import java.net.URL;
+import java.time.Duration;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
/**
* BufferedImageFactoryTestCase
@@ -50,50 +49,58 @@ import static org.junit.Assert.assertTrue;
* @version $Id: BufferedImageFactoryTestCase.java,v 1.0 May 7, 2010 12:40:08 PM haraldk Exp$
*/
public class BufferedImageFactoryTest {
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testCreateNullImage() {
- new BufferedImageFactory((Image) null);
+ assertThrows(IllegalArgumentException.class, () -> {
+ new BufferedImageFactory((Image) null);
+ });
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testCreateNullProducer() {
- new BufferedImageFactory((ImageProducer) null);
+ assertThrows(IllegalArgumentException.class, () -> {
+ new BufferedImageFactory((ImageProducer) null);
+ });
}
// NPE in Toolkit, ok
- @Test(expected = RuntimeException.class)
+ @Test
public void testGetBufferedImageErrorSourceByteArray() {
- Image source = Toolkit.getDefaultToolkit().createImage((byte[]) null);
-
- new BufferedImageFactory(source);
+ assertThrows(RuntimeException.class, () -> {
+ Image source = Toolkit.getDefaultToolkit().createImage((byte[]) null);
+ new BufferedImageFactory(source);
+ });
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testGetBufferedImageErrorSourceImageProducer() {
Image source = Toolkit.getDefaultToolkit().createImage((ImageProducer) null);
-
- new BufferedImageFactory(source);
+ assertThrows(IllegalArgumentException.class, () -> {
+ new BufferedImageFactory(source);
+ });
}
// TODO: This is a quite serious bug, however, the bug is in the Toolkit, allowing such images in the first place...
// In any case, there's not much we can do, except until someone is bored and kills the app/thread... :-P
- @Ignore("Bug in Toolkit")
- @Test(timeout = 1000, expected = ImageConversionException.class)
+ @Disabled("Bug in Toolkit")
+ @Test
public void testGetBufferedImageErrorSourceString() {
- Image source = Toolkit.getDefaultToolkit().createImage((String) null);
-
- BufferedImageFactory factory = new BufferedImageFactory(source);
- factory.getBufferedImage();
+ assertTimeoutPreemptively(Duration.ofMillis(1000), () -> {
+ Image source = Toolkit.getDefaultToolkit().createImage((String) null);
+ BufferedImageFactory factory = new BufferedImageFactory(source);
+ assertThrows(ImageConversionException.class, factory::getBufferedImage);
+ });
}
// This is a little random, and it would be nicer if we could throw an IllegalArgumentException on create.
// Unfortunately, the API doesn't allow this...
- @Test(timeout = 1000, expected = ImageConversionException.class)
+ @Test
public void testGetBufferedImageErrorSourceURL() {
- Image source = Toolkit.getDefaultToolkit().createImage(getClass().getResource("/META-INF/MANIFEST.MF"));
-
- BufferedImageFactory factory = new BufferedImageFactory(source);
- factory.getBufferedImage();
+ assertTimeoutPreemptively(Duration.ofMillis(1000), () -> {
+ Image source = Toolkit.getDefaultToolkit().createImage((String) null);
+ BufferedImageFactory factory = new BufferedImageFactory(source);
+ assertThrows(ImageConversionException.class, factory::getBufferedImage);
+ });
}
@Test
@@ -165,7 +172,7 @@ public class BufferedImageFactoryTest {
assertEquals(3, colorModel.getNumColorComponents());
assertEquals(ColorSpace.getInstance(ColorSpace.CS_sRGB), colorModel.getColorSpace());
- assertTrue(colorModel instanceof IndexColorModel);
+ assertInstanceOf(IndexColorModel.class, colorModel);
assertTrue(colorModel.hasAlpha());
assertEquals(4, colorModel.getNumComponents());
@@ -196,7 +203,7 @@ public class BufferedImageFactoryTest {
for (int y = 0; y < image.getHeight(); y++) {
for (int x = 0; x < image.getWidth(); x++) {
- assertEquals("RGB[" + x + ", " + y + "]", original.getRGB(x * 2, y * 2), image.getRGB(x, y));
+ assertEquals(original.getRGB(x * 2, y * 2), image.getRGB(x, y), "RGB[" + x + ", " + y + "]");
}
}
}
@@ -219,7 +226,7 @@ public class BufferedImageFactoryTest {
for (int y = 0; y < image.getHeight(); y++) {
for (int x = 0; x < image.getWidth(); x++) {
- assertEquals("RGB[" + x + ", " + y + "]", original.getRGB(40 + x, 40 + y), image.getRGB(x, y));
+ assertEquals(original.getRGB(40 + x, 40 + y), image.getRGB(x, y), "RGB[" + x + ", " + y + "]");
}
}
}
@@ -243,7 +250,7 @@ public class BufferedImageFactoryTest {
for (int y = 0; y < image.getHeight(); y++) {
for (int x = 0; x < image.getWidth(); x++) {
- assertEquals("RGB[" + x + ", " + y + "]", original.getRGB(40 + x * 2, 40 + y * 2), image.getRGB(x, y));
+ assertEquals(original.getRGB(40 + x * 2, 40 + y * 2), image.getRGB(x, y), "RGB[" + x + ", " + y + "]");
}
}
}
diff --git a/common/common-image/src/test/java/com/twelvemonkeys/image/ImageUtilTest.java b/common/common-image/src/test/java/com/twelvemonkeys/image/ImageUtilTest.java
index 7c14be3a..14b032ce 100755
--- a/common/common-image/src/test/java/com/twelvemonkeys/image/ImageUtilTest.java
+++ b/common/common-image/src/test/java/com/twelvemonkeys/image/ImageUtilTest.java
@@ -30,7 +30,7 @@
package com.twelvemonkeys.image;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import javax.imageio.ImageIO;
import java.awt.*;
@@ -39,7 +39,7 @@ import java.awt.image.IndexColorModel;
import java.awt.image.RenderedImage;
import java.io.InputStream;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
public class ImageUtilTest {
@@ -116,8 +116,8 @@ public class ImageUtilTest {
public void testImageIsNotBufferedImage() {
// Should not be a buffered image
assertFalse(
- "FOR SOME IMPLEMENTATIONS THIS MIGHT FAIL!\nIn that case, testToBufferedImage() will fail too.",
- scaled instanceof BufferedImage
+ scaled instanceof BufferedImage,
+ "FOR SOME IMPLEMENTATIONS THIS MIGHT FAIL!\nIn that case, testToBufferedImage() will fail too."
);
}
@@ -247,7 +247,7 @@ public class ImageUtilTest {
if (original != notContrasted) { // Don't care to test if images are same
for (int y = 0; y < original.getHeight(); y++) {
for (int x = 0; x < original.getWidth(); x++) {
- assertEquals("0 constrast should not change image", original.getRGB(x, y), notContrasted.getRGB(x, y));
+ assertEquals(original.getRGB(x, y), notContrasted.getRGB(x, y), "0 constrast should not change image");
}
}
}
@@ -275,24 +275,24 @@ public class ImageUtilTest {
// RED
if (oR < 127) {
- assertTrue("Contrast should be decreased or same", oR >= cR && cR >= dR);
+ assertTrue(oR >= cR && cR >= dR, "Contrast should be decreased or same");
}
else {
- assertTrue("Contrast should be increased or same", oR <= cR && cR <= dR);
+ assertTrue(oR <= cR && cR <= dR, "Contrast should be increased or same");
}
// GREEN
if (oG < 127) {
- assertTrue("Contrast should be decreased or same", oG >= cG && cG >= dG);
+ assertTrue(oG >= cG && cG >= dG, "Contrast should be decreased or same");
}
else {
- assertTrue("Contrast should be increased or same", oG <= cG && cG <= dG);
+ assertTrue(oG <= cG && cG <= dG, "Contrast should be increased or same");
}
// BLUE
if (oB < 127) {
- assertTrue("Contrast should be decreased or same", oB >= cB && cB >= dB);
+ assertTrue(oB >= cB && cB >= dB, "Contrast should be decreased or same");
}
else {
- assertTrue("Contrast should be increased or same", oB <= cB && cB <= dB);
+ assertTrue(oB <= cB && cB <= dB, "Contrast should be increased or same");
}
}
}
@@ -304,9 +304,9 @@ public class ImageUtilTest {
int r = rgb >> 16 & 0xFF;
int g = rgb >> 8 & 0xFF;
int b = rgb & 0xFF;
- assertTrue("Max contrast should only produce primary colors", r == 0 || r == 255);
- assertTrue("Max contrast should only produce primary colors", g == 0 || g == 255);
- assertTrue("Max contrast should only produce primary colors", b == 0 || b == 255);
+ assertTrue(r == 0 || r == 255, "Max contrast should only produce primary colors");
+ assertTrue(g == 0 || g == 255, "Max contrast should only produce primary colors");
+ assertTrue(b == 0 || b == 255, "Max contrast should only produce primary colors");
}
}
@@ -327,24 +327,24 @@ public class ImageUtilTest {
// RED
if (oR >= 127) {
- assertTrue("Contrast should be decreased or same", oR >= cR);
+ assertTrue(oR >= cR, "Contrast should be decreased or same");
}
else {
- assertTrue("Contrast should be increased or same", oR <= cR);
+ assertTrue(oR <= cR, "Contrast should be increased or same");
}
// GREEN
if (oG >= 127) {
- assertTrue("Contrast should be decreased or same", oG >= cG);
+ assertTrue(oG >= cG, "Contrast should be decreased or same");
}
else {
- assertTrue("Contrast should be increased or same", oG <= cG);
+ assertTrue(oG <= cG, "Contrast should be increased or same");
}
// BLUE
if (oB >= 127) {
- assertTrue("Contrast should be decreased or same", oB >= cB);
+ assertTrue(oB >= cB, "Contrast should be decreased or same");
}
else {
- assertTrue("Contrast should be increased or same", oB <= cB);
+ assertTrue(oB <= cB, "Contrast should be increased or same");
}
}
}
@@ -357,7 +357,7 @@ public class ImageUtilTest {
int r = rgb >> 16 & 0xFF;
int g = rgb >> 8 & 0xFF;
int b = rgb & 0xFF;
- assertTrue("Minimum contrast should be all gray", r == 127 && g == 127 && b == 127);
+ assertTrue(r == 127 && g == 127 && b == 127, "Minimum contrast should be all gray");
}
}
@@ -400,7 +400,7 @@ public class ImageUtilTest {
if (original != notSharpened) { // Don't care to test if images are same
for (int y = 0; y < original.getHeight(); y++) {
for (int x = 0; x < original.getWidth(); x++) {
- assertEquals("0 sharpen should not change image", original.getRGB(x, y), notSharpened.getRGB(x, y));
+ assertEquals(original.getRGB(x, y), notSharpened.getRGB(x, y), "0 sharpen should not change image");
}
}
}
@@ -446,13 +446,13 @@ public class ImageUtilTest {
}
// assertEquals("Difference should not change", diffOriginal, diffSharpened);
- assertTrue("Abs difference should increase", absDiffOriginal < absDiffSharpened);
+ assertTrue(absDiffOriginal < absDiffSharpened, "Abs difference should increase");
// assertEquals("Difference should not change", diffOriginal, diffDefault);
- assertTrue("Abs difference should increase", absDiffOriginal < absDiffDefault);
+ assertTrue(absDiffOriginal < absDiffDefault, "Abs difference should increase");
// assertEquals("Difference should not change", diffOriginal, diffMore);
- assertTrue("Abs difference should increase", absDiffOriginal < absDiffMore);
+ assertTrue(absDiffOriginal < absDiffMore, "Abs difference should increase");
// assertEquals("Difference should not change", diffSharpened, diffMore);
- assertTrue("Abs difference should increase", absDiffSharpened < absDiffMore);
+ assertTrue(absDiffSharpened < absDiffMore, "Abs difference should increase");
}
@Test
@@ -466,7 +466,7 @@ public class ImageUtilTest {
if (original != notBlurred) { // Don't care to test if images are same
for (int y = 0; y < original.getHeight(); y++) {
for (int x = 0; x < original.getWidth(); x++) {
- assertEquals("0 blur should not change image", original.getRGB(x, y), notBlurred.getRGB(x, y));
+ assertEquals(original.getRGB(x, y), notBlurred.getRGB(x, y), "0 blur should not change image");
}
}
}
@@ -512,13 +512,13 @@ public class ImageUtilTest {
}
// assertEquals("Difference should not change", diffOriginal, diffBlurred);
- assertTrue(String.format("Abs difference should decrease: %s <= %s", absDiffOriginal, absDiffBlurred), absDiffOriginal > absDiffBlurred);
+ assertTrue(absDiffOriginal > absDiffBlurred, String.format("Abs difference should decrease: %s <= %s", absDiffOriginal, absDiffBlurred));
// assertEquals("Difference should not change", diffOriginal, diffDefault);
- assertTrue("Abs difference should decrease", absDiffOriginal > absDiffDefault);
+ assertTrue(absDiffOriginal > absDiffDefault, "Abs difference should decrease");
// assertEquals("Difference should not change", diffOriginal, diffMore);
- assertTrue("Abs difference should decrease", absDiffOriginal > absDiffMore);
+ assertTrue(absDiffOriginal > absDiffMore, "Abs difference should decrease");
// assertEquals("Difference should not change", diffBlurred, diffMore);
- assertTrue("Abs difference should decrease", absDiffBlurred > absDiffMore);
+ assertTrue(absDiffBlurred > absDiffMore, "Abs difference should decrease");
}
@Test
@@ -528,7 +528,7 @@ public class ImageUtilTest {
assertNotNull(sunflower);
BufferedImage image = ImageUtil.createIndexed(sunflower);
- assertNotNull("Image was null", image);
- assertTrue(image.getColorModel() instanceof IndexColorModel);
+ assertNotNull(image, "Image was null");
+ assertInstanceOf(IndexColorModel.class, image.getColorModel());
}
}
diff --git a/common/common-image/src/test/java/com/twelvemonkeys/image/ResampleOpTest.java b/common/common-image/src/test/java/com/twelvemonkeys/image/ResampleOpTest.java
index c6b43bf3..d66aecf1 100644
--- a/common/common-image/src/test/java/com/twelvemonkeys/image/ResampleOpTest.java
+++ b/common/common-image/src/test/java/com/twelvemonkeys/image/ResampleOpTest.java
@@ -30,8 +30,8 @@
package com.twelvemonkeys.image;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
import java.awt.*;
import java.awt.image.BufferedImage;
@@ -40,7 +40,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
/**
* ResampleOpTestCase
@@ -124,7 +124,7 @@ public class ResampleOpTest {
}
}
- assertEquals("Filter threw exceptions: ", Collections.EMPTY_LIST, exceptions);
+ assertEquals(Collections.EMPTY_LIST, exceptions, "Filter threw exceptions: ");
}
// 1x1
@@ -358,7 +358,7 @@ public class ResampleOpTest {
}
}
- @Ignore("Not for general unit testing")
+ @Disabled("Not for general unit testing")
@Test
public void testTime() {
int iterations = 1000;
diff --git a/common/common-io/src/test/java/com/twelvemonkeys/io/CompoundReaderTest.java b/common/common-io/src/test/java/com/twelvemonkeys/io/CompoundReaderTest.java
index 6e1fb796..302cce78 100755
--- a/common/common-io/src/test/java/com/twelvemonkeys/io/CompoundReaderTest.java
+++ b/common/common-io/src/test/java/com/twelvemonkeys/io/CompoundReaderTest.java
@@ -32,7 +32,6 @@ package com.twelvemonkeys.io;
import com.twelvemonkeys.lang.StringUtil;
import com.twelvemonkeys.util.CollectionUtil;
-import org.junit.Test;
import java.io.IOException;
import java.io.Reader;
@@ -40,7 +39,8 @@ import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;
-import static org.junit.Assert.*;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.*;
/**
* CompoundReaderTestCase
diff --git a/common/common-io/src/test/java/com/twelvemonkeys/io/FastByteArrayOutputStreamTest.java b/common/common-io/src/test/java/com/twelvemonkeys/io/FastByteArrayOutputStreamTest.java
index c3537431..d9957e18 100755
--- a/common/common-io/src/test/java/com/twelvemonkeys/io/FastByteArrayOutputStreamTest.java
+++ b/common/common-io/src/test/java/com/twelvemonkeys/io/FastByteArrayOutputStreamTest.java
@@ -30,12 +30,11 @@
package com.twelvemonkeys.io;
-import org.junit.Test;
-
import java.io.IOException;
import java.io.InputStream;
-import static org.junit.Assert.assertEquals;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.*;
/**
* FastByteArrayOutputStreamTestCase
diff --git a/common/common-io/src/test/java/com/twelvemonkeys/io/FileSeekableStreamTest.java b/common/common-io/src/test/java/com/twelvemonkeys/io/FileSeekableStreamTest.java
index d4325af9..e2d8fc02 100755
--- a/common/common-io/src/test/java/com/twelvemonkeys/io/FileSeekableStreamTest.java
+++ b/common/common-io/src/test/java/com/twelvemonkeys/io/FileSeekableStreamTest.java
@@ -30,11 +30,10 @@
package com.twelvemonkeys.io;
-import org.junit.Test;
-
import java.io.*;
-import static org.junit.Assert.*;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.*;
/**
* MemoryCacheSeekableStreamTestCase
@@ -92,13 +91,13 @@ public class FileSeekableStreamTest extends SeekableInputStreamAbstractTest {
try {
FileUtil.read(stream); // Read until EOF
- assertEquals("EOF not reached (test case broken)", -1, stream.read());
- assertFalse("Underlying stream closed before close", closed[0]);
+ assertEquals(-1, stream.read(), "EOF not reached (test case broken)");
+ assertFalse(closed[0], "Underlying stream closed before close");
}
finally {
stream.close();
}
- assertTrue("Underlying stream not closed", closed[0]);
+ assertTrue(closed[0], "Underlying stream not closed");
}
}
diff --git a/common/common-io/src/test/java/com/twelvemonkeys/io/InputStreamAbstractTest.java b/common/common-io/src/test/java/com/twelvemonkeys/io/InputStreamAbstractTest.java
index 59e1ac38..290278ed 100755
--- a/common/common-io/src/test/java/com/twelvemonkeys/io/InputStreamAbstractTest.java
+++ b/common/common-io/src/test/java/com/twelvemonkeys/io/InputStreamAbstractTest.java
@@ -46,14 +46,14 @@
package com.twelvemonkeys.io;
import com.twelvemonkeys.lang.ObjectAbstractTest;
-import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Random;
-import static org.junit.Assert.*;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.*;
/**
* InputStreamAbstractTestCase
@@ -104,15 +104,15 @@ public abstract class InputStreamAbstractTest extends ObjectAbstractTest {
int size = 5;
InputStream input = makeInputStream(makeOrderedArray(size));
for (int i = 0; i < size; i++) {
- assertTrue("Check Size [" + i + "]", (size - i) >= input.available());
- assertEquals("Check Value [" + i + "]", i, input.read());
+ assertTrue((size - i) >= input.available(), "Check Size [" + i + "]");
+ assertEquals(i, input.read(), "Check Value [" + i + "]");
}
- assertEquals("Available after contents all read", 0, input.available());
+ assertEquals(0, input.available(), "Available after contents all read");
// Test reading after the end of file
try {
int result = input.read();
- assertEquals("Wrong value read after end of file", -1, result);
+ assertEquals( -1, result, "Wrong value read after end of file");
}
catch (IOException e) {
fail("Should not have thrown an IOException: " + e.getMessage());
@@ -122,12 +122,12 @@ public abstract class InputStreamAbstractTest extends ObjectAbstractTest {
@Test
public void testAvailable() throws Exception {
InputStream input = makeInputStream(1);
- assertFalse("Unexpected EOF", input.read() < 0);
- assertEquals("Available after contents all read", 0, input.available());
+ assertFalse(input.read() < 0, "Unexpected EOF");
+ assertEquals(0, input.available(), "Available after contents all read");
// Check availbale is zero after End of file
- assertEquals("End of File", -1, input.read());
- assertEquals("Available after End of File", 0, input.available());
+ assertEquals(-1, input.read(), "End of File");
+ assertEquals( 0, input.available(), "Available after End of File");
}
@Test
@@ -138,26 +138,26 @@ public abstract class InputStreamAbstractTest extends ObjectAbstractTest {
// Read into array
int count1 = input.read(bytes);
- assertEquals("Read 1", bytes.length, count1);
+ assertEquals(bytes.length, count1, "Read 1");
for (int i = 0; i < count1; i++) {
- assertEquals("Check Bytes 1", i, bytes[i]);
+ assertEquals(i, bytes[i], "Check Bytes 1");
}
// Read into array
int count2 = input.read(bytes);
- assertEquals("Read 2", 5, count2);
+ assertEquals(5, count2, "Read 2");
for (int i = 0; i < count2; i++) {
- assertEquals("Check Bytes 2", count1 + i, bytes[i]);
+ assertEquals(count1 + i, bytes[i], "Check Bytes 2");
}
// End of File
int count3 = input.read(bytes);
- assertEquals("Read 3 (EOF)", -1, count3);
+ assertEquals(-1, count3, "Read 3 (EOF)");
// Test reading after the end of file
try {
int result = input.read(bytes);
- assertEquals("Wrong value read after end of file", -1, result);
+ assertEquals(-1, result, "Wrong value read after end of file");
}
catch (IOException e) {
fail("Should not have thrown an IOException: " + e.getMessage());
@@ -170,20 +170,20 @@ public abstract class InputStreamAbstractTest extends ObjectAbstractTest {
int offset = 2;
int lth = 4;
int count5 = input.read(bytes, offset, lth);
- assertEquals("Read 5", lth, count5);
+ assertEquals(lth, count5, "Read 5");
for (int i = offset; i < lth; i++) {
- assertEquals("Check Bytes 2", i - offset, bytes[i]);
+ assertEquals(i - offset, bytes[i], "Check Bytes 2");
}
}
@Test
public void testEOF() throws Exception {
InputStream input = makeInputStream(makeOrderedArray(2));
- assertEquals("Read 1", 0, input.read());
- assertEquals("Read 2", 1, input.read());
- assertEquals("Read 3", -1, input.read());
- assertEquals("Read 4", -1, input.read());
- assertEquals("Read 5", -1, input.read());
+ assertEquals(0, input.read(), "Read 1");
+ assertEquals(1, input.read(), "Read 2");
+ assertEquals(-1, input.read(), "Read 3");
+ assertEquals(-1, input.read(), "Read 4");
+ assertEquals(-1, input.read(), "Read 5");
}
@Test
@@ -205,7 +205,7 @@ public abstract class InputStreamAbstractTest extends ObjectAbstractTest {
fail("Should throw IOException");
}
catch (IOException e) {
- assertTrue("Wrong messge: " + e.getMessage(), e.getMessage().contains("reset"));
+ assertTrue(e.getMessage().contains("reset"), "Wrong messge: " + e.getMessage());
}
}
@@ -223,10 +223,10 @@ public abstract class InputStreamAbstractTest extends ObjectAbstractTest {
// No mark may either throw exception, or reset to beginning of stream.
try {
input.reset();
- assertEquals("Re-read of reset data should be same", 0, input.read());
+ assertEquals(0, input.read(), "Re-read of reset data should be same");
}
catch (Exception e) {
- assertTrue("Wrong no mark IOException message", e.getMessage().contains("mark"));
+ assertTrue(e.getMessage().contains("mark"), "Wrong no mark IOException message");
}
}
@@ -249,7 +249,7 @@ public abstract class InputStreamAbstractTest extends ObjectAbstractTest {
// Read further
for (int i = 0; i < 3; i++) {
- assertEquals("Read After Mark [" + i + "]", (position + i), input.read());
+ assertEquals((position + i), input.read(), "Read After Mark [" + i + "]");
}
// Reset
@@ -257,7 +257,7 @@ public abstract class InputStreamAbstractTest extends ObjectAbstractTest {
// Read from marked position
for (int i = 0; i < readlimit + 1; i++) {
- assertEquals("Read After Reset [" + i + "]", (position + i), input.read());
+ assertEquals((position + i), input.read(), "Read After Reset [" + i + "]");
}
}
@@ -280,16 +280,16 @@ public abstract class InputStreamAbstractTest extends ObjectAbstractTest {
// Read past marked position
for (int i = 0; i < readlimit + 1; i++) {
- assertEquals("Read After Reset [" + i + "]", (position + i), input.read());
+ assertEquals((position + i), input.read(), "Read After Reset [" + i + "]");
}
// Reset after read limit passed, may either throw exception, or reset to last mark
try {
input.reset();
- assertEquals("Re-read of reset data should be same", 1, input.read());
+ assertEquals(1, input.read(), "Re-read of reset data should be same");
}
catch (Exception e) {
- assertTrue("Wrong read-limit IOException message", e.getMessage().contains("mark"));
+ assertTrue(e.getMessage().contains("mark"), "Wrong read-limit IOException message");
}
}
@@ -302,29 +302,29 @@ public abstract class InputStreamAbstractTest extends ObjectAbstractTest {
}
int first = input.read();
- assertTrue("Expected to read positive value", first >= 0);
+ assertTrue(first >= 0, "Expected to read positive value");
int readlimit = 5;
// Mark
input.mark(readlimit);
int read = input.read();
- assertTrue("Expected to read positive value", read >= 0);
+ assertTrue(read >= 0, "Expected to read positive value");
assertTrue(input.read() >= 0);
assertTrue(input.read() >= 0);
input.reset();
- assertEquals("Expected value read differs from actual", read, input.read());
+ assertEquals(read, input.read(), "Expected value read differs from actual");
// Reset after read limit passed, may either throw exception, or reset to last good mark
try {
input.reset();
int reRead = input.read();
- assertTrue("Re-read of reset data should be same as initially marked or first", reRead == read || reRead == first);
+ assertTrue(reRead == read || reRead == first, "Re-read of reset data should be same as initially marked or first");
}
catch (Exception e) {
- assertTrue("Wrong read-limit IOException message", e.getMessage().contains("mark"));
+ assertTrue(e.getMessage().contains("mark"), "Wrong read-limit IOException message");
}
}
@@ -332,17 +332,17 @@ public abstract class InputStreamAbstractTest extends ObjectAbstractTest {
public void testSkip() throws Exception {
InputStream input = makeInputStream(makeOrderedArray(10));
- assertEquals("Unexpected value read", 0, input.read());
- assertEquals("Unexpected value read", 1, input.read());
- assertEquals("Unexpected number of bytes skipped", 5, input.skip(5));
- assertEquals("Unexpected value read", 7, input.read());
+ assertEquals(0, input.read(), "Unexpected value read");
+ assertEquals(1, input.read(), "Unexpected value read");
+ assertEquals(5, input.skip(5), "Unexpected number of bytes skipped");
+ assertEquals(7, input.read(), "Unexpected value read");
- assertEquals("Unexpected number of bytes skipped", 2, input.skip(5)); // only 2 left to skip
- assertEquals("Unexpected value read after EOF", -1, input.read());
+ assertEquals(2, input.skip(5), "Unexpected number of bytes skipped"); // only 2 left to skip
+ assertEquals(-1, input.read(), "Unexpected value read after EOF");
// Spec says skip might return 0 or negative after EOF...
- assertTrue("Positive value skipped after EOF", input.skip(5) <= 0); // End of file
- assertEquals("Unexpected value read after EOF", -1, input.read());
+ assertTrue(input.skip(5) <= 0, "Positive value skipped after EOF"); // End of file
+ assertEquals(-1, input.read(), "Unexpected value read after EOF");
}
@Test
diff --git a/common/common-io/src/test/java/com/twelvemonkeys/io/LittleEndianDataInputStreamTest.java b/common/common-io/src/test/java/com/twelvemonkeys/io/LittleEndianDataInputStreamTest.java
index 9527c85c..3cbf893f 100644
--- a/common/common-io/src/test/java/com/twelvemonkeys/io/LittleEndianDataInputStreamTest.java
+++ b/common/common-io/src/test/java/com/twelvemonkeys/io/LittleEndianDataInputStreamTest.java
@@ -30,12 +30,11 @@
package com.twelvemonkeys.io;
-import org.junit.Test;
-
import java.io.ByteArrayInputStream;
import java.io.IOException;
-import static org.junit.Assert.*;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.*;
/**
* LittleEndianDataInputStreamTest
diff --git a/common/common-io/src/test/java/com/twelvemonkeys/io/OutputStreamAbstractTest.java b/common/common-io/src/test/java/com/twelvemonkeys/io/OutputStreamAbstractTest.java
index c5f5a412..60a84f60 100755
--- a/common/common-io/src/test/java/com/twelvemonkeys/io/OutputStreamAbstractTest.java
+++ b/common/common-io/src/test/java/com/twelvemonkeys/io/OutputStreamAbstractTest.java
@@ -31,13 +31,12 @@
package com.twelvemonkeys.io;
import com.twelvemonkeys.lang.ObjectAbstractTest;
-import org.junit.Test;
import java.io.IOException;
import java.io.OutputStream;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.*;
/**
* InputStreamAbstractTestCase
diff --git a/common/common-io/src/test/java/com/twelvemonkeys/io/ReaderAbstractTest.java b/common/common-io/src/test/java/com/twelvemonkeys/io/ReaderAbstractTest.java
index 8fc72aa6..6ca193ab 100755
--- a/common/common-io/src/test/java/com/twelvemonkeys/io/ReaderAbstractTest.java
+++ b/common/common-io/src/test/java/com/twelvemonkeys/io/ReaderAbstractTest.java
@@ -31,12 +31,12 @@
package com.twelvemonkeys.io;
import com.twelvemonkeys.lang.ObjectAbstractTest;
-import org.junit.Test;
import java.io.IOException;
import java.io.Reader;
-import static org.junit.Assert.*;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.*;
/**
* ReaderAbstractTestCase
@@ -112,7 +112,7 @@ public abstract class ReaderAbstractTest extends ObjectAbstractTest {
int toSkip = mInput.length();
while (toSkip > 0) {
long skipped = reader.skip(toSkip);
- assertFalse("Skipped < 0", skipped < 0);
+ assertFalse(skipped < 0, "Skipped < 0");
toSkip -= skipped;
}
diff --git a/common/common-io/src/test/java/com/twelvemonkeys/io/SeekableAbstractTest.java b/common/common-io/src/test/java/com/twelvemonkeys/io/SeekableAbstractTest.java
index 2ae256ec..ba5cfd52 100755
--- a/common/common-io/src/test/java/com/twelvemonkeys/io/SeekableAbstractTest.java
+++ b/common/common-io/src/test/java/com/twelvemonkeys/io/SeekableAbstractTest.java
@@ -30,10 +30,8 @@
package com.twelvemonkeys.io;
-import org.junit.Test;
-
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.*;
/**
* SeekableAbstractTestCase
diff --git a/common/common-io/src/test/java/com/twelvemonkeys/io/SeekableInputStreamAbstractTest.java b/common/common-io/src/test/java/com/twelvemonkeys/io/SeekableInputStreamAbstractTest.java
index 4a4b2d25..8e271b0f 100755
--- a/common/common-io/src/test/java/com/twelvemonkeys/io/SeekableInputStreamAbstractTest.java
+++ b/common/common-io/src/test/java/com/twelvemonkeys/io/SeekableInputStreamAbstractTest.java
@@ -30,14 +30,13 @@
package com.twelvemonkeys.io;
-import org.junit.Test;
-
import java.io.ByteArrayInputStream;
import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
-import static org.junit.Assert.*;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.*;
/**
* SeekableInputStreamAbstractTest
@@ -79,25 +78,25 @@ public abstract class SeekableInputStreamAbstractTest extends InputStreamAbstrac
return; // Not supported, skip test
}
- assertTrue("Expected to read positive value", input.read() >= 0);
+ assertTrue(input.read() >= 0, "Expected to read positive value");
int readlimit = 5;
// Mark
input.mark(readlimit);
int read = input.read();
- assertTrue("Expected to read positive value", read >= 0);
+ assertTrue(read >= 0, "Expected to read positive value");
input.reset();
- assertEquals("Expected value read differs from actual", read, input.read());
+ assertEquals(read, input.read(), "Expected value read differs from actual");
// Reset after read limit passed, may either throw exception, or reset to last good mark
try {
input.reset();
- assertEquals("Re-read of reset data should be first", 0, input.read());
+ assertEquals(0, input.read(), "Re-read of reset data should be first");
}
catch (Exception e) {
- assertTrue("Wrong read-limit IOException message", e.getMessage().contains("mark"));
+ assertTrue(e.getMessage().contains("mark"), "Wrong read-limit IOException message");
}
}
@@ -127,7 +126,7 @@ public abstract class SeekableInputStreamAbstractTest extends InputStreamAbstrac
seekable.seek(pos);
long streamPos = seekable.getStreamPosition();
- assertEquals("Stream positon should match seeked position", pos, streamPos);
+ assertEquals(pos, streamPos, "Stream positon should match seeked position");
}
@Test
@@ -137,7 +136,7 @@ public abstract class SeekableInputStreamAbstractTest extends InputStreamAbstrac
seekable.seek(pos);
seekable.flushBefore(pos);
long flushedPos = seekable.getFlushedPosition();
- assertEquals("Flushed positon should match position", pos, flushedPos);
+ assertEquals(pos, flushedPos, "Flushed positon should match position");
try {
seekable.seek(pos - 1);
@@ -382,13 +381,13 @@ public abstract class SeekableInputStreamAbstractTest extends InputStreamAbstrac
int val;
val = stream.read();
- assertFalse("Unexepected EOF", val == -1);
+ assertFalse(val == -1, "Unexepected EOF");
val = stream.read();
- assertFalse("Unexepected EOF", val == -1);
+ assertFalse(val == -1, "Unexepected EOF");
val = stream.read();
- assertFalse("Unexepected EOF", val == -1);
+ assertFalse(val == -1, "Unexepected EOF");
val = stream.read();
- assertFalse("Unexepected EOF", val == -1);
+ assertFalse(val == -1, "Unexepected EOF");
stream.seek(0);
@@ -422,19 +421,19 @@ public abstract class SeekableInputStreamAbstractTest extends InputStreamAbstrac
stream.seek(0);
for (int i = 0; i < bytes.length; i += 2) {
- assertEquals("Wrong stream position", i, stream.getStreamPosition());
+ assertEquals(i, stream.getStreamPosition(), "Wrong stream position");
int count = stream.read(buffer, 0, 2);
assertEquals(2, count);
- assertEquals(String.format("Wrong value read at pos %d", stream.getStreamPosition()), bytes[i], buffer[0]);
- assertEquals(String.format("Wrong value read at pos %d", stream.getStreamPosition()), bytes[i + 1], buffer[1]);
+ assertEquals(bytes[i], buffer[0], String.format("Wrong value read at pos %d", stream.getStreamPosition()));
+ assertEquals(bytes[i + 1], buffer[1], String.format("Wrong value read at pos %d", stream.getStreamPosition()));
}
stream.seek(0);
for (int i = 0; i < bytes.length; i++) {
- assertEquals("Wrong stream position", i, stream.getStreamPosition());
+ assertEquals(i, stream.getStreamPosition(), "Wrong stream position");
int actual = stream.read();
- assertEquals(String.format("Wrong value read at pos %d", stream.getStreamPosition()), bytes[i] & 0xff, actual);
- assertEquals(String.format("Wrong value read at pos %d", stream.getStreamPosition()), bytes[i], (byte) actual);
+ assertEquals(bytes[i] & 0xff, actual, String.format("Wrong value read at pos %d", stream.getStreamPosition()));
+ assertEquals(bytes[i], (byte) actual, String.format("Wrong value read at pos %d", stream.getStreamPosition()));
}
}
@@ -456,14 +455,14 @@ public abstract class SeekableInputStreamAbstractTest extends InputStreamAbstrac
try {
FileUtil.read(stream); // Read until EOF
- assertEquals("EOF not reached (test case broken)", -1, stream.read());
- assertFalse("Underlying stream closed before close", closed[0]);
+ assertEquals(-1, stream.read(), "EOF not reached (test case broken)");
+ assertFalse(closed[0], "Underlying stream closed before close");
}
finally {
stream.close();
}
- assertTrue("Underlying stream not closed", closed[0]);
+ assertTrue(closed[0], "Underlying stream not closed");
}
diff --git a/common/common-io/src/test/java/com/twelvemonkeys/io/StringArrayReaderTest.java b/common/common-io/src/test/java/com/twelvemonkeys/io/StringArrayReaderTest.java
index 53af2336..2f3df6bf 100755
--- a/common/common-io/src/test/java/com/twelvemonkeys/io/StringArrayReaderTest.java
+++ b/common/common-io/src/test/java/com/twelvemonkeys/io/StringArrayReaderTest.java
@@ -31,12 +31,12 @@
package com.twelvemonkeys.io;
import com.twelvemonkeys.lang.StringUtil;
-import org.junit.Test;
import java.io.IOException;
import java.io.Reader;
-import static org.junit.Assert.*;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.*;
/**
* StringArrayReaderTestCase
diff --git a/common/common-io/src/test/java/com/twelvemonkeys/io/SubStreamTest.java b/common/common-io/src/test/java/com/twelvemonkeys/io/SubStreamTest.java
index 75a51360..d9f008cb 100644
--- a/common/common-io/src/test/java/com/twelvemonkeys/io/SubStreamTest.java
+++ b/common/common-io/src/test/java/com/twelvemonkeys/io/SubStreamTest.java
@@ -1,15 +1,14 @@
package com.twelvemonkeys.io;
-import org.junit.Test;
-
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.time.Duration;
import java.util.Arrays;
import java.util.Random;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.*;
/**
* SubStreamTest.
@@ -23,14 +22,18 @@ public class SubStreamTest {
private final Random rng = new Random(2918475687L);
@SuppressWarnings("resource")
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testCreateNullStream() {
- new SubStream(null, 42);
+ assertThrows(IllegalArgumentException.class, () -> {
+ new SubStream(null, 42);
+ });
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testCreateNegativeLength() {
- new SubStream(new ByteArrayInputStream(new byte[1]), -1);
+ assertThrows(IllegalArgumentException.class, () -> {
+ new SubStream(new ByteArrayInputStream(new byte[1]), -1);
+ });
}
@Test
@@ -100,15 +103,17 @@ public class SubStreamTest {
}
@SuppressWarnings("EmptyTryBlock")
- @Test(timeout = 500L)
+ @Test
public void testCloseConsumesAllShortStream() throws IOException {
- ByteArrayInputStream stream = new ByteArrayInputStream(new byte[13]);
+ assertTimeoutPreemptively(Duration.ofMillis(500), () -> {
+ ByteArrayInputStream stream = new ByteArrayInputStream(new byte[13]);
- try (InputStream ignore = new SubStream(stream, 42)) {
- // Nothing here...
- }
+ try (InputStream ignore = new SubStream(stream, 42)) {
+ // Nothing here...
+ }
- assertEquals(0, stream.available());
- assertEquals(-1, stream.read());
+ assertEquals(0, stream.available());
+ assertEquals(-1, stream.read());
+ });
}
}
\ No newline at end of file
diff --git a/common/common-io/src/test/java/com/twelvemonkeys/io/enc/Base64DecoderTest.java b/common/common-io/src/test/java/com/twelvemonkeys/io/enc/Base64DecoderTest.java
index 457fb901..2da38e0c 100755
--- a/common/common-io/src/test/java/com/twelvemonkeys/io/enc/Base64DecoderTest.java
+++ b/common/common-io/src/test/java/com/twelvemonkeys/io/enc/Base64DecoderTest.java
@@ -31,15 +31,13 @@
package com.twelvemonkeys.io.enc;
import com.twelvemonkeys.io.FileUtil;
-import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
-
-import static org.junit.Assert.assertEquals;
-
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.*;
/**
* Base64DecoderTest
*
@@ -66,7 +64,7 @@ public class Base64DecoderTest extends DecoderAbstractTest {
FileUtil.copy(in, bytes);
- assertEquals("Strings does not match", "", new String(bytes.toByteArray()));
+ assertEquals("", new String(bytes.toByteArray()), "Strings does not match");
}
@Test
@@ -78,7 +76,7 @@ public class Base64DecoderTest extends DecoderAbstractTest {
FileUtil.copy(in, bytes);
- assertEquals("Strings does not match", "test", new String(bytes.toByteArray()));
+ assertEquals("test", new String(bytes.toByteArray()), "Strings does not match");
}
@Test
@@ -93,11 +91,12 @@ public class Base64DecoderTest extends DecoderAbstractTest {
FileUtil.copy(in, bytes);
- assertEquals("Strings does not match",
+ assertEquals(
"Lorem ipsum dolor sit amet, consectetuer adipiscing " +
"elit. Fusce est. Morbi luctus consectetuer justo. Vivamus " +
"dapibus laoreet purus. Nunc viverra dictum nisl. Integer " +
"ullamcorper, nisi in dictum amet.",
- new String(bytes.toByteArray()));
+ new String(bytes.toByteArray()),
+ "Strings does not match");
}
}
\ No newline at end of file
diff --git a/common/common-io/src/test/java/com/twelvemonkeys/io/enc/Base64EncoderTest.java b/common/common-io/src/test/java/com/twelvemonkeys/io/enc/Base64EncoderTest.java
index 7e77196a..6e7c45b5 100644
--- a/common/common-io/src/test/java/com/twelvemonkeys/io/enc/Base64EncoderTest.java
+++ b/common/common-io/src/test/java/com/twelvemonkeys/io/enc/Base64EncoderTest.java
@@ -30,13 +30,12 @@
package com.twelvemonkeys.io.enc;
-import org.junit.Test;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
-
-import static org.junit.Assert.assertEquals;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.*;
/**
* Base64EncoderTest
@@ -63,7 +62,7 @@ public class Base64EncoderTest extends EncoderAbstractTest {
OutputStream out = new EncoderStream(bytes, createEncoder(), true);
out.write(data.getBytes());
- assertEquals("Strings does not match", "", new String(bytes.toByteArray()));
+ assertEquals("", new String(bytes.toByteArray()), "Strings does not match");
}
@Test
@@ -74,7 +73,7 @@ public class Base64EncoderTest extends EncoderAbstractTest {
OutputStream out = new EncoderStream(bytes, createEncoder(), true);
out.write(data.getBytes());
- assertEquals("Strings does not match", "dGVzdA==", new String(bytes.toByteArray()));
+ assertEquals("dGVzdA==", new String(bytes.toByteArray()), "Strings does not match");
}
@Test
@@ -88,11 +87,12 @@ public class Base64EncoderTest extends EncoderAbstractTest {
OutputStream out = new EncoderStream(bytes, createEncoder(), true);
out.write(data.getBytes());
- assertEquals("Strings does not match",
+ assertEquals(
"TG9yZW0gaXBzdW0gZG9sb3Igc2l0IGFtZXQsIGNvbnNlY3RldHVlciBhZGlwaXNjaW5nIGVsaXQuIEZ1" +
"c2NlIGVzdC4gTW9yYmkgbHVjdHVzIGNvbnNlY3RldHVlciBqdXN0by4gVml2YW11cyBkYXBpYnVzIGxh" +
"b3JlZXQgcHVydXMuIE51bmMgdml2ZXJyYSBkaWN0dW0gbmlzbC4gSW50ZWdlciB1bGxhbWNvcnBlciwg" +
"bmlzaSBpbiBkaWN0dW0gYW1ldC4=",
- new String(bytes.toByteArray()));
+ new String(bytes.toByteArray()),
+ "Strings does not match");
}
}
diff --git a/common/common-io/src/test/java/com/twelvemonkeys/io/enc/DecoderAbstractTest.java b/common/common-io/src/test/java/com/twelvemonkeys/io/enc/DecoderAbstractTest.java
index 6f1e8948..4325ad9b 100644
--- a/common/common-io/src/test/java/com/twelvemonkeys/io/enc/DecoderAbstractTest.java
+++ b/common/common-io/src/test/java/com/twelvemonkeys/io/enc/DecoderAbstractTest.java
@@ -32,12 +32,13 @@ package com.twelvemonkeys.io.enc;
import com.twelvemonkeys.io.FileUtil;
import com.twelvemonkeys.lang.ObjectAbstractTest;
-import org.junit.Test;
+import java.awt.image.ImageProducer;
import java.io.*;
import java.nio.ByteBuffer;
-import static org.junit.Assert.*;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.*;
/**
* AbstractDecoderTest
@@ -55,13 +56,13 @@ public abstract class DecoderAbstractTest extends ObjectAbstractTest {
return createDecoder();
}
- @Test(expected = NullPointerException.class)
+ @Test
public final void testNullDecode() throws IOException {
Decoder decoder = createDecoder();
ByteArrayInputStream bytes = new ByteArrayInputStream(new byte[20]);
-
- decoder.decode(bytes, null);
- fail("null should throw NullPointerException");
+ assertThrows(NullPointerException.class, () -> {
+ decoder.decode(bytes, null);
+ });
}
@Test
@@ -71,7 +72,7 @@ public abstract class DecoderAbstractTest extends ObjectAbstractTest {
try {
int count = decoder.decode(bytes, ByteBuffer.allocate(128));
- assertEquals("Should not be able to read any bytes", 0, count);
+ assertEquals( 0, count, "Should not be able to read any bytes");
}
catch (EOFException allowed) {
// Okay
@@ -94,7 +95,7 @@ public abstract class DecoderAbstractTest extends ObjectAbstractTest {
byte[] encoded = outBytes.toByteArray();
byte[] decoded = FileUtil.read(new DecoderStream(new ByteArrayInputStream(encoded), createDecoder()));
- assertArrayEquals(String.format("Data %d", pLength), data, decoded);
+ assertArrayEquals(data, decoded, String.format("Data %d", pLength));
InputStream in = new DecoderStream(new ByteArrayInputStream(encoded), createDecoder());
outBytes = new ByteArrayOutputStream();
@@ -103,7 +104,7 @@ public abstract class DecoderAbstractTest extends ObjectAbstractTest {
in.close();
decoded = outBytes.toByteArray();
- assertArrayEquals(String.format("Data %d", pLength), data, decoded);
+ assertArrayEquals(data, decoded, String.format("Data %d", pLength));
}
@Test
diff --git a/common/common-io/src/test/java/com/twelvemonkeys/io/enc/DecoderStreamTest.java b/common/common-io/src/test/java/com/twelvemonkeys/io/enc/DecoderStreamTest.java
index 8982b485..506c43aa 100644
--- a/common/common-io/src/test/java/com/twelvemonkeys/io/enc/DecoderStreamTest.java
+++ b/common/common-io/src/test/java/com/twelvemonkeys/io/enc/DecoderStreamTest.java
@@ -30,7 +30,6 @@
package com.twelvemonkeys.io.enc;
-import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.IOException;
@@ -39,7 +38,8 @@ import java.nio.ByteBuffer;
import java.util.Arrays;
import java.util.Random;
-import static org.junit.Assert.*;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.*;
public class DecoderStreamTest {
diff --git a/common/common-io/src/test/java/com/twelvemonkeys/io/enc/EncoderAbstractTest.java b/common/common-io/src/test/java/com/twelvemonkeys/io/enc/EncoderAbstractTest.java
index 863f04b7..815dc24e 100644
--- a/common/common-io/src/test/java/com/twelvemonkeys/io/enc/EncoderAbstractTest.java
+++ b/common/common-io/src/test/java/com/twelvemonkeys/io/enc/EncoderAbstractTest.java
@@ -33,13 +33,12 @@ package com.twelvemonkeys.io.enc;
import com.twelvemonkeys.io.FileUtil;
import com.twelvemonkeys.lang.ObjectAbstractTest;
-import org.junit.Test;
import java.io.*;
import java.util.Random;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.fail;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.*;
/**
* AbstractEncoderTest
diff --git a/common/common-io/src/test/java/com/twelvemonkeys/io/enc/EncoderStreamTest.java b/common/common-io/src/test/java/com/twelvemonkeys/io/enc/EncoderStreamTest.java
index a4c8cdff..2c8d81ed 100644
--- a/common/common-io/src/test/java/com/twelvemonkeys/io/enc/EncoderStreamTest.java
+++ b/common/common-io/src/test/java/com/twelvemonkeys/io/enc/EncoderStreamTest.java
@@ -30,8 +30,6 @@
package com.twelvemonkeys.io.enc;
-import org.junit.Test;
-
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
@@ -39,7 +37,8 @@ import java.nio.ByteBuffer;
import java.util.Arrays;
import java.util.Random;
-import static org.junit.Assert.assertArrayEquals;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.*;
public class EncoderStreamTest {
diff --git a/common/common-io/src/test/java/com/twelvemonkeys/io/ole2/CompoundDocumentTest.java b/common/common-io/src/test/java/com/twelvemonkeys/io/ole2/CompoundDocumentTest.java
index a9efc698..cad57de6 100755
--- a/common/common-io/src/test/java/com/twelvemonkeys/io/ole2/CompoundDocumentTest.java
+++ b/common/common-io/src/test/java/com/twelvemonkeys/io/ole2/CompoundDocumentTest.java
@@ -31,9 +31,9 @@
package com.twelvemonkeys.io.ole2;
import com.twelvemonkeys.io.MemoryCacheSeekableStream;
-import org.junit.Test;
import javax.imageio.stream.MemoryCacheImageInputStream;
+import java.awt.image.ImageProducer;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
@@ -43,8 +43,8 @@ import java.nio.ByteOrder;
import java.util.SortedSet;
import java.util.TreeSet;
-import static org.junit.Assert.*;
-
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.*;
/**
* CompoundDocumentTestCase
*
@@ -59,8 +59,8 @@ public class CompoundDocumentTest {
protected final CompoundDocument createTestDocument() throws IOException {
URL input = getClass().getResource(SAMPLE_DATA);
- assertNotNull("Missing test resource!", input);
- assertEquals("Test resource not a file:// resource", "file", input.getProtocol());
+ assertNotNull(input, "Missing test resource!");
+ assertEquals( "file", input.getProtocol(), "Test resource not a file:// resource");
try {
return new CompoundDocument(new File(input.toURI()));
@@ -103,7 +103,7 @@ public class CompoundDocumentTest {
}
}
- @Test(expected = UnsupportedOperationException.class)
+ @Test
public void testChildEntriesUnmodifiable() throws IOException {
try (CompoundDocument document = createTestDocument()) {
Entry root = document.getRootEntry();
@@ -111,9 +111,10 @@ public class CompoundDocumentTest {
assertNotNull(root);
SortedSet children = root.getChildEntries();
-
- // Should not be allowed, as it modifies the internal structure
- children.remove(children.first());
+ assertThrows(UnsupportedOperationException.class, () -> {
+ // Should not be allowed, as it modifies the internal structure
+ children.remove(children.first());
+ });
}
}
@@ -128,7 +129,7 @@ public class CompoundDocumentTest {
Entry catalog = root.getChildEntry("Catalog");
assertNotNull(catalog);
- assertNotNull("Input stream may not be null", catalog.getInputStream());
+ assertNotNull(catalog.getInputStream(), "Input stream may not be null");
}
}
@@ -136,7 +137,7 @@ public class CompoundDocumentTest {
public void testReadCatalogInputStream() throws IOException {
InputStream input = getClass().getResourceAsStream(SAMPLE_DATA);
- assertNotNull("Missing test resource!", input);
+ assertNotNull(input, "Missing test resource!");
CompoundDocument document = new CompoundDocument(input);
Entry root = document.getRootEntry();
@@ -145,14 +146,14 @@ public class CompoundDocumentTest {
Entry catalog = root.getChildEntry("Catalog");
assertNotNull(catalog);
- assertNotNull("Input stream may not be null", catalog.getInputStream());
+ assertNotNull(catalog.getInputStream(), "Input stream may not be null");
}
@Test
public void testReadCatalogSeekableStream() throws IOException {
InputStream input = getClass().getResourceAsStream(SAMPLE_DATA);
- assertNotNull("Missing test resource!", input);
+ assertNotNull(input, "Missing test resource!");
CompoundDocument document = new CompoundDocument(new MemoryCacheSeekableStream(input));
Entry root = document.getRootEntry();
@@ -161,14 +162,14 @@ public class CompoundDocumentTest {
Entry catalog = root.getChildEntry("Catalog");
assertNotNull(catalog);
- assertNotNull("Input stream may not be null", catalog.getInputStream());
+ assertNotNull(catalog.getInputStream(), "Input stream may not be null");
}
@Test
public void testReadCatalogImageInputStream() throws IOException {
InputStream input = getClass().getResourceAsStream(SAMPLE_DATA);
- assertNotNull("Missing test resource!", input);
+ assertNotNull(input, "Missing test resource!");
MemoryCacheImageInputStream stream = new MemoryCacheImageInputStream(input);
stream.setByteOrder(ByteOrder.LITTLE_ENDIAN);
@@ -183,6 +184,6 @@ public class CompoundDocumentTest {
Entry catalog = root.getChildEntry("Catalog");
assertNotNull(catalog);
- assertNotNull("Input stream may not be null", catalog.getInputStream());
+ assertNotNull(catalog.getInputStream(), "Input stream may not be null");
}
}
diff --git a/common/common-io/src/test/java/com/twelvemonkeys/io/ole2/CompoundDocument_SeekableLittleEndianDataInputStreamTest.java b/common/common-io/src/test/java/com/twelvemonkeys/io/ole2/CompoundDocument_SeekableLittleEndianDataInputStreamTest.java
index c0b80b76..dfcf37b1 100644
--- a/common/common-io/src/test/java/com/twelvemonkeys/io/ole2/CompoundDocument_SeekableLittleEndianDataInputStreamTest.java
+++ b/common/common-io/src/test/java/com/twelvemonkeys/io/ole2/CompoundDocument_SeekableLittleEndianDataInputStreamTest.java
@@ -31,7 +31,7 @@
package com.twelvemonkeys.io.ole2;
import com.twelvemonkeys.io.*;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.io.ByteArrayInputStream;
diff --git a/common/common-io/src/test/java/com/twelvemonkeys/io/ole2/CompoundDocument_StreamTest.java b/common/common-io/src/test/java/com/twelvemonkeys/io/ole2/CompoundDocument_StreamTest.java
index 6bdd984a..5625e037 100644
--- a/common/common-io/src/test/java/com/twelvemonkeys/io/ole2/CompoundDocument_StreamTest.java
+++ b/common/common-io/src/test/java/com/twelvemonkeys/io/ole2/CompoundDocument_StreamTest.java
@@ -33,7 +33,6 @@ package com.twelvemonkeys.io.ole2;
import com.twelvemonkeys.io.InputStreamAbstractTest;
import com.twelvemonkeys.io.LittleEndianDataOutputStream;
import com.twelvemonkeys.io.MemoryCacheSeekableStream;
-import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -42,7 +41,8 @@ import java.io.InputStream;
import java.nio.charset.Charset;
import java.util.Arrays;
-import static org.junit.Assert.*;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.*;
/**
* CompoundDocument_StreamTestCase
@@ -165,8 +165,8 @@ public class CompoundDocument_StreamTest extends InputStreamAbstractTest {
count++;
}
- assertFalse("Short stream", count < 32);
- assertFalse("Stream overrun", count > 32);
+ assertFalse(count < 32, "Short stream");
+ assertFalse(count > 32, "Stream overrun");
}
@Test
diff --git a/common/common-io/src/test/java/com/twelvemonkeys/net/HTTPUtilTest.java b/common/common-io/src/test/java/com/twelvemonkeys/net/HTTPUtilTest.java
index f3912e92..3e51012d 100644
--- a/common/common-io/src/test/java/com/twelvemonkeys/net/HTTPUtilTest.java
+++ b/common/common-io/src/test/java/com/twelvemonkeys/net/HTTPUtilTest.java
@@ -30,9 +30,8 @@
package com.twelvemonkeys.net;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.*;
/**
* HTTPUtilTest
diff --git a/common/common-lang/src/test/java/com/twelvemonkeys/lang/BeanUtilTest.java b/common/common-lang/src/test/java/com/twelvemonkeys/lang/BeanUtilTest.java
index b256a68d..a29ae7e3 100755
--- a/common/common-lang/src/test/java/com/twelvemonkeys/lang/BeanUtilTest.java
+++ b/common/common-lang/src/test/java/com/twelvemonkeys/lang/BeanUtilTest.java
@@ -30,14 +30,13 @@
package com.twelvemonkeys.lang;
-import org.junit.Test;
-
import java.io.Serializable;
import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
import java.util.Map;
-import static org.junit.Assert.*;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.*;
/**
* BeanUtilTestCase
@@ -161,10 +160,8 @@ public class BeanUtilTest {
}
assertNotNull(bean.getAmbiguous());
- assertEquals("String converted rather than invoking setAmbiguous(String), ordering not predictable",
- "one", bean.getAmbiguous());
- assertSame("String converted rather than invoking setAmbiguous(String), ordering not predictable",
- value, bean.getAmbiguous());
+ assertEquals("one", bean.getAmbiguous(), "String converted rather than invoking setAmbiguous(String), ordering not predictable");
+ assertSame(value, bean.getAmbiguous(), "String converted rather than invoking setAmbiguous(String), ordering not predictable");
}
@Test
@@ -184,10 +181,10 @@ public class BeanUtilTest {
}
assertNotNull(bean.getAmbiguous());
- assertEquals("Integer converted rather than invoking setAmbiguous(Integer), ordering not predictable",
- 2, bean.getAmbiguous());
- assertSame("Integer converted rather than invoking setAmbiguous(Integer), ordering not predictable",
- value, bean.getAmbiguous());
+ assertEquals(2, bean.getAmbiguous(),
+ "Integer converted rather than invoking setAmbiguous(Integer), ordering not predictable");
+ assertSame(value, bean.getAmbiguous(),
+ "Integer converted rather than invoking setAmbiguous(Integer), ordering not predictable");
}
@Test
@@ -207,10 +204,8 @@ public class BeanUtilTest {
}
assertNotNull(bean.getAmbiguous());
- assertEquals("Object converted rather than invoking setAmbiguous(Object), ordering not predictable",
- value.getClass(), bean.getAmbiguous().getClass());
- assertSame("Object converted rather than invoking setAmbiguous(Object), ordering not predictable",
- value, bean.getAmbiguous());
+ assertEquals(value.getClass(), bean.getAmbiguous().getClass(), "Object converted rather than invoking setAmbiguous(Object), ordering not predictable");
+ assertSame(value, bean.getAmbiguous(), "Object converted rather than invoking setAmbiguous(Object), ordering not predictable");
}
static class TestBean {
diff --git a/common/common-lang/src/test/java/com/twelvemonkeys/lang/DateUtilTest.java b/common/common-lang/src/test/java/com/twelvemonkeys/lang/DateUtilTest.java
index 0dde4b48..5f823b88 100644
--- a/common/common-lang/src/test/java/com/twelvemonkeys/lang/DateUtilTest.java
+++ b/common/common-lang/src/test/java/com/twelvemonkeys/lang/DateUtilTest.java
@@ -30,16 +30,16 @@
package com.twelvemonkeys.lang;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-
import java.util.Arrays;
import java.util.Calendar;
import java.util.List;
import java.util.TimeZone;
-import static org.junit.Assert.assertEquals;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
+
+import static org.junit.jupiter.api.Assertions.*;
/**
* DateUtilTest
@@ -48,12 +48,9 @@ import static org.junit.Assert.assertEquals;
* @author last modified by $Author: haraldk$
* @version $Id: DateUtilTest.java,v 1.0 11.04.12 16:21 haraldk Exp$
*/
-@RunWith(Parameterized.class)
+
public class DateUtilTest {
- private final TimeZone timeZone;
-
- @Parameterized.Parameters
public static List