1   /*
2    * $Id: AbstractBaseBackupMule2050TestCase.java 7972 2007-08-21 12:51:23Z holger $
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.providers.email.issues;
12  
13  import org.mule.MuleManager;
14  import org.mule.providers.email.AbstractRetrieveMailConnector;
15  import org.mule.providers.email.ImapConnectorTestCase;
16  import org.mule.umo.provider.UMOConnector;
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 UMOConnector createConnector(boolean init) throws Exception
32      {
33          UMOConnector connector = super.createConnector(init);
34          ((AbstractRetrieveMailConnector) connector).setBackupEnabled(backupEnabled);
35          return connector;
36      }
37  
38      public void doTestReceiver() throws Exception
39      {
40          File dir = new File(MuleManager.getConfiguration().getWorkingDirectory() + "/mail/INBOX");
41          assertFalse("Mail backup file already exists: " + dir.getAbsolutePath(), dir.exists());
42          debug(dir);
43          super.doTestReceiver();
44          debug(dir);
45          assertTrue(dir.getAbsolutePath(), dir.exists() == backupEnabled);
46      }
47  
48      protected void debug(File dir)
49      {
50          logger.debug(dir.getAbsolutePath() + " exists? " + dir.exists());
51      }
52  
53  }