KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > james > mailrepository > MBoxMailRepositoryTest


1 /****************************************************************
2  * Licensed to the Apache Software Foundation (ASF) under one *
3  * or more contributor license agreements. See the NOTICE file *
4  * distributed with this work for additional information *
5  * regarding copyright ownership. The ASF licenses this file *
6  * to you under the Apache License, Version 2.0 (the *
7  * "License"); you may not use this file except in compliance *
8  * with the License. You may obtain a copy of the License at *
9  * *
10  * http://www.apache.org/licenses/LICENSE-2.0 *
11  * *
12  * Unless required by applicable law or agreed to in writing, *
13  * software distributed under the License is distributed on an *
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
15  * KIND, either express or implied. See the License for the *
16  * specific language governing permissions and limitations *
17  * under the License. *
18  ****************************************************************/

19
20
21 package org.apache.james.mailrepository;
22
23 import java.util.Iterator JavaDoc;
24
25 import junit.framework.TestCase;
26
27 import org.apache.avalon.framework.configuration.ConfigurationException;
28 import org.apache.avalon.framework.configuration.DefaultConfiguration;
29 import org.apache.avalon.framework.service.ServiceException;
30 import org.apache.james.services.MailRepository;
31 import org.apache.james.test.mock.avalon.MockLogger;
32
33 /**
34  * NOTE this test *WAS* disabled because MBoxMailRepository does not
35  * currently support most simple operations for the MailRepository interface.
36  *
37  * NOTE this previously extended AbstractMailRepositoryTest to run all of the
38  * common mail repository tests on the MBox implementation.
39  */

40 public class MBoxMailRepositoryTest extends TestCase {
41
42     
43     protected MailRepository getMailRepository() throws ServiceException, ConfigurationException, Exception JavaDoc {
44         MBoxMailRepository mr = new MBoxMailRepository();
45
46         mr.enableLogging(new MockLogger());
47         DefaultConfiguration defaultConfiguration = new DefaultConfiguration("ReposConf");
48         defaultConfiguration.setAttribute("destinationURL","mbox://src/test/org/apache/james/mailrepository/testdata/Inbox");
49         defaultConfiguration.setAttribute("type","MAIL");
50         mr.configure(defaultConfiguration);
51         return mr;
52     }
53
54     // Try to write a unit test for JAMES-744. At the moment it seems that we cannot reproduce it.
55
public void testReadMboxrdFile() throws ServiceException, ConfigurationException, Exception JavaDoc {
56         MailRepository mr = getMailRepository();
57     
58         Iterator JavaDoc keys = mr.list();
59     
60         assertTrue("Two messages in list", keys.hasNext());
61         keys.next();
62     
63         assertTrue("One messages in list", keys.hasNext());
64         keys.next();
65     
66         assertFalse("No messages", keys.hasNext());
67     }
68
69     /*
70     public void runBare() throws Throwable {
71         System.err.println("TEST DISABLED!");
72         // Decomment this or remove this method to re-enable the MBoxRepository testing
73         // super.runBare();
74     }
75     */

76
77 }
78
79
Popular Tags