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