Added:
james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/impl/VirtualMailboxManagerFactoryTest.java
URL:
http://svn.apache.org/viewvc/james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/impl/VirtualMailboxManagerFactoryTest.java?view=auto&rev=475896
==============================================================================
---
james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/impl/VirtualMailboxManagerFactoryTest.java
(added)
+++
james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/impl/VirtualMailboxManagerFactoryTest.java
Thu Nov 16 11:50:48 2006
@@ -0,0 +1,194 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ * or more contributor license agreements. See the NOTICE file *
+ * distributed with this work for additional information *
+ * regarding copyright ownership. The ASF licenses this file *
+ * to you under the Apache License, Version 2.0 (the *
+ * "License"); you may not use this file except in compliance *
+ * with the License. You may obtain a copy of the License at *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, *
+ * software distributed under the License is distributed on an *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
+ * KIND, either express or implied. See the License for the *
+ * specific language governing permissions and limitations *
+ * under the License. *
+ ****************************************************************/
+
+package org.apache.james.mailboxmanager.impl;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
+import org.apache.avalon.framework.service.ServiceManager;
+import
org.apache.james.mailboxmanager.mailstore.MailStoreMailboxManagerFactory;
+import org.apache.james.mailboxmanager.manager.MailboxManagerFactory;
+import org.apache.james.mailboxmanager.mock.MockMailboxManagerFactory;
+import org.apache.james.mailboxmanager.torque.TorqueMailboxManagerFactory;
+import org.apache.james.services.FileSystem;
+import org.apache.james.test.mock.avalon.MockLogger;
+import org.apache.james.test.mock.james.MockFileSystem;
+import org.jmock.Mock;
+import org.jmock.MockObjectTestCase;
+import org.xml.sax.SAXException;
+
+public class VirtualMailboxManagerFactoryTest extends MockObjectTestCase {
+
+ VirtualMailboxManagerFactory virtualMailboxManagerFactory;
+
+ public void setUp() {
+ virtualMailboxManagerFactory = new VirtualMailboxManagerFactory();
+ }
+
+ public void testReadConf() throws ConfigurationException, SAXException,
+ IOException {
+ Configuration confFile = new DefaultConfigurationBuilder()
+ .buildFromFile("src/conf/james-config.xml");
+ Configuration conf = confFile.getChild("mailboxmanager",
false).getChild("factory",false);
+ VirtualMailboxManagerFactory vmm = new VirtualMailboxManagerFactory();
+ vmm.enableLogging(new MockLogger());
+ vmm.configure(conf);
+ }
+
+ public void testVirtualRepositoryMix() throws Exception {
+ Configuration confFile = new DefaultConfigurationBuilder()
+ .build(getClass()
+ .getResourceAsStream(
+
"/org/apache/james/mailboxmanager/testdata/VirtualRepositoryMix.xml"));
+ Configuration conf = confFile.getChild("mailboxmanager",
false).getChild("factory",false);
+
+ Mock mockService = mock(ServiceManager.class);
+ mockService.expects(once()).method("lookup").with(eq(FileSystem.ROLE))
+ .will(returnValue(new MockFileSystem()));
+
+ VirtualMailboxManagerFactory virtualMailboxManagerFactory = new
VirtualMailboxManagerFactory();
+ virtualMailboxManagerFactory.enableLogging(new MockLogger());
+ virtualMailboxManagerFactory.configure(conf);
+ virtualMailboxManagerFactory.service((ServiceManager) mockService
+ .proxy());
+// virtualMailboxManagerFactory.initialize();
+
+ String[] expected = { "#system", "#user1", "#user2", "#user3", "#mail",
+ "#user" };
+ List resultList = new ArrayList(virtualMailboxManagerFactory
+ .getMountMap().keySet());
+ List expectedList = Arrays.asList(expected);
+ assertEquals(expectedList, resultList);
+
+ MailboxManagerFactory[] factories = new
MailboxManagerFactory[expected.length];
+ for (int i = 0; i < factories.length; i++) {
+ factories[i] = (MailboxManagerFactory) virtualMailboxManagerFactory
+ .getMountMap().get(expected[i]);
+ }
+
+ assertSame(factories[1], factories[5]);
+ assertSame(factories[2], factories[3]);
+ assertNotSame(factories[1], factories[2]);
+ assertNotSame(factories[1], factories[0]);
+ assertNotSame(factories[0], factories[4]);
+
+ MockMailboxManagerFactory mockFactory1 = (MockMailboxManagerFactory)
factories[1];
+ MockMailboxManagerFactory mockFactory2 = (MockMailboxManagerFactory)
factories[2];
+
+ Configuration[] mounts = conf.getChild(
+ "mounts", false).getChildren("mount");
+
+ assertEquals(mounts[0].getChild("target", false),
+ mockFactory1.configuration);
+ assertEquals(mounts[1].getChild("target", false),
+ mockFactory2.configuration);
+
+// assertEquals(1, mockFactory1.init);
+// assertEquals(1, mockFactory2.init);
+
+ assertTrue(factories[0] instanceof MailStoreMailboxManagerFactory);
+ assertTrue(factories[4] instanceof TorqueMailboxManagerFactory);
+
+ }
+
+
+ public void testVirtualRepositoryMixWithInit() throws Exception {
+ Configuration confFile = new DefaultConfigurationBuilder()
+ .build(getClass()
+ .getResourceAsStream(
+
"/org/apache/james/mailboxmanager/testdata/VirtualRepositoryMix.xml"));
+ Configuration conf =
confFile.getChild("mailboxmanager-without-torque",
false).getChild("factory",false);
+
+
+ VirtualMailboxManagerFactory virtualMailboxManagerFactory = new
VirtualMailboxManagerFactory();
+ virtualMailboxManagerFactory.enableLogging(new MockLogger());
+ virtualMailboxManagerFactory.configure(conf);
+ virtualMailboxManagerFactory.service(null);
+ virtualMailboxManagerFactory.initialize();
+
+ String[] expected = { "#system", "#user1", "#user2", "#user3", "#mail",
+ "#user" };
+ List resultList = new ArrayList(virtualMailboxManagerFactory
+ .getMountMap().keySet());
+ List expectedList = Arrays.asList(expected);
+ assertEquals(expectedList, resultList);
+
+ MailboxManagerFactory[] factories = new
MailboxManagerFactory[expected.length];
+ for (int i = 0; i < factories.length; i++) {
+ factories[i] = (MailboxManagerFactory) virtualMailboxManagerFactory
+ .getMountMap().get(expected[i]);
+ }
+
+ assertSame(factories[1], factories[5]);
+ assertSame(factories[2], factories[3]);
+ assertNotSame(factories[1], factories[2]);
+ assertNotSame(factories[1], factories[0]);
+ assertNotSame(factories[0], factories[4]);
+
+ MockMailboxManagerFactory mockFactory1 = (MockMailboxManagerFactory)
factories[1];
+ MockMailboxManagerFactory mockFactory2 = (MockMailboxManagerFactory)
factories[2];
+ MockMailboxManagerFactory mockFactory4 = (MockMailboxManagerFactory)
factories[4];
+
+ Configuration[] mounts = conf.getChild(
+ "mounts", false).getChildren("mount");
+
+ assertEquals(mounts[0].getChild("target", false),
+ mockFactory1.configuration);
+ assertEquals(mounts[1].getChild("target", false),
+ mockFactory2.configuration);
+ assertEquals(mounts[3].getChild("target", false),
+ mockFactory4.configuration);
+
+ assertEquals(1, mockFactory1.init);
+ assertEquals(1, mockFactory2.init);
+ assertEquals(1, mockFactory4.init);
+
+ assertTrue(factories[0] instanceof MailStoreMailboxManagerFactory);
+
+
+ }
+
+
+ public void testMountMap() {
+ Map mountMap = virtualMailboxManagerFactory.getMountMap();
+ String[] expected = { "xaaa", "xaab", "zaa", "b", "c" };
+ mountMap.put("c", "x");
+ mountMap.put("xaaa", "x");
+ mountMap.put("xaab", "x");
+ mountMap.put("zaa", "x");
+ mountMap.put("b", "x");
+ List resultList = new ArrayList(mountMap.keySet());
+ List expectedList = Arrays.asList(expected);
+ assertEquals(expectedList, resultList);
+ }
+
+ protected static Set toSet(Object[] o) {
+ return new HashSet(Arrays.asList(o));
+ }
+
+}
Propchange:
james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/impl/VirtualMailboxManagerFactoryTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/impl/VirtualMailboxManagerTest.java
URL:
http://svn.apache.org/viewvc/james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/impl/VirtualMailboxManagerTest.java?view=auto&rev=475896
==============================================================================
---
james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/impl/VirtualMailboxManagerTest.java
(added)
+++
james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/impl/VirtualMailboxManagerTest.java
Thu Nov 16 11:50:48 2006
@@ -0,0 +1,179 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ * or more contributor license agreements. See the NOTICE file *
+ * distributed with this work for additional information *
+ * regarding copyright ownership. The ASF licenses this file *
+ * to you under the Apache License, Version 2.0 (the *
+ * "License"); you may not use this file except in compliance *
+ * with the License. You may obtain a copy of the License at *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, *
+ * software distributed under the License is distributed on an *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
+ * KIND, either express or implied. See the License for the *
+ * specific language governing permissions and limitations *
+ * under the License. *
+ ****************************************************************/
+
+package org.apache.james.mailboxmanager.impl;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+
+import org.apache.james.mailboxmanager.ListResult;
+import org.apache.james.mailboxmanager.MailboxManagerException;
+import
org.apache.james.mailboxmanager.impl.VirtualMailboxManagerFactory.LengthComparator;
+import org.apache.james.mailboxmanager.manager.MailboxManager;
+import org.apache.james.mailboxmanager.manager.MailboxManagerFactory;
+import org.apache.james.mailboxmanager.mock.MockUser;
+import org.apache.james.services.User;
+import org.jmock.Mock;
+import org.jmock.MockObjectTestCase;
+import org.jmock.core.Constraint;
+import org.jmock.core.constraint.IsEqual;
+import org.jmock.core.constraint.IsSame;
+
+public class VirtualMailboxManagerTest extends MockObjectTestCase {
+
+ protected User user = new MockUser();
+
+ protected VirtualMailboxManager virtualMailboxManager;
+
+ public void setUp() {
+ virtualMailboxManager = new VirtualMailboxManager();
+ virtualMailboxManager.setUser(user);
+ }
+
+ public void testGetMailboxManager() throws MailboxManagerException {
+ String[] points = { "#mail", "#mail.t1.t2", "#mail.t1", "#user",
+ "#user.t1.t2.t3" };
+ MailboxManager[] manager = new MailboxManager[] {
+ (MailboxManager) mock(MailboxManager.class).proxy(),
+ (MailboxManager) mock(MailboxManager.class).proxy(),
+ (MailboxManager) mock(MailboxManager.class).proxy(),
+ (MailboxManager) mock(MailboxManager.class).proxy(),
+ (MailboxManager) mock(MailboxManager.class).proxy() };
+ Mock[] mailboxManagerFactoryMocks = createMailboxManagerFactoryMocks(
+ manager, 2);
+ MailboxManagerFactory[] mailboxManagerFactories =
proxyFactoryMocks(mailboxManagerFactoryMocks);
+
+ addMountPoints(points, mailboxManagerFactories);
+ assertSame(manager[0], virtualMailboxManager
+ .getMailboxManager("#mail.t3"));
+ assertSame(manager[0],
virtualMailboxManager.getMailboxManager("#mail"));
+ assertSame(manager[1], virtualMailboxManager
+ .getMailboxManager("#mail.t1.t2"));
+ assertSame(manager[1], virtualMailboxManager
+ .getMailboxManager("#mail.t1.t2.t4"));
+ assertSame(manager[2], virtualMailboxManager
+ .getMailboxManager("#mail.t1"));
+ assertSame(manager[2], virtualMailboxManager
+ .getMailboxManager("#mail.t1.t3"));
+ assertSame(manager[3],
virtualMailboxManager.getMailboxManager("#user"));
+ assertSame(manager[3], virtualMailboxManager
+ .getMailboxManager("#user.t2"));
+ assertSame(manager[4], virtualMailboxManager
+ .getMailboxManager("#user.t1.t2.t3"));
+ assertSame(manager[4], virtualMailboxManager
+ .getMailboxManager("#user.t1.t2.t3.t4"));
+ assertNull(virtualMailboxManager.getMailboxManager("#other"));
+
+ }
+
+ public void testList() throws MailboxManagerException {
+ String[] expected = { "#mail.t1.t2", "#mail.t1.t3", "#mail",
+ "#mail.group.t5", "#mail.group.6", "#system.t1" };
+ String[] points = { "#mail", "#mail.group", "#system" };
+ Mock[] mailboxManagerMocks = { mock(MailboxManager.class),
+ mock(MailboxManager.class), mock(MailboxManager.class) };
+ MailboxManager[] mailboxManager = proxyMocks(mailboxManagerMocks);
+ Mock[] mailboxManagerFactoryMocks = createMailboxManagerFactoryMocks(
+ mailboxManager, 1);
+ MailboxManagerFactory[] mailboxManagerFactories =
proxyFactoryMocks(mailboxManagerFactoryMocks);
+
+ Constraint[] args = { new IsEqual(""), new IsEqual("%"),
+ new IsEqual(Boolean.FALSE) };
+
+ mailboxManagerMocks[0].expects(once()).method("list").with(args).will(
+ returnValue(generateListResults(new String[] { expected[0],
+ expected[1], expected[2] })));
+
+ mailboxManagerMocks[1].expects(once()).method("list").with(args).will(
+ returnValue(generateListResults(new String[] { expected[3],
+ expected[4] })));
+
+ mailboxManagerMocks[2].expects(once()).method("list").with(args).will(
+ returnValue(generateListResults(new String[] { expected[5]
})));
+
+ addMountPoints(points, mailboxManagerFactories);
+
+ ListResult[] result = virtualMailboxManager.list("", "%", false);
+ assertEquals(expected.length, result.length);
+ assertEquals(new HashSet(Arrays.asList(expected)), toNamesSet(result));
+ System.out.println(toNamesSet(result));
+
+ }
+
+ protected Mock[] createMailboxManagerFactoryMocks(MailboxManager[] manager,
+ int expected) {
+ Mock[] mocks = new Mock[manager.length];
+ for (int i = 0; i < mocks.length; i++) {
+ mocks[i] = mock(MailboxManagerFactory.class);
+ mocks[i].expects(exactly(expected)).method(
+ "getMailboxManagerInstance").with(new IsSame(user)).will(
+ returnValue(manager[i]));
+ }
+ return mocks;
+ }
+
+ protected static MailboxManager[] proxyMocks(Mock[] mocks) {
+ MailboxManager[] managers = new MailboxManager[mocks.length];
+ for (int i = 0; i < mocks.length; i++) {
+ managers[i] = (MailboxManager) mocks[i].proxy();
+ }
+ return managers;
+ }
+
+ protected static MailboxManagerFactory[] proxyFactoryMocks(Mock[] mocks) {
+ MailboxManagerFactory[] factories = new
MailboxManagerFactory[mocks.length];
+ for (int i = 0; i < mocks.length; i++) {
+ factories[i] = (MailboxManagerFactory) mocks[i].proxy();
+ }
+ return factories;
+ }
+
+ protected void addMountPoints(String[] points,
+ MailboxManagerFactory[] mailboxManagerFactories) {
+ Map mountMap = new TreeMap(new LengthComparator());
+ for (int i = 0; i < mailboxManagerFactories.length; i++) {
+
+ mountMap.put(points[i], mailboxManagerFactories[i]);
+ }
+ virtualMailboxManager.setMountMap(mountMap);
+ }
+
+ protected static Set toNamesSet(ListResult[] listResult) {
+ Set nameSet = new HashSet();
+ for (int i = 0; i < listResult.length; i++) {
+ nameSet.add(listResult[i].getName());
+ }
+ return nameSet;
+ }
+
+ protected static ListResult[] generateListResults(String[] names) {
+ ListResult[] result = new ListResult[names.length];
+ for (int i = 0; i < names.length; i++) {
+ result[i] = new ListResultImpl(names[i], ".");
+ }
+ return result;
+ }
+
+}
Propchange:
james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/impl/VirtualMailboxManagerTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/mailstore/MailStoreMailboxCacheTest.java
URL:
http://svn.apache.org/viewvc/james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/mailstore/MailStoreMailboxCacheTest.java?view=auto&rev=475896
==============================================================================
---
james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/mailstore/MailStoreMailboxCacheTest.java
(added)
+++
james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/mailstore/MailStoreMailboxCacheTest.java
Thu Nov 16 11:50:48 2006
@@ -0,0 +1,95 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ * or more contributor license agreements. See the NOTICE file *
+ * distributed with this work for additional information *
+ * regarding copyright ownership. The ASF licenses this file *
+ * to you under the Apache License, Version 2.0 (the *
+ * "License"); you may not use this file except in compliance *
+ * with the License. You may obtain a copy of the License at *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, *
+ * software distributed under the License is distributed on an *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
+ * KIND, either express or implied. See the License for the *
+ * specific language governing permissions and limitations *
+ * under the License. *
+ ****************************************************************/
+
+package org.apache.james.mailboxmanager.mailstore;
+
+import java.util.Arrays;
+
+import org.apache.avalon.cornerstone.services.store.Store;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.avalon.framework.configuration.DefaultConfiguration;
+import org.apache.james.mailboxmanager.MailboxManagerException;
+import org.apache.james.mailboxmanager.mailbox.MailboxSession;
+import org.apache.james.services.MailRepository;
+import org.apache.james.test.mock.avalon.MockLogger;
+import org.jmock.Mock;
+import org.jmock.MockObjectTestCase;
+import org.jmock.core.constraint.IsEqual;
+
+public class MailStoreMailboxCacheTest extends MockObjectTestCase {
+
+ MailstoreMailboxCache mailstoreMailboxCache;
+
+ public void setUp() {
+ mailstoreMailboxCache = new MailstoreMailboxCache();
+ mailstoreMailboxCache.enableLogging(new MockLogger());
+ mailstoreMailboxCache.setMountPoint("#mail");
+ mailstoreMailboxCache.setDestinationURL("file://var/mail/inboxes/");
+ }
+
+ public void testBuildUrlNoInbox() {
+ assertEquals("file://var/mail/inboxes/t1", mailstoreMailboxCache
+ .buildUrl("#mail.t1"));
+ assertEquals("file://var/mail/inboxes/t1.t2", mailstoreMailboxCache
+ .buildUrl("#mail.t1.t2"));
+ }
+
+ public void testBuildUrlInbox() {
+ assertEquals("file://var/mail/inboxes/t1", mailstoreMailboxCache
+ .buildUrl("#mail.t1.INBOX"));
+ assertEquals("file://var/mail/inboxes/t1.t2", mailstoreMailboxCache
+ .buildUrl("#mail.t1.t2.INBOX"));
+ }
+
+ public void testGetMailboxSession() throws MailboxManagerException,
+ ConfigurationException {
+
+ DefaultConfiguration repositoryConfiguration = new
DefaultConfiguration(
+ "repository");
+
+ DefaultConfiguration expectedConfiguration = new DefaultConfiguration(
+ repositoryConfiguration);
+ expectedConfiguration.setAttribute("destinationURL",
+ "file://var/mail/inboxes/t1");
+
+ Mock store = mock(Store.class);
+ Mock mockRepository = mock(MailRepository.class);
+ store.expects(exactly(2)).method("select").with(
+ new IsEqual(expectedConfiguration)).will(
+ returnValue(mockRepository.proxy()));
+
+ mailstoreMailboxCache.setMailStore((Store) store.proxy());
+ mailstoreMailboxCache.setRepositoryConf(repositoryConfiguration);
+ MailboxSession s1 =
mailstoreMailboxCache.getMailboxSession("#mail.t1.INBOX");
+ MailboxSession s2 =
mailstoreMailboxCache.getMailboxSession("#mail.t1.INBOX");
+ assertNotSame(s1, s2);
+ s1.close();
+ MailboxSession s3 =
mailstoreMailboxCache.getMailboxSession("#mail.t1.INBOX");
+ s3.close();
+ s2.close();
+
+ MailboxSession s4 =
mailstoreMailboxCache.getMailboxSession("#mail.t1.INBOX");
+
+ String[] keys = new String[] { "test" };
+ mockRepository.expects(once()).method("list").withNoArguments().will(
+ returnIterator(keys));
+ assertEquals(Arrays.asList(keys), s4.list());
+ }
+
+}
Propchange:
james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/mailstore/MailStoreMailboxCacheTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/mock/MockMailboxManagerFactory.java
URL:
http://svn.apache.org/viewvc/james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/mock/MockMailboxManagerFactory.java?view=auto&rev=475896
==============================================================================
---
james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/mock/MockMailboxManagerFactory.java
(added)
+++
james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/mock/MockMailboxManagerFactory.java
Thu Nov 16 11:50:48 2006
@@ -0,0 +1,63 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ * or more contributor license agreements. See the NOTICE file *
+ * distributed with this work for additional information *
+ * regarding copyright ownership. The ASF licenses this file *
+ * to you under the Apache License, Version 2.0 (the *
+ * "License"); you may not use this file except in compliance *
+ * with the License. You may obtain a copy of the License at *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, *
+ * software distributed under the License is distributed on an *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
+ * KIND, either express or implied. See the License for the *
+ * specific language governing permissions and limitations *
+ * under the License. *
+ ****************************************************************/
+
+package org.apache.james.mailboxmanager.mock;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.avalon.framework.activity.Initializable;
+import org.apache.avalon.framework.configuration.Configurable;
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.james.mailboxmanager.MailboxManagerException;
+import org.apache.james.mailboxmanager.manager.MailboxManager;
+import org.apache.james.mailboxmanager.manager.MailboxManagerFactory;
+import org.apache.james.services.User;
+
+public class MockMailboxManagerFactory implements MailboxManagerFactory,
Configurable, Initializable {
+
+ public Configuration configuration;
+
+ public Set mountPoints = new HashSet() ;
+
+ public int init=0;
+
+ public void deleteEverything() throws MailboxManagerException {
+ }
+
+ public MailboxManager getMailboxManagerInstance(User user) throws
MailboxManagerException {
+ return null;
+ }
+
+ public void configure(Configuration configuration) throws
ConfigurationException {
+ this.configuration=configuration;
+
+ }
+
+
+ public void addMountPoint(String point) {
+ mountPoints.add(point);
+ }
+
+ public void initialize() throws Exception {
+ init++;
+ }
+
+}
Propchange:
james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/mock/MockMailboxManagerFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/mock/TorqueMailboxManagerProviderSingleton.java
URL:
http://svn.apache.org/viewvc/james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/mock/TorqueMailboxManagerProviderSingleton.java?view=diff&rev=475896&r1=475895&r2=475896
==============================================================================
---
james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/mock/TorqueMailboxManagerProviderSingleton.java
(original)
+++
james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/mock/TorqueMailboxManagerProviderSingleton.java
Thu Nov 16 11:50:48 2006
@@ -1,22 +1,45 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ * or more contributor license agreements. See the NOTICE file *
+ * distributed with this work for additional information *
+ * regarding copyright ownership. The ASF licenses this file *
+ * to you under the Apache License, Version 2.0 (the *
+ * "License"); you may not use this file except in compliance *
+ * with the License. You may obtain a copy of the License at *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, *
+ * software distributed under the License is distributed on an *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
+ * KIND, either express or implied. See the License for the *
+ * specific language governing permissions and limitations *
+ * under the License. *
+ ****************************************************************/
+
package org.apache.james.mailboxmanager.mock;
-import org.apache.james.mailboxmanager.torque.TorqueMailboxManagerProvider;
+import org.apache.james.mailboxmanager.impl.DefaultMailboxManagerProvider;
+import org.apache.james.mailboxmanager.manager.MailboxManagerProvider;
+import org.apache.james.mailboxmanager.torque.TorqueMailboxManagerFactory;
import org.apache.james.test.mock.james.MockFileSystem;
public class TorqueMailboxManagerProviderSingleton {
- private static TorqueMailboxManagerProvider torqueMailboxManagerProvider;
+ private static DefaultMailboxManagerProvider defaultMailboxManagerProvider;
- public synchronized static TorqueMailboxManagerProvider
getTorqueMailboxManagerProviderInstance() throws Exception {
- if (torqueMailboxManagerProvider==null) {
- torqueMailboxManagerProvider=new TorqueMailboxManagerProvider() {{
+ public synchronized static MailboxManagerProvider
getTorqueMailboxManagerProviderInstance() throws Exception {
+ if (defaultMailboxManagerProvider==null) {
+ TorqueMailboxManagerFactory torqueMailboxManagerFactory=new
TorqueMailboxManagerFactory() {{
setFileSystem(new MockFileSystem());
}};
- torqueMailboxManagerProvider.configureDefaults();
- torqueMailboxManagerProvider.initialize();
+ torqueMailboxManagerFactory.configureDefaults();
+ torqueMailboxManagerFactory.initialize();
+ defaultMailboxManagerProvider=new DefaultMailboxManagerProvider();
+
defaultMailboxManagerProvider.setMailboxManagerFactory(torqueMailboxManagerFactory);
}
- return torqueMailboxManagerProvider;
+ return defaultMailboxManagerProvider;
}
Added:
james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/testdata/DefaultMailboxManagerConf.xml
URL:
http://svn.apache.org/viewvc/james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/testdata/DefaultMailboxManagerConf.xml?view=auto&rev=475896
==============================================================================
---
james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/testdata/DefaultMailboxManagerConf.xml
(added)
+++
james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/testdata/DefaultMailboxManagerConf.xml
Thu Nov 16 11:50:48 2006
@@ -0,0 +1,23 @@
+<config>
+ <mailboxmanager>
+ <namespaces>
+ <usernamespace name="#mail" delimiter="." />
+ </namespaces>
+
+ <factory
class="org.apache.james.mailboxmanager.mock.MockMailboxManagerFactory">
+ <mount>
+ <point point="#system" />
+ <target
class="org.apache.james.mailboxmanager.impl.MailStoreMailboxManager">
+ <repository destinationURL="file://var/mail/"
type="MAIL" />
+ </target>
+ </mount>
+ <mount>
+ <point point="#mail" />
+ <target type="service"
service="org.apache.james.mailboxmanager.impl.MailStoreMailboxManager">
+ <repository
destinationURL="file://var/mail/inboxes/" type="MAIL" />
+ </target>
+ </mount>
+ </factory>
+ </mailboxmanager>
+
+</config>
Propchange:
james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/testdata/DefaultMailboxManagerConf.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added:
james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/testdata/VirtualRepositoryMix.xml
URL:
http://svn.apache.org/viewvc/james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/testdata/VirtualRepositoryMix.xml?view=auto&rev=475896
==============================================================================
---
james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/testdata/VirtualRepositoryMix.xml
(added)
+++
james/server/sandbox/mailbox-namespaces/src/test/org/apache/james/mailboxmanager/testdata/VirtualRepositoryMix.xml
Thu Nov 16 11:50:48 2006
@@ -0,0 +1,110 @@
+<config>
+ <mailboxmanager>
+ <namespaces>
+ <usernamespace name="#mail" delimiter="."/>
+ </namespaces>
+ <factory
+
class="org.apache.james.mailboxmanager.impl.VirtualMailboxManagerFactory">
+ <mounts>
+ <mount>
+ <point point="#user"/>
+ <point point="#user1"/>
+ <target
+
class="org.apache.james.mailboxmanager.mock.MockMailboxManagerFactory">
+ <myconf attr="test"/>
+ </target>
+ </mount>
+
+ <mount>
+ <point point="#user2"/>
+ <point point="#user3"/>
+ <target
+
class="org.apache.james.mailboxmanager.mock.MockMailboxManagerFactory">
+ <myconf attr="test2"/>
+ </target>
+ </mount>
+ <mount>
+ <point point="#system"/>
+ <target
+
class="org.apache.james.mailboxmanager.mailstore.MailStoreMailboxManagerFactory">
+ <repository
destinationURL="file://var/mail/"
+ type="MAIL"/>
+ </target>
+ </mount>
+ <mount>
+ <point point="#mail"/>
+ <target
+
class="org.apache.james.mailboxmanager.torque.TorqueMailboxManagerFactory">
+ <torque-properties>
+ <property
name="torque.database.default"
+
value="mailboxmanager"/>
+ <property
+
name="torque.database.mailboxmanager.adapter"
+ value="derby"/>
+ <property
+
name="torque.dsfactory.mailboxmanager.factory"
+
value="org.apache.torque.dsfactory.SharedPoolDataSourceFactory"/>
+ <property
+
name="torque.dsfactory.mailboxmanager.connection.driver"
+
value="org.apache.derby.jdbc.EmbeddedDriver"/>
+ <property
+
name="torque.dsfactory.mailboxmanager.connection.url"
+
value="jdbc:derby:tmp/mailboxmanager-derbydb;create=true"/>
+ <property
+
name="torque.dsfactory.mailboxmanager.connection.user"
+ value="app"/>
+ <property
+
name="torque.dsfactory.mailboxmanager.connection.password"
+ value="app"/>
+ <property
+
name="torque.dsfactory.mailboxmanager.pool.maxActive"
+ value="100"/>
+ </torque-properties>
+ </target>
+ </mount>
+ </mounts>
+ </factory>
+ </mailboxmanager>
+ <mailboxmanager-without-torque>
+ <namespaces>
+ <usernamespace name="#mail" delimiter="."/>
+ </namespaces>
+ <factory
+
class="org.apache.james.mailboxmanager.impl.VirtualMailboxManagerFactory">
+ <mounts>
+ <mount>
+ <point point="#user"/>
+ <point point="#user1"/>
+ <target
+
class="org.apache.james.mailboxmanager.mock.MockMailboxManagerFactory">
+ <myconf attr="test"/>
+ </target>
+ </mount>
+
+ <mount>
+ <point point="#user2"/>
+ <point point="#user3"/>
+ <target
+
class="org.apache.james.mailboxmanager.mock.MockMailboxManagerFactory">
+ <myconf attr="test2"/>
+ </target>
+ </mount>
+ <mount>
+ <point point="#system"/>
+ <target
+
class="org.apache.james.mailboxmanager.mailstore.MailStoreMailboxManagerFactory">
+ <repository
destinationURL="file://var/mail/"
+ type="MAIL"/>
+ </target>
+ </mount>
+ <mount>
+ <point point="#mail"/>
+ <target
+
class="org.apache.james.mailboxmanager.mock.MockMailboxManagerFactory">
+ <myconf attr="test3"/>
+ </target>
+ </mount>
+ </mounts>
+ </factory>
+ </mailboxmanager-without-torque>
+</config>
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]