mirror of
https://github.com/haraldk/TwelveMonkeys.git
synced 2026-04-30 00:00:01 -04:00
Upgrade to Junit5 (#1050)
* chore: Update to junit5 for servlet package * chore: Update to junit5 for contrib package * chore: Update to junit5 for common-image package * chore: Update to junit5 for common-lang package * chore: Update to junit5 for entire project files * fix: test case for JPEGImageReaderTest failed for java 8 and 11 assertEquals was using old signature of junit4. * Update common/common-io/src/test/java/com/twelvemonkeys/io/InputStreamAbstractTest.java Co-authored-by: Harald Kuhr <harald.kuhr@gmail.com> * Update common/common-io/src/test/java/com/twelvemonkeys/io/InputStreamAbstractTest.java Co-authored-by: Harald Kuhr <harald.kuhr@gmail.com> * Update imageio/imageio-bmp/src/test/java/com/twelvemonkeys/imageio/plugins/bmp/BMPImageReaderTest.java Co-authored-by: Harald Kuhr <harald.kuhr@gmail.com> * Update imageio/imageio-jpeg/src/test/java/com/twelvemonkeys/imageio/plugins/jpeg/JPEGImageReaderTest.java Co-authored-by: Harald Kuhr <harald.kuhr@gmail.com> * Update imageio/imageio-tiff/src/test/java/com/twelvemonkeys/imageio/plugins/tiff/TIFFImageMetadataTest.java Co-authored-by: Harald Kuhr <harald.kuhr@gmail.com> * Update imageio/imageio-tiff/src/test/java/com/twelvemonkeys/imageio/plugins/tiff/TIFFImageReaderTest.java Co-authored-by: Harald Kuhr <harald.kuhr@gmail.com> * Update imageio/imageio-tiff/src/test/java/com/twelvemonkeys/imageio/plugins/tiff/TIFFImageWriterTest.java Co-authored-by: Harald Kuhr <harald.kuhr@gmail.com> * Update imageio/imageio-core/src/test/java/com/twelvemonkeys/imageio/stream/BufferedChannelImageInputStreamTest.java Co-authored-by: Harald Kuhr <harald.kuhr@gmail.com> * Update imageio/imageio-core/src/test/java/com/twelvemonkeys/imageio/stream/BufferedChannelImageInputStreamTest.java Co-authored-by: Harald Kuhr <harald.kuhr@gmail.com> * refactor: few indentation changes and missed test case - review change related to missing test annotation - unwanted new lines inside test case - duplicate assertions * refactor: moved the lambda expression to method reference * review: testNotNullWithParameterNull catch block was never executed. Added the suggested change * Apply suggestions from code review chore: adjust suggested indentation Co-authored-by: Harald Kuhr <harald.kuhr@gmail.com> * Update imageio/imageio-core/src/test/java/com/twelvemonkeys/imageio/util/ImageReaderAbstractTest.java Co-authored-by: Harald Kuhr <harald.kuhr@gmail.com> * Update imageio/imageio-core/src/test/java/com/twelvemonkeys/imageio/util/ImageReaderAbstractTest.java Co-authored-by: Harald Kuhr <harald.kuhr@gmail.com> * Update imageio/imageio-core/src/test/java/com/twelvemonkeys/imageio/util/ImageWriterAbstractTest.java Co-authored-by: Harald Kuhr <harald.kuhr@gmail.com> * refactor: using assertTimeout doesnot kill the execution, even if the timeout happens. It is better to use assertTimeoutPreemptively in cases, where we really want to kill the execution after timeout. https://stackoverflow.com/questions/57116801/how-to-fail-a-test-after-a-timeout-is-exceeded-in-junit-5/57116959#57116959 --------- Co-authored-by: Harald Kuhr <harald.kuhr@gmail.com>
This commit is contained in:
committed by
GitHub
parent
a67fdd4b80
commit
543acce8a3
+3
-4
@@ -34,8 +34,6 @@ import com.twelvemonkeys.io.FastByteArrayOutputStream;
|
||||
import com.twelvemonkeys.io.LittleEndianDataInputStream;
|
||||
import com.twelvemonkeys.io.LittleEndianDataOutputStream;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.DataInput;
|
||||
import java.io.DataInputStream;
|
||||
@@ -45,8 +43,9 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
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.*;
|
||||
|
||||
|
||||
/**
|
||||
* HorizontalDeDifferencingStreamTest
|
||||
|
||||
+25
-23
@@ -33,7 +33,6 @@ package com.twelvemonkeys.imageio.plugins.psd;
|
||||
import com.twelvemonkeys.imageio.util.ImageReaderAbstractTest;
|
||||
import com.twelvemonkeys.imageio.util.ProgressListenerBase;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
@@ -49,13 +48,15 @@ import java.awt.color.*;
|
||||
import java.awt.image.*;
|
||||
import java.io.EOFException;
|
||||
import java.io.IOException;
|
||||
import java.time.Duration;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
/**
|
||||
* PSDImageReaderTest
|
||||
@@ -244,7 +245,7 @@ public class PSDImageReaderTest extends ImageReaderAbstractTest<PSDImageReader>
|
||||
fail("Expected IndexOutOfBoundsException");
|
||||
}
|
||||
catch (IndexOutOfBoundsException expected) {
|
||||
assertTrue(expected.getMessage(), expected.getMessage().toLowerCase().contains("index"));
|
||||
assertTrue(expected.getMessage().toLowerCase().contains("index"), expected.getMessage());
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -252,7 +253,7 @@ public class PSDImageReaderTest extends ImageReaderAbstractTest<PSDImageReader>
|
||||
fail("Expected IndexOutOfBoundsException");
|
||||
}
|
||||
catch (IndexOutOfBoundsException expected) {
|
||||
assertTrue(expected.getMessage(), expected.getMessage().toLowerCase().contains("index"));
|
||||
assertTrue(expected.getMessage().toLowerCase().contains("index"), expected.getMessage());
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -261,7 +262,7 @@ public class PSDImageReaderTest extends ImageReaderAbstractTest<PSDImageReader>
|
||||
}
|
||||
catch (IndexOutOfBoundsException expected) {
|
||||
// Sloppy...
|
||||
assertTrue(expected.getMessage(), expected.getMessage().toLowerCase().contains("-2"));
|
||||
assertTrue(expected.getMessage().toLowerCase().contains("-2"), expected.getMessage());
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -269,7 +270,7 @@ public class PSDImageReaderTest extends ImageReaderAbstractTest<PSDImageReader>
|
||||
fail("Expected IndexOutOfBoundsException");
|
||||
}
|
||||
catch (IndexOutOfBoundsException expected) {
|
||||
assertTrue(expected.getMessage(), expected.getMessage().toLowerCase().contains("index"));
|
||||
assertTrue(expected.getMessage().toLowerCase().contains("index"), expected.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -312,7 +313,7 @@ public class PSDImageReaderTest extends ImageReaderAbstractTest<PSDImageReader>
|
||||
@Override
|
||||
public void thumbnailProgress(final ImageReader pSource, final float pPercentageDone) {
|
||||
// Optional
|
||||
assertEquals("Listener invoked out of sequence", 1, seqeunce.size());
|
||||
assertEquals(1, seqeunce.size(), "Listener invoked out of sequence");
|
||||
assertTrue(pPercentageDone >= lastPercentageDone);
|
||||
lastPercentageDone = pPercentageDone;
|
||||
}
|
||||
@@ -321,7 +322,7 @@ public class PSDImageReaderTest extends ImageReaderAbstractTest<PSDImageReader>
|
||||
BufferedImage thumbnail = imageReader.readThumbnail(0, 0);
|
||||
assertNotNull(thumbnail);
|
||||
|
||||
assertEquals("Listeners not invoked", 2, seqeunce.size());
|
||||
assertEquals(2, seqeunce.size(), "Listeners not invoked");
|
||||
assertEquals("started", seqeunce.get(0));
|
||||
assertEquals("complete", seqeunce.get(1));
|
||||
}
|
||||
@@ -376,7 +377,7 @@ public class PSDImageReaderTest extends ImageReaderAbstractTest<PSDImageReader>
|
||||
}
|
||||
}
|
||||
|
||||
assertTrue("RAW image type not in type iterator", found);
|
||||
assertTrue(found, "RAW image type not in type iterator");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -698,27 +699,28 @@ public class PSDImageReaderTest extends ImageReaderAbstractTest<PSDImageReader>
|
||||
}
|
||||
}
|
||||
|
||||
@Test(timeout = 1000)
|
||||
@Test
|
||||
public void testBrokenPackBitsThrowsEOFException() throws IOException {
|
||||
PSDImageReader imageReader = createReader();
|
||||
assertTimeoutPreemptively(Duration.ofMillis(1000), () -> {
|
||||
PSDImageReader imageReader = createReader();
|
||||
|
||||
try (ImageInputStream stream = ImageIO.createImageInputStream(getClassLoaderResource("/broken-psd/short-packbits.psd"))) {
|
||||
imageReader.setInput(stream);
|
||||
try (ImageInputStream stream = ImageIO.createImageInputStream(getClassLoaderResource("/broken-psd/short-packbits.psd"))) {
|
||||
imageReader.setInput(stream);
|
||||
|
||||
assertEquals(1, imageReader.getNumImages(true));
|
||||
assertEquals(1, imageReader.getNumImages(true));
|
||||
|
||||
assertEquals(427, imageReader.getWidth(0));
|
||||
assertEquals(107, imageReader.getHeight(0));
|
||||
assertEquals(427, imageReader.getWidth(0));
|
||||
assertEquals(107, imageReader.getHeight(0));
|
||||
|
||||
try {
|
||||
imageReader.read(0);
|
||||
try {
|
||||
imageReader.read(0);
|
||||
|
||||
fail("Expected EOFException, is the test broken?");
|
||||
fail("Expected EOFException, is the test broken?");
|
||||
} catch (EOFException expected) {
|
||||
assertTrue(expected.getMessage().contains("PackBits"));
|
||||
}
|
||||
}
|
||||
catch (EOFException expected) {
|
||||
assertTrue(expected.getMessage().contains("PackBits"));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
+2
-2
@@ -33,14 +33,14 @@ package com.twelvemonkeys.imageio.plugins.psd;
|
||||
import com.twelvemonkeys.imageio.stream.ByteArrayImageInputStream;
|
||||
import com.twelvemonkeys.imageio.stream.DirectImageInputStream;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.imageio.stream.ImageInputStream;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import static com.twelvemonkeys.imageio.plugins.psd.PSDUtil.createDecompressorStream;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class PSDUtilDecompressorStreamTest {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user