• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package software.amazon.eventstream;
2 
3 import org.junit.jupiter.api.Test;
4 
5 import java.nio.ByteBuffer;
6 
7 import static org.junit.jupiter.api.Assertions.assertThrows;
8 
9 public class PreludeTest {
10     @Test
maxPayloadSize()11     public void maxPayloadSize() throws Exception {
12         ByteBuffer buf = ByteBuffer.wrap(new byte[15]);
13         buf.putInt(16777217 + 19); // total length
14         buf.put((byte) 1); // ApplicationData
15         buf.putShort((short) 0); // unmodeled data
16         buf.putInt(0); // headers_length
17         buf.putInt(0xf0c8e628); // prelude_crc
18         buf.flip();
19 
20         assertThrows(IllegalArgumentException.class, () -> Prelude.decode(buf));
21     }
22 
23     @Test
maxHeaderSize()24     public void maxHeaderSize() throws Exception {
25         ByteBuffer buf = ByteBuffer.wrap(new byte[15]);
26         buf.putInt(131073 + 19); // total length
27         buf.put((byte) 1); // ApplicationData
28         buf.putShort((short) 0); // unmodeled data
29         buf.putInt(131073); // headers_length
30         buf.putInt(0x49fd415c); // prelude_crc
31         buf.flip();
32 
33         assertThrows(IllegalArgumentException.class, () -> Prelude.decode(buf));
34     }
35 }
36