KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > mail > gui > composer > command > ForwardInlineCommandTest


1 // The contents of this file are subject to the Mozilla Public License Version
2
//1.1
3
//(the "License"); you may not use this file except in compliance with the
4
//License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
5
//
6
//Software distributed under the License is distributed on an "AS IS" basis,
7
//WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
8
//for the specific language governing rights and
9
//limitations under the License.
10
//
11
//The Original Code is "The Columba Project"
12
//
13
//The Initial Developers of the Original Code are Frederik Dietz and Timo
14
//Stich.
15
//Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
16
//
17
//All Rights Reserved.
18
package org.columba.mail.gui.composer.command;
19
20 import java.io.InputStream JavaDoc;
21 import java.util.List JavaDoc;
22
23 import org.columba.core.command.NullWorkerStatusController;
24 import org.columba.mail.command.MailFolderCommandReference;
25 import org.columba.mail.folder.FolderTstHelper;
26 import org.columba.mail.folder.MailboxTstFactory;
27 import org.columba.mail.gui.composer.ComposerModel;
28 import org.columba.ristretto.message.InputStreamMimePart;
29
30 /**
31  * @author fdietz
32  *
33  */

34 public class ForwardInlineCommandTest extends AbstractComposerTst {
35
36     public ForwardInlineCommandTest(String JavaDoc arg0) {
37         super(arg0);
38         
39     }
40     
41     /**
42      * @param arg0
43      */

44     public ForwardInlineCommandTest(MailboxTstFactory factory, String JavaDoc arg0) {
45         super(factory, arg0);
46     }
47
48     public void test() throws Exception JavaDoc {
49
50         // add message "0.eml" as inputstream to folder
51
String JavaDoc input = FolderTstHelper.getString(0);
52         System.out.println("input=" + input);
53         // create stream from string
54
InputStream JavaDoc inputStream = FolderTstHelper
55                 .getByteArrayInputStream(input);
56         // add stream to folder
57
Object JavaDoc uid = getSourceFolder().addMessage(inputStream);
58
59 // create Command reference
60
MailFolderCommandReference ref = new MailFolderCommandReference(
61                 getSourceFolder(), new Object JavaDoc[] { uid });
62
63         // create copy command
64
ForwardInlineCommand command = new ForwardInlineCommand(ref);
65
66         // execute command -> use mock object class as worker which does
67
// nothing
68
command.execute(NullWorkerStatusController.getInstance());
69
70         // model should contain the data
71
ComposerModel model = command.getModel();
72
73         String JavaDoc subject = model.getSubject();
74
75         assertEquals("Subject", "Fwd: test", subject);
76     }
77     
78     public void testForewardWithAttachment() throws Exception JavaDoc {
79         String JavaDoc input = FolderTstHelper.getString("0_attachment.eml");
80         System.out.println("input=" + input);
81         // create stream from string
82
InputStream JavaDoc inputStream =
83             FolderTstHelper.getByteArrayInputStream(input);
84         // add stream to folder
85
Object JavaDoc uid = getSourceFolder().addMessage(inputStream);
86 // create Command reference
87
MailFolderCommandReference ref = new MailFolderCommandReference(
88                 getSourceFolder(), new Object JavaDoc[] { uid });
89         // create copy command
90
ForwardInlineCommand command = new ForwardInlineCommand(ref);
91         // execute command -> use mock object class as worker which does
92
// nothing
93
command.execute(NullWorkerStatusController.getInstance());
94         // model should contain the data
95
ComposerModel model = command.getModel();
96         List JavaDoc attachments = model.getAttachments();
97  
98         assertEquals("There should be one attachment", 1, attachments.size());
99         Object JavaDoc mimePart = attachments.get(0);
100         assertEquals(
101             "Should be type of StreamableMimePart",
102             true,
103             (mimePart instanceof InputStreamMimePart));
104            
105
106     }
107     
108 }
Popular Tags