KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > james > core > MimeMessageUtilTest


1 /****************************************************************
2  * Licensed to the Apache Software Foundation (ASF) under one *
3  * or more contributor license agreements. See the NOTICE file *
4  * distributed with this work for additional information *
5  * regarding copyright ownership. The ASF licenses this file *
6  * to you under the Apache License, Version 2.0 (the *
7  * "License"); you may not use this file except in compliance *
8  * with the License. You may obtain a copy of the License at *
9  * *
10  * http://www.apache.org/licenses/LICENSE-2.0 *
11  * *
12  * Unless required by applicable law or agreed to in writing, *
13  * software distributed under the License is distributed on an *
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
15  * KIND, either express or implied. See the License for the *
16  * specific language governing permissions and limitations *
17  * under the License. *
18  ****************************************************************/

19
20
21
22 package org.apache.james.core;
23
24 import javax.mail.MessagingException JavaDoc;
25 import javax.mail.Session JavaDoc;
26 import javax.mail.internet.MimeMessage JavaDoc;
27
28 import java.io.ByteArrayInputStream JavaDoc;
29 import java.io.ByteArrayOutputStream JavaDoc;
30 import java.io.IOException JavaDoc;
31 import java.util.Properties JavaDoc;
32
33 import junit.framework.TestCase;
34
35 public class MimeMessageUtilTest extends TestCase {
36
37     public void testWriteMimeMessageMultipartWithMessageID() throws MessagingException JavaDoc, IOException JavaDoc {
38         String JavaDoc message = "Received: from localhost.localdomain ([127.0.0.1])\r\n"+
39         " by athlon14 (JAMES SMTP Server 2.3-dev) with SMTP ID 694\r\n"+
40         " for <test_int1@athlon14.bf.loc>;\r\n"+
41         " Sat, 18 Feb 2006 19:30:53 +0100 (CET)\r\n"+
42         "Subject: ext2int\r\n"+
43         "X-James-Postage: This is a test mail sent by James Postage\r\n"+
44         "Mime-Version: 1.0\r\n"+
45         "Content-Type: multipart/alternative; boundary=\"XyoYyxCQIfmZ5Sxofid6XQVZt5Z09XtTnqBF4Z45XSA=\"\r\n"+
46         "Date: Sat, 18 Feb 2006 19:30:53 +0100 (CET)\r\n"+
47         "From: test_ext2@another.bf.loc\r\n"+
48         "\r\n"+
49         "\r\n"+
50         "--XyoYyxCQIfmZ5Sxofid6XQVZt5Z09XtTnqBF4Z45XSA=\r\n"+
51         "Content-Type: text/plain\r\n"+
52         "\r\n"+
53         "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\r\n"+
54         "--XyoYyxCQIfmZ5Sxofid6XQVZt5Z09XtTnqBF4Z45XSA=\r\n"+
55         "Content-Type: application/octet-stream\r\n"+
56         "\r\n"+
57         "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\r\n"+
58         "--XyoYyxCQIfmZ5Sxofid6XQVZt5Z09XtTnqBF4Z45XSA=--\r\n";
59         
60         ;
61
62         MimeMessage JavaDoc mimeMessage = new MimeMessage JavaDoc(Session.getDefaultInstance(new Properties JavaDoc()),new ByteArrayInputStream JavaDoc(message.getBytes()));
63         mimeMessage.getSize();
64         ByteArrayOutputStream JavaDoc headerOut = new ByteArrayOutputStream JavaDoc();
65         ByteArrayOutputStream JavaDoc bodyOut = new ByteArrayOutputStream JavaDoc();
66         MimeMessageUtil.writeTo(mimeMessage, headerOut, bodyOut);
67     }
68
69 }
70
Popular Tags