1
2
3
4
5
6
7
8
9
10
11 package org.mule.transport.tcp.protocols;
12
13 import java.io.ByteArrayInputStream;
14
15 import org.junit.Test;
16
17 import static org.junit.Assert.assertEquals;
18
19 public class LengthProtocolTestCase extends DefaultProtocolTestCase
20 {
21
22 public LengthProtocolTestCase()
23 {
24 super(new LengthProtocol(), 1);
25 }
26
27 @Test
28 public void testFinalValue() throws Exception
29 {
30 byte[] result = (byte[]) getProtocol().read(new SlowInputStream());
31 assertEquals((byte) SlowInputStream.PAYLOAD, result[0]);
32 }
33
34
35
36 @Test
37 public void testGenerous() throws Exception
38 {
39 byte[] bytes = new byte[SlowInputStream.FULL_LENGTH];
40 for (int i = 0; i < SlowInputStream.FULL_LENGTH; ++i)
41 {
42 bytes[i] = (byte) SlowInputStream.CONTENTS[i];
43 }
44 ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
45 byte[] result = (byte[]) getProtocol().read(bis);
46 assertEquals((byte) SlowInputStream.PAYLOAD, result[0]);
47 }
48
49 }