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.gui.composer.command;
019:
020: import java.io.InputStream;
021: import java.util.List;
022:
023: import org.columba.core.command.NullWorkerStatusController;
024: import org.columba.mail.command.MailFolderCommandReference;
025: import org.columba.mail.folder.FolderTstHelper;
026: import org.columba.mail.folder.MailboxTstFactory;
027: import org.columba.mail.gui.composer.ComposerModel;
028: import org.columba.ristretto.message.InputStreamMimePart;
029:
030: /**
031: * @author fdietz
032: *
033: */
034: public class ForwardCommandTest extends AbstractComposerTst {
035:
036: public ForwardCommandTest(String arg0) {
037: super (arg0);
038:
039: }
040:
041: /**
042: * @param arg0
043: */
044: public ForwardCommandTest(MailboxTstFactory factory, String arg0) {
045: super (factory, arg0);
046: }
047:
048: public void test() throws Exception {
049:
050: // add message "0.eml" as inputstream to folder
051: String input = FolderTstHelper.getString(0);
052: System.out.println("input=" + input);
053: // create stream from string
054: InputStream inputStream = FolderTstHelper
055: .getByteArrayInputStream(input);
056: // add stream to folder
057: Object uid = getSourceFolder().addMessage(inputStream);
058:
059: // create Command reference
060: MailFolderCommandReference ref = new MailFolderCommandReference(
061: getSourceFolder(), new Object[] { uid });
062:
063: // create copy command
064: ForwardCommand command = new ForwardCommand(ref);
065:
066: // execute command -> use mock object class as worker which does
067: // nothing
068: command.execute(NullWorkerStatusController.getInstance());
069:
070: // model should contain the data
071: ComposerModel model = command.getModel();
072:
073: String subject = model.getSubject();
074:
075: assertEquals("Subject", "Fwd: test", subject);
076: }
077:
078: public void testForewardWithAttachment() throws Exception {
079: String input = FolderTstHelper.getString("0_attachment.eml");
080: System.out.println("input=" + input);
081: // create stream from string
082: InputStream inputStream = FolderTstHelper
083: .getByteArrayInputStream(input);
084: // add stream to folder
085: Object uid = getSourceFolder().addMessage(inputStream);
086: // create Command reference
087: MailFolderCommandReference ref = new MailFolderCommandReference(
088: getSourceFolder(), new Object[] { uid });
089: // create copy command
090: ForwardCommand command = new ForwardCommand(ref);
091: // execute command -> use mock object class as worker which does
092: // nothing
093: command.execute(NullWorkerStatusController.getInstance());
094: // model should contain the data
095: ComposerModel model = command.getModel();
096: List attachments = model.getAttachments();
097: assertEquals("There should be one attachment", 1, attachments
098: .size());
099: Object mimePart = attachments.get(0);
100: assertEquals("Should be type of StreamableMimePart", true,
101: (mimePart instanceof InputStreamMimePart));
102:
103: }
104: }
|