View Javadoc

1   /*
2    * $Id: FileRuntimeExceptionStrategyFunctionalTestCase.java 19191 2010-08-25 21:05:23Z tcarlson $
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  
11  package org.mule.test.integration.transport.file;
12  
13  import org.mule.tck.FunctionalTestCase;
14  import org.mule.util.FileUtils;
15  
16  import java.io.File;
17  
18  public class FileRuntimeExceptionStrategyFunctionalTestCase extends FunctionalTestCase
19  {
20      protected String getConfigResources()
21      {
22          return "org/mule/test/integration/providers/file/file-runtime-exception-strategy.xml";
23      }
24  
25      public void testExceptionInTransformer() throws Exception
26      {
27          File f = FileUtils.newFile("./.mule/in/test.txt");
28          f.createNewFile();
29  
30          // try a couple of times with backoff strategy, then fail
31          File errorFile = FileUtils.newFile("./.mule/errors/test-0.out");
32          boolean testSucceded = false;
33          int timesTried = 0;
34          while (timesTried <= 3)
35          {
36              Thread.sleep(500 * ++timesTried);
37              if (errorFile.exists())
38              {
39                  testSucceded = true;
40                  break;
41              }
42          }
43  
44          if (!testSucceded)
45          {
46              fail("Exception strategy hasn't moved the file to the error folder.");
47          }
48      }
49  
50  }