From 47c105df0188202d0ab47de40da80dacd1670703 Mon Sep 17 00:00:00 2001 From: Robert Burrell Donkin Date: Sun, 25 May 2008 13:55:02 +0000 Subject: [PATCH] Confirmed and fixed MIME4J-36 NullPointerException in Header.writeTo with missing Content-Type https://issues.apache.org/jira/browse/MIME4J-36. git-svn-id: https://svn.eu.apache.org/repos/asf/james/mime4j/trunk@659982 13f79535-47bb-0310-9956-ffa450edef68 --- .../james/mime4j/message/MessageWriteToTest.java | 65 ++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 src/test/java/org/apache/james/mime4j/message/MessageWriteToTest.java diff --git a/src/test/java/org/apache/james/mime4j/message/MessageWriteToTest.java b/src/test/java/org/apache/james/mime4j/message/MessageWriteToTest.java new file mode 100644 index 0000000..420f58e --- /dev/null +++ b/src/test/java/org/apache/james/mime4j/message/MessageWriteToTest.java @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.james.mime4j.message; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; + +import org.apache.james.mime4j.ExampleMail; +import org.apache.james.mime4j.util.MessageUtils; + +import junit.framework.TestCase; + +public class MessageWriteToTest extends TestCase { + + protected void setUp() throws Exception { + super.setUp(); + } + + protected void tearDown() throws Exception { + super.tearDown(); + } + + public void testSimpleMailStrictIgnore() throws Exception { + Message message = createMessage(ExampleMail.RFC822_SIMPLE_BYTES); + assertFalse("Not multipart", message.isMultipart()); + ByteArrayOutputStream out = new ByteArrayOutputStream(); + message.writeTo(out, MessageUtils.STRICT_IGNORE); + } + + public void testSimpleMailStrictError() throws Exception { + Message message = createMessage(ExampleMail.RFC822_SIMPLE_BYTES); + assertFalse("Not multipart", message.isMultipart()); + ByteArrayOutputStream out = new ByteArrayOutputStream(); + message.writeTo(out, MessageUtils.STRICT_ERROR); + } + + public void testSimpleMailLenient() throws Exception { + Message message = createMessage(ExampleMail.RFC822_SIMPLE_BYTES); + assertFalse("Not multipart", message.isMultipart()); + ByteArrayOutputStream out = new ByteArrayOutputStream(); + message.writeTo(out, MessageUtils.LENIENT); + } + + private Message createMessage(byte[] octets) throws Exception { + ByteArrayInputStream in = new ByteArrayInputStream(octets); + Message message = new Message(in); + return message; + } +} -- 2.11.4.GIT