01: //The contents of this file are subject to the Mozilla Public License Version 1.1
02: //(the "License"); you may not use this file except in compliance with the
03: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
04: //
05: //Software distributed under the License is distributed on an "AS IS" basis,
06: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
07: //for the specific language governing rights and
08: //limitations under the License.
09: //
10: //The Original Code is "The Columba Project"
11: //
12: //The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
13: //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
14: //
15: //All Rights Reserved.
16:
17: package org.columba.mail.folder.command;
18:
19: import java.io.ByteArrayInputStream;
20: import java.io.InputStream;
21:
22: import org.columba.core.command.NullWorkerStatusController;
23: import org.columba.mail.command.MailFolderCommandReference;
24: import org.columba.mail.folder.AbstractFolderTst;
25: import org.columba.mail.folder.FolderTstHelper;
26: import org.columba.mail.folder.IMailboxInfo;
27: import org.columba.mail.folder.MailboxTstFactory;
28:
29: /**
30: * @author fdietz
31: */
32: public class MoveMessageTest extends AbstractFolderTst {
33:
34: public MoveMessageTest(String arg0) {
35: super (arg0);
36: }
37:
38: /**
39: * @param arg0
40: */
41: public MoveMessageTest(MailboxTstFactory factory, String arg0) {
42: super (factory, arg0);
43: }
44:
45: public void testMoveMessage() throws Exception {
46: // add message "0.eml" as inputstream to folder
47: String input = FolderTstHelper.getString(0);
48: System.out.println("input=" + input);
49: // create stream from string
50: ByteArrayInputStream inputStream = FolderTstHelper
51: .getByteArrayInputStream(input);
52: // add stream to folder
53: Object uid = getSourceFolder().addMessage(inputStream);
54:
55: // create Command reference
56: MailFolderCommandReference ref = new MailFolderCommandReference(
57: getSourceFolder(), getDestFolder(),
58: new Object[] { uid });
59:
60: // create copy command
61: MoveMessageCommand command = new MoveMessageCommand(ref);
62:
63: // execute command -> use mock object class as worker which does nothing
64: command.execute(NullWorkerStatusController.getInstance());
65:
66: // get inputstream of this message from folder
67: InputStream outputStream = destFolder
68: .getMessageSourceStream(uid);
69: // create string from inputstream
70: String output = FolderTstHelper
71: .getStringFromInputStream(outputStream);
72: // compare both messages
73: assertEquals(input, output);
74: IMailboxInfo info = getDestFolder().getMessageFolderInfo();
75: assertEquals("one message should be in destination folder", 1,
76: info.getExists());
77: info = getSourceFolder().getMessageFolderInfo();
78: // close streams
79: inputStream.close();
80: outputStream.close();
81: }
82: }
|