1
2
3
4
5
6
7
8
9
10
11 package org.mule.transport.tcp.integration;
12
13 import org.mule.tck.functional.FunctionalStreamingTestComponent;
14
15 import java.io.IOException;
16 import java.io.InputStream;
17 import java.net.SocketException;
18 import java.net.SocketTimeoutException;
19
20
21
22
23
24
25
26 public class EOFStreamingTestComponent extends FunctionalStreamingTestComponent
27 {
28 protected int read(InputStream is, byte[] buffer) throws IOException
29 {
30 int len;
31 try
32 {
33 do
34 {
35 len = is.read(buffer, 0, buffer.length);
36 if (0 == len)
37 {
38
39
40 try
41 {
42 Thread.sleep(50);
43 }
44 catch (InterruptedException e)
45 {
46
47 }
48 }
49 }
50 while (0 == len);
51 return len;
52 }
53 catch (SocketException e)
54 {
55
56 logger.info("Socket exception occured: " + e.getMessage());
57 return -1;
58 }
59 catch (SocketTimeoutException e)
60 {
61 logger.debug("Socket timeout.");
62 return -1;
63 }
64 }
65
66 }