View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.test.integration.transport.file;
8   
9   import org.mule.tck.junit4.FunctionalTestCase;
10  import org.mule.util.FileUtils;
11  
12  import java.io.File;
13  
14  import org.junit.Test;
15  
16  import static org.junit.Assert.fail;
17  
18  public class FileRuntimeExceptionStrategyFunctionalTestCase extends FunctionalTestCase
19  {
20      @Override
21      protected String getConfigResources()
22      {
23          return "org/mule/test/integration/providers/file/file-runtime-exception-strategy.xml";
24      }
25  
26      @Test
27      public void testExceptionInTransformer() throws Exception
28      {
29          File f = FileUtils.newFile("./.mule/in/test.txt");
30          f.createNewFile();
31  
32          // try a couple of times with backoff strategy, then fail
33          File errorFile = FileUtils.newFile("./.mule/errors/test-0.out");
34          boolean testSucceded = false;
35          int timesTried = 0;
36          while (timesTried <= 3)
37          {
38              Thread.sleep(500 * ++timesTried);
39              if (errorFile.exists())
40              {
41                  testSucceded = true;
42                  break;
43              }
44          }
45  
46          if (!testSucceded)
47          {
48              fail("Exception strategy hasn't moved the file to the error folder.");
49          }
50      }
51  
52  }