1
2
3
4
5
6
7
8
9
10
11 package org.mule.transport.email.issues;
12
13 import org.mule.api.transport.Connector;
14 import org.mule.transport.email.AbstractRetrieveMailConnector;
15 import org.mule.transport.email.connectors.ImapConnectorTestCase;
16 import org.mule.util.FileUtils;
17
18 import java.io.File;
19
20 import static org.junit.Assert.assertFalse;
21 import static org.junit.Assert.assertTrue;
22
23 public abstract class AbstractBaseBackupMule2050TestCase extends ImapConnectorTestCase
24 {
25
26 private boolean backupEnabled;
27
28 public AbstractBaseBackupMule2050TestCase(boolean backupEnabled)
29 {
30 this.backupEnabled = backupEnabled;
31 }
32
33 @Override
34 public Connector createConnector() throws Exception
35 {
36 Connector connector = super.createConnector();
37 ((AbstractRetrieveMailConnector) connector).setBackupEnabled(backupEnabled);
38 return connector;
39 }
40
41 @Override
42 public void testReceiver() throws Exception
43 {
44 File dir = FileUtils.newFile(muleContext.getConfiguration().getWorkingDirectory() + "/mail/INBOX");
45 FileUtils.deleteTree(new File(muleContext.getConfiguration().getWorkingDirectory() + "/mail"));
46 assertFalse("Mail backup file already exists: " + dir.getAbsolutePath(), dir.exists());
47 debug(dir);
48 super.testReceiver();
49 debug(dir);
50 assertTrue(dir.getAbsolutePath(), dir.exists() == backupEnabled);
51 }
52
53 protected void debug(File dir)
54 {
55 logger.debug(dir.getAbsolutePath() + " exists? " + dir.exists());
56 }
57
58 }