01: // The contents of this file are subject to the Mozilla Public License Version
02: // 1.1
03: //(the "License"); you may not use this file except in compliance with the
04: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
05: //
06: //Software distributed under the License is distributed on an "AS IS" basis,
07: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
08: //for the specific language governing rights and
09: //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:
19: package org.columba.mail.folder;
20:
21: import java.io.ByteArrayInputStream;
22: import java.io.InputStream;
23:
24: import org.columba.ristretto.message.Attributes;
25: import org.columba.ristretto.message.Flags;
26:
27: /**
28: * @author fdietz
29: */
30: public class CopyMessageFolderTest extends AbstractFolderTst {
31:
32: public CopyMessageFolderTest(String arg0) {
33: super (arg0);
34: }
35:
36: /**
37: * @param arg0
38: */
39: public CopyMessageFolderTest(MailboxTstFactory factory, String arg0) {
40: super (factory, arg0);
41: }
42:
43: /**
44: * Copy message and check if attributes are copied correctly.
45: * <p>
46: * Use Folder.addMessage(InputStream, Attributes), instead of
47: * CopyMessageCommand.
48: *
49: * @throws Exception
50: */
51: public void testCopyMessageAttribute2() throws Exception {
52: // add message "0.eml" as inputstream to folder
53: String input = FolderTstHelper.getString(0);
54: System.out.println("input=" + input);
55: // create stream from string
56: ByteArrayInputStream inputStream = FolderTstHelper
57: .getByteArrayInputStream(input);
58:
59: // add stream to folder
60: Object uid = getSourceFolder().addMessage(inputStream);
61: // close streams
62: inputStream.close();
63: // get flags of message
64: Flags oldFlags = getSourceFolder().getFlags(uid);
65: // set flags
66: oldFlags.setSeen(false);
67: oldFlags.setRecent(false);
68: oldFlags.setFlagged(true);
69: oldFlags.setDeleted(false);
70:
71: // get message source stream
72: InputStream is = getSourceFolder().getMessageSourceStream(uid);
73: // get message attributes
74: Attributes attributes = getSourceFolder().getAttributes(uid);
75:
76: uid = getDestFolder().addMessage(is, attributes, oldFlags);
77:
78: // close inpustream
79: is.close();
80:
81: Flags flags = getDestFolder().getFlags(uid);
82:
83: assertEquals("copied message should be marked as not seen",
84: false, flags.getSeen());
85: assertEquals("copied message should be marked as flagged",
86: true, flags.getFlagged());
87: assertEquals("copied message should be marked as not expunged",
88: false, flags.getDeleted());
89: // close streams
90: inputStream.close();
91:
92: }
93: }
|