001: // The contents of this file are subject to the Mozilla Public License Version
002: // 1.1
003: //(the "License"); you may not use this file except in compliance with the
004: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
005: //
006: //Software distributed under the License is distributed on an "AS IS" basis,
007: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
008: //for the specific language governing rights and
009: //limitations under the License.
010: //
011: //The Original Code is "The Columba Project"
012: //
013: //The Initial Developers of the Original Code are Frederik Dietz and Timo
014: // Stich.
015: //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
016: //
017: //All Rights Reserved.
018: package org.columba.mail.folder;
019:
020: import java.io.ByteArrayInputStream;
021:
022: import org.columba.mail.folder.command.MarkMessageCommand;
023: import org.columba.ristretto.message.Flags;
024:
025: /**
026: * @author fdietz
027: *
028: */
029: public class ExpungeFolderTest extends AbstractFolderTst {
030:
031: public ExpungeFolderTest(String arg0) {
032: super (arg0);
033: }
034:
035: /**
036: * @param arg0
037: */
038: public ExpungeFolderTest(MailboxTstFactory factory, String arg0) {
039: super (factory, arg0);
040:
041: }
042:
043: /**
044: * Expunge folder, message is *not* marked as expunged
045: *
046: * @throws Exception
047: */
048: public void testExpungeMessage() throws Exception {
049: // add message "0.eml" as inputstream to folder
050: String input = FolderTstHelper.getString(0);
051: System.out.println("input=" + input);
052: // create stream from string
053: ByteArrayInputStream inputStream = FolderTstHelper
054: .getByteArrayInputStream(input);
055: // add stream to folder
056: Object uid = getSourceFolder().addMessage(inputStream);
057: // get flags of message
058: Flags oldFlags = getSourceFolder().getFlags(uid);
059: // set flags
060: oldFlags.setSeen(false);
061: oldFlags.setRecent(true);
062: oldFlags.setFlagged(true);
063: oldFlags.setDeleted(false);
064:
065: getSourceFolder().expungeFolder();
066:
067: Object[] uids = getSourceFolder().getUids();
068: assertEquals("one message should be in source folder", 1,
069: uids.length);
070: IMailboxInfo info = getSourceFolder().getMessageFolderInfo();
071: assertEquals("one message should be in source folder", 1, info
072: .getExists());
073: // close streams
074: inputStream.close();
075: }
076:
077: /**
078: * Expunge folder, one message is marked as expunged
079: *
080: * @throws Exception
081: */
082: public void testExpungeMessage2() throws Exception {
083: // add message "0.eml" as inputstream to folder
084: String input = FolderTstHelper.getString(0);
085: System.out.println("input=" + input);
086: // create stream from string
087: ByteArrayInputStream inputStream = FolderTstHelper
088: .getByteArrayInputStream(input);
089: // add stream to folder
090: Object uid = getSourceFolder().addMessage(inputStream);
091:
092: getSourceFolder().markMessage(new Object[] { uid },
093: MarkMessageCommand.MARK_AS_EXPUNGED);
094:
095: getSourceFolder().expungeFolder();
096:
097: Object[] uids = getSourceFolder().getUids();
098: assertEquals("null message should be in source folder", 0,
099: uids.length);
100: IMailboxInfo info = getSourceFolder().getMessageFolderInfo();
101: assertEquals("null message should be in source folder", 0, info
102: .getExists());
103: // close streams
104: inputStream.close();
105: }
106: }
|