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