1
2
3
4
5
6
7
8
9
10
11 package org.mule.test.integration.streaming;
12
13
14 import org.mule.tck.DynamicPortTestCase;
15 import org.mule.util.FileUtils;
16
17 import java.io.File;
18
19 public class FileToTcpStreamingTestCase extends DynamicPortTestCase
20 {
21 @Override
22 protected void doTearDown() throws Exception
23 {
24 FileUtils.deleteDirectory(FileUtils.newFile(muleContext.getConfiguration().getWorkingDirectory() + "/test-data"));
25 }
26
27 @Override
28 protected String getConfigResources()
29 {
30 return "org/mule/test/integration/streaming/file-to-tcp-streaming.xml";
31 }
32
33 @Override
34 protected int getNumPortsToFind()
35 {
36 return 1;
37 }
38
39 public void testStreamingFromFileToTcp() throws Exception
40 {
41 String text = "\nblah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah " +
42 "\nblah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah " +
43 "\nblah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah " +
44 "\nblah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah\n\n";
45
46 String basepath = muleContext.getConfiguration().getWorkingDirectory() + "/test-data";
47
48 FileUtils.stringToFile(basepath + "/in/foo.txt", text);
49
50 Thread.sleep(4000);
51
52 File file = FileUtils.newFile(basepath, "out/foo.txt.processed");
53 System.out.println("reading " + file.getAbsolutePath());
54 String result = FileUtils.readFileToString(file, "UTF8");
55 assertEquals(text, result);
56 }
57 }