1   /*
2    * $Id: FilePersistenceTestCase.java 11343 2008-03-13 10:58:26Z tcarlson $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.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.persistence;
12  
13  
14  import org.mule.module.client.MuleClient;
15  import org.mule.tck.FunctionalTestCase;
16  import org.mule.util.FileUtils;
17  
18  import java.io.File;
19  
20  public class FilePersistenceTestCase extends FunctionalTestCase
21  {
22  
23      protected String getConfigResources()
24      {
25          return "org/mule/test/integration/persistence/file-persistence-config.xml";
26      }
27  
28      public void testFilesStored() throws Exception
29      {
30  
31          // Note that the FunctionalTestCase will remove the working directory after
32          // each execution
33          String path = muleContext.getConfiguration().getWorkingDirectory() + "/queuestore/test.queue";
34          File store = FileUtils.newFile(path);
35          assertFalse(store.exists());
36  
37          MuleClient client = new MuleClient();
38          client.send("vm://test.queue", "test", null);
39          File[] files = store.listFiles();
40          assertNotNull(files);
41          assertEquals(1, files.length);
42  
43          muleContext.getRegistry().lookupService("TestComponent").start();
44          // give the service some time to initialise
45          Thread.sleep(2000);
46          files = store.listFiles();
47          assertNotNull(files);
48          assertEquals(0, files.length);
49  
50      }
51  }