Replaced greenmail with apache james for unit tests, Added a lot of new testcases, Version bump to 1.9.0, some pom updates, site added, travis CI support added. This commit only touch test code.
git-svn-id: https://svn.apache.org/repos/asf/geronimo/javamail/trunk@1641709 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/geronimo-javamail_1.4/.travis.yml b/geronimo-javamail_1.4/.travis.yml
new file mode 100644
index 0000000..ca8fc8c
--- /dev/null
+++ b/geronimo-javamail_1.4/.travis.yml
@@ -0,0 +1,8 @@
+language: java
+
+jdk:
+ - openjdk6
+ - openjdk7
+ - oraclejdk7
+ - oraclejdk8
+
diff --git a/geronimo-javamail_1.4/geronimo-javamail_1.4_mail/pom.xml b/geronimo-javamail_1.4/geronimo-javamail_1.4_mail/pom.xml
index 4028134..5c70c45 100644
--- a/geronimo-javamail_1.4/geronimo-javamail_1.4_mail/pom.xml
+++ b/geronimo-javamail_1.4/geronimo-javamail_1.4_mail/pom.xml
@@ -27,7 +27,7 @@
<parent>
<groupId>org.apache.geronimo.javamail</groupId>
<artifactId>geronimo-javamail_1.4</artifactId>
- <version>1.8.5-SNAPSHOT</version>
+ <version>1.9.0-SNAPSHOT</version>
</parent>
<artifactId>geronimo-javamail_1.4_mail</artifactId>
@@ -123,7 +123,7 @@
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<instructions>
- <Bundle-SymbolicName>${groupId}.${artifactId};singleton=true</Bundle-SymbolicName>
+ <Bundle-SymbolicName>${project.groupId}.${project.artifactId};singleton=true</Bundle-SymbolicName>
<Specification-Title>JSR-919 Javamail API 1.4 merged bundle</Specification-Title>
<Specification-Vendor>Sun Microsystems, Inc.</Specification-Vendor>
<Specification-Version>1.4</Specification-Version>
@@ -143,6 +143,7 @@
</Export-Package>
<Import-Package>
javax.activation,
+ javax.net,
javax.mail*,
javax.imageio*;resolution:="optional",
javax.net.ssl*;resolution:="optional",
diff --git a/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/pom.xml b/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/pom.xml
index fe3cb8a..3161a08 100644
--- a/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/pom.xml
+++ b/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/pom.xml
@@ -1,39 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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
+<!-- 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. -->
- http://www.apache.org/licenses/LICENSE-2.0
+<!-- $Rev$ $Date: 2014-07-20 09:36:35 +0200 (So, 20. Jul 2014)
+ $ -->
- 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.
--->
-
-<!-- $Rev$ $Date$ -->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.geronimo.javamail</groupId>
<artifactId>geronimo-javamail_1.4</artifactId>
- <version>1.8.5-SNAPSHOT</version>
+ <version>1.9.0-SNAPSHOT</version>
</parent>
<artifactId>geronimo-javamail_1.4_provider</artifactId>
<packaging>bundle</packaging>
<name>Geronimo JavaMail 1.4 :: Provider</name>
+ <properties>
+ <james.version>3.0-beta4</james.version>
+ </properties>
+
<dependencies>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
@@ -44,7 +42,12 @@
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-javamail_1.4_spec</artifactId>
- <scope>provided</scope>
+ <exclusions>
+ <exclusion>
+ <artifactId>apache-mime4j-core</artifactId>
+ <groupId>org.apache.james</groupId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
@@ -54,26 +57,251 @@
</dependency>
<dependency>
- <groupId>com.icegreen</groupId>
- <artifactId>greenmail</artifactId>
- <version>1.3.1b</version>
+ <groupId>org.apache.james</groupId>
+ <artifactId>apache-james-imap-processor</artifactId>
+ <version>0.3</version>
<scope>test</scope>
<exclusions>
<exclusion>
- <groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
+ <groupId>javax.mail</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+
+ <dependency>
+ <groupId>org.apache.james</groupId>
+ <artifactId>james-server-protocols-pop3</artifactId>
+ <version>${james.version}</version>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <artifactId>mail</artifactId>
+ <groupId>javax.mail</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
- <!-- Required for GreenMail -->
+ <groupId>org.apache.james</groupId>
+ <artifactId>james-server-protocols-imap4</artifactId>
+ <version>${james.version}</version>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <artifactId>mail</artifactId>
+ <groupId>javax.mail</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.james</groupId>
+ <artifactId>james-server-protocols-smtp</artifactId>
+ <version>${james.version}</version>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <artifactId>mail</artifactId>
+ <groupId>javax.mail</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.james</groupId>
+ <artifactId>apache-james-mailbox-memory</artifactId>
+ <version>0.5</version>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <artifactId>mail</artifactId>
+ <groupId>javax.mail</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.james</groupId>
+ <artifactId>apache-james-mailbox-memory</artifactId>
+ <version>0.5</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <artifactId>mail</artifactId>
+ <groupId>javax.mail</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.james</groupId>
+ <artifactId>james-server-protocols-library</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ <version>${james.version}</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>mail</artifactId>
+ <groupId>javax.mail</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.james</groupId>
+ <artifactId>james-server-protocols-library</artifactId>
+ <scope>test</scope>
+ <version>${james.version}</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>mail</artifactId>
+ <groupId>javax.mail</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.james</groupId>
+ <artifactId>james-server-filesystem-api</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ <version>${james.version}</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>mail</artifactId>
+ <groupId>javax.mail</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.james</groupId>
+ <artifactId>james-server-data-library</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ <version>${james.version}</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>mail</artifactId>
+ <groupId>javax.mail</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.james</groupId>
+ <artifactId>james-server-data-library</artifactId>
+ <scope>test</scope>
+ <version>${james.version}</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>mail</artifactId>
+ <groupId>javax.mail</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.james</groupId>
+ <artifactId>james-server-data-file</artifactId>
+ <version>${james.version}</version>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <artifactId>mail</artifactId>
+ <groupId>javax.mail</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.james</groupId>
+ <artifactId>james-server-queue-file</artifactId>
+ <version>${james.version}</version>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <artifactId>mail</artifactId>
+ <groupId>javax.mail</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.james</groupId>
+ <artifactId>james-server-data-file</artifactId>
+ <version>${james.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <artifactId>mail</artifactId>
+ <groupId>javax.mail</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.james</groupId>
+ <artifactId>james-server-queue-file</artifactId>
+ <version>${james.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <artifactId>mail</artifactId>
+ <groupId>javax.mail</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.james</groupId>
+ <artifactId>james-server-queue-api</artifactId>
+ <version>${james.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <artifactId>mail</artifactId>
+ <groupId>javax.mail</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.james</groupId>
+ <artifactId>james-server-data-api</artifactId>
+ <version>${james.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <artifactId>mail</artifactId>
+ <groupId>javax.mail</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
<groupId>org.slf4j</groupId>
- <artifactId>slf4j-jdk14</artifactId>
- <version>1.3.1</version>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.7.2</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <version>1.7.2</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-jdk14</artifactId>
+ <version>1.3.1</version> <scope>test</scope> </dependency> -->
+
</dependencies>
<build>
@@ -83,8 +311,9 @@
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<instructions>
- <Bundle-SymbolicName>${groupId}.${artifactId};singleton=true</Bundle-SymbolicName>
- <Specification-Title>JSR-919 Javamail API 1.4 provider bundle</Specification-Title>
+ <Bundle-SymbolicName>${project.groupId}.${project.artifactId};singleton=true</Bundle-SymbolicName>
+ <Specification-Title>JSR-919 Javamail API 1.4
+ provider bundle</Specification-Title>
<Specification-Vendor>Sun Microsystems, Inc.</Specification-Vendor>
<Specification-Version>1.4</Specification-Version>
<Private-Package>
@@ -98,14 +327,14 @@
</Export-Package>
<Import-Package>
javax.activation,
+ javax.net,
javax.mail*,
org.apache.geronimo.mail.util,
javax.imageio*;resolution:="optional",
javax.net.ssl*;resolution:="optional",
javax.security.sasl*;resolution:="optional",
javax.security.auth.callback*;resolution:="optional",
- org.apache.geronimo.mail.james.mime4j.codec,
- javax.net
+ org.apache.geronimo.mail.james.mime4j.codec
</Import-Package>
</instructions>
<unpackBundle>true</unpackBundle>
diff --git a/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/test/java/org/apache/geronimo/javamail/issues/GERONIMO6480Test.java b/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/test/java/org/apache/geronimo/javamail/issues/GERONIMO6480Test.java
new file mode 100755
index 0000000..e999475
--- /dev/null
+++ b/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/test/java/org/apache/geronimo/javamail/issues/GERONIMO6480Test.java
@@ -0,0 +1,139 @@
+/**
+ * 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.geronimo.javamail.issues;
+
+import java.io.File;
+import java.util.Properties;
+
+import javax.activation.DataHandler;
+import javax.activation.FileDataSource;
+import javax.mail.BodyPart;
+import javax.mail.Folder;
+import javax.mail.Message;
+import javax.mail.Session;
+import javax.mail.Store;
+import javax.mail.Transport;
+import javax.mail.internet.InternetAddress;
+import javax.mail.internet.MimeBodyPart;
+import javax.mail.internet.MimeMessage;
+import javax.mail.internet.MimeMultipart;
+
+import junit.framework.Assert;
+
+import org.apache.geronimo.javamail.testserver.AbstractProtocolTest;
+
+public class GERONIMO6480Test extends AbstractProtocolTest {
+
+ public void testGERONIMO6480_0() throws Exception {
+ BodyPart attachmentPart = new MimeBodyPart();
+ attachmentPart.setDataHandler(new DataHandler(new FileDataSource(getAbsoluteFilePathFromClassPath("pdf-test.pdf"))));
+ attachmentPart.setFileName("test.pdf");
+ String contentType = getSendedAttachmentContentType(attachmentPart);
+ Assert.assertEquals("application/octet-stream; name=test.pdf".toLowerCase(), contentType.toLowerCase());
+ // "text/plain; name=test.pdf" with Geronimo because setFileName force it to 'text/plain' when adding the 'name=' part instead of keeping it null
+ }
+
+ public void testGERONIMO6480_1() throws Exception {
+ BodyPart attachmentPart = new MimeBodyPart();
+ attachmentPart.addHeader("Content-Type", "aplication/pdf");
+ // setDataHandler reset "Content-Type" so equivalent to previous test
+ attachmentPart.setDataHandler(new DataHandler(new FileDataSource(getAbsoluteFilePathFromClassPath("pdf-test.pdf"))));
+ attachmentPart.setFileName("test.pdf");
+ String contentType = getSendedAttachmentContentType(attachmentPart);
+ Assert.assertEquals("application/octet-stream; name=test.pdf".toLowerCase(), contentType.toLowerCase());
+ // "text/plain; name=test.pdf" with Geronimo because setFileName force it to 'text/plain' when adding the 'name=' part instead of keeping it null
+ }
+
+ public void testGERONIMO6480_2() throws Exception {
+ BodyPart attachmentPart = new MimeBodyPart();
+ attachmentPart.setDataHandler(new DataHandler(new FileDataSource(getAbsoluteFilePathFromClassPath("pdf-test.pdf"))));
+ attachmentPart.addHeader("Content-Type", "aplication/pdf");
+ attachmentPart.setFileName("test.pdf");
+ String contentType = getSendedAttachmentContentType(attachmentPart);
+ Assert.assertEquals("aplication/pdf; name=test.pdf".toLowerCase(), contentType.toLowerCase());
+ }
+
+ public void testGERONIMO6480_3() throws Exception {
+ System.setProperty("mail.mime.setcontenttypefilename", Boolean.FALSE.toString());
+ try {
+ BodyPart attachmentPart = new MimeBodyPart();
+ attachmentPart.setDataHandler(new DataHandler(new FileDataSource(getAbsoluteFilePathFromClassPath("pdf-test.pdf"))));
+ attachmentPart.setFileName("test.pdf");
+ String contentType = getSendedAttachmentContentType(attachmentPart);
+ Assert.assertEquals("application/octet-stream; name=test.pdf".toLowerCase(), contentType.toLowerCase());
+ } finally {
+ System.setProperty("mail.mime.setcontenttypefilename", Boolean.TRUE.toString());
+ }
+ }
+
+ public void testGERONIMO6480_4() throws Exception {
+ BodyPart attachmentPart = new MimeBodyPart();
+ attachmentPart.setFileName("test.pdf");
+ attachmentPart.setDataHandler(new DataHandler(new FileDataSource(getAbsoluteFilePathFromClassPath("pdf-test.pdf"))));
+ String contentType = getSendedAttachmentContentType(attachmentPart);
+ Assert.assertEquals("application/octet-stream; name=test.pdf".toLowerCase(), contentType.toLowerCase());
+ }
+
+ private File getAbsoluteFilePathFromClassPath(String filename) throws Exception {
+ return new File(GERONIMO6480Test.class.getClassLoader().getResource(filename).toURI());
+ }
+
+ private String getSendedAttachmentContentType(BodyPart attachmentPart) throws Exception {
+
+ start();
+ Properties props = new Properties();
+ props.setProperty("mail.transport.protocol", "smtp");
+ props.setProperty("mail.store.protocol", "imap");
+ props.setProperty("mail.imap.port", String.valueOf(imapConf.getListenerPort()));
+ props.setProperty("mail.smtp.port", String.valueOf(smtpConf.getListenerPort()));
+ //props.setProperty("mail.debug", "true");
+ Session session = Session.getInstance(props);
+
+ BodyPart messageBodyPart = new MimeBodyPart();
+ messageBodyPart.setText("See attachment.");
+
+ MimeMultipart multipart = new MimeMultipart();
+ multipart.addBodyPart(messageBodyPart);
+ multipart.addBodyPart(attachmentPart);
+
+ Message message = new MimeMessage(session);
+ message.setRecipients(Message.RecipientType.TO, InternetAddress.parse("test@mockserver.com"));
+ message.setSubject("Test attachment content-type");
+ message.setContent(multipart);
+
+ Transport.send(message);
+
+ return getAttachmentContentType(session);
+ }
+
+ private String getAttachmentContentType(Session session) throws Exception {
+ Store store = session.getStore();
+ store.connect("127.0.0.1", "serveruser", "serverpass");
+
+ Folder folder = store.getDefaultFolder();
+ folder = folder.getFolder("inbox");
+ folder.open(Folder.READ_ONLY);
+
+ server.ensureMsgCount(1);
+
+ Message message = folder.getMessage(1);
+ MimeMultipart multipart = (MimeMultipart) message.getContent();
+ BodyPart attachmentPart = multipart.getBodyPart(1);
+ return attachmentPart.getContentType();
+ }
+
+}
diff --git a/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/test/java/org/apache/geronimo/javamail/issues/IssuesTest.java b/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/test/java/org/apache/geronimo/javamail/issues/IssuesTest.java
index a2d1a3f..417e988 100644
--- a/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/test/java/org/apache/geronimo/javamail/issues/IssuesTest.java
+++ b/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/test/java/org/apache/geronimo/javamail/issues/IssuesTest.java
@@ -17,54 +17,115 @@
package org.apache.geronimo.javamail.issues;
import java.io.ByteArrayOutputStream;
-import java.io.FileDescriptor;
-import java.io.FileOutputStream;
+import java.io.File;
import java.io.PrintStream;
import java.util.Properties;
+import javax.activation.DataHandler;
+import javax.activation.DataSource;
+import javax.activation.FileDataSource;
+import javax.mail.Folder;
+import javax.mail.Message;
+import javax.mail.Multipart;
import javax.mail.Session;
+import javax.mail.Store;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
+import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMessage.RecipientType;
+import javax.mail.internet.MimeMultipart;
import junit.framework.Assert;
-import junit.framework.TestCase;
-import com.icegreen.greenmail.util.GreenMail;
-import com.icegreen.greenmail.util.ServerSetupTest;
+import org.apache.geronimo.javamail.testserver.AbstractProtocolTest;
+import org.apache.geronimo.javamail.testserver.MailServer;
-public class IssuesTest extends TestCase {
+public class IssuesTest extends AbstractProtocolTest {
public void testGERONIMO6519() throws Exception {
+
+ PrintStream original = System.out;
+
try {
- GreenMail greenMail = new GreenMail(ServerSetupTest.SMTP);
- greenMail.start();
- greenMail.setUser("test@localhost", "test", "test");
+
+ start();
// Setup JavaMail session
Properties props = new Properties();
props.setProperty("mail.debug", "true");
- props.setProperty("mail.smtp.port", String.valueOf(greenMail.getSmtp().getPort()));
+ props.setProperty("mail.smtp.port", String.valueOf(smtpConf.getListenerPort()));
props.setProperty("mail.smtp.localhost", "some.full.qualified.name.com");
-
-
+
ByteArrayOutputStream baos = new ByteArrayOutputStream();
System.setOut(new PrintStream(baos, true));
-
+
Session session = Session.getInstance(props);
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress("test@localhost"));
- message.setRecipient(RecipientType.TO, new InternetAddress("test@localhost"));
+ message.setRecipient(javax.mail.Message.RecipientType.TO, new InternetAddress("test@localhost"));
message.setText("test");
-
+
Transport.send(message);
Assert.assertTrue(baos.toString().contains("EHLO some.full.qualified.name.com"));
-
+
} finally {
- System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out)));
+ System.setOut(original);
}
-
-
+
+ }
+
+ public void testGERONIMO4594() throws Exception {
+
+ System.setProperty("mail.mime.decodefilename", "true");
+ System.setProperty("mail.mime.encodefilename", "true");
+ try {
+
+ start();
+
+ // Setup JavaMail session
+ Properties props = new Properties();
+ props.setProperty("mail.transport.protocol", "smtp");
+ props.setProperty("mail.smtp.port", String.valueOf(smtpConf.getListenerPort()));
+ props.setProperty("mail.store.protocol", "imap");
+ props.setProperty("mail.imap.port", String.valueOf(imapConf.getListenerPort()));
+ //props.setProperty("mail.debug","true");
+ Session session = Session.getInstance(props);
+
+ MimeMessage msg = new MimeMessage(session);
+ msg.setSubject("a file for you");
+ msg.setRecipient(javax.mail.Message.RecipientType.TO, new InternetAddress("serveruser@localhost"));
+ msg.setFrom(new InternetAddress("serveruser@localhost"));
+
+ MimeBodyPart messageBodyPart = new MimeBodyPart();
+ Multipart multipart = new MimeMultipart();
+ messageBodyPart.setText("This is message body");
+ File file = MailServer.getAbsoluteFilePathFromClassPath("encoded_filename_ÄÜÖ(test).pdf");
+ Assert.assertTrue(file.exists());
+ DataSource source = new FileDataSource(file.getAbsoluteFile());
+ messageBodyPart.setDataHandler(new DataHandler(source));
+ messageBodyPart.setFileName(file.getName());
+ multipart.addBodyPart(messageBodyPart);
+ msg.setContent(multipart);
+ sendMessage(msg);
+ server.ensureMsgCount(1);
+
+ Session jmsession = Session.getInstance(props);
+ Store store = jmsession.getStore();
+ store.connect("127.0.0.1", "serveruser", "serverpass");
+ Folder f = store.getFolder("INBOX");
+ f.open(Folder.READ_ONLY); //TODO STAT only when folder open???
+ Assert.assertEquals(1, f.getMessageCount());
+ Message[] messages = new Message[2];
+ messages[0] = f.getMessage(1);
+ Assert.assertEquals("encoded_filename_ÄÜÖ(test).pdf", ((Multipart) messages[0].getContent()).getBodyPart(0).getFileName());
+ f.close(false);
+ store.close();
+
+ } finally {
+ System.setProperty("mail.mime.decodefilename", "false");
+ System.setProperty("mail.mime.encodefilename", "false");
+ }
+
}
}
diff --git a/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/test/java/org/apache/geronimo/javamail/store/imap/AuthenticationTest.java b/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/test/java/org/apache/geronimo/javamail/store/imap/AuthenticationTest.java
index e407ddb..77b0948 100644
--- a/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/test/java/org/apache/geronimo/javamail/store/imap/AuthenticationTest.java
+++ b/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/test/java/org/apache/geronimo/javamail/store/imap/AuthenticationTest.java
@@ -16,15 +16,7 @@
*/
package org.apache.geronimo.javamail.store.imap;
-import junit.framework.TestCase;
-import org.apache.geronimo.mail.util.Base64;
-
-import javax.mail.Folder;
-import javax.mail.MessagingException;
-import javax.mail.Session;
-import javax.mail.Store;
import java.io.BufferedReader;
-import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
@@ -33,8 +25,27 @@
import java.net.Socket;
import java.util.Properties;
+import javax.mail.MessagingException;
+import javax.mail.Session;
+import javax.mail.Store;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.geronimo.mail.util.Base64;
+
public class AuthenticationTest extends TestCase {
+ public void testImplUsage() throws Exception {
+
+ //check that we load our mail impl
+ Properties props = new Properties();
+ props.setProperty("mail.store.protocol", "imap");
+ Session jmsession = Session.getInstance(props);
+ Assert.assertEquals(org.apache.geronimo.javamail.store.imap.IMAPStore.class, jmsession.getStore().getClass());
+
+ }
+
public void testAuthenticatePlain() throws Exception {
//greenmail does not have AUTHENTICATE "PLAIN" support
diff --git a/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/test/java/org/apache/geronimo/javamail/store/imap/IMAPStoreTest.java b/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/test/java/org/apache/geronimo/javamail/store/imap/IMAPStoreTest.java
index 37172d5..3dd7866 100644
--- a/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/test/java/org/apache/geronimo/javamail/store/imap/IMAPStoreTest.java
+++ b/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/test/java/org/apache/geronimo/javamail/store/imap/IMAPStoreTest.java
@@ -18,74 +18,45 @@
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
import java.util.Properties;
-import javax.mail.Address;
import javax.mail.Folder;
import javax.mail.Message;
import javax.mail.Session;
import javax.mail.Store;
-import javax.mail.Transport;
-import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
-import junit.framework.TestCase;
+import org.apache.geronimo.javamail.testserver.AbstractProtocolTest;
-import com.icegreen.greenmail.util.GreenMail;
-import com.icegreen.greenmail.util.ServerSetupTest;
-public class IMAPStoreTest extends TestCase {
+public class IMAPStoreTest extends AbstractProtocolTest {
- private GreenMail greenMail;
- private Message[] messages;
-
- //@Override
- protected void setUp() throws Exception {
- // Setup GreenMail
- greenMail = new GreenMail(ServerSetupTest.SMTP_IMAP);
- greenMail.start();
- greenMail.setUser("test@localhost", "test", "test");
- // Setup JavaMail session
+ public void testSimple() throws Exception {
+
+ start();
+ sendTestMsgs();
+
Properties props = new Properties();
- props.setProperty("mail.smtp.port", String.valueOf(greenMail.getSmtp().getPort()));
- props.setProperty("mail.imap.port", String.valueOf(greenMail.getImap().getPort()));
-
- System.out.println("stmp.port: " + greenMail.getSmtp().getPort());
- System.out.println("imap port: " + greenMail.getImap().getPort());
-
+ props.setProperty("mail.imap.port", String.valueOf(imapConf.getListenerPort()));
+ props.setProperty("mail.debug", "true");
Session session = Session.getInstance(props);
- // Send messages for the current test to GreenMail
- sendMessage(session, "/messages/multipart.msg");
- sendMessage(session, "/messages/simple.msg");
// Load the message from IMAP
Store store = session.getStore("imap");
- store.connect("localhost", "test", "test");
+ store.connect("127.0.0.1", "serveruser", "serverpass");
Folder folder = store.getFolder("INBOX");
folder.open(Folder.READ_ONLY);
- this.messages = folder.getMessages();
- assertEquals(2, messages.length);
+ Message[] messages = new Message[2];
+ messages[0] = folder.getMessage(1);
+ messages[1] = folder.getMessage(2);
+ checkMessages(messages);
+ folder.close(false);
+ store.close();
}
- //@Override
- protected void tearDown() throws Exception {
- greenMail.stop();
- }
-
- private void sendMessage(Session session, String msgFile) throws Exception {
- MimeMessage message;
- InputStream in = IMAPStoreTest.class.getResourceAsStream(msgFile);
- try {
- message = new MimeMessage(session, in);
- } finally {
- in.close();
- }
- Transport.send(message, new Address[] { new InternetAddress("test@localhost") });
- }
- public void testMessages() throws Exception {
+ private void checkMessages(Message[] messages) throws Exception {
MimeMessage msg1 = (MimeMessage)messages[0];
Object content = msg1.getContent();
assertTrue(content instanceof MimeMultipart);
@@ -113,4 +84,6 @@
assertEquals(input.getContentType().toLowerCase(), output.getContentType().toLowerCase());
}
+
+
}
diff --git a/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/test/java/org/apache/geronimo/javamail/store/pop3/POP3StoreTest.java b/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/test/java/org/apache/geronimo/javamail/store/pop3/POP3StoreTest.java
index 11687fb..a91133d 100644
--- a/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/test/java/org/apache/geronimo/javamail/store/pop3/POP3StoreTest.java
+++ b/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/test/java/org/apache/geronimo/javamail/store/pop3/POP3StoreTest.java
@@ -22,70 +22,67 @@
import java.util.Properties;
import javax.mail.Address;
+import javax.mail.FetchProfile;
+import javax.mail.Flags;
+import javax.mail.Flags.Flag;
import javax.mail.Folder;
import javax.mail.Message;
+import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Store;
import javax.mail.Transport;
+import javax.mail.UIDFolder;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
-import junit.framework.TestCase;
+import junit.framework.Assert;
-import com.icegreen.greenmail.util.GreenMail;
-import com.icegreen.greenmail.util.ServerSetupTest;
+import org.apache.geronimo.javamail.testserver.AbstractProtocolTest;
+import org.apache.geronimo.javamail.testserver.MailServer.DummySocketFactory;
-public class POP3StoreTest extends TestCase {
+public class POP3StoreTest extends AbstractProtocolTest {
+
- private GreenMail greenMail;
- private Message[] messages;
- //@Override
- protected void setUp() throws Exception {
- // Setup GreenMail
- greenMail = new GreenMail(ServerSetupTest.SMTP_POP3);
- greenMail.start();
- greenMail.setUser("test@localhost", "test", "test");
+
+ public void testSendRetrieve() throws Exception {
+
+ start();
+
// Setup JavaMail session
Properties props = new Properties();
- props.setProperty("mail.smtp.port", String.valueOf(greenMail.getSmtp().getPort()));
- props.setProperty("mail.pop3.port", String.valueOf(greenMail.getPop3().getPort()));
-
- System.out.println("stmp.port: " + greenMail.getSmtp().getPort());
- System.out.println("pop3 port: " + greenMail.getPop3().getPort());
-
+ props.setProperty("mail.smtp.port", String.valueOf(smtpConf.getListenerPort()));
+ props.setProperty("mail.debug","true");
Session session = Session.getInstance(props);
- // Send messages for the current test to GreenMail
+ // Send messages for the current test to James
sendMessage(session, "/messages/multipart.msg");
sendMessage(session, "/messages/simple.msg");
+ server.ensureMsgCount(2);
- // Load the message from POP3
- Store store = session.getStore("pop3");
- store.connect("localhost", "test", "test");
- Folder folder = store.getFolder("INBOX");
- folder.open(Folder.READ_ONLY);
- this.messages = folder.getMessages();
- assertEquals(2, messages.length);
- }
-
- //@Override
- protected void tearDown() throws Exception {
- greenMail.stop();
- }
+ props = new Properties();
+ props.setProperty("mail.store.protocol", "pop3");
+ props.setProperty("mail.pop3.port", String.valueOf(pop3Conf.getListenerPort()));
+ props.setProperty("mail.debug", "true");
- private void sendMessage(Session session, String msgFile) throws Exception {
- MimeMessage message;
- InputStream in = POP3StoreTest.class.getResourceAsStream(msgFile);
- try {
- message = new MimeMessage(session, in);
- } finally {
- in.close();
- }
- Transport.send(message, new Address[] { new InternetAddress("test@localhost") });
+ Session jmsession = Session.getInstance(props);
+ Store store = jmsession.getStore();
+ store.connect("127.0.0.1", "serveruser", "serverpass");
+ Folder f = store.getFolder("INBOX");
+ f.open(Folder.READ_ONLY); //TODO STAT only when folder open???
+ Assert.assertEquals(2, f.getMessageCount());
+ Message[] messages = new Message[2];
+ messages[0] = f.getMessage(1);
+ messages[1] = f.getMessage(2);
+ checkMessages(messages);
+ f.close(false);
+ store.close();
}
- public void testMessages() throws Exception {
+
+
+
+ private void checkMessages(Message[] messages) throws Exception {
MimeMessage msg1 = (MimeMessage)messages[0];
Object content = msg1.getContent();
assertTrue(content instanceof MimeMultipart);
@@ -113,4 +110,340 @@
assertEquals(input.getContentType().toLowerCase(), output.getContentType().toLowerCase());
}
+
+
+ public void testStartTLS() throws Exception {
+
+ pop3Conf.enableSSL(true, false);
+
+ start();
+
+ sendTestMsgs();
+
+ Properties props = new Properties();
+ props.setProperty("mail.store.protocol", "pop3");
+ props.setProperty("mail.pop3.port", String.valueOf(pop3Conf.getListenerPort()));
+ props.setProperty("mail.debug", "true");
+ props.setProperty("mail.pop3.starttls.required", "true");
+ props.setProperty("mail.pop3.ssl.trust", "*");
+
+ Session jmsession = Session.getInstance(props);
+ Store store = jmsession.getStore();
+ store.connect("127.0.0.1", "serveruser", "serverpass");
+ Folder f = store.getFolder("INBOX");
+ f.open(Folder.READ_ONLY); //TODO STAT only when folder open???
+ Assert.assertEquals(2, f.getMessageCount());
+ f.close(false);
+ store.close();
+
+ }
+
+ public void testAPOP() throws Exception {
+
+ pop3Conf.enableSSL(true, false);
+
+ start();
+ sendTestMsgs();
+
+ Properties props = new Properties();
+ props.setProperty("mail.store.protocol", "pop3");
+ props.setProperty("mail.pop3.port", String.valueOf(pop3Conf.getListenerPort()));
+ props.setProperty("mail.debug", "true");
+ props.setProperty("mail.pop3.apop.enable", "true");
+
+ Session jmsession = Session.getInstance(props);
+ Store store = jmsession.getStore();
+ store.connect("127.0.0.1", "serveruser", "serverpass");
+ Folder f = store.getFolder("INBOX");
+ f.open(Folder.READ_ONLY); //TODO STAT only when folder open???
+ Assert.assertEquals(2, f.getMessageCount());
+ f.close(false);
+ store.close();
+
+ }
+
+ public void testFetch() throws Exception {
+
+
+ pop3Conf.enableSSL(true, false);
+
+ start();
+ sendTestMsgs();
+
+ Properties props = new Properties();
+ props.setProperty("mail.store.protocol", "pop3");
+ props.setProperty("mail.pop3.port", String.valueOf(pop3Conf.getListenerPort()));
+ props.setProperty("mail.debug", "true");
+
+ Session jmsession = Session.getInstance(props);
+ Store store = jmsession.getStore();
+ store.connect("127.0.0.1", "serveruser", "serverpass");
+ Folder f = store.getFolder("INBOX");
+ f.open(Folder.READ_ONLY); //TODO STAT only when folder open???
+ FetchProfile fp = new FetchProfile();
+ fp.add(UIDFolder.FetchProfileItem.UID);
+ fp.add(FetchProfile.Item.CONTENT_INFO);
+
+ Message[] msgs = f.getMessages();
+ ByteArrayOutputStream bout = new ByteArrayOutputStream();
+ Assert.assertEquals(2, msgs.length);
+
+ f.fetch(msgs, fp);
+ Assert.assertEquals(2, f.getMessageCount());
+
+ for (int i = 0; i < msgs.length; i++) {
+ Message message = msgs[i];
+ message.writeTo(bout);
+ String msg = bout.toString();
+ Assert.assertNotNull(msg);
+ int num = message.getMessageNumber();
+ Assert.assertTrue(num > 0);
+ String uid = ((POP3Folder) f).getUID(message);
+ Assert.assertNotNull(uid);
+ Assert.assertTrue(!uid.isEmpty());
+ }
+
+ f.close(false);
+ store.close();
+
+ }
+
+
+
+ public void testDelete() throws Exception {
+
+
+ pop3Conf.enableSSL(true, false);
+
+ start();
+ sendTestMsgs();
+
+ Properties props = new Properties();
+ props.setProperty("mail.store.protocol", "pop3");
+ props.setProperty("mail.pop3.port", String.valueOf(pop3Conf.getListenerPort()));
+ props.setProperty("mail.debug", "true");
+
+ Session jmsession = Session.getInstance(props);
+ Store store = jmsession.getStore();
+ store.connect("127.0.0.1", "serveruser", "serverpass");
+ Folder f = store.getFolder("INBOX");
+ f.open(Folder.READ_WRITE); //TODO STAT only when folder open???
+ Assert.assertEquals(2, f.getMessageCount());
+ Message[] msgs = f.getMessages();
+ f.setFlags(msgs, new Flags(Flag.DELETED), true);
+ Assert.assertEquals(2, f.getMessageCount());
+ f.getMessage(1).getSubject(); //should fail
+ //Assert.assertEquals(2, f.expunge());
+ f.close(false);
+ f.open(Folder.READ_ONLY); //TODO STAT only when folder open???
+ Assert.assertEquals(0, f.getMessageCount());
+ store.close();
+
+ }
+
+
+
+ public void testStartTLSFail() throws Exception {
+
+
+ pop3Conf.enableSSL(false, false);
+
+ start();
+ sendTestMsgs();
+
+ Properties props = new Properties();
+ props.setProperty("mail.store.protocol", "pop3");
+ props.setProperty("mail.pop3.port", String.valueOf(pop3Conf.getListenerPort()));
+ props.setProperty("mail.debug", "true");
+ props.setProperty("mail.pop3.starttls.required", "true");
+ props.setProperty("mail.pop3.ssl.trust", "*");
+
+ Session jmsession = Session.getInstance(props);
+ Store store = jmsession.getStore();
+ try {
+ store.connect("127.0.0.1", "serveruser", "serverpass");
+ fail();
+ } catch (MessagingException e) {
+ //Expected
+ }
+ }
+
+ public void testSSLEnable() throws Exception {
+
+
+ pop3Conf.enableSSL(false, true);
+
+ start();
+ sendTestMsgs();
+
+ Properties props = new Properties();
+ props.setProperty("mail.store.protocol", "pop3");
+ props.setProperty("mail.pop3.port", String.valueOf(pop3Conf.getListenerPort()));
+ props.setProperty("mail.debug", "true");
+ props.setProperty("mail.pop3.ssl.enable", "true");
+ props.setProperty("mail.pop3.ssl.trust", "*");
+
+ Session jmsession = Session.getInstance(props);
+ Store store = jmsession.getStore();
+ store.connect("127.0.0.1", "serveruser", "serverpass");
+ Folder f = store.getFolder("INBOX");
+ f.open(Folder.READ_ONLY); //TODO STAT only when folder open???
+ Assert.assertEquals(2, f.getMessageCount());
+ f.close(false);
+ store.close();
+
+ }
+
+ public void testSSLPop3s() throws Exception {
+
+
+ pop3Conf.enableSSL(false, true);
+
+ start();
+ sendTestMsgs();
+
+ Properties props = new Properties();
+ props.setProperty("mail.store.protocol", "pop3s");
+ props.setProperty("mail.pop3s.port", String.valueOf(pop3Conf.getListenerPort()));
+ props.setProperty("mail.debug", "true");
+ props.setProperty("mail.pop3s.ssl.trust", "*");
+
+ Session jmsession = Session.getInstance(props);
+ Store store = jmsession.getStore();
+ store.connect("127.0.0.1", "serveruser", "serverpass");
+ Folder f = store.getFolder("INBOX");
+ f.open(Folder.READ_ONLY); //TODO STAT only when folder open???
+ Assert.assertEquals(2, f.getMessageCount());
+ f.close(false);
+ store.close();
+
+ }
+
+ public void testSSLPop3sFactoryClass() throws Exception {
+
+
+ pop3Conf.enableSSL(false, true);
+
+ start();
+ sendTestMsgs();
+
+ Properties props = new Properties();
+ props.setProperty("mail.store.protocol", "pop3s");
+ props.setProperty("mail.pop3s.port", String.valueOf(pop3Conf.getListenerPort()));
+ props.setProperty("mail.debug", "true");
+ props.setProperty("mail.pop3s.ssl.trust", "*");
+ props.setProperty("mail.pop3s.ssl.socketFactory.class", DummySocketFactory.class.getName());
+
+
+ Session jmsession = Session.getInstance(props);
+ Store store = jmsession.getStore();
+ try {
+ store.connect("127.0.0.1", "serveruser", "serverpass");
+ fail();
+ } catch (MessagingException e) {
+ Assert.assertEquals("dummy socket factory", e.getCause().getCause().getMessage());
+
+ //Expected
+ }
+
+
+
+ }
+
+ public void testSSLPop3sFactoryInstance() throws Exception {
+
+
+ pop3Conf.enableSSL(false, true);
+
+ start();
+ sendTestMsgs();
+
+ Properties props = new Properties();
+ props.setProperty("mail.store.protocol", "pop3s");
+ props.setProperty("mail.pop3s.port", String.valueOf(pop3Conf.getListenerPort()));
+ props.setProperty("mail.debug", "true");
+ props.setProperty("mail.pop3s.ssl.trust", "*");
+ props.put("mail.pop3s.ssl.socketFactory", new DummySocketFactory());
+
+
+ Session jmsession = Session.getInstance(props);
+ Store store = jmsession.getStore();
+ try {
+ store.connect("127.0.0.1", "serveruser", "serverpass");
+ fail();
+ } catch (MessagingException e) {
+ Assert.assertEquals("dummy socket factory", e.getCause().getMessage());
+
+ //Expected
+ }
+
+ }
+
+ public void testSSLPop3sNotEnabled() throws Exception {
+
+
+ pop3Conf.enableSSL(false, false);
+
+ start();
+ sendTestMsgs();
+
+ Properties props = new Properties();
+ props.setProperty("mail.store.protocol", "pop3s");
+ props.setProperty("mail.pop3s.port", String.valueOf(pop3Conf.getListenerPort()));
+ props.setProperty("mail.debug", "true");
+ props.setProperty("mail.pop3s.ssl.trust", "*");
+ props.setProperty("mail.pop3s.ssl.enable", "false");
+
+ Session jmsession = Session.getInstance(props);
+ Store store = jmsession.getStore();
+ store.connect("127.0.0.1", "serveruser", "serverpass");
+ Folder f = store.getFolder("INBOX");
+ f.open(Folder.READ_ONLY); //TODO STAT only when folder open???
+ Assert.assertEquals(2, f.getMessageCount());
+ f.close(false);
+ store.close();
+
+ }
+
+ public void testPop3GetMsgs() throws Exception {
+
+
+ pop3Conf.enableSSL(false, false);
+
+ start();
+ sendTestMsgs();
+
+ Properties props = new Properties();
+ props.setProperty("mail.store.protocol", "pop3");
+ props.setProperty("mail.pop3.port", String.valueOf(pop3Conf.getListenerPort()));
+ props.setProperty("mail.debug", "true");
+
+ Session jmsession = Session.getInstance(props);
+ Store store = jmsession.getStore();
+ store.connect("127.0.0.1", "serveruser", "serverpass");
+ Folder f = store.getFolder("INBOX");
+ f.open(Folder.READ_ONLY); //TODO STAT only when folder open???
+
+
+ Message[] msgs = f.getMessages();
+ ByteArrayOutputStream bout = new ByteArrayOutputStream();
+ Assert.assertEquals(2, msgs.length);
+
+ for (int i = 0; i < msgs.length; i++) {
+ Message message = msgs[i];
+ message.writeTo(bout);
+ String msg = bout.toString();
+ Assert.assertNotNull(msg);
+ int num = message.getMessageNumber();
+ Assert.assertTrue(num > 0);
+ String uid = ((POP3Folder) f).getUID(message);
+ Assert.assertNotNull(uid);
+ Assert.assertTrue(!uid.isEmpty());
+ }
+
+ f.close(false);
+ store.close();
+
+ }
+
}
diff --git a/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/test/java/org/apache/geronimo/javamail/testserver/AbstractProtocolTest.java b/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/test/java/org/apache/geronimo/javamail/testserver/AbstractProtocolTest.java
new file mode 100644
index 0000000..8648869
--- /dev/null
+++ b/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/test/java/org/apache/geronimo/javamail/testserver/AbstractProtocolTest.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.geronimo.javamail.testserver;
+
+import java.io.InputStream;
+import java.util.Properties;
+
+import javax.mail.Address;
+import javax.mail.Session;
+import javax.mail.Transport;
+import javax.mail.internet.InternetAddress;
+import javax.mail.internet.MimeMessage;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.geronimo.javamail.store.pop3.POP3StoreTest;
+
+public abstract class AbstractProtocolTest extends TestCase {
+
+ protected MailServer server = new MailServer();
+ protected MailServer.Pop3TestConfiguration pop3Conf;
+ protected MailServer.SmtpTestConfiguration smtpConf;
+ protected MailServer.ImapTestConfiguration imapConf;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ pop3Conf = new MailServer.Pop3TestConfiguration();
+ smtpConf = new MailServer.SmtpTestConfiguration();
+ imapConf = new MailServer.ImapTestConfiguration();
+
+ }
+
+ protected void start() throws Exception {
+
+ server.start(smtpConf, pop3Conf, imapConf);
+
+ }
+
+ public void testImplUsageImap() throws Exception {
+
+ //check that we load our mail impl
+ final Properties props = new Properties();
+ props.setProperty("mail.store.protocol", "imap");
+ final Session jmsession = Session.getInstance(props);
+ Assert.assertEquals(org.apache.geronimo.javamail.store.imap.IMAPStore.class, jmsession.getStore().getClass());
+
+ }
+
+ public void testImplUsagePop3() throws Exception {
+
+ //check that we load our mail impl
+ final Properties props = new Properties();
+ props.setProperty("mail.store.protocol", "pop3");
+ final Session jmsession = Session.getInstance(props);
+ Assert.assertEquals(org.apache.geronimo.javamail.store.pop3.POP3Store.class, jmsession.getStore().getClass());
+
+ }
+
+ public void testImplUsageSmtp() throws Exception {
+
+ //check that we load our mail impl
+ final Properties props = new Properties();
+ props.setProperty("mail.transport.protocol", "smtp");
+ final Session jmsession = Session.getInstance(props);
+ Assert.assertEquals(org.apache.geronimo.javamail.transport.smtp.SMTPTransport.class, jmsession.getTransport().getClass());
+
+ }
+
+ protected void sendTestMsgs() throws Exception {
+ final Properties props = new Properties();
+ props.setProperty("mail.smtp.port", String.valueOf(smtpConf.getListenerPort()));
+ props.setProperty("mail.debug", "true");
+ final Session session = Session.getInstance(props);
+ sendMessage(session, "/messages/multipart.msg");
+ sendMessage(session, "/messages/simple.msg");
+ server.ensureMsgCount(2);
+ }
+
+ protected void sendMessage(final Session session, final String msgFile) throws Exception {
+ MimeMessage message;
+ final InputStream in = POP3StoreTest.class.getResourceAsStream(msgFile);
+ try {
+ message = new MimeMessage(session, in);
+ } finally {
+ in.close();
+ }
+ Transport.send(message, new Address[] { new InternetAddress("serveruser@localhost") });
+ }
+
+ protected void sendMessage(final MimeMessage message) throws Exception {
+ Transport.send(message, new Address[] { new InternetAddress("serveruser@localhost") });
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ server.stop();
+ }
+
+}
diff --git a/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/test/java/org/apache/geronimo/javamail/testserver/ApopCmdHandler.java b/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/test/java/org/apache/geronimo/javamail/testserver/ApopCmdHandler.java
new file mode 100644
index 0000000..4c0bead
--- /dev/null
+++ b/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/test/java/org/apache/geronimo/javamail/testserver/ApopCmdHandler.java
@@ -0,0 +1,119 @@
+/**
+ * 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.geronimo.javamail.testserver;
+
+import java.io.IOException;
+import java.math.BigInteger;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+
+import javax.annotation.Resource;
+
+import org.apache.james.mailbox.MailboxManager;
+import org.apache.james.mailbox.MailboxSession;
+import org.apache.james.mailbox.MessageManager;
+import org.apache.james.mailbox.exception.BadCredentialsException;
+import org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.mailbox.model.MailboxPath;
+import org.apache.james.pop3server.mailbox.MailboxAdapter;
+import org.apache.james.protocols.api.Request;
+import org.apache.james.protocols.api.Response;
+import org.apache.james.protocols.lib.POP3BeforeSMTPHelper;
+import org.apache.james.protocols.lib.Slf4jLoggerAdapter;
+import org.apache.james.protocols.pop3.POP3Response;
+import org.apache.james.protocols.pop3.POP3Session;
+import org.apache.james.protocols.pop3.core.AbstractApopCmdHandler;
+import org.apache.james.protocols.pop3.mailbox.Mailbox;
+
+public class ApopCmdHandler extends AbstractApopCmdHandler {
+
+ private MailboxManager manager;
+
+
+ @Resource(name = "mailboxmanager")
+ public void setMailboxManager(MailboxManager manager) {
+ this.manager = manager;
+ }
+
+ @Override
+ public Response onCommand(POP3Session session, Request request) {
+ Response response = super.onCommand(session, request);
+ if (POP3Response.OK_RESPONSE.equals(response.getRetCode())) {
+ POP3BeforeSMTPHelper.addIPAddress(session.getRemoteAddress().getAddress().getHostAddress());
+ }
+ return response;
+ }
+
+ @Override
+ protected Mailbox auth(POP3Session session, String apopTimestamp, String user, String digest) throws Exception {
+ MailboxSession mSession = null;
+
+ String plaintextpassword = "serverpass";
+
+ try {
+ final String toHash = apopTimestamp.trim()+plaintextpassword;
+
+ if(!getMD5(toHash).equals(digest))
+ {
+ System.out.println("Digests does not match");
+ return null;
+ }
+
+
+ session.setUser(user);
+
+ mSession = manager.createSystemSession(session.getUser(), new Slf4jLoggerAdapter(session.getLogger()));
+ manager.startProcessingRequest(mSession);
+ MailboxPath inbox = MailboxPath.inbox(mSession);
+
+ // check if the mailbox exists, if not create it
+ if (!manager.mailboxExists(inbox, mSession)) {
+ manager.createMailbox(inbox, mSession);
+ }
+ MessageManager mailbox = manager.getMailbox(MailboxPath.inbox(mSession), mSession);
+ return new MailboxAdapter(manager, mailbox, mSession);
+ } catch (BadCredentialsException e) {
+ return null;
+ } catch (MailboxException e) {
+ throw new IOException("Unable to access mailbox for user " + session.getUser(), e);
+ } finally {
+ if (mSession != null) {
+ manager.endProcessingRequest(mSession);
+ }
+ }
+
+ }
+
+ private static String getMD5(final String input) {
+ try {
+ final MessageDigest md = MessageDigest.getInstance("MD5");
+ final byte[] messageDigest = md.digest(input.getBytes());
+ final BigInteger number = new BigInteger(1, messageDigest);
+ String hashtext = number.toString(16);
+ // Now we need to zero pad it if you actually want the full 32 chars.
+ while (hashtext.length() < 32) {
+ hashtext = "0" + hashtext;
+ }
+ return hashtext;
+ }
+ catch (final NoSuchAlgorithmException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+}
+
diff --git a/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/test/java/org/apache/geronimo/javamail/testserver/MailServer.java b/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/test/java/org/apache/geronimo/javamail/testserver/MailServer.java
new file mode 100644
index 0000000..0506249
--- /dev/null
+++ b/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/test/java/org/apache/geronimo/javamail/testserver/MailServer.java
@@ -0,0 +1,583 @@
+/**
+ * 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.geronimo.javamail.testserver;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.InetAddress;
+import java.net.Socket;
+import java.net.URL;
+import java.net.URLDecoder;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Semaphore;
+
+import javax.mail.Flags;
+import javax.mail.internet.MimeMessage;
+import javax.net.ssl.SSLSocketFactory;
+
+import org.apache.commons.configuration.DefaultConfigurationBuilder;
+import org.apache.james.dnsservice.api.DNSService;
+import org.apache.james.domainlist.api.DomainListException;
+import org.apache.james.domainlist.api.mock.SimpleDomainList;
+import org.apache.james.filesystem.api.mock.MockFileSystem;
+import org.apache.james.imap.encode.main.DefaultImapEncoderFactory;
+import org.apache.james.imap.encode.main.DefaultLocalizer;
+import org.apache.james.imap.main.DefaultImapDecoderFactory;
+import org.apache.james.imap.processor.main.DefaultImapProcessorFactory;
+import org.apache.james.imapserver.netty.IMAPServer;
+import org.apache.james.mailbox.MailboxSession;
+import org.apache.james.mailbox.MessageManager;
+import org.apache.james.mailbox.acl.GroupMembershipResolver;
+import org.apache.james.mailbox.acl.MailboxACLResolver;
+import org.apache.james.mailbox.acl.SimpleGroupMembershipResolver;
+import org.apache.james.mailbox.acl.UnionMailboxACLResolver;
+import org.apache.james.mailbox.inmemory.InMemoryMailboxSessionMapperFactory;
+import org.apache.james.mailbox.model.MailboxConstants;
+import org.apache.james.mailbox.model.MailboxPath;
+import org.apache.james.mailbox.store.Authenticator;
+import org.apache.james.mailbox.store.StoreMailboxManager;
+import org.apache.james.mailrepository.mock.MockMailRepositoryStore;
+import org.apache.james.pop3server.netty.POP3Server;
+import org.apache.james.protocols.lib.PortUtil;
+import org.apache.james.protocols.lib.mock.MockProtocolHandlerLoader;
+import org.apache.james.queue.api.MailQueue;
+import org.apache.james.queue.api.MailQueue.MailQueueItem;
+import org.apache.james.queue.api.MailQueueFactory;
+import org.apache.james.queue.file.FileMailQueueFactory;
+import org.apache.james.rrt.api.RecipientRewriteTable;
+import org.apache.james.rrt.api.RecipientRewriteTableException;
+import org.apache.james.smtpserver.netty.SMTPServer;
+import org.apache.james.user.api.UsersRepositoryException;
+import org.apache.james.user.lib.mock.MockUsersRepository;
+import org.apache.mailet.HostAddress;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+//James based POP3 or IMAP or SMTP server (for unittesting only)
+public class MailServer {
+
+ private POP3Server pop3Server;
+ private IMAPServer imapServer;
+ private SMTPServer smtpServer;
+ private AlterableDNSServer dnsServer;
+ private final MockUsersRepository usersRepository = new MockUsersRepository();
+ private final MockFileSystem fileSystem = new MockFileSystem();
+ private MockProtocolHandlerLoader protocolHandlerChain;
+ private StoreMailboxManager<Long> mailboxManager;
+
+ private MockMailRepositoryStore store;
+ private DNSService dnsService;
+ private MailQueueFactory queueFactory;
+ private MailQueue queue;
+ private final Semaphore sem = new Semaphore(0);
+
+ public void ensureMsgCount(final int count) throws InterruptedException {
+ sem.acquire(count);
+ }
+
+ private class Fetcher extends Thread {
+
+ private final MailQueue queue;
+ private final MessageManager mailbox;
+ private final MailboxSession session;
+
+ Fetcher(final MailQueue queue, final MessageManager mailbox, final MailboxSession session) {
+ super();
+ this.queue = queue;
+ this.mailbox = mailbox;
+ this.session = session;
+ }
+
+ @Override
+ public void run() {
+ while (true) {
+ try {
+ System.out.println("Await new mail ...");
+ final MailQueueItem item = queue.deQueue();
+ System.out.println("got it");
+ final MimeMessage msg = item.getMail().getMessage();
+ final ByteArrayOutputStream bout = new ByteArrayOutputStream();
+ msg.writeTo(bout);
+ mailbox.appendMessage(new ByteArrayInputStream(bout.toByteArray()), new Date(), session, true, new Flags());
+ item.done(true);
+ sem.release();
+ System.out.println("mail copied over");
+ } catch (final Exception e) {
+ e.printStackTrace();
+ return;
+ }
+ }
+ }
+
+ }
+
+ public MailServer() {
+ super();
+ try {
+ usersRepository.addUser("serveruser", "serverpass");
+ } catch (final UsersRepositoryException e) {
+ throw new RuntimeException(e);
+ }
+
+ }
+
+ public void start(final SmtpTestConfiguration smtpConfig, final Pop3TestConfiguration pop3Config, final ImapTestConfiguration imapConfig)
+ throws Exception {
+ setUpServiceManager();
+
+ imapServer = new IMAPServer();
+
+ imapServer.setImapEncoder(DefaultImapEncoderFactory.createDefaultEncoder(new DefaultLocalizer(), false));
+ imapServer.setImapDecoder(DefaultImapDecoderFactory.createDecoder());
+
+ pop3Server = new POP3Server();
+ pop3Server.setProtocolHandlerLoader(protocolHandlerChain);
+
+ smtpServer = new SMTPServer() {
+ @Override
+ protected java.lang.Class<? extends org.apache.james.protocols.lib.handler.HandlersPackage> getJMXHandlersPackage() {
+ return RefinedJMXHandlersLoader.class;
+ };
+
+ };
+ smtpServer.setProtocolHandlerLoader(protocolHandlerChain);
+ smtpServer.setDNSService(dnsServer);
+
+ imapServer.setFileSystem(fileSystem);
+ pop3Server.setFileSystem(fileSystem);
+ smtpServer.setFileSystem(fileSystem);
+
+ final Logger log = LoggerFactory.getLogger("Mock");
+
+ imapServer.setLog(log);
+ pop3Server.setLog(log);
+ smtpServer.setLog(log);
+
+ final MailboxPath mailboxPath = new MailboxPath(MailboxConstants.USER_NAMESPACE, "serveruser", "INBOX");
+ final MailboxSession session = mailboxManager.login("serveruser", "serverpass", LoggerFactory.getLogger("Test"));
+
+ if (!mailboxManager.mailboxExists(mailboxPath, session)) {
+ mailboxManager.createMailbox(mailboxPath, session);
+ }
+
+ imapServer.setImapProcessor(DefaultImapProcessorFactory.createXListSupportingProcessor(mailboxManager, null, null));//new StoreSubscriptionManager(new InMemoryMailboxSessionMapperFactory()), null));
+
+ //setupTestMails(session, mailboxManager.getMailbox(mailboxPath, session));
+
+ new Fetcher(queue, mailboxManager.getMailbox(mailboxPath, session), session).start();
+
+ smtpConfig.init();
+ pop3Config.init();
+ imapConfig.init();
+
+ smtpServer.configure(smtpConfig);
+ pop3Server.configure(pop3Config);
+ imapServer.configure(imapConfig);
+
+ smtpServer.init();
+ pop3Server.init();
+ imapServer.init();
+
+ }
+
+ public void stop() throws Exception {
+
+ if (protocolHandlerChain != null) {
+ protocolHandlerChain.dispose();
+ }
+
+ if (imapServer != null) {
+ imapServer.destroy();
+ }
+
+ if (pop3Server != null) {
+ pop3Server.destroy();
+ }
+
+ if (smtpServer != null) {
+ smtpServer.destroy();
+ }
+
+ }
+
+ /* protected void setupTestMailsx(MailboxSession session, MessageManager mailbox) throws MailboxException {
+ mailbox.appendMessage(new ByteArrayInputStream(content), new Date(), session, true, new Flags());
+ byte[] content2 = ("EMPTY").getBytes();
+ mailbox.appendMessage(new ByteArrayInputStream(content2), new Date(), session, true, new Flags());
+ }*/
+
+ protected void setUpServiceManager() throws Exception {
+ protocolHandlerChain = new MockProtocolHandlerLoader();
+ protocolHandlerChain.put("usersrepository", usersRepository);
+
+ final InMemoryMailboxSessionMapperFactory factory = new InMemoryMailboxSessionMapperFactory();
+ final MailboxACLResolver aclResolver = new UnionMailboxACLResolver();
+ final GroupMembershipResolver groupMembershipResolver = new SimpleGroupMembershipResolver();
+ mailboxManager = new StoreMailboxManager<Long>(factory, new Authenticator() {
+
+ public boolean isAuthentic(final String userid, final CharSequence passwd) {
+ try {
+ return usersRepository.test(userid, passwd.toString());
+ } catch (final UsersRepositoryException e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
+ }, aclResolver, groupMembershipResolver);
+ mailboxManager.init();
+
+ protocolHandlerChain.put("mailboxmanager", mailboxManager);
+
+ protocolHandlerChain.put("fileSystem", fileSystem);
+
+ //smtp
+ dnsServer = new AlterableDNSServer();
+ store = new MockMailRepositoryStore();
+ protocolHandlerChain.put("mailStore", store);
+ protocolHandlerChain.put("dnsservice", dnsServer);
+ protocolHandlerChain.put("org.apache.james.smtpserver.protocol.DNSService", dnsService);
+
+ protocolHandlerChain.put("recipientrewritetable", new RecipientRewriteTable() {
+
+ public void addRegexMapping(final String user, final String domain, final String regex) throws RecipientRewriteTableException {
+ throw new UnsupportedOperationException("Not implemented");
+ }
+
+ public void removeRegexMapping(final String user, final String domain, final String regex)
+ throws RecipientRewriteTableException {
+ throw new UnsupportedOperationException("Not implemented");
+ }
+
+ public void addAddressMapping(final String user, final String domain, final String address)
+ throws RecipientRewriteTableException {
+ throw new UnsupportedOperationException("Not implemented");
+ }
+
+ public void removeAddressMapping(final String user, final String domain, final String address)
+ throws RecipientRewriteTableException {
+ throw new UnsupportedOperationException("Not implemented");
+ }
+
+ public void addErrorMapping(final String user, final String domain, final String error) throws RecipientRewriteTableException {
+ throw new UnsupportedOperationException("Not implemented");
+ }
+
+ public void removeErrorMapping(final String user, final String domain, final String error)
+ throws RecipientRewriteTableException {
+ throw new UnsupportedOperationException("Not implemented");
+ }
+
+ public Collection<String> getUserDomainMappings(final String user, final String domain) throws RecipientRewriteTableException {
+ throw new UnsupportedOperationException("Not implemented");
+ }
+
+ public void addMapping(final String user, final String domain, final String mapping) throws RecipientRewriteTableException {
+ throw new UnsupportedOperationException("Not implemented");
+ }
+
+ public void removeMapping(final String user, final String domain, final String mapping) throws RecipientRewriteTableException {
+ throw new UnsupportedOperationException("Not implemented");
+ }
+
+ public Map<String, Collection<String>> getAllMappings() throws RecipientRewriteTableException {
+ throw new UnsupportedOperationException("Not implemented");
+ }
+
+ public void addAliasDomainMapping(final String aliasDomain, final String realDomain) throws RecipientRewriteTableException {
+ throw new UnsupportedOperationException("Not implemented");
+ }
+
+ public void removeAliasDomainMapping(final String aliasDomain, final String realDomain) throws RecipientRewriteTableException {
+ throw new UnsupportedOperationException("Not implemented");
+ }
+
+ public Collection<String> getMappings(final String user, final String domain) throws ErrorMappingException,
+ RecipientRewriteTableException {
+ throw new UnsupportedOperationException("Not implemented");
+ }
+ });
+
+ protocolHandlerChain.put("org.apache.james.smtpserver.protocol.DNSService", dnsService);
+
+ final FileMailQueueFactory ff = new FileMailQueueFactory();// MockMailQueueFactory();
+ ff.setFileSystem(fileSystem);
+ queueFactory = ff;
+
+ queue = queueFactory.getQueue(MailQueueFactory.SPOOL);
+ protocolHandlerChain.put("mailqueuefactory", queueFactory);
+ protocolHandlerChain.put("domainlist", new SimpleDomainList() {
+
+ @Override
+ public String getDefaultDomain() {
+ return "localhost";
+ }
+
+ @Override
+ public String[] getDomains() throws DomainListException {
+ return new String[] { "localhost" };
+ }
+
+ @Override
+ public boolean containsDomain(final String serverName) {
+ return "localhost".equals(serverName);
+ }
+ });
+
+ }
+
+ /**
+ * @return the queue
+ */
+ public MailQueue getQueue() {
+ return queue;
+ }
+
+ public static File getAbsoluteFilePathFromClassPath(final String fileNameFromClasspath) {
+
+ File configFile = null;
+ final URL configURL = MailServer.class.getClassLoader().getResource(fileNameFromClasspath);
+ if (configURL != null) {
+ try {
+ configFile = new File(URLDecoder.decode(configURL.getFile(), "UTF-8"));
+ } catch (final UnsupportedEncodingException e) {
+ return null;
+ }
+
+ if (configFile.exists() && configFile.canRead()) {
+ return configFile;
+ } else {
+
+ System.out.println("Cannot read from {}, maybe the file does not exists? " + configFile.getAbsolutePath());
+ }
+
+ } else {
+ System.out.println("Failed to load " + fileNameFromClasspath);
+ }
+
+ return null;
+
+ }
+
+ public static abstract class AbstractTestConfiguration extends DefaultConfigurationBuilder {
+
+ private final int listenerPort = PortUtil.getNonPrivilegedPort();
+
+ /**
+ * @return the listenerPort
+ */
+ public int getListenerPort() {
+ return listenerPort;
+ }
+
+ public AbstractTestConfiguration enableSSL(final boolean enableStartTLS, final boolean enableSSL) {
+ addProperty("tls.[@startTLS]", enableStartTLS);
+ addProperty("tls.[@socketTLS]", enableSSL);
+ addProperty("tls.keystore", "file://" + getAbsoluteFilePathFromClassPath("dummykeystore.jks").getAbsolutePath());
+ addProperty("tls.secret", "123456");
+ addProperty("tls.provider", "org.bouncycastle.jce.provider.BouncyCastleProvider");
+ return this;
+ }
+
+ public void init() {
+ addProperty("[@enabled]", true);
+ addProperty("bind", "127.0.0.1:" + this.listenerPort);
+ addProperty("connectiontimeout", "360000");
+ //addProperty("jmxName", getServertype().name()+"on"+this.listenerPort);
+
+ }
+
+ }
+
+ public static class Pop3TestConfiguration extends AbstractTestConfiguration {
+
+ @Override
+ public void init() {
+ super.init();
+
+ addProperty("helloName", "pop3 on port " + getListenerPort());
+
+ addProperty("handlerchain.[@coreHandlersPackage]", RefinedCoreCmdHandlerLoader.class.getName());
+
+ }
+
+ }
+
+ public static class ImapTestConfiguration extends AbstractTestConfiguration {
+
+ @Override
+ public void init() {
+ super.init();
+
+ addProperty("helloName", "imap on port " + getListenerPort());
+
+ }
+
+ }
+
+ public static class SmtpTestConfiguration extends AbstractTestConfiguration {
+
+ @Override
+ public void init() {
+ super.init();
+ addProperty("handlerchain.handler[@class]", RefinedSmtpCoreCmdHandlerLoader.class.getName());
+
+ }
+
+ public SmtpTestConfiguration setRequireAuth(final boolean requireAuth) {
+
+ addProperty("authRequired", requireAuth);
+ return this;
+ }
+
+ public SmtpTestConfiguration setHeloEhloEnforcement(final boolean heloEhloEnforcement) {
+
+ addProperty("heloEhloEnforcement", heloEhloEnforcement);
+ return this;
+ }
+
+ }
+
+ public static class DummySocketFactory extends SSLSocketFactory {
+
+ @Override
+ public Socket createSocket(final String host, final int port) throws IOException, UnknownHostException {
+ throw new IOException("dummy socket factory");
+ }
+
+ @Override
+ public Socket createSocket(final InetAddress host, final int port) throws IOException {
+ throw new IOException("dummy socket factory");
+ }
+
+ @Override
+ public Socket createSocket(final String host, final int port, final InetAddress localHost, final int localPort) throws IOException,
+ UnknownHostException {
+ throw new IOException("dummy socket factory");
+ }
+
+ @Override
+ public Socket createSocket(final InetAddress address, final int port, final InetAddress localAddress, final int localPort)
+ throws IOException {
+ throw new IOException("dummy socket factory");
+ }
+
+ @Override
+ public Socket createSocket(final Socket arg0, final String arg1, final int arg2, final boolean arg3) throws IOException {
+ throw new IOException("dummy socket factory");
+ }
+
+ @Override
+ public String[] getDefaultCipherSuites() {
+ return new String[0];
+ }
+
+ @Override
+ public String[] getSupportedCipherSuites() {
+ return new String[0];
+ }
+
+ }
+
+ private final class AlterableDNSServer implements DNSService {
+
+ private InetAddress localhostByName = null;
+
+ public Collection<String> findMXRecords(final String hostname) {
+ final List<String> res = new ArrayList<String>();
+ if (hostname == null) {
+ return res;
+ }
+ if ("james.apache.org".equals(hostname)) {
+ res.add("nagoya.apache.org");
+ }
+ return res;
+ }
+
+ public Iterator<HostAddress> getSMTPHostAddresses(final String domainName) {
+ throw new UnsupportedOperationException("Unimplemented mock service");
+ }
+
+ public InetAddress[] getAllByName(final String host) throws UnknownHostException {
+ return new InetAddress[] { getByName(host) };
+ }
+
+ public InetAddress getByName(final String host) throws UnknownHostException {
+ if (getLocalhostByName() != null) {
+ if ("127.0.0.1".equals(host)) {
+ return getLocalhostByName();
+ }
+ }
+
+ if ("0.0.0.0".equals(host)) {
+ return InetAddress.getByName("0.0.0.0");
+ }
+
+ if ("james.apache.org".equals(host)) {
+ return InetAddress.getByName("james.apache.org");
+ }
+
+ if ("abgsfe3rsf.de".equals(host)) {
+ throw new UnknownHostException();
+ }
+
+ if ("128.0.0.1".equals(host) || "192.168.0.1".equals(host) || "127.0.0.1".equals(host) || "127.0.0.0".equals(host)
+ || "255.0.0.0".equals(host) || "255.255.255.255".equals(host)) {
+ return InetAddress.getByName(host);
+ }
+
+ throw new UnsupportedOperationException("getByName not implemented in mock for host: " + host);
+ }
+
+ public Collection<String> findTXTRecords(final String hostname) {
+ final List<String> res = new ArrayList<String>();
+ if (hostname == null) {
+ return res;
+ }
+
+ if ("2.0.0.127.bl.spamcop.net.".equals(hostname)) {
+ res.add("Blocked - see http://www.spamcop.net/bl.shtml?127.0.0.2");
+ }
+ return res;
+ }
+
+ public InetAddress getLocalhostByName() {
+ return localhostByName;
+ }
+
+ public void setLocalhostByName(final InetAddress localhostByName) {
+ this.localhostByName = localhostByName;
+ }
+
+ public String getHostName(final InetAddress addr) {
+ return addr.getHostName();
+ }
+
+ public InetAddress getLocalHost() throws UnknownHostException {
+ return InetAddress.getLocalHost();
+ }
+ }
+
+}
diff --git a/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/test/java/org/apache/geronimo/javamail/testserver/RefinedCoreCmdHandlerLoader.java b/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/test/java/org/apache/geronimo/javamail/testserver/RefinedCoreCmdHandlerLoader.java
new file mode 100644
index 0000000..d2c0e9b
--- /dev/null
+++ b/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/test/java/org/apache/geronimo/javamail/testserver/RefinedCoreCmdHandlerLoader.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.geronimo.javamail.testserver;
+
+
+
+public class RefinedCoreCmdHandlerLoader extends org.apache.james.pop3server.core.CoreCmdHandlerLoader {
+
+ public RefinedCoreCmdHandlerLoader() {
+ super();
+ getHandlers().add(ApopCmdHandler.class.getName());
+
+ }
+
+
+
+}
diff --git a/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/test/java/org/apache/geronimo/javamail/testserver/RefinedJMXHandlersLoader.java b/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/test/java/org/apache/geronimo/javamail/testserver/RefinedJMXHandlersLoader.java
new file mode 100644
index 0000000..32fd915
--- /dev/null
+++ b/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/test/java/org/apache/geronimo/javamail/testserver/RefinedJMXHandlersLoader.java
@@ -0,0 +1,48 @@
+/**
+ * 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.geronimo.javamail.testserver;
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.james.protocols.lib.handler.HandlersPackage;
+import org.apache.james.smtpserver.jmx.CommandHandlerResultJMXMonitor;
+import org.apache.james.smtpserver.jmx.ConnectHandlerResultJMXMonitor;
+import org.apache.james.smtpserver.jmx.HookResultJMXMonitor;
+//import org.apache.james.smtpserver.jmx.LineHandlerResultJMXMonitor;
+
+public class RefinedJMXHandlersLoader implements HandlersPackage {
+
+ private final List<String> handlers = new ArrayList<String>();
+
+ public RefinedJMXHandlersLoader() {
+ handlers.add(ConnectHandlerResultJMXMonitor.class.getName());
+ handlers.add(CommandHandlerResultJMXMonitor.class.getName());
+ //handlers.add(LineHandlerResultJMXMonitor.class.getName());
+ handlers.add(HookResultJMXMonitor.class.getName());
+ }
+
+ /**
+ * @see org.apache.james.protocols.api.handler.HandlersPackage#getHandlers()
+ */
+ public List<String> getHandlers() {
+ return handlers;
+ }
+
+}
+
diff --git a/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/test/java/org/apache/geronimo/javamail/testserver/RefinedSmtpCoreCmdHandlerLoader.java b/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/test/java/org/apache/geronimo/javamail/testserver/RefinedSmtpCoreCmdHandlerLoader.java
new file mode 100644
index 0000000..ba7f59d
--- /dev/null
+++ b/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/test/java/org/apache/geronimo/javamail/testserver/RefinedSmtpCoreCmdHandlerLoader.java
@@ -0,0 +1,146 @@
+/**
+ * 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.geronimo.javamail.testserver;
+
+ /****************************************************************
+ * 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. *
+ ****************************************************************/
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.james.protocols.api.handler.CommandDispatcher;
+import org.apache.james.protocols.api.handler.CommandHandlerResultLogger;
+import org.apache.james.protocols.lib.handler.HandlersPackage;
+import org.apache.james.protocols.smtp.core.ExpnCmdHandler;
+import org.apache.james.protocols.smtp.core.HeloCmdHandler;
+import org.apache.james.protocols.smtp.core.HelpCmdHandler;
+import org.apache.james.protocols.smtp.core.NoopCmdHandler;
+import org.apache.james.protocols.smtp.core.PostmasterAbuseRcptHook;
+import org.apache.james.protocols.smtp.core.QuitCmdHandler;
+import org.apache.james.protocols.smtp.core.ReceivedDataLineFilter;
+import org.apache.james.protocols.smtp.core.RsetCmdHandler;
+import org.apache.james.protocols.smtp.core.VrfyCmdHandler;
+import org.apache.james.protocols.smtp.core.esmtp.AuthCmdHandler;
+import org.apache.james.protocols.smtp.core.esmtp.EhloCmdHandler;
+import org.apache.james.protocols.smtp.core.esmtp.MailSizeEsmtpExtension;
+import org.apache.james.protocols.smtp.core.esmtp.StartTlsCmdHandler;
+import org.apache.james.protocols.smtp.core.log.HookResultLogger;
+import org.apache.james.smtpserver.AddDefaultAttributesMessageHook;
+import org.apache.james.smtpserver.AuthRequiredToRelayRcptHook;
+import org.apache.james.smtpserver.DataLineJamesMessageHookHandler;
+import org.apache.james.smtpserver.JamesDataCmdHandler;
+import org.apache.james.smtpserver.JamesMailCmdHandler;
+import org.apache.james.smtpserver.JamesRcptCmdHandler;
+import org.apache.james.smtpserver.JamesWelcomeMessageHandler;
+import org.apache.james.smtpserver.SendMailHandler;
+import org.apache.james.smtpserver.SenderAuthIdentifyVerificationRcptHook;
+import org.apache.james.smtpserver.UsersRepositoryAuthHook;
+
+/**
+ * This class represent the base command handlers which are shipped with james.
+ */
+public class RefinedSmtpCoreCmdHandlerLoader implements HandlersPackage {
+
+ private final String COMMANDDISPATCHER = CommandDispatcher.class.getName();
+ private final String AUTHCMDHANDLER = AuthCmdHandler.class.getName();
+ private final String DATACMDHANDLER = JamesDataCmdHandler.class.getName();
+ private final String EHLOCMDHANDLER = EhloCmdHandler.class.getName();
+ private final String EXPNCMDHANDLER = ExpnCmdHandler.class.getName();
+ private final String HELOCMDHANDLER = HeloCmdHandler.class.getName();
+ private final String HELPCMDHANDLER = HelpCmdHandler.class.getName();
+ private final String MAILCMDHANDLER = JamesMailCmdHandler.class.getName();
+ private final String NOOPCMDHANDLER = NoopCmdHandler.class.getName();
+ private final String QUITCMDHANDLER = QuitCmdHandler.class.getName();
+ private final String RCPTCMDHANDLER = JamesRcptCmdHandler.class.getName();
+ private final String RSETCMDHANDLER = RsetCmdHandler.class.getName();
+ private final String VRFYCMDHANDLER = VrfyCmdHandler.class.getName();
+ private final String MAILSIZEHOOK = MailSizeEsmtpExtension.class.getName();
+ private final String WELCOMEMESSAGEHANDLER = JamesWelcomeMessageHandler.class.getName();
+ private final String USERSREPOSITORYAUTHHANDLER = UsersRepositoryAuthHook.class.getName();
+ private final String POSTMASTERABUSEHOOK = PostmasterAbuseRcptHook.class.getName();
+ private final String AUTHREQUIREDTORELAY = AuthRequiredToRelayRcptHook.class.getName();
+ private final String SENDERAUTHIDENTITYVERIFICATION = SenderAuthIdentifyVerificationRcptHook.class.getName();
+ private final String RECEIVEDDATALINEFILTER = ReceivedDataLineFilter.class.getName();
+ private final String DATALINEMESSAGEHOOKHANDLER = DataLineJamesMessageHookHandler.class.getName();
+ private final String STARTTLSHANDLER = StartTlsCmdHandler.class.getName();
+
+ // MessageHooks
+ private final String ADDDEFAULTATTRIBUTESHANDLER = AddDefaultAttributesMessageHook.class.getName();
+ private final String SENDMAILHANDLER = SendMailHandler.class.getName();
+
+ // logging stuff
+ private final String COMMANDHANDLERRESULTLOGGER = CommandHandlerResultLogger.class.getName();
+ private final String HOOKRESULTLOGGER = HookResultLogger.class.getName();
+
+ private final List<String> commands = new LinkedList<String>();
+
+ public RefinedSmtpCoreCmdHandlerLoader() {
+ // Insert the base commands in the Map
+ commands.add(WELCOMEMESSAGEHANDLER);
+ commands.add(COMMANDDISPATCHER);
+ commands.add(AUTHCMDHANDLER);
+ commands.add(DATACMDHANDLER);
+ commands.add(EHLOCMDHANDLER);
+ commands.add(EXPNCMDHANDLER);
+ commands.add(HELOCMDHANDLER);
+ commands.add(HELPCMDHANDLER);
+ commands.add(MAILCMDHANDLER);
+ commands.add(NOOPCMDHANDLER);
+ commands.add(QUITCMDHANDLER);
+ commands.add(RCPTCMDHANDLER);
+ commands.add(RSETCMDHANDLER);
+ commands.add(VRFYCMDHANDLER);
+ commands.add(MAILSIZEHOOK);
+ commands.add(USERSREPOSITORYAUTHHANDLER);
+ commands.add(AUTHREQUIREDTORELAY);
+ commands.add(SENDERAUTHIDENTITYVERIFICATION);
+ commands.add(POSTMASTERABUSEHOOK);
+ commands.add(RECEIVEDDATALINEFILTER);
+ commands.add(DATALINEMESSAGEHOOKHANDLER);
+ commands.add(STARTTLSHANDLER);
+ // Add the default messageHooks
+ commands.add(ADDDEFAULTATTRIBUTESHANDLER);
+ commands.add(SENDMAILHANDLER);
+
+ // Add logging stuff
+ commands.add(COMMANDHANDLERRESULTLOGGER);
+ commands.add(HOOKRESULTLOGGER);
+ }
+
+ /**
+ * @see org.apache.james.protocols.api.handler.HandlersPackage#getHandlers()
+ */
+ public List<String> getHandlers() {
+ return commands;
+ }
+}
+
diff --git a/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/test/java/org/apache/geronimo/javamail/transport/smtp/SMTPTransportTest.java b/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/test/java/org/apache/geronimo/javamail/transport/smtp/SMTPTransportTest.java
new file mode 100644
index 0000000..d0f9ead
--- /dev/null
+++ b/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/test/java/org/apache/geronimo/javamail/transport/smtp/SMTPTransportTest.java
@@ -0,0 +1,57 @@
+/**
+ * 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.geronimo.javamail.transport.smtp;
+
+import java.util.Properties;
+
+import javax.mail.Session;
+import javax.mail.Transport;
+import javax.mail.internet.InternetAddress;
+import javax.mail.internet.MimeMessage;
+
+import org.apache.geronimo.javamail.testserver.AbstractProtocolTest;
+
+public class SMTPTransportTest extends AbstractProtocolTest {
+
+ public void testSSLEnable() throws Exception {
+
+
+ smtpConf.enableSSL(false, false);
+
+ start();
+
+ Properties props = new Properties();
+ props.setProperty("mail.transport.protocol", "smtp");
+ props.setProperty("mail.smtp.port", String.valueOf(smtpConf.getListenerPort()));
+ props.setProperty("mail.debug", "true");
+
+ Session jmsession = Session.getInstance(props);
+ Transport t = jmsession.getTransport();
+ t.connect();
+
+ MimeMessage msg = new MimeMessage(jmsession);
+ msg.setFrom(new InternetAddress("test@apache.org"));
+ msg.setSubject("Hi!");
+ msg.setText("All your base are belong to us");
+
+
+ t.sendMessage(msg, new InternetAddress[]{new InternetAddress("testto@apache.org")});
+
+ }
+
+
+}
diff --git a/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/test/resources/dummykeystore.jks b/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/test/resources/dummykeystore.jks
new file mode 100644
index 0000000..cb140cd
--- /dev/null
+++ b/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/test/resources/dummykeystore.jks
Binary files differ
diff --git "a/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/test/resources/encoded_filename_A\314\210U\314\210O\314\210\050test\051.pdf" "b/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/test/resources/encoded_filename_A\314\210U\314\210O\314\210\050test\051.pdf"
new file mode 100644
index 0000000..8671636
--- /dev/null
+++ "b/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/test/resources/encoded_filename_A\314\210U\314\210O\314\210\050test\051.pdf"
Binary files differ
diff --git a/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/test/resources/messages/multipart.msg b/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/test/resources/messages/multipart.msg
index fa8bc6a..8fbc2af 100644
--- a/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/test/resources/messages/multipart.msg
+++ b/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/test/resources/messages/multipart.msg
@@ -1,19 +1,19 @@
-Date: Sat, 11 Oct 2008 00:48:01 +0200 (CEST)
-From: test@localhost
-To: test@localhost
-Message-ID: urn:uuid:219365EB848AD9CACB1223678880948
-Subject: Test
-MIME-Version: 1.0
-Content-Type: multipart/mixed; boundary="----=_Part_0_6727097.1223678881682"
-
-------=_Part_0_6727097.1223678881682
-Content-Type: text/plain; charset=us-ascii
-Content-Transfer-Encoding: 7bit
-
-First part
-------=_Part_0_6727097.1223678881682
-Content-Type: text/plain; charset=us-ascii
-Content-Transfer-Encoding: 7bit
-
-Second part
-------=_Part_0_6727097.1223678881682--
+Date: Sat, 11 Oct 2008 00:48:01 +0200 (CEST)
+From: from@localhost
+To: serveruser@localhost
+Message-ID: urn:uuid:219365EB848AD9CACB1223678880948
+Subject: Test
+MIME-Version: 1.0
+Content-Type: multipart/mixed; boundary="----=_Part_0_6727097.1223678881682"
+
+------=_Part_0_6727097.1223678881682
+Content-Type: text/plain; charset=us-ascii
+Content-Transfer-Encoding: 7bit
+
+First part
+------=_Part_0_6727097.1223678881682
+Content-Type: text/plain; charset=us-ascii
+Content-Transfer-Encoding: 7bit
+
+Second part
+------=_Part_0_6727097.1223678881682--
diff --git a/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/test/resources/messages/simple.msg b/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/test/resources/messages/simple.msg
index 6619c29..9e429ed 100644
--- a/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/test/resources/messages/simple.msg
+++ b/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/test/resources/messages/simple.msg
@@ -1,11 +1,11 @@
-Date: Sat, 11 Oct 2008 00:48:01 +0200 (CEST)
-From: test@localhost
-To: test@localhost
-Subject: Test Foo
-MIME-Version: 1.0
-Content-Type: text/plain; charset=us-ascii
-Content-Transfer-Encoding: 7bit
-
-Foo Bar
-
-
+Date: Sat, 11 Oct 2008 00:48:01 +0200 (CEST)
+From: from@localhost
+To: serveruser@localhost
+Subject: Test Foo
+MIME-Version: 1.0
+Content-Type: text/plain; charset=us-ascii
+Content-Transfer-Encoding: 7bit
+
+Foo Bar
+
+
diff --git a/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/test/resources/pdf-test.pdf b/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/test/resources/pdf-test.pdf
new file mode 100644
index 0000000..8671636
--- /dev/null
+++ b/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/test/resources/pdf-test.pdf
Binary files differ
diff --git a/geronimo-javamail_1.4/pom.xml b/geronimo-javamail_1.4/pom.xml
index 1e4cd5c..2eb3545 100644
--- a/geronimo-javamail_1.4/pom.xml
+++ b/geronimo-javamail_1.4/pom.xml
@@ -1,33 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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
+<!-- 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. -->
- http://www.apache.org/licenses/LICENSE-2.0
+<!-- $Rev$ $Date: 2014-07-20 09:36:35 +0200 (So, 20. Jul 2014)
+ $ -->
- 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.
--->
-
-<!-- $Rev$ $Date$ -->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.geronimo.genesis</groupId>
<artifactId>genesis-java5-flava</artifactId>
- <version>2.0</version>
+ <version>2.2</version>
</parent>
<groupId>org.apache.geronimo.javamail</groupId>
@@ -35,7 +29,7 @@
<name>Geronimo JavaMail 1.4</name>
<packaging>pom</packaging>
- <version>1.8.5-SNAPSHOT</version>
+ <version>1.9.0-SNAPSHOT</version>
<description>
Geronimmo JavaMail Bundle.
@@ -48,16 +42,16 @@
</scm>
<properties>
- <siteId>javamail/${artifactId}</siteId>
+ <siteId>javamail/${project.artifactId}</siteId>
<projectName>Apache Geronimo Javamail Bundle</projectName>
</properties>
- <url>http://geronimo.apache.org/maven/${siteId}/${version}</url>
+ <url>http://geronimo.apache.org/maven/${siteId}/${project.version}</url>
<distributionManagement>
<site>
<id>apache-website</id>
- <url>${site.deploy.url}/maven/${siteId}/${version}</url>
+ <url>${site.deploy.url}/maven/${siteId}/${project.version}</url>
</site>
</distributionManagement>
@@ -86,7 +80,7 @@
<dependency>
<groupId>org.apache.geronimo.javamail</groupId>
<artifactId>geronimo-javamail_1.4_provider</artifactId>
- <version>${version}</version>
+ <version>${project.version}</version>
</dependency>
<dependency>
@@ -104,12 +98,66 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
- <version>1.0.1</version>
+ <version>2.3</version>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.18</version>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-site-plugin</artifactId>
+ <version>3.3</version>
+ <configuration>
+ <stagingDirectory>${staging.directory}</stagingDirectory>
+ </configuration>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven.doxia</groupId>
+ <artifactId>doxia-module-markdown</artifactId>
+ <version>1.3</version>
+ </dependency>
+ </dependencies>
</plugin>
</plugins>
</pluginManagement>
<plugins>
+
+ <plugin>
+ <groupId>org.apache.rat</groupId>
+ <artifactId>apache-rat-plugin</artifactId>
+ <configuration>
+ <includes>
+ <include>src/**/*</include>
+ <include>pom.xml</include>
+ </includes>
+ <excludes>
+ <exclude>**/*/MANIFEST.MF</exclude>
+ <exclude>.git</exclude>
+ <exclude>.gitignore</exclude>
+ <exclude>.idea</exclude>
+ <exclude>*.iws</exclude>
+ <exclude>*.iml</exclude>
+ <exclude>*.ipr</exclude>
+ <exclude>**/src/test/resources/**/*.bodystructure</exclude>
+ <exclude>**/src/test/resources/**/*.msg</exclude>
+ <exclude>**/resources/OSGI-INF/providers/**/*</exclude>
+ </excludes>
+ </configuration>
+ <executions>
+ <execution>
+ <phase>verify</phase>
+ <goals>
+ <goal>check</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
@@ -126,9 +174,9 @@
<version>[1.5,)</version>
</requireJavaVersion>
- <!-- Allow any Maven >= 2.0.5 -->
+ <!-- Allow any Maven >= 2.0.7 -->
<requireMavenVersion>
- <version>[2.0.5,)</version>
+ <version>[2.0.7,)</version>
</requireMavenVersion>
</rules>
</configuration>
@@ -143,4 +191,84 @@
<module>geronimo-javamail_1.4_mail</module>
</modules>
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>findbugs-maven-plugin</artifactId>
+ <version>3.0.0</version>
+ <configuration>
+ <xmlOutput>true</xmlOutput>
+ <!-- Optional directory to put findbugs xdoc xml report -->
+ <xmlOutputDirectory>target/site</xmlOutputDirectory>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-pmd-plugin</artifactId>
+ <version>3.2</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-project-info-reports-plugin</artifactId>
+ <version>2.7</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>2.9.1</version>
+ <configuration>
+ <notimestamp>true</notimestamp>
+ <show>private</show>
+ </configuration>
+ <reportSets>
+ <reportSet>
+ <reports>
+ <report>javadoc</report>
+ </reports>
+ </reportSet>
+ <reportSet>
+ <inherited>false</inherited>
+ <reports>
+ <report>aggregate</report>
+ </reports>
+ </reportSet>
+ </reportSets>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-report-plugin</artifactId>
+ <version>2.18</version>
+ <configuration>
+ <aggregate>true</aggregate>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>cobertura-maven-plugin</artifactId>
+ <version>2.6</version>
+ <configuration>
+ <formats>
+ <format>html</format>
+ </formats>
+ <aggregate>true</aggregate>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>versions-maven-plugin</artifactId>
+ <version>2.1</version>
+ <reportSets>
+ <reportSet>
+ <reports>
+ <report>dependency-updates-report</report>
+ <report>plugin-updates-report</report>
+ <report>property-updates-report</report>
+ </reports>
+ </reportSet>
+ </reportSets>
+ </plugin>
+ </plugins>
+ </reporting>
+
</project>
diff --git a/geronimo-javamail_1.4/src/site/apt/privacy-policy.apt b/geronimo-javamail_1.4/src/site/apt/privacy-policy.apt
new file mode 100644
index 0000000..b842f21
--- /dev/null
+++ b/geronimo-javamail_1.4/src/site/apt/privacy-policy.apt
@@ -0,0 +1,52 @@
+ ----
+ Privacy Policy
+ -----
+ Olivier Lamy
+ -----
+ 2013-11-13
+ -----
+
+~~ 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.
+
+Privacy Policy
+
+ Information about your use of this website is collected using server access logs and a tracking cookie. The
+ collected information consists of the following:
+
+ [[1]] The IP address from which you access the website;
+
+ [[2]] The type of browser and operating system you use to access our site;
+
+ [[3]] The date and time you access our site;
+
+ [[4]] The pages you visit; and
+
+ [[5]] The addresses of pages from where you followed a link to our site.
+
+ []
+
+ Part of this information is gathered using a tracking cookie set by the
+ {{{http://www.google.com/analytics/}Google Analytics}} service and handled by Google as described in their
+ {{{http://www.google.com/privacy.html}privacy policy}}. See your browser documentation for instructions on how to
+ disable the cookie if you prefer not to share this data with Google.
+
+ We use the gathered information to help us make our site more useful to visitors and to better understand how and
+ when our site is used. We do not track or collect personally identifiable information or associate gathered data
+ with any personally identifying information from other sources.
+
+ By using this website, you consent to the collection of this data in the manner and for the purpose described above.
diff --git a/geronimo-javamail_1.4/src/site/markdown/index.md b/geronimo-javamail_1.4/src/site/markdown/index.md
new file mode 100644
index 0000000..9f1e5b9
--- /dev/null
+++ b/geronimo-javamail_1.4/src/site/markdown/index.md
@@ -0,0 +1,35 @@
+<!---
+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.
+-->
+# Geronimo JavaMail 1.4
+
+Geronimo JavaMail 1.4
+
+## Get started
+
+Just get it from maven
+
+### Core
+
+<pre class="prettyprint linenums"><![CDATA[
+<dependency>
+ <groupId>org.apache.geronimo.javamail</groupId>
+ <artifactId>geronimo-javamail_1.4_provider</artifactId>
+ <version>1.9.0-SNAPSHOT</version>
+</dependency>
+]]></pre>
\ No newline at end of file
diff --git a/geronimo-javamail_1.4/src/site/site.xml b/geronimo-javamail_1.4/src/site/site.xml
new file mode 100644
index 0000000..272648e
--- /dev/null
+++ b/geronimo-javamail_1.4/src/site/site.xml
@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ 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.
+-->
+<project name="Apache Johnzon"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://maven.apache.org/DECORATION/1.0.1"
+ xsi:schemaLocation="http://maven.apache.org/DECORATION/1.0.1
+ http://maven.apache.org/xsd/decoration-1.0.1.xsd">
+ <bannerLeft>
+ <name>Geronimo JavaMail</name>
+ <alt>Geronimo JavaMail</alt>
+ <href>/index.html</href>
+ </bannerLeft>
+ <bannerRight>
+ <src>http://geronimo.apache.org/images/topleft_logo_437x64.gif</src>
+ <href>http://geronimo.apache.org/</href>
+ </bannerRight>
+
+ <custom>
+ <fluidoSkin>
+ <topBarEnabled>true</topBarEnabled>
+ <sideBarEnabled>true</sideBarEnabled>
+ <sourceLineNumbersEnabled>true</sourceLineNumbersEnabled>
+ </fluidoSkin>
+ </custom>
+
+ <skin>
+ <groupId>org.apache.maven.skins</groupId>
+ <artifactId>maven-fluido-skin</artifactId>
+ <version>1.3.0</version>
+ </skin>
+
+ <body>
+
+ <head>
+
+ <script type="text/javascript">
+
+ (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
+ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
+ m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
+ })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
+
+ ga('create', 'UA-3211522-15', 'apache.org');
+ ga('send', 'pageview');
+
+ </script>
+
+ </head>
+
+ <menu name="User Guide">
+ <item name="Home" href="/index.html"/>
+ </menu>
+
+ <menu ref="reports" inherit="bottom"/>
+
+ <menu name="ASF">
+ <item name="How Apache Works" href="http://www.apache.org/foundation/how-it-works.html"/>
+ <item name="Foundation" href="http://www.apache.org/foundation/"/>
+ <item name="Sponsoring Apache" href="http://www.apache.org/foundation/sponsorship.html"/>
+ <item name="Thanks" href="http://www.apache.org/foundation/thanks.html"/>
+ </menu>
+
+ <footer>
+ <div class="row span16"><div>Apache Geronimo, Apache, the Apache feather logo, and the Apache Johnzon project logos are trademarks of The Apache Software Foundation.
+ All other marks mentioned may be trademarks or registered trademarks of their respective owners.</div>
+ <a href="${project.url}/privacy-policy.html">Privacy Policy</a>
+ </div>
+ </footer>
+
+ </body>
+</project>