01: /****************************************************************
02: * Licensed to the Apache Software Foundation (ASF) under one *
03: * or more contributor license agreements. See the NOTICE file *
04: * distributed with this work for additional information *
05: * regarding copyright ownership. The ASF licenses this file *
06: * to you under the Apache License, Version 2.0 (the *
07: * "License"); you may not use this file except in compliance *
08: * with the License. You may obtain a copy of the License at *
09: * *
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: ****************************************************************/package org.apache.james.core;
19:
20: import javax.mail.MessagingException;
21: import javax.mail.Session;
22: import javax.mail.internet.MimeMessage;
23:
24: import java.io.ByteArrayInputStream;
25: import java.io.ByteArrayOutputStream;
26: import java.io.IOException;
27: import java.util.Properties;
28:
29: import junit.framework.TestCase;
30:
31: public class MimeMessageUtilTest extends TestCase {
32:
33: public void testWriteMimeMessageMultipartWithMessageID()
34: throws MessagingException, IOException {
35: String message = "Received: from localhost.localdomain ([127.0.0.1])\r\n"
36: + " by athlon14 (JAMES SMTP Server 2.3-dev) with SMTP ID 694\r\n"
37: + " for <test_int1@athlon14.bf.loc>;\r\n"
38: + " Sat, 18 Feb 2006 19:30:53 +0100 (CET)\r\n"
39: + "Subject: ext2int\r\n"
40: + "X-James-Postage: This is a test mail sent by James Postage\r\n"
41: + "Mime-Version: 1.0\r\n"
42: + "Content-Type: multipart/alternative; boundary=\"XyoYyxCQIfmZ5Sxofid6XQVZt5Z09XtTnqBF4Z45XSA=\"\r\n"
43: + "Date: Sat, 18 Feb 2006 19:30:53 +0100 (CET)\r\n"
44: + "From: test_ext2@another.bf.loc\r\n"
45: + "\r\n"
46: + "\r\n"
47: + "--XyoYyxCQIfmZ5Sxofid6XQVZt5Z09XtTnqBF4Z45XSA=\r\n"
48: + "Content-Type: text/plain\r\n"
49: + "\r\n"
50: + "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XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\r\n"
55: + "--XyoYyxCQIfmZ5Sxofid6XQVZt5Z09XtTnqBF4Z45XSA=--\r\n";
56:
57: ;
58:
59: MimeMessage mimeMessage = new MimeMessage(Session
60: .getDefaultInstance(new Properties()),
61: new ByteArrayInputStream(message.getBytes()));
62: mimeMessage.getSize();
63: ByteArrayOutputStream headerOut = new ByteArrayOutputStream();
64: ByteArrayOutputStream bodyOut = new ByteArrayOutputStream();
65: MimeMessageUtil.writeTo(mimeMessage, headerOut, bodyOut);
66: }
67:
68: }
|