Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ This lets you add the dependencies in your project whatever the JDK used, and st
| Plugin | Format | Read | Write | Metadata | TwelveMonkeys Tests | Notes |
|----------------------|----------------------------------------------------------------------------------------------------------------------|------|-------|----------|---------------------|------------------------------------|
| [jxl](imageio-jxl) | [Jpeg XL](https://jpeg.org/jpegxl/) | ✔ | - | - | ✔ | See limitations in the plugin page |
| [webp](imageio-webp) | [WebP](https://developers.google.com/speed/webp) | ✔ | - | - | ✔ | See limitations in the plugin page |
| [webp](imageio-webp) | [WebP](https://developers.google.com/speed/webp) | ✔ | | - | ✔ | See limitations in the plugin page |
| [heif](imageio-heif) | [HEIF](https://en.wikipedia.org/wiki/High_Efficiency_Image_File_Format) & [AVIF](https://en.wikipedia.org/wiki/AVIF) | ✔ | - | - | ✔ | See limitations in the plugin page |

When possible, the plugins will use the extensive test suite
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=1.0.0
version=1.1.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package com.github.gotson.nightmonkeys.common.imageio;

import org.apache.commons.collections4.IteratorUtils;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;

import javax.imageio.ImageIO;
import javax.imageio.ImageWriter;
import java.io.IOException;
import java.net.URL;
import java.util.*;
import java.util.stream.StreamSupport;

import static org.assertj.core.api.Assertions.assertThat;

@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public abstract class NoOpImageWriterAbstractTest {
protected abstract List<String> getFormatNames();

protected abstract List<String> getSuffixes();

protected abstract List<String> getMIMETypes();

@BeforeAll
public void printInformation() throws IOException {
System.out.println("java.version: " + System.getProperty("java.version"));
System.out.println("java.library.path: " + System.getProperty("java.library.path"));
Enumeration<URL> spiFiles = ClassLoader.getSystemResources("META-INF/services/javax.imageio.spi.ImageWriterSpi");
Spliterator<URL> spliterator = Spliterators.spliteratorUnknownSize(IteratorUtils.asIterator(spiFiles), Spliterator.ORDERED);
StreamSupport.stream(spliterator, false).forEachOrdered(x -> System.out.println("SPI File: " + x));
}

@ParameterizedTest
@MethodSource("getFormatNames")
public void testWriterIsNotRegisteredByFormatName(String formatName) {
ArrayList<ImageWriter> writers = new ArrayList<>();
ImageIO.getImageWritersByFormatName(formatName).forEachRemaining(writers::add);

assertThat(writers).isEmpty();
}

@ParameterizedTest
@MethodSource("getSuffixes")
public void testWriterIsNotRegisteredBySuffix(String suffix) {
ArrayList<ImageWriter> writers = new ArrayList<>();
ImageIO.getImageWritersBySuffix(suffix).forEachRemaining(writers::add);

assertThat(writers).isEmpty();
}

@ParameterizedTest
@MethodSource("getMIMETypes")
public void testWriterIsNotRegisteredByMIMEType(String mimeType) {
ArrayList<ImageWriter> writers = new ArrayList<>();
ImageIO.getImageWritersByMIMEType(mimeType).forEachRemaining(writers::add);

assertThat(writers).isEmpty();
}
}
Loading