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