1
2
3
4
5
6
7 package org.mule.test.integration.streaming;
8
9
10 import org.mule.tck.junit4.FunctionalTestCase;
11 import org.mule.tck.junit4.rule.DynamicPort;
12 import org.mule.util.FileUtils;
13
14 import java.io.File;
15
16 import org.junit.Rule;
17 import org.junit.Test;
18
19 import static org.junit.Assert.assertEquals;
20
21 public class FileToTcpStreamingTestCase extends FunctionalTestCase
22 {
23 @Rule
24 public DynamicPort dynamicPort = new DynamicPort("port1");
25
26 @Override
27 protected String getConfigResources()
28 {
29 return "org/mule/test/integration/streaming/file-to-tcp-streaming.xml";
30 }
31
32 @Override
33 protected void doTearDown() throws Exception
34 {
35 FileUtils.deleteDirectory(FileUtils.newFile(muleContext.getConfiguration().getWorkingDirectory() + "/test-data"));
36 }
37
38 @Test
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 }