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:
Vyshak Puthusseri
2024-11-12 14:43:15 +05:30
committed by GitHub
parent a67fdd4b80
commit 543acce8a3
194 changed files with 2554 additions and 3086 deletions
@@ -32,8 +32,9 @@ package com.twelvemonkeys.imageio.plugins.icns;
import com.twelvemonkeys.imageio.util.ImageReaderAbstractTest;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import javax.imageio.spi.ImageReaderSpi;
import java.awt.*;
@@ -126,14 +127,14 @@ public class ICNSImageReaderTest extends ImageReaderAbstractTest<ICNSImageReader
}
@Test
@Ignore("Known issue: Subsampled reading not supported")
@Disabled("Known issue: Subsampled reading not supported")
@Override
public void testReadWithSubsampleParamPixels() throws IOException {
super.testReadWithSubsampleParamPixels();
}
@Test
@Ignore("Known issue: Source region reading not supported")
@Disabled("Known issue: Source region reading not supported")
@Override
public void testReadWithSourceRegionParamEqualImage() throws IOException {
super.testReadWithSourceRegionParamEqualImage();
@@ -32,8 +32,6 @@ package com.twelvemonkeys.imageio.plugins.icns;
import com.twelvemonkeys.imageio.util.ImageWriterAbstractTest;
import org.junit.Test;
import javax.imageio.IIOImage;
import javax.imageio.ImageIO;
import javax.imageio.ImageWriter;
@@ -45,8 +43,9 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.List;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
import static java.util.Arrays.asList;
import static org.junit.Assert.assertTrue;
/**
* ICNSImageWriterTest.
@@ -78,15 +77,14 @@ public class ICNSImageWriterTest extends ImageWriterAbstractTest<ICNSImageWriter
);
}
@Test(expected = IllegalArgumentException.class)
@Test
public void testWriteNonSquare() throws IOException {
// ICNS only supports square icons (except some arcane 16x12 we don't currently support)
ImageWriter writer = createWriter();
try (ImageOutputStream stream = ImageIO.createImageOutputStream(new ByteArrayOutputStream())) {
writer.setOutput(stream);
writer.write(new BufferedImage(32, 64, BufferedImage.TYPE_INT_ARGB));
assertThrows(IllegalArgumentException.class, () -> writer.write(new BufferedImage(32, 64, BufferedImage.TYPE_INT_ARGB)));
}
finally {
@@ -94,7 +92,7 @@ public class ICNSImageWriterTest extends ImageWriterAbstractTest<ICNSImageWriter
}
}
@Test(expected = IllegalArgumentException.class)
@Test
public void testWriteBadSize() throws IOException {
// ICNS only supports sizes in multiples of 2 (16, 32, 64, ..., 1024 + 48 and 96)
ImageWriter writer = createWriter();
@@ -102,7 +100,7 @@ public class ICNSImageWriterTest extends ImageWriterAbstractTest<ICNSImageWriter
writer.setOutput(stream);
writer.write(new BufferedImage(17, 17, BufferedImage.TYPE_INT_ARGB));
assertThrows(IllegalArgumentException.class, () -> writer.write(new BufferedImage(17, 17, BufferedImage.TYPE_INT_ARGB)));
}
finally {
@@ -121,7 +119,7 @@ public class ICNSImageWriterTest extends ImageWriterAbstractTest<ICNSImageWriter
}
}
@Test(expected = IllegalStateException.class)
@Test
public void testWriteSequenceNotStarted() throws IOException {
// ICNS only supports sizes in multiples of 2 (16, 32, 64, ..., 1024 + 48 and 96)
ImageWriter writer = createWriter();
@@ -130,7 +128,7 @@ public class ICNSImageWriterTest extends ImageWriterAbstractTest<ICNSImageWriter
writer.setOutput(stream);
BufferedImage image = new BufferedImage(32, 32, BufferedImage.TYPE_INT_ARGB);
writer.writeToSequence(new IIOImage(image, null, null), writer.getDefaultWriteParam());
assertThrows(IllegalStateException.class, () -> writer.writeToSequence(new IIOImage(image, null, null), writer.getDefaultWriteParam()));
}
finally {
@@ -138,21 +136,21 @@ public class ICNSImageWriterTest extends ImageWriterAbstractTest<ICNSImageWriter
}
}
@Test(expected = IllegalStateException.class)
@Test
public void testEndSequenceNotStarted() throws IOException {
// ICNS only supports sizes in multiples of 2 (16, 32, 64, ..., 1024 + 48 and 96)
ImageWriter writer = createWriter();
try (ImageOutputStream stream = ImageIO.createImageOutputStream(new ByteArrayOutputStream())) {
writer.setOutput(stream);
writer.endWriteSequence();
assertThrows(IllegalStateException.class, () -> writer.endWriteSequence());
}
finally {
writer.dispose();
}
}
@Test(expected = IllegalStateException.class)
@Test
public void testPrepareSequenceAlreadyStarted() throws IOException {
// ICNS only supports sizes in multiples of 2 (16, 32, 64, ..., 1024 + 48 and 96)
ImageWriter writer = createWriter();
@@ -160,7 +158,7 @@ public class ICNSImageWriterTest extends ImageWriterAbstractTest<ICNSImageWriter
writer.setOutput(stream);
writer.prepareWriteSequence(null);
writer.prepareWriteSequence(null);
assertThrows(IllegalStateException.class, () -> writer.prepareWriteSequence(null));
}
finally {
writer.dispose();