KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > addressbook > folder > AbstractFolderTstCase


1 // The contents of this file are subject to the Mozilla Public License Version
2
// 1.1
3
//(the "License"); you may not use this file except in compliance with the
4
//License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
5
//
6
//Software distributed under the License is distributed on an "AS IS" basis,
7
//WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
8
//for the specific language governing rights and
9
//limitations under the License.
10
//
11
//The Original Code is "The Columba Project"
12
//
13
//The Initial Developers of the Original Code are Frederik Dietz and Timo
14
// Stich.
15
//Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
16
//
17
//All Rights Reserved.
18
package org.columba.addressbook.folder;
19
20 import java.io.File JavaDoc;
21 import java.util.HashSet JavaDoc;
22 import java.util.Iterator JavaDoc;
23 import java.util.Set JavaDoc;
24
25 import junit.framework.TestCase;
26
27 import org.columba.addressbook.main.AddressbookMain;
28 import org.columba.core.config.Config;
29 import org.columba.core.logging.Logging;
30 import org.columba.core.plugin.PluginManager;
31 import org.columba.core.shutdown.ShutdownManager;
32
33 /**
34  * @author fdietz
35  *
36  */

37 public class AbstractFolderTstCase extends TestCase {
38
39     private AddressbookFolder sourceFolder;
40
41     private AddressbookFolder destFolder;
42
43     /** A set with all created folders. */
44     private Set JavaDoc folders;
45
46     private static int folderId = 0;
47
48     /**
49      * Constructor for AbstractFolderTestCase.
50      *
51      * @param arg0
52      */

53     public AbstractFolderTstCase(String JavaDoc arg0) {
54         super(arg0);
55
56     }
57
58     /*
59      * @see TestCase#setUp()
60      */

61     protected void setUp() throws Exception JavaDoc {
62
63         // create config-folder
64
File JavaDoc file = new File JavaDoc("test_config");
65         file.mkdir();
66
67         //new Config(file);
68

69         Logging.DEBUG = true;
70         Logging.createDefaultHandler();
71
72         ShutdownManager.getInstance();
73
74         new AddressbookMain();
75
76         // now load all available plugins
77
PluginManager.getInstance().initExternalPlugins();
78
79         folders = new HashSet JavaDoc();
80         sourceFolder = FolderTstFactory.createFolder(folderId++);
81         folders.add(sourceFolder);
82         destFolder = FolderTstFactory.createFolder(folderId++);
83         folders.add(destFolder);
84     }
85
86     /*
87      * @see TestCase#tearDown()
88      */

89     protected void tearDown() throws Exception JavaDoc {
90         for (Iterator JavaDoc iterator = folders.iterator(); iterator.hasNext();) {
91             AbstractFolder folder = (AbstractFolder) iterator.next();
92             File JavaDoc f = folder.getDirectoryFile();
93
94             // delete all mails in folder
95
File JavaDoc[] list = f.listFiles();
96
97             if (list != null) {
98                 for (int i = 0; i < list.length; i++) {
99                     list[i].delete();
100                 }
101             }
102
103             // delete folder
104
f.delete();
105         }
106         new File JavaDoc(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 }
Popular Tags