1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.imaging.formats.pnm;
18
19 import static org.junit.jupiter.api.Assertions.assertEquals;
20 import static org.junit.jupiter.api.Assertions.fail;
21
22 import java.io.ByteArrayInputStream;
23 import java.io.IOException;
24 import java.io.InputStream;
25
26 import org.junit.jupiter.api.Test;
27
28 public class PbmFileInfoTest {
29
30 @Test
31 public void testGetRGBThrowsIOException() throws IOException {
32 final PbmFileInfo pbmFileInfo = new PbmFileInfo(2764, 354, true);
33 final byte[] byteArray = new byte[2];
34 final InputStream inputStream = new ByteArrayInputStream(byteArray);
35 inputStream.read(byteArray);
36
37 try {
38 pbmFileInfo.getRgb(inputStream);
39 fail("Expecting exception: IOException");
40 } catch (final IOException e) {
41 assertEquals("PBM: Unexpected EOF", e.getMessage());
42 assertEquals(PbmFileInfo.class.getName(), e.getStackTrace()[0].getClassName());
43 }
44 }
45
46 }