01: /*
02: * Copyright 2003-2005 Michael Franken, Zilverline.
03: *
04: * The contents of this file, or the files included with this file, are subject to
05: * the current version of ZILVERLINE Collaborative Source License for the
06: * Zilverline Search Engine (the "License"); You may not use this file except in
07: * compliance with the License.
08: *
09: * You may obtain a copy of the License at
10: *
11: * http://www.zilverline.org.
12: *
13: * See the License for the rights, obligations and
14: * limitations governing use of the contents of the file.
15: *
16: * The Original and Upgraded Code is the Zilverline Search Engine. The developer of
17: * the Original and Upgraded Code is Michael Franken. Michael Franken owns the
18: * copyrights in the portions it created. All Rights Reserved.
19: *
20: */
21:
22: package org.zilverline.core;
23:
24: import java.io.File;
25:
26: import org.apache.commons.logging.Log;
27: import org.apache.commons.logging.LogFactory;
28:
29: import org.springframework.test.AbstractDependencyInjectionSpringContextTests;
30:
31: import org.zilverline.service.CollectionManager;
32:
33: /**
34: * IMAPCollectionTest
35: *
36: * @author Michael Franken
37: */
38: public class TestIMAPCollection extends
39: AbstractDependencyInjectionSpringContextTests {
40: /** logger for Commons logging. */
41: private static Log log = LogFactory
42: .getLog(TestIMAPCollection.class);
43:
44: protected String[] getConfigLocations() {
45: return new String[] { "applicationContext.xml" };
46: }
47:
48: public void testConnect() {
49: CollectionManager colMan = (CollectionManager) applicationContext
50: .getBean("collectionMan");
51: IMAPCollection col = new IMAPCollection();
52: col.setName("michael@franken.ws");
53: try {
54: colMan.addCollection(col);
55: col
56: .setAnalyzer("org.apache.lucene.analysis.standard.StandardAnalyzer");
57: col.setIndexDir(new File("d:/temp/zilverline/mail"));
58: col.setHost("xxxxx");
59: col.setUser("xxx");
60: col.setPassword("xxx");
61: col.setFolder("test");
62: col.init();
63: colMan.deleteCollection(col);
64: } catch (IndexException e) {
65: fail("Can not initialize IMAP collection: " + col.getName()
66: + ", " + e.getMessage());
67: }
68:
69: try {
70: col.index(true);
71: assertTrue(col.isIndexValid());
72: int numberOfMails = col.getNumberOfDocs();
73: col.index(false);
74: assertTrue(col.isIndexValid());
75: assertEquals(numberOfMails, col.getNumberOfDocs());
76: } catch (IndexException e) {
77: fail("Can not index IMAP collection: " + col.getName()
78: + ", " + e.getMessage());
79: }
80: }
81:
82: }
|