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: package org.columba.mail.folder;
17:
18: import java.io.ByteArrayInputStream;
19: import java.io.InputStream;
20:
21: /**
22: * @author fdietz
23: *
24: */
25: public class GetMessageSourceStreamTest extends AbstractFolderTst {
26:
27: public GetMessageSourceStreamTest(String arg0) {
28: super (arg0);
29: }
30:
31: /**
32: * @param factory
33: * @param test
34: */
35: public GetMessageSourceStreamTest(MailboxTstFactory factory,
36: String test) {
37: super (factory, test);
38: }
39:
40: /**
41: * Test if IMailbox.getMessageSourceStream() returns the
42: * correct data.
43: *
44: */
45: public void test() throws Exception {
46: // add message "0.eml" as inputstream to folder
47: String input = FolderTstHelper.getString(0);
48: System.out.println("input=" + input);
49:
50: // create stream from string
51: ByteArrayInputStream inputStream = FolderTstHelper
52: .getByteArrayInputStream(input);
53:
54: // add stream to folder
55: Object uid = getSourceFolder().addMessage(inputStream);
56:
57: // get inputstream of this message from folder
58: InputStream outputStream = sourceFolder
59: .getMessageSourceStream(uid);
60:
61: // create string from inputstream
62: String output = FolderTstHelper
63: .getStringFromInputStream(outputStream);
64:
65: // compare both messages
66: assertEquals("message source should be equal", input, output);
67:
68: outputStream.close();
69: }
70:
71: }
|