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:
019: package org.columba.mail.folder.command;
020:
021: import java.io.ByteArrayInputStream;
022:
023: import org.columba.core.command.NullWorkerStatusController;
024: import org.columba.mail.command.MailFolderCommandReference;
025: import org.columba.mail.folder.AbstractFolderTst;
026: import org.columba.mail.folder.FolderTstHelper;
027: import org.columba.mail.folder.MailboxTstFactory;
028: import org.columba.ristretto.message.Flags;
029:
030: /**
031: * @author fdietz
032: */
033: public class MarkMessageTest extends AbstractFolderTst {
034:
035: private Object uid;
036:
037: private ByteArrayInputStream inputStream;
038:
039: public MarkMessageTest(String arg0) {
040: super (arg0);
041: }
042:
043: /**
044: * @param arg0
045: */
046: public MarkMessageTest(MailboxTstFactory factory, String arg0) {
047: super (factory, arg0);
048: }
049:
050: public void testMarkAsReadMessage() throws Exception {
051:
052: // create Command reference
053: MailFolderCommandReference ref = new MailFolderCommandReference(
054: getSourceFolder(), new Object[] { uid });
055: ref.setMarkVariant(MarkMessageCommand.MARK_AS_READ);
056:
057: // create copy command
058: MarkMessageCommand command = new MarkMessageCommand(ref);
059:
060: // execute command -> use mock object class as worker which does
061: // nothing
062: command.execute(NullWorkerStatusController.getInstance());
063:
064: Flags flags = getSourceFolder().getFlags(uid);
065:
066: assertEquals("message should be marked as read", true, flags
067: .getSeen());
068:
069: }
070:
071: public void testMarkAsFlaggedMessage() throws Exception {
072:
073: // create Command reference
074: MailFolderCommandReference ref = new MailFolderCommandReference(
075: getSourceFolder(), new Object[] { uid });
076:
077: ref.setMarkVariant(MarkMessageCommand.MARK_AS_FLAGGED);
078:
079: // create copy command
080: MarkMessageCommand command = new MarkMessageCommand(ref);
081:
082: // execute command -> use mock object class as worker which does
083: // nothing
084: command.execute(NullWorkerStatusController.getInstance());
085:
086: Flags flags = getSourceFolder().getFlags(uid);
087:
088: assertEquals("message should be marked as flagged", true, flags
089: .getFlagged());
090:
091: }
092:
093: public void testMarkAsExpungedMessage() throws Exception {
094:
095: // create Command reference
096: MailFolderCommandReference ref = new MailFolderCommandReference(
097: getSourceFolder(), new Object[] { uid });
098: ref.setMarkVariant(MarkMessageCommand.MARK_AS_EXPUNGED);
099:
100: // create copy command
101: MarkMessageCommand command = new MarkMessageCommand(ref);
102:
103: // execute command -> use mock object class as worker which does
104: // nothing
105: command.execute(NullWorkerStatusController.getInstance());
106:
107: Flags flags = getSourceFolder().getFlags(uid);
108:
109: assertEquals("message should be marked as expunged", true,
110: flags.getDeleted());
111:
112: }
113:
114: /**
115: * @see junit.framework.TestCase#setUp()
116: */
117: protected void setUp() throws Exception {
118: // create folders, etc.
119: super .setUp();
120:
121: // add message "0.eml" as inputstream to folder
122: String input = FolderTstHelper.getString(0);
123: System.out.println("input=" + input);
124: // create stream from string
125: inputStream = FolderTstHelper.getByteArrayInputStream(input);
126: // add stream to folder
127: uid = getSourceFolder().addMessage(inputStream);
128:
129: }
130:
131: /**
132: * @see junit.framework.TestCase#tearDown()
133: */
134: protected void tearDown() throws Exception {
135: // close streams
136: inputStream.close();
137:
138: // delete folders
139: super.tearDown();
140:
141: }
142: }
|