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