KickJava   Java API By Example, From Geeks To Geeks.

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


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 org.apache.avalon.framework.configuration.ConfigurationException;
24 import org.apache.avalon.framework.configuration.DefaultConfiguration;
25 import org.apache.avalon.framework.service.DefaultServiceManager;
26 import org.apache.avalon.framework.service.ServiceException;
27 import org.apache.james.mailrepository.filepair.File_Persistent_Object_Repository;
28 import org.apache.james.mailrepository.filepair.File_Persistent_Stream_Repository;
29 import org.apache.james.services.FileSystem;
30 import org.apache.james.services.MailRepository;
31 import org.apache.james.test.mock.avalon.MockLogger;
32 import org.apache.james.test.mock.avalon.MockStore;
33 import org.apache.james.test.mock.james.MockFileSystem;
34
35 public class AvalonMailRepositoryTest extends AbstractMailRepositoryTest {
36
37     /**
38      * @return
39      * @throws ServiceException
40      * @throws ConfigurationException
41      * @throws Exception
42      */

43     protected MailRepository getMailRepository() throws ServiceException, ConfigurationException, Exception JavaDoc {
44         DefaultServiceManager serviceManager = new DefaultServiceManager();
45         serviceManager.put(FileSystem.ROLE, new MockFileSystem());
46         AvalonMailRepository mr = new AvalonMailRepository();
47         MockStore mockStore = new MockStore();
48         File_Persistent_Stream_Repository file_Persistent_Stream_Repository = new File_Persistent_Stream_Repository();
49         file_Persistent_Stream_Repository.service(serviceManager);
50         file_Persistent_Stream_Repository.enableLogging(new MockLogger());
51         DefaultConfiguration defaultConfiguration2 = new DefaultConfiguration("conf");
52         defaultConfiguration2.setAttribute("destinationURL", "file://target/var/mr");
53         file_Persistent_Stream_Repository.configure(defaultConfiguration2);
54         file_Persistent_Stream_Repository.initialize();
55         mockStore.add("STREAM.mr", file_Persistent_Stream_Repository);
56         File_Persistent_Object_Repository file_Persistent_Object_Repository = new File_Persistent_Object_Repository();
57         file_Persistent_Object_Repository.service(serviceManager);
58         file_Persistent_Object_Repository.enableLogging(new MockLogger());
59         DefaultConfiguration defaultConfiguration22 = new DefaultConfiguration("conf");
60         defaultConfiguration22.setAttribute("destinationURL", "file://target/var/mr");
61         file_Persistent_Object_Repository.configure(defaultConfiguration22);
62         file_Persistent_Object_Repository.initialize();
63         mockStore.add("OBJECT.mr", file_Persistent_Object_Repository);
64         mr.setStore(mockStore);
65
66         mr.enableLogging(new MockLogger());
67         DefaultConfiguration defaultConfiguration = new DefaultConfiguration("ReposConf");
68         defaultConfiguration.setAttribute("destinationURL","file://target/var/mr");
69         defaultConfiguration.setAttribute("type","MAIL");
70         mr.configure(defaultConfiguration);
71         mr.initialize();
72         return mr;
73     }
74
75 }
76
77
Popular Tags