http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/test/java/org/apache/james/core/MimeMessageInputStreamSourceTest.java ---------------------------------------------------------------------- diff --git a/server/container/core/src/test/java/org/apache/james/core/MimeMessageInputStreamSourceTest.java b/server/container/core/src/test/java/org/apache/james/core/MimeMessageInputStreamSourceTest.java deleted file mode 100644 index c62f107..0000000 --- a/server/container/core/src/test/java/org/apache/james/core/MimeMessageInputStreamSourceTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************** - * 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.core; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.io.IOException; - -import javax.mail.MessagingException; - -import org.apache.james.util.ZeroedInputStream; -import org.junit.After; -import org.junit.Test; - -public class MimeMessageInputStreamSourceTest { - - private static final int _1M = 1024*1024; - private static final int _10KB = 10*1024; - private MimeMessageInputStreamSource testee; - - @After - public void tearDown() { - testee.dispose(); - } - - @Test - public void streamWith1MBytesShouldBeReadable() throws MessagingException, IOException { - testee = new MimeMessageInputStreamSource("myKey", new ZeroedInputStream(_1M)); - assertThat(testee.getInputStream()).hasSameContentAs(new ZeroedInputStream(_1M)); - } - - @Test - public void streamWith10KBytesShouldBeReadable() throws MessagingException, IOException { - testee = new MimeMessageInputStreamSource("myKey", new ZeroedInputStream(_10KB)); - assertThat(testee.getInputStream()).hasSameContentAs(new ZeroedInputStream(_10KB)); - } - - @Test - public void streamWithVeryShortNameShouldWork() throws MessagingException, IOException { - String veryShortName = "1"; - testee = new MimeMessageInputStreamSource(veryShortName, new ZeroedInputStream(_1M)); - assertThat(testee.getInputStream()).isNotNull(); - } -}
http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/test/java/org/apache/james/core/MimeMessageTest.java ---------------------------------------------------------------------- diff --git a/server/container/core/src/test/java/org/apache/james/core/MimeMessageTest.java b/server/container/core/src/test/java/org/apache/james/core/MimeMessageTest.java deleted file mode 100644 index 7bc2948..0000000 --- a/server/container/core/src/test/java/org/apache/james/core/MimeMessageTest.java +++ /dev/null @@ -1,437 +0,0 @@ -/**************************************************************** - * 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.core; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.util.Arrays; -import java.util.Enumeration; -import java.util.Properties; - -import javax.mail.BodyPart; -import javax.mail.Session; -import javax.mail.internet.InternetHeaders; -import javax.mail.internet.MimeBodyPart; -import javax.mail.internet.MimeMessage; -import javax.mail.internet.MimeMultipart; - -import org.apache.james.lifecycle.api.LifecycleUtil; -import org.apache.mailet.base.RFC2822Headers; -import org.junit.Test; - -/** - * Test the subject folding issue. - */ -public class MimeMessageTest { - - protected MimeMessage getSimpleMessage() throws Exception { - MimeMessage mmCreated = new MimeMessage(Session.getDefaultInstance(new Properties())); - mmCreated.setSubject("test"); - mmCreated.setText("test body"); - mmCreated.saveChanges(); - return mmCreated; - } - - protected String getSimpleMessageCleanedSource() { - return "Subject: test\r\n" - + "MIME-Version: 1.0\r\n" - + "Content-Type: text/plain; charset=us-ascii\r\n" - + "Content-Transfer-Encoding: 7bit\r\n" - + "\r\n" - + "test body"; - } - - protected MimeMessage getMessageWithBadReturnPath() throws Exception { - MimeMessage mmCreated = new MimeMessage(Session.getDefaultInstance(new Properties())); - mmCreated.setSubject("test"); - mmCreated.setHeader(RFC2822Headers.RETURN_PATH, "<mybadret...@example.com>"); - mmCreated.setText("test body"); - mmCreated.saveChanges(); - return mmCreated; - } - - protected String getMessageWithBadReturnPathSource() { - return "Subject: test\r\n" - + "Return-Path: <mybadret...@example.com>\r\n" - + "MIME-Version: 1.0\r\n" - + "Content-Type: text/plain; charset=us-ascii\r\n" - + "Content-Transfer-Encoding: 7bit\r\n" - + "\r\n" - + "test body"; - } - - protected String getSimpleMessageCleanedSourceHeaderExpected() { - return "X-Test: foo\r\n" + getSimpleMessageCleanedSource(); - } - - /* - * Class under test for String getSubject() - */ - @Test - public void testSimpleMessage() throws Exception { - MimeMessage m = getSimpleMessage(); - assertEquals(getSimpleMessageCleanedSource(), getCleanedMessageSource(m)); - LifecycleUtil.dispose(m); - } - - protected MimeMessage getMultipartMessage() throws Exception { - MimeMessage mmCreated = new MimeMessage(Session.getDefaultInstance(new Properties())); - mmCreated.setSubject("test"); - MimeMultipart mm = new MimeMultipart("alternative"); - mm.addBodyPart(new MimeBodyPart(new InternetHeaders(new ByteArrayInputStream("X-header: test1\r\nContent-Type: text/plain; charset=Cp1252\r\n". - getBytes())), "first part \u00F2\u00E0\u00F9".getBytes())); - mm.addBodyPart(new MimeBodyPart(new InternetHeaders(new ByteArrayInputStream("X-header: test2\r\nContent-Type: text/plain; charset=Cp1252\r\nContent-Transfer-Encoding: quoted-printable\r\n". - getBytes())), "second part =E8=E8".getBytes())); - mmCreated.setContent(mm); - mmCreated.saveChanges(); - return mmCreated; - } - - protected String getMultipartMessageSource() { - return "Subject: test\r\n" - + "MIME-Version: 1.0\r\n" - + "Content-Type: multipart/alternative; \r\n" - + "\tboundary=\"----=_Part_0_XXXXXXXXXXX.XXXXXXXXXXX\"\r\n" - + "\r\n" - + "------=_Part_0_XXXXXXXXXXX.XXXXXXXXXXX\r\n" - + "X-header: test1\r\n" - + "Content-Type: text/plain; charset=Cp1252\r\n" - + "Content-Transfer-Encoding: quoted-printable\r\n" - + "\r\n" - + "first part =E8\r\n" - + "------=_Part_0_XXXXXXXXXXX.XXXXXXXXXXX\r\n" - + "X-header: test2\r\n" - + "Content-Type: text/plain; charset=Cp1252\r\n" - + "Content-Transfer-Encoding: quoted-printable\r\n" - + "\r\n" - + "second part =E8=E8\r\n" - + "------=_Part_0_XXXXXXXXXXX.XXXXXXXXXXX--\r\n"; - } - - protected String getMultipartMessageExpected1() { - return "Subject: test\r\n" - + "MIME-Version: 1.0\r\n" - + "Content-Type: multipart/alternative; \r\n" - + "\tboundary=\"----=_Part_0_XXXXXXXXXXX.XXXXXXXXXXX\"\r\n" - + "\r\n" - + "------=_Part_0_XXXXXXXXXXX.XXXXXXXXXXX\r\n" - + "X-header: test1\r\n" - + "Content-Type: text/plain; charset=Cp1252\r\n" - + "Content-Transfer-Encoding: quoted-printable\r\n" - + "\r\n" - + "test=80\r\n" - + "------=_Part_0_XXXXXXXXXXX.XXXXXXXXXXX\r\n" - + "X-header: test2\r\n" - + "Content-Type: text/plain; charset=Cp1252\r\n" - + "Content-Transfer-Encoding: quoted-printable\r\n" - + "\r\n" - + "second part =E8=E8\r\n" - + "------=_Part_0_XXXXXXXXXXX.XXXXXXXXXXX--\r\n"; - } - - protected String getMultipartMessageExpected2() { - return "Subject: test\r\n" - + "MIME-Version: 1.0\r\n" - + "Content-Type: multipart/alternative; \r\n" - + "\tboundary=\"----=_Part_0_XXXXXXXXXXX.XXXXXXXXXXX\"\r\n" - + "\r\n" - + "------=_Part_0_XXXXXXXXXXX.XXXXXXXXXXX\r\n" - + "X-header: test1\r\n" - + "Content-Type: text/plain; charset=Cp1252\r\n" - + "Content-Transfer-Encoding: quoted-printable\r\n" - + "\r\n" - + "test=80\r\n" - + "------=_Part_0_XXXXXXXXXXX.XXXXXXXXXXX\r\n" - + "X-header: test2\r\n" - + "Content-Type: text/plain; charset=Cp1252\r\n" - + "Content-Transfer-Encoding: quoted-printable\r\n" - + "\r\n" - + "second part =E8=E8\r\n" - + "------=_Part_0_XXXXXXXXXXX.XXXXXXXXXXX\r\n" - + "Subject: test3\r\n" - + "\r\n" - + "third part\r\n" - + "------=_Part_0_XXXXXXXXXXX.XXXXXXXXXXX--\r\n"; - } - - protected String getMultipartMessageExpected3() { - return "Subject: test\r\n" - + "MIME-Version: 1.0\r\n" - + "Content-Type: binary/octet-stream\r\n" - + "Content-Transfer-Encoding: quoted-printable\r\n" - + "\r\n" - + "mynewco=F2=E0=F9ntent=80=E0!"; - } - - /* - * Class under test for String getSubject() - */ - @Test - public void testMultipartMessageChanges() throws Exception { - - MimeMessage mm = getMultipartMessage(); - - // ByteArrayOutputStream out = new ByteArrayOutputStream(); - // mmCreated.writeTo(out,new String[] {"Message-ID"}); - // String messageSource = out.toString(); - // System.out.println(messageSource); - - MimeMultipart content1 = (MimeMultipart) mm.getContent(); - BodyPart b1 = content1.getBodyPart(0); - b1.setContent("test\u20AC", "text/plain; charset=Cp1252"); - mm.setContent(content1, mm.getContentType()); - // .setHeader(RFC2822Headers.CONTENT_TYPE,contentType); - mm.saveChanges(); - - assertEquals(getMultipartMessageExpected1(), getCleanedMessageSource(mm)); - - MimeMultipart content2 = (MimeMultipart) mm.getContent(); - content2.addBodyPart(new MimeBodyPart(new InternetHeaders(new ByteArrayInputStream( - "Subject: test3\r\n".getBytes())), "third part".getBytes())); - mm.setContent(content2, mm.getContentType()); - mm.saveChanges(); - - assertEquals(getMultipartMessageExpected2(), getCleanedMessageSource(mm)); - - mm.setContent("mynewco\u00F2\u00E0\u00F9ntent\u20AC\u00E0!", "text/plain; charset=cp1252"); - mm.setHeader(RFC2822Headers.CONTENT_TYPE, "binary/octet-stream"); - // mm.setHeader("Content-Transfer-Encoding","8bit"); - mm.saveChanges(); - - assertEquals(getMultipartMessageExpected3(), getCleanedMessageSource(mm)); - - LifecycleUtil.dispose(mm); - - } - - protected MimeMessage getMissingEncodingAddHeaderMessage() throws Exception { - MimeMessage m = new MimeMessage(Session.getDefaultInstance(new Properties())); - m.setText("Test\u00E0\r\n"); - m.setSubject("test"); - m.saveChanges(); - return m; - } - - protected String getMissingEncodingAddHeaderSource() { - return "Subject: test\r\n" - + "\r\n" - + "Test\u00E0\r\n"; - } - - protected String getMissingEncodingAddHeaderExpected() { - return "Subject: test\r\n" - + "MIME-Version: 1.0\r\n" - + "Content-Type: text/plain; charset=Cp1252\r\n" - + "Content-Transfer-Encoding: quoted-printable\r\n" - + "\r\n" - + "Test=E0\r\n"; - } - - /** - * This test is not usable in different locale environment. - */ - /* - * public void testMissingEncodingAddHeader() throws Exception { - * - * - * MimeMessage mm = getMissingEncodingAddHeaderMessage(); - * mm.setHeader("Content-Transfer-Encoding", "quoted-printable"); - * mm.saveChanges(); - * - * assertEquals(getMissingEncodingAddHeaderExpected(),getCleanedMessageSource - * (mm)); } - */ - protected String getCleanedMessageSource(MimeMessage mm) throws Exception { - ByteArrayOutputStream out2; - out2 = new ByteArrayOutputStream(); - mm.writeTo(out2, new String[]{"Message-ID"}); - - String res = out2.toString(); - - int p = res.indexOf("\r\n\r\n"); - if (p > 0) { - String head = res.substring(0, p); - String[] str = head.split("\r\n"); - Arrays.sort(str); - StringBuilder outputHead = new StringBuilder(); - for (int i = str.length - 1; i >= 0; i--) { - outputHead.append(str[i]); - outputHead.append("\r\n"); - } - outputHead.append(res.substring(p + 2)); - res = outputHead.toString(); - } - - res = res.replaceAll("----=_Part_\\d*_\\d+\\.\\d+", "----=_Part_\\0_XXXXXXXXXXX.XXXXXXXXXXX"); - return res; - } - - protected void debugMessage(MimeMessage mm) throws Exception { - System.out.println("-------------------"); - System.out.println(getCleanedMessageSource(mm)); - System.out.println("-------------------"); - } - - protected MimeMessage getMissingEncodingMessage() throws Exception { - MimeMessage mmCreated = new MimeMessage(Session.getDefaultInstance(new Properties())); - mmCreated.setSubject("test"); - MimeMultipart mm = new MimeMultipart("alternative"); - mm.addBodyPart(new MimeBodyPart(new InternetHeaders(new ByteArrayInputStream("X-header: test2\r\nContent-Type: text/plain; charset=Cp1252\r\nContent-Transfer-Encoding: quoted-printable\r\n". - getBytes())), "second part =E8=E8".getBytes())); - mmCreated.setContent(mm); - mmCreated.saveChanges(); - return mmCreated; - } - - protected String getMissingEncodingMessageSource() { - return "Subject: test\r\n" - + "MIME-Version: 1.0\r\n" - + "Content-Type: multipart/alternative; \r\n" - + "\tboundary=\"----=_Part_0_XXXXXXXXXXX.XXXXXXXXXXX\"\r\n" - + "\r\n" - + "------=_Part_0_XXXXXXXXXXX.XXXXXXXXXXX\r\n" - + "X-header: test2\r\n" - + "Content-Type: text/plain; charset=Cp1252\r\n" - + "Content-Transfer-Encoding: quoted-printable\r\n" - + "\r\n" - + "second part =E8=E8\r\n" - + "------=_Part_0_XXXXXXXXXXX.XXXXXXXXXXX--\r\n"; - } - - @Test - public void testGetLineCount() throws Exception { - MimeMessage mm = getMissingEncodingMessage(); - try { - int count = mm.getLineCount(); - assertTrue(count == -1 || count == 7); - } catch (Exception e) { - fail("Unexpected exception in getLineCount"); - } - LifecycleUtil.dispose(mm); - } - - /** - * This test throw a NullPointerException when the original message was - * created by a MimeMessageInputStreamSource. - */ - @Test - public void testMessageCloningViaCoW() throws Exception { - MimeMessage mmorig = getSimpleMessage(); - - MimeMessage mm = new MimeMessageCopyOnWriteProxy(mmorig); - - MimeMessage mm2 = new MimeMessageCopyOnWriteProxy(mm); - - mm2.setHeader("Subject", "Modified"); - - LifecycleUtil.dispose(mm2); - System.gc(); - Thread.sleep(200); - // ((Disposable)mail_dup.getMessage()).dispose(); - - mm.setHeader("Subject", "Modified"); - - LifecycleUtil.dispose(mm); - LifecycleUtil.dispose(mmorig); - } - - /** - * This test throw a NullPointerException when the original message was - * created by a MimeMessageInputStreamSource. - */ - @Test - public void testMessageCloningViaCoW2() throws Exception { - MimeMessage mmorig = getSimpleMessage(); - - MimeMessage mm = new MimeMessageCopyOnWriteProxy(mmorig); - - MimeMessage mm2 = new MimeMessageCopyOnWriteProxy(mm); - - LifecycleUtil.dispose(mm); - mm = null; - System.gc(); - Thread.sleep(200); - - try { - mm2.writeTo(System.out); - } catch (Exception e) { - e.printStackTrace(); - fail("Exception while writing the message to output"); - } - - LifecycleUtil.dispose(mm2); - LifecycleUtil.dispose(mmorig); - } - - /** - * This test throw a NullPointerException when the original message was - * created by a MimeMessageInputStreamSource. - */ - @Test - public void testMessageCloningViaCoWSubjectLost() throws Exception { - MimeMessage mmorig = getSimpleMessage(); - - MimeMessage mm = new MimeMessageCopyOnWriteProxy(mmorig); - - mm.setHeader("X-Test", "foo"); - mm.saveChanges(); - - assertEquals(getSimpleMessageCleanedSourceHeaderExpected(), getCleanedMessageSource(mm)); - - LifecycleUtil.dispose(mm); - LifecycleUtil.dispose(mmorig); - } - - @Test - public void testReturnPath() throws Exception { - MimeMessage message = getSimpleMessage(); - assertNull(message.getHeader(RFC2822Headers.RETURN_PATH)); - LifecycleUtil.dispose(message); - } - - @Test - public void testHeaderOrder() throws Exception { - MimeMessage message = getSimpleMessage(); - message.setHeader(RFC2822Headers.RETURN_PATH, "<t...@test.de>"); - @SuppressWarnings("unchecked") - Enumeration<String> h = message.getAllHeaderLines(); - - assertEquals(h.nextElement(), "Return-Path: <t...@test.de>"); - LifecycleUtil.dispose(message); - } - - /** - * http://issues.apache.org/jira/browse/GERONIMO-4261 - * - * This bug was in geronimo-javamail_1.4-1.5 Has been fixed in - * geronimo-javamail_1.4-1.6 - */ - @Test - public void testGeronimoIndexOutOfBounds() throws Exception { - String message = " \r\n" + "Subject: test\r\n" + "\r\n" + "Body\r\n"; - - byte[] messageBytes = message.getBytes("US-ASCII"); - new MimeMessage(null, new ByteArrayInputStream(messageBytes)); - } -} http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/test/java/org/apache/james/core/MimeMessageUtilTest.java ---------------------------------------------------------------------- diff --git a/server/container/core/src/test/java/org/apache/james/core/MimeMessageUtilTest.java b/server/container/core/src/test/java/org/apache/james/core/MimeMessageUtilTest.java deleted file mode 100644 index af14dd6..0000000 --- a/server/container/core/src/test/java/org/apache/james/core/MimeMessageUtilTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************** - * 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.core; - -import javax.mail.MessagingException; -import javax.mail.Session; -import javax.mail.internet.MimeMessage; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.util.Properties; -import org.junit.Test; - -public class MimeMessageUtilTest { - - @Test - public void testWriteMimeMessageMultipartWithMessageID() throws MessagingException, IOException { - String message = "Received: from localhost.localdomain ([127.0.0.1])\r\n" + - " by athlon14 (JAMES SMTP Server 2.3-dev) with SMTP ID 694\r\n" + - " for <test_i...@athlon14.bf.loc>;\r\n" + - " Sat, 18 Feb 2006 19:30:53 +0100 (CET)\r\n" + - "Subject: ext2int\r\n" + - "X-James-Postage: This is a test mail sent by James Postage\r\n" + - "Mime-Version: 1.0\r\n" + - "Content-Type: multipart/alternative; boundary=\"XyoYyxCQIfmZ5Sxofid6XQVZt5Z09XtTnqBF4Z45XSA=\"\r\n" + - "Date: Sat, 18 Feb 2006 19:30:53 +0100 (CET)\r\n" + - "From: test_e...@another.bf.loc\r\n" + - "\r\n" + - "\r\n" + - "--XyoYyxCQIfmZ5Sxofid6XQVZt5Z09XtTnqBF4Z45XSA=\r\n" + - "Content-Type: text/plain\r\n" + - "\r\n" + - "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\r\n" + - "--XyoYyxCQIfmZ5Sxofid6XQVZt5Z09XtTnqBF4Z45XSA=\r\n" + - "Content-Type: application/octet-stream\r\n" + - "\r\n" + - "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\r\n" + - "--XyoYyxCQIfmZ5Sxofid6XQVZt5Z09XtTnqBF4Z45XSA=--\r\n"; - - MimeMessage mimeMessage = new MimeMessage(Session.getDefaultInstance(new Properties()), new ByteArrayInputStream(message.getBytes())); - mimeMessage.getSize(); - ByteArrayOutputStream headerOut = new ByteArrayOutputStream(); - ByteArrayOutputStream bodyOut = new ByteArrayOutputStream(); - MimeMessageUtil.writeTo(mimeMessage, headerOut, bodyOut); - } - -} http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/test/java/org/apache/james/core/MimeMessageWrapperTest.java ---------------------------------------------------------------------- diff --git a/server/container/core/src/test/java/org/apache/james/core/MimeMessageWrapperTest.java b/server/container/core/src/test/java/org/apache/james/core/MimeMessageWrapperTest.java deleted file mode 100644 index 2f06915..0000000 --- a/server/container/core/src/test/java/org/apache/james/core/MimeMessageWrapperTest.java +++ /dev/null @@ -1,289 +0,0 @@ -/**************************************************************** - * 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.core; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import java.io.BufferedReader; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.util.Enumeration; -import java.util.Properties; - -import javax.mail.MessagingException; -import javax.mail.Session; -import javax.mail.internet.MimeMessage; -import javax.mail.util.SharedByteArrayInputStream; - -import org.apache.james.lifecycle.api.LifecycleUtil; -import org.apache.mailet.base.RFC2822Headers; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -/** - * Test the subject folding issue. - */ -public class MimeMessageWrapperTest extends MimeMessageFromStreamTest { - - private final class TestableMimeMessageWrapper extends MimeMessageWrapper { - - boolean messageLoadable = true; - boolean headersLoadable = true; - - private TestableMimeMessageWrapper(MimeMessageSource source) throws MessagingException { - super(source); - } - - public boolean messageParsed() { - return messageParsed; - } - - public void setHeadersLoadable(boolean headersLoadable) { - this.headersLoadable = headersLoadable; - } - - @Override - protected synchronized void loadHeaders() throws MessagingException { - if (headersLoadable) { - super.loadHeaders(); - } else { - throw new IllegalStateException("headersLoadable disabled"); - } - } - - @Override - public synchronized void loadMessage() throws MessagingException { - if (messageLoadable) { - super.loadMessage(); - } else { - throw new IllegalStateException("messageLoadable disabled"); - } - } - } - TestableMimeMessageWrapper mw = null; - final String content = "Subject: foo\r\nContent-Transfer-Encoding2: plain"; - final String sep = "\r\n\r\n"; - final String body = "bar\r\n"; - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - @Override - protected MimeMessage getMessageFromSources(String sources) throws Exception { - MimeMessageInputStreamSource mmis = new MimeMessageInputStreamSource("test", new SharedByteArrayInputStream(sources.getBytes())); - return new TestableMimeMessageWrapper(mmis); - } - - @Before - public void setUp() throws Exception { - mw = (TestableMimeMessageWrapper) getMessageFromSources(content + sep + body); - } - - @After - public void tearDown() throws Exception { - LifecycleUtil.dispose(mw); - } - - @Test - public void testDeferredMessageLoading() throws MessagingException, IOException { - assertEquals("foo", mw.getSubject()); - assertFalse(mw.messageParsed()); - assertEquals("bar\r\n", mw.getContent()); - assertTrue(mw.messageParsed()); - assertFalse(mw.isModified()); - } - - /** - * this is commented out due optimisation reverts (JAMES-559) public void - * testDeferredMessageLoadingWhileWriting() throws MessagingException, - * IOException { mw.setMessageLoadable(false); - * assertEquals("foo",mw.getSubject()); assertFalse(mw.isModified()); - * mw.setSubject("newSubject"); assertEquals("newSubject",mw.getSubject()); - * assertFalse(mw.messageParsed()); assertTrue(mw.isModified()); - * mw.setMessageLoadable(true); - * - * } - */ - @Test - public void testDeferredHeaderLoading() throws MessagingException, IOException { - mw.setHeadersLoadable(false); - - expectedException.expect(IllegalStateException.class); - - mw.getSubject(); - } - - /** - * See JAMES-474 MimeMessageWrapper(MimeMessage) should clone the original - * message. - */ - @Test - public void testMessageCloned() throws MessagingException, IOException, InterruptedException { - MimeMessageWrapper mmw = new MimeMessageWrapper(mw); - LifecycleUtil.dispose(mw); - mw = null; - System.gc(); - Thread.sleep(200); - mmw.writeTo(System.out); - } - - @Test - public void testGetSubjectFolding() throws Exception { - StringBuilder res = new StringBuilder(); - BufferedReader r = new BufferedReader(new InputStreamReader(mw.getInputStream())); - String line; - while (r.ready()) { - line = r.readLine(); - res.append(line).append("\r\n"); - } - r.close(); - assertEquals(body, res.toString()); - } - - @Test - public void testAddHeaderAndSave() throws Exception { - mw.addHeader("X-Test", "X-Value"); - - assertEquals("X-Value", mw.getHeader("X-Test")[0]); - - mw.saveChanges(); - - ByteArrayOutputStream rawMessage = new ByteArrayOutputStream(); - mw.writeTo(rawMessage); - - assertEquals("X-Value", mw.getHeader("X-Test")[0]); - - String res = rawMessage.toString(); - - boolean found = res.indexOf("X-Test: X-Value") > 0; - assertEquals(true, found); - } - - @Test - public void testReplaceReturnPathOnBadMessage() throws Exception { - MimeMessage message = getMessageWithBadReturnPath(); - message.setHeader(RFC2822Headers.RETURN_PATH, "<t...@test.de>"); - @SuppressWarnings("unchecked") - Enumeration<String> e = message.getMatchingHeaderLines(new String[]{"Return-Path"}); - assertEquals("Return-Path: <t...@test.de>", e.nextElement()); - assertFalse(e.hasMoreElements()); - @SuppressWarnings("unchecked") - Enumeration<String> h = message.getAllHeaderLines(); - assertEquals("Return-Path: <t...@test.de>", h.nextElement()); - assertFalse(h.nextElement().toString().startsWith("Return-Path:")); - LifecycleUtil.dispose(message); - } - - @Test - public void testAddReturnPathOnBadMessage() throws Exception { - MimeMessage message = getMessageWithBadReturnPath(); - message.addHeader(RFC2822Headers.RETURN_PATH, "<t...@test.de>"); - // test that we have now 2 return-paths - @SuppressWarnings("unchecked") - Enumeration<String> e = message.getMatchingHeaderLines(new String[]{"Return-Path"}); - assertEquals("Return-Path: <t...@test.de>", e.nextElement()); - assertEquals("Return-Path: <mybadret...@example.com>", e.nextElement()); - // test that return-path is the first line - @SuppressWarnings("unchecked") - Enumeration<String> h = message.getAllHeaderLines(); - assertEquals("Return-Path: <t...@test.de>", h.nextElement()); - LifecycleUtil.dispose(message); - } - - /** - * Test for JAMES-1154 - */ - @Test - public void testMessageStreamWithUpatedHeaders() throws MessagingException, IOException { - mw.addHeader("X-Test", "X-Value"); - - assertEquals("X-Value", mw.getHeader("X-Test")[0]); - - mw.saveChanges(); - - BufferedReader reader = new BufferedReader(new InputStreamReader(mw.getMessageInputStream())); - - boolean headerUpdated = reader.lines() - .anyMatch(line -> line.equals("X-Test: X-Value")); - reader.close(); - assertTrue(headerUpdated); - } - - /** - * Test for JAMES-1154 - */ - @Test - public void testMessageStreamWithUpatedContent() throws MessagingException, IOException { - String newContent = "This is the new message content!"; - mw.setText(newContent); - assertEquals(newContent, mw.getContent()); - - mw.saveChanges(); - - BufferedReader reader = new BufferedReader(new InputStreamReader(mw.getMessageInputStream())); - - boolean contentUpdated = reader.lines() - .anyMatch(line -> line.equals(newContent)); - reader.close(); - assertTrue(contentUpdated); - } - - @Test - public void testSize() throws MessagingException { - assertEquals(body.length(), mw.getSize()); - } - - @Test - public void testSizeModifiedHeaders() throws MessagingException { - mw.addHeader("whatever", "test"); - assertEquals(body.length(), mw.getSize()); - } - - @Test - public void testSizeModifiedBodyWithoutSave() throws MessagingException { - String newBody = "This is the new body of the message"; - mw.setText(newBody); - assertEquals(body.length(), mw.getSize()); - } - - @Test - public void testSizeModifiedBodyWithSave() throws MessagingException { - String newBody = "This is the new body of the message"; - mw.setText(newBody); - mw.saveChanges(); - assertEquals(body.length(), mw.getSize()); - } - - @Test - public void jiraJames1593() throws MessagingException, IOException { - Properties noProperties = new Properties(); - Session session = Session.getDefaultInstance(noProperties); - InputStream stream = ClassLoader.getSystemResourceAsStream("JAMES-1593.eml"); - MimeMessage message = new MimeMessage(session, stream); - MimeMessageWrapper wrapper = new MimeMessageWrapper(message); - assertEquals("\"base64\"", wrapper.getEncoding()); - } -} http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/test/java/org/apache/james/core/filesystem/FileSystemImplTest.java ---------------------------------------------------------------------- diff --git a/server/container/core/src/test/java/org/apache/james/core/filesystem/FileSystemImplTest.java b/server/container/core/src/test/java/org/apache/james/core/filesystem/FileSystemImplTest.java deleted file mode 100644 index 28c9de4..0000000 --- a/server/container/core/src/test/java/org/apache/james/core/filesystem/FileSystemImplTest.java +++ /dev/null @@ -1,32 +0,0 @@ -/**************************************************************** - * 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.core.filesystem; - -import org.apache.james.core.JamesServerResourceLoader; -import org.apache.james.filesystem.api.AbstractFileSystemTest; -import org.apache.james.filesystem.api.FileSystem; - -public class FileSystemImplTest extends AbstractFileSystemTest { - - @Override - protected FileSystem buildFileSystem(String configurationRootDirectory) { - return new FileSystemImpl(new JamesServerResourceLoader(configurationRootDirectory)); - } - -} http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/test/java/org/apache/james/core/filesystem/SimpleUrlTest.java ---------------------------------------------------------------------- diff --git a/server/container/core/src/test/java/org/apache/james/core/filesystem/SimpleUrlTest.java b/server/container/core/src/test/java/org/apache/james/core/filesystem/SimpleUrlTest.java deleted file mode 100644 index 239592e..0000000 --- a/server/container/core/src/test/java/org/apache/james/core/filesystem/SimpleUrlTest.java +++ /dev/null @@ -1,114 +0,0 @@ -/**************************************************************** - * 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.core.filesystem; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.junit.Test; - -public class SimpleUrlTest { - - @Test(expected=NullPointerException.class) - public void simplifyPathShouldThrowOnNull() { - SimpleUrl.simplifyPath(null); - } - - @Test - public void simplifyPathShouldReturnEmptyOnEmptyArray() { - String actual = SimpleUrl.simplifyPath(""); - assertThat(actual).isEmpty(); - } - - @Test - public void simplifyPathShoudReturnEmptyWhenSimplifyingCurrentDir() { - String actual = SimpleUrl.simplifyPath("./bar/.././foo/.."); - assertThat(actual).isEmpty(); - } - - @Test - public void simplifyPathShoudReturnSimplifiedDirectory() { - String actual = SimpleUrl.simplifyPath("../foo/../bar/./baz"); - assertThat(actual).isEqualTo("../bar/baz"); - } - - @Test - public void simplifiedShouldReturnEmptyWhenEmptyInput() { - assertThat(new SimpleUrl("").getSimplified()).isEmpty(); - } - - @Test(expected=NullPointerException.class) - public void simplifiedShouldThrowWhenNullInput() { - new SimpleUrl(null); - } - - @Test - public void simplifiedShouldReturnInputValueWhenProtocolOnlyInput() { - assertThat(new SimpleUrl("file:").getSimplified()).isEqualTo("file:"); - } - - @Test - public void simplifiedShouldReturnInputValueWhenRelativePath() { - assertThat(new SimpleUrl("abcd/ef/gh").getSimplified()).isEqualTo("abcd/ef/gh"); - } - - @Test - public void simplifiedShouldReturnInputValueWhenAbsolutePath() { - assertThat(new SimpleUrl("/abcd/ef/gh").getSimplified()).isEqualTo("/abcd/ef/gh"); - } - - @Test - public void simplifiedShouldReturnInputValueWhenHttpUrl() { - assertThat(new SimpleUrl("http://example.com/ef/gh").getSimplified()).isEqualTo("http://example.com/ef/gh"); - } - - @Test - public void simplifiedShouldReturnInputValueWhenPathContainsColumn() { - assertThat(new SimpleUrl("ab/cd:ef/gh").getSimplified()).isEqualTo("ab/cd:ef/gh"); - } - - @Test - public void simplifiedShouldCollapseComplexePathWhenContainingParentDirElement() { - assertThat(new SimpleUrl("file:///home/user/./foo/../.bar/baz").getSimplified()).isEqualTo("file:///home/user/.bar/baz"); - } - - @Test - public void simplifiedShouldCollapseComplexePathWhenContainingParentDirElementInRelativePath() { - assertThat(new SimpleUrl("file://../.././foo/../.bar/baz").getSimplified()).isEqualTo("file://../../.bar/baz"); - } - - @Test - public void simplifiedShouldCollapseComplexePathWhenContainingParentDirElementWithoutDoubleSlashes() { - assertThat(new SimpleUrl("file:/home/user/./foo/../.bar/baz").getSimplified()).isEqualTo("file:/home/user/.bar/baz"); - } - - @Test - public void simplifiedShouldCollapseComplexePathWhenContainingParentDirElementInRelativePathWithoutDoubleSlashes() { - assertThat(new SimpleUrl("file:../.././foo/../.bar/baz").getSimplified()).isEqualTo("file:../../.bar/baz"); - } - - @Test - public void simplifiedShouldReplaceASingleWindowSeperatorByASlash() { - assertThat(new SimpleUrl("\\").getSimplified()).isEqualTo("/"); - } - - @Test - public void simplifiedShouldReplaceAllWindowsSeperatorBySlashes() { - assertThat(new SimpleUrl("file:c:\\\\programs\\run.exe").getSimplified()).isEqualTo("file:c://programs/run.exe"); - } -} http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/test/java/org/apache/james/server/core/MailHeadersTest.java ---------------------------------------------------------------------- diff --git a/server/container/core/src/test/java/org/apache/james/server/core/MailHeadersTest.java b/server/container/core/src/test/java/org/apache/james/server/core/MailHeadersTest.java new file mode 100644 index 0000000..cf75a12 --- /dev/null +++ b/server/container/core/src/test/java/org/apache/james/server/core/MailHeadersTest.java @@ -0,0 +1,43 @@ +/**************************************************************** + * 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.server.core; + +import java.io.ByteArrayInputStream; +import java.util.Enumeration; +import javax.mail.MessagingException; +import org.apache.mailet.base.RFC2822Headers; +import static org.junit.Assert.assertEquals; +import org.junit.Test; + +public class MailHeadersTest { + + @Test + public void testHeadersOrder() throws MessagingException { + MailHeaders header = new MailHeaders(new ByteArrayInputStream((RFC2822Headers.SUBJECT + ": testsubject\r\n"). + getBytes())); + header.setHeader(RFC2822Headers.RETURN_PATH, "<test@test>"); + header.setHeader(RFC2822Headers.FROM, "<te...@test.de>"); + @SuppressWarnings("unchecked") + Enumeration<String> h = header.getAllHeaderLines(); + + assertEquals(h.nextElement(), "Return-Path: <test@test>"); + assertEquals(h.nextElement(), "From: <te...@test.de>"); + assertEquals(h.nextElement(), "Subject: testsubject"); + } +} http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/test/java/org/apache/james/server/core/MailImplTest.java ---------------------------------------------------------------------- diff --git a/server/container/core/src/test/java/org/apache/james/server/core/MailImplTest.java b/server/container/core/src/test/java/org/apache/james/server/core/MailImplTest.java new file mode 100644 index 0000000..ab5d9b7 --- /dev/null +++ b/server/container/core/src/test/java/org/apache/james/server/core/MailImplTest.java @@ -0,0 +1,115 @@ +/**************************************************************** + * 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.server.core; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNotSame; +import static org.junit.Assert.assertNull; + +import java.io.ByteArrayInputStream; +import java.util.ArrayList; + +import javax.mail.MessagingException; +import javax.mail.Session; +import javax.mail.internet.MimeMessage; + +import org.apache.james.core.MailAddress; +import org.apache.mailet.Mail; +import org.apache.mailet.base.test.MailUtil; +import org.junit.Test; + +public class MailImplTest extends MailTestAllImplementations { + + private static final Session NO_SESSION = null; + + @Override + protected Mail createMailImplementation() { + return new MailImpl(); + } + + @Test + public void testConstr1() throws MessagingException { + MailImpl mail = new MailImpl(); + + helperTestInitialState(mail); + helperTestMessageSize(mail, 0); // MimeMessageWrapper default is 0 + assertNull("no initial message", mail.getMessage()); + assertNull("no initial sender", mail.getSender()); + assertNull("no initial name", mail.getName()); + } + + @Test + public void testConstr2() throws MessagingException { + ArrayList<MailAddress> recepients = new ArrayList<>(); + String name = MailUtil.newId(); + String sender = "sender@localhost"; + MailAddress senderMailAddress = new MailAddress(sender); + MailImpl mail = new MailImpl(name, senderMailAddress, recepients); + + helperTestInitialState(mail); // MimeMessageWrapper default is 0 + helperTestMessageSize(mail, 0); // MimeMessageWrapper default is 0 + assertNull("no initial message", mail.getMessage()); + assertEquals("sender", sender, mail.getSender().toString()); + assertEquals("name", name, mail.getName()); + + mail.setMessage(new MimeMessage(NO_SESSION)); + assertNotNull("message", mail.getMessage()); + } + + @Test + public void testConstr3() throws MessagingException { + ArrayList<MailAddress> recepients = new ArrayList<>(); + String name = MailUtil.newId(); + String sender = "sender@localhost"; + MailAddress senderMailAddress = new MailAddress(sender); + MimeMessage mimeMessage = new MimeMessage(NO_SESSION, new ByteArrayInputStream(new byte[0])); + MailImpl mail = new MailImpl(name, senderMailAddress, recepients, mimeMessage); + + helperTestInitialState(mail); + helperTestMessageSize(mail, 0); + assertEquals("initial message", mimeMessage.getMessageID(), mail.getMessage().getMessageID()); + assertEquals("sender", sender, mail.getSender().toString()); + assertEquals("name", name, mail.getName()); + mail.dispose(); + } + + @Test + public void testDuplicate() throws MessagingException { + MailImpl mail = new MailImpl(); + MailImpl duplicate = (MailImpl) mail.duplicate(); + assertNotSame("is real duplicate", mail, duplicate); + helperTestInitialState(duplicate); + helperTestMessageSize(duplicate, 0); + } + + @Test + public void testDuplicateNewName() throws MessagingException { + String newName = "aNewName"; + + MailImpl mail = new MailImpl(); + assertFalse("before + after names differ", newName.equals(mail.getName())); + + MailImpl duplicate = (MailImpl) mail.duplicate(newName); + assertEquals("new name set", newName, duplicate.getName()); + helperTestInitialState(duplicate); + helperTestMessageSize(duplicate, 0); + } +} http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/test/java/org/apache/james/server/core/MailTestAllImplementations.java ---------------------------------------------------------------------- diff --git a/server/container/core/src/test/java/org/apache/james/server/core/MailTestAllImplementations.java b/server/container/core/src/test/java/org/apache/james/server/core/MailTestAllImplementations.java new file mode 100644 index 0000000..1a133b2 --- /dev/null +++ b/server/container/core/src/test/java/org/apache/james/server/core/MailTestAllImplementations.java @@ -0,0 +1,72 @@ +/**************************************************************** + * 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.server.core; + +import javax.mail.MessagingException; + +import org.apache.mailet.Mail; +import org.junit.Test; +import static org.junit.Assert.*; + +/** + * testing common behavior of Mail implementors. subclasses automatically get + * their Mail-behavior tested. + */ +public abstract class MailTestAllImplementations { + + /** provide the concrete implementation to test */ + protected abstract Mail createMailImplementation(); + + protected void helperTestInitialState(Mail mail) { + assertFalse("no initial attributes", mail.hasAttributes()); + assertNull("no initial error", mail.getErrorMessage()); + assertNotNull("initial last update set", mail.getLastUpdated()); + try { + assertTrue("no initial recipient", mail.getRecipients().isEmpty()); + } catch (NullPointerException e) { + // current behavior. *BUT*, shouldn't this method better return with + // an empty list?! + } + assertEquals("initial remote address is localhost ip", "127.0.0.1", mail.getRemoteAddr()); + assertEquals("initial remote host is localhost", "localhost", mail.getRemoteHost()); + assertEquals("default initial state", Mail.DEFAULT, mail.getState()); + } + + protected void helperTestMessageSize(Mail mail, int expectedMsgSize) throws MessagingException { + try { + assertEquals("initial message size == " + expectedMsgSize, expectedMsgSize, mail.getMessageSize()); + } catch (NullPointerException e) { + // current behavior. *BUT*, shouldn't this method return more + // gracefully?! + } + } + + @Test + public void testAttributes() { + Mail mail = createMailImplementation(); + assertFalse("no initial attributes", mail.hasAttributes()); + assertFalse("attributes initially empty", mail.getAttributeNames().hasNext()); + assertNull("not found on emtpy list", mail.getAttribute("test")); + assertNull("no previous item with key", mail.setAttribute("testKey", "testValue")); + assertEquals("item found", "testValue", mail.getAttribute("testKey")); + assertTrue("has attribute", mail.hasAttributes()); + assertEquals("item removed", "testValue", mail.removeAttribute("testKey")); + assertNull("item no longer found", mail.getAttribute("testKey")); + } +} http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageCopyOnWriteProxyTest.java ---------------------------------------------------------------------- diff --git a/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageCopyOnWriteProxyTest.java b/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageCopyOnWriteProxyTest.java new file mode 100644 index 0000000..afea93c --- /dev/null +++ b/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageCopyOnWriteProxyTest.java @@ -0,0 +1,279 @@ +/**************************************************************** + * 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.server.core; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNotSame; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.util.ArrayList; +import java.util.Properties; + +import javax.mail.MessagingException; +import javax.mail.Session; +import javax.mail.internet.MimeMessage; +import javax.mail.util.SharedByteArrayInputStream; + +import org.apache.james.lifecycle.api.LifecycleUtil; +import org.apache.james.core.MailAddress; +import org.apache.mailet.Mail; +import org.junit.Test; + +public class MimeMessageCopyOnWriteProxyTest extends MimeMessageFromStreamTest { + + final String content = "Subject: foo\r\nContent-Transfer-Encoding2: plain"; + final String sep = "\r\n\r\n"; + final String body = "bar\r\n.\r\n"; + + @Override + protected MimeMessage getMessageFromSources(String sources) throws Exception { + MimeMessageInputStreamSource mmis = new MimeMessageInputStreamSource("test", new SharedByteArrayInputStream(sources.getBytes())); + return new MimeMessageCopyOnWriteProxy(mmis); + // return new MimeMessage(Session.getDefaultInstance(new + // Properties()),new ByteArrayInputStream(sources.getBytes())); + } + + @Test + public void testMessageCloning1() throws Exception { + ArrayList<MailAddress> r = new ArrayList<>(); + r.add(new MailAddress("recipi...@test.com")); + MimeMessageCopyOnWriteProxy messageFromSources = (MimeMessageCopyOnWriteProxy) getMessageFromSources( + content + sep + body); + MailImpl mail = new MailImpl("test", new MailAddress("t...@test.com"), r, messageFromSources); + MailImpl m2 = (MailImpl) mail.duplicate(); + System.out.println("mail: " + getReferences(mail.getMessage()) + " m2: " + getReferences(m2.getMessage())); + assertNotSame(m2, mail); + assertNotSame(m2.getMessage(), mail.getMessage()); + // test that the wrapped message is the same + assertTrue(isSameMimeMessage(m2.getMessage(), mail.getMessage())); + // test it is the same after read only operations! + mail.getMessage().getSubject(); + assertTrue(isSameMimeMessage(m2.getMessage(), mail.getMessage())); + mail.getMessage().setText("new body"); + mail.getMessage().saveChanges(); + // test it is different after a write operation! + mail.getMessage().setSubject("new Subject"); + assertTrue(!isSameMimeMessage(m2.getMessage(), mail.getMessage())); + LifecycleUtil.dispose(mail); + LifecycleUtil.dispose(m2); + LifecycleUtil.dispose(messageFromSources); + } + + @Test + public void testMessageCloning2() throws Exception { + ArrayList<MailAddress> r = new ArrayList<>(); + r.add(new MailAddress("recipi...@test.com")); + MimeMessageCopyOnWriteProxy messageFromSources = (MimeMessageCopyOnWriteProxy) getMessageFromSources( + content + sep + body); + MailImpl mail = new MailImpl("test", new MailAddress("t...@test.com"), r, messageFromSources); + MailImpl m2 = (MailImpl) mail.duplicate(); + System.out.println("mail: " + getReferences(mail.getMessage()) + " m2: " + getReferences(m2.getMessage())); + assertNotSame(m2, mail); + assertNotSame(m2.getMessage(), mail.getMessage()); + // test that the wrapped message is the same + assertTrue(isSameMimeMessage(m2.getMessage(), mail.getMessage())); + // test it is the same after real only operations! + m2.getMessage().getSubject(); + assertTrue(isSameMimeMessage(m2.getMessage(), mail.getMessage())); + m2.getMessage().setText("new body"); + m2.getMessage().saveChanges(); + // test it is different after a write operation! + m2.getMessage().setSubject("new Subject"); + assertTrue(!isSameMimeMessage(m2.getMessage(), mail.getMessage())); + // check that the subjects are correct on both mails! + assertEquals(m2.getMessage().getSubject(), "new Subject"); + assertEquals(mail.getMessage().getSubject(), "foo"); + // cloning again the messages + Mail m2clone = m2.duplicate(); + assertTrue(isSameMimeMessage(m2clone.getMessage(), m2.getMessage())); + MimeMessage mm = getWrappedMessage(m2.getMessage()); + assertNotSame(m2.getMessage(), m2clone.getMessage()); + // test that m2clone has a valid wrapped message + MimeMessage mm3 = getWrappedMessage(m2clone.getMessage()); + assertNotNull(mm3); + // dispose m2 and check that the clone has still a valid message and it + // is the same! + LifecycleUtil.dispose(m2); + assertEquals(mm3, getWrappedMessage(m2clone.getMessage())); + // change the message that should be not referenced by m2 that has + // been disposed, so it should not clone it! + m2clone.getMessage().setSubject("new Subject 2"); + m2clone.getMessage().setText("new Body 3"); + assertTrue(isSameMimeMessage(m2clone.getMessage(), mm)); + LifecycleUtil.dispose(mail); + LifecycleUtil.dispose(messageFromSources); + } + + /** + * If I create a new MimeMessageCopyOnWriteProxy from another + * MimeMessageCopyOnWriteProxy, I remove references to the first and I + * change the second, then it should not clone + */ + @Test + public void testMessageAvoidCloning() throws Exception { + ArrayList<MailAddress> r = new ArrayList<>(); + r.add(new MailAddress("recipi...@test.com")); + MimeMessageCopyOnWriteProxy messageFromSources = (MimeMessageCopyOnWriteProxy) getMessageFromSources( + content + sep + body); + MailImpl mail = new MailImpl("test", new MailAddress("t...@test.com"), r, messageFromSources); + // cloning the message + Mail mailClone = mail.duplicate(); + assertTrue(isSameMimeMessage(mailClone.getMessage(), mail.getMessage())); + MimeMessage mm = getWrappedMessage(mail.getMessage()); + assertNotSame(mail.getMessage(), mailClone.getMessage()); + // dispose mail and check that the clone has still a valid message and + // it is the same! + LifecycleUtil.dispose(mail); + LifecycleUtil.dispose(messageFromSources); + // need to add a gc and a wait, because the original mimemessage should + // be finalized before the test. + System.gc(); + Thread.sleep(1000); + // dumb test + assertTrue(isSameMimeMessage(mailClone.getMessage(), mailClone.getMessage())); + // change the message that should be not referenced by mail that has + // been disposed, so it should not clone it! + mailClone.getMessage().setSubject("new Subject 2"); + mailClone.getMessage().setText("new Body 3"); + assertTrue(isSameMimeMessage(mailClone.getMessage(), mm)); + LifecycleUtil.dispose(mailClone); + LifecycleUtil.dispose(mm); + } + + /** + * If I create a new MimeMessageCopyOnWriteProxy from a MimeMessage and I + * change the new message, the original should be unaltered and the proxy + * should clone the message. + */ + @Test + public void testMessageCloning3() throws Exception { + ArrayList<MailAddress> r = new ArrayList<>(); + r.add(new MailAddress("recipi...@test.com")); + MimeMessage m = new MimeMessage(Session.getDefaultInstance(new Properties(null))); + m.setText("CIPS"); + MailImpl mail = new MailImpl("test", new MailAddress("t...@test.com"), r, m); + assertTrue(isSameMimeMessage(m, mail.getMessage())); + // change the message that should be not referenced by mail that has + // been disposed, so it should not clone it! + System.gc(); + Thread.sleep(100); + mail.getMessage().setSubject("new Subject 2"); + mail.getMessage().setText("new Body 3"); + System.gc(); + Thread.sleep(100); + assertFalse(isSameMimeMessage(m, mail.getMessage())); + LifecycleUtil.dispose(mail); + LifecycleUtil.dispose(m); + } + + @Test + public void testMessageDisposing() throws Exception { + ArrayList<MailAddress> r = new ArrayList<>(); + r.add(new MailAddress("recipi...@test.com")); + MimeMessageCopyOnWriteProxy messageFromSources = (MimeMessageCopyOnWriteProxy) getMessageFromSources( + content + sep + body); + MailImpl mail = new MailImpl("test", new MailAddress("t...@test.com"), r, messageFromSources); + // cloning the message + MailImpl mailClone = (MailImpl) mail.duplicate(); + LifecycleUtil.dispose(mail); + + assertNotNull(getWrappedMessage(mailClone.getMessage())); + assertNull(mail.getMessage()); + + LifecycleUtil.dispose(mailClone); + + assertNull(mailClone.getMessage()); + assertNull(mail.getMessage()); + LifecycleUtil.dispose(mail); + LifecycleUtil.dispose(messageFromSources); + } + + @Test + public void testNPE1() throws MessagingException, InterruptedException { + ArrayList<MailAddress> recipients = new ArrayList<>(); + recipients.add(new MailAddress("recipi...@test.com")); + MimeMessageCopyOnWriteProxy mw = new MimeMessageCopyOnWriteProxy(new MimeMessageInputStreamSource("test", + new SharedByteArrayInputStream(("Return-path: ret...@test.com\r\n" + "Content-Transfer-Encoding: plain\r\n" + "Subject: test\r\n\r\n" + "Body Text testNPE1\r\n"). + getBytes()))); + + MimeMessageCopyOnWriteProxy mw2 = new MimeMessageCopyOnWriteProxy(mw); + LifecycleUtil.dispose(mw2); + mw2 = null; + System.gc(); + Thread.sleep(1000); + // the NPE was inside this call + mw.getMessageSize(); + LifecycleUtil.dispose(mw); + } + + /** + * This test throw a NullPointerException when the original message was + * created by a MimeMessageInputStreamSource. + */ + @Test + public void testMessageCloningViaCoW3() throws Exception { + MimeMessage mmorig = getSimpleMessage(); + + MimeMessage mm = new MimeMessageCopyOnWriteProxy(mmorig); + + LifecycleUtil.dispose(mmorig); + mmorig = null; + System.gc(); + Thread.sleep(200); + + try { + mm.writeTo(System.out); + } catch (Exception e) { + e.printStackTrace(); + fail("Exception while writing the message to output"); + } + + LifecycleUtil.dispose(mm); + } + + private static String getReferences(MimeMessage m) { + StringBuilder ref = new StringBuilder("/"); + while (m instanceof MimeMessageCopyOnWriteProxy) { + ref.append(((MimeMessageCopyOnWriteProxy) m).refCount.getReferenceCount()).append("/"); + m = ((MimeMessageCopyOnWriteProxy) m).getWrappedMessage(); + } + if (m instanceof MimeMessageWrapper) { + ref.append("W"); + } else { + ref.append("M"); + } + return ref.toString(); + } + + private static MimeMessage getWrappedMessage(MimeMessage m) { + while (m instanceof MimeMessageCopyOnWriteProxy) { + m = ((MimeMessageCopyOnWriteProxy) m).getWrappedMessage(); + } + return m; + } + + private static boolean isSameMimeMessage(MimeMessage first, MimeMessage second) { + return getWrappedMessage(first) == getWrappedMessage(second); + + } +} http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageFromMimeMessageTest.java ---------------------------------------------------------------------- diff --git a/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageFromMimeMessageTest.java b/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageFromMimeMessageTest.java new file mode 100644 index 0000000..b93d57d --- /dev/null +++ b/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageFromMimeMessageTest.java @@ -0,0 +1,31 @@ +/**************************************************************** + * 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.server.core; + +import javax.mail.internet.MimeMessage; + +public class MimeMessageFromMimeMessageTest extends MimeMessageFromStreamTest { + + @Override + protected MimeMessage getMessageFromSources(String sources) throws Exception { + return new MimeMessage(super.getMessageFromSources(sources)); + } + +} http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageFromSharedStreamTest.java ---------------------------------------------------------------------- diff --git a/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageFromSharedStreamTest.java b/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageFromSharedStreamTest.java new file mode 100644 index 0000000..a11aedc --- /dev/null +++ b/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageFromSharedStreamTest.java @@ -0,0 +1,36 @@ +/**************************************************************** + * 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.server.core; + +import javax.mail.util.SharedByteArrayInputStream; + +import javax.mail.Session; +import javax.mail.internet.MimeMessage; + +import java.util.Properties; + +public class MimeMessageFromSharedStreamTest extends MimeMessageFromStreamTest { + + @Override + protected MimeMessage getMessageFromSources(String sources) throws Exception { + return new MimeMessage(Session.getDefaultInstance(new Properties()), new SharedByteArrayInputStream(sources.getBytes())); + } + +} http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageFromStreamTest.java ---------------------------------------------------------------------- diff --git a/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageFromStreamTest.java b/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageFromStreamTest.java new file mode 100644 index 0000000..8b68c14 --- /dev/null +++ b/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageFromStreamTest.java @@ -0,0 +1,59 @@ +/**************************************************************** + * 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.server.core; + +import javax.mail.Session; +import javax.mail.internet.MimeMessage; + +import java.io.ByteArrayInputStream; +import java.util.Properties; + +public class MimeMessageFromStreamTest extends MimeMessageTest { + + protected MimeMessage getMessageFromSources(String sources) throws Exception { + return new MimeMessage(Session.getDefaultInstance(new Properties()), new ByteArrayInputStream(sources.getBytes())); + } + + @Override + protected MimeMessage getMultipartMessage() throws Exception { + return getMessageFromSources(getMultipartMessageSource()); + } + + @Override + protected MimeMessage getSimpleMessage() throws Exception { + return getMessageFromSources(getSimpleMessageCleanedSource()); + } + + @Override + protected MimeMessage getMessageWithBadReturnPath() throws Exception { + return getMessageFromSources(getMessageWithBadReturnPathSource()); + } + + @Override + protected MimeMessage getMissingEncodingAddHeaderMessage() throws Exception { + return getMessageFromSources(getMissingEncodingAddHeaderSource()); + } + + @Override + protected MimeMessage getMissingEncodingMessage() throws Exception { + return getMessageFromSources(getMissingEncodingMessageSource()); + } + +} http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageInputStreamSourceTest.java ---------------------------------------------------------------------- diff --git a/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageInputStreamSourceTest.java b/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageInputStreamSourceTest.java new file mode 100644 index 0000000..642699b --- /dev/null +++ b/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageInputStreamSourceTest.java @@ -0,0 +1,60 @@ +/**************************************************************** + * 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.server.core; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.io.IOException; + +import javax.mail.MessagingException; + +import org.apache.james.util.ZeroedInputStream; +import org.junit.After; +import org.junit.Test; + +public class MimeMessageInputStreamSourceTest { + + private static final int _1M = 1024*1024; + private static final int _10KB = 10*1024; + private MimeMessageInputStreamSource testee; + + @After + public void tearDown() { + testee.dispose(); + } + + @Test + public void streamWith1MBytesShouldBeReadable() throws MessagingException, IOException { + testee = new MimeMessageInputStreamSource("myKey", new ZeroedInputStream(_1M)); + assertThat(testee.getInputStream()).hasSameContentAs(new ZeroedInputStream(_1M)); + } + + @Test + public void streamWith10KBytesShouldBeReadable() throws MessagingException, IOException { + testee = new MimeMessageInputStreamSource("myKey", new ZeroedInputStream(_10KB)); + assertThat(testee.getInputStream()).hasSameContentAs(new ZeroedInputStream(_10KB)); + } + + @Test + public void streamWithVeryShortNameShouldWork() throws MessagingException, IOException { + String veryShortName = "1"; + testee = new MimeMessageInputStreamSource(veryShortName, new ZeroedInputStream(_1M)); + assertThat(testee.getInputStream()).isNotNull(); + } +} --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org