KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > mail > folder > GetMessageSourceStreamTest


1 //The contents of this file are subject to the Mozilla Public License Version 1.1
2
//(the "License"); you may not use this file except in compliance with the
3
//License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
4
//
5
//Software distributed under the License is distributed on an "AS IS" basis,
6
//WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
7
//for the specific language governing rights and
8
//limitations under the License.
9
//
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 JavaDoc;
19 import java.io.InputStream JavaDoc;
20
21
22 /**
23  * @author fdietz
24  *
25  */

26 public class GetMessageSourceStreamTest extends AbstractFolderTst {
27
28     
29     public GetMessageSourceStreamTest(String JavaDoc arg0) {
30         super(arg0);
31     }
32     
33     /**
34      * @param factory
35      * @param test
36      */

37     public GetMessageSourceStreamTest(MailboxTstFactory factory, String JavaDoc test) {
38         super(factory, test);
39     }
40
41     /**
42      * Test if IMailbox.getMessageSourceStream() returns the
43      * correct data.
44      *
45      */

46     public void test() throws Exception JavaDoc {
47         // add message "0.eml" as inputstream to folder
48
String JavaDoc input = FolderTstHelper.getString(0);
49         System.out.println("input=" + input);
50
51         // create stream from string
52
ByteArrayInputStream JavaDoc inputStream = FolderTstHelper
53                 .getByteArrayInputStream(input);
54
55         // add stream to folder
56
Object JavaDoc uid = getSourceFolder().addMessage(inputStream);
57
58         // get inputstream of this message from folder
59
InputStream JavaDoc outputStream = sourceFolder.getMessageSourceStream(uid);
60
61         // create string from inputstream
62
String JavaDoc output = FolderTstHelper.getStringFromInputStream(outputStream);
63
64         // compare both messages
65
assertEquals("message source should be equal", input, output);
66
67         outputStream.close();
68     }
69
70 }
71
Popular Tags