View Javadoc

1   /*
2    * $Id: FileToTcpStreamingTestCase.java 19864 2010-10-08 06:56:32Z dirk.olmes $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  package org.mule.test.integration.streaming;
11  
12  
13  import org.mule.tck.DynamicPortTestCase;
14  import org.mule.util.FileUtils;
15  
16  import java.io.File;
17  
18  public class FileToTcpStreamingTestCase extends DynamicPortTestCase
19  {
20      @Override
21      protected void doTearDown() throws Exception
22      {
23          FileUtils.deleteDirectory(FileUtils.newFile(muleContext.getConfiguration().getWorkingDirectory() + "/test-data"));
24      }
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 int getNumPortsToFind()
34      {
35          return 1;
36      }
37  
38      public void testStreamingFromFileToTcp() throws Exception
39      {
40          String text = "\nblah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah " +
41                  "\nblah blah blah blah 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\n\n";
44  
45          String basepath = muleContext.getConfiguration().getWorkingDirectory() + "/test-data";
46          
47          FileUtils.stringToFile(basepath + "/in/foo.txt", text);
48  
49          Thread.sleep(4000);
50  
51          File file = FileUtils.newFile(basepath, "out/foo.txt.processed");
52          System.out.println("reading " + file.getAbsolutePath());
53          String result = FileUtils.readFileToString(file, "UTF8");
54          assertEquals(text, result);
55      }
56  }