Added: james/imap/trunk/maildir/src/main/java/org/apache/james/imap/maildir/user/MaildirSubscriptionMapper.java URL: http://svn.apache.org/viewvc/james/imap/trunk/maildir/src/main/java/org/apache/james/imap/maildir/user/MaildirSubscriptionMapper.java?rev=986076&view=auto ============================================================================== --- james/imap/trunk/maildir/src/main/java/org/apache/james/imap/maildir/user/MaildirSubscriptionMapper.java (added) +++ james/imap/trunk/maildir/src/main/java/org/apache/james/imap/maildir/user/MaildirSubscriptionMapper.java Mon Aug 16 17:55:26 2010 @@ -0,0 +1,199 @@ +/**************************************************************** + * 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.imap.maildir.user; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; +import java.io.PrintWriter; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.apache.james.imap.api.display.HumanReadableText; +import org.apache.james.imap.mailbox.MailboxException; +import org.apache.james.imap.mailbox.SubscriptionException; +import org.apache.james.imap.maildir.user.model.MaildirSubscription; +import org.apache.james.imap.store.user.SubscriptionMapper; +import org.apache.james.imap.store.user.model.Subscription; + +public class MaildirSubscriptionMapper implements SubscriptionMapper { + + private static final String PATH_USER = "%user"; + private static final String FILE_SUBSCRIPTION = "subscriptions"; + private final String maildirLocation; + + public MaildirSubscriptionMapper(String maildirLocation) { + this.maildirLocation = maildirLocation; + } + + /* + * (non-Javadoc) + * @see org.apache.james.imap.store.user.SubscriptionMapper#delete(org.apache.james.imap.store.user.model.Subscription) + */ + public void delete(Subscription subscription) throws SubscriptionException { + // TODO: we need some kind of file locking here + Set<String> subscriptionNames = readSubscriptionsForUser(subscription.getUser()); + boolean changed = subscriptionNames.remove(subscription.getMailbox()); + if (changed) { + try { + writeSubscriptions(new File(createFolderNameFromUser(subscription.getUser())), subscriptionNames); + } catch (IOException e) { + throw new SubscriptionException(HumanReadableText.GENERIC_SUBSCRIPTION_FAILURE); + } + } + } + + /* + * (non-Javadoc) + * @see org.apache.james.imap.store.user.SubscriptionMapper#findSubscriptionsForUser(java.lang.String) + */ + public List<Subscription> findSubscriptionsForUser(String user) throws SubscriptionException { + Set<String> subscriptionNames = readSubscriptionsForUser(user); + ArrayList<Subscription> subscriptions = new ArrayList<Subscription>(); + for (String subscription : subscriptionNames) { + subscriptions.add(new MaildirSubscription(user, subscription)); + } + return subscriptions; + } + + /* + * (non-Javadoc) + * @see org.apache.james.imap.store.user.SubscriptionMapper#findMailboxSubscriptionForUser(java.lang.String, java.lang.String) + */ + public Subscription findMailboxSubscriptionForUser(String user, String mailbox) throws SubscriptionException { + File userRoot = new File(createFolderNameFromUser(user)); + Set<String> subscriptionNames; + try { + subscriptionNames = readSubscriptions(userRoot); + } catch (IOException e) { + throw new SubscriptionException(HumanReadableText.GENERIC_SUBSCRIPTION_FAILURE); + } + if (subscriptionNames.contains(mailbox)) + return new MaildirSubscription(user, mailbox); + return null; + } + + /* + * (non-Javadoc) + * @see org.apache.james.imap.store.user.SubscriptionMapper#save(org.apache.james.imap.store.user.model.Subscription) + */ + public void save(Subscription subscription) throws SubscriptionException { + // TODO: we need some kind of file locking here + Set<String> subscriptionNames = readSubscriptionsForUser(subscription.getUser()); + boolean changed = subscriptionNames.add(subscription.getMailbox()); + if (changed) { + try { + writeSubscriptions(new File(createFolderNameFromUser(subscription.getUser())), subscriptionNames); + } catch (IOException e) { + throw new SubscriptionException(HumanReadableText.GENERIC_SUBSCRIPTION_FAILURE); + } + } + } + + /* + * (non-Javadoc) + * @see org.apache.james.imap.store.transaction.TransactionalMapper#endRequest() + */ + public void endRequest() { + // nothing to do + } + + /* + * (non-Javadoc) + * @see org.apache.james.imap.store.transaction.TransactionalMapper#execute(org.apache.james.imap.store.transaction.TransactionalMapper.Transaction) + */ + public void execute(Transaction transaction) throws MailboxException { + transaction.run(); + } + + /** + * Get the folder name of the folder containing the user's mailboxes + * @param user The user to get the folder for + * @return The name of the folder + */ + private String createFolderNameFromUser(String user) { + return maildirLocation.replace(PATH_USER, user); + } + + /** + * Read the subscriptions for a particular user + * @param user The user to get the subscriptions for + * @return A Set of names of subscribed mailboxes of the user + * @throws SubscriptionException + */ + private Set<String> readSubscriptionsForUser(String user) throws SubscriptionException { + File userRoot = new File(createFolderNameFromUser(user)); + Set<String> subscriptionNames; + try { + subscriptionNames = readSubscriptions(userRoot); + } catch (IOException e) { + throw new SubscriptionException(HumanReadableText.GENERIC_SUBSCRIPTION_FAILURE); + } + return subscriptionNames; + } + + /** + * Read the names of the mailboxes which are subscribed from the specified folder + * @param mailboxFolder The folder which contains the subscription file + * @return A Set of names of subscribed mailboxes + * @throws IOException + */ + private Set<String> readSubscriptions(File mailboxFolder) throws IOException { + File subscriptionFile = new File(mailboxFolder, FILE_SUBSCRIPTION); + HashSet<String> subscriptions = new HashSet<String>(); + if (!subscriptionFile.exists()) { + return subscriptions; + } + FileReader fileReader = new FileReader(subscriptionFile); + BufferedReader reader = new BufferedReader(fileReader); + String subscription; + while ((subscription = reader.readLine()) != null) + if (!subscription.equals("")) + subscriptions.add(subscription); + reader.close(); + fileReader.close(); + return subscriptions; + } + + /** + * Write the set of mailbox names into the subscriptions file in the specified folder + * @param mailboxFolder Folder which contains the subscriptions file + * @param subscriptions Set of names of subscribed mailboxes + * @throws IOException + */ + private void writeSubscriptions(File mailboxFolder, final Set<String> subscriptions) throws IOException { + List<String> sortedSubscriptions = new ArrayList<String>(subscriptions); + Collections.sort(sortedSubscriptions); + File subscriptionFile = new File(mailboxFolder, FILE_SUBSCRIPTION); + if (!subscriptionFile.exists()) + subscriptionFile.createNewFile(); + FileWriter fileWriter = new FileWriter(subscriptionFile); + PrintWriter writer = new PrintWriter(fileWriter); + for (String subscription : sortedSubscriptions) + writer.println(subscription); + writer.close(); + fileWriter.close(); + } + +}
Added: james/imap/trunk/maildir/src/main/java/org/apache/james/imap/maildir/user/model/MaildirSubscription.java URL: http://svn.apache.org/viewvc/james/imap/trunk/maildir/src/main/java/org/apache/james/imap/maildir/user/model/MaildirSubscription.java?rev=986076&view=auto ============================================================================== --- james/imap/trunk/maildir/src/main/java/org/apache/james/imap/maildir/user/model/MaildirSubscription.java (added) +++ james/imap/trunk/maildir/src/main/java/org/apache/james/imap/maildir/user/model/MaildirSubscription.java Mon Aug 16 17:55:26 2010 @@ -0,0 +1,41 @@ +/**************************************************************** + * 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.imap.maildir.user.model; + +import org.apache.james.imap.store.user.model.Subscription; + +public class MaildirSubscription implements Subscription { + + private final String user; + private final String mailbox; + + public MaildirSubscription(String user, String mailbox) { + this.user = user; + this.mailbox = mailbox; + } + + public String getMailbox() { + return mailbox; + } + + public String getUser() { + return user; + } + +} Added: james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/AuthenticatedStateTest.java URL: http://svn.apache.org/viewvc/james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/AuthenticatedStateTest.java?rev=986076&view=auto ============================================================================== --- james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/AuthenticatedStateTest.java (added) +++ james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/AuthenticatedStateTest.java Mon Aug 16 17:55:26 2010 @@ -0,0 +1,29 @@ +/**************************************************************** + * 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.imap.functional.maildir; + +import org.apache.james.imap.functional.suite.AuthenticatedState; + +public class AuthenticatedStateTest extends + AuthenticatedState { + public AuthenticatedStateTest() throws Exception { + super(MaildirHostSystem.build()); + } +} Added: james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/ConcurrentSessionsTest.java URL: http://svn.apache.org/viewvc/james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/ConcurrentSessionsTest.java?rev=986076&view=auto ============================================================================== --- james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/ConcurrentSessionsTest.java (added) +++ james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/ConcurrentSessionsTest.java Mon Aug 16 17:55:26 2010 @@ -0,0 +1,31 @@ +/**************************************************************** + * 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.imap.functional.maildir; + +import org.apache.james.imap.functional.suite.ConcurrentSessions; + +public class ConcurrentSessionsTest extends + ConcurrentSessions { + + public ConcurrentSessionsTest() throws Exception { + super(MaildirHostSystem.build()); + } + +} Added: james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/EventTest.java URL: http://svn.apache.org/viewvc/james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/EventTest.java?rev=986076&view=auto ============================================================================== --- james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/EventTest.java (added) +++ james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/EventTest.java Mon Aug 16 17:55:26 2010 @@ -0,0 +1,30 @@ +/**************************************************************** + * 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.imap.functional.maildir; + +import org.apache.james.imap.functional.suite.Events; + +public class EventTest extends Events { + + public EventTest() throws Exception { + super(MaildirHostSystem.build()); + } + +} Added: james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/ExpungeTest.java URL: http://svn.apache.org/viewvc/james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/ExpungeTest.java?rev=986076&view=auto ============================================================================== --- james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/ExpungeTest.java (added) +++ james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/ExpungeTest.java Mon Aug 16 17:55:26 2010 @@ -0,0 +1,30 @@ +/**************************************************************** + * 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.imap.functional.maildir; + +import org.apache.james.imap.functional.suite.Expunge; + +public class ExpungeTest extends Expunge { + + public ExpungeTest() throws Exception { + super(MaildirHostSystem.build()); + } + +} Added: james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/FetchBodySectionTest.java URL: http://svn.apache.org/viewvc/james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/FetchBodySectionTest.java?rev=986076&view=auto ============================================================================== --- james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/FetchBodySectionTest.java (added) +++ james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/FetchBodySectionTest.java Mon Aug 16 17:55:26 2010 @@ -0,0 +1,29 @@ +/**************************************************************** + * 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.imap.functional.maildir; + +import org.apache.james.imap.functional.suite.FetchBodySection; + +public class FetchBodySectionTest extends FetchBodySection { + + public FetchBodySectionTest() throws Exception { + super(MaildirHostSystem.build()); + + } +} Added: james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/FetchBodyStructureTest.java URL: http://svn.apache.org/viewvc/james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/FetchBodyStructureTest.java?rev=986076&view=auto ============================================================================== --- james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/FetchBodyStructureTest.java (added) +++ james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/FetchBodyStructureTest.java Mon Aug 16 17:55:26 2010 @@ -0,0 +1,31 @@ +/**************************************************************** + * 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.imap.functional.maildir; + +import org.apache.james.imap.functional.suite.FetchBodyStructure; + +public class FetchBodyStructureTest extends + FetchBodyStructure { + + public FetchBodyStructureTest() throws Exception { + super(MaildirHostSystem.build()); + } + +} Added: james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/FetchHeadersTest.java URL: http://svn.apache.org/viewvc/james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/FetchHeadersTest.java?rev=986076&view=auto ============================================================================== --- james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/FetchHeadersTest.java (added) +++ james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/FetchHeadersTest.java Mon Aug 16 17:55:26 2010 @@ -0,0 +1,30 @@ +/**************************************************************** + * 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.imap.functional.maildir; + +import org.apache.james.imap.functional.suite.FetchHeaders; + +public class FetchHeadersTest extends FetchHeaders { + + public FetchHeadersTest() throws Exception { + super(MaildirHostSystem.build()); + } + +} Added: james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/FetchTest.java URL: http://svn.apache.org/viewvc/james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/FetchTest.java?rev=986076&view=auto ============================================================================== --- james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/FetchTest.java (added) +++ james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/FetchTest.java Mon Aug 16 17:55:26 2010 @@ -0,0 +1,29 @@ +/**************************************************************** + * 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.imap.functional.maildir; + +import org.apache.james.imap.functional.suite.Fetch; + +public class FetchTest extends Fetch { + + public FetchTest() throws Exception { + super(MaildirHostSystem.build()); + } +} Added: james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/ListingTest.java URL: http://svn.apache.org/viewvc/james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/ListingTest.java?rev=986076&view=auto ============================================================================== --- james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/ListingTest.java (added) +++ james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/ListingTest.java Mon Aug 16 17:55:26 2010 @@ -0,0 +1,28 @@ +/**************************************************************** + * 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.imap.functional.maildir; + +import org.apache.james.imap.functional.suite.Listing; + +public class ListingTest extends Listing{ + + public ListingTest() throws Exception { + super(MaildirHostSystem.build()); + } +} Added: james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/MaildirHostSystem.java URL: http://svn.apache.org/viewvc/james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/MaildirHostSystem.java?rev=986076&view=auto ============================================================================== --- james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/MaildirHostSystem.java (added) +++ james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/MaildirHostSystem.java Mon Aug 16 17:55:26 2010 @@ -0,0 +1,84 @@ +/**************************************************************** + * 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.imap.functional.maildir; + +import java.io.File; + +import org.apache.commons.io.FileUtils; +import org.apache.james.imap.encode.main.DefaultImapEncoderFactory; +import org.apache.james.imap.functional.ImapHostSystem; +import org.apache.james.imap.functional.InMemoryUserManager; +import org.apache.james.imap.maildir.MaildirMailboxManager; +import org.apache.james.imap.maildir.MaildirMailboxSessionMapperFactory; +import org.apache.james.imap.maildir.MaildirSubscriptionManager; +import org.apache.james.imap.main.DefaultImapDecoderFactory; +import org.apache.james.imap.processor.main.DefaultImapProcessorFactory; +import org.apache.james.test.functional.HostSystem; + +public class MaildirHostSystem extends ImapHostSystem { + + public static final String META_DATA_DIRECTORY = "target/user-meta-data"; + private static final String MAILDIR_HOME = "target/Maildir"; + + private final MaildirMailboxManager mailboxManager; + private final InMemoryUserManager userManager; + private final MaildirMailboxSessionMapperFactory mailboxSessionMapperFactory; + + public static HostSystem build() throws Exception { + return new MaildirHostSystem(); + } + + public MaildirHostSystem() { + userManager = new InMemoryUserManager(); + mailboxSessionMapperFactory = new MaildirMailboxSessionMapperFactory(MAILDIR_HOME + "/%user"); + MaildirSubscriptionManager sm = new MaildirSubscriptionManager(mailboxSessionMapperFactory); + mailboxManager = new MaildirMailboxManager(mailboxSessionMapperFactory, userManager, sm); + + final DefaultImapProcessorFactory defaultImapProcessorFactory = new DefaultImapProcessorFactory(); + defaultImapProcessorFactory.configure(mailboxManager); + configure(new DefaultImapDecoderFactory().buildImapDecoder(), + new DefaultImapEncoderFactory().buildImapEncoder(), + defaultImapProcessorFactory.buildImapProcessor()); + (new File(MAILDIR_HOME)).mkdirs(); + } + + public boolean addUser(String user, String password) throws Exception { + userManager.addUser(user, password); + return true; + } + + @Override + public void resetData() throws Exception { + resetUserMetaData(); + try { + FileUtils.deleteDirectory(new File(MAILDIR_HOME)); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public void resetUserMetaData() throws Exception { + File dir = new File(META_DATA_DIRECTORY); + if (dir.exists()) { + FileUtils.deleteDirectory(dir); + } + dir.mkdirs(); + } + +} Added: james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/MaildirStressTest.java URL: http://svn.apache.org/viewvc/james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/MaildirStressTest.java?rev=986076&view=auto ============================================================================== --- james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/MaildirStressTest.java (added) +++ james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/MaildirStressTest.java Mon Aug 16 17:55:26 2010 @@ -0,0 +1,54 @@ +/**************************************************************** + * 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.imap.functional.maildir; + +import java.io.File; +import java.io.IOException; + +import org.apache.commons.io.FileUtils; +import org.apache.james.imap.functional.AbstractStressTest; +import org.apache.james.imap.maildir.MaildirMailboxManager; +import org.apache.james.imap.maildir.MaildirMailboxSessionMapperFactory; +import org.apache.james.imap.maildir.MaildirSubscriptionManager; +import org.apache.james.imap.store.StoreMailboxManager; +import org.junit.After; +import org.junit.Before; + +public class MaildirStressTest extends AbstractStressTest { + + private static final String MAILDIR_HOME = "target/Maildir"; + private MaildirMailboxManager mailboxManager; + + @Before + public void setUp() { + MaildirMailboxSessionMapperFactory mf = new MaildirMailboxSessionMapperFactory(MAILDIR_HOME + "/%user"); + mailboxManager = new MaildirMailboxManager(mf, null, new MaildirSubscriptionManager(mf)); + } + + @After + public void tearDown() throws IOException { + FileUtils.deleteDirectory(new File(MAILDIR_HOME)); + } + + @Override + protected StoreMailboxManager<?> getMailboxManager() { + return mailboxManager; + } + +} Added: james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/NonAuthenticatedStateTest.java URL: http://svn.apache.org/viewvc/james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/NonAuthenticatedStateTest.java?rev=986076&view=auto ============================================================================== --- james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/NonAuthenticatedStateTest.java (added) +++ james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/NonAuthenticatedStateTest.java Mon Aug 16 17:55:26 2010 @@ -0,0 +1,30 @@ +/**************************************************************** + * 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.imap.functional.maildir; + +import org.apache.james.imap.functional.suite.NonAuthenticatedState; + +public class NonAuthenticatedStateTest extends + NonAuthenticatedState { + + public NonAuthenticatedStateTest() throws Exception { + super(MaildirHostSystem.build()); + } +} Added: james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/PartialFetchTest.java URL: http://svn.apache.org/viewvc/james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/PartialFetchTest.java?rev=986076&view=auto ============================================================================== --- james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/PartialFetchTest.java (added) +++ james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/PartialFetchTest.java Mon Aug 16 17:55:26 2010 @@ -0,0 +1,30 @@ +/**************************************************************** + * 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.imap.functional.maildir; + +import org.apache.james.imap.functional.suite.PartialFetch; + +public class PartialFetchTest extends PartialFetch { + + public PartialFetchTest() throws Exception { + super(MaildirHostSystem.build()); + } + +} Added: james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/RenameTest.java URL: http://svn.apache.org/viewvc/james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/RenameTest.java?rev=986076&view=auto ============================================================================== --- james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/RenameTest.java (added) +++ james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/RenameTest.java Mon Aug 16 17:55:26 2010 @@ -0,0 +1,31 @@ +/**************************************************************** + * 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.imap.functional.maildir; + +import org.apache.james.imap.functional.suite.Rename; + +public class RenameTest extends Rename { + + public RenameTest() throws Exception { + super(MaildirHostSystem.build()); + } + +} + Added: james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/SecurityTest.java URL: http://svn.apache.org/viewvc/james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/SecurityTest.java?rev=986076&view=auto ============================================================================== --- james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/SecurityTest.java (added) +++ james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/SecurityTest.java Mon Aug 16 17:55:26 2010 @@ -0,0 +1,30 @@ +/**************************************************************** + * 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.imap.functional.maildir; + +import org.apache.james.imap.functional.suite.Security; + +public class SecurityTest extends Security { + + public SecurityTest() throws Exception { + super(MaildirHostSystem.build()); + } + +} Added: james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/SelectTest.java URL: http://svn.apache.org/viewvc/james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/SelectTest.java?rev=986076&view=auto ============================================================================== --- james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/SelectTest.java (added) +++ james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/SelectTest.java Mon Aug 16 17:55:26 2010 @@ -0,0 +1,29 @@ +/**************************************************************** + * 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.imap.functional.maildir; + +import org.apache.james.imap.functional.suite.Select; + +public class SelectTest extends Select{ + + public SelectTest() throws Exception { + super(MaildirHostSystem.build()); + } +} Added: james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/SelectedInboxTest.java URL: http://svn.apache.org/viewvc/james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/SelectedInboxTest.java?rev=986076&view=auto ============================================================================== --- james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/SelectedInboxTest.java (added) +++ james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/SelectedInboxTest.java Mon Aug 16 17:55:26 2010 @@ -0,0 +1,29 @@ +/**************************************************************** + * 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.imap.functional.maildir; + +import org.apache.james.imap.functional.suite.SelectedInbox; + +public class SelectedInboxTest extends SelectedInbox { + + public SelectedInboxTest() throws Exception { + super(MaildirHostSystem.build()); + } +} Added: james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/SelectedStateTest.java URL: http://svn.apache.org/viewvc/james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/SelectedStateTest.java?rev=986076&view=auto ============================================================================== --- james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/SelectedStateTest.java (added) +++ james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/SelectedStateTest.java Mon Aug 16 17:55:26 2010 @@ -0,0 +1,29 @@ +/**************************************************************** + * 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.imap.functional.maildir; + +import org.apache.james.imap.functional.suite.SelectedState; + +public class SelectedStateTest extends SelectedState { + + public SelectedStateTest() throws Exception { + super(MaildirHostSystem.build()); + } +} Added: james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/UidSearchTest.java URL: http://svn.apache.org/viewvc/james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/UidSearchTest.java?rev=986076&view=auto ============================================================================== --- james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/UidSearchTest.java (added) +++ james/imap/trunk/maildir/src/test/java/org/apache/james/imap/functional/maildir/UidSearchTest.java Mon Aug 16 17:55:26 2010 @@ -0,0 +1,29 @@ +/**************************************************************** + * 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.imap.functional.maildir; + +import org.apache.james.imap.functional.suite.UidSearch; + +public class UidSearchTest extends UidSearch{ + + public UidSearchTest() throws Exception { + super(MaildirHostSystem.build()); + } +} Modified: james/imap/trunk/parent/pom.xml URL: http://svn.apache.org/viewvc/james/imap/trunk/parent/pom.xml?rev=986076&r1=986075&r2=986076&view=diff ============================================================================== --- james/imap/trunk/parent/pom.xml (original) +++ james/imap/trunk/parent/pom.xml Mon Aug 16 17:55:26 2010 @@ -232,7 +232,7 @@ <groupId>org.apache.james</groupId> <artifactId>apache-james-imap-jcr</artifactId> <version>${pom.version}</version> - </dependency> + </dependency> <dependency> <groupId>org.apache.james</groupId> <artifactId>apache-james-imap-memory</artifactId> @@ -274,8 +274,13 @@ <groupId>org.apache.james</groupId> <artifactId>apache-james-imap-deployment</artifactId> <version>${pom.version}</version> - <type>test-jar</type> + <type>test-jar</type> <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.james</groupId> + <artifactId>apache-james-imap-maildir</artifactId> + <version>${pom.version}</version> </dependency> <!-- END Modules @@ -499,28 +504,7 @@ <!-- END OpenJPA --> - - <!-- - START Maildir - --> - <!-- - <dependency> - <groupId>commons-transaction</groupId> - <artifactId>commons-transaction</artifactId> - <version>2.0-SNAPSHOT</version> - </dependency> - <dependency> - <groupId>com.thoughtworks.xstream</groupId> - <artifactId>xstream</artifactId> - <version>1.3.1</version> - </dependency> - --> - - - <!-- - END Maildir - --> - + <!-- START JCR --> Modified: james/imap/trunk/pom.xml URL: http://svn.apache.org/viewvc/james/imap/trunk/pom.xml?rev=986076&r1=986075&r2=986076&view=diff ============================================================================== --- james/imap/trunk/pom.xml (original) +++ james/imap/trunk/pom.xml Mon Aug 16 17:55:26 2010 @@ -48,9 +48,7 @@ <module>deployment</module> <module>parent</module> <module>torque</module> - <!-- <module>maildir</module> - --> </modules> <distributionManagement> <site> --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
