001: // The contents of this file are subject to the Mozilla Public License Version
002: // 1.1
003: //(the "License"); you may not use this file except in compliance with the
004: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
005: //
006: //Software distributed under the License is distributed on an "AS IS" basis,
007: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
008: //for the specific language governing rights and
009: //limitations under the License.
010: //
011: //The Original Code is "The Columba Project"
012: //
013: //The Initial Developers of the Original Code are Frederik Dietz and Timo
014: // Stich.
015: //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
016: //
017: //All Rights Reserved.
018: package org.columba.addressbook.folder;
019:
020: import java.io.File;
021: import java.util.HashSet;
022: import java.util.Iterator;
023: import java.util.Set;
024:
025: import junit.framework.TestCase;
026:
027: import org.columba.addressbook.main.AddressbookMain;
028: import org.columba.core.config.Config;
029: import org.columba.core.logging.Logging;
030: import org.columba.core.plugin.PluginManager;
031: import org.columba.core.shutdown.ShutdownManager;
032:
033: /**
034: * @author fdietz
035: *
036: */
037: public class AbstractFolderTstCase extends TestCase {
038:
039: private AddressbookFolder sourceFolder;
040:
041: private AddressbookFolder destFolder;
042:
043: /** A set with all created folders. */
044: private Set folders;
045:
046: private static int folderId = 0;
047:
048: /**
049: * Constructor for AbstractFolderTestCase.
050: *
051: * @param arg0
052: */
053: public AbstractFolderTstCase(String arg0) {
054: super (arg0);
055:
056: }
057:
058: /*
059: * @see TestCase#setUp()
060: */
061: protected void setUp() throws Exception {
062:
063: // create config-folder
064: File file = new File("test_config");
065: file.mkdir();
066:
067: //new Config(file);
068:
069: Logging.DEBUG = true;
070: Logging.createDefaultHandler();
071:
072: ShutdownManager.getInstance();
073:
074: new AddressbookMain();
075:
076: // now load all available plugins
077: PluginManager.getInstance().initExternalPlugins();
078:
079: folders = new HashSet();
080: sourceFolder = FolderTstFactory.createFolder(folderId++);
081: folders.add(sourceFolder);
082: destFolder = FolderTstFactory.createFolder(folderId++);
083: folders.add(destFolder);
084: }
085:
086: /*
087: * @see TestCase#tearDown()
088: */
089: protected void tearDown() throws Exception {
090: for (Iterator iterator = folders.iterator(); iterator.hasNext();) {
091: AbstractFolder folder = (AbstractFolder) iterator.next();
092: File f = folder.getDirectoryFile();
093:
094: // delete all mails in folder
095: File[] list = f.listFiles();
096:
097: if (list != null) {
098: for (int i = 0; i < list.length; i++) {
099: list[i].delete();
100: }
101: }
102:
103: // delete folder
104: f.delete();
105: }
106: new File(FolderTstHelper.homeDirectory + "/folders/").delete();
107: }
108:
109: /**
110: * @return Returns the destFolder.
111: */
112: public AddressbookFolder getDestFolder() {
113: return destFolder;
114: }
115:
116: /**
117: * @return Returns the sourceFolder.
118: */
119: public AddressbookFolder getSourceFolder() {
120: return sourceFolder;
121: }
122: }
|