KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > james > imapserver > handler > session > DeleteSessionTest


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 package org.apache.james.imapserver.handler.session;
21
22 import java.io.IOException JavaDoc;
23
24 import javax.mail.MessagingException JavaDoc;
25 import javax.mail.internet.MimeMessage JavaDoc;
26
27 import org.apache.james.imapserver.ProtocolException;
28 import org.apache.james.imapserver.client.DeleteClientCommand;
29 import org.apache.james.imapserver.client.LoginCommand;
30 import org.apache.james.imapserver.client.LogoutClientCommand;
31 import org.apache.james.imapserver.store.MailboxException;
32 import org.apache.james.imapserver.util.MessageGenerator;
33 import org.apache.james.mailboxmanager.MailboxManagerException;
34
35 public class DeleteSessionTest extends AbstractSessionTest {
36
37     String JavaDoc[] folders = { USER_MAILBOX_ROOT + ".INBOX",
38             USER_MAILBOX_ROOT + ".test", USER_MAILBOX_ROOT + ".test1",
39             USER_MAILBOX_ROOT + ".test1.test1a",
40             USER_MAILBOX_ROOT + ".test1.test1b",
41             USER_MAILBOX_ROOT + ".test2.test2a",
42             USER_MAILBOX_ROOT + ".test2.test2b" };
43
44     MimeMessage JavaDoc[] msgs = null;
45
46     public void setUp() throws MailboxException, MessagingException JavaDoc,
47             IOException JavaDoc, MailboxManagerException {
48         super.setUp();
49         msgs = MessageGenerator.generateSimpleMessages(4);
50         createFolders(folders);
51         // increase the uid
52
appendMessagesClosed(USER_MAILBOX_ROOT+".test1.test1a", msgs);
53  
54     }
55
56     public void tearDown() throws Exception JavaDoc {
57         super.tearDown();
58         for (int i = 0; i < folders.length; i++) {
59             assertFalse(folders[i] + " is still in use!", isOpen(folders[i]));
60         }
61     }
62
63     public void testDeleteExisting() throws ProtocolException, IOException JavaDoc,
64             MessagingException JavaDoc, MailboxManagerException {
65         verifyCommand(new LoginCommand(USER_NAME, USER_PASSWORD));
66         assertTrue(folderExists(USER_MAILBOX_ROOT + ".test1.test1a"));
67         verifyCommand(new DeleteClientCommand("test1.test1a"));
68         assertFalse(folderExists(USER_MAILBOX_ROOT + ".test1.test1a"));
69         verifyCommand(new LogoutClientCommand());
70     }
71
72 }
73
Popular Tags