1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.imaging.formats.rgbe;
18
19 import static org.junit.jupiter.api.Assertions.assertNotNull;
20 import static org.junit.jupiter.api.Assertions.assertThrows;
21
22 import java.awt.image.BufferedImage;
23 import java.io.File;
24 import java.io.IOException;
25 import java.util.List;
26
27 import org.apache.commons.imaging.ImageInfo;
28 import org.apache.commons.imaging.Imaging;
29 import org.apache.commons.imaging.ImagingException;
30 import org.apache.commons.imaging.bytesource.ByteSource;
31 import org.apache.commons.imaging.common.ImageMetadata;
32 import org.apache.commons.imaging.internal.Debug;
33 import org.apache.commons.imaging.test.TestResources;
34 import org.junit.jupiter.api.Test;
35
36 public class RgbeReadTest extends RgbeBaseTest {
37
38 @Test
39 public void test() throws IOException, ImagingException {
40 Debug.debug("start");
41
42 final List<File> images = getRgbeImages();
43
44 for (final File imageFile : images) {
45
46 Debug.debug("imageFile", imageFile);
47
48 final ImageMetadata metadata = Imaging.getMetadata(imageFile);
49 assertNotNull(metadata);
50
51 final ImageInfo imageInfo = Imaging.getImageInfo(imageFile);
52 assertNotNull(imageInfo);
53
54 final BufferedImage image = Imaging.getBufferedImage(imageFile);
55 assertNotNull(image);
56 }
57 }
58
59
60
61
62 @Test
63 public void testErrorDecompressingInvalidFile() {
64
65 final File inputFile = TestResources.resourceToFile("/IMAGING-219/timeout-9713502c9c371f1654b493650c16ab17c0444369.hdr");
66 final ByteSource byteSourceFile = ByteSource.file(inputFile);
67 final RgbeImagingParameters params = new RgbeImagingParameters();
68 assertThrows(ImagingException.class, () -> new RgbeImageParser().getBufferedImage(byteSourceFile, params));
69 }
70 }