View Javadoc

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