1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.imaging.formats.jpeg.decoder;
18
19 import static org.junit.jupiter.api.Assertions.assertThrows;
20
21 import org.apache.commons.imaging.ImagingException;
22 import org.junit.jupiter.api.Test;
23
24
25
26
27
28
29 public class JpegInputStreamTest {
30
31 @Test
32 public void testNextBitThrowsImageReadExceptionOne() {
33 final int[] byteArray = new int[6];
34 byteArray[0] = (byte) -1;
35 byteArray[1] = (byte) 74;
36 final JpegInputStream jpegInputStream = new JpegInputStream(byteArray);
37
38 assertThrows(ImagingException.class, jpegInputStream::nextBit);
39
40 }
41
42 @Test
43 public void testNextBitThrowsImageReadExceptionTwo() {
44 final int[] byteArray = {};
45 final JpegInputStream jpegInputStream = new JpegInputStream(byteArray);
46
47 assertThrows(IllegalStateException.class, jpegInputStream::nextBit);
48
49 }
50
51 }