1
2
3
4
5
6
7 package org.mule.test.integration.persistence;
8
9
10 import org.mule.module.client.MuleClient;
11 import org.mule.tck.junit4.FunctionalTestCase;
12 import org.mule.util.FileUtils;
13
14 import java.io.File;
15
16 import org.junit.Test;
17
18 import static org.junit.Assert.assertEquals;
19 import static org.junit.Assert.assertFalse;
20 import static org.junit.Assert.assertNotNull;
21
22 public class FilePersistenceTestCase extends FunctionalTestCase
23 {
24
25 @Override
26 protected String getConfigResources()
27 {
28 return "org/mule/test/integration/persistence/file-persistence-config.xml";
29 }
30
31 @Test
32 public void testFilesStored() throws Exception
33 {
34
35
36 String path = muleContext.getConfiguration().getWorkingDirectory() + "/queuestore/test.queue";
37 File store = FileUtils.newFile(path);
38 assertFalse(store.exists());
39
40 MuleClient client = new MuleClient(muleContext);
41 client.dispatch("vm://test.queue", "test", null);
42
43 Thread.sleep(500);
44 File[] files = store.listFiles();
45 assertNotNull(files);
46 assertEquals(1, files.length);
47
48 muleContext.getRegistry().lookupService("TestComponent").start();
49
50 Thread.sleep(2000);
51 files = store.listFiles();
52 assertNotNull(files);
53 assertEquals(0, files.length);
54 }
55 }