1   /*
2    * $Id: AbstractBaseBackupMule2050TestCase.java 7976 2007-08-21 14:26:13Z dirk.olmes $
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      public UMOConnector getConnector(boolean init) throws Exception
31      {
32          UMOConnector connector = super.getConnector(init);
33          ((AbstractRetrieveMailConnector) connector).setBackupEnabled(backupEnabled);
34          return connector;
35      }
36  
37      public void doTestReceiver() throws Exception
38      {
39          File dir = new File(MuleManager.getConfiguration().getWorkingDirectory() + "/mail/INBOX");
40          assertFalse("Mail backup file already exists: " + dir.getAbsolutePath(), dir.exists());
41          debug(dir);
42          super.doTestReceiver();
43          debug(dir);
44          assertTrue(dir.getAbsolutePath(), dir.exists() == backupEnabled);
45      }
46  
47      protected void debug(File dir)
48      {
49          logger.debug(dir.getAbsolutePath() + " exists? " + dir.exists());
50      }
51  
52  }