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 public abstract class AbstractBaseBackupMule2050TestCase extends ImapConnectorTestCase
21 {
22
23 private boolean backupEnabled;
24
25 public AbstractBaseBackupMule2050TestCase(boolean backupEnabled)
26 {
27 this.backupEnabled = backupEnabled;
28 }
29
30 @Override
31 public Connector createConnector() throws Exception
32 {
33 Connector connector = super.createConnector();
34 ((AbstractRetrieveMailConnector) connector).setBackupEnabled(backupEnabled);
35 return connector;
36 }
37
38 public void testReceiver() throws Exception
39 {
40 File dir = FileUtils.newFile(muleContext.getConfiguration().getWorkingDirectory() + "/mail/INBOX");
41 FileUtils.deleteTree(new File(muleContext.getConfiguration().getWorkingDirectory() + "/mail"));
42 assertFalse("Mail backup file already exists: " + dir.getAbsolutePath(), dir.exists());
43 debug(dir);
44 super.testReceiver();
45 debug(dir);
46 assertTrue(dir.getAbsolutePath(), dir.exists() == backupEnabled);
47 }
48
49 protected void debug(File dir)
50 {
51 logger.debug(dir.getAbsolutePath() + " exists? " + dir.exists());
52 }
53
54 }