You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by bt...@apache.org on 2017/09/11 02:36:45 UTC

[01/23] james-project git commit: JAMES-2138 alphabetic ordering of Cassandra Modules

Repository: james-project
Updated Branches:
  refs/heads/master 2c411e8b5 -> 1998ff35a


JAMES-2138 alphabetic ordering of Cassandra Modules


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/9b3adc13
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/9b3adc13
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/9b3adc13

Branch: refs/heads/master
Commit: 9b3adc13770a7460f822a5f353e17c4f3303e4f9
Parents: 5354f23
Author: Matthieu Baechler <ma...@apache.org>
Authored: Mon Sep 4 10:51:33 2017 +0200
Committer: benwa <bt...@linagora.com>
Committed: Sat Sep 9 10:40:29 2017 +0700

----------------------------------------------------------------------
 .../apache/james/CassandraJamesServerMain.java  | 39 ++++++++++----------
 1 file changed, 19 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/9b3adc13/server/container/guice/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServerMain.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServerMain.java b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServerMain.java
index d6910f3..5421400 100644
--- a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServerMain.java
+++ b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServerMain.java
@@ -52,34 +52,33 @@ import com.google.inject.util.Modules;
 public class CassandraJamesServerMain {
 
     public static final Module protocols = Modules.combine(
-            new IMAPServerModule(),
-            new ProtocolHandlerModule(),
-            new POP3ServerModule(),
-            new SMTPServerModule(),
-            new LMTPServerModule(),
-            new ManageSieveServerModule(),
-            new WebAdminServerModule(),
-            new DataRoutesModules(),
-            new MailboxRoutesModule(),
-            new CassandraRoutesModule(),
-            new SwaggerRoutesModules());
+        new CassandraRoutesModule(),
+        new DataRoutesModules(),
+        new IMAPServerModule(),
+        new LMTPServerModule(),
+        new MailboxRoutesModule(),
+        new ManageSieveServerModule(),
+        new POP3ServerModule(),
+        new ProtocolHandlerModule(),
+        new SMTPServerModule(),
+        new SwaggerRoutesModules(),
+        new WebAdminServerModule());
 
     public static final Module cassandraServerModule = Modules.combine(
-        new JMAPServerModule(),
-        new CassandraUsersRepositoryModule(),
+        new ActiveMQQueueModule(),
         new CassandraDomainListModule(),
-        new CassandraRecipientRewriteTableModule(),
-        new CassandraSieveRepositoryModule(),
         new CassandraJmapModule(),
         new CassandraMailboxModule(),
+        new CassandraMetricsModule(),
+        new CassandraRecipientRewriteTableModule(),
         new CassandraSessionModule(),
+        new CassandraSieveRepositoryModule(),
+        new CassandraUsersRepositoryModule(),
         new ElasticSearchMailboxModule(),
-        new TikaMailboxModule(),
-        new ActiveMQQueueModule(),
         new ElasticSearchMetricReporterModule(),
-        new CassandraMetricsModule(),
-        new MailboxModule());
-
+        new JMAPServerModule(),
+        new MailboxModule(),
+        new TikaMailboxModule());
 
     public static void main(String[] args) throws Exception {
         GuiceJamesServer server = new GuiceJamesServer()


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


[04/23] james-project git commit: JAMES-2138 Always use ElasticSearch in names

Posted by bt...@apache.org.
JAMES-2138 Always use ElasticSearch in names


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/5354f231
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/5354f231
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/5354f231

Branch: refs/heads/master
Commit: 5354f2310f39d5708f510abae5f272f84a11ffaa
Parents: 840a885
Author: Matthieu Baechler <ma...@apache.org>
Authored: Mon Sep 4 10:48:27 2017 +0200
Committer: benwa <bt...@linagora.com>
Committed: Sat Sep 9 10:40:29 2017 +0700

----------------------------------------------------------------------
 .../apache/james/CassandraJamesServerMain.java  |   4 +-
 .../modules/server/ESMetricReporterModule.java  | 115 -------------------
 .../ElasticSearchMetricReporterModule.java      | 115 +++++++++++++++++++
 .../org/apache/james/JPAJamesServerMain.java    |   4 +-
 .../org/apache/james/JPAJamesServerMain.java    |   4 +-
 5 files changed, 121 insertions(+), 121 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/5354f231/server/container/guice/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServerMain.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServerMain.java b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServerMain.java
index f047959..d6910f3 100644
--- a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServerMain.java
+++ b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServerMain.java
@@ -40,7 +40,7 @@ import org.apache.james.modules.protocols.SMTPServerModule;
 import org.apache.james.modules.server.ActiveMQQueueModule;
 import org.apache.james.modules.server.CassandraRoutesModule;
 import org.apache.james.modules.server.DataRoutesModules;
-import org.apache.james.modules.server.ESMetricReporterModule;
+import org.apache.james.modules.server.ElasticSearchMetricReporterModule;
 import org.apache.james.modules.server.JMXServerModule;
 import org.apache.james.modules.server.MailboxRoutesModule;
 import org.apache.james.modules.server.SwaggerRoutesModules;
@@ -76,7 +76,7 @@ public class CassandraJamesServerMain {
         new ElasticSearchMailboxModule(),
         new TikaMailboxModule(),
         new ActiveMQQueueModule(),
-        new ESMetricReporterModule(),
+        new ElasticSearchMetricReporterModule(),
         new CassandraMetricsModule(),
         new MailboxModule());
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/5354f231/server/container/guice/es-metric-reporter/src/main/java/org/apache/james/modules/server/ESMetricReporterModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/es-metric-reporter/src/main/java/org/apache/james/modules/server/ESMetricReporterModule.java b/server/container/guice/es-metric-reporter/src/main/java/org/apache/james/modules/server/ESMetricReporterModule.java
deleted file mode 100644
index 43cf53e..0000000
--- a/server/container/guice/es-metric-reporter/src/main/java/org/apache/james/modules/server/ESMetricReporterModule.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-
-package org.apache.james.modules.server;
-
-import java.io.FileNotFoundException;
-import java.util.List;
-
-import org.apache.commons.configuration.ConfigurationException;
-import org.apache.commons.configuration.HierarchicalConfiguration;
-import org.apache.commons.configuration.PropertiesConfiguration;
-import org.apache.commons.lang.NotImplementedException;
-import org.apache.james.lifecycle.api.Configurable;
-import org.apache.james.metrics.es.ESMetricReporter;
-import org.apache.james.metrics.es.ESReporterConfiguration;
-import org.apache.james.utils.ConfigurationPerformer;
-import org.apache.james.utils.PropertiesProvider;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.collect.ImmutableList;
-import com.google.inject.AbstractModule;
-import com.google.inject.Inject;
-import com.google.inject.Provides;
-import com.google.inject.Singleton;
-import com.google.inject.multibindings.Multibinder;
-
-public class ESMetricReporterModule extends AbstractModule {
-    private static final String ELASTICSEARCH_CONFIGURATION_NAME = "elasticsearch";
-    private static final String ELASTICSEARCH_MASTER_HOST = "elasticsearch.masterHost";
-
-    private static final Logger LOGGER = LoggerFactory.getLogger(ESMetricReporterModule.class);
-
-    public static final boolean DEFAULT_DISABLE = false;
-    public static final int DEFAULT_ES_HTTP_PORT = 9200;
-
-    @Override
-    protected void configure() {
-        Multibinder.newSetBinder(binder(), ConfigurationPerformer.class).addBinding().to(ESMetricReporterStarter.class);
-    }
-
-    @Provides
-    public ESReporterConfiguration provideConfiguration(PropertiesProvider propertiesProvider) throws ConfigurationException {
-        try {
-            PropertiesConfiguration propertiesReader = propertiesProvider.getConfiguration(ELASTICSEARCH_CONFIGURATION_NAME);
-
-            if (isMetricEnable(propertiesReader)) {
-                return ESReporterConfiguration.builder()
-                    .enabled()
-                    .onHost(locateHost(propertiesReader),
-                        propertiesReader.getInt("elasticsearch.http.port", DEFAULT_ES_HTTP_PORT))
-                    .onIndex(propertiesReader.getString("elasticsearch.metrics.reports.index", null))
-                    .periodInSecond(propertiesReader.getLong("elasticsearch.metrics.reports.period", null))
-                    .build();
-            }
-        } catch (FileNotFoundException e) {
-            LOGGER.info("Can not locate " + ELASTICSEARCH_CONFIGURATION_NAME + " configuration");
-        }
-        return ESReporterConfiguration.builder()
-            .disabled()
-            .build();
-    }
-
-    private String locateHost(PropertiesConfiguration propertiesReader) {
-        return propertiesReader.getString("elasticsearch.http.host",
-            propertiesReader.getString(ELASTICSEARCH_MASTER_HOST));
-    }
-
-    private boolean isMetricEnable(PropertiesConfiguration propertiesReader) {
-        return propertiesReader.getBoolean("elasticsearch.metrics.reports.enabled", DEFAULT_DISABLE);
-    }
-
-    @Singleton
-    public static class ESMetricReporterStarter implements ConfigurationPerformer, Configurable {
-
-        private final ESMetricReporter esMetricReporter;
-
-        @Inject
-        public ESMetricReporterStarter(ESMetricReporter esMetricReporter) {
-            this.esMetricReporter = esMetricReporter;
-        }
-
-        @Override
-        public void initModule() {
-            esMetricReporter.start();
-        }
-
-        @Override
-        public List<Class<? extends Configurable>> forClasses() {
-            return ImmutableList.of(ESMetricReporterStarter.class);
-        }
-
-        @Override
-        public void configure(HierarchicalConfiguration config) throws ConfigurationException {
-            throw new NotImplementedException();
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/5354f231/server/container/guice/es-metric-reporter/src/main/java/org/apache/james/modules/server/ElasticSearchMetricReporterModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/es-metric-reporter/src/main/java/org/apache/james/modules/server/ElasticSearchMetricReporterModule.java b/server/container/guice/es-metric-reporter/src/main/java/org/apache/james/modules/server/ElasticSearchMetricReporterModule.java
new file mode 100644
index 0000000..f31e07c
--- /dev/null
+++ b/server/container/guice/es-metric-reporter/src/main/java/org/apache/james/modules/server/ElasticSearchMetricReporterModule.java
@@ -0,0 +1,115 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.modules.server;
+
+import java.io.FileNotFoundException;
+import java.util.List;
+
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.HierarchicalConfiguration;
+import org.apache.commons.configuration.PropertiesConfiguration;
+import org.apache.commons.lang.NotImplementedException;
+import org.apache.james.lifecycle.api.Configurable;
+import org.apache.james.metrics.es.ESMetricReporter;
+import org.apache.james.metrics.es.ESReporterConfiguration;
+import org.apache.james.utils.ConfigurationPerformer;
+import org.apache.james.utils.PropertiesProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.collect.ImmutableList;
+import com.google.inject.AbstractModule;
+import com.google.inject.Inject;
+import com.google.inject.Provides;
+import com.google.inject.Singleton;
+import com.google.inject.multibindings.Multibinder;
+
+public class ElasticSearchMetricReporterModule extends AbstractModule {
+    private static final String ELASTICSEARCH_CONFIGURATION_NAME = "elasticsearch";
+    private static final String ELASTICSEARCH_MASTER_HOST = "elasticsearch.masterHost";
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(ElasticSearchMetricReporterModule.class);
+
+    public static final boolean DEFAULT_DISABLE = false;
+    public static final int DEFAULT_ES_HTTP_PORT = 9200;
+
+    @Override
+    protected void configure() {
+        Multibinder.newSetBinder(binder(), ConfigurationPerformer.class).addBinding().to(ESMetricReporterStarter.class);
+    }
+
+    @Provides
+    public ESReporterConfiguration provideConfiguration(PropertiesProvider propertiesProvider) throws ConfigurationException {
+        try {
+            PropertiesConfiguration propertiesReader = propertiesProvider.getConfiguration(ELASTICSEARCH_CONFIGURATION_NAME);
+
+            if (isMetricEnable(propertiesReader)) {
+                return ESReporterConfiguration.builder()
+                    .enabled()
+                    .onHost(locateHost(propertiesReader),
+                        propertiesReader.getInt("elasticsearch.http.port", DEFAULT_ES_HTTP_PORT))
+                    .onIndex(propertiesReader.getString("elasticsearch.metrics.reports.index", null))
+                    .periodInSecond(propertiesReader.getLong("elasticsearch.metrics.reports.period", null))
+                    .build();
+            }
+        } catch (FileNotFoundException e) {
+            LOGGER.info("Can not locate " + ELASTICSEARCH_CONFIGURATION_NAME + " configuration");
+        }
+        return ESReporterConfiguration.builder()
+            .disabled()
+            .build();
+    }
+
+    private String locateHost(PropertiesConfiguration propertiesReader) {
+        return propertiesReader.getString("elasticsearch.http.host",
+            propertiesReader.getString(ELASTICSEARCH_MASTER_HOST));
+    }
+
+    private boolean isMetricEnable(PropertiesConfiguration propertiesReader) {
+        return propertiesReader.getBoolean("elasticsearch.metrics.reports.enabled", DEFAULT_DISABLE);
+    }
+
+    @Singleton
+    public static class ESMetricReporterStarter implements ConfigurationPerformer, Configurable {
+
+        private final ESMetricReporter esMetricReporter;
+
+        @Inject
+        public ESMetricReporterStarter(ESMetricReporter esMetricReporter) {
+            this.esMetricReporter = esMetricReporter;
+        }
+
+        @Override
+        public void initModule() {
+            esMetricReporter.start();
+        }
+
+        @Override
+        public List<Class<? extends Configurable>> forClasses() {
+            return ImmutableList.of(ESMetricReporterStarter.class);
+        }
+
+        @Override
+        public void configure(HierarchicalConfiguration config) throws ConfigurationException {
+            throw new NotImplementedException();
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/5354f231/server/container/guice/jpa-guice/src/main/java/org/apache/james/JPAJamesServerMain.java
----------------------------------------------------------------------
diff --git a/server/container/guice/jpa-guice/src/main/java/org/apache/james/JPAJamesServerMain.java b/server/container/guice/jpa-guice/src/main/java/org/apache/james/JPAJamesServerMain.java
index e47868c..c3d89f5 100644
--- a/server/container/guice/jpa-guice/src/main/java/org/apache/james/JPAJamesServerMain.java
+++ b/server/container/guice/jpa-guice/src/main/java/org/apache/james/JPAJamesServerMain.java
@@ -33,7 +33,7 @@ import org.apache.james.modules.protocols.SMTPServerModule;
 import org.apache.james.modules.server.ActiveMQQueueModule;
 import org.apache.james.modules.server.DataRoutesModules;
 import org.apache.james.modules.server.DefaultProcessorsConfigurationProviderModule;
-import org.apache.james.modules.server.ESMetricReporterModule;
+import org.apache.james.modules.server.ElasticSearchMetricReporterModule;
 import org.apache.james.modules.server.JMXServerModule;
 import org.apache.james.modules.server.MailboxRoutesModule;
 import org.apache.james.modules.server.NoJwtModule;
@@ -65,7 +65,7 @@ public class JPAJamesServerMain {
         new MailboxModule(),
         new NoJwtModule(),
         new DefaultProcessorsConfigurationProviderModule(),
-        new ESMetricReporterModule());
+        new ElasticSearchMetricReporterModule());
 
     public static void main(String[] args) throws Exception {
         GuiceJamesServer server = new GuiceJamesServer()

http://git-wip-us.apache.org/repos/asf/james-project/blob/5354f231/server/container/guice/jpa-smtp/src/main/java/org/apache/james/JPAJamesServerMain.java
----------------------------------------------------------------------
diff --git a/server/container/guice/jpa-smtp/src/main/java/org/apache/james/JPAJamesServerMain.java b/server/container/guice/jpa-smtp/src/main/java/org/apache/james/JPAJamesServerMain.java
index ea2fc04..a2079c6 100644
--- a/server/container/guice/jpa-smtp/src/main/java/org/apache/james/JPAJamesServerMain.java
+++ b/server/container/guice/jpa-smtp/src/main/java/org/apache/james/JPAJamesServerMain.java
@@ -27,7 +27,7 @@ import org.apache.james.modules.protocols.SMTPServerModule;
 import org.apache.james.modules.server.ActiveMQQueueModule;
 import org.apache.james.modules.server.DataRoutesModules;
 import org.apache.james.modules.server.DefaultProcessorsConfigurationProviderModule;
-import org.apache.james.modules.server.ESMetricReporterModule;
+import org.apache.james.modules.server.ElasticSearchMetricReporterModule;
 import org.apache.james.modules.server.NoJwtModule;
 import org.apache.james.modules.server.RawPostDequeueDecoratorModule;
 import org.apache.james.modules.server.WebAdminServerModule;
@@ -51,7 +51,7 @@ public class JPAJamesServerMain {
         (binder) -> binder.bind(EntityManagerFactory.class).toProvider(OpenJPAPersistence::getEntityManagerFactory),
         new ActiveMQQueueModule(),
         new RawPostDequeueDecoratorModule(),
-        new ESMetricReporterModule());
+        new ElasticSearchMetricReporterModule());
 
     public static void main(String[] args) throws Exception {
         GuiceJamesServer server = new GuiceJamesServer()


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


[21/23] james-project git commit: JAMES-2133 Add missing licence

Posted by bt...@apache.org.
JAMES-2133 Add missing licence


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/743cd159
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/743cd159
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/743cd159

Branch: refs/heads/master
Commit: 743cd15967d21078d35a97ea44309291d47767da
Parents: 55f476a
Author: benwa <bt...@linagora.com>
Authored: Thu Sep 7 13:58:55 2017 +0700
Committer: benwa <bt...@linagora.com>
Committed: Mon Sep 11 09:35:11 2017 +0700

----------------------------------------------------------------------
 .../mailbox/ResilientClusterProvider.java        | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/743cd159/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ResilientClusterProvider.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ResilientClusterProvider.java b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ResilientClusterProvider.java
index c8be620..5ab43dc 100644
--- a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ResilientClusterProvider.java
+++ b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ResilientClusterProvider.java
@@ -1,3 +1,22 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
 package org.apache.james.modules.mailbox;
 
 import java.time.LocalDateTime;


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


[23/23] james-project git commit: JAMES-2140 Log composedId upon delivery

Posted by bt...@apache.org.
JAMES-2140 Log composedId upon delivery


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/1998ff35
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/1998ff35
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/1998ff35

Branch: refs/heads/master
Commit: 1998ff35a2b4f3c5b96a3b266508b9a97fc343fb
Parents: 2abd71b
Author: benwa <bt...@linagora.com>
Authored: Fri Sep 8 12:00:43 2017 +0700
Committer: benwa <bt...@linagora.com>
Committed: Mon Sep 11 09:35:44 2017 +0700

----------------------------------------------------------------------
 .../transport/mailets/delivery/MailboxAppender.java    | 13 +++++++------
 .../transport/mailets/delivery/SimpleMailStore.java    |  7 ++++---
 2 files changed, 11 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/1998ff35/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/delivery/MailboxAppender.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/delivery/MailboxAppender.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/delivery/MailboxAppender.java
index 335389c..2a931c1 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/delivery/MailboxAppender.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/delivery/MailboxAppender.java
@@ -31,6 +31,7 @@ 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.ComposedMessageId;
 import org.apache.james.mailbox.model.MailboxPath;
 
 import com.google.common.base.Strings;
@@ -45,9 +46,9 @@ public class MailboxAppender {
         this.mailboxManager = mailboxManager;
     }
 
-    public void append(MimeMessage mail, String user, String folder) throws MessagingException {
+    public ComposedMessageId append(MimeMessage mail, String user, String folder) throws MessagingException {
         MailboxSession session = createMailboxSession(user);
-        append(mail, user, useSlashAsSeparator(folder, session), session);
+        return append(mail, user, useSlashAsSeparator(folder, session), session);
     }
 
     private String useSlashAsSeparator(String urlPath, MailboxSession session) throws MessagingException {
@@ -61,11 +62,11 @@ public class MailboxAppender {
         return destination;
     }
 
-    private void append(MimeMessage mail, String user, String folder, MailboxSession session) throws MessagingException {
+    private ComposedMessageId append(MimeMessage mail, String user, String folder, MailboxSession session) throws MessagingException {
         mailboxManager.startProcessingRequest(session);
         try {
             MailboxPath mailboxPath = new MailboxPath(session.getPersonalSpace(), user, folder);
-            appendMessageToMailbox(mail, session, mailboxPath);
+            return appendMessageToMailbox(mail, session, mailboxPath);
         } catch (MailboxException e) {
             throw new MessagingException("Unable to access mailbox.", e);
         } finally {
@@ -73,13 +74,13 @@ public class MailboxAppender {
         }
     }
 
-    private void appendMessageToMailbox(MimeMessage mail, MailboxSession session, MailboxPath path) throws MailboxException, MessagingException {
+    private ComposedMessageId appendMessageToMailbox(MimeMessage mail, MailboxSession session, MailboxPath path) throws MailboxException, MessagingException {
         createMailboxIfNotExist(session, path);
         final MessageManager mailbox = mailboxManager.getMailbox(path, session);
         if (mailbox == null) {
             throw new MessagingException("Mailbox " + path + " for user " + session.getUser().getUserName() + " was not found on this server.");
         }
-        mailbox.appendMessage(new MimeMessageInputStream(mail), new Date(), session, IS_RECENT, FLAGS);
+        return mailbox.appendMessage(new MimeMessageInputStream(mail), new Date(), session, IS_RECENT, FLAGS);
     }
 
     private void createMailboxIfNotExist(MailboxSession session, MailboxPath path) throws MailboxException {

http://git-wip-us.apache.org/repos/asf/james-project/blob/1998ff35/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/delivery/SimpleMailStore.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/delivery/SimpleMailStore.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/delivery/SimpleMailStore.java
index 21673b9..369a20d 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/delivery/SimpleMailStore.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/delivery/SimpleMailStore.java
@@ -21,6 +21,7 @@ package org.apache.james.transport.mailets.delivery;
 
 import javax.mail.MessagingException;
 
+import org.apache.james.mailbox.model.ComposedMessageId;
 import org.apache.james.metrics.api.Metric;
 import org.apache.james.user.api.UsersRepository;
 import org.apache.james.user.api.UsersRepositoryException;
@@ -91,11 +92,11 @@ public class SimpleMailStore implements MailStore {
         String username = computeUsername(recipient);
 
         String locatedFolder = locateFolder(username, mail);
-        mailboxAppender.append(mail.getMessage(), username, locatedFolder);
+        ComposedMessageId composedMessageId = mailboxAppender.append(mail.getMessage(), username, locatedFolder);
 
         metric.increment();
-        LOGGER.info("Local delivered mail {} successfully from {} to {} in folder {}", mail.getName(),
-            DeliveryUtils.prettyPrint(mail.getSender()), DeliveryUtils.prettyPrint(recipient), locatedFolder);
+        LOGGER.info("Local delivered mail {} successfully from {} to {} in folder {} with composedMessageId {}", mail.getName(),
+            DeliveryUtils.prettyPrint(mail.getSender()), DeliveryUtils.prettyPrint(recipient), locatedFolder, composedMessageId);
     }
 
     private String locateFolder(String username, Mail mail) {


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


[08/23] james-project git commit: JAMES-2138 move MailAddress to a new james-core project

Posted by bt...@apache.org.
http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageTest.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageTest.java b/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageTest.java
new file mode 100644
index 0000000..8b51e50
--- /dev/null
+++ b/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageTest.java
@@ -0,0 +1,437 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+package org.apache.james.server.core;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.util.Arrays;
+import java.util.Enumeration;
+import java.util.Properties;
+
+import javax.mail.BodyPart;
+import javax.mail.Session;
+import javax.mail.internet.InternetHeaders;
+import javax.mail.internet.MimeBodyPart;
+import javax.mail.internet.MimeMessage;
+import javax.mail.internet.MimeMultipart;
+
+import org.apache.james.lifecycle.api.LifecycleUtil;
+import org.apache.mailet.base.RFC2822Headers;
+import org.junit.Test;
+
+/**
+ * Test the subject folding issue.
+ */
+public class MimeMessageTest {
+
+    protected MimeMessage getSimpleMessage() throws Exception {
+        MimeMessage mmCreated = new MimeMessage(Session.getDefaultInstance(new Properties()));
+        mmCreated.setSubject("test");
+        mmCreated.setText("test body");
+        mmCreated.saveChanges();
+        return mmCreated;
+    }
+
+    protected String getSimpleMessageCleanedSource() {
+        return "Subject: test\r\n"
+                + "MIME-Version: 1.0\r\n"
+                + "Content-Type: text/plain; charset=us-ascii\r\n"
+                + "Content-Transfer-Encoding: 7bit\r\n"
+                + "\r\n"
+                + "test body";
+    }
+
+    protected MimeMessage getMessageWithBadReturnPath() throws Exception {
+        MimeMessage mmCreated = new MimeMessage(Session.getDefaultInstance(new Properties()));
+        mmCreated.setSubject("test");
+        mmCreated.setHeader(RFC2822Headers.RETURN_PATH, "<my...@example.com>");
+        mmCreated.setText("test body");
+        mmCreated.saveChanges();
+        return mmCreated;
+    }
+
+    protected String getMessageWithBadReturnPathSource() {
+        return "Subject: test\r\n"
+                + "Return-Path: <my...@example.com>\r\n"
+                + "MIME-Version: 1.0\r\n"
+                + "Content-Type: text/plain; charset=us-ascii\r\n"
+                + "Content-Transfer-Encoding: 7bit\r\n"
+                + "\r\n"
+                + "test body";
+    }
+
+    protected String getSimpleMessageCleanedSourceHeaderExpected() {
+        return "X-Test: foo\r\n" + getSimpleMessageCleanedSource();
+    }
+
+    /*
+     * Class under test for String getSubject()
+     */
+    @Test
+    public void testSimpleMessage() throws Exception {
+        MimeMessage m = getSimpleMessage();
+        assertEquals(getSimpleMessageCleanedSource(), getCleanedMessageSource(m));
+        LifecycleUtil.dispose(m);
+    }
+
+    protected MimeMessage getMultipartMessage() throws Exception {
+        MimeMessage mmCreated = new MimeMessage(Session.getDefaultInstance(new Properties()));
+        mmCreated.setSubject("test");
+        MimeMultipart mm = new MimeMultipart("alternative");
+        mm.addBodyPart(new MimeBodyPart(new InternetHeaders(new ByteArrayInputStream("X-header: test1\r\nContent-Type: text/plain; charset=Cp1252\r\n".
+                getBytes())), "first part \u00F2\u00E0\u00F9".getBytes()));
+        mm.addBodyPart(new MimeBodyPart(new InternetHeaders(new ByteArrayInputStream("X-header: test2\r\nContent-Type: text/plain; charset=Cp1252\r\nContent-Transfer-Encoding: quoted-printable\r\n".
+                getBytes())), "second part =E8=E8".getBytes()));
+        mmCreated.setContent(mm);
+        mmCreated.saveChanges();
+        return mmCreated;
+    }
+
+    protected String getMultipartMessageSource() {
+        return "Subject: test\r\n"
+                + "MIME-Version: 1.0\r\n"
+                + "Content-Type: multipart/alternative; \r\n"
+                + "\tboundary=\"----=_Part_0_XXXXXXXXXXX.XXXXXXXXXXX\"\r\n"
+                + "\r\n"
+                + "------=_Part_0_XXXXXXXXXXX.XXXXXXXXXXX\r\n"
+                + "X-header: test1\r\n"
+                + "Content-Type: text/plain; charset=Cp1252\r\n"
+                + "Content-Transfer-Encoding: quoted-printable\r\n"
+                + "\r\n"
+                + "first part =E8\r\n"
+                + "------=_Part_0_XXXXXXXXXXX.XXXXXXXXXXX\r\n"
+                + "X-header: test2\r\n"
+                + "Content-Type: text/plain; charset=Cp1252\r\n"
+                + "Content-Transfer-Encoding: quoted-printable\r\n"
+                + "\r\n"
+                + "second part =E8=E8\r\n"
+                + "------=_Part_0_XXXXXXXXXXX.XXXXXXXXXXX--\r\n";
+    }
+
+    protected String getMultipartMessageExpected1() {
+        return "Subject: test\r\n"
+                + "MIME-Version: 1.0\r\n"
+                + "Content-Type: multipart/alternative; \r\n"
+                + "\tboundary=\"----=_Part_0_XXXXXXXXXXX.XXXXXXXXXXX\"\r\n"
+                + "\r\n"
+                + "------=_Part_0_XXXXXXXXXXX.XXXXXXXXXXX\r\n"
+                + "X-header: test1\r\n"
+                + "Content-Type: text/plain; charset=Cp1252\r\n"
+                + "Content-Transfer-Encoding: quoted-printable\r\n"
+                + "\r\n"
+                + "test=80\r\n"
+                + "------=_Part_0_XXXXXXXXXXX.XXXXXXXXXXX\r\n"
+                + "X-header: test2\r\n"
+                + "Content-Type: text/plain; charset=Cp1252\r\n"
+                + "Content-Transfer-Encoding: quoted-printable\r\n"
+                + "\r\n"
+                + "second part =E8=E8\r\n"
+                + "------=_Part_0_XXXXXXXXXXX.XXXXXXXXXXX--\r\n";
+    }
+
+    protected String getMultipartMessageExpected2() {
+        return "Subject: test\r\n"
+                + "MIME-Version: 1.0\r\n"
+                + "Content-Type: multipart/alternative; \r\n"
+                + "\tboundary=\"----=_Part_0_XXXXXXXXXXX.XXXXXXXXXXX\"\r\n"
+                + "\r\n"
+                + "------=_Part_0_XXXXXXXXXXX.XXXXXXXXXXX\r\n"
+                + "X-header: test1\r\n"
+                + "Content-Type: text/plain; charset=Cp1252\r\n"
+                + "Content-Transfer-Encoding: quoted-printable\r\n"
+                + "\r\n"
+                + "test=80\r\n"
+                + "------=_Part_0_XXXXXXXXXXX.XXXXXXXXXXX\r\n"
+                + "X-header: test2\r\n"
+                + "Content-Type: text/plain; charset=Cp1252\r\n"
+                + "Content-Transfer-Encoding: quoted-printable\r\n"
+                + "\r\n"
+                + "second part =E8=E8\r\n"
+                + "------=_Part_0_XXXXXXXXXXX.XXXXXXXXXXX\r\n"
+                + "Subject: test3\r\n"
+                + "\r\n"
+                + "third part\r\n"
+                + "------=_Part_0_XXXXXXXXXXX.XXXXXXXXXXX--\r\n";
+    }
+
+    protected String getMultipartMessageExpected3() {
+        return "Subject: test\r\n"
+                + "MIME-Version: 1.0\r\n"
+                + "Content-Type: binary/octet-stream\r\n"
+                + "Content-Transfer-Encoding: quoted-printable\r\n"
+                + "\r\n"
+                + "mynewco=F2=E0=F9ntent=80=E0!";
+    }
+
+    /*
+     * Class under test for String getSubject()
+     */
+    @Test
+    public void testMultipartMessageChanges() throws Exception {
+
+        MimeMessage mm = getMultipartMessage();
+
+        // ByteArrayOutputStream out = new ByteArrayOutputStream();
+        // mmCreated.writeTo(out,new String[] {"Message-ID"});
+        // String messageSource = out.toString();
+        // System.out.println(messageSource);
+
+        MimeMultipart content1 = (MimeMultipart) mm.getContent();
+        BodyPart b1 = content1.getBodyPart(0);
+        b1.setContent("test\u20AC", "text/plain; charset=Cp1252");
+        mm.setContent(content1, mm.getContentType());
+        // .setHeader(RFC2822Headers.CONTENT_TYPE,contentType);
+        mm.saveChanges();
+
+        assertEquals(getMultipartMessageExpected1(), getCleanedMessageSource(mm));
+
+        MimeMultipart content2 = (MimeMultipart) mm.getContent();
+        content2.addBodyPart(new MimeBodyPart(new InternetHeaders(new ByteArrayInputStream(
+                "Subject: test3\r\n".getBytes())), "third part".getBytes()));
+        mm.setContent(content2, mm.getContentType());
+        mm.saveChanges();
+
+        assertEquals(getMultipartMessageExpected2(), getCleanedMessageSource(mm));
+
+        mm.setContent("mynewco\u00F2\u00E0\u00F9ntent\u20AC\u00E0!", "text/plain; charset=cp1252");
+        mm.setHeader(RFC2822Headers.CONTENT_TYPE, "binary/octet-stream");
+        // mm.setHeader("Content-Transfer-Encoding","8bit");
+        mm.saveChanges();
+
+        assertEquals(getMultipartMessageExpected3(), getCleanedMessageSource(mm));
+
+        LifecycleUtil.dispose(mm);
+
+    }
+
+    protected MimeMessage getMissingEncodingAddHeaderMessage() throws Exception {
+        MimeMessage m = new MimeMessage(Session.getDefaultInstance(new Properties()));
+        m.setText("Test\u00E0\r\n");
+        m.setSubject("test");
+        m.saveChanges();
+        return m;
+    }
+
+    protected String getMissingEncodingAddHeaderSource() {
+        return "Subject: test\r\n"
+                + "\r\n"
+                + "Test\u00E0\r\n";
+    }
+
+    protected String getMissingEncodingAddHeaderExpected() {
+        return "Subject: test\r\n"
+                + "MIME-Version: 1.0\r\n"
+                + "Content-Type: text/plain; charset=Cp1252\r\n"
+                + "Content-Transfer-Encoding: quoted-printable\r\n"
+                + "\r\n"
+                + "Test=E0\r\n";
+    }
+
+    /**
+     * This test is not usable in different locale environment.
+     */
+    /*
+     * public void testMissingEncodingAddHeader() throws Exception {
+     * 
+     * 
+     * MimeMessage mm = getMissingEncodingAddHeaderMessage();
+     * mm.setHeader("Content-Transfer-Encoding", "quoted-printable");
+     * mm.saveChanges();
+     * 
+     * assertEquals(getMissingEncodingAddHeaderExpected(),getCleanedMessageSource
+     * (mm)); }
+     */
+    protected String getCleanedMessageSource(MimeMessage mm) throws Exception {
+        ByteArrayOutputStream out2;
+        out2 = new ByteArrayOutputStream();
+        mm.writeTo(out2, new String[]{"Message-ID"});
+
+        String res = out2.toString();
+
+        int p = res.indexOf("\r\n\r\n");
+        if (p > 0) {
+            String head = res.substring(0, p);
+            String[] str = head.split("\r\n");
+            Arrays.sort(str);
+            StringBuilder outputHead = new StringBuilder();
+            for (int i = str.length - 1; i >= 0; i--) {
+                outputHead.append(str[i]);
+                outputHead.append("\r\n");
+            }
+            outputHead.append(res.substring(p + 2));
+            res = outputHead.toString();
+        }
+
+        res = res.replaceAll("----=_Part_\\d*_\\d+\\.\\d+", "----=_Part_\\0_XXXXXXXXXXX.XXXXXXXXXXX");
+        return res;
+    }
+
+    protected void debugMessage(MimeMessage mm) throws Exception {
+        System.out.println("-------------------");
+        System.out.println(getCleanedMessageSource(mm));
+        System.out.println("-------------------");
+    }
+
+    protected MimeMessage getMissingEncodingMessage() throws Exception {
+        MimeMessage mmCreated = new MimeMessage(Session.getDefaultInstance(new Properties()));
+        mmCreated.setSubject("test");
+        MimeMultipart mm = new MimeMultipart("alternative");
+        mm.addBodyPart(new MimeBodyPart(new InternetHeaders(new ByteArrayInputStream("X-header: test2\r\nContent-Type: text/plain; charset=Cp1252\r\nContent-Transfer-Encoding: quoted-printable\r\n".
+                getBytes())), "second part =E8=E8".getBytes()));
+        mmCreated.setContent(mm);
+        mmCreated.saveChanges();
+        return mmCreated;
+    }
+
+    protected String getMissingEncodingMessageSource() {
+        return "Subject: test\r\n"
+                + "MIME-Version: 1.0\r\n"
+                + "Content-Type: multipart/alternative; \r\n"
+                + "\tboundary=\"----=_Part_0_XXXXXXXXXXX.XXXXXXXXXXX\"\r\n"
+                + "\r\n"
+                + "------=_Part_0_XXXXXXXXXXX.XXXXXXXXXXX\r\n"
+                + "X-header: test2\r\n"
+                + "Content-Type: text/plain; charset=Cp1252\r\n"
+                + "Content-Transfer-Encoding: quoted-printable\r\n"
+                + "\r\n"
+                + "second part =E8=E8\r\n"
+                + "------=_Part_0_XXXXXXXXXXX.XXXXXXXXXXX--\r\n";
+    }
+
+    @Test
+    public void testGetLineCount() throws Exception {
+        MimeMessage mm = getMissingEncodingMessage();
+        try {
+            int count = mm.getLineCount();
+            assertTrue(count == -1 || count == 7);
+        } catch (Exception e) {
+            fail("Unexpected exception in getLineCount");
+        }
+        LifecycleUtil.dispose(mm);
+    }
+
+    /**
+     * This test throw a NullPointerException when the original message was
+     * created by a MimeMessageInputStreamSource.
+     */
+    @Test
+    public void testMessageCloningViaCoW() throws Exception {
+        MimeMessage mmorig = getSimpleMessage();
+
+        MimeMessage mm = new MimeMessageCopyOnWriteProxy(mmorig);
+
+        MimeMessage mm2 = new MimeMessageCopyOnWriteProxy(mm);
+
+        mm2.setHeader("Subject", "Modified");
+
+        LifecycleUtil.dispose(mm2);
+        System.gc();
+        Thread.sleep(200);
+        // ((Disposable)mail_dup.getMessage()).dispose();
+
+        mm.setHeader("Subject", "Modified");
+
+        LifecycleUtil.dispose(mm);
+        LifecycleUtil.dispose(mmorig);
+    }
+
+    /**
+     * This test throw a NullPointerException when the original message was
+     * created by a MimeMessageInputStreamSource.
+     */
+    @Test
+    public void testMessageCloningViaCoW2() throws Exception {
+        MimeMessage mmorig = getSimpleMessage();
+
+        MimeMessage mm = new MimeMessageCopyOnWriteProxy(mmorig);
+
+        MimeMessage mm2 = new MimeMessageCopyOnWriteProxy(mm);
+
+        LifecycleUtil.dispose(mm);
+        mm = null;
+        System.gc();
+        Thread.sleep(200);
+
+        try {
+            mm2.writeTo(System.out);
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail("Exception while writing the message to output");
+        }
+
+        LifecycleUtil.dispose(mm2);
+        LifecycleUtil.dispose(mmorig);
+    }
+
+    /**
+     * This test throw a NullPointerException when the original message was
+     * created by a MimeMessageInputStreamSource.
+     */
+    @Test
+    public void testMessageCloningViaCoWSubjectLost() throws Exception {
+        MimeMessage mmorig = getSimpleMessage();
+
+        MimeMessage mm = new MimeMessageCopyOnWriteProxy(mmorig);
+
+        mm.setHeader("X-Test", "foo");
+        mm.saveChanges();
+
+        assertEquals(getSimpleMessageCleanedSourceHeaderExpected(), getCleanedMessageSource(mm));
+
+        LifecycleUtil.dispose(mm);
+        LifecycleUtil.dispose(mmorig);
+    }
+
+    @Test
+    public void testReturnPath() throws Exception {
+        MimeMessage message = getSimpleMessage();
+        assertNull(message.getHeader(RFC2822Headers.RETURN_PATH));
+        LifecycleUtil.dispose(message);
+    }
+
+    @Test
+    public void testHeaderOrder() throws Exception {
+        MimeMessage message = getSimpleMessage();
+        message.setHeader(RFC2822Headers.RETURN_PATH, "<te...@test.de>");
+        @SuppressWarnings("unchecked")
+        Enumeration<String> h = message.getAllHeaderLines();
+
+        assertEquals(h.nextElement(), "Return-Path: <te...@test.de>");
+        LifecycleUtil.dispose(message);
+    }
+
+    /**
+     * http://issues.apache.org/jira/browse/GERONIMO-4261
+     * 
+     * This bug was in geronimo-javamail_1.4-1.5 Has been fixed in
+     * geronimo-javamail_1.4-1.6
+     */
+    @Test
+    public void testGeronimoIndexOutOfBounds() throws Exception {
+        String message = "                  \r\n" + "Subject: test\r\n" + "\r\n" + "Body\r\n";
+
+        byte[] messageBytes = message.getBytes("US-ASCII");
+        new MimeMessage(null, new ByteArrayInputStream(messageBytes));
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageUtilTest.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageUtilTest.java b/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageUtilTest.java
new file mode 100644
index 0000000..0f023da
--- /dev/null
+++ b/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageUtilTest.java
@@ -0,0 +1,65 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.server.core;
+
+import javax.mail.MessagingException;
+import javax.mail.Session;
+import javax.mail.internet.MimeMessage;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Properties;
+import org.junit.Test;
+
+public class MimeMessageUtilTest {
+
+    @Test
+    public void testWriteMimeMessageMultipartWithMessageID() throws MessagingException, IOException {
+        String message = "Received: from localhost.localdomain ([127.0.0.1])\r\n" +
+        "          by athlon14 (JAMES SMTP Server 2.3-dev) with SMTP ID 694\r\n" +
+        "          for <te...@athlon14.bf.loc>;\r\n" +
+        "          Sat, 18 Feb 2006 19:30:53 +0100 (CET)\r\n" +
+        "Subject: ext2int\r\n" +
+        "X-James-Postage: This is a test mail sent by James Postage\r\n" +
+        "Mime-Version: 1.0\r\n" +
+        "Content-Type: multipart/alternative; boundary=\"XyoYyxCQIfmZ5Sxofid6XQVZt5Z09XtTnqBF4Z45XSA=\"\r\n" +
+        "Date: Sat, 18 Feb 2006 19:30:53 +0100 (CET)\r\n" +
+        "From: test_ext2@another.bf.loc\r\n" +
+        "\r\n" +
+        "\r\n" +
+        "--XyoYyxCQIfmZ5Sxofid6XQVZt5Z09XtTnqBF4Z45XSA=\r\n" +
+        "Content-Type: text/plain\r\n" +
+        "\r\n" +
+        "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\r\n" +
+        "--XyoYyxCQIfmZ5Sxofid6XQVZt5Z09XtTnqBF4Z45XSA=\r\n" +
+        "Content-Type: application/octet-stream\r\n" +
+        "\r\n" +
+        "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\r\n" +
+        "--XyoYyxCQIfmZ5Sxofid6XQVZt5Z09XtTnqBF4Z45XSA=--\r\n";
+
+        MimeMessage mimeMessage = new MimeMessage(Session.getDefaultInstance(new Properties()), new ByteArrayInputStream(message.getBytes()));
+        mimeMessage.getSize();
+        ByteArrayOutputStream headerOut = new ByteArrayOutputStream();
+        ByteArrayOutputStream bodyOut = new ByteArrayOutputStream();
+        MimeMessageUtil.writeTo(mimeMessage, headerOut, bodyOut);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageWrapperTest.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageWrapperTest.java b/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageWrapperTest.java
new file mode 100644
index 0000000..ebd92d3
--- /dev/null
+++ b/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageWrapperTest.java
@@ -0,0 +1,289 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+package org.apache.james.server.core;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.io.BufferedReader;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.Enumeration;
+import java.util.Properties;
+
+import javax.mail.MessagingException;
+import javax.mail.Session;
+import javax.mail.internet.MimeMessage;
+import javax.mail.util.SharedByteArrayInputStream;
+
+import org.apache.james.lifecycle.api.LifecycleUtil;
+import org.apache.mailet.base.RFC2822Headers;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+/**
+ * Test the subject folding issue.
+ */
+public class MimeMessageWrapperTest extends MimeMessageFromStreamTest {
+
+    private final class TestableMimeMessageWrapper extends MimeMessageWrapper {
+
+        boolean messageLoadable = true;
+        boolean headersLoadable = true;
+
+        private TestableMimeMessageWrapper(MimeMessageSource source) throws MessagingException {
+            super(source);
+        }
+
+        public boolean messageParsed() {
+            return messageParsed;
+        }
+
+        public void setHeadersLoadable(boolean headersLoadable) {
+            this.headersLoadable = headersLoadable;
+        }
+
+        @Override
+        protected synchronized void loadHeaders() throws MessagingException {
+            if (headersLoadable) {
+                super.loadHeaders();
+            } else {
+                throw new IllegalStateException("headersLoadable disabled");
+            }
+        }
+
+        @Override
+        public synchronized void loadMessage() throws MessagingException {
+            if (messageLoadable) {
+                super.loadMessage();
+            } else {
+                throw new IllegalStateException("messageLoadable disabled");
+            }
+        }
+    }
+    TestableMimeMessageWrapper mw = null;
+    final String content = "Subject: foo\r\nContent-Transfer-Encoding2: plain";
+    final String sep = "\r\n\r\n";
+    final String body = "bar\r\n";
+
+    @Rule
+    public ExpectedException expectedException = ExpectedException.none();
+
+    @Override
+    protected MimeMessage getMessageFromSources(String sources) throws Exception {
+        MimeMessageInputStreamSource mmis = new MimeMessageInputStreamSource("test", new SharedByteArrayInputStream(sources.getBytes()));
+        return new TestableMimeMessageWrapper(mmis);
+    }
+
+    @Before
+    public void setUp() throws Exception {
+        mw = (TestableMimeMessageWrapper) getMessageFromSources(content + sep + body);
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        LifecycleUtil.dispose(mw);
+    }
+
+    @Test
+    public void testDeferredMessageLoading() throws MessagingException, IOException {
+        assertEquals("foo", mw.getSubject());
+        assertFalse(mw.messageParsed());
+        assertEquals("bar\r\n", mw.getContent());
+        assertTrue(mw.messageParsed());
+        assertFalse(mw.isModified());
+    }
+
+    /**
+     * this is commented out due optimisation reverts (JAMES-559) public void
+     * testDeferredMessageLoadingWhileWriting() throws MessagingException,
+     * IOException { mw.setMessageLoadable(false);
+     * assertEquals("foo",mw.getSubject()); assertFalse(mw.isModified());
+     * mw.setSubject("newSubject"); assertEquals("newSubject",mw.getSubject());
+     * assertFalse(mw.messageParsed()); assertTrue(mw.isModified());
+     * mw.setMessageLoadable(true);
+     * 
+     * }
+     */
+    @Test
+    public void testDeferredHeaderLoading() throws MessagingException, IOException {
+        mw.setHeadersLoadable(false);
+
+        expectedException.expect(IllegalStateException.class);
+
+        mw.getSubject();
+    }
+
+    /**
+     * See JAMES-474 MimeMessageWrapper(MimeMessage) should clone the original
+     * message.
+     */
+    @Test
+    public void testMessageCloned() throws MessagingException, IOException, InterruptedException {
+        MimeMessageWrapper mmw = new MimeMessageWrapper(mw);
+        LifecycleUtil.dispose(mw);
+        mw = null;
+        System.gc();
+        Thread.sleep(200);
+        mmw.writeTo(System.out);
+    }
+
+    @Test
+    public void testGetSubjectFolding() throws Exception {
+        StringBuilder res = new StringBuilder();
+        BufferedReader r = new BufferedReader(new InputStreamReader(mw.getInputStream()));
+        String line;
+        while (r.ready()) {
+            line = r.readLine();
+            res.append(line).append("\r\n");
+        }
+        r.close();
+        assertEquals(body, res.toString());
+    }
+
+    @Test
+    public void testAddHeaderAndSave() throws Exception {
+        mw.addHeader("X-Test", "X-Value");
+
+        assertEquals("X-Value", mw.getHeader("X-Test")[0]);
+
+        mw.saveChanges();
+
+        ByteArrayOutputStream rawMessage = new ByteArrayOutputStream();
+        mw.writeTo(rawMessage);
+
+        assertEquals("X-Value", mw.getHeader("X-Test")[0]);
+
+        String res = rawMessage.toString();
+
+        boolean found = res.indexOf("X-Test: X-Value") > 0;
+        assertEquals(true, found);
+    }
+
+    @Test
+    public void testReplaceReturnPathOnBadMessage() throws Exception {
+        MimeMessage message = getMessageWithBadReturnPath();
+        message.setHeader(RFC2822Headers.RETURN_PATH, "<te...@test.de>");
+        @SuppressWarnings("unchecked")
+        Enumeration<String> e = message.getMatchingHeaderLines(new String[]{"Return-Path"});
+        assertEquals("Return-Path: <te...@test.de>", e.nextElement());
+        assertFalse(e.hasMoreElements());
+        @SuppressWarnings("unchecked")
+        Enumeration<String> h = message.getAllHeaderLines();
+        assertEquals("Return-Path: <te...@test.de>", h.nextElement());
+        assertFalse(h.nextElement().toString().startsWith("Return-Path:"));
+        LifecycleUtil.dispose(message);
+    }
+
+    @Test
+    public void testAddReturnPathOnBadMessage() throws Exception {
+        MimeMessage message = getMessageWithBadReturnPath();
+        message.addHeader(RFC2822Headers.RETURN_PATH, "<te...@test.de>");
+        // test that we have now 2 return-paths
+        @SuppressWarnings("unchecked")
+        Enumeration<String> e = message.getMatchingHeaderLines(new String[]{"Return-Path"});
+        assertEquals("Return-Path: <te...@test.de>", e.nextElement());
+        assertEquals("Return-Path: <my...@example.com>", e.nextElement());
+        // test that return-path is the first line
+        @SuppressWarnings("unchecked")
+        Enumeration<String> h = message.getAllHeaderLines();
+        assertEquals("Return-Path: <te...@test.de>", h.nextElement());
+        LifecycleUtil.dispose(message);
+    }
+
+    /**
+     * Test for JAMES-1154
+     */
+    @Test
+    public void testMessageStreamWithUpatedHeaders() throws MessagingException, IOException {
+        mw.addHeader("X-Test", "X-Value");
+
+        assertEquals("X-Value", mw.getHeader("X-Test")[0]);
+
+        mw.saveChanges();
+
+        BufferedReader reader = new BufferedReader(new InputStreamReader(mw.getMessageInputStream()));
+
+        boolean headerUpdated = reader.lines()
+            .anyMatch(line -> line.equals("X-Test: X-Value"));
+        reader.close();
+        assertTrue(headerUpdated);
+    }
+
+    /**
+     * Test for JAMES-1154
+     */
+    @Test
+    public void testMessageStreamWithUpatedContent() throws MessagingException, IOException {
+        String newContent = "This is the new message content!";
+        mw.setText(newContent);
+        assertEquals(newContent, mw.getContent());
+
+        mw.saveChanges();
+
+        BufferedReader reader = new BufferedReader(new InputStreamReader(mw.getMessageInputStream()));
+
+        boolean contentUpdated = reader.lines()
+            .anyMatch(line -> line.equals(newContent));
+        reader.close();
+        assertTrue(contentUpdated);
+    }
+
+    @Test
+    public void testSize() throws MessagingException {
+        assertEquals(body.length(), mw.getSize());
+    }
+
+    @Test
+    public void testSizeModifiedHeaders() throws MessagingException {
+        mw.addHeader("whatever", "test");
+        assertEquals(body.length(), mw.getSize());
+    }
+
+    @Test
+    public void testSizeModifiedBodyWithoutSave() throws MessagingException {
+        String newBody = "This is the new body of the message";
+        mw.setText(newBody);
+        assertEquals(body.length(), mw.getSize());
+    }
+
+    @Test
+    public void testSizeModifiedBodyWithSave() throws MessagingException {
+        String newBody = "This is the new body of the message";
+        mw.setText(newBody);
+        mw.saveChanges();
+        assertEquals(body.length(), mw.getSize());
+    }
+    
+    @Test
+    public void jiraJames1593() throws MessagingException, IOException {
+        Properties noProperties = new Properties();
+        Session session = Session.getDefaultInstance(noProperties);
+        InputStream stream = ClassLoader.getSystemResourceAsStream("JAMES-1593.eml");
+        MimeMessage message = new MimeMessage(session, stream);
+        MimeMessageWrapper wrapper = new MimeMessageWrapper(message);
+        assertEquals("\"base64\"", wrapper.getEncoding());
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/test/java/org/apache/james/server/core/filesystem/FileSystemImplTest.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/test/java/org/apache/james/server/core/filesystem/FileSystemImplTest.java b/server/container/core/src/test/java/org/apache/james/server/core/filesystem/FileSystemImplTest.java
new file mode 100644
index 0000000..c32b65a
--- /dev/null
+++ b/server/container/core/src/test/java/org/apache/james/server/core/filesystem/FileSystemImplTest.java
@@ -0,0 +1,32 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+package org.apache.james.server.core.filesystem;
+
+import org.apache.james.server.core.JamesServerResourceLoader;
+import org.apache.james.filesystem.api.AbstractFileSystemTest;
+import org.apache.james.filesystem.api.FileSystem;
+
+public class FileSystemImplTest extends AbstractFileSystemTest {
+
+    @Override
+    protected FileSystem buildFileSystem(String configurationRootDirectory) {
+        return new FileSystemImpl(new JamesServerResourceLoader(configurationRootDirectory));
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/test/java/org/apache/james/server/core/filesystem/SimpleUrlTest.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/test/java/org/apache/james/server/core/filesystem/SimpleUrlTest.java b/server/container/core/src/test/java/org/apache/james/server/core/filesystem/SimpleUrlTest.java
new file mode 100644
index 0000000..420f8b3
--- /dev/null
+++ b/server/container/core/src/test/java/org/apache/james/server/core/filesystem/SimpleUrlTest.java
@@ -0,0 +1,114 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+package org.apache.james.server.core.filesystem;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import org.junit.Test;
+
+public class SimpleUrlTest {
+
+    @Test(expected=NullPointerException.class)
+    public void simplifyPathShouldThrowOnNull() {
+        SimpleUrl.simplifyPath(null);
+    }
+    
+    @Test
+    public void simplifyPathShouldReturnEmptyOnEmptyArray() {
+        String actual = SimpleUrl.simplifyPath("");
+        assertThat(actual).isEmpty();
+    }
+
+    @Test
+    public void simplifyPathShoudReturnEmptyWhenSimplifyingCurrentDir() {
+        String actual = SimpleUrl.simplifyPath("./bar/.././foo/..");
+        assertThat(actual).isEmpty();
+    }
+
+    @Test
+    public void simplifyPathShoudReturnSimplifiedDirectory() {
+        String actual = SimpleUrl.simplifyPath("../foo/../bar/./baz");
+        assertThat(actual).isEqualTo("../bar/baz");
+    }
+
+    @Test
+    public void simplifiedShouldReturnEmptyWhenEmptyInput() {
+        assertThat(new SimpleUrl("").getSimplified()).isEmpty();
+    }
+
+    @Test(expected=NullPointerException.class)
+    public void simplifiedShouldThrowWhenNullInput() {
+        new SimpleUrl(null);
+    }
+
+    @Test
+    public void simplifiedShouldReturnInputValueWhenProtocolOnlyInput() {
+        assertThat(new SimpleUrl("file:").getSimplified()).isEqualTo("file:");
+    }
+
+    @Test
+    public void simplifiedShouldReturnInputValueWhenRelativePath() {
+        assertThat(new SimpleUrl("abcd/ef/gh").getSimplified()).isEqualTo("abcd/ef/gh");
+    }
+
+    @Test
+    public void simplifiedShouldReturnInputValueWhenAbsolutePath() {
+        assertThat(new SimpleUrl("/abcd/ef/gh").getSimplified()).isEqualTo("/abcd/ef/gh");
+    }
+
+    @Test
+    public void simplifiedShouldReturnInputValueWhenHttpUrl() {
+        assertThat(new SimpleUrl("http://example.com/ef/gh").getSimplified()).isEqualTo("http://example.com/ef/gh");
+    }
+
+    @Test
+    public void simplifiedShouldReturnInputValueWhenPathContainsColumn() {
+        assertThat(new SimpleUrl("ab/cd:ef/gh").getSimplified()).isEqualTo("ab/cd:ef/gh");
+    }
+
+    @Test
+    public void simplifiedShouldCollapseComplexePathWhenContainingParentDirElement() {
+        assertThat(new SimpleUrl("file:///home/user/./foo/../.bar/baz").getSimplified()).isEqualTo("file:///home/user/.bar/baz");
+    }
+
+    @Test
+    public void simplifiedShouldCollapseComplexePathWhenContainingParentDirElementInRelativePath() {
+        assertThat(new SimpleUrl("file://../.././foo/../.bar/baz").getSimplified()).isEqualTo("file://../../.bar/baz");
+    }
+
+    @Test
+    public void simplifiedShouldCollapseComplexePathWhenContainingParentDirElementWithoutDoubleSlashes() {
+        assertThat(new SimpleUrl("file:/home/user/./foo/../.bar/baz").getSimplified()).isEqualTo("file:/home/user/.bar/baz");
+    }
+
+    @Test
+    public void simplifiedShouldCollapseComplexePathWhenContainingParentDirElementInRelativePathWithoutDoubleSlashes() {
+        assertThat(new SimpleUrl("file:../.././foo/../.bar/baz").getSimplified()).isEqualTo("file:../../.bar/baz");
+    }
+
+    @Test
+    public void simplifiedShouldReplaceASingleWindowSeperatorByASlash() {
+        assertThat(new SimpleUrl("\\").getSimplified()).isEqualTo("/");
+    }
+
+    @Test
+    public void simplifiedShouldReplaceAllWindowsSeperatorBySlashes() {
+        assertThat(new SimpleUrl("file:c:\\\\programs\\run.exe").getSimplified()).isEqualTo("file:c://programs/run.exe");
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/guice/custom-mailets/src/main/java/com/custom/matchers/AnotherMatcher.java
----------------------------------------------------------------------
diff --git a/server/container/guice/custom-mailets/src/main/java/com/custom/matchers/AnotherMatcher.java b/server/container/guice/custom-mailets/src/main/java/com/custom/matchers/AnotherMatcher.java
index 06cd44a..1b9dd6c 100644
--- a/server/container/guice/custom-mailets/src/main/java/com/custom/matchers/AnotherMatcher.java
+++ b/server/container/guice/custom-mailets/src/main/java/com/custom/matchers/AnotherMatcher.java
@@ -24,7 +24,7 @@ import java.util.Collection;
 import javax.mail.MessagingException;
 
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.GenericMatcher;
 
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/guice/custom-mailets/src/main/java/org/apache/james/transport/matchers/CustomMatcher.java
----------------------------------------------------------------------
diff --git a/server/container/guice/custom-mailets/src/main/java/org/apache/james/transport/matchers/CustomMatcher.java b/server/container/guice/custom-mailets/src/main/java/org/apache/james/transport/matchers/CustomMatcher.java
index 785592a..eea805f 100644
--- a/server/container/guice/custom-mailets/src/main/java/org/apache/james/transport/matchers/CustomMatcher.java
+++ b/server/container/guice/custom-mailets/src/main/java/org/apache/james/transport/matchers/CustomMatcher.java
@@ -24,7 +24,7 @@ import java.util.Collection;
 import javax.mail.MessagingException;
 
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.GenericMatcher;
 
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/guice/guice-common/src/main/java/org/apache/james/modules/CommonServicesModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/CommonServicesModule.java b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/CommonServicesModule.java
index cc308a2..30d123e 100644
--- a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/CommonServicesModule.java
+++ b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/CommonServicesModule.java
@@ -24,8 +24,8 @@ import java.util.Optional;
 import javax.inject.Named;
 import javax.inject.Singleton;
 
-import org.apache.james.core.JamesServerResourceLoader;
-import org.apache.james.core.filesystem.FileSystemImpl;
+import org.apache.james.server.core.JamesServerResourceLoader;
+import org.apache.james.server.core.filesystem.FileSystemImpl;
 import org.apache.james.filesystem.api.FileSystem;
 import org.apache.james.filesystem.api.JamesDirectoriesProvider;
 import org.apache.james.modules.server.AsyncTasksExecutorModule;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/guice/guice-common/src/test/java/org/apache/james/modules/TestFilesystemModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/test/java/org/apache/james/modules/TestFilesystemModule.java b/server/container/guice/guice-common/src/test/java/org/apache/james/modules/TestFilesystemModule.java
index 9f5bba4..29486a1 100644
--- a/server/container/guice/guice-common/src/test/java/org/apache/james/modules/TestFilesystemModule.java
+++ b/server/container/guice/guice-common/src/test/java/org/apache/james/modules/TestFilesystemModule.java
@@ -23,7 +23,7 @@ import java.io.File;
 import java.io.IOException;
 import java.util.function.Supplier;
 
-import org.apache.james.core.JamesServerResourceLoader;
+import org.apache.james.server.core.JamesServerResourceLoader;
 import org.apache.james.filesystem.api.FileSystem;
 import org.apache.james.filesystem.api.JamesDirectoriesProvider;
 import org.junit.rules.TemporaryFolder;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/guice/guice-common/src/test/java/org/apache/james/utils/FileConfigurationProviderTest.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/test/java/org/apache/james/utils/FileConfigurationProviderTest.java b/server/container/guice/guice-common/src/test/java/org/apache/james/utils/FileConfigurationProviderTest.java
index 6318fc7..e9b715b 100644
--- a/server/container/guice/guice-common/src/test/java/org/apache/james/utils/FileConfigurationProviderTest.java
+++ b/server/container/guice/guice-common/src/test/java/org/apache/james/utils/FileConfigurationProviderTest.java
@@ -22,8 +22,8 @@ package org.apache.james.utils;
 import static org.assertj.core.api.Assertions.assertThat;
 
 import org.apache.commons.configuration.HierarchicalConfiguration;
-import org.apache.james.core.JamesServerResourceLoader;
-import org.apache.james.core.filesystem.FileSystemImpl;
+import org.apache.james.server.core.JamesServerResourceLoader;
+import org.apache.james.server.core.filesystem.FileSystemImpl;
 import org.apache.james.filesystem.api.FileSystem;
 import org.junit.Before;
 import org.junit.Test;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/guice/guice-common/src/test/java/org/apache/james/utils/InMemoryMailRepositoryStoreTest.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/test/java/org/apache/james/utils/InMemoryMailRepositoryStoreTest.java b/server/container/guice/guice-common/src/test/java/org/apache/james/utils/InMemoryMailRepositoryStoreTest.java
index 9964eae..8c4e309 100644
--- a/server/container/guice/guice-common/src/test/java/org/apache/james/utils/InMemoryMailRepositoryStoreTest.java
+++ b/server/container/guice/guice-common/src/test/java/org/apache/james/utils/InMemoryMailRepositoryStoreTest.java
@@ -24,8 +24,8 @@ import static org.assertj.core.api.Assertions.fail;
 
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.configuration.HierarchicalConfiguration;
-import org.apache.james.core.JamesServerResourceLoader;
-import org.apache.james.core.filesystem.FileSystemImpl;
+import org.apache.james.server.core.JamesServerResourceLoader;
+import org.apache.james.server.core.filesystem.FileSystemImpl;
 import org.apache.james.filesystem.api.FileSystem;
 import org.apache.james.mailrepository.api.MailRepositoryStore;
 import org.apache.james.mailrepository.file.FileMailRepository;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/server/MemoryMailQueueFactory.java
----------------------------------------------------------------------
diff --git a/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/server/MemoryMailQueueFactory.java b/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/server/MemoryMailQueueFactory.java
index eebc896..d3f5941 100644
--- a/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/server/MemoryMailQueueFactory.java
+++ b/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/server/MemoryMailQueueFactory.java
@@ -27,7 +27,7 @@ import java.util.concurrent.TimeUnit;
 import javax.mail.MessagingException;
 import javax.mail.internet.MimeMessage;
 
-import org.apache.james.core.MailImpl;
+import org.apache.james.server.core.MailImpl;
 import org.apache.james.queue.api.MailQueue;
 import org.apache.james.queue.api.MailQueueFactory;
 import org.apache.james.queue.api.MailQueueItemDecoratorFactory;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/spring/src/main/java/org/apache/james/container/spring/context/JamesServerApplicationContext.java
----------------------------------------------------------------------
diff --git a/server/container/spring/src/main/java/org/apache/james/container/spring/context/JamesServerApplicationContext.java b/server/container/spring/src/main/java/org/apache/james/container/spring/context/JamesServerApplicationContext.java
index 06dba52..c8bdc91 100644
--- a/server/container/spring/src/main/java/org/apache/james/container/spring/context/JamesServerApplicationContext.java
+++ b/server/container/spring/src/main/java/org/apache/james/container/spring/context/JamesServerApplicationContext.java
@@ -20,7 +20,7 @@ package org.apache.james.container.spring.context;
 
 import org.apache.james.container.spring.resource.DefaultJamesResourceLoader;
 import org.apache.james.container.spring.resource.JamesResourceLoader;
-import org.apache.james.core.JamesServerResourceLoader;
+import org.apache.james.server.core.JamesServerResourceLoader;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 import org.springframework.core.io.Resource;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/spring/src/main/java/org/apache/james/container/spring/tool/James23Importer.java
----------------------------------------------------------------------
diff --git a/server/container/spring/src/main/java/org/apache/james/container/spring/tool/James23Importer.java b/server/container/spring/src/main/java/org/apache/james/container/spring/tool/James23Importer.java
index e9fb853..f17e39d 100644
--- a/server/container/spring/src/main/java/org/apache/james/container/spring/tool/James23Importer.java
+++ b/server/container/spring/src/main/java/org/apache/james/container/spring/tool/James23Importer.java
@@ -27,7 +27,7 @@ import javax.inject.Named;
 import javax.mail.Flags;
 import javax.mail.MessagingException;
 
-import org.apache.james.core.MimeMessageInputStream;
+import org.apache.james.server.core.MimeMessageInputStream;
 import org.apache.james.domainlist.api.DomainList;
 import org.apache.james.domainlist.api.DomainListException;
 import org.apache.james.mailbox.MailboxManager;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/spring/src/test/java/org/apache/james/container/spring/filesystem/FileSystemImplTest.java
----------------------------------------------------------------------
diff --git a/server/container/spring/src/test/java/org/apache/james/container/spring/filesystem/FileSystemImplTest.java b/server/container/spring/src/test/java/org/apache/james/container/spring/filesystem/FileSystemImplTest.java
index 8b5b9e2..e878a02 100644
--- a/server/container/spring/src/test/java/org/apache/james/container/spring/filesystem/FileSystemImplTest.java
+++ b/server/container/spring/src/test/java/org/apache/james/container/spring/filesystem/FileSystemImplTest.java
@@ -21,7 +21,7 @@ package org.apache.james.container.spring.filesystem;
 import org.apache.james.container.spring.context.JamesServerApplicationContext;
 import org.apache.james.container.spring.resource.DefaultJamesResourceLoader;
 import org.apache.james.container.spring.resource.JamesResourceLoader;
-import org.apache.james.core.JamesServerResourceLoader;
+import org.apache.james.server.core.JamesServerResourceLoader;
 import org.apache.james.filesystem.api.AbstractFileSystemTest;
 import org.apache.james.filesystem.api.FileSystem;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/data/data-api/src/main/java/org/apache/james/user/api/UsersRepository.java
----------------------------------------------------------------------
diff --git a/server/data/data-api/src/main/java/org/apache/james/user/api/UsersRepository.java b/server/data/data-api/src/main/java/org/apache/james/user/api/UsersRepository.java
index 038fd30..8cb09ac 100644
--- a/server/data/data-api/src/main/java/org/apache/james/user/api/UsersRepository.java
+++ b/server/data/data-api/src/main/java/org/apache/james/user/api/UsersRepository.java
@@ -22,7 +22,7 @@ package org.apache.james.user.api;
 import java.util.Iterator;
 
 import org.apache.james.user.api.model.User;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 
 /**
  * Interface for a repository of users. A repository represents a logical

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/data/data-api/src/main/java/org/apache/james/user/api/model/JamesUser.java
----------------------------------------------------------------------
diff --git a/server/data/data-api/src/main/java/org/apache/james/user/api/model/JamesUser.java b/server/data/data-api/src/main/java/org/apache/james/user/api/model/JamesUser.java
index 65dda8a..1db501d 100644
--- a/server/data/data-api/src/main/java/org/apache/james/user/api/model/JamesUser.java
+++ b/server/data/data-api/src/main/java/org/apache/james/user/api/model/JamesUser.java
@@ -19,7 +19,7 @@
 
 package org.apache.james.user.api.model;
 
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 
 /**
  * Interface for objects representing users of an email/ messaging system.

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/data/data-file/src/main/java/org/apache/james/mailrepository/file/FileMailRepository.java
----------------------------------------------------------------------
diff --git a/server/data/data-file/src/main/java/org/apache/james/mailrepository/file/FileMailRepository.java b/server/data/data-file/src/main/java/org/apache/james/mailrepository/file/FileMailRepository.java
index b26d2e2..9865783 100644
--- a/server/data/data-file/src/main/java/org/apache/james/mailrepository/file/FileMailRepository.java
+++ b/server/data/data-file/src/main/java/org/apache/james/mailrepository/file/FileMailRepository.java
@@ -35,8 +35,8 @@ import javax.mail.internet.MimeMessage;
 
 import org.apache.commons.configuration.DefaultConfigurationBuilder;
 import org.apache.commons.configuration.HierarchicalConfiguration;
-import org.apache.james.core.MimeMessageCopyOnWriteProxy;
-import org.apache.james.core.MimeMessageWrapper;
+import org.apache.james.server.core.MimeMessageCopyOnWriteProxy;
+import org.apache.james.server.core.MimeMessageWrapper;
 import org.apache.james.filesystem.api.FileSystem;
 import org.apache.james.mailrepository.lib.AbstractMailRepository;
 import org.apache.james.repository.file.FilePersistentObjectRepository;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/data/data-file/src/main/java/org/apache/james/mailrepository/file/MBoxMailRepository.java
----------------------------------------------------------------------
diff --git a/server/data/data-file/src/main/java/org/apache/james/mailrepository/file/MBoxMailRepository.java b/server/data/data-file/src/main/java/org/apache/james/mailrepository/file/MBoxMailRepository.java
index f96e883..2ea4417 100755
--- a/server/data/data-file/src/main/java/org/apache/james/mailrepository/file/MBoxMailRepository.java
+++ b/server/data/data-file/src/main/java/org/apache/james/mailrepository/file/MBoxMailRepository.java
@@ -72,7 +72,7 @@ import javax.mail.internet.MimeMessage;
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.configuration.HierarchicalConfiguration;
 import org.apache.commons.io.FileUtils;
-import org.apache.james.core.MailImpl;
+import org.apache.james.server.core.MailImpl;
 import org.apache.james.lifecycle.api.Configurable;
 import org.apache.james.mailrepository.api.MailRepository;
 import org.apache.mailet.Mail;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/data/data-file/src/main/java/org/apache/james/mailrepository/file/MimeMessageStreamRepositorySource.java
----------------------------------------------------------------------
diff --git a/server/data/data-file/src/main/java/org/apache/james/mailrepository/file/MimeMessageStreamRepositorySource.java b/server/data/data-file/src/main/java/org/apache/james/mailrepository/file/MimeMessageStreamRepositorySource.java
index 4cc7c71..a06475f 100644
--- a/server/data/data-file/src/main/java/org/apache/james/mailrepository/file/MimeMessageStreamRepositorySource.java
+++ b/server/data/data-file/src/main/java/org/apache/james/mailrepository/file/MimeMessageStreamRepositorySource.java
@@ -19,7 +19,7 @@
 
 package org.apache.james.mailrepository.file;
 
-import org.apache.james.core.MimeMessageSource;
+import org.apache.james.server.core.MimeMessageSource;
 import org.apache.james.repository.api.StreamRepository;
 
 import java.io.IOException;
@@ -87,7 +87,7 @@ public class MimeMessageStreamRepositorySource extends MimeMessageSource {
     }
 
     /**
-     * @see org.apache.james.core.MimeMessageSource#getMessageSize()
+     * @see org.apache.james.server.core.MimeMessageSource#getMessageSize()
      */
     public long getMessageSize() throws IOException {
         if (size == -1) {

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/data/data-jcr/src/main/java/org/apache/james/mailrepository/jcr/JCRMailRepository.java
----------------------------------------------------------------------
diff --git a/server/data/data-jcr/src/main/java/org/apache/james/mailrepository/jcr/JCRMailRepository.java b/server/data/data-jcr/src/main/java/org/apache/james/mailrepository/jcr/JCRMailRepository.java
index 475bc45..6c3e796 100644
--- a/server/data/data-jcr/src/main/java/org/apache/james/mailrepository/jcr/JCRMailRepository.java
+++ b/server/data/data-jcr/src/main/java/org/apache/james/mailrepository/jcr/JCRMailRepository.java
@@ -58,11 +58,11 @@ import org.apache.commons.io.IOUtils;
 import org.apache.jackrabbit.commons.cnd.CndImporter;
 import org.apache.jackrabbit.util.ISO9075;
 import org.apache.jackrabbit.util.Text;
-import org.apache.james.core.MailImpl;
+import org.apache.james.server.core.MailImpl;
 import org.apache.james.mailrepository.api.MailRepository;
 import org.apache.james.mailrepository.lib.AbstractMailRepository;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/data/data-jdbc/src/main/java/org/apache/james/mailrepository/jdbc/JDBCMailRepository.java
----------------------------------------------------------------------
diff --git a/server/data/data-jdbc/src/main/java/org/apache/james/mailrepository/jdbc/JDBCMailRepository.java b/server/data/data-jdbc/src/main/java/org/apache/james/mailrepository/jdbc/JDBCMailRepository.java
index 00c5d2a..d1ad86c 100644
--- a/server/data/data-jdbc/src/main/java/org/apache/james/mailrepository/jdbc/JDBCMailRepository.java
+++ b/server/data/data-jdbc/src/main/java/org/apache/james/mailrepository/jdbc/JDBCMailRepository.java
@@ -51,16 +51,16 @@ import javax.sql.DataSource;
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.configuration.DefaultConfigurationBuilder;
 import org.apache.commons.configuration.HierarchicalConfiguration;
-import org.apache.james.core.MailImpl;
-import org.apache.james.core.MimeMessageCopyOnWriteProxy;
-import org.apache.james.core.MimeMessageWrapper;
+import org.apache.james.server.core.MailImpl;
+import org.apache.james.server.core.MimeMessageCopyOnWriteProxy;
+import org.apache.james.server.core.MimeMessageWrapper;
 import org.apache.james.filesystem.api.FileSystem;
 import org.apache.james.mailrepository.lib.AbstractMailRepository;
 import org.apache.james.repository.file.FilePersistentStreamRepository;
 import org.apache.james.util.sql.JDBCUtil;
 import org.apache.james.util.sql.SqlResources;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/data/data-jdbc/src/main/java/org/apache/james/mailrepository/jdbc/MessageInputStream.java
----------------------------------------------------------------------
diff --git a/server/data/data-jdbc/src/main/java/org/apache/james/mailrepository/jdbc/MessageInputStream.java b/server/data/data-jdbc/src/main/java/org/apache/james/mailrepository/jdbc/MessageInputStream.java
index 1474431..4985da6 100644
--- a/server/data/data-jdbc/src/main/java/org/apache/james/mailrepository/jdbc/MessageInputStream.java
+++ b/server/data/data-jdbc/src/main/java/org/apache/james/mailrepository/jdbc/MessageInputStream.java
@@ -30,9 +30,9 @@ import java.io.PipedOutputStream;
 import javax.mail.MessagingException;
 import javax.mail.internet.MimeMessage;
 
-import org.apache.james.core.MimeMessageCopyOnWriteProxy;
-import org.apache.james.core.MimeMessageUtil;
-import org.apache.james.core.MimeMessageWrapper;
+import org.apache.james.server.core.MimeMessageCopyOnWriteProxy;
+import org.apache.james.server.core.MimeMessageUtil;
+import org.apache.james.server.core.MimeMessageWrapper;
 import org.apache.james.repository.api.StreamRepository;
 import org.apache.mailet.Mail;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/data/data-jdbc/src/main/java/org/apache/james/mailrepository/jdbc/MimeMessageJDBCSource.java
----------------------------------------------------------------------
diff --git a/server/data/data-jdbc/src/main/java/org/apache/james/mailrepository/jdbc/MimeMessageJDBCSource.java b/server/data/data-jdbc/src/main/java/org/apache/james/mailrepository/jdbc/MimeMessageJDBCSource.java
index 53373da..fab0714 100644
--- a/server/data/data-jdbc/src/main/java/org/apache/james/mailrepository/jdbc/MimeMessageJDBCSource.java
+++ b/server/data/data-jdbc/src/main/java/org/apache/james/mailrepository/jdbc/MimeMessageJDBCSource.java
@@ -29,7 +29,7 @@ import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 
-import org.apache.james.core.MimeMessageSource;
+import org.apache.james.server.core.MimeMessageSource;
 import org.apache.james.repository.api.StreamRepository;
 import org.apache.james.util.sql.JDBCUtil;
 
@@ -117,7 +117,7 @@ public class MimeMessageJDBCSource extends MimeMessageSource {
      * is to support a repository with the entire message in the database, which
      * is how James 1.2 worked.
      * 
-     * @see org.apache.james.core.MimeMessageSource#getInputStream()
+     * @see org.apache.james.server.core.MimeMessageSource#getInputStream()
      */
     public synchronized InputStream getInputStream() throws IOException {
         Connection conn = null;
@@ -176,7 +176,7 @@ public class MimeMessageJDBCSource extends MimeMessageSource {
     /**
      * Runs a custom SQL statement to check the size of the message body
      * 
-     * @see org.apache.james.core.MimeMessageSource#getMessageSize()
+     * @see org.apache.james.server.core.MimeMessageSource#getMessageSize()
      */
     public synchronized long getMessageSize() throws IOException {
         if (size != -1)

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/data/data-jdbc/src/main/java/org/apache/james/user/jdbc/JamesUsersJdbcRepository.java
----------------------------------------------------------------------
diff --git a/server/data/data-jdbc/src/main/java/org/apache/james/user/jdbc/JamesUsersJdbcRepository.java b/server/data/data-jdbc/src/main/java/org/apache/james/user/jdbc/JamesUsersJdbcRepository.java
index 6f2756d..ed3f182 100644
--- a/server/data/data-jdbc/src/main/java/org/apache/james/user/jdbc/JamesUsersJdbcRepository.java
+++ b/server/data/data-jdbc/src/main/java/org/apache/james/user/jdbc/JamesUsersJdbcRepository.java
@@ -22,7 +22,7 @@ package org.apache.james.user.jdbc;
 import org.apache.james.user.api.model.User;
 import org.apache.james.user.lib.model.DefaultJamesUser;
 import org.apache.james.user.lib.model.DefaultUser;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/data/data-jmap/src/main/java/org/apache/james/jmap/api/vacation/RecipientId.java
----------------------------------------------------------------------
diff --git a/server/data/data-jmap/src/main/java/org/apache/james/jmap/api/vacation/RecipientId.java b/server/data/data-jmap/src/main/java/org/apache/james/jmap/api/vacation/RecipientId.java
index 9bae604..f8e8f2c 100644
--- a/server/data/data-jmap/src/main/java/org/apache/james/jmap/api/vacation/RecipientId.java
+++ b/server/data/data-jmap/src/main/java/org/apache/james/jmap/api/vacation/RecipientId.java
@@ -21,7 +21,7 @@ package org.apache.james.jmap.api.vacation;
 
 import java.util.Objects;
 
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 
 import com.google.common.base.Preconditions;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/data/data-jmap/src/test/java/org/apache/james/jmap/api/vacation/AbstractNotificationRegistryTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-jmap/src/test/java/org/apache/james/jmap/api/vacation/AbstractNotificationRegistryTest.java b/server/data/data-jmap/src/test/java/org/apache/james/jmap/api/vacation/AbstractNotificationRegistryTest.java
index ba687d0..dd31bae 100644
--- a/server/data/data-jmap/src/test/java/org/apache/james/jmap/api/vacation/AbstractNotificationRegistryTest.java
+++ b/server/data/data-jmap/src/test/java/org/apache/james/jmap/api/vacation/AbstractNotificationRegistryTest.java
@@ -29,7 +29,7 @@ import java.util.Optional;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.james.util.date.ZonedDateTimeProvider;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.junit.Before;
 import org.junit.Test;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/data/data-ldap-integration-testing/src/test/java/org/apache/james/user/ldap/ReadOnlyUsersLDAPRepositoryTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-ldap-integration-testing/src/test/java/org/apache/james/user/ldap/ReadOnlyUsersLDAPRepositoryTest.java b/server/data/data-ldap-integration-testing/src/test/java/org/apache/james/user/ldap/ReadOnlyUsersLDAPRepositoryTest.java
index 785d74f..619f2af 100644
--- a/server/data/data-ldap-integration-testing/src/test/java/org/apache/james/user/ldap/ReadOnlyUsersLDAPRepositoryTest.java
+++ b/server/data/data-ldap-integration-testing/src/test/java/org/apache/james/user/ldap/ReadOnlyUsersLDAPRepositoryTest.java
@@ -23,7 +23,7 @@ import static org.assertj.core.api.Assertions.assertThat;
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.configuration.HierarchicalConfiguration;
 import org.apache.commons.configuration.plist.PropertyListConfiguration;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/data/data-ldap/src/main/java/org/apache/james/user/ldap/ReadOnlyUsersLDAPRepository.java
----------------------------------------------------------------------
diff --git a/server/data/data-ldap/src/main/java/org/apache/james/user/ldap/ReadOnlyUsersLDAPRepository.java b/server/data/data-ldap/src/main/java/org/apache/james/user/ldap/ReadOnlyUsersLDAPRepository.java
index bae64b4..27092ac 100644
--- a/server/data/data-ldap/src/main/java/org/apache/james/user/ldap/ReadOnlyUsersLDAPRepository.java
+++ b/server/data/data-ldap/src/main/java/org/apache/james/user/ldap/ReadOnlyUsersLDAPRepository.java
@@ -50,7 +50,7 @@ import org.apache.james.util.retry.naming.ldap.RetryingLdapContext;
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.configuration.HierarchicalConfiguration;
 import org.apache.commons.lang.StringUtils;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/data/data-library/src/main/java/org/apache/james/rrt/lib/AbstractRecipientRewriteTable.java
----------------------------------------------------------------------
diff --git a/server/data/data-library/src/main/java/org/apache/james/rrt/lib/AbstractRecipientRewriteTable.java b/server/data/data-library/src/main/java/org/apache/james/rrt/lib/AbstractRecipientRewriteTable.java
index ff40572..7e429f5 100644
--- a/server/data/data-library/src/main/java/org/apache/james/rrt/lib/AbstractRecipientRewriteTable.java
+++ b/server/data/data-library/src/main/java/org/apache/james/rrt/lib/AbstractRecipientRewriteTable.java
@@ -34,7 +34,7 @@ import org.apache.james.lifecycle.api.Configurable;
 import org.apache.james.rrt.api.RecipientRewriteTable;
 import org.apache.james.rrt.api.RecipientRewriteTableException;
 import org.apache.james.rrt.lib.Mapping.Type;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/data/data-library/src/main/java/org/apache/james/rrt/lib/RecipientRewriteTableUtil.java
----------------------------------------------------------------------
diff --git a/server/data/data-library/src/main/java/org/apache/james/rrt/lib/RecipientRewriteTableUtil.java b/server/data/data-library/src/main/java/org/apache/james/rrt/lib/RecipientRewriteTableUtil.java
index c3859e0..966feee 100644
--- a/server/data/data-library/src/main/java/org/apache/james/rrt/lib/RecipientRewriteTableUtil.java
+++ b/server/data/data-library/src/main/java/org/apache/james/rrt/lib/RecipientRewriteTableUtil.java
@@ -27,7 +27,7 @@ import java.util.regex.Pattern;
 import java.util.regex.PatternSyntaxException;
 
 import org.apache.james.rrt.api.RecipientRewriteTable;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 
 /**
  * This helper class contains methods for the RecipientRewriteTable implementations

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/data/data-library/src/main/java/org/apache/james/user/lib/AbstractUsersRepository.java
----------------------------------------------------------------------
diff --git a/server/data/data-library/src/main/java/org/apache/james/user/lib/AbstractUsersRepository.java b/server/data/data-library/src/main/java/org/apache/james/user/lib/AbstractUsersRepository.java
index 28f6128..ebc60ee 100644
--- a/server/data/data-library/src/main/java/org/apache/james/user/lib/AbstractUsersRepository.java
+++ b/server/data/data-library/src/main/java/org/apache/james/user/lib/AbstractUsersRepository.java
@@ -30,7 +30,7 @@ import org.apache.james.user.api.UsersRepository;
 import org.apache.james.user.api.UsersRepositoryException;
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.configuration.HierarchicalConfiguration;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 
 import com.google.common.annotations.VisibleForTesting;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/data/data-library/src/main/java/org/apache/james/user/lib/model/DefaultJamesUser.java
----------------------------------------------------------------------
diff --git a/server/data/data-library/src/main/java/org/apache/james/user/lib/model/DefaultJamesUser.java b/server/data/data-library/src/main/java/org/apache/james/user/lib/model/DefaultJamesUser.java
index 29e449a..6f0960e 100644
--- a/server/data/data-library/src/main/java/org/apache/james/user/lib/model/DefaultJamesUser.java
+++ b/server/data/data-library/src/main/java/org/apache/james/user/lib/model/DefaultJamesUser.java
@@ -20,7 +20,7 @@
 package org.apache.james.user.lib.model;
 
 import org.apache.james.user.api.model.JamesUser;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 
 /**
  * Implementation of User Interface.
@@ -87,7 +87,7 @@ public class DefaultJamesUser extends DefaultUser implements JamesUser {
     }
 
     /**
-     * @see org.apache.james.user.api.model.JamesUser#setForwardingDestination(org.apache.mailet.MailAddress)
+     * @see org.apache.james.user.api.model.JamesUser#setForwardingDestination(MailAddress)
      */
     public boolean setForwardingDestination(MailAddress address) {
         /* TODO: Some verification would be good */

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/data/data-library/src/test/java/org/apache/james/mailrepository/AbstractMailRepositoryTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-library/src/test/java/org/apache/james/mailrepository/AbstractMailRepositoryTest.java b/server/data/data-library/src/test/java/org/apache/james/mailrepository/AbstractMailRepositoryTest.java
index 56e3979..571d314 100644
--- a/server/data/data-library/src/test/java/org/apache/james/mailrepository/AbstractMailRepositoryTest.java
+++ b/server/data/data-library/src/test/java/org/apache/james/mailrepository/AbstractMailRepositoryTest.java
@@ -33,13 +33,13 @@ import javax.mail.MessagingException;
 import javax.mail.internet.MimeMessage;
 import javax.mail.util.SharedByteArrayInputStream;
 
-import org.apache.james.core.MailImpl;
-import org.apache.james.core.MimeMessageCopyOnWriteProxy;
-import org.apache.james.core.MimeMessageInputStreamSource;
+import org.apache.james.server.core.MailImpl;
+import org.apache.james.server.core.MimeMessageCopyOnWriteProxy;
+import org.apache.james.server.core.MimeMessageInputStreamSource;
 import org.apache.james.lifecycle.api.LifecycleUtil;
 import org.apache.james.mailrepository.api.MailRepository;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/data/data-library/src/test/java/org/apache/james/user/lib/AbstractUsersRepositoryTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-library/src/test/java/org/apache/james/user/lib/AbstractUsersRepositoryTest.java b/server/data/data-library/src/test/java/org/apache/james/user/lib/AbstractUsersRepositoryTest.java
index a4d889d..dd52a7f 100644
--- a/server/data/data-library/src/test/java/org/apache/james/user/lib/AbstractUsersRepositoryTest.java
+++ b/server/data/data-library/src/test/java/org/apache/james/user/lib/AbstractUsersRepositoryTest.java
@@ -28,7 +28,7 @@ import org.apache.james.lifecycle.api.LifecycleUtil;
 import org.apache.james.user.api.AlreadyExistInUsersRepositoryException;
 import org.apache.james.user.api.UsersRepositoryException;
 import org.apache.james.user.api.model.User;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.junit.Assume;
 import org.junit.Test;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/TemporaryFilesystemModule.java
----------------------------------------------------------------------
diff --git a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/TemporaryFilesystemModule.java b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/TemporaryFilesystemModule.java
index 7aee891..22eaac4 100644
--- a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/TemporaryFilesystemModule.java
+++ b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/TemporaryFilesystemModule.java
@@ -30,7 +30,7 @@ import java.util.List;
 import java.util.function.Supplier;
 
 import org.apache.commons.io.IOUtils;
-import org.apache.james.core.JamesServerResourceLoader;
+import org.apache.james.server.core.JamesServerResourceLoader;
 import org.apache.james.filesystem.api.FileSystem;
 import org.apache.james.filesystem.api.JamesDirectoriesProvider;
 import org.apache.james.modules.CommonServicesModule;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/AmqpForwardAttachmentTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/AmqpForwardAttachmentTest.java b/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/AmqpForwardAttachmentTest.java
index 01a3e02..47f71c4 100644
--- a/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/AmqpForwardAttachmentTest.java
+++ b/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/AmqpForwardAttachmentTest.java
@@ -37,7 +37,7 @@ import org.apache.james.util.streams.SwarmGenericContainer;
 import org.apache.james.utils.IMAPMessageReader;
 import org.apache.james.utils.DataProbeImpl;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.MimeMessageBuilder;
 import org.junit.After;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/ICSAttachmentWorkflowTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/ICSAttachmentWorkflowTest.java b/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/ICSAttachmentWorkflowTest.java
index 15b1fac..6247e2e 100644
--- a/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/ICSAttachmentWorkflowTest.java
+++ b/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/ICSAttachmentWorkflowTest.java
@@ -39,7 +39,7 @@ import org.apache.james.util.streams.SwarmGenericContainer;
 import org.apache.james.utils.IMAPMessageReader;
 import org.apache.james.utils.DataProbeImpl;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.MimeMessageBuilder;
 import org.junit.After;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/StripAttachmentTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/StripAttachmentTest.java b/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/StripAttachmentTest.java
index b11d216..bb24326 100644
--- a/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/StripAttachmentTest.java
+++ b/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/StripAttachmentTest.java
@@ -35,7 +35,7 @@ import org.apache.james.probe.DataProbe;
 import org.apache.james.utils.IMAPMessageReader;
 import org.apache.james.utils.DataProbeImpl;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.MimeMessageBuilder;
 import org.junit.After;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/ExceptionThrowingMatcher.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/ExceptionThrowingMatcher.java b/server/mailet/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/ExceptionThrowingMatcher.java
index cd5e98e..839c981 100644
--- a/server/mailet/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/ExceptionThrowingMatcher.java
+++ b/server/mailet/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/ExceptionThrowingMatcher.java
@@ -21,7 +21,7 @@ package org.apache.james.mailetcontainer.api.mock;
 import java.util.Collection;
 import javax.mail.MessagingException;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.Matcher;
 import org.apache.mailet.MatcherConfig;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailetContext.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailetContext.java b/server/mailet/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailetContext.java
index 8662256..ac061d7 100644
--- a/server/mailet/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailetContext.java
+++ b/server/mailet/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailetContext.java
@@ -32,7 +32,7 @@ import javax.mail.internet.MimeMessage;
 import org.apache.mailet.HostAddress;
 import org.apache.mailet.LookupException;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.MailetContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMatcher.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMatcher.java b/server/mailet/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMatcher.java
index 6407eb8..170e83f 100644
--- a/server/mailet/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMatcher.java
+++ b/server/mailet/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMatcher.java
@@ -26,7 +26,7 @@ import java.util.List;
 import javax.mail.MessagingException;
 
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.Matcher;
 import org.apache.mailet.MatcherConfig;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/JamesMailetContext.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/JamesMailetContext.java b/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/JamesMailetContext.java
index c0fa112..197035e 100644
--- a/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/JamesMailetContext.java
+++ b/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/JamesMailetContext.java
@@ -40,7 +40,7 @@ import javax.mail.internet.ParseException;
 
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.configuration.HierarchicalConfiguration;
-import org.apache.james.core.MailImpl;
+import org.apache.james.server.core.MailImpl;
 import org.apache.james.dnsservice.api.DNSService;
 import org.apache.james.dnsservice.api.TemporaryResolutionException;
 import org.apache.james.dnsservice.library.MXHostAddressIterator;
@@ -55,7 +55,7 @@ import org.apache.james.user.api.UsersRepositoryException;
 import org.apache.mailet.HostAddress;
 import org.apache.mailet.LookupException;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.MailetContext;
 import org.apache.mailet.base.RFC2822Headers;
 import org.slf4j.Logger;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/ProcessorUtil.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/ProcessorUtil.java b/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/ProcessorUtil.java
index 1d127c4..25adf18 100644
--- a/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/ProcessorUtil.java
+++ b/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/ProcessorUtil.java
@@ -26,7 +26,7 @@ import java.util.Collection;
 import javax.mail.MessagingException;
 
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.MailetException;
 import org.slf4j.Logger;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/camel/MatcherSplitter.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/camel/MatcherSplitter.java b/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/camel/MatcherSplitter.java
index ff5b812..df09138 100644
--- a/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/camel/MatcherSplitter.java
+++ b/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/camel/MatcherSplitter.java
@@ -32,14 +32,14 @@ import org.apache.camel.Body;
 import org.apache.camel.ExchangeProperty;
 import org.apache.camel.Handler;
 import org.apache.camel.InOnly;
-import org.apache.james.core.MailImpl;
+import org.apache.james.server.core.MailImpl;
 import org.apache.james.mailetcontainer.impl.ProcessorUtil;
 import org.apache.james.mailetcontainer.lib.AbstractStateMailetProcessor.MailetProcessorListener;
 import org.apache.james.metrics.api.MetricFactory;
 import org.apache.james.metrics.api.TimeMetric;
 import org.apache.james.util.MDCBuilder;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.Matcher;
 import org.slf4j.Logger;
 


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


[19/23] james-project git commit: JAMES-2138 Documenting group feature on the website

Posted by bt...@apache.org.
JAMES-2138 Documenting group feature on the website


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/55f476a6
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/55f476a6
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/55f476a6

Branch: refs/heads/master
Commit: 55f476a68e3b709d00a4b2909781941474c87500
Parents: dc2ad6d
Author: benwa <bt...@linagora.com>
Authored: Wed Sep 6 14:09:36 2017 +0700
Committer: benwa <bt...@linagora.com>
Committed: Sat Sep 9 10:46:41 2017 +0700

----------------------------------------------------------------------
 src/site/markdown/server/manage-webadmin.md | 75 ++++++++++++++++++++++++
 1 file changed, 75 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/55f476a6/src/site/markdown/server/manage-webadmin.md
----------------------------------------------------------------------
diff --git a/src/site/markdown/server/manage-webadmin.md b/src/site/markdown/server/manage-webadmin.md
index 2f9a2f6..5fb5d2c 100644
--- a/src/site/markdown/server/manage-webadmin.md
+++ b/src/site/markdown/server/manage-webadmin.md
@@ -425,3 +425,78 @@ Note that several calls to this endpoint will be run in a sequential pattern.
 
 If the server restarts during the migration, the migration is silently aborted.
 
+## Creating address group
+
+You can use **webadmin** to define address groups.
+
+When a specific email is sent to the group mail address, every group member will receive it.
+
+This feature uses [Recipients rewrite table](/server/config-recipientrewritetable.html) and requires
+the [RecipientRewriteTable mailet](https://github.com/apache/james-project/blob/master/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/RecipientRewriteTable.java)
+to be configured.
+
+### Listing groups
+
+```
+curl -XGET http://ip:port/address/groups
+```
+
+Will return the groups as a list of JSON Strings representing mail addresses. For instance:
+
+```
+["group1@domain.com", "group2@domain.com"]
+```
+
+Response codes:
+
+ - 200: Success
+ - 500: Internal error
+
+### Listing members of a group
+
+```
+curl -XGET http://ip:port/address/groups/group@domain.com
+```
+
+Will return the group members as a list of JSON Strings representing mail addresses. For instance:
+
+```
+["member1@domain.com", "member2@domain.com"]
+```
+
+Response codes:
+
+ - 200: Success
+ - 400: Group structure is not valid
+ - 404: The group does not exist
+ - 500: Internal error
+
+### Adding a group member
+
+```
+curl -XPUT http://ip:port/address/groups/group@domain.com/member@domain.com
+```
+
+Will add member@domain.com to group@domain.com, creating the group if needed
+
+Response codes:
+
+ - 200: Success
+ - 400: Group structure or member is not valid
+ - 403: Server does not own the requested domain
+ - 409: Requested group address is already used for another purpose
+ - 500: Internal error
+
+### Removing a group member
+
+```
+curl -XDELETE http://ip:port/address/groups/group@domain.com/member@domain.com
+```
+
+Will remove member@domain.com from group@domain.com, removing the group if group is empty after deletion
+
+Response codes:
+
+ - 200: Success
+ - 400: Group structure or member is not valid
+ - 500: Internal error
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


[12/23] james-project git commit: JAMES-2138 move MailAddress to a new james-core project

Posted by bt...@apache.org.
http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/main/java/org/apache/james/core/MimeMessageWrapper.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/main/java/org/apache/james/core/MimeMessageWrapper.java b/server/container/core/src/main/java/org/apache/james/core/MimeMessageWrapper.java
deleted file mode 100644
index 71780ce..0000000
--- a/server/container/core/src/main/java/org/apache/james/core/MimeMessageWrapper.java
+++ /dev/null
@@ -1,705 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-
-package org.apache.james.core;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.LineNumberReader;
-import java.io.OutputStream;
-import java.io.SequenceInputStream;
-import java.util.Enumeration;
-import java.util.UUID;
-
-import javax.activation.DataHandler;
-import javax.mail.MessagingException;
-import javax.mail.Session;
-import javax.mail.internet.InternetHeaders;
-import javax.mail.internet.MimeMessage;
-import javax.mail.util.SharedByteArrayInputStream;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.james.lifecycle.api.Disposable;
-import org.apache.james.lifecycle.api.LifecycleUtil;
-
-/**
- * This object wraps a MimeMessage, only loading the underlying MimeMessage
- * object when needed. Also tracks if changes were made to reduce unnecessary
- * saves.
- */
-public class MimeMessageWrapper extends MimeMessage implements Disposable {
-
-    /**
-     * System property which tells JAMES if it should copy a message in memory
-     * or via a temporary file. Default is the file
-     */
-    public final static String USE_MEMORY_COPY = "james.message.usememorycopy";
-
-    /**
-     * Can provide an input stream to the data
-     */
-    protected MimeMessageSource source = null;
-
-    /**
-     * This is false until we parse the message
-     */
-    protected boolean messageParsed = false;
-
-    /**
-     * This is false until we parse the message
-     */
-    protected boolean headersModified = false;
-
-    /**
-     * This is false until we parse the message
-     */
-    protected boolean bodyModified = false;
-
-    /**
-     * Keep a reference to the sourceIn so we can close it only when we dispose
-     * the message.
-     */
-    private InputStream sourceIn;
-
-    private long initialHeaderSize;
-
-    private MimeMessageWrapper(Session session) {
-        super(session);
-        this.headers = null;
-        this.modified = false;
-        this.headersModified = false;
-        this.bodyModified = false;
-    }
-
-    /**
-     * A constructor that instantiates a MimeMessageWrapper based on a
-     * MimeMessageSource
-     * 
-     * @param source
-     *            the MimeMessageSource
-     * @throws MessagingException
-     */
-    public MimeMessageWrapper(Session session, MimeMessageSource source) {
-        this(session);
-        this.source = source;
-    }
-
-    /**
-     * A constructor that instantiates a MimeMessageWrapper based on a
-     * MimeMessageSource
-     * 
-     * @param source
-     *            the MimeMessageSource
-     * @throws MessagingException
-     * @throws MessagingException
-     */
-    public MimeMessageWrapper(MimeMessageSource source) {
-        this(Session.getDefaultInstance(System.getProperties()), source);
-    }
-
-    public MimeMessageWrapper(MimeMessage original) throws MessagingException {
-        this(Session.getDefaultInstance(System.getProperties()));
-        flags = original.getFlags();
-
-        if (source == null) {
-            InputStream in;
-
-            boolean useMemoryCopy = false;
-            String memoryCopy = System.getProperty(USE_MEMORY_COPY);
-            if (memoryCopy != null) {
-                useMemoryCopy = Boolean.valueOf(memoryCopy);
-            }
-            try {
-
-                if (useMemoryCopy) {
-                    ByteArrayOutputStream bos;
-                    int size = original.getSize();
-                    if (size > 0) {
-                        bos = new ByteArrayOutputStream(size);
-                    } else {
-                        bos = new ByteArrayOutputStream();
-                    }
-                    original.writeTo(bos);
-                    bos.close();
-                    in = new SharedByteArrayInputStream(bos.toByteArray());
-                    parse(in);
-                    in.close();
-                    saved = true;
-                } else {
-                    MimeMessageInputStreamSource src = new MimeMessageInputStreamSource("MailCopy-" + UUID.randomUUID().toString());
-                    OutputStream out = src.getWritableOutputStream();
-                    original.writeTo(out);
-                    out.close();
-                    source = src;
-                }
-
-            } catch (IOException ex) {
-                // should never happen, but just in case...
-                throw new MessagingException("IOException while copying message", ex);
-            }
-        }
-    }
-
-    /**
-     * Overrides default javamail behaviour by not altering the Message-ID by
-     * default, see <a href="https://issues.apache.org/jira/browse/JAMES-875">JAMES-875</a> and
-     * <a href="https://issues.apache.org/jira/browse/JAMES-1010">JAMES-1010</a>
-     *
-     * @see javax.mail.internet.MimeMessage#updateMessageID()
-     */
-    @Override
-    protected void updateMessageID() throws MessagingException {
-        if (getMessageID() == null)
-            super.updateMessageID();
-    }
-
-    /**
-     * Returns the source ID of the MimeMessageSource that is supplying this
-     * with data.
-     * 
-     * @see MimeMessageSource
-     */
-    public synchronized String getSourceId() {
-        return source != null ? source.getSourceId() : null;
-    }
-
-    /**
-     * Load the message headers from the internal source.
-     * 
-     * @throws MessagingException
-     *             if an error is encountered while loading the headers
-     */
-    protected synchronized void loadHeaders() throws MessagingException {
-        if (headers != null) {
-            // Another thread has already loaded these headers
-        } else if (source != null) {
-            try {
-                InputStream in = source.getInputStream();
-                try {
-                    headers = createInternetHeaders(in);
-
-                } finally {
-                    IOUtils.closeQuietly(in);
-                }
-            } catch (IOException ioe) {
-                throw new MessagingException("Unable to parse headers from stream: " + ioe.getMessage(), ioe);
-            }
-        } else {
-            throw new MessagingException("loadHeaders called for a message with no source, contentStream or stream");
-        }
-    }
-
-    /**
-     * Load the complete MimeMessage from the internal source.
-     * 
-     * @throws MessagingException
-     *             if an error is encountered while loading the message
-     */
-    public synchronized void loadMessage() throws MessagingException {
-        if (messageParsed) {
-            // Another thread has already loaded this message
-        } else if (source != null) {
-            sourceIn = null;
-            try {
-                sourceIn = source.getInputStream();
-
-                parse(sourceIn);
-                // TODO is it ok?
-                saved = true;
-
-            } catch (IOException ioe) {
-                IOUtils.closeQuietly(sourceIn);
-                sourceIn = null;
-                throw new MessagingException("Unable to parse stream: " + ioe.getMessage(), ioe);
-            }
-        } else {
-            throw new MessagingException("loadHeaders called for an unparsed message with no source");
-        }
-    }
-
-    /**
-     * Get whether the message has been modified.
-     * 
-     * @return whether the message has been modified
-     */
-    public synchronized boolean isModified() {
-        return headersModified || bodyModified || modified;
-    }
-
-    /**
-     * Get whether the body of the message has been modified
-     * 
-     * @return bodyModified
-     */
-    public synchronized boolean isBodyModified() {
-        return bodyModified;
-    }
-
-    /**
-     * Get whether the header of the message has been modified
-     * 
-     * @return headersModified
-     */
-    public synchronized boolean isHeaderModified() {
-        return headersModified;
-    }
-
-    /**
-     * Rewritten for optimization purposes
-     */
-    @Override
-    public void writeTo(OutputStream os) throws IOException, MessagingException {
-        writeTo(os, os);
-
-    }
-
-    /**
-     * Rewritten for optimization purposes
-     */
-    @Override
-    public void writeTo(OutputStream os, String[] ignoreList) throws IOException, MessagingException {
-        writeTo(os, os, ignoreList);
-    }
-
-    /**
-     * Write
-     */
-    public void writeTo(OutputStream headerOs, OutputStream bodyOs) throws IOException, MessagingException {
-        writeTo(headerOs, bodyOs, new String[0]);
-    }
-
-    public void writeTo(OutputStream headerOs, OutputStream bodyOs, String[] ignoreList) throws IOException, MessagingException {
-        writeTo(headerOs, bodyOs, ignoreList, false);
-    }
-
-    public synchronized void writeTo(OutputStream headerOs, OutputStream bodyOs, String[] ignoreList, boolean preLoad) throws IOException, MessagingException {
-        
-        if (!preLoad && source != null && !isBodyModified()) {
-            // We do not want to instantiate the message... just read from
-            // source
-            // and write to this outputstream
-
-            // First handle the headers
-            InputStream in = source.getInputStream();
-            try {
-                InternetHeaders myHeaders;
-                MailHeaders parsedHeaders = new MailHeaders(in);
-
-                // check if we should use the parsed headers or not
-                if (!isHeaderModified()) {
-                    myHeaders = parsedHeaders;
-                } else {
-                    // The headers was modified so we need to call saveChanges() just to be sure
-                    // See JAMES-1320
-                    if (!saved)
-                        saveChanges();
-                    myHeaders = headers;
-                }
-                @SuppressWarnings("unchecked")
-                Enumeration<String> filteredHeaders = myHeaders.getNonMatchingHeaderLines(ignoreList);
-                IOUtils.copy(new InternetHeadersInputStream(filteredHeaders), headerOs);
-                IOUtils.copy(in, bodyOs);
-            } finally {
-                IOUtils.closeQuietly(in);
-            }
-        } else {
-            // save the changes as the message was modified
-            // See JAMES-1320
-            if (!saved)
-                saveChanges();
-
-            // MimeMessageUtil.writeToInternal(this, headerOs, bodyOs,
-            // ignoreList);
-            if (headers == null) {
-                loadHeaders();
-            }
-            @SuppressWarnings("unchecked")
-            Enumeration<String> filteredHeaders = headers.getNonMatchingHeaderLines(ignoreList);
-            IOUtils.copy(new InternetHeadersInputStream(filteredHeaders), headerOs);
-
-            if (preLoad && !messageParsed) {
-                loadMessage();
-            }
-            MimeMessageUtil.writeMessageBodyTo(this, bodyOs);
-        }
-    }
-
-    /**
-     * This is the MimeMessage implementation - this should return ONLY the
-     * body, not the entire message (should not count headers). This size will
-     * never change on {@link #saveChanges()}
-     */
-    @Override
-    public synchronized int getSize() throws MessagingException {
-        if (source != null) {
-            try {
-                long fullSize = source.getMessageSize();
-                if (headers == null) {
-                    loadHeaders();
-                }
-                // 2 == CRLF
-                return (int) (fullSize - initialHeaderSize - 2);
-
-            } catch (IOException e) {
-                throw new MessagingException("Unable to calculate message size");
-            }
-        } else {
-            if (!messageParsed) {
-                loadMessage();
-            }
-
-            return super.getSize();
-        }
-
-    }
-
-    /**
-     * Corrects JavaMail 1.1 version which always returns -1. Only corrected for
-     * content less than 5000 bytes, to avoid memory hogging.
-     */
-    @Override
-    public int getLineCount() throws MessagingException {
-        InputStream in;
-        try {
-            in = getContentStream();
-        } catch (Exception e) {
-            return -1;
-        }
-        if (in == null) {
-            return -1;
-        }
-        // Wrap input stream in LineNumberReader
-        // Not sure what encoding to use really...
-        InputStreamReader isr = null;
-        LineNumberReader counter = null;
-        try {
-            if (getEncoding() != null) {
-                isr = new InputStreamReader(in, getEncoding());
-                counter = new LineNumberReader(isr);
-            } else {
-                isr = new InputStreamReader(in);
-                counter = new LineNumberReader(isr);
-            }
-            // Read through all the data
-            char[] block = new char[4096];
-            while (counter.read(block) > -1) {
-                // Just keep reading
-            }
-            return counter.getLineNumber();
-        } catch (IOException ioe) {
-            return -1;
-        } finally {
-            IOUtils.closeQuietly(counter);
-            IOUtils.closeQuietly(isr);
-            IOUtils.closeQuietly(in);
-        }
-    }
-
-    /**
-     * Returns size of message, ie headers and content
-     */
-    public long getMessageSize() throws MessagingException {
-        if (source != null && !isModified()) {
-            try {
-                return source.getMessageSize();
-            } catch (IOException ioe) {
-                throw new MessagingException("Error retrieving message size", ioe);
-            }
-        } else {
-            return MimeMessageUtil.calculateMessageSize(this);
-        }
-    }
-
-    /**
-     * We override all the "headers" access methods to be sure that we loaded
-     * the headers
-     */
-
-    @Override
-    public String[] getHeader(String name) throws MessagingException {
-        if (headers == null) {
-            loadHeaders();
-        }
-        return headers.getHeader(name);
-    }
-
-    @Override
-    public String getHeader(String name, String delimiter) throws MessagingException {
-        if (headers == null) {
-            loadHeaders();
-        }
-        return headers.getHeader(name, delimiter);
-    }
-
-    @SuppressWarnings("unchecked")
-    @Override
-    public Enumeration<String> getAllHeaders() throws MessagingException {
-        if (headers == null) {
-            loadHeaders();
-        }
-        return headers.getAllHeaders();
-    }
-
-    @SuppressWarnings("unchecked")
-    @Override
-    public Enumeration<String> getMatchingHeaders(String[] names) throws MessagingException {
-        if (headers == null) {
-            loadHeaders();
-        }
-        return headers.getMatchingHeaders(names);
-    }
-
-    @SuppressWarnings("unchecked")
-    @Override
-    public Enumeration<String> getNonMatchingHeaders(String[] names) throws MessagingException {
-        if (headers == null) {
-            loadHeaders();
-        }
-        return headers.getNonMatchingHeaders(names);
-    }
-
-    @SuppressWarnings("unchecked")
-    @Override
-    public Enumeration<String> getAllHeaderLines() throws MessagingException {
-        if (headers == null) {
-            loadHeaders();
-        }
-        return headers.getAllHeaderLines();
-    }
-
-    @SuppressWarnings("unchecked")
-    @Override
-    public Enumeration<String> getMatchingHeaderLines(String[] names) throws MessagingException {
-        if (headers == null) {
-            loadHeaders();
-        }
-        return headers.getMatchingHeaderLines(names);
-    }
-
-    @SuppressWarnings("unchecked")
-    @Override
-    public Enumeration<String> getNonMatchingHeaderLines(String[] names) throws MessagingException {
-        if (headers == null) {
-            loadHeaders();
-        }
-        return headers.getNonMatchingHeaderLines(names);
-    }
-
-    private synchronized void checkModifyHeaders() throws MessagingException {
-        // Disable only-header loading optimizations for JAMES-559
-        /*
-         * if (!messageParsed) { loadMessage(); }
-         */
-
-        // End JAMES-559
-        if (headers == null) {
-            loadHeaders();
-        }
-        modified = true;
-        saved = false;
-        headersModified = true;
-    }
-
-    @Override
-    public void setHeader(String name, String value) throws MessagingException {
-        checkModifyHeaders();
-        super.setHeader(name, value);
-    }
-
-    @Override
-    public void addHeader(String name, String value) throws MessagingException {
-        checkModifyHeaders();
-        super.addHeader(name, value);
-    }
-
-    @Override
-    public void removeHeader(String name) throws MessagingException {
-        checkModifyHeaders();
-        super.removeHeader(name);
-    }
-
-    @Override
-    public void addHeaderLine(String line) throws MessagingException {
-        checkModifyHeaders();
-        super.addHeaderLine(line);
-    }
-
-    /**
-     * The message is changed when working with headers and when altering the
-     * content. Every method that alter the content will fallback to this one.
-     * 
-     * @see javax.mail.Part#setDataHandler(javax.activation.DataHandler)
-     */
-    @Override
-    public synchronized void setDataHandler(DataHandler arg0) throws MessagingException {
-        modified = true;
-        saved = false;
-        bodyModified = true;
-        super.setDataHandler(arg0);
-    }
-
-    @Override
-    public void dispose() {
-        if (sourceIn != null) {
-            IOUtils.closeQuietly(sourceIn);
-        }
-        if (source != null) {
-            LifecycleUtil.dispose(source);
-        }
-    }
-
-    /**
-     * @see javax.mail.internet.MimeMessage#parse(java.io.InputStream)
-     */
-    @Override
-    protected synchronized void parse(InputStream is) throws MessagingException {
-        // the super implementation calls
-        // headers = createInternetHeaders(is);
-        super.parse(is);
-        messageParsed = true;
-    }
-
-    /**
-     * If we already parsed the headers then we simply return the updated ones.
-     * Otherwise we parse
-     * 
-     * @see javax.mail.internet.MimeMessage#createInternetHeaders(java.io.InputStream)
-     */
-    @Override
-    protected synchronized InternetHeaders createInternetHeaders(InputStream is) throws MessagingException {
-        /*
-         * This code is no more needed: see JAMES-570 and new tests
-         * 
-         * InternetHeaders can be a bit awkward to work with due to its own
-         * internal handling of header order. This hack may not always be
-         * necessary, but for now we are trying to ensure that there is a
-         * Return-Path header, even if just a placeholder, so that later, e.g.,
-         * in LocalDelivery, when we call setHeader, it will remove any other
-         * Return-Path headers, and ensure that ours is on the top. addHeader
-         * handles header order, but not setHeader. This may change in future
-         * JavaMail. But if there are other Return-Path header values, let's
-         * drop our placeholder.
-         * 
-         * MailHeaders newHeaders = new MailHeaders(new
-         * ByteArrayInputStream((f.RETURN_PATH + ": placeholder").getBytes()));
-         * newHeaders.setHeader(RFC2822Headers.RETURN_PATH, null);
-         * newHeaders.load(is); String[] returnPathHeaders =
-         * newHeaders.getHeader(RFC2822Headers.RETURN_PATH); if
-         * (returnPathHeaders.length > 1)
-         * newHeaders.setHeader(RFC2822Headers.RETURN_PATH,
-         * returnPathHeaders[1]);
-         */
-
-        // Keep this: skip the headers from the stream
-        // we could put that code in the else and simple write an "header"
-        // skipping
-        // reader for the others.
-        MailHeaders newHeaders = new MailHeaders(is);
-
-        if (headers != null) {
-            return headers;
-        } else {
-            initialHeaderSize = newHeaders.getSize();
-
-            return newHeaders;
-        }
-    }
-
-    /**
-     * @see javax.mail.internet.MimeMessage#getContentStream()
-     */
-    @Override
-    protected InputStream getContentStream() throws MessagingException {
-        if (!messageParsed) {
-            loadMessage();
-        }
-        return super.getContentStream();
-    }
-
-    /**
-     * @see javax.mail.internet.MimeMessage#getRawInputStream()
-     */
-    @Override
-    public synchronized InputStream getRawInputStream() throws MessagingException {
-        if (!messageParsed && !isModified() && source != null) {
-            InputStream is;
-            try {
-                is = source.getInputStream();
-                // skip the headers.
-                new MailHeaders(is);
-                return is;
-            } catch (IOException e) {
-                throw new MessagingException("Unable to read the stream: " + e.getMessage(), e);
-            }
-        } else {
-            return super.getRawInputStream();
-        }
-    }
-
-    /**
-     * Return an {@link InputStream} which holds the full content of the
-     * message. This method tries to optimize this call as far as possible. This
-     * stream contains the updated {@link MimeMessage} content if something was
-     * changed
-     * 
-     * @return messageInputStream
-     * @throws MessagingException
-     */
-
-    public synchronized InputStream getMessageInputStream() throws MessagingException {
-        if (!messageParsed && !isModified() && source != null) {
-            try {
-                return source.getInputStream();
-            } catch (IOException e) {
-                throw new MessagingException("Unable to get inputstream", e);
-            }
-        } else {
-            try {
-
-                // Try to optimize if possible to prevent OOM on big mails.
-                // See JAMES-1252 for an example
-                if (!bodyModified && source != null) {
-                    // ok only the headers were modified so we don't need to
-                    // copy the whole message content into memory
-                    InputStream in = source.getInputStream();
-                    
-                    // skip over headers from original stream we want to use the
-                    // in memory ones
-                    new MailHeaders(in);
-
-                    // now construct the new stream using the in memory headers
-                    // and the body from the original source
-                    return new SequenceInputStream(new InternetHeadersInputStream(getAllHeaderLines()), in);
-                } else {
-                    // the body was changed so we have no other solution to copy
-                    // it into memory first :(
-                    ByteArrayOutputStream out = new ByteArrayOutputStream();
-                    writeTo(out);
-                    return new ByteArrayInputStream(out.toByteArray());
-                }
-            } catch (IOException e) {
-                throw new MessagingException("Unable to get inputstream", e);
-            }
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/main/java/org/apache/james/core/filesystem/ClassPathResource.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/main/java/org/apache/james/core/filesystem/ClassPathResource.java b/server/container/core/src/main/java/org/apache/james/core/filesystem/ClassPathResource.java
deleted file mode 100644
index 473ce48..0000000
--- a/server/container/core/src/main/java/org/apache/james/core/filesystem/ClassPathResource.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-package org.apache.james.core.filesystem;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-
-public class ClassPathResource implements Resource {
-    
-    private final String path;
-    private final ClassLoader classLoader;
-
-    public ClassPathResource(String path) {
-        this.path = sanitizePath(path);
-        this.classLoader = getDefaultClassLoader();
-    }
-
-    private String sanitizePath(String path) {
-        String pathToUse = new SimpleUrl(path).getSimplified();
-        if (pathToUse.startsWith("/")) {
-            return pathToUse.substring(1);
-        }
-        return pathToUse;
-    }
-
-    @Override
-    public File getFile() throws IOException {
-        URL url = getURL();
-        return ResourceUtils.getFile(url, getDescription());
-    }
-
-    public URL getURL() throws IOException {
-        URL url = resolveURL();
-        if (url == null) {
-            throw new FileNotFoundException(getDescription() + " cannot be resolved to URL because it does not exist");
-        }
-        return url;
-    }
-
-    protected URL resolveURL() {
-        return this.classLoader.getResource(this.path);
-    }
-
-    @Override
-    public InputStream getInputStream() throws IOException {
-        InputStream is = this.classLoader.getResourceAsStream(this.path);
-        if (is == null) {
-            throw new FileNotFoundException(getDescription() + " cannot be opened because it does not exist");
-        }
-        return is;
-    }
-
-    public String getDescription() {
-        return "class path resource [" + path + "]";
-    }
-
-    private ClassLoader getDefaultClassLoader() {
-        ClassLoader currentThreadClassLoader = getcurrentThreadClassLoader();
-        if (currentThreadClassLoader != null) {
-            return currentThreadClassLoader;
-        }
-        
-        // No thread context class loader -> use class loader of this class.
-        ClassLoader currentClassClassLoader = ClassPathResource.class.getClassLoader();
-        if (currentClassClassLoader != null) {
-            return currentClassClassLoader;
-        }
-        
-        // getClassLoader() returning null indicates the bootstrap ClassLoader
-        return getSystemClassLoader();
-    }
-
-    private ClassLoader getcurrentThreadClassLoader() {
-        try {
-            return Thread.currentThread().getContextClassLoader();
-        } catch (Throwable ex) {
-            // Cannot access thread context ClassLoader - falling back...
-            return null;
-        }
-    }
-    
-    private ClassLoader getSystemClassLoader() {
-        try {
-            return ClassLoader.getSystemClassLoader();
-        } catch (Throwable ex) {
-            // Cannot access system ClassLoader - oh well, maybe the
-            // caller can live with null...
-            return null;
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/main/java/org/apache/james/core/filesystem/FileSystemImpl.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/main/java/org/apache/james/core/filesystem/FileSystemImpl.java b/server/container/core/src/main/java/org/apache/james/core/filesystem/FileSystemImpl.java
deleted file mode 100644
index b4dfadc..0000000
--- a/server/container/core/src/main/java/org/apache/james/core/filesystem/FileSystemImpl.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-package org.apache.james.core.filesystem;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-
-import javax.inject.Inject;
-
-import org.apache.james.filesystem.api.FileSystem;
-import org.apache.james.filesystem.api.JamesDirectoriesProvider;
-
-public class FileSystemImpl implements FileSystem {
-
-    private final JamesDirectoriesProvider directoryProvider;
-    private final ResourceFactory resourceLoader;
-
-    @Inject
-    public FileSystemImpl(JamesDirectoriesProvider directoryProvider) {
-        this.directoryProvider = directoryProvider;
-        this.resourceLoader = new ResourceFactory(directoryProvider);
-    }
-
-    @Override
-    public File getBasedir() throws FileNotFoundException {
-        return new File(directoryProvider.getRootDirectory());
-    }
-
-    @Override
-    public InputStream getResource(String url) throws IOException {
-        return resourceLoader.getResource(url).getInputStream();
-    }
-
-    @Override
-    public File getFile(String fileURL) throws FileNotFoundException {
-        try {
-            return resourceLoader.getResource(fileURL).getFile();
-        } catch (IOException e) {
-            throw new FileNotFoundException(e.getMessage());
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/main/java/org/apache/james/core/filesystem/FileSystemResource.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/main/java/org/apache/james/core/filesystem/FileSystemResource.java b/server/container/core/src/main/java/org/apache/james/core/filesystem/FileSystemResource.java
deleted file mode 100644
index bcd5d65..0000000
--- a/server/container/core/src/main/java/org/apache/james/core/filesystem/FileSystemResource.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-package org.apache.james.core.filesystem;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-
-class FileSystemResource implements Resource {
-
-    private final File file;
-
-    public FileSystemResource(File file) {
-        this.file = file;
-    }
-
-    @Override
-    public File getFile() {
-        return this.file;
-    }
-
-    @Override
-    public InputStream getInputStream() throws IOException {
-        return new FileInputStream(this.file);
-    }
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/main/java/org/apache/james/core/filesystem/Resource.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/main/java/org/apache/james/core/filesystem/Resource.java b/server/container/core/src/main/java/org/apache/james/core/filesystem/Resource.java
deleted file mode 100644
index 08b86e3..0000000
--- a/server/container/core/src/main/java/org/apache/james/core/filesystem/Resource.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-package org.apache.james.core.filesystem;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-
-public interface Resource {
-    File getFile() throws IOException;
-
-    InputStream getInputStream() throws IOException;
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/main/java/org/apache/james/core/filesystem/ResourceFactory.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/main/java/org/apache/james/core/filesystem/ResourceFactory.java b/server/container/core/src/main/java/org/apache/james/core/filesystem/ResourceFactory.java
deleted file mode 100644
index 39272f2..0000000
--- a/server/container/core/src/main/java/org/apache/james/core/filesystem/ResourceFactory.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-package org.apache.james.core.filesystem;
-
-import java.io.File;
-import java.net.MalformedURLException;
-import java.net.URL;
-
-import org.apache.james.filesystem.api.FileSystem;
-import org.apache.james.filesystem.api.JamesDirectoriesProvider;
-
-public class ResourceFactory {
-
-    private final JamesDirectoriesProvider directoryProvider;
-
-    public ResourceFactory(JamesDirectoriesProvider directoryProvider) {
-        this.directoryProvider = directoryProvider;
-    }
-    
-    public Resource getResource(String fileURL) {
-        if (fileURL.startsWith(FileSystem.CLASSPATH_PROTOCOL)) {
-            return handleClasspathProtocol(fileURL);
-        } else if (fileURL.startsWith(FileSystem.FILE_PROTOCOL)) {
-            return handleFileProtocol(fileURL);
-        } else {
-            try {
-                // Try to parse the location as a URL...
-                return handleUrlResource(fileURL);
-            } catch (MalformedURLException ex) {
-                // No URL -> resolve as resource path.
-                return new ClassPathResource(fileURL);
-            }
-        }
-    }
-
-    private Resource handleUrlResource(String fileURL) throws MalformedURLException {
-        URL url = new URL(fileURL);
-        return new UrlResource(url);
-    }
-
-    private Resource handleClasspathProtocol(String fileURL) {
-        String resourceName = fileURL.substring(FileSystem.CLASSPATH_PROTOCOL.length());
-        return new ClassPathResource(resourceName);
-    }
-    
-    private Resource handleFileProtocol(String fileURL) {
-        File file = interpretPath(fileURL);
-        return new FileSystemResource(file);
-    }
-
-    private File interpretPath(String fileURL) {
-        if (FileProtocol.CONF.match(fileURL)) {
-            return new File(directoryProvider.getConfDirectory() + "/" + FileProtocol.CONF.removeProtocolFromPath(fileURL));
-        } else if (FileProtocol.VAR.match(fileURL)) {
-            return new File(directoryProvider.getVarDirectory() + "/" + FileProtocol.VAR.removeProtocolFromPath(fileURL));
-        } else if (FileProtocol.ABSOLUTE.match(fileURL)) {
-            return new File(directoryProvider.getAbsoluteDirectory() + FileProtocol.ABSOLUTE.removeProtocolFromPath(fileURL));
-        } else {
-            // move to the root folder of the spring deployment
-            return new File(directoryProvider.getRootDirectory() + "/" + FileProtocol.OTHER.removeProtocolFromPath(fileURL));
-        }
-    }
-    
-    private enum FileProtocol {
-        CONF(FileSystem.FILE_PROTOCOL_AND_CONF),
-        VAR(FileSystem.FILE_PROTOCOL_AND_VAR),
-        ABSOLUTE(FileSystem.FILE_PROTOCOL_ABSOLUTE),
-        OTHER(FileSystem.FILE_PROTOCOL);
-        
-        private final String protocolPrefix;
-        
-        FileProtocol(String protocolPrefix) {
-            this.protocolPrefix = protocolPrefix;
-        }
-        
-        private boolean match(String path) {
-            return path.startsWith(protocolPrefix);
-        }
-        
-        private String removeProtocolFromPath(String path) {
-            return path.substring(protocolPrefix.length());
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/main/java/org/apache/james/core/filesystem/ResourceUtils.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/main/java/org/apache/james/core/filesystem/ResourceUtils.java b/server/container/core/src/main/java/org/apache/james/core/filesystem/ResourceUtils.java
deleted file mode 100644
index b7fec52..0000000
--- a/server/container/core/src/main/java/org/apache/james/core/filesystem/ResourceUtils.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-package org.apache.james.core.filesystem;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.net.URISyntaxException;
-import java.net.URL;
-
-public class ResourceUtils {
-    public static final String URL_PROTOCOL_FILE = "file";
-
-    public static File getFile(URL url, String description) throws FileNotFoundException {
-        if (!URL_PROTOCOL_FILE.equals(url.getProtocol())) {
-            throw new FileNotFoundException(description + " cannot be resolved to absolute file path " + "because it does not reside in the file system: " + url);
-        }
-        try {
-            return new File(url.toURI().getSchemeSpecificPart());
-        } catch (URISyntaxException ex) {
-            // Fallback for URLs that are not valid URIs (should hardly ever
-            // happen).
-            return new File(url.getFile());
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/main/java/org/apache/james/core/filesystem/SimpleUrl.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/main/java/org/apache/james/core/filesystem/SimpleUrl.java b/server/container/core/src/main/java/org/apache/james/core/filesystem/SimpleUrl.java
deleted file mode 100644
index 18b56bf..0000000
--- a/server/container/core/src/main/java/org/apache/james/core/filesystem/SimpleUrl.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-package org.apache.james.core.filesystem;
-
-import java.util.Optional;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.CharMatcher;
-import com.google.common.io.Files;
-
-public class SimpleUrl {
-    private static final String FOLDER_SEPARATOR = "/";
-
-    private static final char WINDOWS_FOLDER_SEPARATOR = '\\';
-
-    private static final String CURRENT_PATH = ".";
-
-    private static final Pattern URL_REGEXP = Pattern.compile("^([^/][^/]*:(?://)?)?(.*)");
-
-    private static String url;
-    private static String protocol;
-    private static String path;
-    private static String simplifiedUrl;
-
-    public SimpleUrl(String url) {
-        SimpleUrl.url = url;
-        String urlWithUnixSeparators = CharMatcher.is(WINDOWS_FOLDER_SEPARATOR).replaceFrom(url, FOLDER_SEPARATOR);
-        extractComponents(urlWithUnixSeparators);
-        simplifiedUrl = protocol + simplifyPath(path);
-    }
-
-    private static void extractComponents(String urlWithUnixSeparators) {
-        Matcher m = URL_REGEXP.matcher(urlWithUnixSeparators);
-        m.matches();
-        protocol = Optional.ofNullable(m.group(1)).orElse("");
-        path = Optional.ofNullable(m.group(2)).orElse("");
-    }
-
-    @VisibleForTesting
-    static String simplifyPath(String path) {
-        String simplified = Files.simplifyPath(path);
-        if (CURRENT_PATH.equals(simplified)) {
-            return "";
-        }
-        return simplified;
-    }
-
-    public String getUrl() {
-        return url;
-    }
-
-    public String getSimplified() {
-        return simplifiedUrl;
-    }
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/main/java/org/apache/james/core/filesystem/UrlResource.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/main/java/org/apache/james/core/filesystem/UrlResource.java b/server/container/core/src/main/java/org/apache/james/core/filesystem/UrlResource.java
deleted file mode 100644
index f1f190c..0000000
--- a/server/container/core/src/main/java/org/apache/james/core/filesystem/UrlResource.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-package org.apache.james.core.filesystem;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.net.URLConnection;
-
-public class UrlResource implements Resource {
-    public static final String URL_PROTOCOL_FILE = "file";
-    private final URL url;
-
-    public UrlResource(URL url) {
-        this.url = url;
-    }
-
-    @Override
-    public InputStream getInputStream() throws IOException {
-        URLConnection con = this.url.openConnection();
-        useCachesIfNecessary(con);
-        try {
-            return con.getInputStream();
-        } catch (IOException ex) {
-            // Close the HTTP connection (if applicable).
-            if (con instanceof HttpURLConnection) {
-                ((HttpURLConnection) con).disconnect();
-            }
-            throw ex;
-        }
-    }
-
-    public static void useCachesIfNecessary(URLConnection con) {
-        con.setUseCaches(con.getClass().getSimpleName().startsWith("JNLP"));
-    }
-
-    @Override
-    public File getFile() throws IOException {
-        return ResourceUtils.getFile(url, "URL [" + this.url + "]");
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/main/java/org/apache/james/core/package.html
----------------------------------------------------------------------
diff --git a/server/container/core/src/main/java/org/apache/james/core/package.html b/server/container/core/src/main/java/org/apache/james/core/package.html
deleted file mode 100644
index a9ce61d..0000000
--- a/server/container/core/src/main/java/org/apache/james/core/package.html
+++ /dev/null
@@ -1,21 +0,0 @@
-<!--
-  Licensed to the Apache Software Foundation (ASF) under one
-  or more contributor license agreements.  See the NOTICE file
-  distributed with this work for additional information
-  regarding copyright ownership.  The ASF licenses this file
-  to you under the Apache License, Version 2.0 (the
-  "License"); you may not use this file except in compliance
-  with the License.  You may obtain a copy of the License at
-
-    http://www.apache.org/licenses/LICENSE-2.0
-
-  Unless required by applicable law or agreed to in writing,
-  software distributed under the License is distributed on an
-  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-  KIND, either express or implied.  See the License for the
-  specific language governing permissions and limitations
-  under the License.    
--->
-<body>
-<p>Implementations of core James services and concepts.</p>
-</body>

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/main/java/org/apache/james/server/core/InternetHeadersInputStream.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/main/java/org/apache/james/server/core/InternetHeadersInputStream.java b/server/container/core/src/main/java/org/apache/james/server/core/InternetHeadersInputStream.java
new file mode 100644
index 0000000..58bf8dd
--- /dev/null
+++ b/server/container/core/src/main/java/org/apache/james/server/core/InternetHeadersInputStream.java
@@ -0,0 +1,93 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.server.core;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.util.Enumeration;
+
+import javax.mail.internet.InternetHeaders;
+
+/**
+ * Provide an {@link InputStream} over an {@link InternetHeaders} instance. When
+ * the end of {@link InternetHeaders} are reached a {@link #LINE_SEPERATOR} is
+ * append
+ */
+public class InternetHeadersInputStream extends InputStream {
+
+    private final static String LINE_SEPERATOR = "\r\n";
+
+    private final Enumeration<String> headerLines;
+    private byte[] currLine;
+    private int pos = 0;
+
+    @SuppressWarnings("unchecked")
+    public InternetHeadersInputStream(InternetHeaders headers) {
+        this(headers.getAllHeaderLines());
+    }
+
+    public InternetHeadersInputStream(Enumeration<String> headerLines) {
+        this.headerLines = headerLines;
+    }
+
+    @Override
+    public int read() throws IOException {
+        if (currLine == null || pos == currLine.length) {
+            if (!readNextLine()) {
+                return -1;
+            }
+        }
+        return currLine[pos++];
+    }
+
+    /**
+     * Load the next header line if possible
+     * 
+     * @return true if there was an headerline which could be read
+     * 
+     * @throws IOException
+     */
+    private boolean readNextLine() throws IOException {
+        if (headerLines.hasMoreElements()) {
+            try {
+                pos = 0;
+                String line = (headerLines.nextElement() + LINE_SEPERATOR);
+                // Add seperator to show that headers are complete
+                if (!headerLines.hasMoreElements()) {
+                    line += LINE_SEPERATOR;
+                }
+                currLine = line.getBytes("US-ASCII");
+                return true;
+            } catch (UnsupportedEncodingException e) {
+                // should never happen
+                throw new IOException("US-ASCII encoding not supported by this platform ?!");
+            }
+        } else {
+            return false;
+        }
+    }
+
+    @Override
+    public void close() throws IOException {
+        currLine = null;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/main/java/org/apache/james/server/core/JamesServerResourceLoader.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/main/java/org/apache/james/server/core/JamesServerResourceLoader.java b/server/container/core/src/main/java/org/apache/james/server/core/JamesServerResourceLoader.java
new file mode 100644
index 0000000..d64dc62
--- /dev/null
+++ b/server/container/core/src/main/java/org/apache/james/server/core/JamesServerResourceLoader.java
@@ -0,0 +1,72 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+package org.apache.james.server.core;
+
+import org.apache.james.filesystem.api.JamesDirectoriesProvider;
+
+public class JamesServerResourceLoader implements JamesDirectoriesProvider {
+
+    private final String rootDirectory;
+
+    public JamesServerResourceLoader(String rootDirectory) {
+        this.rootDirectory = rootDirectory;
+    }
+
+    /**
+     * @see org.apache.james.container.spring.resource.JamesResourceLoader#getAbsoluteDirectory()
+     */
+    public String getAbsoluteDirectory() {
+        return "/";
+    }
+
+    /**
+     * @see
+     * org.apache.james.container.spring.resource.JamesResourceLoader#getConfDirectory()
+     */
+    public String getConfDirectory() {
+        return getRootDirectory() + "/conf/";
+    }
+
+    /**
+     * @see
+     * org.apache.james.container.spring.resource.JamesResourceLoader#getVarDirectory()
+     */
+    public String getVarDirectory() {
+        return getRootDirectory() + "/var/";
+    }
+
+    /**
+     * Return the directory where the external jar libraries must be placed
+     * by the administrator. The jars may contain mailets, jdbc drivers,...
+     * 
+     * @return externalLibraryDirectory
+     */
+    public String getExternalLibraryDirectory() {
+        return getRootDirectory() + "/conf/lib/";
+    }
+
+    /**
+     * @see
+     * org.apache.james.container.spring.resource.JamesResourceLoader#getRootDirectory()
+     */
+    public String getRootDirectory() {
+        return rootDirectory;
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/main/java/org/apache/james/server/core/MailHeaders.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/main/java/org/apache/james/server/core/MailHeaders.java b/server/container/core/src/main/java/org/apache/james/server/core/MailHeaders.java
new file mode 100644
index 0000000..a98223c
--- /dev/null
+++ b/server/container/core/src/main/java/org/apache/james/server/core/MailHeaders.java
@@ -0,0 +1,187 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.server.core;
+
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.Serializable;
+import java.util.Enumeration;
+
+import javax.mail.MessagingException;
+import javax.mail.internet.InternetHeaders;
+
+import org.apache.mailet.base.RFC2822Headers;
+
+/**
+ * This interface defines a container for mail headers. Each header must use
+ * MIME format:
+ * 
+ * <pre>
+ * name: value
+ * </pre>
+ */
+public class MailHeaders extends InternetHeaders implements Serializable, Cloneable {
+
+    private static final long serialVersionUID = 238748126601L;
+    private boolean modified = false;
+    private long size = -1;
+
+    /**
+     * No argument constructor
+     * 
+     * @throws MessagingException
+     *             if the super class cannot be properly instantiated
+     */
+    public MailHeaders() {
+        super();
+    }
+
+    /**
+     * Constructor that takes an InputStream containing the contents of the set
+     * of mail headers.
+     * 
+     * @param in
+     *            the InputStream containing the header data
+     * 
+     * @throws MessagingException
+     *             if the super class cannot be properly instantiated based on
+     *             the stream
+     */
+    public MailHeaders(InputStream in) throws MessagingException {
+        super();
+        load(in);
+    }
+
+    /**
+     * Write the headers to an output stream
+     * 
+     * @param out
+     *            the OutputStream to which to write the headers
+     */
+    @SuppressWarnings("unchecked")
+    public void writeTo(OutputStream out) throws MessagingException {
+        MimeMessageUtil.writeHeadersTo(getAllHeaderLines(), out);
+    }
+
+    /**
+     * Generate a representation of the headers as a series of bytes.
+     * 
+     * @return the byte array containing the headers
+     */
+    public byte[] toByteArray() throws MessagingException {
+        ByteArrayOutputStream headersBytes = new ByteArrayOutputStream();
+        writeTo(headersBytes);
+        return headersBytes.toByteArray();
+    }
+
+    /**
+     * Check if a particular header is present.
+     * 
+     * @return true if the header is present, false otherwise
+     */
+    public boolean isSet(String name) {
+        String[] value = super.getHeader(name);
+        return (value != null && value.length != 0);
+    }
+
+    /**
+     * If the new header is a Return-Path we get sure that we add it to the top
+     * Javamail, at least until 1.4.0 does the wrong thing if it loaded a stream
+     * with a return-path in the middle.
+     * 
+     * @see javax.mail.internet.InternetHeaders#addHeader(java.lang.String,
+     *      java.lang.String)
+     */
+    @SuppressWarnings("unchecked")
+    public synchronized void addHeader(String arg0, String arg1) {
+        if (RFC2822Headers.RETURN_PATH.equalsIgnoreCase(arg0)) {
+            headers.add(0, new InternetHeader(arg0, arg1));
+        } else {
+            super.addHeader(arg0, arg1);
+        }
+        modified();
+    }
+
+    /**
+     * If the new header is a Return-Path we get sure that we add it to the top
+     * Javamail, at least until 1.4.0 does the wrong thing if it loaded a stream
+     * with a return-path in the middle.
+     * 
+     * @see javax.mail.internet.InternetHeaders#setHeader(java.lang.String,
+     *      java.lang.String)
+     */
+    public synchronized void setHeader(String arg0, String arg1) {
+        if (RFC2822Headers.RETURN_PATH.equalsIgnoreCase(arg0)) {
+            super.removeHeader(arg0);
+        }
+        super.setHeader(arg0, arg1);
+
+        modified();
+    }
+
+    @Override
+    public synchronized void removeHeader(String name) {
+        super.removeHeader(name);
+        modified();
+    }
+
+    @Override
+    public synchronized void addHeaderLine(String line) {
+        super.addHeaderLine(line);
+        modified();
+    }
+
+    private void modified() {
+        modified = true;
+        size = -1;
+    }
+
+    /**
+     * Check if all REQUIRED headers fields as specified in RFC 822 are present.
+     * 
+     * @return true if the headers are present, false otherwise
+     */
+    public boolean isValid() {
+        return (isSet(RFC2822Headers.DATE) && isSet(RFC2822Headers.TO) && isSet(RFC2822Headers.FROM));
+    }
+
+    /**
+     * Return the size of the headers
+     * 
+     * @return size
+     */
+    @SuppressWarnings("unchecked")
+    public synchronized long getSize() {
+        if (size == -1 || modified) {
+            long c = 0;
+            Enumeration<String> headerLines = getAllHeaderLines();
+            while (headerLines.hasMoreElements()) {
+                c += headerLines.nextElement().length();
+                // CRLF
+                c += 2;
+            }
+            size = c;
+            modified = false;
+        }
+        return size;
+
+    }
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


[22/23] james-project git commit: JAMES-2133 Remove useless log

Posted by bt...@apache.org.
JAMES-2133 Remove useless log

Seens like a debug log. It is even logged as info later


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/2abd71bb
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/2abd71bb
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/2abd71bb

Branch: refs/heads/master
Commit: 2abd71bbac81886c6db0fcc156bbb0be0be12baa
Parents: 743cd15
Author: benwa <bt...@linagora.com>
Authored: Thu Sep 7 14:07:40 2017 +0700
Committer: benwa <bt...@linagora.com>
Committed: Mon Sep 11 09:35:11 2017 +0700

----------------------------------------------------------------------
 .../org/apache/james/modules/mailbox/ResilientClusterProvider.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/2abd71bb/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ResilientClusterProvider.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ResilientClusterProvider.java b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ResilientClusterProvider.java
index 5ab43dc..93adf63 100644
--- a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ResilientClusterProvider.java
+++ b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ResilientClusterProvider.java
@@ -71,7 +71,7 @@ public class ResilientClusterProvider implements Provider<Cluster> {
     private ResilientClusterProvider(CassandraSessionConfiguration cassandraSessionConfiguration, AsyncRetryExecutor executor) throws ConfigurationException, ExecutionException, InterruptedException {
         PropertiesConfiguration configuration = cassandraSessionConfiguration.getConfiguration();
         List<Host> servers = listCassandraServers(configuration);
-        LOGGER.warn("CASSANDRA NODES : {}", servers);
+
         QueryLoggerConfiguration queryLoggerConfiguration = getCassandraQueryLoggerConf(configuration);
 
         int maxRetries = configuration.getInt("cassandra.retryConnection.maxRetries", DEFAULT_CONNECTION_MAX_RETRIES);


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


[20/23] james-project git commit: JAMES-2138 Adding integration test for Groups webadmin feature.

Posted by bt...@apache.org.
JAMES-2138 Adding integration test for Groups webadmin feature.


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/dc2ad6d9
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/dc2ad6d9
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/dc2ad6d9

Branch: refs/heads/master
Commit: dc2ad6d9f3ab21129e2a0041595e9eb06a82f270
Parents: 4817caa
Author: benwa <bt...@linagora.com>
Authored: Wed Sep 6 13:53:46 2017 +0700
Committer: benwa <bt...@linagora.com>
Committed: Sat Sep 9 10:46:41 2017 +0700

----------------------------------------------------------------------
 .../WebAdminServerIntegrationTest.java          | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/dc2ad6d9/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/WebAdminServerIntegrationTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/WebAdminServerIntegrationTest.java b/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/WebAdminServerIntegrationTest.java
index 8b6230c..30c810d 100644
--- a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/WebAdminServerIntegrationTest.java
+++ b/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/WebAdminServerIntegrationTest.java
@@ -28,6 +28,8 @@ import static org.assertj.core.api.Assertions.assertThat;
 import static org.hamcrest.Matchers.containsString;
 import static org.hamcrest.Matchers.is;
 
+import java.util.List;
+
 import org.apache.james.CassandraJmapTestRule;
 import org.apache.james.DockerCassandraRule;
 import org.apache.james.GuiceJamesServer;
@@ -261,6 +263,24 @@ public class WebAdminServerIntegrationTest {
     }
 
     @Test
+    public void addressGroupsEndpointShouldHandleRequests() throws Exception {
+        dataProbe.addAddressMapping("group", "domain.com", "user1@domain.com");
+        dataProbe.addAddressMapping("group", "domain.com", "user2@domain.com");
+
+        List<String> members = given()
+            .port(webAdminGuiceProbe.getWebAdminPort())
+            .when()
+            .get("/address/groups/group@domain.com")
+            .then()
+            .statusCode(200)
+            .contentType(JSON_CONTENT_TYPE)
+            .extract()
+            .jsonPath()
+            .getList(".");
+        assertThat(members).containsOnly("user1@domain.com", "user2@domain.com");
+    }
+
+    @Test
     public void getSwaggerShouldReturnJsonDataForSwagger() throws Exception {
         given()
             .port(webAdminGuiceProbe.getWebAdminPort())


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


[13/23] james-project git commit: JAMES-2138 move MailAddress to a new james-core project

Posted by bt...@apache.org.
http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/main/java/org/apache/james/core/MailImpl.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/main/java/org/apache/james/core/MailImpl.java b/server/container/core/src/main/java/org/apache/james/core/MailImpl.java
deleted file mode 100644
index c7ecd83..0000000
--- a/server/container/core/src/main/java/org/apache/james/core/MailImpl.java
+++ /dev/null
@@ -1,691 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-
-package org.apache.james.core;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.OptionalDataException;
-import java.io.OutputStream;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.UUID;
-
-import javax.mail.MessagingException;
-import javax.mail.internet.MimeMessage;
-import javax.mail.internet.ParseException;
-
-import org.apache.james.lifecycle.api.Disposable;
-import org.apache.james.lifecycle.api.LifecycleUtil;
-import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
-import org.apache.mailet.PerRecipientHeaders;
-import org.apache.mailet.PerRecipientHeaders.Header;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * <p>
- * Wraps a MimeMessage adding routing information (from SMTP) and some simple
- * API enhancements.
- * </p>
- * <p>
- * From James version > 2.2.0a8 "mail attributes" have been added. Backward and
- * forward compatibility is supported:
- * <ul>
- * <li>messages stored in file repositories <i>without</i> attributes by James
- * version <= 2.2.0a8 will be processed by later versions as having an empty
- * attributes hashmap;</li>
- * <li>messages stored in file repositories <i>with</i> attributes by James
- * version > 2.2.0a8 will be processed by previous versions, ignoring the
- * attributes.</li>
- * </ul>
- * </p>
- */
-public class MailImpl implements Disposable, Mail {
-
-    private static final Logger LOGGER = LoggerFactory.getLogger(MailImpl.class);
-
-    /**
-     * We hardcode the serialVersionUID so that from James 1.2 on, MailImpl will
-     * be deserializable (so your mail doesn't get lost)
-     */
-    public static final long serialVersionUID = -4289663364703986260L;
-    /**
-     * The error message, if any, associated with this mail.
-     */
-    private String errorMessage;
-    /**
-     * The state of this mail, which determines how it is processed.
-     */
-    private String state;
-    /**
-     * The MimeMessage that holds the mail data.
-     */
-    private MimeMessage message;
-    /**
-     * The sender of this mail.
-     */
-    private MailAddress sender;
-    /**
-     * The collection of recipients to whom this mail was sent.
-     */
-    private Collection<MailAddress> recipients;
-    /**
-     * The identifier for this mail message
-     */
-    private String name;
-    /**
-     * The remote host from which this mail was sent.
-     */
-    private String remoteHost = "localhost";
-    /**
-     * The remote address from which this mail was sent.
-     */
-    private String remoteAddr = "127.0.0.1";
-    /**
-     * The last time this message was updated.
-     */
-    private Date lastUpdated = new Date();
-    /**
-     * Attributes added to this MailImpl instance
-     */
-    private Map<String, Object> attributes;
-    /**
-     * Specific headers for some recipients
-     * These headers will be added at delivery time
-     */
-    private PerRecipientHeaders perRecipientSpecificHeaders;
-
-    /**
-     * A constructor that creates a new, uninitialized MailImpl
-     */
-    public MailImpl() {
-        setState(Mail.DEFAULT);
-        attributes = new HashMap<>();
-        perRecipientSpecificHeaders = new PerRecipientHeaders();
-    }
-
-    /**
-     * A constructor that creates a MailImpl with the specified name, sender,
-     * and recipients.
-     *
-     * @param name       the name of the MailImpl
-     * @param sender     the sender for this MailImpl
-     * @param recipients the collection of recipients of this MailImpl
-     */
-    public MailImpl(String name, MailAddress sender, Collection<MailAddress> recipients) {
-        this();
-        this.name = name;
-        this.sender = sender;
-        this.recipients = null;
-
-        // Copy the recipient list
-        if (recipients != null) {
-            this.recipients = new ArrayList<>();
-            this.recipients.addAll(recipients);
-        }
-    }
-
-    /**
-     * Create a copy of the input mail and assign it a new name
-     *
-     * @param mail original mail
-     * @throws MessagingException when the message is not clonable
-     */
-    public MailImpl(Mail mail) throws MessagingException {
-        this(mail, newName(mail));
-    }
-
-    /**
-     * @param mail
-     * @param newName
-     * @throws MessagingException
-     */
-    @SuppressWarnings("unchecked")
-    public MailImpl(Mail mail, String newName) throws MessagingException {
-        this(newName, mail.getSender(), mail.getRecipients(), mail.getMessage());
-        setRemoteHost(mail.getRemoteHost());
-        setRemoteAddr(mail.getRemoteAddr());
-        setLastUpdated(mail.getLastUpdated());
-        try {
-            if (mail instanceof MailImpl) {
-                setAttributesRaw((HashMap<String, Object>) cloneSerializableObject(((MailImpl) mail).getAttributesRaw()));
-            } else {
-                HashMap<String, Object> attribs = new HashMap<>();
-                for (Iterator<String> i = mail.getAttributeNames(); i.hasNext(); ) {
-                    String hashKey = i.next();
-                    attribs.put(hashKey, cloneSerializableObject(mail.getAttribute(hashKey)));
-                }
-                setAttributesRaw(attribs);
-            }
-        } catch (IOException | ClassNotFoundException e) {
-            LOGGER.error("Error while deserializing attributes", e);
-            setAttributesRaw(new HashMap<>());
-        }
-    }
-
-    /**
-     * A constructor that creates a MailImpl with the specified name, sender,
-     * recipients, and message data.
-     *
-     * @param name       the name of the MailImpl
-     * @param sender     the sender for this MailImpl
-     * @param recipients the collection of recipients of this MailImpl
-     * @param messageIn  a stream containing the message source
-     */
-    public MailImpl(String name, MailAddress sender, Collection<MailAddress> recipients, InputStream messageIn) throws MessagingException {
-        this(name, sender, recipients);
-        MimeMessageSource source = new MimeMessageInputStreamSource(name, messageIn);
-        // if MimeMessageCopyOnWriteProxy throws an error in the constructor we
-        // have to manually care disposing our source.
-        try {
-            this.setMessage(new MimeMessageCopyOnWriteProxy(source));
-        } catch (MessagingException e) {
-            LifecycleUtil.dispose(source);
-            throw e;
-        }
-    }
-
-    /**
-     * A constructor that creates a MailImpl with the specified name, sender,
-     * recipients, and MimeMessage.
-     *
-     * @param name       the name of the MailImpl
-     * @param sender     the sender for this MailImpl
-     * @param recipients the collection of recipients of this MailImpl
-     * @param message    the MimeMessage associated with this MailImpl
-     */
-    public MailImpl(String name, MailAddress sender, Collection<MailAddress> recipients, MimeMessage message) {
-        this(name, sender, recipients);
-        this.setMessage(new MimeMessageCopyOnWriteProxy(message));
-    }
-
-    /**
-     * Duplicate the MailImpl.
-     *
-     * @return a MailImpl that is a duplicate of this one
-     */
-    public Mail duplicate() {
-        return duplicate(name);
-    }
-
-    /**
-     * Duplicate the MailImpl, replacing the mail name with the one passed in as
-     * an argument.
-     *
-     * @param newName the name for the duplicated mail
-     * @return a MailImpl that is a duplicate of this one with a different name
-     */
-    public Mail duplicate(String newName) {
-        try {
-            return new MailImpl(this, newName);
-        } catch (MessagingException me) {
-            // Ignored. Return null in the case of an error.
-        }
-        return null;
-    }
-
-    /**
-     * Get the error message associated with this MailImpl.
-     *
-     * @return the error message associated with this MailImpl
-     */
-    @Override
-    public String getErrorMessage() {
-        return errorMessage;
-    }
-
-    /**
-     * Get the MimeMessage associated with this MailImpl.
-     *
-     * @return the MimeMessage associated with this MailImpl
-     */
-    @Override
-    public MimeMessage getMessage() throws MessagingException {
-        return message;
-    }
-
-    /**
-     * Set the name of this MailImpl.
-     *
-     * @param name the name of this MailImpl
-     */
-    @Override
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    /**
-     * Get the name of this MailImpl.
-     *
-     * @return the name of this MailImpl
-     */
-    @Override
-    public String getName() {
-        return name;
-    }
-
-    /**
-     * Get the recipients of this MailImpl.
-     *
-     * @return the recipients of this MailImpl
-     */
-    @Override
-    public Collection<MailAddress> getRecipients() {
-        return recipients;
-    }
-
-    /**
-     * Get the sender of this MailImpl.
-     *
-     * @return the sender of this MailImpl
-     */
-    @Override
-    public MailAddress getSender() {
-        return sender;
-    }
-
-    /**
-     * Get the state of this MailImpl.
-     *
-     * @return the state of this MailImpl
-     */
-    @Override
-    public String getState() {
-        return state;
-    }
-
-    /**
-     * Get the remote host associated with this MailImpl.
-     *
-     * @return the remote host associated with this MailImpl
-     */
-    @Override
-    public String getRemoteHost() {
-        return remoteHost;
-    }
-
-    /**
-     * Get the remote address associated with this MailImpl.
-     *
-     * @return the remote address associated with this MailImpl
-     */
-    @Override
-    public String getRemoteAddr() {
-        return remoteAddr;
-    }
-
-    /**
-     * Get the last updated time for this MailImpl.
-     *
-     * @return the last updated time for this MailImpl
-     */
-    @Override
-    public Date getLastUpdated() {
-        return lastUpdated;
-    }
-
-    /**
-     * <p>
-     * Return the size of the message including its headers.
-     * MimeMessage.getSize() method only returns the size of the message body.
-     * </p>
-     * <p/>
-     * <p>
-     * Note: this size is not guaranteed to be accurate - see Sun's
-     * documentation of MimeMessage.getSize().
-     * </p>
-     *
-     * @return approximate size of full message including headers.
-     * @throws MessagingException if a problem occurs while computing the message size
-     */
-    @Override
-    public long getMessageSize() throws MessagingException {
-        return MimeMessageUtil.getMessageSize(message);
-    }
-
-    /**
-     * Set the error message associated with this MailImpl.
-     *
-     * @param msg the new error message associated with this MailImpl
-     */
-    @Override
-    public void setErrorMessage(String msg) {
-        this.errorMessage = msg;
-    }
-
-    /**
-     * Set the MimeMessage associated with this MailImpl.
-     *
-     * @param message the new MimeMessage associated with this MailImpl
-     */
-    @Override
-    public void setMessage(MimeMessage message) {
-
-        // TODO: We should use the MimeMessageCopyOnWriteProxy
-        // everytime we set the MimeMessage. We should
-        // investigate if we should wrap it here
-
-        if (this.message != message) {
-            // If a setMessage is called on a Mail that already have a message
-            // (discouraged) we have to make sure that the message we remove is
-            // correctly unreferenced and disposed, otherwise it will keep locks
-            if (this.message != null) {
-                LifecycleUtil.dispose(this.message);
-            }
-            this.message = message;
-        }
-    }
-
-    /**
-     * Set the recipients for this MailImpl.
-     *
-     * @param recipients the recipients for this MailImpl
-     */
-    @Override
-    public void setRecipients(Collection<MailAddress> recipients) {
-        this.recipients = recipients;
-    }
-
-    /**
-     * Set the sender of this MailImpl.
-     *
-     * @param sender the sender of this MailImpl
-     */
-    public void setSender(MailAddress sender) {
-        this.sender = sender;
-    }
-
-    /**
-     * Set the state of this MailImpl.
-     *
-     * @param state the state of this MailImpl
-     */
-    public void setState(String state) {
-        this.state = state;
-    }
-
-    /**
-     * Set the remote address associated with this MailImpl.
-     *
-     * @param remoteHost the new remote host associated with this MailImpl
-     */
-    public void setRemoteHost(String remoteHost) {
-        this.remoteHost = remoteHost;
-    }
-
-    /**
-     * Set the remote address associated with this MailImpl.
-     *
-     * @param remoteAddr the new remote address associated with this MailImpl
-     */
-    public void setRemoteAddr(String remoteAddr) {
-        this.remoteAddr = remoteAddr;
-    }
-
-    /**
-     * Set the date this mail was last updated.
-     *
-     * @param lastUpdated the date the mail was last updated
-     */
-    public void setLastUpdated(Date lastUpdated) {
-        // Make a defensive copy to ensure that the date
-        // doesn't get changed external to the class
-        if (lastUpdated != null) {
-            lastUpdated = new Date(lastUpdated.getTime());
-        }
-        this.lastUpdated = lastUpdated;
-    }
-
-    /**
-     * Writes the message out to an OutputStream.
-     *
-     * @param out the OutputStream to which to write the content
-     * @throws MessagingException if the MimeMessage is not set for this MailImpl
-     * @throws IOException        if an error occurs while reading or writing from the stream
-     */
-    public void writeMessageTo(OutputStream out) throws IOException, MessagingException {
-        if (message != null) {
-            message.writeTo(out);
-        } else {
-            throw new MessagingException("No message set for this MailImpl.");
-        }
-    }
-
-    // Serializable Methods
-    // TODO: These need some work. Currently very tightly coupled to
-    // the internal representation.
-
-    /**
-     * Read the MailImpl from an <code>ObjectInputStream</code>.
-     *
-     * @param in the ObjectInputStream from which the object is read
-     * @throws IOException            if an error occurs while reading from the stream
-     * @throws ClassNotFoundException ?
-     * @throws ClassCastException     if the serialized objects are not of the appropriate type
-     */
-    @SuppressWarnings("unchecked")
-    private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException {
-        try {
-            Object obj = in.readObject();
-            if (obj == null) {
-                sender = null;
-            } else if (obj instanceof String) {
-                sender = new MailAddress((String) obj);
-            } else if (obj instanceof MailAddress) {
-                sender = (MailAddress) obj;
-            }
-        } catch (ParseException pe) {
-            throw new IOException("Error parsing sender address: " + pe.getMessage());
-        }
-        recipients = (Collection<MailAddress>) in.readObject();
-        state = (String) in.readObject();
-        errorMessage = (String) in.readObject();
-        name = (String) in.readObject();
-        remoteHost = (String) in.readObject();
-        remoteAddr = (String) in.readObject();
-        setLastUpdated((Date) in.readObject());
-        // the following is under try/catch to be backwards compatible
-        // with messages created with James version <= 2.2.0a8
-        try {
-            attributes = (HashMap<String, Object>) in.readObject();
-        } catch (OptionalDataException ode) {
-            if (ode.eof) {
-                attributes = new HashMap<>();
-            } else {
-                throw ode;
-            }
-        }
-    }
-
-    /**
-     * Write the MailImpl to an <code>ObjectOutputStream</code>.
-     *
-     * @param out the ObjectOutputStream to which the object is written
-     * @throws IOException if an error occurs while writing to the stream
-     */
-    private void writeObject(java.io.ObjectOutputStream out) throws IOException {
-        out.writeObject(sender);
-        out.writeObject(recipients);
-        out.writeObject(state);
-        out.writeObject(errorMessage);
-        out.writeObject(name);
-        out.writeObject(remoteHost);
-        out.writeObject(remoteAddr);
-        out.writeObject(lastUpdated);
-        out.writeObject(attributes);
-    }
-
-    @Override
-    public void dispose() {
-        LifecycleUtil.dispose(message);
-        message = null;
-    }
-
-    /**
-     * <p>
-     * This method is necessary, when Mail repositories needs to deal explicitly
-     * with storing Mail attributes as a Serializable
-     * </p>
-     * <p>
-     * <strong>Note</strong>: This method is not exposed in the Mail interface,
-     * it is for internal use by James only.
-     * </p>
-     *
-     * @return Serializable of the entire attributes collection
-     * @since 2.2.0
-     */
-    public Map<String, Object> getAttributesRaw() {
-        return attributes;
-    }
-
-    /**
-     * <p>
-     * This method is necessary, when Mail repositories needs to deal explicitly
-     * with retriving Mail attributes as a Serializable
-     * </p>
-     * <p>
-     * <strong>Note</strong>: This method is not exposed in the Mail interface,
-     * it is for internal use by James only.
-     * </p>
-     *
-     * @param attr Serializable of the entire attributes collection
-     * @since 2.2.0
-     */
-    public void setAttributesRaw(HashMap<String, Object> attr) {
-        this.attributes = (attr == null) ? new HashMap<>() : attr;
-    }
-
-    @Override
-    public Serializable getAttribute(String key) {
-        return (Serializable) attributes.get(key);
-    }
-
-    @Override
-    public Serializable setAttribute(String key, Serializable object) {
-        return (Serializable) attributes.put(key, object);
-    }
-
-    @Override
-    public Serializable removeAttribute(String key) {
-        return (Serializable) attributes.remove(key);
-    }
-
-    @Override
-    public void removeAllAttributes() {
-        attributes.clear();
-    }
-
-    @Override
-    public Iterator<String> getAttributeNames() {
-        return attributes.keySet().iterator();
-    }
-
-    @Override
-    public boolean hasAttributes() {
-        return !attributes.isEmpty();
-    }
-
-    /**
-     * This methods provide cloning for serializable objects. Mail Attributes
-     * are Serializable but not Clonable so we need a deep copy
-     *
-     * @param o Object to be cloned
-     * @return the cloned Object
-     * @throws IOException
-     * @throws ClassNotFoundException
-     */
-    private static Object cloneSerializableObject(Object o) throws IOException, ClassNotFoundException {
-        ByteArrayOutputStream b = new ByteArrayOutputStream();
-        ObjectOutputStream out = new ObjectOutputStream(b);
-        out.writeObject(o);
-        out.flush();
-        out.close();
-        ByteArrayInputStream bi = new ByteArrayInputStream(b.toByteArray());
-        ObjectInputStream in = new ObjectInputStream(bi);
-        return in.readObject();
-    }
-
-    private static final java.util.Random random = new java.util.Random(); // Used
-    // to
-    // generate
-    // new
-    // mail
-    // names
-
-    /**
-     * Create a unique new primary key name for the given MailObject.
-     *
-     * @param mail the mail to use as the basis for the new mail name
-     * @return a new name
-     */
-    public static String newName(Mail mail) throws MessagingException {
-        String oldName = mail.getName();
-
-        // Checking if the original mail name is too long, perhaps because of a
-        // loop caused by a configuration error.
-        // it could cause a "null pointer exception" in AvalonMailRepository
-        // much
-        // harder to understand.
-        if (oldName.length() > 76) {
-            int count = 0;
-            int index = 0;
-            while ((index = oldName.indexOf('!', index + 1)) >= 0) {
-                count++;
-            }
-            // It looks like a configuration loop. It's better to stop.
-            if (count > 7) {
-                throw new MessagingException("Unable to create a new message name: too long." + " Possible loop in config.xml.");
-            } else {
-                oldName = oldName.substring(0, 76);
-            }
-        }
-
-        return oldName + "-!" + random.nextInt(1048576);
-    }
-
-    /**
-     * Generate a new identifier/name for a mail being processed by this server.
-     *
-     * @return the new identifier
-     */
-    public static String getId() {
-        return "Mail" + System.currentTimeMillis() + "-" + UUID.randomUUID();
-    }
-
-    @Override
-    public PerRecipientHeaders getPerRecipientSpecificHeaders() {
-        return perRecipientSpecificHeaders;
-    }
-
-    @Override
-    public void addSpecificHeaderForRecipient(Header header, MailAddress recipient) {
-        perRecipientSpecificHeaders.addHeaderForRecipient(header, recipient);
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/main/java/org/apache/james/core/MimeMessageCopyOnWriteProxy.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/main/java/org/apache/james/core/MimeMessageCopyOnWriteProxy.java b/server/container/core/src/main/java/org/apache/james/core/MimeMessageCopyOnWriteProxy.java
deleted file mode 100644
index f75d7dd..0000000
--- a/server/container/core/src/main/java/org/apache/james/core/MimeMessageCopyOnWriteProxy.java
+++ /dev/null
@@ -1,561 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-
-package org.apache.james.core;
-
-import javax.activation.DataHandler;
-import javax.mail.Address;
-import javax.mail.Flags;
-import javax.mail.Folder;
-import javax.mail.Message;
-import javax.mail.MessagingException;
-import javax.mail.Multipart;
-import javax.mail.Session;
-import javax.mail.Flags.Flag;
-import javax.mail.internet.MimeMessage;
-import javax.mail.search.SearchTerm;
-
-import org.apache.james.lifecycle.api.Disposable;
-import org.apache.james.lifecycle.api.LifecycleUtil;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.Date;
-import java.util.Enumeration;
-
-/**
- * This object wraps a "possibly shared" MimeMessage tracking copies and
- * automatically cloning it (if shared) when a write operation is invoked.
- */
-public class MimeMessageCopyOnWriteProxy extends MimeMessage implements Disposable {
-
-    /**
-     * Used internally to track the reference count It is important that this is
-     * static otherwise it will keep a reference to the parent object.
-     */
-    protected static class MessageReferenceTracker {
-
-        /**
-         * reference counter
-         */
-        private int referenceCount = 1;
-
-        /**
-         * The mime message in memory
-         */
-        private MimeMessage wrapped = null;
-
-        public MessageReferenceTracker(MimeMessage ref) {
-            wrapped = ref;
-        }
-
-        protected synchronized void incrementReferenceCount() {
-            referenceCount++;
-        }
-
-        protected synchronized void decrementReferenceCount() {
-            referenceCount--;
-            if (referenceCount <= 0) {
-                LifecycleUtil.dispose(wrapped);
-                wrapped = null;
-            }
-        }
-
-        protected synchronized int getReferenceCount() {
-            return referenceCount;
-        }
-
-        public synchronized MimeMessage getWrapped() {
-            return wrapped;
-        }
-
-    }
-
-    protected MessageReferenceTracker refCount;
-
-    public MimeMessageCopyOnWriteProxy(MimeMessage original) {
-        this(original, false);
-    }
-
-    public MimeMessageCopyOnWriteProxy(MimeMessageSource original) throws MessagingException {
-        this(new MimeMessageWrapper(original), true);
-    }
-
-    /**
-     * Private constructor providing an external reference counter.
-     */
-    private MimeMessageCopyOnWriteProxy(MimeMessage original, boolean writeable) {
-        super(Session.getDefaultInstance(System.getProperties(), null));
-
-        if (original instanceof MimeMessageCopyOnWriteProxy) {
-            refCount = ((MimeMessageCopyOnWriteProxy) original).refCount;
-        } else {
-            refCount = new MessageReferenceTracker(original);
-        }
-
-        if (!writeable) {
-            refCount.incrementReferenceCount();
-        }
-    }
-
-    /**
-     * Check the number of references over the MimeMessage and clone it if
-     * needed before returning the reference
-     * 
-     * @throws MessagingException
-     *             exception
-     */
-    protected synchronized MimeMessage getWrappedMessageForWriting() throws MessagingException {
-        if (refCount.getReferenceCount() > 1) {
-            refCount.decrementReferenceCount();
-            refCount = new MessageReferenceTracker(new MimeMessageWrapper(refCount.getWrapped()));
-        }
-        return refCount.getWrapped();
-    }
-
-    /**
-     * Return wrapped mimeMessage
-     * 
-     * @return wrapped return the wrapped mimeMessage
-     */
-    public synchronized MimeMessage getWrappedMessage() {
-        return refCount.getWrapped();
-    }
-
-    @Override
-    public synchronized void dispose() {
-        if (refCount != null) {
-            refCount.decrementReferenceCount();
-            refCount = null;
-        }
-    }
-
-    @Override
-    public void writeTo(OutputStream os) throws IOException, MessagingException {
-        getWrappedMessage().writeTo(os);
-    }
-
-    /**
-     * Rewritten for optimization purposes
-     */
-    @Override
-    public void writeTo(OutputStream os, String[] ignoreList) throws IOException, MessagingException {
-        getWrappedMessage().writeTo(os, ignoreList);
-    }
-
-    /*
-     * Various reader methods
-     */
-
-    @Override
-    public Address[] getFrom() throws MessagingException {
-        return getWrappedMessage().getFrom();
-    }
-
-    @Override
-    public Address[] getRecipients(Message.RecipientType type) throws MessagingException {
-        return getWrappedMessage().getRecipients(type);
-    }
-
-    @Override
-    public Address[] getAllRecipients() throws MessagingException {
-        return getWrappedMessage().getAllRecipients();
-    }
-
-    @Override
-    public Address[] getReplyTo() throws MessagingException {
-        return getWrappedMessage().getReplyTo();
-    }
-
-    @Override
-    public String getSubject() throws MessagingException {
-        return getWrappedMessage().getSubject();
-    }
-
-    @Override
-    public Date getSentDate() throws MessagingException {
-        return getWrappedMessage().getSentDate();
-    }
-
-    @Override
-    public Date getReceivedDate() throws MessagingException {
-        return getWrappedMessage().getReceivedDate();
-    }
-
-    @Override
-    public int getSize() throws MessagingException {
-        return getWrappedMessage().getSize();
-    }
-
-    @Override
-    public int getLineCount() throws MessagingException {
-        return getWrappedMessage().getLineCount();
-    }
-
-    @Override
-    public String getContentType() throws MessagingException {
-        return getWrappedMessage().getContentType();
-    }
-
-    @Override
-    public boolean isMimeType(String mimeType) throws MessagingException {
-        return getWrappedMessage().isMimeType(mimeType);
-    }
-
-    @Override
-    public String getDisposition() throws MessagingException {
-        return getWrappedMessage().getDisposition();
-    }
-
-    @Override
-    public String getEncoding() throws MessagingException {
-        return getWrappedMessage().getEncoding();
-    }
-
-    @Override
-    public String getContentID() throws MessagingException {
-        return getWrappedMessage().getContentID();
-    }
-
-    @Override
-    public String getContentMD5() throws MessagingException {
-        return getWrappedMessage().getContentMD5();
-    }
-
-    @Override
-    public String getDescription() throws MessagingException {
-        return getWrappedMessage().getDescription();
-    }
-
-    @Override
-    public String[] getContentLanguage() throws MessagingException {
-        return getWrappedMessage().getContentLanguage();
-    }
-
-    @Override
-    public String getMessageID() throws MessagingException {
-        return getWrappedMessage().getMessageID();
-    }
-
-    @Override
-    public String getFileName() throws MessagingException {
-        return getWrappedMessage().getFileName();
-    }
-
-    @Override
-    public InputStream getInputStream() throws IOException, MessagingException {
-        return getWrappedMessage().getInputStream();
-    }
-
-    @Override
-    public DataHandler getDataHandler() throws MessagingException {
-        return getWrappedMessage().getDataHandler();
-    }
-
-    @Override
-    public Object getContent() throws IOException, MessagingException {
-        return getWrappedMessage().getContent();
-    }
-
-    @Override
-    public String[] getHeader(String name) throws MessagingException {
-        return getWrappedMessage().getHeader(name);
-    }
-
-    @Override
-    public String getHeader(String name, String delimiter) throws MessagingException {
-        return getWrappedMessage().getHeader(name, delimiter);
-    }
-
-    @SuppressWarnings("unchecked")
-    @Override
-    public Enumeration<String> getAllHeaders() throws MessagingException {
-        return getWrappedMessage().getAllHeaders();
-    }
-
-    @SuppressWarnings("unchecked")
-    @Override
-    public Enumeration<String> getMatchingHeaders(String[] names) throws MessagingException {
-        return getWrappedMessage().getMatchingHeaders(names);
-    }
-
-    @SuppressWarnings("unchecked")
-    @Override
-    public Enumeration<String> getNonMatchingHeaders(String[] names) throws MessagingException {
-        return getWrappedMessage().getNonMatchingHeaders(names);
-    }
-
-    @SuppressWarnings("unchecked")
-    @Override
-    public Enumeration<String> getAllHeaderLines() throws MessagingException {
-        return getWrappedMessage().getAllHeaderLines();
-    }
-
-    @SuppressWarnings("unchecked")
-    @Override
-    public Enumeration<String> getMatchingHeaderLines(String[] names) throws MessagingException {
-        return getWrappedMessage().getMatchingHeaderLines(names);
-    }
-
-    @SuppressWarnings("unchecked")
-    @Override
-    public Enumeration<String> getNonMatchingHeaderLines(String[] names) throws MessagingException {
-        return getWrappedMessage().getNonMatchingHeaderLines(names);
-    }
-
-    @Override
-    public Flags getFlags() throws MessagingException {
-        return getWrappedMessage().getFlags();
-    }
-
-    @Override
-    public boolean isSet(Flags.Flag flag) throws MessagingException {
-        return getWrappedMessage().isSet(flag);
-    }
-
-    @Override
-    public Address getSender() throws MessagingException {
-        return getWrappedMessage().getSender();
-    }
-
-    @Override
-    public boolean match(SearchTerm arg0) throws MessagingException {
-        return getWrappedMessage().match(arg0);
-    }
-
-    @Override
-    public InputStream getRawInputStream() throws MessagingException {
-        return getWrappedMessage().getRawInputStream();
-    }
-
-    @Override
-    public Folder getFolder() {
-        return getWrappedMessage().getFolder();
-    }
-
-    @Override
-    public int getMessageNumber() {
-        return getWrappedMessage().getMessageNumber();
-    }
-
-    @Override
-    public boolean isExpunged() {
-        return getWrappedMessage().isExpunged();
-    }
-
-    @Override
-    public boolean equals(Object arg0) {
-        return getWrappedMessage().equals(arg0);
-    }
-
-    @Override
-    public int hashCode() {
-        return getWrappedMessage().hashCode();
-    }
-
-    @Override
-    public String toString() {
-        return getWrappedMessage().toString();
-    }
-
-    @Override
-    public void setFrom(Address address) throws MessagingException {
-        getWrappedMessageForWriting().setFrom(address);
-    }
-
-    @Override
-    public void setFrom() throws MessagingException {
-        getWrappedMessageForWriting().setFrom();
-    }
-
-    @Override
-    public void addFrom(Address[] addresses) throws MessagingException {
-        getWrappedMessageForWriting().addFrom(addresses);
-    }
-
-    @Override
-    public void setRecipients(Message.RecipientType type, Address[] addresses) throws MessagingException {
-        getWrappedMessageForWriting().setRecipients(type, addresses);
-    }
-
-    @Override
-    public void addRecipients(Message.RecipientType type, Address[] addresses) throws MessagingException {
-        getWrappedMessageForWriting().addRecipients(type, addresses);
-    }
-
-    @Override
-    public void setReplyTo(Address[] addresses) throws MessagingException {
-        getWrappedMessageForWriting().setReplyTo(addresses);
-    }
-
-    @Override
-    public void setSubject(String subject) throws MessagingException {
-        getWrappedMessageForWriting().setSubject(subject);
-    }
-
-    @Override
-    public void setSubject(String subject, String charset) throws MessagingException {
-        getWrappedMessageForWriting().setSubject(subject, charset);
-    }
-
-    @Override
-    public void setSentDate(Date d) throws MessagingException {
-        getWrappedMessageForWriting().setSentDate(d);
-    }
-
-    @Override
-    public void setDisposition(String disposition) throws MessagingException {
-        getWrappedMessageForWriting().setDisposition(disposition);
-    }
-
-    @Override
-    public void setContentID(String cid) throws MessagingException {
-        getWrappedMessageForWriting().setContentID(cid);
-    }
-
-    @Override
-    public void setContentMD5(String md5) throws MessagingException {
-        getWrappedMessageForWriting().setContentMD5(md5);
-    }
-
-    @Override
-    public void setDescription(String description) throws MessagingException {
-        getWrappedMessageForWriting().setDescription(description);
-    }
-
-    @Override
-    public void setDescription(String description, String charset) throws MessagingException {
-        getWrappedMessageForWriting().setDescription(description, charset);
-    }
-
-    @Override
-    public void setContentLanguage(String[] languages) throws MessagingException {
-        getWrappedMessageForWriting().setContentLanguage(languages);
-    }
-
-    @Override
-    public void setFileName(String filename) throws MessagingException {
-        getWrappedMessageForWriting().setFileName(filename);
-    }
-
-    @Override
-    public void setDataHandler(DataHandler dh) throws MessagingException {
-        getWrappedMessageForWriting().setDataHandler(dh);
-    }
-
-    @Override
-    public void setContent(Object o, String type) throws MessagingException {
-        getWrappedMessageForWriting().setContent(o, type);
-    }
-
-    @Override
-    public void setText(String text) throws MessagingException {
-        getWrappedMessageForWriting().setText(text);
-    }
-
-    @Override
-    public void setText(String text, String charset) throws MessagingException {
-        getWrappedMessageForWriting().setText(text, charset);
-    }
-
-    @Override
-    public void setContent(Multipart mp) throws MessagingException {
-        getWrappedMessageForWriting().setContent(mp);
-    }
-
-    /**
-     * This does not need a writable message
-     */
-    @Override
-    public Message reply(boolean replyToAll) throws MessagingException {
-        return getWrappedMessage().reply(replyToAll);
-    }
-
-    @Override
-    public void setHeader(String name, String value) throws MessagingException {
-        getWrappedMessageForWriting().setHeader(name, value);
-    }
-
-    @Override
-    public void addHeader(String name, String value) throws MessagingException {
-        getWrappedMessageForWriting().addHeader(name, value);
-    }
-
-    @Override
-    public void removeHeader(String name) throws MessagingException {
-        getWrappedMessageForWriting().removeHeader(name);
-    }
-
-    @Override
-    public void addHeaderLine(String line) throws MessagingException {
-        getWrappedMessageForWriting().addHeaderLine(line);
-    }
-
-    @Override
-    public void setFlags(Flags flag, boolean set) throws MessagingException {
-        getWrappedMessageForWriting().setFlags(flag, set);
-    }
-
-    @Override
-    public void saveChanges() throws MessagingException {
-        getWrappedMessageForWriting().saveChanges();
-    }
-
-    /*
-     * Since JavaMail 1.2
-     */
-
-    @Override
-    public void addRecipients(Message.RecipientType type, String addresses) throws MessagingException {
-        getWrappedMessageForWriting().addRecipients(type, addresses);
-    }
-
-    @Override
-    public void setRecipients(Message.RecipientType type, String addresses) throws MessagingException {
-        getWrappedMessageForWriting().setRecipients(type, addresses);
-    }
-
-    @Override
-    public void setSender(Address arg0) throws MessagingException {
-        getWrappedMessageForWriting().setSender(arg0);
-    }
-
-    public void addRecipient(RecipientType arg0, Address arg1) throws MessagingException {
-        getWrappedMessageForWriting().addRecipient(arg0, arg1);
-    }
-
-    @Override
-    public void setFlag(Flag arg0, boolean arg1) throws MessagingException {
-        getWrappedMessageForWriting().setFlag(arg0, arg1);
-    }
-
-    public long getMessageSize() throws MessagingException {
-        return MimeMessageUtil.getMessageSize(getWrappedMessage());
-    }
-
-    /**
-     * Since javamail 1.4
-     */
-    @Override
-    public void setText(String text, String charset, String subtype) throws MessagingException {
-        getWrappedMessage().setText(text, charset, subtype);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/main/java/org/apache/james/core/MimeMessageInputStream.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/main/java/org/apache/james/core/MimeMessageInputStream.java b/server/container/core/src/main/java/org/apache/james/core/MimeMessageInputStream.java
deleted file mode 100644
index f4ea3a7..0000000
--- a/server/container/core/src/main/java/org/apache/james/core/MimeMessageInputStream.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-
-package org.apache.james.core;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-
-import javax.mail.MessagingException;
-import javax.mail.internet.MimeMessage;
-
-/**
- * Provide an {@link InputStream} over an {@link MimeMessage}
- */
-public class MimeMessageInputStream extends InputStream {
-    private final InputStream in;
-
-    /**
-     * Provide an {@link InputStream} over a {@link MimeMessage}.
-     * 
-     * @param message
-     *            the message to wrap
-     * @param tryCast
-     *            try to cast the {@link MimeMessage} to
-     *            {@link MimeMessageCopyOnWriteProxy} /
-     *            {@link MimeMessageWrapper} to do some optimized processing if
-     *            possible
-     * @throws MessagingException
-     */
-    public MimeMessageInputStream(MimeMessage message, boolean tryCast) throws MessagingException {
-        MimeMessage m = message;
-
-        // check if we need to use the wrapped message
-        if (tryCast && m instanceof MimeMessageCopyOnWriteProxy) {
-            m = ((MimeMessageCopyOnWriteProxy) m).getWrappedMessage();
-        }
-
-        // check if we can use optimized operations
-        if (tryCast && m instanceof MimeMessageWrapper) {
-            in = ((MimeMessageWrapper) m).getMessageInputStream();
-        } else {
-
-            ByteArrayOutputStream out = new ByteArrayOutputStream();
-            try {
-                message.writeTo(out);
-                in = new ByteArrayInputStream(out.toByteArray());
-            } catch (IOException e1) {
-                throw new MessagingException("Unable to read message " + message, e1);
-            }
-
-        }
-
-    }
-
-    /**
-     * Use true as tryCast parameter
-     * 
-     * {@link #MimeMessageInputStream(MimeMessage, boolean)}
-     */
-    public MimeMessageInputStream(MimeMessage message) throws MessagingException {
-        this(message, true);
-    }
-
-    @Override
-    public int read() throws IOException {
-        return in.read();
-    }
-
-    @Override
-    public void close() throws IOException {
-        in.close();
-    }
-
-    @Override
-    public int available() throws IOException {
-        return in.available();
-    }
-
-    @Override
-    public void mark(int readlimit) {
-        in.mark(readlimit);
-    }
-
-    @Override
-    public boolean markSupported() {
-        return in.markSupported();
-    }
-
-    @Override
-    public int read(byte[] b, int off, int len) throws IOException {
-        return in.read(b, off, len);
-    }
-
-    @Override
-    public int read(byte[] b) throws IOException {
-        return in.read(b);
-    }
-
-    @Override
-    public void reset() throws IOException {
-        in.reset();
-    }
-
-    @Override
-    public long skip(long n) throws IOException {
-        return in.skip(n);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/main/java/org/apache/james/core/MimeMessageInputStreamSource.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/main/java/org/apache/james/core/MimeMessageInputStreamSource.java b/server/container/core/src/main/java/org/apache/james/core/MimeMessageInputStreamSource.java
deleted file mode 100644
index 46d1afd..0000000
--- a/server/container/core/src/main/java/org/apache/james/core/MimeMessageInputStreamSource.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-
-package org.apache.james.core;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.mail.MessagingException;
-import javax.mail.util.SharedByteArrayInputStream;
-import javax.mail.util.SharedFileInputStream;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.io.output.DeferredFileOutputStream;
-import org.apache.james.lifecycle.api.Disposable;
-
-/**
- * Takes an input stream and creates a repeatable input stream source for a
- * MimeMessageWrapper. It does this by completely reading the input stream and
- * saving that to data to an {@link DeferredFileOutputStream} with its threshold set to 100kb
- */
-public class MimeMessageInputStreamSource extends MimeMessageSource implements Disposable {
-
-    private final List<InputStream> streams = new ArrayList<>();
-
-    /**
-     * A temporary file used to hold the message stream
-     */
-    private DeferredFileOutputStream out;
-
-    /**
-     * The full path of the temporary file
-     */
-    private final String sourceId;
-
-    /**
-     * 100kb threshold for the stream.
-     */
-    private final static int THRESHOLD = 1024 * 100;
-
-    /**
-     * Temporary directory to use
-     */
-    private final static File TMPDIR = new File(System.getProperty("java.io.tmpdir"));
-
-    /**
-     * Construct a new MimeMessageInputStreamSource from an
-     * <code>InputStream</code> that contains the bytes of a MimeMessage.
-     *
-     * @param key the prefix for the name of the temp file
-     * @param in  the stream containing the MimeMessage
-     * @throws MessagingException if an error occurs while trying to store the stream
-     */
-    public MimeMessageInputStreamSource(String key, InputStream in) throws MessagingException {
-        super();
-        // We want to immediately read this into a temporary file
-        // Create a temp file and channel the input stream into it
-        try {
-            out = new DeferredFileOutputStream(THRESHOLD, "mimemessage-" + key, ".m64", TMPDIR);
-            IOUtils.copy(in, out);
-            sourceId = key;
-        } catch (IOException ioe) {
-            File file = out.getFile();
-            if (file != null) {
-                FileUtils.deleteQuietly(file);
-            }
-            throw new MessagingException("Unable to retrieve the data: " + ioe.getMessage(), ioe);
-        } finally {
-            try {
-                if (out != null) {
-                    out.close();
-                }
-            } catch (IOException ioe) {
-                // Ignored - logging unavailable to log this non-fatal error.
-            }
-
-            try {
-                if (in != null) {
-                    in.close();
-                }
-            } catch (IOException ioe) {
-                // Ignored - logging unavailable to log this non-fatal error.
-            }
-
-        }
-    }
-
-    public MimeMessageInputStreamSource(String key) {
-        super();
-        out = new DeferredFileOutputStream(THRESHOLD, key, ".m64", TMPDIR);
-        sourceId = key;
-    }
-
-    /**
-     * Returns the unique identifier of this input stream source
-     *
-     * @return the unique identifier for this MimeMessageInputStreamSource
-     */
-    public String getSourceId() {
-        return sourceId;
-    }
-
-    /**
-     * Get an input stream to retrieve the data stored in the temporary file
-     *
-     * @return a <code>BufferedInputStream</code> containing the data
-     */
-    public synchronized InputStream getInputStream() throws IOException {
-        InputStream in;
-        if (out.isInMemory()) {
-            in = new SharedByteArrayInputStream(out.getData());
-        } else {
-            in = new SharedFileInputStream(out.getFile());
-        }
-        streams.add(in);
-        return in;
-    }
-
-    /**
-     * Get the size of the temp file
-     *
-     * @return the size of the temp file
-     * @throws IOException if an error is encoutered while computing the size of the
-     *                     message
-     */
-    @Override
-    public long getMessageSize() throws IOException {
-        return out.getByteCount();
-    }
-
-    public OutputStream getWritableOutputStream() {
-        return out;
-    }
-
-    @Override
-    public void dispose() {
-        // explicit close all streams
-        for (InputStream stream : streams) {
-            IOUtils.closeQuietly(stream);
-        }
-
-        if (out != null) {
-            IOUtils.closeQuietly(out);
-            File file = out.getFile();
-            if (file != null) {
-                FileUtils.deleteQuietly(file);
-                file = null;
-            }
-            out = null;
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/main/java/org/apache/james/core/MimeMessageSource.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/main/java/org/apache/james/core/MimeMessageSource.java b/server/container/core/src/main/java/org/apache/james/core/MimeMessageSource.java
deleted file mode 100644
index 57e1e23..0000000
--- a/server/container/core/src/main/java/org/apache/james/core/MimeMessageSource.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-
-package org.apache.james.core;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-/**
- * This defines a reusable datasource that can supply an input stream with
- * MimeMessage data. This allows a MimeMessageWrapper or other classes to grab
- * the underlying data.
- * 
- * @see MimeMessageWrapper
- */
-public abstract class MimeMessageSource {
-
-    /**
-     * Returns a unique String ID that represents the location from where this
-     * file is loaded. This will be used to identify where the data is,
-     * primarily to avoid situations where this data would get overwritten.
-     * 
-     * @return the String ID
-     */
-    public abstract String getSourceId();
-
-    /**
-     * Get an input stream to retrieve the data stored in the datasource
-     * 
-     * @return a <code>InputStream</code> containing the data
-     * 
-     * @throws IOException
-     *             if an error occurs while generating the InputStream
-     */
-    public abstract InputStream getInputStream() throws IOException;
-
-    /**
-     * Return the size of all the data. Default implementation... others can
-     * override to do this much faster
-     * 
-     * @return the size of the data represented by this source
-     * @throws IOException
-     *             if an error is encountered while computing the message size
-     */
-    public long getMessageSize() throws IOException {
-        int size = 0;
-        InputStream in = null;
-        try {
-            in = getInputStream();
-            int read;
-            byte[] data = new byte[1024];
-            while ((read = in.read(data)) > 0) {
-                size += read;
-            }
-        } finally {
-            try {
-                if (in != null) {
-                    in.close();
-                }
-            } catch (IOException ioe) {
-                // Exception ignored because logging is
-                // unavailable
-            }
-        }
-        return size;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/main/java/org/apache/james/core/MimeMessageUtil.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/main/java/org/apache/james/core/MimeMessageUtil.java b/server/container/core/src/main/java/org/apache/james/core/MimeMessageUtil.java
deleted file mode 100644
index 5ee7a49..0000000
--- a/server/container/core/src/main/java/org/apache/james/core/MimeMessageUtil.java
+++ /dev/null
@@ -1,311 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-
-package org.apache.james.core;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.Enumeration;
-
-import javax.activation.UnsupportedDataTypeException;
-import javax.mail.MessagingException;
-import javax.mail.internet.MimeMessage;
-import javax.mail.internet.MimeUtility;
-
-import org.apache.commons.io.IOUtils;
-
-/**
- * Utility class to provide optimized write methods for the various MimeMessage
- * implementations.
- */
-public class MimeMessageUtil {
-
-    /**
-     * Convenience method to take any MimeMessage and write the headers and body
-     * to two different output streams
-     * 
-     * @param message
-     *            the MimeMessage reading from
-     * @param headerOs
-     *            the OutputStream writting the headers to
-     * @param bodyOs
-     *            the OutputStream writting the body to
-     * @throws IOException
-     *             get thrown if an IO Error detected while writing to the
-     *             streams
-     * @throws MessagingException
-     *             get thrown if an error detected while reading the message
-     */
-    public static void writeTo(MimeMessage message, OutputStream headerOs, OutputStream bodyOs) throws IOException, MessagingException {
-        writeTo(message, headerOs, bodyOs, null);
-    }
-
-    /**
-     * Convenience method to take any MimeMessage and write the headers and body
-     * to two different output streams, with an ignore list
-     * 
-     * @param message
-     *            the MimeMessage reading from
-     * @param headerOs
-     *            the OutputStream writting the headers to
-     * @param bodyOs
-     *            the OutputStream writting the body to
-     * @param ignoreList
-     *            the String[] which contains headers which should be ignored
-     * @throws IOException
-     *             get thrown if an IO Error detected while writing to the
-     *             streams
-     * @throws MessagingException
-     *             get thrown if an error detected while reading the message
-     */
-    public static void writeTo(MimeMessage message, OutputStream headerOs, OutputStream bodyOs, String[] ignoreList) throws IOException, MessagingException {
-        MimeMessage testMessage = message;
-        if (message instanceof MimeMessageCopyOnWriteProxy) {
-            MimeMessageCopyOnWriteProxy wr = (MimeMessageCopyOnWriteProxy) message;
-            testMessage = wr.getWrappedMessage();
-        }
-        if (testMessage instanceof MimeMessageWrapper) {
-            MimeMessageWrapper wrapper = (MimeMessageWrapper) testMessage;
-            if (!wrapper.isModified()) {
-                wrapper.writeTo(headerOs, bodyOs, ignoreList);
-                return;
-            }
-        }
-        writeToInternal(message, headerOs, bodyOs, ignoreList);
-    }
-
-    /**
-     * 
-     * @param message
-     * @param headerOs
-     * @param bodyOs
-     * @param ignoreList
-     * @throws MessagingException
-     * @throws IOException
-     * @throws UnsupportedDataTypeException
-     */
-    public static void writeToInternal(MimeMessage message, OutputStream headerOs, OutputStream bodyOs, String[] ignoreList) throws MessagingException, IOException {
-        if (message.getMessageID() == null) {
-            message.saveChanges();
-        }
-
-        writeHeadersTo(message, headerOs, ignoreList);
-
-        // Write the body to the output stream
-        writeMessageBodyTo(message, bodyOs);
-    }
-
-    /**
-     * Write message body of given mimeessage to the given outputStream
-     * 
-     * @param message
-     *            the MimeMessage used as input
-     * @param bodyOs
-     *            the OutputStream to write the message body to
-     * @throws IOException
-     * @throws UnsupportedDataTypeException
-     * @throws MessagingException
-     */
-    public static void writeMessageBodyTo(MimeMessage message, OutputStream bodyOs) throws IOException, MessagingException {
-        OutputStream bos;
-        InputStream bis;
-
-        try {
-            // Get the message as a stream. This will encode
-            // objects as necessary, and we have some input from
-            // decoding an re-encoding the stream. I'd prefer the
-            // raw stream, but see
-            bos = MimeUtility.encode(bodyOs, message.getEncoding());
-            bis = message.getInputStream();
-        } catch (UnsupportedDataTypeException | MessagingException udte) {
-            /*
-             * If we get an UnsupportedDataTypeException try using the raw input
-             * stream as a "best attempt" at rendering a message.
-             * 
-             * WARNING: JavaMail v1.3 getRawInputStream() returns INVALID
-             * (unchanged) content for a changed message. getInputStream() works
-             * properly, but in this case has failed due to a missing
-             * DataHandler.
-             * 
-             * MimeMessage.getRawInputStream() may throw a "no content"
-             * MessagingException. In JavaMail v1.3, when you initially create a
-             * message using MimeMessage APIs, there is no raw content
-             * available. getInputStream() works, but getRawInputStream() throws
-             * an exception. If we catch that exception, throw the UDTE. It
-             * should mean that someone has locally constructed a message part
-             * for which JavaMail doesn't have a DataHandler.
-             */
-
-            try {
-                bis = message.getRawInputStream();
-                bos = bodyOs;
-            } catch (javax.mail.MessagingException ignored) {
-                throw udte;
-            }
-        }
-
-        try {
-            IOUtils.copy(bis, bos);
-        } finally {
-            IOUtils.closeQuietly(bis);
-        }
-    }
-
-    /**
-     * Write the message headers to the given outputstream
-     * 
-     * @param message
-     *            the MimeMessage to read from
-     * @param headerOs
-     *            the OutputStream to which the headers get written
-     * @param ignoreList
-     *            the String[] which holds headers which should be ignored
-     * @throws MessagingException
-     */
-    private static void writeHeadersTo(MimeMessage message, OutputStream headerOs, String[] ignoreList) throws MessagingException {
-        // Write the headers (minus ignored ones)
-        @SuppressWarnings("unchecked")
-        Enumeration<String> headers = message.getNonMatchingHeaderLines(ignoreList);
-        writeHeadersTo(headers, headerOs);
-    }
-
-    /**
-     * Write the message headers to the given outputstream
-     * 
-     * @param headers
-     *            the Enumeration which holds the headers
-     * @param headerOs
-     *            the OutputStream to which the headers get written
-     * @throws MessagingException
-     */
-    public static void writeHeadersTo(Enumeration<String> headers, OutputStream headerOs) throws MessagingException {
-        try {
-            IOUtils.copy(new InternetHeadersInputStream(headers), headerOs);
-        } catch (IOException e) {
-            throw new MessagingException("Unable to write headers to stream", e);
-        }
-    }
-
-    /**
-     * Get an InputStream which holds all headers of the given MimeMessage
-     * 
-     * @param message
-     *            the MimeMessage used as source
-     * @param ignoreList
-     *            the String[] which holds headers which should be ignored
-     * @return stream the InputStream which holds the headers
-     * @throws MessagingException
-     */
-    @SuppressWarnings("unchecked")
-    public static InputStream getHeadersInputStream(MimeMessage message, String[] ignoreList) throws MessagingException {
-        return new InternetHeadersInputStream(message.getNonMatchingHeaderLines(ignoreList));
-    }
-
-    /**
-     * Slow method to calculate the exact size of a message!
-     */
-    private static final class SizeCalculatorOutputStream extends OutputStream {
-        long size = 0;
-
-        public void write(int arg0) throws IOException {
-            size++;
-        }
-
-        public long getSize() {
-            return size;
-        }
-
-        public void write(byte[] arg0, int arg1, int arg2) throws IOException {
-            size += arg2;
-        }
-
-        public void write(byte[] arg0) throws IOException {
-            size += arg0.length;
-        }
-    }
-
-    /**
-     * Return the full site of an mimeMessage
-     * 
-     * @return size of full message including headers
-     * @throws MessagingException
-     *             if a problem occours while computing the message size
-     */
-    public static long getMessageSize(MimeMessage message) throws MessagingException {
-        // If we have a MimeMessageWrapper, then we can ask it for just the
-        // message size and skip calculating it
-        long size = -1;
-
-        if (message instanceof MimeMessageWrapper) {
-            MimeMessageWrapper wrapper = (MimeMessageWrapper) message;
-            size = wrapper.getMessageSize();
-        } else if (message instanceof MimeMessageCopyOnWriteProxy) {
-            MimeMessageCopyOnWriteProxy wrapper = (MimeMessageCopyOnWriteProxy) message;
-            size = wrapper.getMessageSize();
-        }
-
-        if (size == -1) {
-            size = calculateMessageSize(message);
-        }
-
-        return size;
-    }
-
-    /**
-     * Calculate the size of the give mimeMessage
-     * 
-     * @param message
-     *            the MimeMessage
-     * @return size the calculated size
-     * @throws MessagingException
-     *             if a problem occours while calculate the message size
-     */
-    public static long calculateMessageSize(MimeMessage message) throws MessagingException {
-        long size;
-        // SK: Should probably eventually store this as a locally
-        // maintained value (so we don't have to load and reparse
-        // messages each time).
-        size = message.getSize();
-        if (size != -1) {
-            Enumeration<?> e = message.getAllHeaderLines();
-            if (e.hasMoreElements()) {
-                size += 2;
-            }
-            while (e.hasMoreElements()) {
-                // add 2 bytes for the CRLF
-                size += ((String) e.nextElement()).length() + 2;
-            }
-        }
-
-        if (size == -1) {
-            SizeCalculatorOutputStream out = new SizeCalculatorOutputStream();
-            try {
-                message.writeTo(out);
-            } catch (IOException e) {
-                // should never happen as SizeCalculator does not actually throw
-                // IOExceptions.
-                throw new MessagingException("IOException wrapped by getMessageSize", e);
-            }
-            size = out.getSize();
-        }
-        return size;
-    }
-
-}


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


[11/23] james-project git commit: JAMES-2138 move MailAddress to a new james-core project

Posted by bt...@apache.org.
http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/main/java/org/apache/james/server/core/MailImpl.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/main/java/org/apache/james/server/core/MailImpl.java b/server/container/core/src/main/java/org/apache/james/server/core/MailImpl.java
new file mode 100644
index 0000000..106d46f
--- /dev/null
+++ b/server/container/core/src/main/java/org/apache/james/server/core/MailImpl.java
@@ -0,0 +1,691 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.server.core;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.OptionalDataException;
+import java.io.OutputStream;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.UUID;
+
+import javax.mail.MessagingException;
+import javax.mail.internet.MimeMessage;
+import javax.mail.internet.ParseException;
+
+import org.apache.james.lifecycle.api.Disposable;
+import org.apache.james.lifecycle.api.LifecycleUtil;
+import org.apache.james.core.MailAddress;
+import org.apache.mailet.Mail;
+import org.apache.mailet.PerRecipientHeaders;
+import org.apache.mailet.PerRecipientHeaders.Header;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * <p>
+ * Wraps a MimeMessage adding routing information (from SMTP) and some simple
+ * API enhancements.
+ * </p>
+ * <p>
+ * From James version > 2.2.0a8 "mail attributes" have been added. Backward and
+ * forward compatibility is supported:
+ * <ul>
+ * <li>messages stored in file repositories <i>without</i> attributes by James
+ * version <= 2.2.0a8 will be processed by later versions as having an empty
+ * attributes hashmap;</li>
+ * <li>messages stored in file repositories <i>with</i> attributes by James
+ * version > 2.2.0a8 will be processed by previous versions, ignoring the
+ * attributes.</li>
+ * </ul>
+ * </p>
+ */
+public class MailImpl implements Disposable, Mail {
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(MailImpl.class);
+
+    /**
+     * We hardcode the serialVersionUID so that from James 1.2 on, MailImpl will
+     * be deserializable (so your mail doesn't get lost)
+     */
+    public static final long serialVersionUID = -4289663364703986260L;
+    /**
+     * The error message, if any, associated with this mail.
+     */
+    private String errorMessage;
+    /**
+     * The state of this mail, which determines how it is processed.
+     */
+    private String state;
+    /**
+     * The MimeMessage that holds the mail data.
+     */
+    private MimeMessage message;
+    /**
+     * The sender of this mail.
+     */
+    private MailAddress sender;
+    /**
+     * The collection of recipients to whom this mail was sent.
+     */
+    private Collection<MailAddress> recipients;
+    /**
+     * The identifier for this mail message
+     */
+    private String name;
+    /**
+     * The remote host from which this mail was sent.
+     */
+    private String remoteHost = "localhost";
+    /**
+     * The remote address from which this mail was sent.
+     */
+    private String remoteAddr = "127.0.0.1";
+    /**
+     * The last time this message was updated.
+     */
+    private Date lastUpdated = new Date();
+    /**
+     * Attributes added to this MailImpl instance
+     */
+    private Map<String, Object> attributes;
+    /**
+     * Specific headers for some recipients
+     * These headers will be added at delivery time
+     */
+    private PerRecipientHeaders perRecipientSpecificHeaders;
+
+    /**
+     * A constructor that creates a new, uninitialized MailImpl
+     */
+    public MailImpl() {
+        setState(Mail.DEFAULT);
+        attributes = new HashMap<>();
+        perRecipientSpecificHeaders = new PerRecipientHeaders();
+    }
+
+    /**
+     * A constructor that creates a MailImpl with the specified name, sender,
+     * and recipients.
+     *
+     * @param name       the name of the MailImpl
+     * @param sender     the sender for this MailImpl
+     * @param recipients the collection of recipients of this MailImpl
+     */
+    public MailImpl(String name, MailAddress sender, Collection<MailAddress> recipients) {
+        this();
+        this.name = name;
+        this.sender = sender;
+        this.recipients = null;
+
+        // Copy the recipient list
+        if (recipients != null) {
+            this.recipients = new ArrayList<>();
+            this.recipients.addAll(recipients);
+        }
+    }
+
+    /**
+     * Create a copy of the input mail and assign it a new name
+     *
+     * @param mail original mail
+     * @throws MessagingException when the message is not clonable
+     */
+    public MailImpl(Mail mail) throws MessagingException {
+        this(mail, newName(mail));
+    }
+
+    /**
+     * @param mail
+     * @param newName
+     * @throws MessagingException
+     */
+    @SuppressWarnings("unchecked")
+    public MailImpl(Mail mail, String newName) throws MessagingException {
+        this(newName, mail.getSender(), mail.getRecipients(), mail.getMessage());
+        setRemoteHost(mail.getRemoteHost());
+        setRemoteAddr(mail.getRemoteAddr());
+        setLastUpdated(mail.getLastUpdated());
+        try {
+            if (mail instanceof MailImpl) {
+                setAttributesRaw((HashMap<String, Object>) cloneSerializableObject(((MailImpl) mail).getAttributesRaw()));
+            } else {
+                HashMap<String, Object> attribs = new HashMap<>();
+                for (Iterator<String> i = mail.getAttributeNames(); i.hasNext(); ) {
+                    String hashKey = i.next();
+                    attribs.put(hashKey, cloneSerializableObject(mail.getAttribute(hashKey)));
+                }
+                setAttributesRaw(attribs);
+            }
+        } catch (IOException | ClassNotFoundException e) {
+            LOGGER.error("Error while deserializing attributes", e);
+            setAttributesRaw(new HashMap<>());
+        }
+    }
+
+    /**
+     * A constructor that creates a MailImpl with the specified name, sender,
+     * recipients, and message data.
+     *
+     * @param name       the name of the MailImpl
+     * @param sender     the sender for this MailImpl
+     * @param recipients the collection of recipients of this MailImpl
+     * @param messageIn  a stream containing the message source
+     */
+    public MailImpl(String name, MailAddress sender, Collection<MailAddress> recipients, InputStream messageIn) throws MessagingException {
+        this(name, sender, recipients);
+        MimeMessageSource source = new MimeMessageInputStreamSource(name, messageIn);
+        // if MimeMessageCopyOnWriteProxy throws an error in the constructor we
+        // have to manually care disposing our source.
+        try {
+            this.setMessage(new MimeMessageCopyOnWriteProxy(source));
+        } catch (MessagingException e) {
+            LifecycleUtil.dispose(source);
+            throw e;
+        }
+    }
+
+    /**
+     * A constructor that creates a MailImpl with the specified name, sender,
+     * recipients, and MimeMessage.
+     *
+     * @param name       the name of the MailImpl
+     * @param sender     the sender for this MailImpl
+     * @param recipients the collection of recipients of this MailImpl
+     * @param message    the MimeMessage associated with this MailImpl
+     */
+    public MailImpl(String name, MailAddress sender, Collection<MailAddress> recipients, MimeMessage message) {
+        this(name, sender, recipients);
+        this.setMessage(new MimeMessageCopyOnWriteProxy(message));
+    }
+
+    /**
+     * Duplicate the MailImpl.
+     *
+     * @return a MailImpl that is a duplicate of this one
+     */
+    public Mail duplicate() {
+        return duplicate(name);
+    }
+
+    /**
+     * Duplicate the MailImpl, replacing the mail name with the one passed in as
+     * an argument.
+     *
+     * @param newName the name for the duplicated mail
+     * @return a MailImpl that is a duplicate of this one with a different name
+     */
+    public Mail duplicate(String newName) {
+        try {
+            return new MailImpl(this, newName);
+        } catch (MessagingException me) {
+            // Ignored. Return null in the case of an error.
+        }
+        return null;
+    }
+
+    /**
+     * Get the error message associated with this MailImpl.
+     *
+     * @return the error message associated with this MailImpl
+     */
+    @Override
+    public String getErrorMessage() {
+        return errorMessage;
+    }
+
+    /**
+     * Get the MimeMessage associated with this MailImpl.
+     *
+     * @return the MimeMessage associated with this MailImpl
+     */
+    @Override
+    public MimeMessage getMessage() throws MessagingException {
+        return message;
+    }
+
+    /**
+     * Set the name of this MailImpl.
+     *
+     * @param name the name of this MailImpl
+     */
+    @Override
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    /**
+     * Get the name of this MailImpl.
+     *
+     * @return the name of this MailImpl
+     */
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    /**
+     * Get the recipients of this MailImpl.
+     *
+     * @return the recipients of this MailImpl
+     */
+    @Override
+    public Collection<MailAddress> getRecipients() {
+        return recipients;
+    }
+
+    /**
+     * Get the sender of this MailImpl.
+     *
+     * @return the sender of this MailImpl
+     */
+    @Override
+    public MailAddress getSender() {
+        return sender;
+    }
+
+    /**
+     * Get the state of this MailImpl.
+     *
+     * @return the state of this MailImpl
+     */
+    @Override
+    public String getState() {
+        return state;
+    }
+
+    /**
+     * Get the remote host associated with this MailImpl.
+     *
+     * @return the remote host associated with this MailImpl
+     */
+    @Override
+    public String getRemoteHost() {
+        return remoteHost;
+    }
+
+    /**
+     * Get the remote address associated with this MailImpl.
+     *
+     * @return the remote address associated with this MailImpl
+     */
+    @Override
+    public String getRemoteAddr() {
+        return remoteAddr;
+    }
+
+    /**
+     * Get the last updated time for this MailImpl.
+     *
+     * @return the last updated time for this MailImpl
+     */
+    @Override
+    public Date getLastUpdated() {
+        return lastUpdated;
+    }
+
+    /**
+     * <p>
+     * Return the size of the message including its headers.
+     * MimeMessage.getSize() method only returns the size of the message body.
+     * </p>
+     * <p/>
+     * <p>
+     * Note: this size is not guaranteed to be accurate - see Sun's
+     * documentation of MimeMessage.getSize().
+     * </p>
+     *
+     * @return approximate size of full message including headers.
+     * @throws MessagingException if a problem occurs while computing the message size
+     */
+    @Override
+    public long getMessageSize() throws MessagingException {
+        return MimeMessageUtil.getMessageSize(message);
+    }
+
+    /**
+     * Set the error message associated with this MailImpl.
+     *
+     * @param msg the new error message associated with this MailImpl
+     */
+    @Override
+    public void setErrorMessage(String msg) {
+        this.errorMessage = msg;
+    }
+
+    /**
+     * Set the MimeMessage associated with this MailImpl.
+     *
+     * @param message the new MimeMessage associated with this MailImpl
+     */
+    @Override
+    public void setMessage(MimeMessage message) {
+
+        // TODO: We should use the MimeMessageCopyOnWriteProxy
+        // everytime we set the MimeMessage. We should
+        // investigate if we should wrap it here
+
+        if (this.message != message) {
+            // If a setMessage is called on a Mail that already have a message
+            // (discouraged) we have to make sure that the message we remove is
+            // correctly unreferenced and disposed, otherwise it will keep locks
+            if (this.message != null) {
+                LifecycleUtil.dispose(this.message);
+            }
+            this.message = message;
+        }
+    }
+
+    /**
+     * Set the recipients for this MailImpl.
+     *
+     * @param recipients the recipients for this MailImpl
+     */
+    @Override
+    public void setRecipients(Collection<MailAddress> recipients) {
+        this.recipients = recipients;
+    }
+
+    /**
+     * Set the sender of this MailImpl.
+     *
+     * @param sender the sender of this MailImpl
+     */
+    public void setSender(MailAddress sender) {
+        this.sender = sender;
+    }
+
+    /**
+     * Set the state of this MailImpl.
+     *
+     * @param state the state of this MailImpl
+     */
+    public void setState(String state) {
+        this.state = state;
+    }
+
+    /**
+     * Set the remote address associated with this MailImpl.
+     *
+     * @param remoteHost the new remote host associated with this MailImpl
+     */
+    public void setRemoteHost(String remoteHost) {
+        this.remoteHost = remoteHost;
+    }
+
+    /**
+     * Set the remote address associated with this MailImpl.
+     *
+     * @param remoteAddr the new remote address associated with this MailImpl
+     */
+    public void setRemoteAddr(String remoteAddr) {
+        this.remoteAddr = remoteAddr;
+    }
+
+    /**
+     * Set the date this mail was last updated.
+     *
+     * @param lastUpdated the date the mail was last updated
+     */
+    public void setLastUpdated(Date lastUpdated) {
+        // Make a defensive copy to ensure that the date
+        // doesn't get changed external to the class
+        if (lastUpdated != null) {
+            lastUpdated = new Date(lastUpdated.getTime());
+        }
+        this.lastUpdated = lastUpdated;
+    }
+
+    /**
+     * Writes the message out to an OutputStream.
+     *
+     * @param out the OutputStream to which to write the content
+     * @throws MessagingException if the MimeMessage is not set for this MailImpl
+     * @throws IOException        if an error occurs while reading or writing from the stream
+     */
+    public void writeMessageTo(OutputStream out) throws IOException, MessagingException {
+        if (message != null) {
+            message.writeTo(out);
+        } else {
+            throw new MessagingException("No message set for this MailImpl.");
+        }
+    }
+
+    // Serializable Methods
+    // TODO: These need some work. Currently very tightly coupled to
+    // the internal representation.
+
+    /**
+     * Read the MailImpl from an <code>ObjectInputStream</code>.
+     *
+     * @param in the ObjectInputStream from which the object is read
+     * @throws IOException            if an error occurs while reading from the stream
+     * @throws ClassNotFoundException ?
+     * @throws ClassCastException     if the serialized objects are not of the appropriate type
+     */
+    @SuppressWarnings("unchecked")
+    private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException {
+        try {
+            Object obj = in.readObject();
+            if (obj == null) {
+                sender = null;
+            } else if (obj instanceof String) {
+                sender = new MailAddress((String) obj);
+            } else if (obj instanceof MailAddress) {
+                sender = (MailAddress) obj;
+            }
+        } catch (ParseException pe) {
+            throw new IOException("Error parsing sender address: " + pe.getMessage());
+        }
+        recipients = (Collection<MailAddress>) in.readObject();
+        state = (String) in.readObject();
+        errorMessage = (String) in.readObject();
+        name = (String) in.readObject();
+        remoteHost = (String) in.readObject();
+        remoteAddr = (String) in.readObject();
+        setLastUpdated((Date) in.readObject());
+        // the following is under try/catch to be backwards compatible
+        // with messages created with James version <= 2.2.0a8
+        try {
+            attributes = (HashMap<String, Object>) in.readObject();
+        } catch (OptionalDataException ode) {
+            if (ode.eof) {
+                attributes = new HashMap<>();
+            } else {
+                throw ode;
+            }
+        }
+    }
+
+    /**
+     * Write the MailImpl to an <code>ObjectOutputStream</code>.
+     *
+     * @param out the ObjectOutputStream to which the object is written
+     * @throws IOException if an error occurs while writing to the stream
+     */
+    private void writeObject(java.io.ObjectOutputStream out) throws IOException {
+        out.writeObject(sender);
+        out.writeObject(recipients);
+        out.writeObject(state);
+        out.writeObject(errorMessage);
+        out.writeObject(name);
+        out.writeObject(remoteHost);
+        out.writeObject(remoteAddr);
+        out.writeObject(lastUpdated);
+        out.writeObject(attributes);
+    }
+
+    @Override
+    public void dispose() {
+        LifecycleUtil.dispose(message);
+        message = null;
+    }
+
+    /**
+     * <p>
+     * This method is necessary, when Mail repositories needs to deal explicitly
+     * with storing Mail attributes as a Serializable
+     * </p>
+     * <p>
+     * <strong>Note</strong>: This method is not exposed in the Mail interface,
+     * it is for internal use by James only.
+     * </p>
+     *
+     * @return Serializable of the entire attributes collection
+     * @since 2.2.0
+     */
+    public Map<String, Object> getAttributesRaw() {
+        return attributes;
+    }
+
+    /**
+     * <p>
+     * This method is necessary, when Mail repositories needs to deal explicitly
+     * with retriving Mail attributes as a Serializable
+     * </p>
+     * <p>
+     * <strong>Note</strong>: This method is not exposed in the Mail interface,
+     * it is for internal use by James only.
+     * </p>
+     *
+     * @param attr Serializable of the entire attributes collection
+     * @since 2.2.0
+     */
+    public void setAttributesRaw(HashMap<String, Object> attr) {
+        this.attributes = (attr == null) ? new HashMap<>() : attr;
+    }
+
+    @Override
+    public Serializable getAttribute(String key) {
+        return (Serializable) attributes.get(key);
+    }
+
+    @Override
+    public Serializable setAttribute(String key, Serializable object) {
+        return (Serializable) attributes.put(key, object);
+    }
+
+    @Override
+    public Serializable removeAttribute(String key) {
+        return (Serializable) attributes.remove(key);
+    }
+
+    @Override
+    public void removeAllAttributes() {
+        attributes.clear();
+    }
+
+    @Override
+    public Iterator<String> getAttributeNames() {
+        return attributes.keySet().iterator();
+    }
+
+    @Override
+    public boolean hasAttributes() {
+        return !attributes.isEmpty();
+    }
+
+    /**
+     * This methods provide cloning for serializable objects. Mail Attributes
+     * are Serializable but not Clonable so we need a deep copy
+     *
+     * @param o Object to be cloned
+     * @return the cloned Object
+     * @throws IOException
+     * @throws ClassNotFoundException
+     */
+    private static Object cloneSerializableObject(Object o) throws IOException, ClassNotFoundException {
+        ByteArrayOutputStream b = new ByteArrayOutputStream();
+        ObjectOutputStream out = new ObjectOutputStream(b);
+        out.writeObject(o);
+        out.flush();
+        out.close();
+        ByteArrayInputStream bi = new ByteArrayInputStream(b.toByteArray());
+        ObjectInputStream in = new ObjectInputStream(bi);
+        return in.readObject();
+    }
+
+    private static final java.util.Random random = new java.util.Random(); // Used
+    // to
+    // generate
+    // new
+    // mail
+    // names
+
+    /**
+     * Create a unique new primary key name for the given MailObject.
+     *
+     * @param mail the mail to use as the basis for the new mail name
+     * @return a new name
+     */
+    public static String newName(Mail mail) throws MessagingException {
+        String oldName = mail.getName();
+
+        // Checking if the original mail name is too long, perhaps because of a
+        // loop caused by a configuration error.
+        // it could cause a "null pointer exception" in AvalonMailRepository
+        // much
+        // harder to understand.
+        if (oldName.length() > 76) {
+            int count = 0;
+            int index = 0;
+            while ((index = oldName.indexOf('!', index + 1)) >= 0) {
+                count++;
+            }
+            // It looks like a configuration loop. It's better to stop.
+            if (count > 7) {
+                throw new MessagingException("Unable to create a new message name: too long." + " Possible loop in config.xml.");
+            } else {
+                oldName = oldName.substring(0, 76);
+            }
+        }
+
+        return oldName + "-!" + random.nextInt(1048576);
+    }
+
+    /**
+     * Generate a new identifier/name for a mail being processed by this server.
+     *
+     * @return the new identifier
+     */
+    public static String getId() {
+        return "Mail" + System.currentTimeMillis() + "-" + UUID.randomUUID();
+    }
+
+    @Override
+    public PerRecipientHeaders getPerRecipientSpecificHeaders() {
+        return perRecipientSpecificHeaders;
+    }
+
+    @Override
+    public void addSpecificHeaderForRecipient(Header header, MailAddress recipient) {
+        perRecipientSpecificHeaders.addHeaderForRecipient(header, recipient);
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/main/java/org/apache/james/server/core/MimeMessageCopyOnWriteProxy.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/main/java/org/apache/james/server/core/MimeMessageCopyOnWriteProxy.java b/server/container/core/src/main/java/org/apache/james/server/core/MimeMessageCopyOnWriteProxy.java
new file mode 100644
index 0000000..53483eb
--- /dev/null
+++ b/server/container/core/src/main/java/org/apache/james/server/core/MimeMessageCopyOnWriteProxy.java
@@ -0,0 +1,561 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.server.core;
+
+import javax.activation.DataHandler;
+import javax.mail.Address;
+import javax.mail.Flags;
+import javax.mail.Folder;
+import javax.mail.Message;
+import javax.mail.MessagingException;
+import javax.mail.Multipart;
+import javax.mail.Session;
+import javax.mail.Flags.Flag;
+import javax.mail.internet.MimeMessage;
+import javax.mail.search.SearchTerm;
+
+import org.apache.james.lifecycle.api.Disposable;
+import org.apache.james.lifecycle.api.LifecycleUtil;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Date;
+import java.util.Enumeration;
+
+/**
+ * This object wraps a "possibly shared" MimeMessage tracking copies and
+ * automatically cloning it (if shared) when a write operation is invoked.
+ */
+public class MimeMessageCopyOnWriteProxy extends MimeMessage implements Disposable {
+
+    /**
+     * Used internally to track the reference count It is important that this is
+     * static otherwise it will keep a reference to the parent object.
+     */
+    protected static class MessageReferenceTracker {
+
+        /**
+         * reference counter
+         */
+        private int referenceCount = 1;
+
+        /**
+         * The mime message in memory
+         */
+        private MimeMessage wrapped = null;
+
+        public MessageReferenceTracker(MimeMessage ref) {
+            wrapped = ref;
+        }
+
+        protected synchronized void incrementReferenceCount() {
+            referenceCount++;
+        }
+
+        protected synchronized void decrementReferenceCount() {
+            referenceCount--;
+            if (referenceCount <= 0) {
+                LifecycleUtil.dispose(wrapped);
+                wrapped = null;
+            }
+        }
+
+        protected synchronized int getReferenceCount() {
+            return referenceCount;
+        }
+
+        public synchronized MimeMessage getWrapped() {
+            return wrapped;
+        }
+
+    }
+
+    protected MessageReferenceTracker refCount;
+
+    public MimeMessageCopyOnWriteProxy(MimeMessage original) {
+        this(original, false);
+    }
+
+    public MimeMessageCopyOnWriteProxy(MimeMessageSource original) throws MessagingException {
+        this(new MimeMessageWrapper(original), true);
+    }
+
+    /**
+     * Private constructor providing an external reference counter.
+     */
+    private MimeMessageCopyOnWriteProxy(MimeMessage original, boolean writeable) {
+        super(Session.getDefaultInstance(System.getProperties(), null));
+
+        if (original instanceof MimeMessageCopyOnWriteProxy) {
+            refCount = ((MimeMessageCopyOnWriteProxy) original).refCount;
+        } else {
+            refCount = new MessageReferenceTracker(original);
+        }
+
+        if (!writeable) {
+            refCount.incrementReferenceCount();
+        }
+    }
+
+    /**
+     * Check the number of references over the MimeMessage and clone it if
+     * needed before returning the reference
+     * 
+     * @throws MessagingException
+     *             exception
+     */
+    protected synchronized MimeMessage getWrappedMessageForWriting() throws MessagingException {
+        if (refCount.getReferenceCount() > 1) {
+            refCount.decrementReferenceCount();
+            refCount = new MessageReferenceTracker(new MimeMessageWrapper(refCount.getWrapped()));
+        }
+        return refCount.getWrapped();
+    }
+
+    /**
+     * Return wrapped mimeMessage
+     * 
+     * @return wrapped return the wrapped mimeMessage
+     */
+    public synchronized MimeMessage getWrappedMessage() {
+        return refCount.getWrapped();
+    }
+
+    @Override
+    public synchronized void dispose() {
+        if (refCount != null) {
+            refCount.decrementReferenceCount();
+            refCount = null;
+        }
+    }
+
+    @Override
+    public void writeTo(OutputStream os) throws IOException, MessagingException {
+        getWrappedMessage().writeTo(os);
+    }
+
+    /**
+     * Rewritten for optimization purposes
+     */
+    @Override
+    public void writeTo(OutputStream os, String[] ignoreList) throws IOException, MessagingException {
+        getWrappedMessage().writeTo(os, ignoreList);
+    }
+
+    /*
+     * Various reader methods
+     */
+
+    @Override
+    public Address[] getFrom() throws MessagingException {
+        return getWrappedMessage().getFrom();
+    }
+
+    @Override
+    public Address[] getRecipients(Message.RecipientType type) throws MessagingException {
+        return getWrappedMessage().getRecipients(type);
+    }
+
+    @Override
+    public Address[] getAllRecipients() throws MessagingException {
+        return getWrappedMessage().getAllRecipients();
+    }
+
+    @Override
+    public Address[] getReplyTo() throws MessagingException {
+        return getWrappedMessage().getReplyTo();
+    }
+
+    @Override
+    public String getSubject() throws MessagingException {
+        return getWrappedMessage().getSubject();
+    }
+
+    @Override
+    public Date getSentDate() throws MessagingException {
+        return getWrappedMessage().getSentDate();
+    }
+
+    @Override
+    public Date getReceivedDate() throws MessagingException {
+        return getWrappedMessage().getReceivedDate();
+    }
+
+    @Override
+    public int getSize() throws MessagingException {
+        return getWrappedMessage().getSize();
+    }
+
+    @Override
+    public int getLineCount() throws MessagingException {
+        return getWrappedMessage().getLineCount();
+    }
+
+    @Override
+    public String getContentType() throws MessagingException {
+        return getWrappedMessage().getContentType();
+    }
+
+    @Override
+    public boolean isMimeType(String mimeType) throws MessagingException {
+        return getWrappedMessage().isMimeType(mimeType);
+    }
+
+    @Override
+    public String getDisposition() throws MessagingException {
+        return getWrappedMessage().getDisposition();
+    }
+
+    @Override
+    public String getEncoding() throws MessagingException {
+        return getWrappedMessage().getEncoding();
+    }
+
+    @Override
+    public String getContentID() throws MessagingException {
+        return getWrappedMessage().getContentID();
+    }
+
+    @Override
+    public String getContentMD5() throws MessagingException {
+        return getWrappedMessage().getContentMD5();
+    }
+
+    @Override
+    public String getDescription() throws MessagingException {
+        return getWrappedMessage().getDescription();
+    }
+
+    @Override
+    public String[] getContentLanguage() throws MessagingException {
+        return getWrappedMessage().getContentLanguage();
+    }
+
+    @Override
+    public String getMessageID() throws MessagingException {
+        return getWrappedMessage().getMessageID();
+    }
+
+    @Override
+    public String getFileName() throws MessagingException {
+        return getWrappedMessage().getFileName();
+    }
+
+    @Override
+    public InputStream getInputStream() throws IOException, MessagingException {
+        return getWrappedMessage().getInputStream();
+    }
+
+    @Override
+    public DataHandler getDataHandler() throws MessagingException {
+        return getWrappedMessage().getDataHandler();
+    }
+
+    @Override
+    public Object getContent() throws IOException, MessagingException {
+        return getWrappedMessage().getContent();
+    }
+
+    @Override
+    public String[] getHeader(String name) throws MessagingException {
+        return getWrappedMessage().getHeader(name);
+    }
+
+    @Override
+    public String getHeader(String name, String delimiter) throws MessagingException {
+        return getWrappedMessage().getHeader(name, delimiter);
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public Enumeration<String> getAllHeaders() throws MessagingException {
+        return getWrappedMessage().getAllHeaders();
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public Enumeration<String> getMatchingHeaders(String[] names) throws MessagingException {
+        return getWrappedMessage().getMatchingHeaders(names);
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public Enumeration<String> getNonMatchingHeaders(String[] names) throws MessagingException {
+        return getWrappedMessage().getNonMatchingHeaders(names);
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public Enumeration<String> getAllHeaderLines() throws MessagingException {
+        return getWrappedMessage().getAllHeaderLines();
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public Enumeration<String> getMatchingHeaderLines(String[] names) throws MessagingException {
+        return getWrappedMessage().getMatchingHeaderLines(names);
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public Enumeration<String> getNonMatchingHeaderLines(String[] names) throws MessagingException {
+        return getWrappedMessage().getNonMatchingHeaderLines(names);
+    }
+
+    @Override
+    public Flags getFlags() throws MessagingException {
+        return getWrappedMessage().getFlags();
+    }
+
+    @Override
+    public boolean isSet(Flags.Flag flag) throws MessagingException {
+        return getWrappedMessage().isSet(flag);
+    }
+
+    @Override
+    public Address getSender() throws MessagingException {
+        return getWrappedMessage().getSender();
+    }
+
+    @Override
+    public boolean match(SearchTerm arg0) throws MessagingException {
+        return getWrappedMessage().match(arg0);
+    }
+
+    @Override
+    public InputStream getRawInputStream() throws MessagingException {
+        return getWrappedMessage().getRawInputStream();
+    }
+
+    @Override
+    public Folder getFolder() {
+        return getWrappedMessage().getFolder();
+    }
+
+    @Override
+    public int getMessageNumber() {
+        return getWrappedMessage().getMessageNumber();
+    }
+
+    @Override
+    public boolean isExpunged() {
+        return getWrappedMessage().isExpunged();
+    }
+
+    @Override
+    public boolean equals(Object arg0) {
+        return getWrappedMessage().equals(arg0);
+    }
+
+    @Override
+    public int hashCode() {
+        return getWrappedMessage().hashCode();
+    }
+
+    @Override
+    public String toString() {
+        return getWrappedMessage().toString();
+    }
+
+    @Override
+    public void setFrom(Address address) throws MessagingException {
+        getWrappedMessageForWriting().setFrom(address);
+    }
+
+    @Override
+    public void setFrom() throws MessagingException {
+        getWrappedMessageForWriting().setFrom();
+    }
+
+    @Override
+    public void addFrom(Address[] addresses) throws MessagingException {
+        getWrappedMessageForWriting().addFrom(addresses);
+    }
+
+    @Override
+    public void setRecipients(Message.RecipientType type, Address[] addresses) throws MessagingException {
+        getWrappedMessageForWriting().setRecipients(type, addresses);
+    }
+
+    @Override
+    public void addRecipients(Message.RecipientType type, Address[] addresses) throws MessagingException {
+        getWrappedMessageForWriting().addRecipients(type, addresses);
+    }
+
+    @Override
+    public void setReplyTo(Address[] addresses) throws MessagingException {
+        getWrappedMessageForWriting().setReplyTo(addresses);
+    }
+
+    @Override
+    public void setSubject(String subject) throws MessagingException {
+        getWrappedMessageForWriting().setSubject(subject);
+    }
+
+    @Override
+    public void setSubject(String subject, String charset) throws MessagingException {
+        getWrappedMessageForWriting().setSubject(subject, charset);
+    }
+
+    @Override
+    public void setSentDate(Date d) throws MessagingException {
+        getWrappedMessageForWriting().setSentDate(d);
+    }
+
+    @Override
+    public void setDisposition(String disposition) throws MessagingException {
+        getWrappedMessageForWriting().setDisposition(disposition);
+    }
+
+    @Override
+    public void setContentID(String cid) throws MessagingException {
+        getWrappedMessageForWriting().setContentID(cid);
+    }
+
+    @Override
+    public void setContentMD5(String md5) throws MessagingException {
+        getWrappedMessageForWriting().setContentMD5(md5);
+    }
+
+    @Override
+    public void setDescription(String description) throws MessagingException {
+        getWrappedMessageForWriting().setDescription(description);
+    }
+
+    @Override
+    public void setDescription(String description, String charset) throws MessagingException {
+        getWrappedMessageForWriting().setDescription(description, charset);
+    }
+
+    @Override
+    public void setContentLanguage(String[] languages) throws MessagingException {
+        getWrappedMessageForWriting().setContentLanguage(languages);
+    }
+
+    @Override
+    public void setFileName(String filename) throws MessagingException {
+        getWrappedMessageForWriting().setFileName(filename);
+    }
+
+    @Override
+    public void setDataHandler(DataHandler dh) throws MessagingException {
+        getWrappedMessageForWriting().setDataHandler(dh);
+    }
+
+    @Override
+    public void setContent(Object o, String type) throws MessagingException {
+        getWrappedMessageForWriting().setContent(o, type);
+    }
+
+    @Override
+    public void setText(String text) throws MessagingException {
+        getWrappedMessageForWriting().setText(text);
+    }
+
+    @Override
+    public void setText(String text, String charset) throws MessagingException {
+        getWrappedMessageForWriting().setText(text, charset);
+    }
+
+    @Override
+    public void setContent(Multipart mp) throws MessagingException {
+        getWrappedMessageForWriting().setContent(mp);
+    }
+
+    /**
+     * This does not need a writable message
+     */
+    @Override
+    public Message reply(boolean replyToAll) throws MessagingException {
+        return getWrappedMessage().reply(replyToAll);
+    }
+
+    @Override
+    public void setHeader(String name, String value) throws MessagingException {
+        getWrappedMessageForWriting().setHeader(name, value);
+    }
+
+    @Override
+    public void addHeader(String name, String value) throws MessagingException {
+        getWrappedMessageForWriting().addHeader(name, value);
+    }
+
+    @Override
+    public void removeHeader(String name) throws MessagingException {
+        getWrappedMessageForWriting().removeHeader(name);
+    }
+
+    @Override
+    public void addHeaderLine(String line) throws MessagingException {
+        getWrappedMessageForWriting().addHeaderLine(line);
+    }
+
+    @Override
+    public void setFlags(Flags flag, boolean set) throws MessagingException {
+        getWrappedMessageForWriting().setFlags(flag, set);
+    }
+
+    @Override
+    public void saveChanges() throws MessagingException {
+        getWrappedMessageForWriting().saveChanges();
+    }
+
+    /*
+     * Since JavaMail 1.2
+     */
+
+    @Override
+    public void addRecipients(Message.RecipientType type, String addresses) throws MessagingException {
+        getWrappedMessageForWriting().addRecipients(type, addresses);
+    }
+
+    @Override
+    public void setRecipients(Message.RecipientType type, String addresses) throws MessagingException {
+        getWrappedMessageForWriting().setRecipients(type, addresses);
+    }
+
+    @Override
+    public void setSender(Address arg0) throws MessagingException {
+        getWrappedMessageForWriting().setSender(arg0);
+    }
+
+    public void addRecipient(RecipientType arg0, Address arg1) throws MessagingException {
+        getWrappedMessageForWriting().addRecipient(arg0, arg1);
+    }
+
+    @Override
+    public void setFlag(Flag arg0, boolean arg1) throws MessagingException {
+        getWrappedMessageForWriting().setFlag(arg0, arg1);
+    }
+
+    public long getMessageSize() throws MessagingException {
+        return MimeMessageUtil.getMessageSize(getWrappedMessage());
+    }
+
+    /**
+     * Since javamail 1.4
+     */
+    @Override
+    public void setText(String text, String charset, String subtype) throws MessagingException {
+        getWrappedMessage().setText(text, charset, subtype);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/main/java/org/apache/james/server/core/MimeMessageInputStream.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/main/java/org/apache/james/server/core/MimeMessageInputStream.java b/server/container/core/src/main/java/org/apache/james/server/core/MimeMessageInputStream.java
new file mode 100644
index 0000000..c3e27d4
--- /dev/null
+++ b/server/container/core/src/main/java/org/apache/james/server/core/MimeMessageInputStream.java
@@ -0,0 +1,127 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.server.core;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.mail.MessagingException;
+import javax.mail.internet.MimeMessage;
+
+/**
+ * Provide an {@link InputStream} over an {@link MimeMessage}
+ */
+public class MimeMessageInputStream extends InputStream {
+    private final InputStream in;
+
+    /**
+     * Provide an {@link InputStream} over a {@link MimeMessage}.
+     * 
+     * @param message
+     *            the message to wrap
+     * @param tryCast
+     *            try to cast the {@link MimeMessage} to
+     *            {@link MimeMessageCopyOnWriteProxy} /
+     *            {@link MimeMessageWrapper} to do some optimized processing if
+     *            possible
+     * @throws MessagingException
+     */
+    public MimeMessageInputStream(MimeMessage message, boolean tryCast) throws MessagingException {
+        MimeMessage m = message;
+
+        // check if we need to use the wrapped message
+        if (tryCast && m instanceof MimeMessageCopyOnWriteProxy) {
+            m = ((MimeMessageCopyOnWriteProxy) m).getWrappedMessage();
+        }
+
+        // check if we can use optimized operations
+        if (tryCast && m instanceof MimeMessageWrapper) {
+            in = ((MimeMessageWrapper) m).getMessageInputStream();
+        } else {
+
+            ByteArrayOutputStream out = new ByteArrayOutputStream();
+            try {
+                message.writeTo(out);
+                in = new ByteArrayInputStream(out.toByteArray());
+            } catch (IOException e1) {
+                throw new MessagingException("Unable to read message " + message, e1);
+            }
+
+        }
+
+    }
+
+    /**
+     * Use true as tryCast parameter
+     * 
+     * {@link #MimeMessageInputStream(MimeMessage, boolean)}
+     */
+    public MimeMessageInputStream(MimeMessage message) throws MessagingException {
+        this(message, true);
+    }
+
+    @Override
+    public int read() throws IOException {
+        return in.read();
+    }
+
+    @Override
+    public void close() throws IOException {
+        in.close();
+    }
+
+    @Override
+    public int available() throws IOException {
+        return in.available();
+    }
+
+    @Override
+    public void mark(int readlimit) {
+        in.mark(readlimit);
+    }
+
+    @Override
+    public boolean markSupported() {
+        return in.markSupported();
+    }
+
+    @Override
+    public int read(byte[] b, int off, int len) throws IOException {
+        return in.read(b, off, len);
+    }
+
+    @Override
+    public int read(byte[] b) throws IOException {
+        return in.read(b);
+    }
+
+    @Override
+    public void reset() throws IOException {
+        in.reset();
+    }
+
+    @Override
+    public long skip(long n) throws IOException {
+        return in.skip(n);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/main/java/org/apache/james/server/core/MimeMessageInputStreamSource.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/main/java/org/apache/james/server/core/MimeMessageInputStreamSource.java b/server/container/core/src/main/java/org/apache/james/server/core/MimeMessageInputStreamSource.java
new file mode 100644
index 0000000..0eea1de
--- /dev/null
+++ b/server/container/core/src/main/java/org/apache/james/server/core/MimeMessageInputStreamSource.java
@@ -0,0 +1,174 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.server.core;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.mail.MessagingException;
+import javax.mail.util.SharedByteArrayInputStream;
+import javax.mail.util.SharedFileInputStream;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.io.output.DeferredFileOutputStream;
+import org.apache.james.lifecycle.api.Disposable;
+
+/**
+ * Takes an input stream and creates a repeatable input stream source for a
+ * MimeMessageWrapper. It does this by completely reading the input stream and
+ * saving that to data to an {@link DeferredFileOutputStream} with its threshold set to 100kb
+ */
+public class MimeMessageInputStreamSource extends MimeMessageSource implements Disposable {
+
+    private final List<InputStream> streams = new ArrayList<>();
+
+    /**
+     * A temporary file used to hold the message stream
+     */
+    private DeferredFileOutputStream out;
+
+    /**
+     * The full path of the temporary file
+     */
+    private final String sourceId;
+
+    /**
+     * 100kb threshold for the stream.
+     */
+    private final static int THRESHOLD = 1024 * 100;
+
+    /**
+     * Temporary directory to use
+     */
+    private final static File TMPDIR = new File(System.getProperty("java.io.tmpdir"));
+
+    /**
+     * Construct a new MimeMessageInputStreamSource from an
+     * <code>InputStream</code> that contains the bytes of a MimeMessage.
+     *
+     * @param key the prefix for the name of the temp file
+     * @param in  the stream containing the MimeMessage
+     * @throws MessagingException if an error occurs while trying to store the stream
+     */
+    public MimeMessageInputStreamSource(String key, InputStream in) throws MessagingException {
+        super();
+        // We want to immediately read this into a temporary file
+        // Create a temp file and channel the input stream into it
+        try {
+            out = new DeferredFileOutputStream(THRESHOLD, "mimemessage-" + key, ".m64", TMPDIR);
+            IOUtils.copy(in, out);
+            sourceId = key;
+        } catch (IOException ioe) {
+            File file = out.getFile();
+            if (file != null) {
+                FileUtils.deleteQuietly(file);
+            }
+            throw new MessagingException("Unable to retrieve the data: " + ioe.getMessage(), ioe);
+        } finally {
+            try {
+                if (out != null) {
+                    out.close();
+                }
+            } catch (IOException ioe) {
+                // Ignored - logging unavailable to log this non-fatal error.
+            }
+
+            try {
+                if (in != null) {
+                    in.close();
+                }
+            } catch (IOException ioe) {
+                // Ignored - logging unavailable to log this non-fatal error.
+            }
+
+        }
+    }
+
+    public MimeMessageInputStreamSource(String key) {
+        super();
+        out = new DeferredFileOutputStream(THRESHOLD, key, ".m64", TMPDIR);
+        sourceId = key;
+    }
+
+    /**
+     * Returns the unique identifier of this input stream source
+     *
+     * @return the unique identifier for this MimeMessageInputStreamSource
+     */
+    public String getSourceId() {
+        return sourceId;
+    }
+
+    /**
+     * Get an input stream to retrieve the data stored in the temporary file
+     *
+     * @return a <code>BufferedInputStream</code> containing the data
+     */
+    public synchronized InputStream getInputStream() throws IOException {
+        InputStream in;
+        if (out.isInMemory()) {
+            in = new SharedByteArrayInputStream(out.getData());
+        } else {
+            in = new SharedFileInputStream(out.getFile());
+        }
+        streams.add(in);
+        return in;
+    }
+
+    /**
+     * Get the size of the temp file
+     *
+     * @return the size of the temp file
+     * @throws IOException if an error is encoutered while computing the size of the
+     *                     message
+     */
+    @Override
+    public long getMessageSize() throws IOException {
+        return out.getByteCount();
+    }
+
+    public OutputStream getWritableOutputStream() {
+        return out;
+    }
+
+    @Override
+    public void dispose() {
+        // explicit close all streams
+        for (InputStream stream : streams) {
+            IOUtils.closeQuietly(stream);
+        }
+
+        if (out != null) {
+            IOUtils.closeQuietly(out);
+            File file = out.getFile();
+            if (file != null) {
+                FileUtils.deleteQuietly(file);
+                file = null;
+            }
+            out = null;
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/main/java/org/apache/james/server/core/MimeMessageSource.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/main/java/org/apache/james/server/core/MimeMessageSource.java b/server/container/core/src/main/java/org/apache/james/server/core/MimeMessageSource.java
new file mode 100644
index 0000000..d5375a1
--- /dev/null
+++ b/server/container/core/src/main/java/org/apache/james/server/core/MimeMessageSource.java
@@ -0,0 +1,84 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.server.core;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * This defines a reusable datasource that can supply an input stream with
+ * MimeMessage data. This allows a MimeMessageWrapper or other classes to grab
+ * the underlying data.
+ * 
+ * @see MimeMessageWrapper
+ */
+public abstract class MimeMessageSource {
+
+    /**
+     * Returns a unique String ID that represents the location from where this
+     * file is loaded. This will be used to identify where the data is,
+     * primarily to avoid situations where this data would get overwritten.
+     * 
+     * @return the String ID
+     */
+    public abstract String getSourceId();
+
+    /**
+     * Get an input stream to retrieve the data stored in the datasource
+     * 
+     * @return a <code>InputStream</code> containing the data
+     * 
+     * @throws IOException
+     *             if an error occurs while generating the InputStream
+     */
+    public abstract InputStream getInputStream() throws IOException;
+
+    /**
+     * Return the size of all the data. Default implementation... others can
+     * override to do this much faster
+     * 
+     * @return the size of the data represented by this source
+     * @throws IOException
+     *             if an error is encountered while computing the message size
+     */
+    public long getMessageSize() throws IOException {
+        int size = 0;
+        InputStream in = null;
+        try {
+            in = getInputStream();
+            int read;
+            byte[] data = new byte[1024];
+            while ((read = in.read(data)) > 0) {
+                size += read;
+            }
+        } finally {
+            try {
+                if (in != null) {
+                    in.close();
+                }
+            } catch (IOException ioe) {
+                // Exception ignored because logging is
+                // unavailable
+            }
+        }
+        return size;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/main/java/org/apache/james/server/core/MimeMessageUtil.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/main/java/org/apache/james/server/core/MimeMessageUtil.java b/server/container/core/src/main/java/org/apache/james/server/core/MimeMessageUtil.java
new file mode 100644
index 0000000..698ad5d
--- /dev/null
+++ b/server/container/core/src/main/java/org/apache/james/server/core/MimeMessageUtil.java
@@ -0,0 +1,311 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.server.core;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Enumeration;
+
+import javax.activation.UnsupportedDataTypeException;
+import javax.mail.MessagingException;
+import javax.mail.internet.MimeMessage;
+import javax.mail.internet.MimeUtility;
+
+import org.apache.commons.io.IOUtils;
+
+/**
+ * Utility class to provide optimized write methods for the various MimeMessage
+ * implementations.
+ */
+public class MimeMessageUtil {
+
+    /**
+     * Convenience method to take any MimeMessage and write the headers and body
+     * to two different output streams
+     * 
+     * @param message
+     *            the MimeMessage reading from
+     * @param headerOs
+     *            the OutputStream writting the headers to
+     * @param bodyOs
+     *            the OutputStream writting the body to
+     * @throws IOException
+     *             get thrown if an IO Error detected while writing to the
+     *             streams
+     * @throws MessagingException
+     *             get thrown if an error detected while reading the message
+     */
+    public static void writeTo(MimeMessage message, OutputStream headerOs, OutputStream bodyOs) throws IOException, MessagingException {
+        writeTo(message, headerOs, bodyOs, null);
+    }
+
+    /**
+     * Convenience method to take any MimeMessage and write the headers and body
+     * to two different output streams, with an ignore list
+     * 
+     * @param message
+     *            the MimeMessage reading from
+     * @param headerOs
+     *            the OutputStream writting the headers to
+     * @param bodyOs
+     *            the OutputStream writting the body to
+     * @param ignoreList
+     *            the String[] which contains headers which should be ignored
+     * @throws IOException
+     *             get thrown if an IO Error detected while writing to the
+     *             streams
+     * @throws MessagingException
+     *             get thrown if an error detected while reading the message
+     */
+    public static void writeTo(MimeMessage message, OutputStream headerOs, OutputStream bodyOs, String[] ignoreList) throws IOException, MessagingException {
+        MimeMessage testMessage = message;
+        if (message instanceof MimeMessageCopyOnWriteProxy) {
+            MimeMessageCopyOnWriteProxy wr = (MimeMessageCopyOnWriteProxy) message;
+            testMessage = wr.getWrappedMessage();
+        }
+        if (testMessage instanceof MimeMessageWrapper) {
+            MimeMessageWrapper wrapper = (MimeMessageWrapper) testMessage;
+            if (!wrapper.isModified()) {
+                wrapper.writeTo(headerOs, bodyOs, ignoreList);
+                return;
+            }
+        }
+        writeToInternal(message, headerOs, bodyOs, ignoreList);
+    }
+
+    /**
+     * 
+     * @param message
+     * @param headerOs
+     * @param bodyOs
+     * @param ignoreList
+     * @throws MessagingException
+     * @throws IOException
+     * @throws UnsupportedDataTypeException
+     */
+    public static void writeToInternal(MimeMessage message, OutputStream headerOs, OutputStream bodyOs, String[] ignoreList) throws MessagingException, IOException {
+        if (message.getMessageID() == null) {
+            message.saveChanges();
+        }
+
+        writeHeadersTo(message, headerOs, ignoreList);
+
+        // Write the body to the output stream
+        writeMessageBodyTo(message, bodyOs);
+    }
+
+    /**
+     * Write message body of given mimeessage to the given outputStream
+     * 
+     * @param message
+     *            the MimeMessage used as input
+     * @param bodyOs
+     *            the OutputStream to write the message body to
+     * @throws IOException
+     * @throws UnsupportedDataTypeException
+     * @throws MessagingException
+     */
+    public static void writeMessageBodyTo(MimeMessage message, OutputStream bodyOs) throws IOException, MessagingException {
+        OutputStream bos;
+        InputStream bis;
+
+        try {
+            // Get the message as a stream. This will encode
+            // objects as necessary, and we have some input from
+            // decoding an re-encoding the stream. I'd prefer the
+            // raw stream, but see
+            bos = MimeUtility.encode(bodyOs, message.getEncoding());
+            bis = message.getInputStream();
+        } catch (UnsupportedDataTypeException | MessagingException udte) {
+            /*
+             * If we get an UnsupportedDataTypeException try using the raw input
+             * stream as a "best attempt" at rendering a message.
+             * 
+             * WARNING: JavaMail v1.3 getRawInputStream() returns INVALID
+             * (unchanged) content for a changed message. getInputStream() works
+             * properly, but in this case has failed due to a missing
+             * DataHandler.
+             * 
+             * MimeMessage.getRawInputStream() may throw a "no content"
+             * MessagingException. In JavaMail v1.3, when you initially create a
+             * message using MimeMessage APIs, there is no raw content
+             * available. getInputStream() works, but getRawInputStream() throws
+             * an exception. If we catch that exception, throw the UDTE. It
+             * should mean that someone has locally constructed a message part
+             * for which JavaMail doesn't have a DataHandler.
+             */
+
+            try {
+                bis = message.getRawInputStream();
+                bos = bodyOs;
+            } catch (javax.mail.MessagingException ignored) {
+                throw udte;
+            }
+        }
+
+        try {
+            IOUtils.copy(bis, bos);
+        } finally {
+            IOUtils.closeQuietly(bis);
+        }
+    }
+
+    /**
+     * Write the message headers to the given outputstream
+     * 
+     * @param message
+     *            the MimeMessage to read from
+     * @param headerOs
+     *            the OutputStream to which the headers get written
+     * @param ignoreList
+     *            the String[] which holds headers which should be ignored
+     * @throws MessagingException
+     */
+    private static void writeHeadersTo(MimeMessage message, OutputStream headerOs, String[] ignoreList) throws MessagingException {
+        // Write the headers (minus ignored ones)
+        @SuppressWarnings("unchecked")
+        Enumeration<String> headers = message.getNonMatchingHeaderLines(ignoreList);
+        writeHeadersTo(headers, headerOs);
+    }
+
+    /**
+     * Write the message headers to the given outputstream
+     * 
+     * @param headers
+     *            the Enumeration which holds the headers
+     * @param headerOs
+     *            the OutputStream to which the headers get written
+     * @throws MessagingException
+     */
+    public static void writeHeadersTo(Enumeration<String> headers, OutputStream headerOs) throws MessagingException {
+        try {
+            IOUtils.copy(new InternetHeadersInputStream(headers), headerOs);
+        } catch (IOException e) {
+            throw new MessagingException("Unable to write headers to stream", e);
+        }
+    }
+
+    /**
+     * Get an InputStream which holds all headers of the given MimeMessage
+     * 
+     * @param message
+     *            the MimeMessage used as source
+     * @param ignoreList
+     *            the String[] which holds headers which should be ignored
+     * @return stream the InputStream which holds the headers
+     * @throws MessagingException
+     */
+    @SuppressWarnings("unchecked")
+    public static InputStream getHeadersInputStream(MimeMessage message, String[] ignoreList) throws MessagingException {
+        return new InternetHeadersInputStream(message.getNonMatchingHeaderLines(ignoreList));
+    }
+
+    /**
+     * Slow method to calculate the exact size of a message!
+     */
+    private static final class SizeCalculatorOutputStream extends OutputStream {
+        long size = 0;
+
+        public void write(int arg0) throws IOException {
+            size++;
+        }
+
+        public long getSize() {
+            return size;
+        }
+
+        public void write(byte[] arg0, int arg1, int arg2) throws IOException {
+            size += arg2;
+        }
+
+        public void write(byte[] arg0) throws IOException {
+            size += arg0.length;
+        }
+    }
+
+    /**
+     * Return the full site of an mimeMessage
+     * 
+     * @return size of full message including headers
+     * @throws MessagingException
+     *             if a problem occours while computing the message size
+     */
+    public static long getMessageSize(MimeMessage message) throws MessagingException {
+        // If we have a MimeMessageWrapper, then we can ask it for just the
+        // message size and skip calculating it
+        long size = -1;
+
+        if (message instanceof MimeMessageWrapper) {
+            MimeMessageWrapper wrapper = (MimeMessageWrapper) message;
+            size = wrapper.getMessageSize();
+        } else if (message instanceof MimeMessageCopyOnWriteProxy) {
+            MimeMessageCopyOnWriteProxy wrapper = (MimeMessageCopyOnWriteProxy) message;
+            size = wrapper.getMessageSize();
+        }
+
+        if (size == -1) {
+            size = calculateMessageSize(message);
+        }
+
+        return size;
+    }
+
+    /**
+     * Calculate the size of the give mimeMessage
+     * 
+     * @param message
+     *            the MimeMessage
+     * @return size the calculated size
+     * @throws MessagingException
+     *             if a problem occours while calculate the message size
+     */
+    public static long calculateMessageSize(MimeMessage message) throws MessagingException {
+        long size;
+        // SK: Should probably eventually store this as a locally
+        // maintained value (so we don't have to load and reparse
+        // messages each time).
+        size = message.getSize();
+        if (size != -1) {
+            Enumeration<?> e = message.getAllHeaderLines();
+            if (e.hasMoreElements()) {
+                size += 2;
+            }
+            while (e.hasMoreElements()) {
+                // add 2 bytes for the CRLF
+                size += ((String) e.nextElement()).length() + 2;
+            }
+        }
+
+        if (size == -1) {
+            SizeCalculatorOutputStream out = new SizeCalculatorOutputStream();
+            try {
+                message.writeTo(out);
+            } catch (IOException e) {
+                // should never happen as SizeCalculator does not actually throw
+                // IOExceptions.
+                throw new MessagingException("IOException wrapped by getMessageSize", e);
+            }
+            size = out.getSize();
+        }
+        return size;
+    }
+
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


[05/23] james-project git commit: JAMES-2138 split webadmin modules to avoid confusion in protocols

Posted by bt...@apache.org.
JAMES-2138 split webadmin modules to avoid confusion in protocols

 - Brings consistency in the way we define Guice modules
    - Extraction of protocols, extraction of WebAdmin
    - Generalized alphabetic order sorting of Guice modules
 - Corrects the problem of WebAdmin probe injection
 - Adds Swagger routes to JPA and Memory


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/e9cb6e90
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/e9cb6e90
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/e9cb6e90

Branch: refs/heads/master
Commit: e9cb6e908f27a2eb53156e6e03a3611d41a793af
Parents: 9b3adc1
Author: Matthieu Baechler <ma...@apache.org>
Authored: Mon Sep 4 10:55:34 2017 +0200
Committer: benwa <bt...@linagora.com>
Committed: Sat Sep 9 10:45:52 2017 +0700

----------------------------------------------------------------------
 .../smtp/host/CassandraJamesSmtpHostSystem.java |  3 +-
 .../apache/james/CassandraJamesServerMain.java  | 15 +++++----
 server/container/guice/jpa-guice/pom.xml        |  4 +++
 .../org/apache/james/JPAJamesServerMain.java    | 29 +++++++++-------
 server/container/guice/memory-guice/pom.xml     |  4 +++
 .../org/apache/james/MemoryJamesServerMain.java | 26 ++++++++++-----
 .../modules/server/SwaggerRoutesModule.java     | 35 ++++++++++++++++++++
 .../modules/server/SwaggerRoutesModules.java    | 35 --------------------
 8 files changed, 88 insertions(+), 63 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/e9cb6e90/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/host/CassandraJamesSmtpHostSystem.java
----------------------------------------------------------------------
diff --git a/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/host/CassandraJamesSmtpHostSystem.java b/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/host/CassandraJamesSmtpHostSystem.java
index 5dcb1ae..4909779 100644
--- a/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/host/CassandraJamesSmtpHostSystem.java
+++ b/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/host/CassandraJamesSmtpHostSystem.java
@@ -100,9 +100,10 @@ public class CassandraJamesSmtpHostSystem extends ExternalSessionFactory impleme
     public InMemoryDNSService getInMemoryDnsService() {
         return inMemoryDNSService;
     }
+
     protected GuiceJamesServer createJamesServer() {
         return new GuiceJamesServer()
-            .combineWith(CassandraJamesServerMain.cassandraServerModule, new SMTPServerModule(), new ProtocolHandlerModule())
+            .combineWith(CassandraJamesServerMain.cassandraServerModule, CassandraJamesServerMain.protocols, new ProtocolHandlerModule())
             .overrideWith(new CassandraJmapServerModule(folder::getRoot, embeddedElasticSearch, cassandraHost, cassandraPort),
                 (binder) -> binder.bind(DNSService.class).toInstance(inMemoryDNSService));
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/e9cb6e90/server/container/guice/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServerMain.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServerMain.java b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServerMain.java
index 5421400..fc7b762 100644
--- a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServerMain.java
+++ b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServerMain.java
@@ -43,7 +43,7 @@ import org.apache.james.modules.server.DataRoutesModules;
 import org.apache.james.modules.server.ElasticSearchMetricReporterModule;
 import org.apache.james.modules.server.JMXServerModule;
 import org.apache.james.modules.server.MailboxRoutesModule;
-import org.apache.james.modules.server.SwaggerRoutesModules;
+import org.apache.james.modules.server.SwaggerRoutesModule;
 import org.apache.james.modules.server.WebAdminServerModule;
 
 import com.google.inject.Module;
@@ -51,18 +51,22 @@ import com.google.inject.util.Modules;
 
 public class CassandraJamesServerMain {
 
-    public static final Module protocols = Modules.combine(
+    public static final Module webadmin = Modules.combine(
         new CassandraRoutesModule(),
         new DataRoutesModules(),
+        new MailboxRoutesModule(),
+        new SwaggerRoutesModule(),
+        new WebAdminServerModule());
+
+    public static final Module protocols = Modules.combine(
         new IMAPServerModule(),
         new LMTPServerModule(),
-        new MailboxRoutesModule(),
         new ManageSieveServerModule(),
         new POP3ServerModule(),
         new ProtocolHandlerModule(),
         new SMTPServerModule(),
-        new SwaggerRoutesModules(),
-        new WebAdminServerModule());
+        new JMAPServerModule(),
+        webadmin);
 
     public static final Module cassandraServerModule = Modules.combine(
         new ActiveMQQueueModule(),
@@ -76,7 +80,6 @@ public class CassandraJamesServerMain {
         new CassandraUsersRepositoryModule(),
         new ElasticSearchMailboxModule(),
         new ElasticSearchMetricReporterModule(),
-        new JMAPServerModule(),
         new MailboxModule(),
         new TikaMailboxModule());
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/e9cb6e90/server/container/guice/jpa-guice/pom.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/jpa-guice/pom.xml b/server/container/guice/jpa-guice/pom.xml
index 99e7030..7104f98 100644
--- a/server/container/guice/jpa-guice/pom.xml
+++ b/server/container/guice/jpa-guice/pom.xml
@@ -113,6 +113,10 @@
         </dependency>
         <dependency>
             <groupId>${project.groupId}</groupId>
+            <artifactId>james-server-guice-webadmin-swagger</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
             <artifactId>james-server-jpa-common-guice</artifactId>
         </dependency>
         <dependency>

http://git-wip-us.apache.org/repos/asf/james-project/blob/e9cb6e90/server/container/guice/jpa-guice/src/main/java/org/apache/james/JPAJamesServerMain.java
----------------------------------------------------------------------
diff --git a/server/container/guice/jpa-guice/src/main/java/org/apache/james/JPAJamesServerMain.java b/server/container/guice/jpa-guice/src/main/java/org/apache/james/JPAJamesServerMain.java
index c3d89f5..e4a63b2 100644
--- a/server/container/guice/jpa-guice/src/main/java/org/apache/james/JPAJamesServerMain.java
+++ b/server/container/guice/jpa-guice/src/main/java/org/apache/james/JPAJamesServerMain.java
@@ -38,6 +38,7 @@ import org.apache.james.modules.server.JMXServerModule;
 import org.apache.james.modules.server.MailboxRoutesModule;
 import org.apache.james.modules.server.NoJwtModule;
 import org.apache.james.modules.server.RawPostDequeueDecoratorModule;
+import org.apache.james.modules.server.SwaggerRoutesModule;
 import org.apache.james.modules.server.WebAdminServerModule;
 
 import com.google.inject.Module;
@@ -45,27 +46,31 @@ import com.google.inject.util.Modules;
 
 public class JPAJamesServerMain {
 
+    public static final Module webadmin = Modules.combine(
+        new WebAdminServerModule(),
+        new DataRoutesModules(),
+        new MailboxRoutesModule(),
+        new SwaggerRoutesModule());
+
     public static final Module protocols = Modules.combine(
         new IMAPServerModule(),
-        new ProtocolHandlerModule(),
-        new POP3ServerModule(),
-        new SMTPServerModule(),
         new LMTPServerModule(),
         new ManageSieveServerModule(),
-        new WebAdminServerModule(),
-        new DataRoutesModules(),
-        new MailboxRoutesModule());
+        new POP3ServerModule(),
+        new ProtocolHandlerModule(),
+        new SMTPServerModule(),
+        webadmin);
     
     public static final Module jpaServerModule = Modules.combine(
-        new JPAMailboxModule(),
-        new JPADataModule(),
-        new SieveFileRepositoryModule(),
         new ActiveMQQueueModule(),
-        new RawPostDequeueDecoratorModule(),
+        new DefaultProcessorsConfigurationProviderModule(),
+        new ElasticSearchMetricReporterModule(),
+        new JPADataModule(),
+        new JPAMailboxModule(),
         new MailboxModule(),
         new NoJwtModule(),
-        new DefaultProcessorsConfigurationProviderModule(),
-        new ElasticSearchMetricReporterModule());
+        new RawPostDequeueDecoratorModule(),
+        new SieveFileRepositoryModule());
 
     public static void main(String[] args) throws Exception {
         GuiceJamesServer server = new GuiceJamesServer()

http://git-wip-us.apache.org/repos/asf/james-project/blob/e9cb6e90/server/container/guice/memory-guice/pom.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/memory-guice/pom.xml b/server/container/guice/memory-guice/pom.xml
index 5f07851..f2df5be 100644
--- a/server/container/guice/memory-guice/pom.xml
+++ b/server/container/guice/memory-guice/pom.xml
@@ -106,6 +106,10 @@
             <artifactId>james-server-guice-webadmin-mailbox</artifactId>
         </dependency>
         <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>james-server-guice-webadmin-swagger</artifactId>
+        </dependency>
+        <dependency>
             <groupId>ch.qos.logback</groupId>
             <artifactId>logback-classic</artifactId>
             <scope>test</scope>

http://git-wip-us.apache.org/repos/asf/james-project/blob/e9cb6e90/server/container/guice/memory-guice/src/main/java/org/apache/james/MemoryJamesServerMain.java
----------------------------------------------------------------------
diff --git a/server/container/guice/memory-guice/src/main/java/org/apache/james/MemoryJamesServerMain.java b/server/container/guice/memory-guice/src/main/java/org/apache/james/MemoryJamesServerMain.java
index bfc412b..2cb650d 100644
--- a/server/container/guice/memory-guice/src/main/java/org/apache/james/MemoryJamesServerMain.java
+++ b/server/container/guice/memory-guice/src/main/java/org/apache/james/MemoryJamesServerMain.java
@@ -34,6 +34,7 @@ import org.apache.james.modules.server.DataRoutesModules;
 import org.apache.james.modules.server.JMXServerModule;
 import org.apache.james.modules.server.MailboxRoutesModule;
 import org.apache.james.modules.server.MemoryMailQueueModule;
+import org.apache.james.modules.server.SwaggerRoutesModule;
 import org.apache.james.modules.server.WebAdminServerModule;
 
 import com.google.inject.Module;
@@ -41,22 +42,29 @@ import com.google.inject.util.Modules;
 
 public class MemoryJamesServerMain {
 
-    public static final Module inMemoryServerModule = Modules.combine(
-            new JMAPServerModule(),
-            new IMAPServerModule(),
-            new ProtocolHandlerModule(),
-            new POP3ServerModule(),
-            new SMTPServerModule(),
-            new LMTPServerModule(),
-            new ManageSieveServerModule(),
+    public static final Module webadmin = Modules.combine(
             new WebAdminServerModule(),
             new DataRoutesModules(),
             new MailboxRoutesModule(),
+            new SwaggerRoutesModule());
+
+    public static final Module protocols = Modules.combine(
+            new IMAPServerModule(),
+            new JMAPServerModule(),
+            new LMTPServerModule(),
+            new ManageSieveServerModule(),
+            new POP3ServerModule(),
+            new ProtocolHandlerModule(),
+            new SMTPServerModule(),
+            webadmin);
+
+    public static final Module inMemoryServerModule = Modules.combine(
             new MemoryDataModule(),
             new MemoryDataJmapModule(),
             new MemoryMailboxModule(),
             new MemoryMailQueueModule(),
-            new MailboxModule());
+            new MailboxModule(),
+            protocols);
 
     public static void main(String[] args) throws Exception {
         new GuiceJamesServer()

http://git-wip-us.apache.org/repos/asf/james-project/blob/e9cb6e90/server/container/guice/protocols/webadmin-swagger/src/main/java/org/apache/james/modules/server/SwaggerRoutesModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/protocols/webadmin-swagger/src/main/java/org/apache/james/modules/server/SwaggerRoutesModule.java b/server/container/guice/protocols/webadmin-swagger/src/main/java/org/apache/james/modules/server/SwaggerRoutesModule.java
new file mode 100644
index 0000000..bc25611
--- /dev/null
+++ b/server/container/guice/protocols/webadmin-swagger/src/main/java/org/apache/james/modules/server/SwaggerRoutesModule.java
@@ -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.                                           *
+ ****************************************************************/
+
+package org.apache.james.modules.server;
+
+import org.apache.james.webadmin.Routes;
+import org.apache.james.webadmin.swagger.routes.SwaggerRoutes;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.multibindings.Multibinder;
+
+public class SwaggerRoutesModule extends AbstractModule {
+
+    @Override
+    protected void configure() {
+        Multibinder<Routes> routesMultibinder = Multibinder.newSetBinder(binder(), Routes.class);
+        routesMultibinder.addBinding().to(SwaggerRoutes.class);
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/e9cb6e90/server/container/guice/protocols/webadmin-swagger/src/main/java/org/apache/james/modules/server/SwaggerRoutesModules.java
----------------------------------------------------------------------
diff --git a/server/container/guice/protocols/webadmin-swagger/src/main/java/org/apache/james/modules/server/SwaggerRoutesModules.java b/server/container/guice/protocols/webadmin-swagger/src/main/java/org/apache/james/modules/server/SwaggerRoutesModules.java
deleted file mode 100644
index a633c4f..0000000
--- a/server/container/guice/protocols/webadmin-swagger/src/main/java/org/apache/james/modules/server/SwaggerRoutesModules.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-
-package org.apache.james.modules.server;
-
-import org.apache.james.webadmin.Routes;
-import org.apache.james.webadmin.swagger.routes.SwaggerRoutes;
-
-import com.google.inject.AbstractModule;
-import com.google.inject.multibindings.Multibinder;
-
-public class SwaggerRoutesModules extends AbstractModule {
-
-    @Override
-    protected void configure() {
-        Multibinder<Routes> routesMultibinder = Multibinder.newSetBinder(binder(), Routes.class);
-        routesMultibinder.addBinding().to(SwaggerRoutes.class);
-    }
-}


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


[18/23] james-project git commit: JAMES-2138 Webadmin default content type should be JSON

Posted by bt...@apache.org.
JAMES-2138 Webadmin default content type should be JSON


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/4817caa7
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/4817caa7
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/4817caa7

Branch: refs/heads/master
Commit: 4817caa7c514731e540b4ef715ac487a24acbf56
Parents: b421854
Author: benwa <bt...@linagora.com>
Authored: Wed Sep 6 13:10:40 2017 +0700
Committer: benwa <bt...@linagora.com>
Committed: Sat Sep 9 10:46:36 2017 +0700

----------------------------------------------------------------------
 .../WebAdminServerIntegrationTest.java          |   6 +
 .../routes/CassandraMigrationRoutes.java        |   1 -
 .../routes/CassandraMigrationRoutesTest.java    |  45 ++++--
 .../apache/james/webadmin/WebAdminServer.java   |   1 +
 .../webadmin/routes/DomainsRoutesTest.java      |  56 ++++---
 .../james/webadmin/routes/UsersRoutesTest.java  |  79 +++++++---
 .../webadmin/routes/GlobalQuotaRoutesTest.java  | 146 +++++++++++++------
 .../routes/UserMailboxesRoutesTest.java         |  90 ++++++++----
 8 files changed, 293 insertions(+), 131 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/4817caa7/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/WebAdminServerIntegrationTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/WebAdminServerIntegrationTest.java b/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/WebAdminServerIntegrationTest.java
index 6835242..8b6230c 100644
--- a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/WebAdminServerIntegrationTest.java
+++ b/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/WebAdminServerIntegrationTest.java
@@ -22,6 +22,7 @@ package org.apache.james.webadmin.integration;
 import static com.jayway.restassured.RestAssured.given;
 import static com.jayway.restassured.config.EncoderConfig.encoderConfig;
 import static com.jayway.restassured.config.RestAssuredConfig.newConfig;
+import static org.apache.james.webadmin.Constants.JSON_CONTENT_TYPE;
 import static org.apache.james.webadmin.Constants.SEPARATOR;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.hamcrest.Matchers.containsString;
@@ -161,6 +162,7 @@ public class WebAdminServerIntegrationTest {
             .get(UserRoutes.USERS)
         .then()
             .statusCode(200)
+            .contentType(JSON_CONTENT_TYPE)
             .body(is("[{\"username\":\"username@domain\"}]"));
     }
 
@@ -203,6 +205,7 @@ public class WebAdminServerIntegrationTest {
             .get(VERSION)
         .then()
             .statusCode(200)
+            .contentType(JSON_CONTENT_TYPE)
             .body(is("{\"version\":null}"));
     }
 
@@ -214,6 +217,7 @@ public class WebAdminServerIntegrationTest {
             .get(VERSION_LATEST)
         .then()
             .statusCode(200)
+            .contentType(JSON_CONTENT_TYPE)
             .body(is("{\"version\":" + CassandraSchemaVersionManager.MAX_VERSION + "}"));
     }
 
@@ -233,6 +237,7 @@ public class WebAdminServerIntegrationTest {
             .get(VERSION)
         .then()
             .statusCode(200)
+            .contentType(JSON_CONTENT_TYPE)
             .body(is("{\"version\":" + CassandraSchemaVersionManager.MAX_VERSION + "}"));
     }
 
@@ -251,6 +256,7 @@ public class WebAdminServerIntegrationTest {
             .get(VERSION)
         .then()
             .statusCode(200)
+            .contentType(JSON_CONTENT_TYPE)
             .body(is("{\"version\":" + CassandraSchemaVersionManager.MAX_VERSION + "}"));
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/4817caa7/server/protocols/webadmin/webadmin-cassandra/src/main/java/org/apache/james/webadmin/routes/CassandraMigrationRoutes.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-cassandra/src/main/java/org/apache/james/webadmin/routes/CassandraMigrationRoutes.java b/server/protocols/webadmin/webadmin-cassandra/src/main/java/org/apache/james/webadmin/routes/CassandraMigrationRoutes.java
index c9564e7..c574f13 100644
--- a/server/protocols/webadmin/webadmin-cassandra/src/main/java/org/apache/james/webadmin/routes/CassandraMigrationRoutes.java
+++ b/server/protocols/webadmin/webadmin-cassandra/src/main/java/org/apache/james/webadmin/routes/CassandraMigrationRoutes.java
@@ -34,7 +34,6 @@ import spark.Service;
 
 public class CassandraMigrationRoutes implements Routes {
 
-
     private static final Logger LOGGER = LoggerFactory.getLogger(CassandraMigrationRoutes.class);
 
     public static final String VERSION_BASE = "/cassandra/version";

http://git-wip-us.apache.org/repos/asf/james-project/blob/4817caa7/server/protocols/webadmin/webadmin-cassandra/src/test/java/org/apache/james/webadmin/routes/CassandraMigrationRoutesTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-cassandra/src/test/java/org/apache/james/webadmin/routes/CassandraMigrationRoutesTest.java b/server/protocols/webadmin/webadmin-cassandra/src/test/java/org/apache/james/webadmin/routes/CassandraMigrationRoutesTest.java
index 17aaa2b..d3554d0 100644
--- a/server/protocols/webadmin/webadmin-cassandra/src/test/java/org/apache/james/webadmin/routes/CassandraMigrationRoutesTest.java
+++ b/server/protocols/webadmin/webadmin-cassandra/src/test/java/org/apache/james/webadmin/routes/CassandraMigrationRoutesTest.java
@@ -24,13 +24,14 @@ import static com.jayway.restassured.RestAssured.when;
 import static com.jayway.restassured.config.EncoderConfig.encoderConfig;
 import static com.jayway.restassured.config.RestAssuredConfig.newConfig;
 import static org.apache.james.webadmin.WebAdminServer.NO_CONFIGURATION;
-import static org.hamcrest.CoreMatchers.is;
+import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.Matchers.eq;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.verifyNoMoreInteractions;
 import static org.mockito.Mockito.when;
+
 import java.util.Map;
 import java.util.Optional;
 import java.util.concurrent.CompletableFuture;
@@ -41,6 +42,10 @@ import org.apache.james.metrics.logger.DefaultMetricFactory;
 import org.apache.james.webadmin.WebAdminServer;
 import org.apache.james.webadmin.service.CassandraMigrationService;
 import org.apache.james.webadmin.utils.JsonTransformer;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
 
 import com.google.common.base.Charsets;
 import com.google.common.collect.ImmutableMap;
@@ -48,11 +53,6 @@ import com.jayway.restassured.RestAssured;
 import com.jayway.restassured.builder.RequestSpecBuilder;
 import com.jayway.restassured.http.ContentType;
 
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-
 public class CassandraMigrationRoutesTest {
 
     private static final Integer LATEST_VERSION = 3;
@@ -101,20 +101,33 @@ public class CassandraMigrationRoutesTest {
     public void getShouldReturnTheCurrentVersion() throws Exception {
         when(schemaVersionDAO.getCurrentSchemaVersion()).thenReturn(CompletableFuture.completedFuture(Optional.of(CURRENT_VERSION)));
 
-        when()
-            .get()
-        .then()
-            .statusCode(200)
-            .body(is("{\"version\":2}"));
+        Integer version =
+            when()
+                .get()
+            .then()
+                .statusCode(200)
+                .contentType(ContentType.JSON)
+                .extract()
+                .jsonPath()
+                .getInt("version");
+
+        assertThat(version).isEqualTo(CURRENT_VERSION);
     }
 
     @Test
     public void getShouldReturnTheLatestVersionWhenSetUpTheLatestVersion() throws Exception {
-        when()
-            .get("/latest")
-        .then()
-            .statusCode(200)
-            .body(is("{\"version\":" + LATEST_VERSION + "}"));
+
+        Integer version =
+            when()
+                .get("/latest")
+            .then()
+                .statusCode(200)
+                .contentType(ContentType.JSON)
+                .extract()
+                .jsonPath()
+                .getInt("version");
+
+        assertThat(version).isEqualTo(LATEST_VERSION);
     }
 
     @Ignore

http://git-wip-us.apache.org/repos/asf/james-project/blob/4817caa7/server/protocols/webadmin/webadmin-core/src/main/java/org/apache/james/webadmin/WebAdminServer.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-core/src/main/java/org/apache/james/webadmin/WebAdminServer.java b/server/protocols/webadmin/webadmin-core/src/main/java/org/apache/james/webadmin/WebAdminServer.java
index cfd60b6..ba27d1c 100644
--- a/server/protocols/webadmin/webadmin-core/src/main/java/org/apache/james/webadmin/WebAdminServer.java
+++ b/server/protocols/webadmin/webadmin-core/src/main/java/org/apache/james/webadmin/WebAdminServer.java
@@ -83,6 +83,7 @@ public class WebAdminServer implements Configurable {
             configureCORS();
             configureMetrics();
             service.before(authenticationFilter);
+            service.before((request, response) -> response.type(Constants.JSON_CONTENT_TYPE));
             configureMDC();
             routesList.forEach(routes -> routes.define(service));
             service.awaitInitialization();

http://git-wip-us.apache.org/repos/asf/james-project/blob/4817caa7/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/DomainsRoutesTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/DomainsRoutesTest.java b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/DomainsRoutesTest.java
index 23739f9..c3eeaad 100644
--- a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/DomainsRoutesTest.java
+++ b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/DomainsRoutesTest.java
@@ -26,8 +26,7 @@ import static com.jayway.restassured.config.EncoderConfig.encoderConfig;
 import static com.jayway.restassured.config.RestAssuredConfig.newConfig;
 import static org.apache.james.webadmin.Constants.SEPARATOR;
 import static org.apache.james.webadmin.WebAdminServer.NO_CONFIGURATION;
-import static org.hamcrest.CoreMatchers.containsString;
-import static org.hamcrest.CoreMatchers.is;
+import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.Matchers.any;
 import static org.mockito.Mockito.doThrow;
 import static org.mockito.Mockito.mock;
@@ -35,6 +34,7 @@ import static org.mockito.Mockito.when;
 
 import java.net.InetAddress;
 import java.nio.charset.StandardCharsets;
+import java.util.List;
 
 import org.apache.james.dnsservice.api.DNSService;
 import org.apache.james.domainlist.api.DomainList;
@@ -51,6 +51,7 @@ import org.junit.runner.RunWith;
 import com.jayway.restassured.RestAssured;
 import com.jayway.restassured.builder.RequestSpecBuilder;
 import com.jayway.restassured.http.ContentType;
+
 import de.bechte.junit.runners.context.HierarchicalContextRunner;
 
 @RunWith(HierarchicalContextRunner.class)
@@ -96,11 +97,18 @@ public class DomainsRoutesTest {
 
         @Test
         public void getDomainsShouldBeEmptyByDefault() {
-            given()
-                .get()
-            .then()
-                .statusCode(200)
-                .body(is("[]"));
+            List<String> domains =
+                given()
+                    .get()
+                .then()
+                    .statusCode(200)
+                    .contentType(ContentType.JSON)
+                    .extract()
+                    .body()
+                    .jsonPath()
+                    .getList(".");
+
+            assertThat(domains).isEmpty();
         }
 
         @Test
@@ -132,11 +140,18 @@ public class DomainsRoutesTest {
             with()
                 .put(DOMAIN);
 
-            when()
-                .get()
-            .then()
-                .statusCode(200)
-                .body(containsString(DOMAIN));
+            List<String> domains =
+                when()
+                    .get()
+                .then()
+                    .contentType(ContentType.JSON)
+                    .statusCode(200)
+                    .extract()
+                    .body()
+                    .jsonPath()
+                    .getList(".");
+
+            assertThat(domains).containsExactly(DOMAIN);
         }
 
         @Test
@@ -186,11 +201,18 @@ public class DomainsRoutesTest {
             .then()
                 .statusCode(204);
 
-            when()
-                .get()
-            .then()
-                .statusCode(200)
-                .body(is("[]"));
+            List<String> domains =
+                when()
+                    .get()
+                .then()
+                    .contentType(ContentType.JSON)
+                    .statusCode(200)
+                    .extract()
+                    .body()
+                    .jsonPath()
+                    .getList(".");
+
+           assertThat(domains).isEmpty();
         }
 
         @Test

http://git-wip-us.apache.org/repos/asf/james-project/blob/4817caa7/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/UsersRoutesTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/UsersRoutesTest.java b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/UsersRoutesTest.java
index cba4019..c1c7527 100644
--- a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/UsersRoutesTest.java
+++ b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/UsersRoutesTest.java
@@ -25,14 +25,15 @@ import static com.jayway.restassured.RestAssured.with;
 import static com.jayway.restassured.config.EncoderConfig.encoderConfig;
 import static com.jayway.restassured.config.RestAssuredConfig.newConfig;
 import static org.apache.james.webadmin.WebAdminServer.NO_CONFIGURATION;
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.CoreMatchers.is;
+import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.Matchers.any;
 import static org.mockito.Mockito.doThrow;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 import java.nio.charset.StandardCharsets;
+import java.util.List;
+import java.util.Map;
 
 import org.apache.james.domainlist.api.DomainList;
 import org.apache.james.metrics.logger.DefaultMetricFactory;
@@ -48,9 +49,11 @@ import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
+import com.google.common.collect.ImmutableMap;
 import com.jayway.restassured.RestAssured;
 import com.jayway.restassured.builder.RequestSpecBuilder;
 import com.jayway.restassured.http.ContentType;
+
 import de.bechte.junit.runners.context.HierarchicalContextRunner;
 
 @RunWith(HierarchicalContextRunner.class)
@@ -96,11 +99,18 @@ public class UsersRoutesTest {
 
         @Test
         public void getUsersShouldBeEmptyByDefault() {
-            when()
-                .get()
-            .then()
-                .statusCode(200)
-                .body(is("[]"));
+            List<Map<String, String>> users =
+                when()
+                    .get()
+                .then()
+                    .statusCode(200)
+                    .contentType(ContentType.JSON)
+                    .extract()
+                    .body()
+                    .jsonPath()
+                    .getList(".");
+
+            assertThat(users).isEmpty();
         }
 
         @Test
@@ -155,13 +165,20 @@ public class UsersRoutesTest {
         public void postShouldAddTheUser() {
             with()
                 .body("{\"password\":\"password\"}")
-            .put(USERNAME);
-
-            when()
-                .get()
-            .then()
-                .statusCode(200)
-                .body(equalTo("[{\"username\":\"" + USERNAME + "\"}]"));
+                .put(USERNAME);
+
+            List<Map<String, String>> users =
+                when()
+                    .get()
+                .then()
+                    .statusCode(200)
+                    .contentType(ContentType.JSON)
+                    .extract()
+                    .body()
+                    .jsonPath()
+                    .getList(".");
+
+            assertThat(users).containsExactly(ImmutableMap.of("username", USERNAME));
         }
 
         @Test
@@ -180,11 +197,18 @@ public class UsersRoutesTest {
                 .statusCode(204);
 
             // Then
-            when()
-                .get()
-            .then()
-                .statusCode(200)
-                .body(equalTo("[{\"username\":\"" + USERNAME + "\"}]"));
+            List<Map<String, String>> users =
+                when()
+                    .get()
+                .then()
+                    .statusCode(200)
+                    .contentType(ContentType.JSON)
+                    .extract()
+                    .body()
+                    .jsonPath()
+                    .getList(".");
+
+            assertThat(users).containsExactly(ImmutableMap.of("username", USERNAME));
         }
 
         @Test
@@ -269,11 +293,18 @@ public class UsersRoutesTest {
                 .statusCode(204);
 
             // Then
-            when()
-                .get()
-            .then()
-                .statusCode(200)
-                .body(equalTo("[]"));
+            List<Map<String, String>> users =
+                when()
+                    .get()
+                .then()
+                    .statusCode(200)
+                    .contentType(ContentType.JSON)
+                    .extract()
+                    .body()
+                    .jsonPath()
+                    .getList(".");
+
+            assertThat(users).isEmpty();
         }
 
         @Test

http://git-wip-us.apache.org/repos/asf/james-project/blob/4817caa7/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/GlobalQuotaRoutesTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/GlobalQuotaRoutesTest.java b/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/GlobalQuotaRoutesTest.java
index 89f9fc0..4d6f8bd 100644
--- a/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/GlobalQuotaRoutesTest.java
+++ b/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/GlobalQuotaRoutesTest.java
@@ -24,7 +24,6 @@ import static com.jayway.restassured.config.EncoderConfig.encoderConfig;
 import static com.jayway.restassured.config.RestAssuredConfig.newConfig;
 import static org.apache.james.webadmin.WebAdminServer.NO_CONFIGURATION;
 import static org.assertj.core.api.Assertions.assertThat;
-import static org.hamcrest.CoreMatchers.is;
 
 import org.apache.james.mailbox.inmemory.quota.InMemoryPerUserMaxQuotaManager;
 import org.apache.james.mailbox.model.Quota;
@@ -39,6 +38,7 @@ import com.google.common.base.Charsets;
 import com.jayway.restassured.RestAssured;
 import com.jayway.restassured.builder.RequestSpecBuilder;
 import com.jayway.restassured.http.ContentType;
+import com.jayway.restassured.path.json.JsonPath;
 
 public class GlobalQuotaRoutesTest {
 
@@ -69,11 +69,16 @@ public class GlobalQuotaRoutesTest {
 
     @Test
     public void getCountQuotaCountShouldReturnUnlimitedByDefault() {
-        given()
-            .get(GlobalQuotaRoutes.COUNT_ENDPOINT)
-        .then()
-            .statusCode(200)
-            .body(is(String.valueOf(Quota.UNLIMITED)));
+        long quota =
+            given()
+                .get(GlobalQuotaRoutes.COUNT_ENDPOINT)
+            .then()
+                .statusCode(200)
+                .contentType(ContentType.JSON)
+                .extract()
+                .as(Long.class);
+
+        assertThat(quota).isEqualTo(Quota.UNLIMITED);
     }
 
     @Test
@@ -81,11 +86,16 @@ public class GlobalQuotaRoutesTest {
         int value = 42;
         maxQuotaManager.setDefaultMaxMessage(value);
 
-        given()
-            .get(GlobalQuotaRoutes.COUNT_ENDPOINT)
-        .then()
-            .statusCode(200)
-            .body(is(String.valueOf(value)));
+        Long actual =
+            given()
+                .get(GlobalQuotaRoutes.COUNT_ENDPOINT)
+            .then()
+                .statusCode(200)
+                .contentType(ContentType.JSON)
+                .extract()
+                .as(Long.class);
+
+        assertThat(actual).isEqualTo(value);
     }
 
     @Test
@@ -131,23 +141,34 @@ public class GlobalQuotaRoutesTest {
 
     @Test
     public void getSizeQuotaCountShouldReturnUnlimitedByDefault() {
-        given()
-            .get(GlobalQuotaRoutes.SIZE_ENDPOINT)
-        .then()
-            .statusCode(200)
-            .body(is(String.valueOf(Quota.UNLIMITED)));
+        long quota =
+            given()
+                .get(GlobalQuotaRoutes.SIZE_ENDPOINT)
+            .then()
+                .statusCode(200)
+                .contentType(ContentType.JSON)
+                .extract()
+                .as(Long.class);
+
+        assertThat(quota).isEqualTo(Quota.UNLIMITED);
     }
 
     @Test
     public void getSizeShouldReturnStoredValue() throws Exception{
-        int value = 42;
+        long value = 42;
         maxQuotaManager.setDefaultMaxStorage(value);
 
-        given()
-            .get(GlobalQuotaRoutes.SIZE_ENDPOINT)
-        .then()
-            .statusCode(200)
-            .body(is(String.valueOf(value)));
+
+        long quota =
+            given()
+                .get(GlobalQuotaRoutes.SIZE_ENDPOINT)
+            .then()
+                .statusCode(200)
+                .contentType(ContentType.JSON)
+                .extract()
+                .as(Long.class);
+
+        assertThat(quota).isEqualTo(value);
     }
 
     @Test
@@ -193,45 +214,74 @@ public class GlobalQuotaRoutesTest {
 
     @Test
     public void getQuotaShouldReturnBothWhenValueSpecified() throws Exception {
-        maxQuotaManager.setDefaultMaxStorage(42);
-        maxQuotaManager.setDefaultMaxMessage(52);
-
-        given()
-            .get(GlobalQuotaRoutes.QUOTA_ENDPOINT)
-        .then()
-            .statusCode(200)
-            .body(is("{\"count\":52,\"size\":42}"));
+        int maxStorage = 42;
+        int maxMessage = 52;
+        maxQuotaManager.setDefaultMaxStorage(maxStorage);
+        maxQuotaManager.setDefaultMaxMessage(maxMessage);
+
+        JsonPath jsonPath =
+            given()
+                .get(GlobalQuotaRoutes.QUOTA_ENDPOINT)
+            .then()
+                .statusCode(200)
+                .contentType(ContentType.JSON)
+                .extract()
+                .jsonPath();
+
+        assertThat(jsonPath.getLong("size")).isEqualTo(maxStorage);
+        assertThat(jsonPath.getLong("count")).isEqualTo(maxMessage);
     }
 
     @Test
     public void getQuotaShouldReturnBothDefaultValues() throws Exception {
-        given()
-            .get(GlobalQuotaRoutes.QUOTA_ENDPOINT)
-        .then()
-            .statusCode(200)
-            .body(is("{\"count\":-1,\"size\":-1}"));
+        JsonPath jsonPath =
+            given()
+                .get(GlobalQuotaRoutes.QUOTA_ENDPOINT)
+            .then()
+                .statusCode(200)
+                .contentType(ContentType.JSON)
+                .extract()
+                .jsonPath();
+
+        assertThat(jsonPath.getLong("size")).isEqualTo(Quota.UNLIMITED);
+        assertThat(jsonPath.getLong("count")).isEqualTo(Quota.UNLIMITED);
     }
 
     @Test
     public void getQuotaShouldReturnBothWhenNoCount() throws Exception {
-        maxQuotaManager.setDefaultMaxStorage(42);
-
-        given()
-            .get(GlobalQuotaRoutes.QUOTA_ENDPOINT)
-        .then()
-            .statusCode(200)
-            .body(is("{\"count\":-1,\"size\":42}"));
+        int maxStorage = 42;
+        maxQuotaManager.setDefaultMaxStorage(maxStorage);
+
+        JsonPath jsonPath =
+            given()
+                .get(GlobalQuotaRoutes.QUOTA_ENDPOINT)
+            .then()
+                .statusCode(200)
+                .contentType(ContentType.JSON)
+                .extract()
+                .jsonPath();
+
+        assertThat(jsonPath.getLong("size")).isEqualTo(maxStorage);
+        assertThat(jsonPath.getLong("count")).isEqualTo(Quota.UNLIMITED);
     }
 
     @Test
     public void getQuotaShouldReturnBothWhenNoSize() throws Exception {
-        maxQuotaManager.setDefaultMaxMessage(42);
+        int maxMessage = 42;
+        maxQuotaManager.setDefaultMaxMessage(maxMessage);
 
-        given()
-            .get(GlobalQuotaRoutes.QUOTA_ENDPOINT)
-        .then()
-            .statusCode(200)
-            .body(is("{\"count\":42,\"size\":-1}"));
+
+        JsonPath jsonPath =
+            given()
+                .get(GlobalQuotaRoutes.QUOTA_ENDPOINT)
+                .then()
+                .statusCode(200)
+                .contentType(ContentType.JSON)
+                .extract()
+                .jsonPath();
+
+        assertThat(jsonPath.getLong("size")).isEqualTo(Quota.UNLIMITED);
+        assertThat(jsonPath.getLong("count")).isEqualTo(maxMessage);
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/james-project/blob/4817caa7/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/UserMailboxesRoutesTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/UserMailboxesRoutesTest.java b/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/UserMailboxesRoutesTest.java
index 503abfe..7ae6ce4 100644
--- a/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/UserMailboxesRoutesTest.java
+++ b/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/UserMailboxesRoutesTest.java
@@ -26,12 +26,16 @@ import static com.jayway.restassured.config.RestAssuredConfig.newConfig;
 import static org.apache.james.webadmin.Constants.SEPARATOR;
 import static org.apache.james.webadmin.WebAdminServer.NO_CONFIGURATION;
 import static org.apache.james.webadmin.routes.UserMailboxesRoutes.USERS_BASE;
+import static org.assertj.core.api.Assertions.assertThat;
 import static org.hamcrest.CoreMatchers.is;
 import static org.mockito.Matchers.any;
 import static org.mockito.Mockito.doThrow;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
+import java.util.List;
+import java.util.Map;
+
 import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.acl.SimpleGroupMembershipResolver;
@@ -63,6 +67,7 @@ import org.junit.runner.RunWith;
 
 import com.google.common.base.Charsets;
 import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
 import com.jayway.restassured.RestAssured;
 import com.jayway.restassured.builder.RequestSpecBuilder;
 import com.jayway.restassured.http.ContentType;
@@ -291,11 +296,18 @@ public class UserMailboxesRoutesTest {
 
         @Test
         public void getMailboxesShouldReturnEmptyListByDefault() {
-            when()
-                .get()
-            .then()
-                .statusCode(200)
-                .body(is("[]"));
+            List<Object> list =
+                when()
+                    .get()
+                .then()
+                    .statusCode(200)
+                    .contentType(ContentType.JSON)
+                    .extract()
+                    .body()
+                    .jsonPath()
+                    .getList(".");
+
+            assertThat(list).isEmpty();
         }
 
         @Test
@@ -427,11 +439,18 @@ public class UserMailboxesRoutesTest {
             with()
                 .delete();
 
-            when()
-                .get()
-            .then()
-                .statusCode(200)
-                .body(is("[]"));
+            List<Object> list =
+                when()
+                    .get()
+                .then()
+                    .statusCode(200)
+                    .contentType(ContentType.JSON)
+                    .extract()
+                    .body()
+                    .jsonPath()
+                    .getList(".");
+
+            assertThat(list).isEmpty();
         }
 
         @Test
@@ -459,11 +478,18 @@ public class UserMailboxesRoutesTest {
             with()
                 .delete(MAILBOX_NAME);
 
-            when()
-                .get()
-            .then()
-                .statusCode(200)
-                .body(is("[]"));
+            List<Object> list =
+                when()
+                    .get()
+                .then()
+                    .statusCode(200)
+                    .contentType(ContentType.JSON)
+                    .extract()
+                    .body()
+                    .jsonPath()
+                    .getList(".");
+
+            assertThat(list).isEmpty();
         }
 
         @Test
@@ -478,11 +504,18 @@ public class UserMailboxesRoutesTest {
             with()
                 .delete(MAILBOX_NAME);
 
-            when()
-                .get()
-            .then()
-                .statusCode(200)
-                .body(is("[{\"mailboxName\":\"" + mailboxName + "\"}]"));
+            List<Map<String, String>> list =
+                when()
+                    .get()
+                .then()
+                    .statusCode(200)
+                    .contentType(ContentType.JSON)
+                    .extract()
+                    .body()
+                    .jsonPath()
+                    .getList(".");
+
+            assertThat(list).containsExactly(ImmutableMap.of("mailboxName", mailboxName));
         }
 
         @Test
@@ -510,11 +543,18 @@ public class UserMailboxesRoutesTest {
             with()
                 .delete(MAILBOX_NAME + ".child");
 
-            when()
-                .get()
-            .then()
-                .statusCode(200)
-                .body(is("[{\"mailboxName\":\"myMailboxName\"}]"));
+            List<Map<String, String>> list =
+                when()
+                    .get()
+                .then()
+                    .statusCode(200)
+                    .contentType(ContentType.JSON)
+                    .extract()
+                    .body()
+                    .jsonPath()
+                    .getList(".");
+
+            assertThat(list).containsExactly(ImmutableMap.of("mailboxName", MAILBOX_NAME));
         }
     }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


[07/23] james-project git commit: JAMES-2138 move MailAddress to a new james-core project

Posted by bt...@apache.org.
http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/jmx/JMXStateMailetProcessorListener.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/jmx/JMXStateMailetProcessorListener.java b/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/jmx/JMXStateMailetProcessorListener.java
index f304cbd..9393490 100644
--- a/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/jmx/JMXStateMailetProcessorListener.java
+++ b/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/jmx/JMXStateMailetProcessorListener.java
@@ -36,7 +36,7 @@ import org.apache.james.lifecycle.api.Disposable;
 import org.apache.james.mailetcontainer.impl.matchers.CompositeMatcher;
 import org.apache.james.mailetcontainer.lib.AbstractStateMailetProcessor;
 import org.apache.james.mailetcontainer.lib.AbstractStateMailetProcessor.MailetProcessorListener;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.Mailet;
 import org.apache.mailet.Matcher;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/matchers/And.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/matchers/And.java b/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/matchers/And.java
index 3d5e7e7..456d098 100644
--- a/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/matchers/And.java
+++ b/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/matchers/And.java
@@ -25,7 +25,7 @@ import java.util.Set;
 import javax.mail.MessagingException;
 
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.Matcher;
 
 import com.google.common.collect.ImmutableList;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/matchers/Not.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/matchers/Not.java b/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/matchers/Not.java
index 7b46a4f..1cc0cc6 100644
--- a/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/matchers/Not.java
+++ b/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/matchers/Not.java
@@ -25,7 +25,7 @@ import java.util.Optional;
 import javax.mail.MessagingException;
 
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.Matcher;
 
 import com.google.common.collect.Lists;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/matchers/Or.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/matchers/Or.java b/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/matchers/Or.java
index 47bb7c6..4c0ed8c 100644
--- a/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/matchers/Or.java
+++ b/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/matchers/Or.java
@@ -25,7 +25,7 @@ import java.util.HashSet;
 import javax.mail.MessagingException;
 
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.Matcher;
 
 /**

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/matchers/Xor.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/matchers/Xor.java b/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/matchers/Xor.java
index 32794cc..cb67528 100644
--- a/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/matchers/Xor.java
+++ b/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/matchers/Xor.java
@@ -25,7 +25,7 @@ import java.util.Optional;
 import javax.mail.MessagingException;
 
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.Matcher;
 
 import com.google.common.collect.ImmutableSet;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/lib/AbstractStateMailetProcessor.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/lib/AbstractStateMailetProcessor.java b/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/lib/AbstractStateMailetProcessor.java
index db12893..aa0e0e7 100644
--- a/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/lib/AbstractStateMailetProcessor.java
+++ b/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/lib/AbstractStateMailetProcessor.java
@@ -43,7 +43,7 @@ import org.apache.james.mailetcontainer.impl.MatcherMailetPair;
 import org.apache.james.mailetcontainer.impl.jmx.JMXStateMailetProcessorListener;
 import org.apache.james.mailetcontainer.impl.matchers.CompositeMatcher;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.Mailet;
 import org.apache.mailet.MailetConfig;
 import org.apache.mailet.MailetContext;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/JamesMailetContextTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/JamesMailetContextTest.java b/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/JamesMailetContextTest.java
index b1f88ac..f5e5f76 100644
--- a/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/JamesMailetContextTest.java
+++ b/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/JamesMailetContextTest.java
@@ -30,7 +30,7 @@ import org.apache.james.dnsservice.api.DNSService;
 import org.apache.james.domainlist.lib.AbstractDomainList;
 import org.apache.james.domainlist.memory.MemoryDomainList;
 import org.apache.james.user.memory.MemoryUsersRepository;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.junit.Before;
 import org.junit.Test;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/AndTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/AndTest.java b/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/AndTest.java
index 490b248..a851eb3 100644
--- a/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/AndTest.java
+++ b/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/AndTest.java
@@ -26,7 +26,7 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.Matcher;
 import org.apache.mailet.base.test.FakeMail;
 import org.junit.Before;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/NotTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/NotTest.java b/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/NotTest.java
index ca555da..f3bb18b 100644
--- a/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/NotTest.java
+++ b/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/NotTest.java
@@ -24,7 +24,7 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.Matcher;
 import org.apache.mailet.base.test.FakeMail;
 import org.junit.Before;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/OrTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/OrTest.java b/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/OrTest.java
index 94fb41c..4fa4b15 100644
--- a/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/OrTest.java
+++ b/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/OrTest.java
@@ -28,7 +28,7 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.Matcher;
 import org.apache.mailet.base.test.FakeMail;
 import org.junit.Before;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/XorTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/XorTest.java b/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/XorTest.java
index c06aeaf..ac16d65 100644
--- a/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/XorTest.java
+++ b/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/XorTest.java
@@ -27,7 +27,7 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.Matcher;
 import org.apache.mailet.base.test.FakeMail;
 import org.junit.Before;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/lib/AbstractStateCompositeProcessorTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/lib/AbstractStateCompositeProcessorTest.java b/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/lib/AbstractStateCompositeProcessorTest.java
index b000490..ec66062 100644
--- a/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/lib/AbstractStateCompositeProcessorTest.java
+++ b/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/lib/AbstractStateCompositeProcessorTest.java
@@ -30,7 +30,7 @@ import javax.mail.MessagingException;
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.configuration.DefaultConfigurationBuilder;
 import org.apache.commons.configuration.HierarchicalConfiguration;
-import org.apache.james.core.MailImpl;
+import org.apache.james.server.core.MailImpl;
 import org.apache.james.mailetcontainer.api.MailProcessor;
 import org.apache.james.mailetcontainer.api.mock.MockMailProcessor;
 import org.apache.mailet.Mail;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/lib/AbstractStateMailetProcessorTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/lib/AbstractStateMailetProcessorTest.java b/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/lib/AbstractStateMailetProcessorTest.java
index 8958f00..47a4baf 100644
--- a/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/lib/AbstractStateMailetProcessorTest.java
+++ b/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/lib/AbstractStateMailetProcessorTest.java
@@ -21,14 +21,14 @@ package org.apache.james.mailetcontainer.lib;
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.configuration.DefaultConfigurationBuilder;
 import org.apache.commons.configuration.HierarchicalConfiguration;
-import org.apache.james.core.MailImpl;
+import org.apache.james.server.core.MailImpl;
 import org.apache.james.mailetcontainer.api.mock.ExceptionThrowingMailet;
 import org.apache.james.mailetcontainer.api.mock.ExceptionThrowingMatcher;
 import org.apache.james.mailetcontainer.api.mock.MockMailet;
 import org.apache.james.mailetcontainer.api.mock.MockMatcher;
 import org.apache.james.mailetcontainer.lib.AbstractStateMailetProcessor.MailetProcessorListener;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.Mailet;
 import org.apache.mailet.Matcher;
 import static org.junit.Assert.assertEquals;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/AbstractRecipientRewriteTable.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/AbstractRecipientRewriteTable.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/AbstractRecipientRewriteTable.java
index 5ce3f5f..095af8e 100755
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/AbstractRecipientRewriteTable.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/AbstractRecipientRewriteTable.java
@@ -32,14 +32,14 @@ import javax.inject.Inject;
 import javax.mail.MessagingException;
 import javax.mail.internet.ParseException;
 
-import org.apache.james.core.MailImpl;
+import org.apache.james.server.core.MailImpl;
 import org.apache.james.dnsservice.api.DNSService;
 import org.apache.james.domainlist.api.DomainList;
 import org.apache.james.domainlist.api.DomainListException;
 import org.apache.james.rrt.lib.RecipientRewriteTableUtil;
 import org.apache.mailet.Experimental;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.GenericMailet;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/BayesianAnalysis.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/BayesianAnalysis.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/BayesianAnalysis.java
index 4028e7b..2d9924b 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/BayesianAnalysis.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/BayesianAnalysis.java
@@ -37,7 +37,7 @@ import org.apache.james.util.bayesian.JDBCBayesianAnalyzer;
 import org.apache.james.util.sql.JDBCUtil;
 import org.apache.mailet.Experimental;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.GenericMailet;
 import org.apache.mailet.base.RFC2822Headers;
 import org.slf4j.Logger;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Bounce.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Bounce.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Bounce.java
index 2886391..9ba3b46 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Bounce.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Bounce.java
@@ -40,7 +40,7 @@ import org.apache.james.transport.util.SenderUtils;
 import org.apache.james.transport.util.SpecialAddressesUtils;
 import org.apache.james.transport.util.TosUtils;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.GenericMailet;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/DSNBounce.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/DSNBounce.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/DSNBounce.java
index 8a72e57..88f745b 100755
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/DSNBounce.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/DSNBounce.java
@@ -32,7 +32,7 @@ import javax.mail.internet.InternetAddress;
 import javax.mail.internet.MimeBodyPart;
 import javax.mail.internet.MimeMessage;
 
-import org.apache.james.core.MailImpl;
+import org.apache.james.server.core.MailImpl;
 import org.apache.james.dnsservice.api.DNSService;
 import org.apache.james.transport.mailets.managesieve.ManageSieveMailet;
 import org.apache.james.transport.mailets.redirect.InitParameters;
@@ -52,7 +52,7 @@ import org.apache.james.transport.util.SpecialAddressesUtils;
 import org.apache.james.transport.util.TosUtils;
 import org.apache.commons.lang.time.FastDateFormat;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.DateFormats;
 import org.apache.mailet.base.GenericMailet;
 import org.apache.mailet.base.RFC2822Headers;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Forward.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Forward.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Forward.java
index 312306f..59ca7d1 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Forward.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Forward.java
@@ -39,7 +39,7 @@ import org.apache.james.transport.util.ReplyToUtils;
 import org.apache.james.transport.util.SenderUtils;
 import org.apache.james.transport.util.TosUtils;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.GenericMailet;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/JDBCAlias.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/JDBCAlias.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/JDBCAlias.java
index 6b71b97..a4d56a0 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/JDBCAlias.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/JDBCAlias.java
@@ -35,7 +35,7 @@ import javax.sql.DataSource;
 import org.apache.james.util.sql.JDBCUtil;
 import org.apache.mailet.Experimental;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.MailetException;
 import org.apache.mailet.base.GenericMailet;
 import org.slf4j.Logger;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/JDBCRecipientRewriteTable.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/JDBCRecipientRewriteTable.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/JDBCRecipientRewriteTable.java
index a06266f..5d4e759 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/JDBCRecipientRewriteTable.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/JDBCRecipientRewriteTable.java
@@ -34,7 +34,7 @@ import javax.sql.DataSource;
 import org.apache.james.rrt.lib.RecipientRewriteTableUtil;
 import org.apache.james.util.sql.JDBCUtil;
 import org.apache.mailet.Experimental;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.MailetException;
 
 /**

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/NotifyPostmaster.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/NotifyPostmaster.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/NotifyPostmaster.java
index ed95c5a..8d030d4 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/NotifyPostmaster.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/NotifyPostmaster.java
@@ -41,7 +41,7 @@ import org.apache.james.transport.util.SenderUtils;
 import org.apache.james.transport.util.SpecialAddressesUtils;
 import org.apache.james.transport.util.TosUtils;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.MailetConfig;
 import org.apache.mailet.base.GenericMailet;
 import org.slf4j.Logger;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/NotifySender.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/NotifySender.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/NotifySender.java
index 07bc700..62377ee 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/NotifySender.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/NotifySender.java
@@ -41,7 +41,7 @@ import org.apache.james.transport.util.SenderUtils;
 import org.apache.james.transport.util.SpecialAddressesUtils;
 import org.apache.james.transport.util.TosUtils;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.MailetConfig;
 import org.apache.mailet.base.GenericMailet;
 import org.slf4j.Logger;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/RecipientRewriteTableProcessor.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/RecipientRewriteTableProcessor.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/RecipientRewriteTableProcessor.java
index a1652fe..b3ba95b 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/RecipientRewriteTableProcessor.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/RecipientRewriteTableProcessor.java
@@ -37,7 +37,7 @@ import org.apache.james.rrt.lib.Mapping;
 import org.apache.james.rrt.lib.Mappings;
 import org.apache.james.util.streams.Iterators;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.MailetContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Redirect.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Redirect.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Redirect.java
index 616b7a0..cc1f1fd 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Redirect.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Redirect.java
@@ -42,7 +42,7 @@ import org.apache.james.transport.util.SenderUtils;
 import org.apache.james.transport.util.SpecialAddressesUtils;
 import org.apache.james.transport.util.TosUtils;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.GenericMailet;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/RemoteDelivery.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/RemoteDelivery.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/RemoteDelivery.java
index 1d74732..1650b44 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/RemoteDelivery.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/RemoteDelivery.java
@@ -42,7 +42,7 @@ import org.apache.james.transport.mailets.remoteDelivery.DeliveryRunnable;
 import org.apache.james.transport.mailets.remoteDelivery.RemoteDeliveryConfiguration;
 import org.apache.james.transport.mailets.remoteDelivery.RemoteDeliverySocketFactory;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.GenericMailet;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Resend.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Resend.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Resend.java
index 393bd6e..46efc81 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Resend.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Resend.java
@@ -40,7 +40,7 @@ import org.apache.james.transport.util.SenderUtils;
 import org.apache.james.transport.util.SpecialAddressesUtils;
 import org.apache.james.transport.util.TosUtils;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.GenericMailet;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/SPF.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/SPF.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/SPF.java
index 6bd7519..21e9de0 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/SPF.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/SPF.java
@@ -28,7 +28,7 @@ import org.apache.james.jspf.impl.DefaultSPF;
 import org.apache.james.transport.mailets.managesieve.ManageSieveMailet;
 import org.apache.mailet.Experimental;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.GenericMailet;
 import org.slf4j.LoggerFactory;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Sieve.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Sieve.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Sieve.java
index 4f61488..2822e80 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Sieve.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Sieve.java
@@ -31,7 +31,7 @@ import org.apache.james.transport.mailets.jsieve.delivery.SieveExecutor;
 import org.apache.james.transport.mailets.jsieve.delivery.SievePoster;
 import org.apache.james.user.api.UsersRepository;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.GenericMailet;
 
 /**

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/ToSenderFolder.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/ToSenderFolder.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/ToSenderFolder.java
index 56f4e77..3635080 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/ToSenderFolder.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/ToSenderFolder.java
@@ -28,7 +28,7 @@ import org.apache.james.user.api.UsersRepository;
 import org.apache.james.user.api.UsersRepositoryException;
 import org.apache.mailet.Experimental;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.GenericMailet;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/WhiteListManager.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/WhiteListManager.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/WhiteListManager.java
index cc48148..e7b2d13 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/WhiteListManager.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/WhiteListManager.java
@@ -53,7 +53,7 @@ import org.apache.james.util.sql.JDBCUtil;
 import org.apache.james.util.sql.SqlResources;
 import org.apache.mailet.Experimental;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.DateFormats;
 import org.apache.mailet.base.GenericMailet;
 import org.apache.mailet.base.RFC2822Headers;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/XMLRecipientRewriteTable.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/XMLRecipientRewriteTable.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/XMLRecipientRewriteTable.java
index 1afe6be..d362a3f 100755
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/XMLRecipientRewriteTable.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/XMLRecipientRewriteTable.java
@@ -28,7 +28,7 @@ import javax.mail.MessagingException;
 
 import org.apache.james.rrt.lib.RecipientRewriteTableUtil;
 import org.apache.mailet.Experimental;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 
 /**
  * <p>

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/delivery/DeliveryUtils.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/delivery/DeliveryUtils.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/delivery/DeliveryUtils.java
index 22cb40d..3385f38 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/delivery/DeliveryUtils.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/delivery/DeliveryUtils.java
@@ -19,7 +19,7 @@
 
 package org.apache.james.transport.mailets.delivery;
 
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 
 public class DeliveryUtils {
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/delivery/MailDispatcher.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/delivery/MailDispatcher.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/delivery/MailDispatcher.java
index 4257917..f4743cb 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/delivery/MailDispatcher.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/delivery/MailDispatcher.java
@@ -27,7 +27,7 @@ import javax.mail.MessagingException;
 import javax.mail.internet.MimeMessage;
 
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.MailetContext;
 import org.apache.mailet.PerRecipientHeaders.Header;
 import org.apache.mailet.base.RFC2822Headers;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/delivery/MailStore.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/delivery/MailStore.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/delivery/MailStore.java
index 4082d4f..fed03e0 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/delivery/MailStore.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/delivery/MailStore.java
@@ -22,7 +22,7 @@ package org.apache.james.transport.mailets.delivery;
 import javax.mail.MessagingException;
 
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 
 public interface MailStore {
     String DELIVERY_PATH_PREFIX = "DeliveryPath_";

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/delivery/MailboxAppender.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/delivery/MailboxAppender.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/delivery/MailboxAppender.java
index 47dc518..335389c 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/delivery/MailboxAppender.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/delivery/MailboxAppender.java
@@ -25,7 +25,7 @@ import javax.mail.Flags;
 import javax.mail.MessagingException;
 import javax.mail.internet.MimeMessage;
 
-import org.apache.james.core.MimeMessageInputStream;
+import org.apache.james.server.core.MimeMessageInputStream;
 import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.MessageManager;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/delivery/SimpleMailStore.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/delivery/SimpleMailStore.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/delivery/SimpleMailStore.java
index 87a910d..21673b9 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/delivery/SimpleMailStore.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/delivery/SimpleMailStore.java
@@ -25,7 +25,7 @@ import org.apache.james.metrics.api.Metric;
 import org.apache.james.user.api.UsersRepository;
 import org.apache.james.user.api.UsersRepositoryException;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/ActionContext.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/ActionContext.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/ActionContext.java
index 6800d8e..f9a0925 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/ActionContext.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/ActionContext.java
@@ -24,7 +24,7 @@ import javax.mail.MessagingException;
 import javax.mail.internet.MimeMessage;
 
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.joda.time.DateTime;
 
 /**

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/ActionUtils.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/ActionUtils.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/ActionUtils.java
index 2354ff0..0dbb78f 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/ActionUtils.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/ActionUtils.java
@@ -22,7 +22,7 @@ package org.apache.james.transport.mailets.jsieve;
 import javax.mail.MessagingException;
 
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/FileIntoAction.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/FileIntoAction.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/FileIntoAction.java
index 24f08ce..6c10428 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/FileIntoAction.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/FileIntoAction.java
@@ -23,7 +23,7 @@ import javax.mail.MessagingException;
 import org.apache.jsieve.mail.Action;
 import org.apache.jsieve.mail.ActionFileInto;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/RedirectAction.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/RedirectAction.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/RedirectAction.java
index 6d48cc8..9e21e6a 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/RedirectAction.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/RedirectAction.java
@@ -27,7 +27,7 @@ import javax.mail.internet.InternetAddress;
 import org.apache.jsieve.mail.Action;
 import org.apache.jsieve.mail.ActionRedirect;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/RejectAction.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/RejectAction.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/RejectAction.java
index 63d2f84..fdb3f33 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/RejectAction.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/RejectAction.java
@@ -39,7 +39,7 @@ import org.apache.james.mdn.type.DispositionType;
 import org.apache.jsieve.mail.Action;
 import org.apache.jsieve.mail.ActionReject;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/ResourceLocator.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/ResourceLocator.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/ResourceLocator.java
index b87b82a..06ba496 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/ResourceLocator.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/ResourceLocator.java
@@ -21,7 +21,7 @@ package org.apache.james.transport.mailets.jsieve;
 import org.apache.james.sieverepository.api.SieveRepository;
 import org.apache.james.user.api.UsersRepository;
 import org.apache.james.user.api.UsersRepositoryException;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.joda.time.DateTime;
 
 import java.io.InputStream;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/SieveMailAdapter.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/SieveMailAdapter.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/SieveMailAdapter.java
index dbebaeb..be6bf21 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/SieveMailAdapter.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/SieveMailAdapter.java
@@ -49,7 +49,7 @@ import org.apache.jsieve.mail.MailUtils;
 import org.apache.jsieve.mail.SieveMailException;
 import org.apache.jsieve.mail.optional.EnvelopeAccessors;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.MailetContext;
 import org.joda.time.DateTime;
 import org.slf4j.Logger;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/VacationAction.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/VacationAction.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/VacationAction.java
index 9453de5..614ddf7 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/VacationAction.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/VacationAction.java
@@ -28,7 +28,7 @@ import javax.mail.internet.AddressException;
 import org.apache.jsieve.mail.Action;
 import org.apache.jsieve.mail.optional.ActionVacation;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.joda.time.Days;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/VacationReply.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/VacationReply.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/VacationReply.java
index 6bb8cba..73340ab 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/VacationReply.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/VacationReply.java
@@ -32,7 +32,7 @@ import javax.mail.internet.MimeMultipart;
 import javax.mail.util.ByteArrayDataSource;
 
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/delivery/SieveExecutor.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/delivery/SieveExecutor.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/delivery/SieveExecutor.java
index ceb8d09..787eab1 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/delivery/SieveExecutor.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/delivery/SieveExecutor.java
@@ -36,7 +36,7 @@ import org.apache.jsieve.exception.SieveException;
 import org.apache.jsieve.parser.generated.ParseException;
 import org.apache.jsieve.parser.generated.TokenMgrError;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.MailetContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/delivery/SievePoster.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/delivery/SievePoster.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/delivery/SievePoster.java
index 39e6b3b..824b988 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/delivery/SievePoster.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/delivery/SievePoster.java
@@ -28,7 +28,7 @@ import org.apache.james.transport.mailets.jsieve.Poster;
 import org.apache.james.user.api.UsersRepository;
 import org.apache.james.user.api.UsersRepositoryException;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 
 public class SievePoster implements Poster {
     private final String folder;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/AddressExtractor.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/AddressExtractor.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/AddressExtractor.java
index 43272f9..0b4f871 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/AddressExtractor.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/AddressExtractor.java
@@ -26,7 +26,7 @@ import javax.mail.MessagingException;
 import javax.mail.internet.AddressException;
 import javax.mail.internet.InternetAddress;
 
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.MailetContext;
 import org.apache.mailet.base.StringUtils;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/MailMessageAlteringUtils.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/MailMessageAlteringUtils.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/MailMessageAlteringUtils.java
index b6a956b..0a1f25f 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/MailMessageAlteringUtils.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/MailMessageAlteringUtils.java
@@ -27,7 +27,7 @@ import javax.mail.internet.MimeBodyPart;
 import javax.mail.internet.MimeMessage;
 import javax.mail.internet.MimeMultipart;
 
-import org.apache.james.core.MimeMessageUtil;
+import org.apache.james.server.core.MimeMessageUtil;
 import org.apache.james.transport.mailets.utils.MimeMessageUtils;
 import org.apache.mailet.Mail;
 import org.apache.mailet.base.RFC2822Headers;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/MailModifier.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/MailModifier.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/MailModifier.java
index c1e0d2c..90c7b75 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/MailModifier.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/MailModifier.java
@@ -26,11 +26,11 @@ import javax.mail.Message;
 import javax.mail.MessagingException;
 import javax.mail.internet.InternetAddress;
 
-import org.apache.james.core.MailImpl;
+import org.apache.james.server.core.MailImpl;
 import org.apache.james.dnsservice.api.DNSService;
 import org.apache.james.transport.util.MailAddressUtils;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.DateFormats;
 import org.apache.mailet.base.RFC2822Headers;
 import org.apache.mailet.base.StringUtils;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/NotifyMailetsMessage.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/NotifyMailetsMessage.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/NotifyMailetsMessage.java
index dc3b048..5f02575 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/NotifyMailetsMessage.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/NotifyMailetsMessage.java
@@ -25,7 +25,7 @@ import javax.mail.MessagingException;
 import javax.mail.internet.MimeMessage;
 
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.RFC2822Headers;
 
 import com.google.common.base.Splitter;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/ProcessRedirectNotify.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/ProcessRedirectNotify.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/ProcessRedirectNotify.java
index 44ab401..0cf003c 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/ProcessRedirectNotify.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/ProcessRedirectNotify.java
@@ -22,7 +22,7 @@ import javax.mail.MessagingException;
 import javax.mail.Session;
 import javax.mail.internet.MimeMessage;
 
-import org.apache.james.core.MailImpl;
+import org.apache.james.server.core.MailImpl;
 import org.apache.mailet.Mail;
 import org.apache.mailet.base.StringUtils;
 import org.slf4j.Logger;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/RedirectNotify.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/RedirectNotify.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/RedirectNotify.java
index be4fd3f..50bcded 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/RedirectNotify.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/RedirectNotify.java
@@ -28,7 +28,7 @@ import org.apache.james.dnsservice.api.DNSService;
 import org.apache.james.transport.mailets.Redirect;
 import org.apache.james.transport.mailets.utils.MimeMessageModifier;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.Mailet;
 import org.apache.mailet.MailetConfig;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/SpecialAddress.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/SpecialAddress.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/SpecialAddress.java
index 640c1f0..4fb0d9f 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/SpecialAddress.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/SpecialAddress.java
@@ -19,7 +19,7 @@
 
 package org.apache.james.transport.mailets.redirect;
 
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 
 import com.google.common.base.Throwables;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remoteDelivery/AddressesArrayToMailAddressListConverter.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remoteDelivery/AddressesArrayToMailAddressListConverter.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remoteDelivery/AddressesArrayToMailAddressListConverter.java
index cef6c33..3ec875b 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remoteDelivery/AddressesArrayToMailAddressListConverter.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remoteDelivery/AddressesArrayToMailAddressListConverter.java
@@ -26,7 +26,7 @@ import javax.mail.Address;
 import javax.mail.internet.AddressException;
 
 import org.apache.james.util.OptionalUtils;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remoteDelivery/Bouncer.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remoteDelivery/Bouncer.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remoteDelivery/Bouncer.java
index d0a12c4..8cca867 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remoteDelivery/Bouncer.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remoteDelivery/Bouncer.java
@@ -29,7 +29,7 @@ import javax.mail.MessagingException;
 import javax.mail.SendFailedException;
 
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.MailetContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remoteDelivery/InternetAddressConverter.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remoteDelivery/InternetAddressConverter.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remoteDelivery/InternetAddressConverter.java
index af446ec..ca9037f 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remoteDelivery/InternetAddressConverter.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remoteDelivery/InternetAddressConverter.java
@@ -22,7 +22,7 @@ package org.apache.james.transport.mailets.remoteDelivery;
 import java.util.Collection;
 import javax.mail.internet.InternetAddress;
 
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 
 import com.google.common.base.Preconditions;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remoteDelivery/MailDelivrer.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remoteDelivery/MailDelivrer.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remoteDelivery/MailDelivrer.java
index c0f8f82..f3b6870 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remoteDelivery/MailDelivrer.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remoteDelivery/MailDelivrer.java
@@ -33,7 +33,7 @@ import org.apache.james.dnsservice.api.DNSService;
 import org.apache.james.dnsservice.api.TemporaryResolutionException;
 import org.apache.mailet.HostAddress;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/AbstractSQLWhitelistMatcher.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/AbstractSQLWhitelistMatcher.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/AbstractSQLWhitelistMatcher.java
index 78f0bb7..c05b790 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/AbstractSQLWhitelistMatcher.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/AbstractSQLWhitelistMatcher.java
@@ -42,7 +42,7 @@ import org.apache.james.util.sql.JDBCUtil;
 import org.apache.james.util.sql.SqlResources;
 import org.apache.mailet.Experimental;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.GenericMatcher;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/AbstractStorageQuota.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/AbstractStorageQuota.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/AbstractStorageQuota.java
index d7991ed..1fe84eb 100755
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/AbstractStorageQuota.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/AbstractStorageQuota.java
@@ -42,7 +42,7 @@ import org.apache.james.user.api.UsersRepository;
 import org.apache.james.user.api.UsersRepositoryException;
 import org.apache.mailet.Experimental;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.MailetContext;
 
 /**

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/InSpammerBlacklist.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/InSpammerBlacklist.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/InSpammerBlacklist.java
index e602f68..2950f4f 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/InSpammerBlacklist.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/InSpammerBlacklist.java
@@ -29,7 +29,7 @@ import javax.mail.MessagingException;
 import org.apache.james.dnsservice.api.DNSService;
 import org.apache.mailet.Experimental;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.GenericMatcher;
 
 /**

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/IsInWhiteList.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/IsInWhiteList.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/IsInWhiteList.java
index ec6d087..6aa7b2a 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/IsInWhiteList.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/IsInWhiteList.java
@@ -29,7 +29,7 @@ import javax.mail.MessagingException;
 
 import org.apache.mailet.Experimental;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/IsOverQuota.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/IsOverQuota.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/IsOverQuota.java
index b977e22..f07665d 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/IsOverQuota.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/IsOverQuota.java
@@ -36,7 +36,7 @@ import org.apache.james.mailbox.quota.QuotaRootResolver;
 import org.apache.james.user.api.UsersRepository;
 import org.apache.james.user.api.UsersRepositoryException;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.GenericMatcher;
 
 /**

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/MailboxQuotaFixed.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/MailboxQuotaFixed.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/MailboxQuotaFixed.java
index 3e068b1..cc438fe 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/MailboxQuotaFixed.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/MailboxQuotaFixed.java
@@ -20,7 +20,7 @@ package org.apache.james.transport.matchers;
 
 import org.apache.mailet.Experimental;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.Matcher;
 
 import javax.mail.MessagingException;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/NetworkIsInWhitelist.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/NetworkIsInWhitelist.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/NetworkIsInWhitelist.java
index 8542f85..05fab7d 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/NetworkIsInWhitelist.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/NetworkIsInWhitelist.java
@@ -33,7 +33,7 @@ import org.apache.james.dnsservice.api.DNSService;
 import org.apache.james.dnsservice.library.netmatcher.NetMatcher;
 import org.apache.mailet.Experimental;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/RemoteAddrInNetwork.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/RemoteAddrInNetwork.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/RemoteAddrInNetwork.java
index a75f6c2..2cca1c4 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/RemoteAddrInNetwork.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/RemoteAddrInNetwork.java
@@ -20,7 +20,7 @@
 package org.apache.james.transport.matchers;
 
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 
 import java.util.Collection;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/RemoteAddrNotInNetwork.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/RemoteAddrNotInNetwork.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/RemoteAddrNotInNetwork.java
index 331bc07..6741ce7 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/RemoteAddrNotInNetwork.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/RemoteAddrNotInNetwork.java
@@ -20,7 +20,7 @@
 package org.apache.james.transport.matchers;
 
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 
 import java.util.Collection;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/SenderInFakeDomain.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/SenderInFakeDomain.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/SenderInFakeDomain.java
index 3279118..c28eee0 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/SenderInFakeDomain.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/SenderInFakeDomain.java
@@ -23,7 +23,7 @@ import java.util.Collection;
 
 import org.apache.mailet.Experimental;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/main/java/org/apache/james/transport/util/MailAddressUtils.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/util/MailAddressUtils.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/util/MailAddressUtils.java
index 0a19e1f..708ee4a 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/util/MailAddressUtils.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/util/MailAddressUtils.java
@@ -24,7 +24,7 @@ import javax.mail.internet.AddressException;
 import javax.mail.internet.InternetAddress;
 
 import org.apache.james.transport.mailets.redirect.SpecialAddress;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 
 import com.github.steveash.guavate.Guavate;
 import com.google.common.collect.ImmutableList;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/main/java/org/apache/james/transport/util/RecipientsUtils.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/util/RecipientsUtils.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/util/RecipientsUtils.java
index e1220c1..16c45ac 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/util/RecipientsUtils.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/util/RecipientsUtils.java
@@ -25,7 +25,7 @@ import javax.mail.MessagingException;
 import org.apache.james.transport.mailets.redirect.RedirectNotify;
 import org.apache.james.transport.mailets.redirect.SpecialAddress;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 
 import com.google.common.collect.ImmutableList;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/main/java/org/apache/james/transport/util/ReplyToUtils.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/util/ReplyToUtils.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/util/ReplyToUtils.java
index 58f42fa..1b00a6f 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/util/ReplyToUtils.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/util/ReplyToUtils.java
@@ -23,7 +23,7 @@ import javax.mail.MessagingException;
 
 import org.apache.james.transport.mailets.redirect.SpecialAddress;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 
 public class ReplyToUtils {
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/main/java/org/apache/james/transport/util/SenderUtils.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/util/SenderUtils.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/util/SenderUtils.java
index 0d33658..1caa0a5 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/util/SenderUtils.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/util/SenderUtils.java
@@ -23,7 +23,7 @@ import javax.mail.MessagingException;
 
 import org.apache.james.transport.mailets.redirect.SpecialAddress;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 
 public class SenderUtils {
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/main/java/org/apache/james/transport/util/SpecialAddressesUtils.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/util/SpecialAddressesUtils.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/util/SpecialAddressesUtils.java
index 5e68d80..05507ae 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/util/SpecialAddressesUtils.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/util/SpecialAddressesUtils.java
@@ -32,7 +32,7 @@ import org.apache.james.transport.mailets.redirect.RedirectNotify;
 import org.apache.james.transport.mailets.redirect.SpecialAddress;
 import org.apache.james.transport.mailets.redirect.SpecialAddressKind;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.RFC2822Headers;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/main/java/org/apache/james/transport/util/TosUtils.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/util/TosUtils.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/util/TosUtils.java
index 44c03a1..06176cf 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/util/TosUtils.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/util/TosUtils.java
@@ -26,7 +26,7 @@ import javax.mail.internet.InternetAddress;
 import org.apache.james.transport.mailets.redirect.RedirectNotify;
 import org.apache.james.transport.mailets.redirect.SpecialAddress;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 
 import com.google.common.collect.ImmutableList;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/test/java/org/apache/james/samples/mailets/InstrumentationMailet.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/samples/mailets/InstrumentationMailet.java b/server/mailet/mailets/src/test/java/org/apache/james/samples/mailets/InstrumentationMailet.java
index 557f101..1515afd 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/samples/mailets/InstrumentationMailet.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/samples/mailets/InstrumentationMailet.java
@@ -35,7 +35,7 @@ import javax.mail.internet.NewsAddress;
 
 import org.apache.james.transport.mailets.managesieve.ManageSieveMailet;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.Mailet;
 import org.apache.mailet.MailetConfig;
 import org.slf4j.Logger;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/BounceTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/BounceTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/BounceTest.java
index e5b3e97..cbe0af2 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/BounceTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/BounceTest.java
@@ -32,7 +32,7 @@ import javax.mail.internet.MimeMessage;
 
 import org.apache.james.dnsservice.api.DNSService;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.MailAddressFixture;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMailContext;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/DSNBounceTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/DSNBounceTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/DSNBounceTest.java
index 13d2152..280b3e6 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/DSNBounceTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/DSNBounceTest.java
@@ -38,7 +38,7 @@ import javax.mail.internet.MimeMessage;
 import org.apache.james.dnsservice.api.DNSService;
 import org.apache.james.transport.mailets.redirect.SpecialAddress;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.DateFormats;
 import org.apache.mailet.base.MailAddressFixture;
 import org.apache.mailet.base.RFC2822Headers;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/ForwardTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/ForwardTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/ForwardTest.java
index bc2b318..e3def5f 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/ForwardTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/ForwardTest.java
@@ -30,7 +30,7 @@ import javax.mail.Session;
 import javax.mail.internet.MimeMessage;
 
 import org.apache.james.dnsservice.api.DNSService;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.MailAddressFixture;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMailContext;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/NotifyPostmasterTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/NotifyPostmasterTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/NotifyPostmasterTest.java
index aca75e9..fd455ed 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/NotifyPostmasterTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/NotifyPostmasterTest.java
@@ -32,7 +32,7 @@ import javax.mail.internet.MimeMessage;
 
 import org.apache.james.dnsservice.api.DNSService;
 import org.apache.james.transport.mailets.redirect.SpecialAddress;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.MailAddressFixture;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMailContext;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/NotifySenderTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/NotifySenderTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/NotifySenderTest.java
index b800abc..6b9c6b4 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/NotifySenderTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/NotifySenderTest.java
@@ -32,7 +32,7 @@ import javax.mail.internet.MimeMessage;
 
 import org.apache.james.dnsservice.api.DNSService;
 import org.apache.james.transport.mailets.redirect.SpecialAddress;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.MailAddressFixture;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMailContext;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/RecipientRewriteTableProcessorTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/RecipientRewriteTableProcessorTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/RecipientRewriteTableProcessorTest.java
index 4e31a6f..242c0b3 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/RecipientRewriteTableProcessorTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/RecipientRewriteTableProcessorTest.java
@@ -37,7 +37,7 @@ import org.apache.james.rrt.api.RecipientRewriteTable.ErrorMappingException;
 import org.apache.james.rrt.api.RecipientRewriteTableException;
 import org.apache.james.rrt.lib.MappingsImpl;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.MailAddressFixture;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMailContext;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/RecordingMailContext.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/RecordingMailContext.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/RecordingMailContext.java
index 1fb078c..6866a48 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/RecordingMailContext.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/RecordingMailContext.java
@@ -29,7 +29,7 @@ import javax.mail.internet.MimeMessage;
 import org.apache.mailet.HostAddress;
 import org.apache.mailet.LookupException;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.MailetContext;
 import org.apache.mailet.TemporaryLookupException;
 import org.apache.mailet.base.test.FakeMailContext;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/RedirectTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/RedirectTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/RedirectTest.java
index 3c99341..7f90aab 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/RedirectTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/RedirectTest.java
@@ -29,7 +29,7 @@ import javax.mail.Session;
 import javax.mail.internet.MimeMessage;
 
 import org.apache.james.dnsservice.api.DNSService;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.MailAddressFixture;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMailContext;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/ResendTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/ResendTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/ResendTest.java
index b3b7e5e..aae7a06 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/ResendTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/ResendTest.java
@@ -32,7 +32,7 @@ import javax.mail.Session;
 import javax.mail.internet.MimeMessage;
 
 import org.apache.james.dnsservice.api.DNSService;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.MailAddressFixture;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMailContext;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/ResourceLocatorTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/ResourceLocatorTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/ResourceLocatorTest.java
index 79a12c0..05202af 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/ResourceLocatorTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/ResourceLocatorTest.java
@@ -27,7 +27,7 @@ import org.apache.james.sieverepository.api.SieveRepository;
 import org.apache.james.sieverepository.api.exception.ScriptNotFoundException;
 import org.apache.james.transport.mailets.jsieve.ResourceLocator;
 import org.apache.james.user.api.UsersRepository;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.junit.Before;
 import org.junit.Test;
 


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


[17/23] james-project git commit: JAMES-2138 Implement address/groups endpoints using RRT

Posted by bt...@apache.org.
JAMES-2138 Implement address/groups endpoints using RRT


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/b4218540
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/b4218540
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/b4218540

Branch: refs/heads/master
Commit: b4218540785c8164f0a0555cbb592e244bd0cf5f
Parents: 936746b
Author: Matthieu Baechler <ma...@apache.org>
Authored: Tue Sep 5 17:51:03 2017 +0200
Committer: benwa <bt...@linagora.com>
Committed: Sat Sep 9 10:46:02 2017 +0700

----------------------------------------------------------------------
 .../james/modules/server/DataRoutesModules.java |   2 +
 .../java/org/apache/james/rrt/lib/Mapping.java  |   2 +
 .../org/apache/james/rrt/lib/MappingImpl.java   |  15 +-
 .../apache/james/rrt/lib/MappingImplTest.java   |  21 +
 .../WebAdminServerIntegrationTest.java          |   4 +-
 .../org/apache/james/webadmin/Constants.java    |   1 +
 .../james/webadmin/routes/GroupsRoutes.java     | 214 ++++++++
 .../james/webadmin/routes/GroupsRoutesTest.java | 515 +++++++++++++++++++
 8 files changed, 766 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/b4218540/server/container/guice/protocols/webadmin-data/src/main/java/org/apache/james/modules/server/DataRoutesModules.java
----------------------------------------------------------------------
diff --git a/server/container/guice/protocols/webadmin-data/src/main/java/org/apache/james/modules/server/DataRoutesModules.java b/server/container/guice/protocols/webadmin-data/src/main/java/org/apache/james/modules/server/DataRoutesModules.java
index 48233d7..a279651 100644
--- a/server/container/guice/protocols/webadmin-data/src/main/java/org/apache/james/modules/server/DataRoutesModules.java
+++ b/server/container/guice/protocols/webadmin-data/src/main/java/org/apache/james/modules/server/DataRoutesModules.java
@@ -21,6 +21,7 @@ package org.apache.james.modules.server;
 
 import org.apache.james.webadmin.Routes;
 import org.apache.james.webadmin.routes.DomainsRoutes;
+import org.apache.james.webadmin.routes.GroupsRoutes;
 import org.apache.james.webadmin.routes.UserRoutes;
 
 import com.google.inject.AbstractModule;
@@ -32,6 +33,7 @@ public class DataRoutesModules extends AbstractModule {
     protected void configure() {
         Multibinder<Routes> routesMultibinder = Multibinder.newSetBinder(binder(), Routes.class);
         routesMultibinder.addBinding().to(DomainsRoutes.class);
+        routesMultibinder.addBinding().to(GroupsRoutes.class);
         routesMultibinder.addBinding().to(UserRoutes.class);
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/b4218540/server/data/data-api/src/main/java/org/apache/james/rrt/lib/Mapping.java
----------------------------------------------------------------------
diff --git a/server/data/data-api/src/main/java/org/apache/james/rrt/lib/Mapping.java b/server/data/data-api/src/main/java/org/apache/james/rrt/lib/Mapping.java
index e9ef3b2..2354d22 100644
--- a/server/data/data-api/src/main/java/org/apache/james/rrt/lib/Mapping.java
+++ b/server/data/data-api/src/main/java/org/apache/james/rrt/lib/Mapping.java
@@ -23,6 +23,8 @@ package org.apache.james.rrt.lib;
 
 public interface Mapping {
 
+    String getAddress();
+
     enum Type { Regex, Domain, Error, Address }
 
     Type getType();

http://git-wip-us.apache.org/repos/asf/james-project/blob/b4218540/server/data/data-library/src/main/java/org/apache/james/rrt/lib/MappingImpl.java
----------------------------------------------------------------------
diff --git a/server/data/data-library/src/main/java/org/apache/james/rrt/lib/MappingImpl.java b/server/data/data-library/src/main/java/org/apache/james/rrt/lib/MappingImpl.java
index 4f0c97a..a17df46 100644
--- a/server/data/data-library/src/main/java/org/apache/james/rrt/lib/MappingImpl.java
+++ b/server/data/data-library/src/main/java/org/apache/james/rrt/lib/MappingImpl.java
@@ -92,10 +92,16 @@ public class MappingImpl implements Mapping, Serializable {
     
     @Override
     public String getErrorMessage() {
-        Preconditions.checkState(mapping.startsWith(RecipientRewriteTable.ERROR_PREFIX));
+        Preconditions.checkState(getType() == Type.Error);
         return mapping.substring(RecipientRewriteTable.ERROR_PREFIX.length());
     }
-    
+
+    @Override
+    public String getAddress() {
+        Preconditions.checkState(getType() == Type.Address);
+        return mapping;
+    }
+
     @Override
     public boolean equals(Object other) {
         if (other instanceof MappingImpl) {
@@ -104,15 +110,14 @@ public class MappingImpl implements Mapping, Serializable {
         }
         return false;
     }
-    
+
     @Override
     public int hashCode() {
         return Objects.hashCode(mapping);
     }
-    
+
     @Override
     public String toString() {
         return "MappingImpl{mapping=" + mapping + "}";
     }
-    
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/b4218540/server/data/data-library/src/test/java/org/apache/james/rrt/lib/MappingImplTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-library/src/test/java/org/apache/james/rrt/lib/MappingImplTest.java b/server/data/data-library/src/test/java/org/apache/james/rrt/lib/MappingImplTest.java
index 5844fdc..c4ccce6 100644
--- a/server/data/data-library/src/test/java/org/apache/james/rrt/lib/MappingImplTest.java
+++ b/server/data/data-library/src/test/java/org/apache/james/rrt/lib/MappingImplTest.java
@@ -21,6 +21,7 @@
 package org.apache.james.rrt.lib;
 
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
 import org.junit.Test;
 
@@ -132,4 +133,24 @@ public class MappingImplTest {
     public void toStringShouldReturnValuePrefixedAsByMoreObject() {
         assertThat(MappingImpl.of("value").toString()).isEqualTo("MappingImpl{mapping=value}");
     }
+
+    @Test
+    public void getAddressShouldReturnMappingValueForAddress() {
+        assertThat(MappingImpl.address("value").getAddress()).isEqualTo("value");
+    }
+
+    @Test
+    public void getAddressShouldThrowForError() {
+        assertThatThrownBy(() -> MappingImpl.error("value").getAddress()).isInstanceOf(IllegalStateException.class);
+    }
+
+    @Test
+    public void getAddressShouldThrowForRegex() {
+        assertThatThrownBy(() -> MappingImpl.regex("value").getAddress()).isInstanceOf(IllegalStateException.class);
+    }
+
+    @Test
+    public void getAddressShouldThrowForDomain() {
+        assertThatThrownBy(() -> MappingImpl.domain("value").getAddress()).isInstanceOf(IllegalStateException.class);
+    }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/b4218540/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/WebAdminServerIntegrationTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/WebAdminServerIntegrationTest.java b/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/WebAdminServerIntegrationTest.java
index 919ac42..6835242 100644
--- a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/WebAdminServerIntegrationTest.java
+++ b/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/WebAdminServerIntegrationTest.java
@@ -268,9 +268,7 @@ public class WebAdminServerIntegrationTest {
             .body(containsString("\"tags\":[\"GlobalQuota\"]"))
             .body(containsString("\"tags\":[\"Domains\"]"))
             .body(containsString("\"tags\":[\"Users\"]"))
-        ;
+            .body(containsString("\"tags\":[\"Address Groups\"]"));
     }
 
-    //TODO: check Groups full path
-
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/b4218540/server/protocols/webadmin/webadmin-core/src/main/java/org/apache/james/webadmin/Constants.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-core/src/main/java/org/apache/james/webadmin/Constants.java b/server/protocols/webadmin/webadmin-core/src/main/java/org/apache/james/webadmin/Constants.java
index 1031a86..70cfbbb 100644
--- a/server/protocols/webadmin/webadmin-core/src/main/java/org/apache/james/webadmin/Constants.java
+++ b/server/protocols/webadmin/webadmin-core/src/main/java/org/apache/james/webadmin/Constants.java
@@ -23,5 +23,6 @@ public interface Constants {
 
     String SEPARATOR = "/";
     String EMPTY_BODY = "";
+    String JSON_CONTENT_TYPE = "application/json";
 
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/b4218540/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/GroupsRoutes.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/GroupsRoutes.java b/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/GroupsRoutes.java
new file mode 100644
index 0000000..f47fda1
--- /dev/null
+++ b/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/GroupsRoutes.java
@@ -0,0 +1,214 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.webadmin.routes;
+
+import static org.apache.james.webadmin.Constants.SEPARATOR;
+import static spark.Spark.halt;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+
+import javax.inject.Inject;
+import javax.mail.internet.AddressException;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+
+import org.apache.james.core.MailAddress;
+import org.apache.james.domainlist.api.DomainList;
+import org.apache.james.domainlist.api.DomainListException;
+import org.apache.james.rrt.api.RecipientRewriteTable;
+import org.apache.james.rrt.api.RecipientRewriteTableException;
+import org.apache.james.rrt.lib.Mapping;
+import org.apache.james.rrt.lib.Mappings;
+import org.apache.james.user.api.UsersRepository;
+import org.apache.james.user.api.UsersRepositoryException;
+import org.apache.james.util.streams.Iterators;
+import org.apache.james.webadmin.Constants;
+import org.apache.james.webadmin.Routes;
+import org.apache.james.webadmin.utils.JsonExtractException;
+import org.apache.james.webadmin.utils.JsonTransformer;
+import org.eclipse.jetty.http.HttpStatus;
+
+import com.github.steveash.guavate.Guavate;
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.collect.ImmutableSortedSet;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
+import spark.HaltException;
+import spark.Request;
+import spark.Response;
+import spark.Service;
+
+@Api(tags = "Address Groups")
+@Path(GroupsRoutes.ROOT_PATH)
+@Produces(Constants.JSON_CONTENT_TYPE)
+public class GroupsRoutes implements Routes {
+
+    public static final String ROOT_PATH = "address/groups";
+    private static final String GROUP_ADDRESS = "groupAddress";
+    private static final String GROUP_ADDRESS_PATH = ROOT_PATH + SEPARATOR + ":" + GROUP_ADDRESS;
+    private static final String USER_ADDRESS = "userAddress";
+    private static final String USER_IN_GROUP_ADDRESS_PATH = GROUP_ADDRESS_PATH + SEPARATOR + ":" + USER_ADDRESS;
+
+    private final UsersRepository usersRepository;
+    private final DomainList domainList;
+    private final JsonTransformer jsonTransformer;
+    private final RecipientRewriteTable recipientRewriteTable;
+
+    @Inject
+    @VisibleForTesting
+    GroupsRoutes(RecipientRewriteTable recipientRewriteTable, UsersRepository usersRepository,
+                 DomainList domainList, JsonTransformer jsonTransformer) {
+        this.usersRepository = usersRepository;
+        this.domainList = domainList;
+        this.jsonTransformer = jsonTransformer;
+        this.recipientRewriteTable = recipientRewriteTable;
+    }
+
+    @Override
+    public void define(Service service) {
+        service.get(ROOT_PATH, this::listGroups, jsonTransformer);
+        service.get(GROUP_ADDRESS_PATH, this::listGroupMembers, jsonTransformer);
+        service.put(GROUP_ADDRESS_PATH, (request, response) -> halt(HttpStatus.BAD_REQUEST_400));
+        service.put(USER_IN_GROUP_ADDRESS_PATH, this::addToGroup);
+        service.delete(GROUP_ADDRESS_PATH, (request, response) -> halt(HttpStatus.BAD_REQUEST_400));
+        service.delete(USER_IN_GROUP_ADDRESS_PATH, this::removeFromGroup);
+    }
+
+    @GET
+    @Path(ROOT_PATH)
+    @ApiOperation(value = "getting groups list")
+    @ApiResponses(value = {
+        @ApiResponse(code = 200, message = "OK", response = List.class),
+        @ApiResponse(code = 500, message = "Internal server error - Something went bad on the server side.")
+    })
+    public Set<String> listGroups(Request request, Response response) throws RecipientRewriteTableException {
+        return Optional.ofNullable(recipientRewriteTable.getAllMappings())
+            .map(mappings ->
+                mappings.entrySet().stream()
+                    .filter(e -> e.getValue().contains(Mapping.Type.Address))
+                    .map(Map.Entry::getKey)
+                    .collect(Guavate.toImmutableSortedSet()))
+            .orElse(ImmutableSortedSet.of());
+    }
+
+    @PUT
+    @Path(ROOT_PATH + "/{" + GROUP_ADDRESS + "}/{" + USER_ADDRESS + "}")
+    @ApiOperation(value = "adding a member into a group")
+    @ApiImplicitParams({
+        @ApiImplicitParam(required = true, dataType = "string", name = GROUP_ADDRESS, paramType = "path"),
+        @ApiImplicitParam(required = true, dataType = "string", name = USER_ADDRESS, paramType = "path")
+    })
+    @ApiResponses(value = {
+        @ApiResponse(code = 200, message = "OK", response = List.class),
+        @ApiResponse(code = 400, message = GROUP_ADDRESS + " or group structure format is not valid"),
+        @ApiResponse(code = 403, message = "server doesn't own the domain"),
+        @ApiResponse(code = 409, message = "requested group address is already used for another purpose"),
+        @ApiResponse(code = 500, message = "Internal server error - Something went bad on the server side.")
+    })
+    public HaltException addToGroup(Request request, Response response) throws JsonExtractException, AddressException, RecipientRewriteTableException, UsersRepositoryException, DomainListException {
+        MailAddress groupAddress = parseMailAddress(request.params(GROUP_ADDRESS));
+        ensureRegisteredDomain(groupAddress.getDomain());
+        ensureNotShadowingAnotherAddress(groupAddress);
+        MailAddress userAddress = parseMailAddress(request.params(USER_ADDRESS));
+        recipientRewriteTable.addAddressMapping(groupAddress.getLocalPart(), groupAddress.getDomain(), userAddress.asString());
+        return halt(HttpStatus.CREATED_201);
+    }
+
+    private void ensureRegisteredDomain(String domain) throws DomainListException {
+        if (!domainList.containsDomain(domain)) {
+            throw halt(HttpStatus.FORBIDDEN_403);
+        }
+    }
+
+    private void ensureNotShadowingAnotherAddress(MailAddress groupAddress) throws UsersRepositoryException {
+        if (usersRepository.contains(groupAddress.asString())) {
+            throw halt(HttpStatus.CONFLICT_409);
+        }
+    }
+
+
+    @DELETE
+    @Path(ROOT_PATH + "/{" + GROUP_ADDRESS + "}/{" + USER_ADDRESS + "}")
+    @ApiOperation(value = "remove a member from a group")
+    @ApiImplicitParams({
+        @ApiImplicitParam(required = true, dataType = "string", name = GROUP_ADDRESS, paramType = "path"),
+        @ApiImplicitParam(required = true, dataType = "string", name = USER_ADDRESS, paramType = "path")
+    })
+    @ApiResponses(value = {
+        @ApiResponse(code = 200, message = "OK", response = List.class),
+        @ApiResponse(code = 400, message = GROUP_ADDRESS + " or group structure format is not valid"),
+        @ApiResponse(code = 500, message = "Internal server error - Something went bad on the server side.")
+    })
+    public HaltException removeFromGroup(Request request, Response response) throws JsonExtractException, AddressException, RecipientRewriteTableException {
+        MailAddress groupAddress = parseMailAddress(request.params(GROUP_ADDRESS));
+        MailAddress userAddress = parseMailAddress(request.params(USER_ADDRESS));
+        recipientRewriteTable.removeAddressMapping(groupAddress.getLocalPart(), groupAddress.getDomain(), userAddress.asString());
+        return halt(HttpStatus.OK_200);
+    }
+
+    @GET
+    @Path(ROOT_PATH + "/{" + GROUP_ADDRESS + "}")
+    @ApiOperation(value = "listing group members")
+    @ApiImplicitParams({
+        @ApiImplicitParam(required = true, dataType = "string", name = GROUP_ADDRESS, paramType = "path")
+    })
+    @ApiResponses(value = {
+        @ApiResponse(code = 200, message = "OK", response = List.class),
+        @ApiResponse(code = 400, message = "The group is not an address"),
+        @ApiResponse(code = 404, message = "The group does not exist"),
+        @ApiResponse(code = 500, message = "Internal server error - Something went bad on the server side.")
+    })
+    public ImmutableSortedSet<String> listGroupMembers(Request request, Response response) throws RecipientRewriteTable.ErrorMappingException, RecipientRewriteTableException {
+        MailAddress groupAddress = parseMailAddress(request.params(GROUP_ADDRESS));
+        Mappings mappings = recipientRewriteTable.getMappings(groupAddress.getLocalPart(), groupAddress.getDomain());
+
+        ensureNonEmptyMappings(mappings);
+
+        return Iterators
+                .toStream(mappings.select(Mapping.Type.Address).iterator())
+                .map(Mapping::getAddress)
+                .collect(Guavate.toImmutableSortedSet());
+    }
+
+    private MailAddress parseMailAddress(String address) {
+        try {
+            return new MailAddress(address);
+        } catch (AddressException e) {
+            throw halt(HttpStatus.BAD_REQUEST_400);
+        }
+    }
+
+    private void ensureNonEmptyMappings(Mappings mappings) {
+        if (mappings == null || mappings.isEmpty()) {
+            throw halt(HttpStatus.NOT_FOUND_404);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/b4218540/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/GroupsRoutesTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/GroupsRoutesTest.java b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/GroupsRoutesTest.java
new file mode 100644
index 0000000..f866f6a
--- /dev/null
+++ b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/GroupsRoutesTest.java
@@ -0,0 +1,515 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.webadmin.routes;
+
+import static com.jayway.restassured.RestAssured.given;
+import static com.jayway.restassured.RestAssured.when;
+import static com.jayway.restassured.config.EncoderConfig.encoderConfig;
+import static com.jayway.restassured.config.RestAssuredConfig.newConfig;
+import static org.apache.james.webadmin.Constants.SEPARATOR;
+import static org.apache.james.webadmin.WebAdminServer.NO_CONFIGURATION;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.hamcrest.CoreMatchers.is;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.mock;
+
+import java.nio.charset.StandardCharsets;
+import java.util.List;
+
+import org.apache.james.dnsservice.api.DNSService;
+import org.apache.james.domainlist.api.DomainList;
+import org.apache.james.domainlist.api.DomainListException;
+import org.apache.james.domainlist.memory.MemoryDomainList;
+import org.apache.james.metrics.logger.DefaultMetricFactory;
+import org.apache.james.rrt.api.RecipientRewriteTable;
+import org.apache.james.rrt.api.RecipientRewriteTableException;
+import org.apache.james.rrt.memory.MemoryRecipientRewriteTable;
+import org.apache.james.user.api.UsersRepository;
+import org.apache.james.user.api.UsersRepositoryException;
+import org.apache.james.user.memory.MemoryUsersRepository;
+import org.apache.james.webadmin.WebAdminServer;
+import org.apache.james.webadmin.utils.JsonTransformer;
+import org.eclipse.jetty.http.HttpStatus;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mockito;
+
+import com.jayway.restassured.RestAssured;
+import com.jayway.restassured.builder.RequestSpecBuilder;
+import com.jayway.restassured.filter.log.LogDetail;
+import com.jayway.restassured.http.ContentType;
+import de.bechte.junit.runners.context.HierarchicalContextRunner;
+
+@RunWith(HierarchicalContextRunner.class)
+public class GroupsRoutesTest {
+
+    private static final String DOMAIN = "b.com";
+    private static final String GROUP1 = "group1" + "@" + DOMAIN;
+    private static final String GROUP2 = "group2" + "@" + DOMAIN;
+    private static final String USER_A = "a" + "@" + DOMAIN;
+    private static final String USER_B = "b" + "@" + DOMAIN;
+
+    private WebAdminServer webAdminServer;
+
+    private void createServer(GroupsRoutes groupsRoutes) throws Exception {
+        webAdminServer = new WebAdminServer(
+            new DefaultMetricFactory(),
+            groupsRoutes);
+        webAdminServer.configure(NO_CONFIGURATION);
+        webAdminServer.await();
+
+        RestAssured.requestSpecification = new RequestSpecBuilder()
+            .setContentType(ContentType.JSON)
+            .setAccept(ContentType.JSON)
+            .setConfig(newConfig().encoderConfig(encoderConfig().defaultContentCharset(StandardCharsets.UTF_8)))
+            .setPort(webAdminServer.getPort().toInt())
+            .setBasePath(GroupsRoutes.ROOT_PATH)
+            .log(LogDetail.ALL)
+            .build();
+    }
+
+    @After
+    public void stop() {
+        webAdminServer.destroy();
+    }
+
+    public class NormalBehaviour {
+
+        MemoryUsersRepository usersRepository;
+        MemoryDomainList domainList;
+        MemoryRecipientRewriteTable memoryRecipientRewriteTable;
+
+        @Before
+        public void setUp() throws Exception {
+            memoryRecipientRewriteTable = new MemoryRecipientRewriteTable();
+            DNSService dnsService = mock(DNSService.class);
+            domainList = new MemoryDomainList(dnsService);
+            domainList.addDomain(DOMAIN);
+            usersRepository = MemoryUsersRepository.withVirtualHosting();
+            usersRepository.setDomainList(domainList);
+            createServer(new GroupsRoutes(memoryRecipientRewriteTable, usersRepository, domainList, new JsonTransformer()));
+        }
+
+        @Test
+        public void getGroupsShouldBeEmpty() {
+            when()
+                .get()
+            .then()
+                .contentType(ContentType.JSON)
+                .statusCode(HttpStatus.OK_200)
+                .body(is("[]"));
+        }
+
+        @Test
+        public void getGroupsShouldListExistingGroupsInOrder() {
+            given()
+                .put(GROUP2 + SEPARATOR + USER_A);
+
+            given()
+                .put(GROUP1 + SEPARATOR + USER_A);
+
+            List<String> addresses =
+                when()
+                    .get()
+                .then()
+                    .contentType(ContentType.JSON)
+                    .statusCode(HttpStatus.OK_200)
+                    .extract()
+                    .body()
+                    .jsonPath()
+                    .getList(".");
+            assertThat(addresses).containsExactly(GROUP1, GROUP2);
+        }
+
+        @Test
+        public void getUnregisteredGroupShouldReturnNotFound() {
+            when()
+                .get("unknown@domain.travel")
+            .then()
+                .statusCode(HttpStatus.NOT_FOUND_404);
+        }
+
+        @Test
+        public void putUserInGroupShouldReturnCreated() {
+            when()
+                .put(GROUP1 + SEPARATOR + USER_A)
+            .then()
+                .statusCode(HttpStatus.CREATED_201);
+        }
+
+        @Test
+        public void putUserInGroupShouldCreateGroup() {
+            when()
+                .put(GROUP1 + SEPARATOR + USER_A);
+
+            List<String> addresses =
+                when()
+                    .get(GROUP1)
+                .then()
+                    .contentType(ContentType.JSON)
+                    .statusCode(HttpStatus.OK_200)
+                    .extract()
+                    .body()
+                    .jsonPath()
+                    .getList(".");
+            assertThat(addresses).containsExactly(USER_A);
+        }
+
+        @Test
+        public void putSameUserInGroupTwiceShouldBeIdempotent() {
+            given()
+                .put(GROUP1 + SEPARATOR + USER_A);
+
+            when()
+                .put(GROUP1 + SEPARATOR + USER_A);
+
+            List<String> addresses =
+                when()
+                    .get(GROUP1)
+                .then()
+                    .contentType(ContentType.JSON)
+                    .statusCode(HttpStatus.OK_200)
+                    .extract()
+                    .body()
+                    .jsonPath()
+                    .getList(".");
+            assertThat(addresses).containsExactly(USER_A);
+        }
+
+        @Test
+        public void putUserInGroupShouldAllowSeveralUsers() {
+            given()
+                .put(GROUP1 + SEPARATOR + USER_A);
+
+            given()
+                .put(GROUP1 + SEPARATOR + USER_B);
+
+            List<String> addresses =
+                when()
+                    .get(GROUP1)
+                .then()
+                    .contentType(ContentType.JSON)
+                    .statusCode(HttpStatus.OK_200)
+                    .extract()
+                    .body()
+                    .jsonPath()
+                    .getList(".");
+            assertThat(addresses).containsExactly(USER_A, USER_B);
+        }
+
+        @Test
+        public void putUserInGroupShouldNotAllowGroupOnUnregisteredDomain() throws UsersRepositoryException, DomainListException {
+            when()
+                .put("group@unregisteredDomain" + SEPARATOR + USER_A)
+            .then()
+                .contentType(ContentType.JSON)
+                .statusCode(HttpStatus.FORBIDDEN_403);
+        }
+
+
+        @Test
+        public void putUserInGroupShouldNotAllowUserShadowing() throws UsersRepositoryException, DomainListException {
+            usersRepository.addUser(USER_A, "whatever");
+
+            when()
+                .put(USER_A + SEPARATOR + USER_B)
+            .then()
+                .contentType(ContentType.JSON)
+                .statusCode(HttpStatus.CONFLICT_409);
+        }
+
+        @Test
+        public void getGroupShouldReturnMembersInOrder() {
+            given()
+                .put(GROUP1 + SEPARATOR + USER_B);
+
+            given()
+                .put(GROUP1 + SEPARATOR + USER_A);
+
+            List<String> addresses =
+                when()
+                    .get(GROUP1)
+                .then()
+                    .contentType(ContentType.JSON)
+                    .statusCode(HttpStatus.OK_200)
+                    .extract()
+                    .body()
+                    .jsonPath()
+                    .getList(".");
+            assertThat(addresses).containsExactly(USER_A, USER_B);
+        }
+
+
+        @Test
+        public void deleteUserNotInGroupShouldReturnOK() {
+            when()
+                .delete(GROUP1 + SEPARATOR + USER_A)
+            .then()
+                .statusCode(HttpStatus.OK_200);
+        }
+
+        @Test
+        public void deleteLastUserInGroupShouldDeleteGroup() {
+            given()
+                .put(GROUP1 + SEPARATOR + USER_A);
+
+            given()
+                .delete(GROUP1 + SEPARATOR + USER_A);
+
+            when()
+                .get()
+            .then()
+                .contentType(ContentType.JSON)
+                .statusCode(HttpStatus.OK_200)
+                .body(is("[]"));
+        }
+    }
+
+    public class FilteringOtherRewriteRuleTypes extends NormalBehaviour {
+
+        @Before
+        public void setup() throws Exception {
+            super.setUp();
+            memoryRecipientRewriteTable.addErrorMapping("error", DOMAIN, "disabled");
+            memoryRecipientRewriteTable.addRegexMapping("regex", DOMAIN, ".*@b\\.com");
+            memoryRecipientRewriteTable.addAliasDomainMapping("alias", DOMAIN);
+
+        }
+
+    }
+
+    public class ExceptionHandling {
+
+        private RecipientRewriteTable memoryRecipientRewriteTable;
+
+        @Before
+        public void setUp() throws Exception {
+            memoryRecipientRewriteTable = mock(RecipientRewriteTable.class);
+            UsersRepository userRepository = mock(UsersRepository.class);
+            DomainList domainList = mock(DomainList.class);
+            Mockito.when(domainList.containsDomain(anyString())).thenReturn(true);
+            createServer(new GroupsRoutes(memoryRecipientRewriteTable, userRepository, domainList, new JsonTransformer()));
+        }
+
+        @Test
+        public void getMalformedGroupShouldReturnBadRequest() {
+            when()
+                .get("not-an-address")
+            .then()
+                .statusCode(HttpStatus.BAD_REQUEST_400);
+        }
+
+        @Test
+        public void putMalformedGroupShouldReturnBadRequest() {
+            when()
+                .put("not-an-address" + SEPARATOR + USER_A)
+            .then()
+                .statusCode(HttpStatus.BAD_REQUEST_400);
+        }
+
+        @Test
+        public void putMalformedAddressShouldReturnBadRequest() {
+            when()
+                .put(GROUP1 + SEPARATOR + "not-an-address")
+            .then()
+                .statusCode(HttpStatus.BAD_REQUEST_400);
+        }
+
+        @Test
+        public void putRequiresTwoPathParams() {
+            when()
+                .put(GROUP1)
+            .then()
+                .statusCode(HttpStatus.BAD_REQUEST_400);
+        }
+
+        @Test
+        public void deleteMalformedGroupShouldReturnBadRequest() {
+            when()
+                .delete("not-an-address" + SEPARATOR + USER_A)
+            .then()
+                .statusCode(HttpStatus.BAD_REQUEST_400);
+        }
+
+        @Test
+        public void deleteMalformedAddressShouldReturnBadRequest() {
+            when()
+                .delete(GROUP1 + SEPARATOR + "not-an-address")
+            .then()
+                .statusCode(HttpStatus.BAD_REQUEST_400);
+        }
+
+        @Test
+        public void deleteRequiresTwoPathParams() {
+            when()
+                .delete(GROUP1)
+            .then()
+                .statusCode(HttpStatus.BAD_REQUEST_400);
+        }
+
+        @Test
+        public void putShouldReturnErrorWhenRecipientRewriteTableExceptionIsThrown() throws Exception {
+            doThrow(RecipientRewriteTableException.class)
+                .when(memoryRecipientRewriteTable)
+                .addAddressMapping(anyString(), anyString(), anyString());
+
+            when()
+                .put(GROUP1 + SEPARATOR + GROUP2)
+            .then()
+                .statusCode(HttpStatus.INTERNAL_SERVER_ERROR_500);
+        }
+
+        @Test
+        public void putShouldReturnErrorWhenErrorMappingExceptionIsThrown() throws Exception {
+            doThrow(RecipientRewriteTable.ErrorMappingException.class)
+                .when(memoryRecipientRewriteTable)
+                .addAddressMapping(anyString(), anyString(), anyString());
+
+            when()
+                .put(GROUP1 + SEPARATOR + GROUP2)
+            .then()
+                .statusCode(HttpStatus.INTERNAL_SERVER_ERROR_500);
+        }
+
+        @Test
+        public void putShouldReturnErrorWhenRuntimeExceptionIsThrown() throws Exception {
+            doThrow(RuntimeException.class)
+                .when(memoryRecipientRewriteTable)
+                .addAddressMapping(anyString(), anyString(), anyString());
+
+            when()
+                .put(GROUP1 + SEPARATOR + GROUP2)
+            .then()
+                .statusCode(HttpStatus.INTERNAL_SERVER_ERROR_500);
+        }
+
+        @Test
+        public void getAllShouldReturnErrorWhenRecipientRewriteTableExceptionIsThrown() throws Exception {
+            doThrow(RecipientRewriteTableException.class)
+                .when(memoryRecipientRewriteTable)
+                .getAllMappings();
+
+            when()
+                .get()
+            .then()
+                .statusCode(HttpStatus.INTERNAL_SERVER_ERROR_500);
+        }
+
+        @Test
+        public void getAllShouldReturnErrorWhenErrorMappingExceptionIsThrown() throws Exception {
+            doThrow(RecipientRewriteTable.ErrorMappingException.class)
+                .when(memoryRecipientRewriteTable)
+                .getAllMappings();
+
+            when()
+                .get()
+            .then()
+                .statusCode(HttpStatus.INTERNAL_SERVER_ERROR_500);
+        }
+
+        @Test
+        public void getAllShouldReturnErrorWhenRuntimeExceptionIsThrown() throws Exception {
+            doThrow(RuntimeException.class)
+                .when(memoryRecipientRewriteTable)
+                .getAllMappings();
+
+            when()
+                .get()
+            .then()
+                .statusCode(HttpStatus.INTERNAL_SERVER_ERROR_500);
+        }
+
+        @Test
+        public void deleteShouldReturnErrorWhenRecipientRewriteTableExceptionIsThrown() throws Exception {
+            doThrow(RecipientRewriteTableException.class)
+                .when(memoryRecipientRewriteTable)
+                .removeAddressMapping(anyString(), anyString(), anyString());
+
+            when()
+                .delete(GROUP1 + SEPARATOR + GROUP2)
+            .then()
+                .statusCode(HttpStatus.INTERNAL_SERVER_ERROR_500);
+        }
+
+        @Test
+        public void deleteShouldReturnErrorWhenErrorMappingExceptionIsThrown() throws Exception {
+            doThrow(RecipientRewriteTable.ErrorMappingException.class)
+                .when(memoryRecipientRewriteTable)
+                .removeAddressMapping(anyString(), anyString(), anyString());
+
+            when()
+                .delete(GROUP1 + SEPARATOR + GROUP2)
+            .then()
+                .statusCode(HttpStatus.INTERNAL_SERVER_ERROR_500);
+        }
+
+        @Test
+        public void deleteShouldReturnErrorWhenRuntimeExceptionIsThrown() throws Exception {
+            doThrow(RuntimeException.class)
+                .when(memoryRecipientRewriteTable)
+                .removeAddressMapping(anyString(), anyString(), anyString());
+
+            when()
+                .delete(GROUP1 + SEPARATOR + GROUP2)
+            .then()
+                .statusCode(HttpStatus.INTERNAL_SERVER_ERROR_500);
+        }
+
+        @Test
+        public void getShouldReturnErrorWhenRecipientRewriteTableExceptionIsThrown() throws Exception {
+            doThrow(RecipientRewriteTableException.class)
+                .when(memoryRecipientRewriteTable)
+                .getMappings(anyString(), anyString());
+
+            when()
+                .get(GROUP1)
+            .then()
+                .statusCode(HttpStatus.INTERNAL_SERVER_ERROR_500);
+        }
+
+        @Test
+        public void getShouldReturnErrorWhenErrorMappingExceptionIsThrown() throws Exception {
+            doThrow(RecipientRewriteTable.ErrorMappingException.class)
+                .when(memoryRecipientRewriteTable)
+                .getMappings(anyString(), anyString());
+
+            when()
+                .get(GROUP1)
+            .then()
+                .statusCode(HttpStatus.INTERNAL_SERVER_ERROR_500);
+        }
+
+        @Test
+        public void getShouldReturnErrorWhenRuntimeExceptionIsThrown() throws Exception {
+            doThrow(RuntimeException.class)
+                .when(memoryRecipientRewriteTable)
+                .getMappings(anyString(), anyString());
+
+            when()
+                .get(GROUP1)
+            .then()
+                .statusCode(HttpStatus.INTERNAL_SERVER_ERROR_500);
+        }
+    }
+
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


[03/23] james-project git commit: JAMES-2138 upgrade some code to java-8 style

Posted by bt...@apache.org.
JAMES-2138 upgrade some code to java-8 style


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/73b650ed
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/73b650ed
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/73b650ed

Branch: refs/heads/master
Commit: 73b650ed781e41dfba622fab4071af59956ad1c4
Parents: 2c411e8
Author: Matthieu Baechler <ma...@apache.org>
Authored: Mon Sep 4 10:01:38 2017 +0200
Committer: benwa <bt...@linagora.com>
Committed: Sat Sep 9 10:40:29 2017 +0700

----------------------------------------------------------------------
 .../apache/james/webadmin/routes/CORSRoute.java    | 17 +++++++++--------
 .../james/webadmin/routes/DomainRoutesTest.java    |  5 ++---
 .../james/webadmin/routes/UsersRoutesTest.java     |  6 +++---
 3 files changed, 14 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/73b650ed/server/protocols/webadmin/webadmin-core/src/main/java/org/apache/james/webadmin/routes/CORSRoute.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-core/src/main/java/org/apache/james/webadmin/routes/CORSRoute.java b/server/protocols/webadmin/webadmin-core/src/main/java/org/apache/james/webadmin/routes/CORSRoute.java
index 39e9bd7..e966667 100644
--- a/server/protocols/webadmin/webadmin-core/src/main/java/org/apache/james/webadmin/routes/CORSRoute.java
+++ b/server/protocols/webadmin/webadmin-core/src/main/java/org/apache/james/webadmin/routes/CORSRoute.java
@@ -19,6 +19,8 @@
 
 package org.apache.james.webadmin.routes;
 
+import java.util.Optional;
+
 import org.apache.james.webadmin.Routes;
 
 import spark.Service;
@@ -28,14 +30,13 @@ public class CORSRoute implements Routes {
     @Override
     public void define(Service service) {
         service.options("/*", (request, response) -> {
-            String accessControlRequestHeaders = request.headers("Access-Control-Request-Headers");
-            if (accessControlRequestHeaders != null) {
-                response.header("Access-Control-Allow-Headers", accessControlRequestHeaders);
-            }
-            String accessControlRequestMethod = request.headers("Access-Control-Request-Method");
-            if (accessControlRequestMethod != null) {
-                response.header("Access-Control-Allow-Methods", accessControlRequestMethod);
-            }
+
+            Optional.ofNullable(request.headers("Access-Control-Request-Headers"))
+                .ifPresent(header -> response.header("Access-Control-Allow-Headers", header));
+
+            Optional.ofNullable(request.headers("Access-Control-Request-Method"))
+                .ifPresent(header -> response.header("Access-Control-Allow-Methods", header));
+
             return "";
         });
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/73b650ed/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/DomainRoutesTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/DomainRoutesTest.java b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/DomainRoutesTest.java
index 511638a..f17acd3 100644
--- a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/DomainRoutesTest.java
+++ b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/DomainRoutesTest.java
@@ -34,6 +34,7 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 import java.net.InetAddress;
+import java.nio.charset.StandardCharsets;
 
 import org.apache.james.dnsservice.api.DNSService;
 import org.apache.james.domainlist.api.DomainList;
@@ -47,11 +48,9 @@ import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
-import com.google.common.base.Charsets;
 import com.jayway.restassured.RestAssured;
 import com.jayway.restassured.builder.RequestSpecBuilder;
 import com.jayway.restassured.http.ContentType;
-
 import de.bechte.junit.runners.context.HierarchicalContextRunner;
 
 @RunWith(HierarchicalContextRunner.class)
@@ -70,7 +69,7 @@ public class DomainRoutesTest {
         RestAssured.requestSpecification = new RequestSpecBuilder()
         		.setContentType(ContentType.JSON)
         		.setAccept(ContentType.JSON)
-        		.setConfig(newConfig().encoderConfig(encoderConfig().defaultContentCharset(Charsets.UTF_8)))
+        		.setConfig(newConfig().encoderConfig(encoderConfig().defaultContentCharset(StandardCharsets.UTF_8)))
         		.setPort(webAdminServer.getPort().toInt())
         		.setBasePath(DomainRoutes.DOMAINS)
         		.build();

http://git-wip-us.apache.org/repos/asf/james-project/blob/73b650ed/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/UsersRoutesTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/UsersRoutesTest.java b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/UsersRoutesTest.java
index 684ea9b..cba4019 100644
--- a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/UsersRoutesTest.java
+++ b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/UsersRoutesTest.java
@@ -32,6 +32,8 @@ import static org.mockito.Mockito.doThrow;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
+import java.nio.charset.StandardCharsets;
+
 import org.apache.james.domainlist.api.DomainList;
 import org.apache.james.metrics.logger.DefaultMetricFactory;
 import org.apache.james.user.api.UsersRepository;
@@ -46,11 +48,9 @@ import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
-import com.google.common.base.Charsets;
 import com.jayway.restassured.RestAssured;
 import com.jayway.restassured.builder.RequestSpecBuilder;
 import com.jayway.restassured.http.ContentType;
-
 import de.bechte.junit.runners.context.HierarchicalContextRunner;
 
 @RunWith(HierarchicalContextRunner.class)
@@ -70,7 +70,7 @@ public class UsersRoutesTest {
         RestAssured.requestSpecification = new RequestSpecBuilder()
         		.setContentType(ContentType.JSON)
         		.setAccept(ContentType.JSON)
-        		.setConfig(newConfig().encoderConfig(encoderConfig().defaultContentCharset(Charsets.UTF_8)))
+        		.setConfig(newConfig().encoderConfig(encoderConfig().defaultContentCharset(StandardCharsets.UTF_8)))
         		.setPort(webAdminServer.getPort().toInt())
         		.setBasePath(UserRoutes.USERS)
         		.build();


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


[15/23] james-project git commit: JAMES-2138 move MailAddress to a new james-core project

Posted by bt...@apache.org.
http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/api/src/test/java/org/apache/mailet/MailAddressTest.java
----------------------------------------------------------------------
diff --git a/mailet/api/src/test/java/org/apache/mailet/MailAddressTest.java b/mailet/api/src/test/java/org/apache/mailet/MailAddressTest.java
deleted file mode 100644
index aa63231..0000000
--- a/mailet/api/src/test/java/org/apache/mailet/MailAddressTest.java
+++ /dev/null
@@ -1,229 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-
-package org.apache.mailet;
-
-import org.junit.Test;
-
-import javax.mail.internet.AddressException;
-import javax.mail.internet.InternetAddress;
-
-import static org.junit.Assert.*;
-
-public class MailAddressTest {
-
-    private static final String
-            GOOD_LOCAL_PART = "\"quoted@local part\"",
-            GOOD_QUOTED_LOCAL_PART = "\"quoted@local part\"@james.apache.org",
-            GOOD_ADDRESS = "server-dev@james.apache.org",
-            GOOD_DOMAIN = "james.apache.org";
-
-    private static final String[] GOOD_ADDRESSES = {
-            GOOD_ADDRESS,
-            GOOD_QUOTED_LOCAL_PART,
-            "server-dev@james-apache.org",
-            "server-dev@[127.0.0.1]",
-            "server-dev@#123",
-            "server-dev@#123.apache.org",
-            "server.dev@james.apache.org",
-            "\\.server-dev@james.apache.org",
-            "server-dev\\.@james.apache.org",
-    };
-
-    private static final String[] BAD_ADDRESSES = {
-            "",
-            "server-dev",
-            "server-dev@",
-            "[]",
-            "server-dev@[]",
-            "server-dev@#",
-            "quoted local-part@james.apache.org",
-            "quoted@local-part@james.apache.org",
-            "local-part.@james.apache.org",
-            ".local-part@james.apache.org",
-            "local-part@.james.apache.org",
-            "local-part@james.apache.org.",
-            "local-part@james.apache..org",
-            "server-dev@-james.apache.org",
-            "server-dev@james.apache.org-",
-            "server-dev@#james.apache.org",
-            "server-dev@#123james.apache.org",
-            "server-dev@#-123.james.apache.org",
-            "server-dev@james. apache.org",
-            "server-dev@james\\.apache.org",
-            "server-dev@[300.0.0.1]",
-            "server-dev@[127.0.1]",
-            "server-dev@[0127.0.0.1]",
-            "server-dev@[127.0.1.1a]",
-            "server-dev@[127\\.0.1.1]",
-            "server-dev@[127.0.1.1.1]",
-            "server-dev@[127.0.1.-1]"
-    };
-
-    /**
-     * Test method for {@link org.apache.mailet.MailAddress#hashCode()}.
-     *
-     * @throws AddressException
-     */
-    @Test
-    public void testHashCode() throws AddressException {
-
-        MailAddress a = new MailAddress(GOOD_ADDRESS);
-        MailAddress b = new MailAddress(GOOD_ADDRESS);
-        assertTrue(a.hashCode() + " != " + b.hashCode(), a.hashCode() == b.hashCode());
-    }
-
-    /**
-     * Test method for {@link org.apache.mailet.MailAddress#MailAddress(java.lang.String)}.
-     *
-     * @throws AddressException
-     */
-    @Test
-    public void testMailAddressString() throws AddressException {
-
-        MailAddress a = new MailAddress(GOOD_ADDRESS);
-        assertTrue(GOOD_ADDRESS.equals(a.toString()));
-
-        for (String goodAddress : GOOD_ADDRESSES) {
-            try {
-                a = new MailAddress(goodAddress);
-            } catch (AddressException e) {
-                fail(e.getMessage());
-            }
-        }
-
-        for (String badAddress : BAD_ADDRESSES) {
-            try {
-                a = new MailAddress(badAddress);
-                fail(badAddress);
-            } catch (AddressException ignore) {
-            }
-        }
-    }
-
-    /**
-     * Test method for {@link org.apache.mailet.MailAddress#MailAddress(java.lang.String, java.lang.String)}.
-     */
-    @Test
-    public void testMailAddressStringString() {
-
-        try {
-            new MailAddress("local-part", "domain");
-        } catch (AddressException e) {
-            assertTrue(e.getMessage(), false);
-        }
-        try {
-            MailAddress a = new MailAddress("local-part", "-domain");
-            assertFalse(a.toString(), true);
-        } catch (AddressException e) {
-            assertTrue(true);
-        }
-    }
-
-    /**
-     * Test method for {@link org.apache.mailet.MailAddress#MailAddress(javax.mail.internet.InternetAddress)}.
-     */
-    @Test
-    public void testMailAddressInternetAddress() {
-
-        try {
-            new MailAddress(new InternetAddress(GOOD_QUOTED_LOCAL_PART));
-        } catch (AddressException e) {
-            System.out.println("AddressException" + e.getMessage());
-            assertTrue(e.getMessage(), false);
-        }
-    }
-
-    /**
-     * Test method for {@link org.apache.mailet.MailAddress#getDomain()}.
-     */
-    @Test
-    public void testGetDomain() {
-
-        try {
-            MailAddress a = new MailAddress(new InternetAddress(GOOD_ADDRESS));
-            assertTrue(a.getDomain() + " != " + GOOD_DOMAIN, a.getDomain().equals(GOOD_DOMAIN));
-        } catch (AddressException e) {
-            System.out.println("AddressException" + e.getMessage());
-            assertTrue(e.getMessage(), false);
-        }
-    }
-
-    /**
-     * Test method for {@link org.apache.mailet.MailAddress#getLocalPart()}.
-     */
-    @Test
-    public void testGetLocalPart() {
-
-        try {
-            MailAddress a = new MailAddress(new InternetAddress(GOOD_QUOTED_LOCAL_PART));
-            assertTrue(GOOD_LOCAL_PART + " != " + a.getLocalPart(), a.getLocalPart().equals(GOOD_LOCAL_PART));
-        } catch (AddressException e) {
-            System.out.println("AddressException" + e.getMessage());
-            assertTrue(e.getMessage(), false);
-        }
-    }
-
-    /**
-     * Test method for {@link org.apache.mailet.MailAddress#toString()}.
-     */
-    @Test
-    public void testToString() {
-
-        try {
-            MailAddress a = new MailAddress(new InternetAddress(GOOD_ADDRESS));
-            assertTrue(a.toString() + " != " + GOOD_ADDRESS, a.toString().equals(GOOD_ADDRESS));
-        } catch (AddressException e) {
-            System.out.println("AddressException" + e.getMessage());
-            assertTrue(e.getMessage(), false);
-        }
-    }
-
-    /**
-     * Test method for {@link org.apache.mailet.MailAddress#toInternetAddress()}.
-     */
-    @Test
-    public void testToInternetAddress() {
-
-        try {
-            InternetAddress b = new InternetAddress(GOOD_ADDRESS);
-            MailAddress a = new MailAddress(b);
-            assertTrue(a.toInternetAddress().equals(b));
-            assertTrue(a.toString() + " != " + GOOD_ADDRESS, a.toString().equals(GOOD_ADDRESS));
-        } catch (AddressException e) {
-            System.out.println("AddressException" + e.getMessage());
-            assertTrue(e.getMessage(), false);
-        }
-    }
-
-    /**
-     * Test method for {@link org.apache.mailet.MailAddress#equals(java.lang.Object)}.
-     *
-     * @throws AddressException
-     */
-    @Test
-    public void testEqualsObject() throws AddressException {
-
-        MailAddress a = new MailAddress(GOOD_ADDRESS);
-        MailAddress b = new MailAddress(GOOD_ADDRESS);
-
-        assertTrue(a.toString() + " != " + b.toString(), a.equals(b));
-        assertFalse(a.toString() + " != " + null, a.equals(null));
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/base/src/main/java/org/apache/mailet/base/AutomaticallySentMailDetectorImpl.java
----------------------------------------------------------------------
diff --git a/mailet/base/src/main/java/org/apache/mailet/base/AutomaticallySentMailDetectorImpl.java b/mailet/base/src/main/java/org/apache/mailet/base/AutomaticallySentMailDetectorImpl.java
index d95a061..8054943 100644
--- a/mailet/base/src/main/java/org/apache/mailet/base/AutomaticallySentMailDetectorImpl.java
+++ b/mailet/base/src/main/java/org/apache/mailet/base/AutomaticallySentMailDetectorImpl.java
@@ -33,7 +33,7 @@ import org.apache.james.mime4j.parser.MimeStreamParser;
 import org.apache.james.mime4j.stream.BodyDescriptor;
 import org.apache.james.mime4j.stream.MimeConfig;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 
 public class AutomaticallySentMailDetectorImpl implements AutomaticallySentMailDetector {
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/base/src/main/java/org/apache/mailet/base/GenericMatcher.java
----------------------------------------------------------------------
diff --git a/mailet/base/src/main/java/org/apache/mailet/base/GenericMatcher.java b/mailet/base/src/main/java/org/apache/mailet/base/GenericMatcher.java
index 858ba6c..262965f 100644
--- a/mailet/base/src/main/java/org/apache/mailet/base/GenericMatcher.java
+++ b/mailet/base/src/main/java/org/apache/mailet/base/GenericMatcher.java
@@ -25,7 +25,7 @@ import java.util.Collection;
 import javax.mail.MessagingException;
 
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.MailetContext;
 import org.apache.mailet.Matcher;
 import org.apache.mailet.MatcherConfig;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/base/src/main/java/org/apache/mailet/base/GenericRecipientMatcher.java
----------------------------------------------------------------------
diff --git a/mailet/base/src/main/java/org/apache/mailet/base/GenericRecipientMatcher.java b/mailet/base/src/main/java/org/apache/mailet/base/GenericRecipientMatcher.java
index 0676c13..c7691bf 100644
--- a/mailet/base/src/main/java/org/apache/mailet/base/GenericRecipientMatcher.java
+++ b/mailet/base/src/main/java/org/apache/mailet/base/GenericRecipientMatcher.java
@@ -26,7 +26,7 @@ import java.util.Collection;
 import javax.mail.MessagingException;
 
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 
 import com.google.common.collect.ImmutableList;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/base/src/main/java/org/apache/mailet/base/MatcherInverter.java
----------------------------------------------------------------------
diff --git a/mailet/base/src/main/java/org/apache/mailet/base/MatcherInverter.java b/mailet/base/src/main/java/org/apache/mailet/base/MatcherInverter.java
index 2628fdf..8249e49 100644
--- a/mailet/base/src/main/java/org/apache/mailet/base/MatcherInverter.java
+++ b/mailet/base/src/main/java/org/apache/mailet/base/MatcherInverter.java
@@ -26,7 +26,7 @@ import java.util.Collection;
 import javax.mail.MessagingException;
 
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.Matcher;
 import org.apache.mailet.MatcherConfig;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/base/src/test/java/org/apache/mailet/base/AutomaticallySentMailDetectorImplTest.java
----------------------------------------------------------------------
diff --git a/mailet/base/src/test/java/org/apache/mailet/base/AutomaticallySentMailDetectorImplTest.java b/mailet/base/src/test/java/org/apache/mailet/base/AutomaticallySentMailDetectorImplTest.java
index 99d0095..e0f38f9 100644
--- a/mailet/base/src/test/java/org/apache/mailet/base/AutomaticallySentMailDetectorImplTest.java
+++ b/mailet/base/src/test/java/org/apache/mailet/base/AutomaticallySentMailDetectorImplTest.java
@@ -32,7 +32,7 @@ import javax.mail.internet.MimeMessage;
 import javax.mail.internet.MimeMultipart;
 import javax.mail.util.ByteArrayDataSource;
 
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.MimeMessageBuilder;
 import org.junit.Test;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/base/src/test/java/org/apache/mailet/base/MailAddressFixture.java
----------------------------------------------------------------------
diff --git a/mailet/base/src/test/java/org/apache/mailet/base/MailAddressFixture.java b/mailet/base/src/test/java/org/apache/mailet/base/MailAddressFixture.java
index ca1725d..b1a4883 100644
--- a/mailet/base/src/test/java/org/apache/mailet/base/MailAddressFixture.java
+++ b/mailet/base/src/test/java/org/apache/mailet/base/MailAddressFixture.java
@@ -21,7 +21,7 @@ package org.apache.mailet.base;
 
 import javax.mail.internet.AddressException;
 
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 
 import com.google.common.base.Throwables;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/base/src/test/java/org/apache/mailet/base/MatcherInverterTest.java
----------------------------------------------------------------------
diff --git a/mailet/base/src/test/java/org/apache/mailet/base/MatcherInverterTest.java b/mailet/base/src/test/java/org/apache/mailet/base/MatcherInverterTest.java
index 331efbe..bc49fec 100644
--- a/mailet/base/src/test/java/org/apache/mailet/base/MatcherInverterTest.java
+++ b/mailet/base/src/test/java/org/apache/mailet/base/MatcherInverterTest.java
@@ -29,7 +29,7 @@ import java.util.Collection;
 import javax.mail.MessagingException;
 
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.test.FakeMail;
 import org.junit.Test;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/base/src/test/java/org/apache/mailet/base/test/FakeMail.java
----------------------------------------------------------------------
diff --git a/mailet/base/src/test/java/org/apache/mailet/base/test/FakeMail.java b/mailet/base/src/test/java/org/apache/mailet/base/test/FakeMail.java
index 98c7579..8a4bcde 100644
--- a/mailet/base/src/test/java/org/apache/mailet/base/test/FakeMail.java
+++ b/mailet/base/src/test/java/org/apache/mailet/base/test/FakeMail.java
@@ -36,7 +36,7 @@ import javax.mail.internet.InternetAddress;
 import javax.mail.internet.MimeMessage;
 
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.PerRecipientHeaders;
 import org.apache.mailet.PerRecipientHeaders.Header;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/base/src/test/java/org/apache/mailet/base/test/FakeMailContext.java
----------------------------------------------------------------------
diff --git a/mailet/base/src/test/java/org/apache/mailet/base/test/FakeMailContext.java b/mailet/base/src/test/java/org/apache/mailet/base/test/FakeMailContext.java
index 14409fb..9c54dc0 100644
--- a/mailet/base/src/test/java/org/apache/mailet/base/test/FakeMailContext.java
+++ b/mailet/base/src/test/java/org/apache/mailet/base/test/FakeMailContext.java
@@ -33,7 +33,7 @@ import javax.mail.internet.MimeMessage;
 import org.apache.mailet.HostAddress;
 import org.apache.mailet.LookupException;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.MailetContext;
 import org.slf4j.Logger;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/base/src/test/java/org/apache/mailet/base/test/MailUtil.java
----------------------------------------------------------------------
diff --git a/mailet/base/src/test/java/org/apache/mailet/base/test/MailUtil.java b/mailet/base/src/test/java/org/apache/mailet/base/test/MailUtil.java
index 17f26f6..148e352 100644
--- a/mailet/base/src/test/java/org/apache/mailet/base/test/MailUtil.java
+++ b/mailet/base/src/test/java/org/apache/mailet/base/test/MailUtil.java
@@ -26,7 +26,7 @@ import javax.mail.MessagingException;
 import javax.mail.internet.MimeMessage;
 
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 
 /**
  * some utilities for James unit testing

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/crypto/src/main/java/org/apache/james/transport/mailets/AbstractSign.java
----------------------------------------------------------------------
diff --git a/mailet/crypto/src/main/java/org/apache/james/transport/mailets/AbstractSign.java b/mailet/crypto/src/main/java/org/apache/james/transport/mailets/AbstractSign.java
index 4baa77d..e4ed9cd 100644
--- a/mailet/crypto/src/main/java/org/apache/james/transport/mailets/AbstractSign.java
+++ b/mailet/crypto/src/main/java/org/apache/james/transport/mailets/AbstractSign.java
@@ -39,7 +39,7 @@ import org.apache.james.transport.SMIMEAttributeNames;
 import org.apache.james.user.api.UsersRepository;
 import org.apache.james.user.api.UsersRepositoryException;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.GenericMailet;
 import org.apache.mailet.base.RFC2822Headers;
 import org.slf4j.Logger;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/crypto/src/main/java/org/apache/james/transport/matcher/IsSMIMEEncrypted.java
----------------------------------------------------------------------
diff --git a/mailet/crypto/src/main/java/org/apache/james/transport/matcher/IsSMIMEEncrypted.java b/mailet/crypto/src/main/java/org/apache/james/transport/matcher/IsSMIMEEncrypted.java
index d47c901..1646361 100644
--- a/mailet/crypto/src/main/java/org/apache/james/transport/matcher/IsSMIMEEncrypted.java
+++ b/mailet/crypto/src/main/java/org/apache/james/transport/matcher/IsSMIMEEncrypted.java
@@ -27,7 +27,7 @@ import javax.mail.internet.MimeMessage;
 
 import org.apache.mailet.base.GenericMatcher;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 
 /**
  * Checks if a mail is smime encrypted.

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/crypto/src/main/java/org/apache/james/transport/matcher/IsSMIMESigned.java
----------------------------------------------------------------------
diff --git a/mailet/crypto/src/main/java/org/apache/james/transport/matcher/IsSMIMESigned.java b/mailet/crypto/src/main/java/org/apache/james/transport/matcher/IsSMIMESigned.java
index 42e35d0..88ab165 100644
--- a/mailet/crypto/src/main/java/org/apache/james/transport/matcher/IsSMIMESigned.java
+++ b/mailet/crypto/src/main/java/org/apache/james/transport/matcher/IsSMIMESigned.java
@@ -27,7 +27,7 @@ import javax.mail.internet.MimeMessage;
 
 import org.apache.mailet.base.GenericMatcher;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 
 /**
  * checks if a mail is smime signed. 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/crypto/src/main/java/org/apache/james/transport/matcher/IsX509CertificateSubject.java
----------------------------------------------------------------------
diff --git a/mailet/crypto/src/main/java/org/apache/james/transport/matcher/IsX509CertificateSubject.java b/mailet/crypto/src/main/java/org/apache/james/transport/matcher/IsX509CertificateSubject.java
index a307c36..30f920d 100644
--- a/mailet/crypto/src/main/java/org/apache/james/transport/matcher/IsX509CertificateSubject.java
+++ b/mailet/crypto/src/main/java/org/apache/james/transport/matcher/IsX509CertificateSubject.java
@@ -30,7 +30,7 @@ import java.util.List;
 import javax.mail.MessagingException;
 
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.GenericMatcher;
 
 /**

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/icalendar/src/main/java/org/apache/james/transport/mailets/ICALToJsonAttribute.java
----------------------------------------------------------------------
diff --git a/mailet/icalendar/src/main/java/org/apache/james/transport/mailets/ICALToJsonAttribute.java b/mailet/icalendar/src/main/java/org/apache/james/transport/mailets/ICALToJsonAttribute.java
index 33eca9d..023199f 100644
--- a/mailet/icalendar/src/main/java/org/apache/james/transport/mailets/ICALToJsonAttribute.java
+++ b/mailet/icalendar/src/main/java/org/apache/james/transport/mailets/ICALToJsonAttribute.java
@@ -34,7 +34,7 @@ import javax.mail.internet.MimeMessage;
 import org.apache.commons.lang3.tuple.Pair;
 import org.apache.james.transport.mailets.model.ICAL;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.GenericMailet;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/icalendar/src/main/java/org/apache/james/transport/mailets/model/ICAL.java
----------------------------------------------------------------------
diff --git a/mailet/icalendar/src/main/java/org/apache/james/transport/mailets/model/ICAL.java b/mailet/icalendar/src/main/java/org/apache/james/transport/mailets/model/ICAL.java
index 14db606..29dc158 100644
--- a/mailet/icalendar/src/main/java/org/apache/james/transport/mailets/model/ICAL.java
+++ b/mailet/icalendar/src/main/java/org/apache/james/transport/mailets/model/ICAL.java
@@ -22,7 +22,7 @@ package org.apache.james.transport.mailets.model;
 import java.util.Objects;
 import java.util.Optional;
 
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 
 import com.fasterxml.jackson.annotation.JsonProperty;
 import com.google.common.base.Charsets;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/icalendar/src/test/java/org/apache/james/transport/mailets/ICALToJsonAttributeTest.java
----------------------------------------------------------------------
diff --git a/mailet/icalendar/src/test/java/org/apache/james/transport/mailets/ICALToJsonAttributeTest.java b/mailet/icalendar/src/test/java/org/apache/james/transport/mailets/ICALToJsonAttributeTest.java
index 5538b15..21c061e 100644
--- a/mailet/icalendar/src/test/java/org/apache/james/transport/mailets/ICALToJsonAttributeTest.java
+++ b/mailet/icalendar/src/test/java/org/apache/james/transport/mailets/ICALToJsonAttributeTest.java
@@ -31,7 +31,7 @@ import java.util.stream.Collectors;
 import javax.mail.MessagingException;
 
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.MailAddressFixture;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMailetConfig;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/icalendar/src/test/java/org/apache/james/transport/mailets/model/ICALTest.java
----------------------------------------------------------------------
diff --git a/mailet/icalendar/src/test/java/org/apache/james/transport/mailets/model/ICALTest.java b/mailet/icalendar/src/test/java/org/apache/james/transport/mailets/model/ICALTest.java
index 99db64b..4699ae3 100644
--- a/mailet/icalendar/src/test/java/org/apache/james/transport/mailets/model/ICALTest.java
+++ b/mailet/icalendar/src/test/java/org/apache/james/transport/mailets/model/ICALTest.java
@@ -23,7 +23,7 @@ import static org.assertj.core.api.Assertions.assertThat;
 
 import java.io.ByteArrayInputStream;
 
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.MailAddressFixture;
 import org.junit.Rule;
 import org.junit.Test;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/standard/src/main/java/org/apache/james/transport/mailets/AddDeliveredToHeader.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/main/java/org/apache/james/transport/mailets/AddDeliveredToHeader.java b/mailet/standard/src/main/java/org/apache/james/transport/mailets/AddDeliveredToHeader.java
index d4a4082..c1651a0 100644
--- a/mailet/standard/src/main/java/org/apache/james/transport/mailets/AddDeliveredToHeader.java
+++ b/mailet/standard/src/main/java/org/apache/james/transport/mailets/AddDeliveredToHeader.java
@@ -22,7 +22,7 @@ package org.apache.james.transport.mailets;
 import javax.mail.MessagingException;
 
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.PerRecipientHeaders;
 import org.apache.mailet.base.GenericMailet;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/standard/src/main/java/org/apache/james/transport/mailets/ClamAVScan.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/main/java/org/apache/james/transport/mailets/ClamAVScan.java b/mailet/standard/src/main/java/org/apache/james/transport/mailets/ClamAVScan.java
index 0e4bc26..8aec378 100644
--- a/mailet/standard/src/main/java/org/apache/james/transport/mailets/ClamAVScan.java
+++ b/mailet/standard/src/main/java/org/apache/james/transport/mailets/ClamAVScan.java
@@ -42,7 +42,7 @@ import javax.mail.internet.MimeMessage;
 import org.apache.commons.io.IOUtils;
 import org.apache.mailet.Experimental;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.GenericMailet;
 import org.apache.mailet.base.RFC2822Headers;
 import org.slf4j.Logger;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/standard/src/main/java/org/apache/james/transport/mailets/PostmasterAlias.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/main/java/org/apache/james/transport/mailets/PostmasterAlias.java b/mailet/standard/src/main/java/org/apache/james/transport/mailets/PostmasterAlias.java
index 6f822db..04c8c72 100644
--- a/mailet/standard/src/main/java/org/apache/james/transport/mailets/PostmasterAlias.java
+++ b/mailet/standard/src/main/java/org/apache/james/transport/mailets/PostmasterAlias.java
@@ -27,7 +27,7 @@ import java.util.Vector;
 import javax.mail.MessagingException;
 
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.MailetContext;
 import org.apache.mailet.base.GenericMailet;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/standard/src/main/java/org/apache/james/transport/mailets/RecipientToLowerCase.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/main/java/org/apache/james/transport/mailets/RecipientToLowerCase.java b/mailet/standard/src/main/java/org/apache/james/transport/mailets/RecipientToLowerCase.java
index 4a12bf8..56e8646 100644
--- a/mailet/standard/src/main/java/org/apache/james/transport/mailets/RecipientToLowerCase.java
+++ b/mailet/standard/src/main/java/org/apache/james/transport/mailets/RecipientToLowerCase.java
@@ -23,7 +23,7 @@ import javax.mail.MessagingException;
 import javax.mail.internet.AddressException;
 
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.GenericMailet;
 
 import com.github.steveash.guavate.Guavate;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/standard/src/main/java/org/apache/james/transport/mailets/UseHeaderRecipients.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/main/java/org/apache/james/transport/mailets/UseHeaderRecipients.java b/mailet/standard/src/main/java/org/apache/james/transport/mailets/UseHeaderRecipients.java
index c562ee8..ef1e20c 100644
--- a/mailet/standard/src/main/java/org/apache/james/transport/mailets/UseHeaderRecipients.java
+++ b/mailet/standard/src/main/java/org/apache/james/transport/mailets/UseHeaderRecipients.java
@@ -36,7 +36,7 @@ import org.apache.james.mime4j.field.address.LenientAddressParser;
 import org.apache.james.mime4j.util.MimeUtil;
 import org.apache.mailet.Experimental;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.GenericMailet;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/standard/src/main/java/org/apache/james/transport/matchers/AbstractQuotaMatcher.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/main/java/org/apache/james/transport/matchers/AbstractQuotaMatcher.java b/mailet/standard/src/main/java/org/apache/james/transport/matchers/AbstractQuotaMatcher.java
index d5b2601..5539786 100755
--- a/mailet/standard/src/main/java/org/apache/james/transport/matchers/AbstractQuotaMatcher.java
+++ b/mailet/standard/src/main/java/org/apache/james/transport/matchers/AbstractQuotaMatcher.java
@@ -28,7 +28,7 @@ import javax.mail.MessagingException;
 
 import org.apache.mailet.Experimental;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.GenericMatcher;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/standard/src/main/java/org/apache/james/transport/matchers/All.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/main/java/org/apache/james/transport/matchers/All.java b/mailet/standard/src/main/java/org/apache/james/transport/matchers/All.java
index 7229510..8133740 100644
--- a/mailet/standard/src/main/java/org/apache/james/transport/matchers/All.java
+++ b/mailet/standard/src/main/java/org/apache/james/transport/matchers/All.java
@@ -20,7 +20,7 @@ package org.apache.james.transport.matchers;
 
 import org.apache.mailet.base.GenericMatcher;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 
 import java.util.Collection;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/standard/src/main/java/org/apache/james/transport/matchers/AttachmentFileNameIs.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/main/java/org/apache/james/transport/matchers/AttachmentFileNameIs.java b/mailet/standard/src/main/java/org/apache/james/transport/matchers/AttachmentFileNameIs.java
index 5195543..c505816 100755
--- a/mailet/standard/src/main/java/org/apache/james/transport/matchers/AttachmentFileNameIs.java
+++ b/mailet/standard/src/main/java/org/apache/james/transport/matchers/AttachmentFileNameIs.java
@@ -37,7 +37,7 @@ import javax.mail.internet.MimeMessage;
 
 import org.apache.mailet.Experimental;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.GenericMatcher;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/standard/src/main/java/org/apache/james/transport/matchers/CommandForListserv.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/main/java/org/apache/james/transport/matchers/CommandForListserv.java b/mailet/standard/src/main/java/org/apache/james/transport/matchers/CommandForListserv.java
index cf15c14..119b8fd 100644
--- a/mailet/standard/src/main/java/org/apache/james/transport/matchers/CommandForListserv.java
+++ b/mailet/standard/src/main/java/org/apache/james/transport/matchers/CommandForListserv.java
@@ -23,7 +23,7 @@ package org.apache.james.transport.matchers;
 
 import org.apache.mailet.Experimental;
 import org.apache.mailet.base.GenericRecipientMatcher;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 
 import javax.mail.MessagingException;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/standard/src/main/java/org/apache/james/transport/matchers/CommandListservMatcher.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/main/java/org/apache/james/transport/matchers/CommandListservMatcher.java b/mailet/standard/src/main/java/org/apache/james/transport/matchers/CommandListservMatcher.java
index f64b007..a784edf 100644
--- a/mailet/standard/src/main/java/org/apache/james/transport/matchers/CommandListservMatcher.java
+++ b/mailet/standard/src/main/java/org/apache/james/transport/matchers/CommandListservMatcher.java
@@ -23,7 +23,7 @@ package org.apache.james.transport.matchers;
 
 import org.apache.mailet.Experimental;
 import org.apache.mailet.base.GenericRecipientMatcher;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 
 import javax.mail.MessagingException;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/standard/src/main/java/org/apache/james/transport/matchers/CompareNumericHeaderValue.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/main/java/org/apache/james/transport/matchers/CompareNumericHeaderValue.java b/mailet/standard/src/main/java/org/apache/james/transport/matchers/CompareNumericHeaderValue.java
index e1ec507..b4e9aa3 100644
--- a/mailet/standard/src/main/java/org/apache/james/transport/matchers/CompareNumericHeaderValue.java
+++ b/mailet/standard/src/main/java/org/apache/james/transport/matchers/CompareNumericHeaderValue.java
@@ -24,7 +24,7 @@ package org.apache.james.transport.matchers;
 import org.apache.mailet.Experimental;
 import org.apache.mailet.base.GenericMatcher;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 
 import javax.mail.MessagingException;
 import javax.mail.internet.MimeMessage;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/standard/src/main/java/org/apache/james/transport/matchers/FetchedFrom.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/main/java/org/apache/james/transport/matchers/FetchedFrom.java b/mailet/standard/src/main/java/org/apache/james/transport/matchers/FetchedFrom.java
index 6b707f3..a16baff 100644
--- a/mailet/standard/src/main/java/org/apache/james/transport/matchers/FetchedFrom.java
+++ b/mailet/standard/src/main/java/org/apache/james/transport/matchers/FetchedFrom.java
@@ -21,7 +21,7 @@ package org.apache.james.transport.matchers;
 
 import org.apache.mailet.base.GenericMatcher;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 
 import javax.mail.internet.MimeMessage;
 import java.util.Collection;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/standard/src/main/java/org/apache/james/transport/matchers/GenericRegexMatcher.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/main/java/org/apache/james/transport/matchers/GenericRegexMatcher.java b/mailet/standard/src/main/java/org/apache/james/transport/matchers/GenericRegexMatcher.java
index e9c0612..6896967 100755
--- a/mailet/standard/src/main/java/org/apache/james/transport/matchers/GenericRegexMatcher.java
+++ b/mailet/standard/src/main/java/org/apache/james/transport/matchers/GenericRegexMatcher.java
@@ -29,7 +29,7 @@ import javax.mail.MessagingException;
 import javax.mail.internet.MimeMessage;
 
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.GenericMatcher;
 
 /**

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/standard/src/main/java/org/apache/james/transport/matchers/HasAttachment.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/main/java/org/apache/james/transport/matchers/HasAttachment.java b/mailet/standard/src/main/java/org/apache/james/transport/matchers/HasAttachment.java
index a998039..5f58a75 100644
--- a/mailet/standard/src/main/java/org/apache/james/transport/matchers/HasAttachment.java
+++ b/mailet/standard/src/main/java/org/apache/james/transport/matchers/HasAttachment.java
@@ -23,7 +23,7 @@ package org.apache.james.transport.matchers;
 
 import org.apache.mailet.base.GenericMatcher;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 
 import javax.mail.MessagingException;
 import javax.mail.Multipart;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/standard/src/main/java/org/apache/james/transport/matchers/HasHabeasWarrantMark.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/main/java/org/apache/james/transport/matchers/HasHabeasWarrantMark.java b/mailet/standard/src/main/java/org/apache/james/transport/matchers/HasHabeasWarrantMark.java
index 5b7e757..ab981ab 100644
--- a/mailet/standard/src/main/java/org/apache/james/transport/matchers/HasHabeasWarrantMark.java
+++ b/mailet/standard/src/main/java/org/apache/james/transport/matchers/HasHabeasWarrantMark.java
@@ -28,7 +28,7 @@ import javax.mail.internet.MimeMessage;
 
 import org.apache.mailet.Experimental;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.GenericMatcher;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/standard/src/main/java/org/apache/james/transport/matchers/HasHeader.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/main/java/org/apache/james/transport/matchers/HasHeader.java b/mailet/standard/src/main/java/org/apache/james/transport/matchers/HasHeader.java
index 1fe2108..c659634 100644
--- a/mailet/standard/src/main/java/org/apache/james/transport/matchers/HasHeader.java
+++ b/mailet/standard/src/main/java/org/apache/james/transport/matchers/HasHeader.java
@@ -33,7 +33,7 @@ import org.apache.james.mime4j.codec.DecodeMonitor;
 import org.apache.james.mime4j.codec.DecoderUtil;
 import org.apache.james.mime4j.util.MimeUtil;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.GenericMatcher;
 
 /**

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/standard/src/main/java/org/apache/james/transport/matchers/HasHeaderWithPrefix.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/main/java/org/apache/james/transport/matchers/HasHeaderWithPrefix.java b/mailet/standard/src/main/java/org/apache/james/transport/matchers/HasHeaderWithPrefix.java
index 05ee715..3295015 100644
--- a/mailet/standard/src/main/java/org/apache/james/transport/matchers/HasHeaderWithPrefix.java
+++ b/mailet/standard/src/main/java/org/apache/james/transport/matchers/HasHeaderWithPrefix.java
@@ -27,7 +27,7 @@ import javax.mail.MessagingException;
 
 import org.apache.james.transport.mailets.utils.MimeMessageUtils;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.GenericMatcher;
 
 import com.google.common.base.Strings;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/standard/src/main/java/org/apache/james/transport/matchers/HasMailAttribute.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/main/java/org/apache/james/transport/matchers/HasMailAttribute.java b/mailet/standard/src/main/java/org/apache/james/transport/matchers/HasMailAttribute.java
index 41dcf91..a00f2bf 100644
--- a/mailet/standard/src/main/java/org/apache/james/transport/matchers/HasMailAttribute.java
+++ b/mailet/standard/src/main/java/org/apache/james/transport/matchers/HasMailAttribute.java
@@ -27,7 +27,7 @@ import java.util.Collection;
 import javax.mail.MessagingException;
 
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.GenericMatcher;
 
 /**

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/standard/src/main/java/org/apache/james/transport/matchers/HasMailAttributeWithValue.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/main/java/org/apache/james/transport/matchers/HasMailAttributeWithValue.java b/mailet/standard/src/main/java/org/apache/james/transport/matchers/HasMailAttributeWithValue.java
index bfc6aac..4a02a35 100644
--- a/mailet/standard/src/main/java/org/apache/james/transport/matchers/HasMailAttributeWithValue.java
+++ b/mailet/standard/src/main/java/org/apache/james/transport/matchers/HasMailAttributeWithValue.java
@@ -26,7 +26,7 @@ import java.util.Collection;
 import javax.mail.MessagingException;
 
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.GenericMatcher;
 
 /**

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/standard/src/main/java/org/apache/james/transport/matchers/HasMailAttributeWithValueRegex.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/main/java/org/apache/james/transport/matchers/HasMailAttributeWithValueRegex.java b/mailet/standard/src/main/java/org/apache/james/transport/matchers/HasMailAttributeWithValueRegex.java
index 1253ede..84f3fbc 100644
--- a/mailet/standard/src/main/java/org/apache/james/transport/matchers/HasMailAttributeWithValueRegex.java
+++ b/mailet/standard/src/main/java/org/apache/james/transport/matchers/HasMailAttributeWithValueRegex.java
@@ -24,7 +24,7 @@ package org.apache.james.transport.matchers;
 
 import org.apache.mailet.base.GenericMatcher;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.MatcherConfig;
 import java.util.Collection;
 import java.util.regex.Pattern;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/standard/src/main/java/org/apache/james/transport/matchers/HostIs.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/main/java/org/apache/james/transport/matchers/HostIs.java b/mailet/standard/src/main/java/org/apache/james/transport/matchers/HostIs.java
index 2600007..36c0684 100644
--- a/mailet/standard/src/main/java/org/apache/james/transport/matchers/HostIs.java
+++ b/mailet/standard/src/main/java/org/apache/james/transport/matchers/HostIs.java
@@ -26,7 +26,7 @@ import java.util.Locale;
 import java.util.StringTokenizer;
 import java.util.Vector;
 
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.GenericRecipientMatcher;
 
 /**

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/standard/src/main/java/org/apache/james/transport/matchers/HostIsLocal.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/main/java/org/apache/james/transport/matchers/HostIsLocal.java b/mailet/standard/src/main/java/org/apache/james/transport/matchers/HostIsLocal.java
index 66b1b11..9d37136 100644
--- a/mailet/standard/src/main/java/org/apache/james/transport/matchers/HostIsLocal.java
+++ b/mailet/standard/src/main/java/org/apache/james/transport/matchers/HostIsLocal.java
@@ -22,7 +22,7 @@
 package org.apache.james.transport.matchers;
 
 import org.apache.mailet.base.GenericRecipientMatcher;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 
 /**
  * Matches mail to Domains which are local

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/standard/src/main/java/org/apache/james/transport/matchers/IsSingleRecipient.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/main/java/org/apache/james/transport/matchers/IsSingleRecipient.java b/mailet/standard/src/main/java/org/apache/james/transport/matchers/IsSingleRecipient.java
index fd5373b..cdbdbf9 100644
--- a/mailet/standard/src/main/java/org/apache/james/transport/matchers/IsSingleRecipient.java
+++ b/mailet/standard/src/main/java/org/apache/james/transport/matchers/IsSingleRecipient.java
@@ -23,7 +23,7 @@ package org.apache.james.transport.matchers;
 
 import org.apache.mailet.base.GenericMatcher;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 
 import java.util.Collection;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/standard/src/main/java/org/apache/james/transport/matchers/RecipientIs.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/main/java/org/apache/james/transport/matchers/RecipientIs.java b/mailet/standard/src/main/java/org/apache/james/transport/matchers/RecipientIs.java
index 6030e91..0c567df 100644
--- a/mailet/standard/src/main/java/org/apache/james/transport/matchers/RecipientIs.java
+++ b/mailet/standard/src/main/java/org/apache/james/transport/matchers/RecipientIs.java
@@ -24,7 +24,7 @@ import java.util.Collection;
 import javax.mail.MessagingException;
 
 import org.apache.james.transport.matchers.utils.MailAddressCollectionReader;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.GenericRecipientMatcher;
 
 import com.google.common.base.Strings;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/standard/src/main/java/org/apache/james/transport/matchers/RecipientIsLocal.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/main/java/org/apache/james/transport/matchers/RecipientIsLocal.java b/mailet/standard/src/main/java/org/apache/james/transport/matchers/RecipientIsLocal.java
index cc687a2..7155581 100644
--- a/mailet/standard/src/main/java/org/apache/james/transport/matchers/RecipientIsLocal.java
+++ b/mailet/standard/src/main/java/org/apache/james/transport/matchers/RecipientIsLocal.java
@@ -22,7 +22,7 @@
 package org.apache.james.transport.matchers;
 
 import org.apache.mailet.base.GenericRecipientMatcher;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.MailetContext;
 
 /**

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/standard/src/main/java/org/apache/james/transport/matchers/RecipientIsRegex.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/main/java/org/apache/james/transport/matchers/RecipientIsRegex.java b/mailet/standard/src/main/java/org/apache/james/transport/matchers/RecipientIsRegex.java
index 2ee1b16..67b0c49 100755
--- a/mailet/standard/src/main/java/org/apache/james/transport/matchers/RecipientIsRegex.java
+++ b/mailet/standard/src/main/java/org/apache/james/transport/matchers/RecipientIsRegex.java
@@ -23,7 +23,7 @@ import java.util.regex.Pattern;
 import java.util.regex.PatternSyntaxException;
 
 import org.apache.mailet.base.GenericRecipientMatcher;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 
 import javax.mail.MessagingException;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/standard/src/main/java/org/apache/james/transport/matchers/RelayLimit.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/main/java/org/apache/james/transport/matchers/RelayLimit.java b/mailet/standard/src/main/java/org/apache/james/transport/matchers/RelayLimit.java
index ddd91a0..3c248ba 100644
--- a/mailet/standard/src/main/java/org/apache/james/transport/matchers/RelayLimit.java
+++ b/mailet/standard/src/main/java/org/apache/james/transport/matchers/RelayLimit.java
@@ -25,7 +25,7 @@ import org.apache.mailet.base.MailetUtil;
 import org.apache.mailet.base.RFC2822Headers;
 import org.apache.mailet.base.GenericMatcher;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 
 import javax.mail.Header;
 import javax.mail.MessagingException;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/standard/src/main/java/org/apache/james/transport/matchers/SMTPAuthSuccessful.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/main/java/org/apache/james/transport/matchers/SMTPAuthSuccessful.java b/mailet/standard/src/main/java/org/apache/james/transport/matchers/SMTPAuthSuccessful.java
index 016aeca..54aa8af 100644
--- a/mailet/standard/src/main/java/org/apache/james/transport/matchers/SMTPAuthSuccessful.java
+++ b/mailet/standard/src/main/java/org/apache/james/transport/matchers/SMTPAuthSuccessful.java
@@ -24,7 +24,7 @@ package org.apache.james.transport.matchers;
 import com.google.common.collect.ImmutableList;
 import org.apache.mailet.base.GenericMatcher;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 
 import java.util.Collection;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/standard/src/main/java/org/apache/james/transport/matchers/SMTPAuthUserIs.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/main/java/org/apache/james/transport/matchers/SMTPAuthUserIs.java b/mailet/standard/src/main/java/org/apache/james/transport/matchers/SMTPAuthUserIs.java
index cc3fc52..ba9719f 100644
--- a/mailet/standard/src/main/java/org/apache/james/transport/matchers/SMTPAuthUserIs.java
+++ b/mailet/standard/src/main/java/org/apache/james/transport/matchers/SMTPAuthUserIs.java
@@ -25,7 +25,7 @@ import java.util.Collection;
 import java.util.StringTokenizer;
 
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.GenericMatcher;
 
 /**

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/standard/src/main/java/org/apache/james/transport/matchers/SMTPIsAuthNetwork.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/main/java/org/apache/james/transport/matchers/SMTPIsAuthNetwork.java b/mailet/standard/src/main/java/org/apache/james/transport/matchers/SMTPIsAuthNetwork.java
index ea15d7d..bc9afa9 100644
--- a/mailet/standard/src/main/java/org/apache/james/transport/matchers/SMTPIsAuthNetwork.java
+++ b/mailet/standard/src/main/java/org/apache/james/transport/matchers/SMTPIsAuthNetwork.java
@@ -24,7 +24,7 @@ package org.apache.james.transport.matchers;
 import org.apache.mailet.Experimental;
 import org.apache.mailet.base.GenericMatcher;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 
 import java.util.Collection;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/standard/src/main/java/org/apache/james/transport/matchers/SenderHostIs.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/main/java/org/apache/james/transport/matchers/SenderHostIs.java b/mailet/standard/src/main/java/org/apache/james/transport/matchers/SenderHostIs.java
index 073aad3..d6f67e1 100755
--- a/mailet/standard/src/main/java/org/apache/james/transport/matchers/SenderHostIs.java
+++ b/mailet/standard/src/main/java/org/apache/james/transport/matchers/SenderHostIs.java
@@ -25,7 +25,7 @@ import java.util.Collection;
 import java.util.Locale;
 
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.GenericMatcher;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/standard/src/main/java/org/apache/james/transport/matchers/SenderHostIsLocal.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/main/java/org/apache/james/transport/matchers/SenderHostIsLocal.java b/mailet/standard/src/main/java/org/apache/james/transport/matchers/SenderHostIsLocal.java
index 0c9b5d5..6eac31d 100644
--- a/mailet/standard/src/main/java/org/apache/james/transport/matchers/SenderHostIsLocal.java
+++ b/mailet/standard/src/main/java/org/apache/james/transport/matchers/SenderHostIsLocal.java
@@ -24,7 +24,7 @@ import java.util.Collection;
 import java.util.Locale;
 
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.GenericMatcher;
 
 /**

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/standard/src/main/java/org/apache/james/transport/matchers/SenderIs.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/main/java/org/apache/james/transport/matchers/SenderIs.java b/mailet/standard/src/main/java/org/apache/james/transport/matchers/SenderIs.java
index b0d7239..1513674 100644
--- a/mailet/standard/src/main/java/org/apache/james/transport/matchers/SenderIs.java
+++ b/mailet/standard/src/main/java/org/apache/james/transport/matchers/SenderIs.java
@@ -26,7 +26,7 @@ import javax.mail.MessagingException;
 
 import org.apache.james.transport.matchers.utils.MailAddressCollectionReader;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.GenericMatcher;
 
 import com.google.common.annotations.VisibleForTesting;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/standard/src/main/java/org/apache/james/transport/matchers/SenderIsLocal.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/main/java/org/apache/james/transport/matchers/SenderIsLocal.java b/mailet/standard/src/main/java/org/apache/james/transport/matchers/SenderIsLocal.java
index 4cf9db3..8903278 100644
--- a/mailet/standard/src/main/java/org/apache/james/transport/matchers/SenderIsLocal.java
+++ b/mailet/standard/src/main/java/org/apache/james/transport/matchers/SenderIsLocal.java
@@ -23,7 +23,7 @@ import java.util.Collection;
 import javax.mail.MessagingException;
 
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.GenericMatcher;
 
 /**

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/standard/src/main/java/org/apache/james/transport/matchers/SenderIsNull.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/main/java/org/apache/james/transport/matchers/SenderIsNull.java b/mailet/standard/src/main/java/org/apache/james/transport/matchers/SenderIsNull.java
index bd244ab..b791ff5 100644
--- a/mailet/standard/src/main/java/org/apache/james/transport/matchers/SenderIsNull.java
+++ b/mailet/standard/src/main/java/org/apache/james/transport/matchers/SenderIsNull.java
@@ -21,7 +21,7 @@ package org.apache.james.transport.matchers;
 
 import org.apache.mailet.base.GenericMatcher;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 
 import java.util.Collection;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/standard/src/main/java/org/apache/james/transport/matchers/SenderIsRegex.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/main/java/org/apache/james/transport/matchers/SenderIsRegex.java b/mailet/standard/src/main/java/org/apache/james/transport/matchers/SenderIsRegex.java
index 8b32a4f..3988356 100644
--- a/mailet/standard/src/main/java/org/apache/james/transport/matchers/SenderIsRegex.java
+++ b/mailet/standard/src/main/java/org/apache/james/transport/matchers/SenderIsRegex.java
@@ -21,7 +21,7 @@ package org.apache.james.transport.matchers;
 
 import org.apache.mailet.base.GenericMatcher;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 
 import java.util.Collection;
 import java.util.regex.Pattern;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/standard/src/main/java/org/apache/james/transport/matchers/SentByMailet.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/main/java/org/apache/james/transport/matchers/SentByMailet.java b/mailet/standard/src/main/java/org/apache/james/transport/matchers/SentByMailet.java
index df173cf..3c3ba02 100644
--- a/mailet/standard/src/main/java/org/apache/james/transport/matchers/SentByMailet.java
+++ b/mailet/standard/src/main/java/org/apache/james/transport/matchers/SentByMailet.java
@@ -23,7 +23,7 @@ import java.util.Collection;
 
 import com.google.common.collect.ImmutableList;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.GenericMatcher;
 
 /**

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/standard/src/main/java/org/apache/james/transport/matchers/SizeGreaterThan.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/main/java/org/apache/james/transport/matchers/SizeGreaterThan.java b/mailet/standard/src/main/java/org/apache/james/transport/matchers/SizeGreaterThan.java
index 78175f3..f2bfff2 100644
--- a/mailet/standard/src/main/java/org/apache/james/transport/matchers/SizeGreaterThan.java
+++ b/mailet/standard/src/main/java/org/apache/james/transport/matchers/SizeGreaterThan.java
@@ -23,7 +23,7 @@ package org.apache.james.transport.matchers;
 
 import org.apache.mailet.base.GenericMatcher;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 
 import javax.mail.MessagingException;
 import java.util.Collection;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/standard/src/main/java/org/apache/james/transport/matchers/SubjectIs.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/main/java/org/apache/james/transport/matchers/SubjectIs.java b/mailet/standard/src/main/java/org/apache/james/transport/matchers/SubjectIs.java
index 44429e5..8be7516 100644
--- a/mailet/standard/src/main/java/org/apache/james/transport/matchers/SubjectIs.java
+++ b/mailet/standard/src/main/java/org/apache/james/transport/matchers/SubjectIs.java
@@ -23,7 +23,7 @@ package org.apache.james.transport.matchers;
 
 import org.apache.mailet.base.GenericMatcher;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 
 import javax.mail.internet.MimeMessage;
 import java.util.Collection;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/standard/src/main/java/org/apache/james/transport/matchers/SubjectStartsWith.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/main/java/org/apache/james/transport/matchers/SubjectStartsWith.java b/mailet/standard/src/main/java/org/apache/james/transport/matchers/SubjectStartsWith.java
index 8e15957..c48c6a5 100644
--- a/mailet/standard/src/main/java/org/apache/james/transport/matchers/SubjectStartsWith.java
+++ b/mailet/standard/src/main/java/org/apache/james/transport/matchers/SubjectStartsWith.java
@@ -23,7 +23,7 @@ package org.apache.james.transport.matchers;
 
 import org.apache.mailet.base.GenericMatcher;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 
 import javax.mail.MessagingException;
 import javax.mail.internet.MimeMessage;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/standard/src/main/java/org/apache/james/transport/matchers/TooManyLines.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/main/java/org/apache/james/transport/matchers/TooManyLines.java b/mailet/standard/src/main/java/org/apache/james/transport/matchers/TooManyLines.java
index 958990f..5ebd8b0 100644
--- a/mailet/standard/src/main/java/org/apache/james/transport/matchers/TooManyLines.java
+++ b/mailet/standard/src/main/java/org/apache/james/transport/matchers/TooManyLines.java
@@ -24,7 +24,7 @@ import java.util.Collection;
 import javax.mail.MessagingException;
 
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.GenericMatcher;
 import org.apache.mailet.base.MailetUtil;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/standard/src/main/java/org/apache/james/transport/matchers/TooManyRecipients.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/main/java/org/apache/james/transport/matchers/TooManyRecipients.java b/mailet/standard/src/main/java/org/apache/james/transport/matchers/TooManyRecipients.java
index f7d3e92..555a92d 100644
--- a/mailet/standard/src/main/java/org/apache/james/transport/matchers/TooManyRecipients.java
+++ b/mailet/standard/src/main/java/org/apache/james/transport/matchers/TooManyRecipients.java
@@ -24,7 +24,7 @@ import java.util.Collection;
 import javax.mail.MessagingException;
 
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.GenericMatcher;
 import org.apache.mailet.base.MailetUtil;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/standard/src/main/java/org/apache/james/transport/matchers/UserIs.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/main/java/org/apache/james/transport/matchers/UserIs.java b/mailet/standard/src/main/java/org/apache/james/transport/matchers/UserIs.java
index a764d5a..ece24da 100644
--- a/mailet/standard/src/main/java/org/apache/james/transport/matchers/UserIs.java
+++ b/mailet/standard/src/main/java/org/apache/james/transport/matchers/UserIs.java
@@ -23,7 +23,7 @@ import java.util.Set;
 
 import javax.mail.MessagingException;
 
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.GenericRecipientMatcher;
 
 import com.google.common.base.Splitter;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/standard/src/main/java/org/apache/james/transport/matchers/utils/MailAddressCollectionReader.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/main/java/org/apache/james/transport/matchers/utils/MailAddressCollectionReader.java b/mailet/standard/src/main/java/org/apache/james/transport/matchers/utils/MailAddressCollectionReader.java
index 6371d35..bbbbbba 100644
--- a/mailet/standard/src/main/java/org/apache/james/transport/matchers/utils/MailAddressCollectionReader.java
+++ b/mailet/standard/src/main/java/org/apache/james/transport/matchers/utils/MailAddressCollectionReader.java
@@ -22,7 +22,7 @@ package org.apache.james.transport.matchers.utils;
 import java.util.Set;
 import javax.mail.internet.AddressException;
 
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 
 import com.github.steveash.guavate.Guavate;
 import com.google.common.base.Preconditions;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/standard/src/test/java/org/apache/james/transport/mailets/LogMessageTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/mailets/LogMessageTest.java b/mailet/standard/src/test/java/org/apache/james/transport/mailets/LogMessageTest.java
index f3e1c3a..beb7db6 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/mailets/LogMessageTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/mailets/LogMessageTest.java
@@ -36,7 +36,7 @@ import javax.mail.internet.AddressException;
 import javax.mail.internet.MimeMessage;
 
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMailContext;
 import org.apache.mailet.base.test.FakeMailetConfig;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/standard/src/test/java/org/apache/james/transport/mailets/RecipientToLowerCaseTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/mailets/RecipientToLowerCaseTest.java b/mailet/standard/src/test/java/org/apache/james/transport/mailets/RecipientToLowerCaseTest.java
index b062cb7..ed1d4b7 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/mailets/RecipientToLowerCaseTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/mailets/RecipientToLowerCaseTest.java
@@ -23,7 +23,7 @@ import static org.assertj.core.api.Assertions.assertThat;
 
 import java.util.Collection;
 
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.test.FakeMail;
 import org.junit.Before;
 import org.junit.Test;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/standard/src/test/java/org/apache/james/transport/mailets/ToProcessorTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/mailets/ToProcessorTest.java b/mailet/standard/src/test/java/org/apache/james/transport/mailets/ToProcessorTest.java
index 233d909..7f5c898 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/mailets/ToProcessorTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/mailets/ToProcessorTest.java
@@ -26,7 +26,7 @@ import static org.mockito.Mockito.mock;
 import javax.mail.MessagingException;
 
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.Mailet;
 import org.apache.mailet.MailetException;
 import org.apache.mailet.base.test.FakeMail;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/standard/src/test/java/org/apache/james/transport/mailets/UseHeaderRecipientsTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/mailets/UseHeaderRecipientsTest.java b/mailet/standard/src/test/java/org/apache/james/transport/mailets/UseHeaderRecipientsTest.java
index cdcb968..3d25483 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/mailets/UseHeaderRecipientsTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/mailets/UseHeaderRecipientsTest.java
@@ -22,7 +22,7 @@ package org.apache.james.transport.mailets;
 import static org.assertj.core.api.Assertions.assertThat;
 
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.MailAddressFixture;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMailContext;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/standard/src/test/java/org/apache/james/transport/matchers/AbstractHasMailAttributeTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/AbstractHasMailAttributeTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/AbstractHasMailAttributeTest.java
index fbef0a7..342e154 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/AbstractHasMailAttributeTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/AbstractHasMailAttributeTest.java
@@ -24,7 +24,7 @@ import java.util.Collection;
 
 import javax.mail.MessagingException;
 
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.Matcher;
 import org.apache.mailet.base.GenericMatcher;
 import org.apache.mailet.base.test.FakeMail;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/standard/src/test/java/org/apache/james/transport/matchers/HasMailAttributeWithValueRegexTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/HasMailAttributeWithValueRegexTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/HasMailAttributeWithValueRegexTest.java
index 83e578c..47f60fe 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/HasMailAttributeWithValueRegexTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/HasMailAttributeWithValueRegexTest.java
@@ -24,7 +24,7 @@ import java.util.Collection;
 
 import javax.mail.MessagingException;
 
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.GenericMatcher;
 
 import junit.framework.AssertionFailedError;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/standard/src/test/java/org/apache/james/transport/matchers/HasMailAttributeWithValueTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/HasMailAttributeWithValueTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/HasMailAttributeWithValueTest.java
index ee373f3..f67cc74 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/HasMailAttributeWithValueTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/HasMailAttributeWithValueTest.java
@@ -24,7 +24,7 @@ import java.util.Collection;
 
 import javax.mail.MessagingException;
 
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.GenericMatcher;
 
 public class HasMailAttributeWithValueTest extends AbstractHasMailAttributeTest {

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/standard/src/test/java/org/apache/james/transport/matchers/RecipientIsLocalTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/RecipientIsLocalTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/RecipientIsLocalTest.java
index 853e7e5..5fdb250 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/RecipientIsLocalTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/RecipientIsLocalTest.java
@@ -24,7 +24,7 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.MailetContext;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMatcherConfig;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/standard/src/test/java/org/apache/james/transport/matchers/SMTPAuthSuccessfulTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SMTPAuthSuccessfulTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SMTPAuthSuccessfulTest.java
index 0ca0337..4c1374e 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SMTPAuthSuccessfulTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SMTPAuthSuccessfulTest.java
@@ -24,7 +24,7 @@ import static org.assertj.core.api.Assertions.assertThat;
 import java.util.Collection;
 
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.MailAddressFixture;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMailContext;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/standard/src/test/java/org/apache/james/transport/matchers/SMTPAuthUserIsTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SMTPAuthUserIsTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SMTPAuthUserIsTest.java
index 3f5a533..970ba27 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SMTPAuthUserIsTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SMTPAuthUserIsTest.java
@@ -24,9 +24,8 @@ import java.util.Collection;
 
 import javax.mail.MessagingException;
 
-import org.apache.james.transport.matchers.SMTPAuthUserIs;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.GenericMatcher;
 
 public class SMTPAuthUserIsTest extends AbstractHasMailAttributeTest {

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/standard/src/test/java/org/apache/james/transport/matchers/SMTPIsAuthNetworkTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SMTPIsAuthNetworkTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SMTPIsAuthNetworkTest.java
index 282879c..8f90d00 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SMTPIsAuthNetworkTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SMTPIsAuthNetworkTest.java
@@ -24,7 +24,7 @@ import java.util.Collection;
 
 import javax.mail.MessagingException;
 
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.Matcher;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMatcherConfig;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderHostIsLocalTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderHostIsLocalTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderHostIsLocalTest.java
index d61b52a..6ab12eb 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderHostIsLocalTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderHostIsLocalTest.java
@@ -33,7 +33,7 @@ import java.util.Collection;
 import javax.mail.MessagingException;
 
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.MailetContext;
 import org.apache.mailet.Matcher;
 import org.apache.mailet.base.test.FakeMail;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderHostIsTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderHostIsTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderHostIsTest.java
index 9546906..2904f8a 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderHostIsTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderHostIsTest.java
@@ -29,7 +29,7 @@ import java.util.Collection;
 import javax.mail.MessagingException;
 
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.MailetContext;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMatcherConfig;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderIsLocalTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderIsLocalTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderIsLocalTest.java
index 87b81a7..f97aea6 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderIsLocalTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderIsLocalTest.java
@@ -31,7 +31,7 @@ import java.util.Collection;
 import javax.mail.MessagingException;
 
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.MailetContext;
 import org.apache.mailet.Matcher;
 import org.apache.mailet.base.test.FakeMail;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderIsNullTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderIsNullTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderIsNullTest.java
index ed3a77e..8241b64 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderIsNullTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderIsNullTest.java
@@ -23,7 +23,7 @@ package org.apache.james.transport.matchers;
 import static org.apache.mailet.base.MailAddressFixture.ANY_AT_JAMES;
 import static org.assertj.core.api.Assertions.assertThat;
 
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMatcherConfig;
 import org.junit.Before;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderIsRegexTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderIsRegexTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderIsRegexTest.java
index 2538914..114dc26 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderIsRegexTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderIsRegexTest.java
@@ -24,7 +24,7 @@ import static org.assertj.core.api.Assertions.assertThat;
 
 import javax.mail.MessagingException;
 
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMatcherConfig;
 import org.junit.Before;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderIsTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderIsTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderIsTest.java
index 234e7ad..1c7b823 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderIsTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderIsTest.java
@@ -24,7 +24,7 @@ import static org.assertj.core.api.Assertions.assertThat;
 
 import javax.mail.MessagingException;
 
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMatcherConfig;
 import org.junit.Before;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/standard/src/test/java/org/apache/james/transport/matchers/SentByMailetTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SentByMailetTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SentByMailetTest.java
index 06ac680..67e6285 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SentByMailetTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SentByMailetTest.java
@@ -24,7 +24,7 @@ import static org.assertj.core.api.Assertions.assertThat;
 import java.util.Collection;
 
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.MailAddressFixture;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMailContext;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/standard/src/test/java/org/apache/james/transport/matchers/SubjectIsTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SubjectIsTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SubjectIsTest.java
index fe388c2..11193fa 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SubjectIsTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SubjectIsTest.java
@@ -25,7 +25,7 @@ import static org.assertj.core.api.Assertions.assertThat;
 import javax.mail.MessagingException;
 import javax.mail.internet.AddressException;
 
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMatcherConfig;
 import org.apache.mailet.base.test.MailUtil;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/standard/src/test/java/org/apache/james/transport/matchers/SubjectStartsWithTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SubjectStartsWithTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SubjectStartsWithTest.java
index dd7c28c..e927980 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SubjectStartsWithTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SubjectStartsWithTest.java
@@ -25,7 +25,7 @@ import static org.assertj.core.api.Assertions.assertThat;
 import javax.mail.MessagingException;
 import javax.mail.internet.AddressException;
 
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMatcherConfig;
 import org.apache.mailet.base.test.MailUtil;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/standard/src/test/java/org/apache/james/transport/matchers/TooManyLinesTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/TooManyLinesTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/TooManyLinesTest.java
index 575d396..691b27d 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/TooManyLinesTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/TooManyLinesTest.java
@@ -25,7 +25,7 @@ import java.util.Collection;
 
 import javax.mail.MessagingException;
 
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMatcherConfig;
 import org.apache.mailet.base.test.MimeMessageBuilder;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/standard/src/test/java/org/apache/james/transport/matchers/TooManyRecipientsTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/TooManyRecipientsTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/TooManyRecipientsTest.java
index d399d11..41ee23a 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/TooManyRecipientsTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/TooManyRecipientsTest.java
@@ -25,7 +25,7 @@ import java.util.Collection;
 
 import javax.mail.MessagingException;
 
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMatcherConfig;
 import org.junit.Before;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/standard/src/test/java/org/apache/james/transport/matchers/util/MailAddressCollectionReaderTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/util/MailAddressCollectionReaderTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/util/MailAddressCollectionReaderTest.java
index c7c0494..ce9f83a 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/util/MailAddressCollectionReaderTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/util/MailAddressCollectionReaderTest.java
@@ -22,7 +22,7 @@ package org.apache.james.transport.matchers.util;
 import static org.assertj.core.api.Assertions.assertThat;
 
 import org.apache.james.transport.matchers.utils.MailAddressCollectionReader;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


[09/23] james-project git commit: JAMES-2138 move MailAddress to a new james-core project

Posted by bt...@apache.org.
http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/test/java/org/apache/james/core/MimeMessageInputStreamSourceTest.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/test/java/org/apache/james/core/MimeMessageInputStreamSourceTest.java b/server/container/core/src/test/java/org/apache/james/core/MimeMessageInputStreamSourceTest.java
deleted file mode 100644
index c62f107..0000000
--- a/server/container/core/src/test/java/org/apache/james/core/MimeMessageInputStreamSourceTest.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-package org.apache.james.core;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-import java.io.IOException;
-
-import javax.mail.MessagingException;
-
-import org.apache.james.util.ZeroedInputStream;
-import org.junit.After;
-import org.junit.Test;
-
-public class MimeMessageInputStreamSourceTest {
-
-    private static final int _1M = 1024*1024;
-    private static final int _10KB = 10*1024;
-    private MimeMessageInputStreamSource testee;
-
-    @After
-    public void tearDown() {
-        testee.dispose();
-    }
-    
-    @Test
-    public void streamWith1MBytesShouldBeReadable() throws MessagingException, IOException {
-        testee = new MimeMessageInputStreamSource("myKey", new ZeroedInputStream(_1M));
-        assertThat(testee.getInputStream()).hasSameContentAs(new ZeroedInputStream(_1M));
-    }
-    
-    @Test
-    public void streamWith10KBytesShouldBeReadable() throws MessagingException, IOException {
-        testee = new MimeMessageInputStreamSource("myKey", new ZeroedInputStream(_10KB));
-        assertThat(testee.getInputStream()).hasSameContentAs(new ZeroedInputStream(_10KB));
-    }
-
-    @Test
-    public void streamWithVeryShortNameShouldWork() throws MessagingException, IOException {
-        String veryShortName = "1";
-        testee = new MimeMessageInputStreamSource(veryShortName, new ZeroedInputStream(_1M));
-        assertThat(testee.getInputStream()).isNotNull();
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/test/java/org/apache/james/core/MimeMessageTest.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/test/java/org/apache/james/core/MimeMessageTest.java b/server/container/core/src/test/java/org/apache/james/core/MimeMessageTest.java
deleted file mode 100644
index 7bc2948..0000000
--- a/server/container/core/src/test/java/org/apache/james/core/MimeMessageTest.java
+++ /dev/null
@@ -1,437 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-package org.apache.james.core;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.util.Arrays;
-import java.util.Enumeration;
-import java.util.Properties;
-
-import javax.mail.BodyPart;
-import javax.mail.Session;
-import javax.mail.internet.InternetHeaders;
-import javax.mail.internet.MimeBodyPart;
-import javax.mail.internet.MimeMessage;
-import javax.mail.internet.MimeMultipart;
-
-import org.apache.james.lifecycle.api.LifecycleUtil;
-import org.apache.mailet.base.RFC2822Headers;
-import org.junit.Test;
-
-/**
- * Test the subject folding issue.
- */
-public class MimeMessageTest {
-
-    protected MimeMessage getSimpleMessage() throws Exception {
-        MimeMessage mmCreated = new MimeMessage(Session.getDefaultInstance(new Properties()));
-        mmCreated.setSubject("test");
-        mmCreated.setText("test body");
-        mmCreated.saveChanges();
-        return mmCreated;
-    }
-
-    protected String getSimpleMessageCleanedSource() {
-        return "Subject: test\r\n"
-                + "MIME-Version: 1.0\r\n"
-                + "Content-Type: text/plain; charset=us-ascii\r\n"
-                + "Content-Transfer-Encoding: 7bit\r\n"
-                + "\r\n"
-                + "test body";
-    }
-
-    protected MimeMessage getMessageWithBadReturnPath() throws Exception {
-        MimeMessage mmCreated = new MimeMessage(Session.getDefaultInstance(new Properties()));
-        mmCreated.setSubject("test");
-        mmCreated.setHeader(RFC2822Headers.RETURN_PATH, "<my...@example.com>");
-        mmCreated.setText("test body");
-        mmCreated.saveChanges();
-        return mmCreated;
-    }
-
-    protected String getMessageWithBadReturnPathSource() {
-        return "Subject: test\r\n"
-                + "Return-Path: <my...@example.com>\r\n"
-                + "MIME-Version: 1.0\r\n"
-                + "Content-Type: text/plain; charset=us-ascii\r\n"
-                + "Content-Transfer-Encoding: 7bit\r\n"
-                + "\r\n"
-                + "test body";
-    }
-
-    protected String getSimpleMessageCleanedSourceHeaderExpected() {
-        return "X-Test: foo\r\n" + getSimpleMessageCleanedSource();
-    }
-
-    /*
-     * Class under test for String getSubject()
-     */
-    @Test
-    public void testSimpleMessage() throws Exception {
-        MimeMessage m = getSimpleMessage();
-        assertEquals(getSimpleMessageCleanedSource(), getCleanedMessageSource(m));
-        LifecycleUtil.dispose(m);
-    }
-
-    protected MimeMessage getMultipartMessage() throws Exception {
-        MimeMessage mmCreated = new MimeMessage(Session.getDefaultInstance(new Properties()));
-        mmCreated.setSubject("test");
-        MimeMultipart mm = new MimeMultipart("alternative");
-        mm.addBodyPart(new MimeBodyPart(new InternetHeaders(new ByteArrayInputStream("X-header: test1\r\nContent-Type: text/plain; charset=Cp1252\r\n".
-                getBytes())), "first part \u00F2\u00E0\u00F9".getBytes()));
-        mm.addBodyPart(new MimeBodyPart(new InternetHeaders(new ByteArrayInputStream("X-header: test2\r\nContent-Type: text/plain; charset=Cp1252\r\nContent-Transfer-Encoding: quoted-printable\r\n".
-                getBytes())), "second part =E8=E8".getBytes()));
-        mmCreated.setContent(mm);
-        mmCreated.saveChanges();
-        return mmCreated;
-    }
-
-    protected String getMultipartMessageSource() {
-        return "Subject: test\r\n"
-                + "MIME-Version: 1.0\r\n"
-                + "Content-Type: multipart/alternative; \r\n"
-                + "\tboundary=\"----=_Part_0_XXXXXXXXXXX.XXXXXXXXXXX\"\r\n"
-                + "\r\n"
-                + "------=_Part_0_XXXXXXXXXXX.XXXXXXXXXXX\r\n"
-                + "X-header: test1\r\n"
-                + "Content-Type: text/plain; charset=Cp1252\r\n"
-                + "Content-Transfer-Encoding: quoted-printable\r\n"
-                + "\r\n"
-                + "first part =E8\r\n"
-                + "------=_Part_0_XXXXXXXXXXX.XXXXXXXXXXX\r\n"
-                + "X-header: test2\r\n"
-                + "Content-Type: text/plain; charset=Cp1252\r\n"
-                + "Content-Transfer-Encoding: quoted-printable\r\n"
-                + "\r\n"
-                + "second part =E8=E8\r\n"
-                + "------=_Part_0_XXXXXXXXXXX.XXXXXXXXXXX--\r\n";
-    }
-
-    protected String getMultipartMessageExpected1() {
-        return "Subject: test\r\n"
-                + "MIME-Version: 1.0\r\n"
-                + "Content-Type: multipart/alternative; \r\n"
-                + "\tboundary=\"----=_Part_0_XXXXXXXXXXX.XXXXXXXXXXX\"\r\n"
-                + "\r\n"
-                + "------=_Part_0_XXXXXXXXXXX.XXXXXXXXXXX\r\n"
-                + "X-header: test1\r\n"
-                + "Content-Type: text/plain; charset=Cp1252\r\n"
-                + "Content-Transfer-Encoding: quoted-printable\r\n"
-                + "\r\n"
-                + "test=80\r\n"
-                + "------=_Part_0_XXXXXXXXXXX.XXXXXXXXXXX\r\n"
-                + "X-header: test2\r\n"
-                + "Content-Type: text/plain; charset=Cp1252\r\n"
-                + "Content-Transfer-Encoding: quoted-printable\r\n"
-                + "\r\n"
-                + "second part =E8=E8\r\n"
-                + "------=_Part_0_XXXXXXXXXXX.XXXXXXXXXXX--\r\n";
-    }
-
-    protected String getMultipartMessageExpected2() {
-        return "Subject: test\r\n"
-                + "MIME-Version: 1.0\r\n"
-                + "Content-Type: multipart/alternative; \r\n"
-                + "\tboundary=\"----=_Part_0_XXXXXXXXXXX.XXXXXXXXXXX\"\r\n"
-                + "\r\n"
-                + "------=_Part_0_XXXXXXXXXXX.XXXXXXXXXXX\r\n"
-                + "X-header: test1\r\n"
-                + "Content-Type: text/plain; charset=Cp1252\r\n"
-                + "Content-Transfer-Encoding: quoted-printable\r\n"
-                + "\r\n"
-                + "test=80\r\n"
-                + "------=_Part_0_XXXXXXXXXXX.XXXXXXXXXXX\r\n"
-                + "X-header: test2\r\n"
-                + "Content-Type: text/plain; charset=Cp1252\r\n"
-                + "Content-Transfer-Encoding: quoted-printable\r\n"
-                + "\r\n"
-                + "second part =E8=E8\r\n"
-                + "------=_Part_0_XXXXXXXXXXX.XXXXXXXXXXX\r\n"
-                + "Subject: test3\r\n"
-                + "\r\n"
-                + "third part\r\n"
-                + "------=_Part_0_XXXXXXXXXXX.XXXXXXXXXXX--\r\n";
-    }
-
-    protected String getMultipartMessageExpected3() {
-        return "Subject: test\r\n"
-                + "MIME-Version: 1.0\r\n"
-                + "Content-Type: binary/octet-stream\r\n"
-                + "Content-Transfer-Encoding: quoted-printable\r\n"
-                + "\r\n"
-                + "mynewco=F2=E0=F9ntent=80=E0!";
-    }
-
-    /*
-     * Class under test for String getSubject()
-     */
-    @Test
-    public void testMultipartMessageChanges() throws Exception {
-
-        MimeMessage mm = getMultipartMessage();
-
-        // ByteArrayOutputStream out = new ByteArrayOutputStream();
-        // mmCreated.writeTo(out,new String[] {"Message-ID"});
-        // String messageSource = out.toString();
-        // System.out.println(messageSource);
-
-        MimeMultipart content1 = (MimeMultipart) mm.getContent();
-        BodyPart b1 = content1.getBodyPart(0);
-        b1.setContent("test\u20AC", "text/plain; charset=Cp1252");
-        mm.setContent(content1, mm.getContentType());
-        // .setHeader(RFC2822Headers.CONTENT_TYPE,contentType);
-        mm.saveChanges();
-
-        assertEquals(getMultipartMessageExpected1(), getCleanedMessageSource(mm));
-
-        MimeMultipart content2 = (MimeMultipart) mm.getContent();
-        content2.addBodyPart(new MimeBodyPart(new InternetHeaders(new ByteArrayInputStream(
-                "Subject: test3\r\n".getBytes())), "third part".getBytes()));
-        mm.setContent(content2, mm.getContentType());
-        mm.saveChanges();
-
-        assertEquals(getMultipartMessageExpected2(), getCleanedMessageSource(mm));
-
-        mm.setContent("mynewco\u00F2\u00E0\u00F9ntent\u20AC\u00E0!", "text/plain; charset=cp1252");
-        mm.setHeader(RFC2822Headers.CONTENT_TYPE, "binary/octet-stream");
-        // mm.setHeader("Content-Transfer-Encoding","8bit");
-        mm.saveChanges();
-
-        assertEquals(getMultipartMessageExpected3(), getCleanedMessageSource(mm));
-
-        LifecycleUtil.dispose(mm);
-
-    }
-
-    protected MimeMessage getMissingEncodingAddHeaderMessage() throws Exception {
-        MimeMessage m = new MimeMessage(Session.getDefaultInstance(new Properties()));
-        m.setText("Test\u00E0\r\n");
-        m.setSubject("test");
-        m.saveChanges();
-        return m;
-    }
-
-    protected String getMissingEncodingAddHeaderSource() {
-        return "Subject: test\r\n"
-                + "\r\n"
-                + "Test\u00E0\r\n";
-    }
-
-    protected String getMissingEncodingAddHeaderExpected() {
-        return "Subject: test\r\n"
-                + "MIME-Version: 1.0\r\n"
-                + "Content-Type: text/plain; charset=Cp1252\r\n"
-                + "Content-Transfer-Encoding: quoted-printable\r\n"
-                + "\r\n"
-                + "Test=E0\r\n";
-    }
-
-    /**
-     * This test is not usable in different locale environment.
-     */
-    /*
-     * public void testMissingEncodingAddHeader() throws Exception {
-     * 
-     * 
-     * MimeMessage mm = getMissingEncodingAddHeaderMessage();
-     * mm.setHeader("Content-Transfer-Encoding", "quoted-printable");
-     * mm.saveChanges();
-     * 
-     * assertEquals(getMissingEncodingAddHeaderExpected(),getCleanedMessageSource
-     * (mm)); }
-     */
-    protected String getCleanedMessageSource(MimeMessage mm) throws Exception {
-        ByteArrayOutputStream out2;
-        out2 = new ByteArrayOutputStream();
-        mm.writeTo(out2, new String[]{"Message-ID"});
-
-        String res = out2.toString();
-
-        int p = res.indexOf("\r\n\r\n");
-        if (p > 0) {
-            String head = res.substring(0, p);
-            String[] str = head.split("\r\n");
-            Arrays.sort(str);
-            StringBuilder outputHead = new StringBuilder();
-            for (int i = str.length - 1; i >= 0; i--) {
-                outputHead.append(str[i]);
-                outputHead.append("\r\n");
-            }
-            outputHead.append(res.substring(p + 2));
-            res = outputHead.toString();
-        }
-
-        res = res.replaceAll("----=_Part_\\d*_\\d+\\.\\d+", "----=_Part_\\0_XXXXXXXXXXX.XXXXXXXXXXX");
-        return res;
-    }
-
-    protected void debugMessage(MimeMessage mm) throws Exception {
-        System.out.println("-------------------");
-        System.out.println(getCleanedMessageSource(mm));
-        System.out.println("-------------------");
-    }
-
-    protected MimeMessage getMissingEncodingMessage() throws Exception {
-        MimeMessage mmCreated = new MimeMessage(Session.getDefaultInstance(new Properties()));
-        mmCreated.setSubject("test");
-        MimeMultipart mm = new MimeMultipart("alternative");
-        mm.addBodyPart(new MimeBodyPart(new InternetHeaders(new ByteArrayInputStream("X-header: test2\r\nContent-Type: text/plain; charset=Cp1252\r\nContent-Transfer-Encoding: quoted-printable\r\n".
-                getBytes())), "second part =E8=E8".getBytes()));
-        mmCreated.setContent(mm);
-        mmCreated.saveChanges();
-        return mmCreated;
-    }
-
-    protected String getMissingEncodingMessageSource() {
-        return "Subject: test\r\n"
-                + "MIME-Version: 1.0\r\n"
-                + "Content-Type: multipart/alternative; \r\n"
-                + "\tboundary=\"----=_Part_0_XXXXXXXXXXX.XXXXXXXXXXX\"\r\n"
-                + "\r\n"
-                + "------=_Part_0_XXXXXXXXXXX.XXXXXXXXXXX\r\n"
-                + "X-header: test2\r\n"
-                + "Content-Type: text/plain; charset=Cp1252\r\n"
-                + "Content-Transfer-Encoding: quoted-printable\r\n"
-                + "\r\n"
-                + "second part =E8=E8\r\n"
-                + "------=_Part_0_XXXXXXXXXXX.XXXXXXXXXXX--\r\n";
-    }
-
-    @Test
-    public void testGetLineCount() throws Exception {
-        MimeMessage mm = getMissingEncodingMessage();
-        try {
-            int count = mm.getLineCount();
-            assertTrue(count == -1 || count == 7);
-        } catch (Exception e) {
-            fail("Unexpected exception in getLineCount");
-        }
-        LifecycleUtil.dispose(mm);
-    }
-
-    /**
-     * This test throw a NullPointerException when the original message was
-     * created by a MimeMessageInputStreamSource.
-     */
-    @Test
-    public void testMessageCloningViaCoW() throws Exception {
-        MimeMessage mmorig = getSimpleMessage();
-
-        MimeMessage mm = new MimeMessageCopyOnWriteProxy(mmorig);
-
-        MimeMessage mm2 = new MimeMessageCopyOnWriteProxy(mm);
-
-        mm2.setHeader("Subject", "Modified");
-
-        LifecycleUtil.dispose(mm2);
-        System.gc();
-        Thread.sleep(200);
-        // ((Disposable)mail_dup.getMessage()).dispose();
-
-        mm.setHeader("Subject", "Modified");
-
-        LifecycleUtil.dispose(mm);
-        LifecycleUtil.dispose(mmorig);
-    }
-
-    /**
-     * This test throw a NullPointerException when the original message was
-     * created by a MimeMessageInputStreamSource.
-     */
-    @Test
-    public void testMessageCloningViaCoW2() throws Exception {
-        MimeMessage mmorig = getSimpleMessage();
-
-        MimeMessage mm = new MimeMessageCopyOnWriteProxy(mmorig);
-
-        MimeMessage mm2 = new MimeMessageCopyOnWriteProxy(mm);
-
-        LifecycleUtil.dispose(mm);
-        mm = null;
-        System.gc();
-        Thread.sleep(200);
-
-        try {
-            mm2.writeTo(System.out);
-        } catch (Exception e) {
-            e.printStackTrace();
-            fail("Exception while writing the message to output");
-        }
-
-        LifecycleUtil.dispose(mm2);
-        LifecycleUtil.dispose(mmorig);
-    }
-
-    /**
-     * This test throw a NullPointerException when the original message was
-     * created by a MimeMessageInputStreamSource.
-     */
-    @Test
-    public void testMessageCloningViaCoWSubjectLost() throws Exception {
-        MimeMessage mmorig = getSimpleMessage();
-
-        MimeMessage mm = new MimeMessageCopyOnWriteProxy(mmorig);
-
-        mm.setHeader("X-Test", "foo");
-        mm.saveChanges();
-
-        assertEquals(getSimpleMessageCleanedSourceHeaderExpected(), getCleanedMessageSource(mm));
-
-        LifecycleUtil.dispose(mm);
-        LifecycleUtil.dispose(mmorig);
-    }
-
-    @Test
-    public void testReturnPath() throws Exception {
-        MimeMessage message = getSimpleMessage();
-        assertNull(message.getHeader(RFC2822Headers.RETURN_PATH));
-        LifecycleUtil.dispose(message);
-    }
-
-    @Test
-    public void testHeaderOrder() throws Exception {
-        MimeMessage message = getSimpleMessage();
-        message.setHeader(RFC2822Headers.RETURN_PATH, "<te...@test.de>");
-        @SuppressWarnings("unchecked")
-        Enumeration<String> h = message.getAllHeaderLines();
-
-        assertEquals(h.nextElement(), "Return-Path: <te...@test.de>");
-        LifecycleUtil.dispose(message);
-    }
-
-    /**
-     * http://issues.apache.org/jira/browse/GERONIMO-4261
-     * 
-     * This bug was in geronimo-javamail_1.4-1.5 Has been fixed in
-     * geronimo-javamail_1.4-1.6
-     */
-    @Test
-    public void testGeronimoIndexOutOfBounds() throws Exception {
-        String message = "                  \r\n" + "Subject: test\r\n" + "\r\n" + "Body\r\n";
-
-        byte[] messageBytes = message.getBytes("US-ASCII");
-        new MimeMessage(null, new ByteArrayInputStream(messageBytes));
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/test/java/org/apache/james/core/MimeMessageUtilTest.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/test/java/org/apache/james/core/MimeMessageUtilTest.java b/server/container/core/src/test/java/org/apache/james/core/MimeMessageUtilTest.java
deleted file mode 100644
index af14dd6..0000000
--- a/server/container/core/src/test/java/org/apache/james/core/MimeMessageUtilTest.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-
-package org.apache.james.core;
-
-import javax.mail.MessagingException;
-import javax.mail.Session;
-import javax.mail.internet.MimeMessage;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.util.Properties;
-import org.junit.Test;
-
-public class MimeMessageUtilTest {
-
-    @Test
-    public void testWriteMimeMessageMultipartWithMessageID() throws MessagingException, IOException {
-        String message = "Received: from localhost.localdomain ([127.0.0.1])\r\n" +
-        "          by athlon14 (JAMES SMTP Server 2.3-dev) with SMTP ID 694\r\n" +
-        "          for <te...@athlon14.bf.loc>;\r\n" +
-        "          Sat, 18 Feb 2006 19:30:53 +0100 (CET)\r\n" +
-        "Subject: ext2int\r\n" +
-        "X-James-Postage: This is a test mail sent by James Postage\r\n" +
-        "Mime-Version: 1.0\r\n" +
-        "Content-Type: multipart/alternative; boundary=\"XyoYyxCQIfmZ5Sxofid6XQVZt5Z09XtTnqBF4Z45XSA=\"\r\n" +
-        "Date: Sat, 18 Feb 2006 19:30:53 +0100 (CET)\r\n" +
-        "From: test_ext2@another.bf.loc\r\n" +
-        "\r\n" +
-        "\r\n" +
-        "--XyoYyxCQIfmZ5Sxofid6XQVZt5Z09XtTnqBF4Z45XSA=\r\n" +
-        "Content-Type: text/plain\r\n" +
-        "\r\n" +
-        "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\r\n" +
-        "--XyoYyxCQIfmZ5Sxofid6XQVZt5Z09XtTnqBF4Z45XSA=\r\n" +
-        "Content-Type: application/octet-stream\r\n" +
-        "\r\n" +
-        "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\r\n" +
-        "--XyoYyxCQIfmZ5Sxofid6XQVZt5Z09XtTnqBF4Z45XSA=--\r\n";
-
-        MimeMessage mimeMessage = new MimeMessage(Session.getDefaultInstance(new Properties()), new ByteArrayInputStream(message.getBytes()));
-        mimeMessage.getSize();
-        ByteArrayOutputStream headerOut = new ByteArrayOutputStream();
-        ByteArrayOutputStream bodyOut = new ByteArrayOutputStream();
-        MimeMessageUtil.writeTo(mimeMessage, headerOut, bodyOut);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/test/java/org/apache/james/core/MimeMessageWrapperTest.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/test/java/org/apache/james/core/MimeMessageWrapperTest.java b/server/container/core/src/test/java/org/apache/james/core/MimeMessageWrapperTest.java
deleted file mode 100644
index 2f06915..0000000
--- a/server/container/core/src/test/java/org/apache/james/core/MimeMessageWrapperTest.java
+++ /dev/null
@@ -1,289 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-package org.apache.james.core;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.io.BufferedReader;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.util.Enumeration;
-import java.util.Properties;
-
-import javax.mail.MessagingException;
-import javax.mail.Session;
-import javax.mail.internet.MimeMessage;
-import javax.mail.util.SharedByteArrayInputStream;
-
-import org.apache.james.lifecycle.api.LifecycleUtil;
-import org.apache.mailet.base.RFC2822Headers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-
-/**
- * Test the subject folding issue.
- */
-public class MimeMessageWrapperTest extends MimeMessageFromStreamTest {
-
-    private final class TestableMimeMessageWrapper extends MimeMessageWrapper {
-
-        boolean messageLoadable = true;
-        boolean headersLoadable = true;
-
-        private TestableMimeMessageWrapper(MimeMessageSource source) throws MessagingException {
-            super(source);
-        }
-
-        public boolean messageParsed() {
-            return messageParsed;
-        }
-
-        public void setHeadersLoadable(boolean headersLoadable) {
-            this.headersLoadable = headersLoadable;
-        }
-
-        @Override
-        protected synchronized void loadHeaders() throws MessagingException {
-            if (headersLoadable) {
-                super.loadHeaders();
-            } else {
-                throw new IllegalStateException("headersLoadable disabled");
-            }
-        }
-
-        @Override
-        public synchronized void loadMessage() throws MessagingException {
-            if (messageLoadable) {
-                super.loadMessage();
-            } else {
-                throw new IllegalStateException("messageLoadable disabled");
-            }
-        }
-    }
-    TestableMimeMessageWrapper mw = null;
-    final String content = "Subject: foo\r\nContent-Transfer-Encoding2: plain";
-    final String sep = "\r\n\r\n";
-    final String body = "bar\r\n";
-
-    @Rule
-    public ExpectedException expectedException = ExpectedException.none();
-
-    @Override
-    protected MimeMessage getMessageFromSources(String sources) throws Exception {
-        MimeMessageInputStreamSource mmis = new MimeMessageInputStreamSource("test", new SharedByteArrayInputStream(sources.getBytes()));
-        return new TestableMimeMessageWrapper(mmis);
-    }
-
-    @Before
-    public void setUp() throws Exception {
-        mw = (TestableMimeMessageWrapper) getMessageFromSources(content + sep + body);
-    }
-
-    @After
-    public void tearDown() throws Exception {
-        LifecycleUtil.dispose(mw);
-    }
-
-    @Test
-    public void testDeferredMessageLoading() throws MessagingException, IOException {
-        assertEquals("foo", mw.getSubject());
-        assertFalse(mw.messageParsed());
-        assertEquals("bar\r\n", mw.getContent());
-        assertTrue(mw.messageParsed());
-        assertFalse(mw.isModified());
-    }
-
-    /**
-     * this is commented out due optimisation reverts (JAMES-559) public void
-     * testDeferredMessageLoadingWhileWriting() throws MessagingException,
-     * IOException { mw.setMessageLoadable(false);
-     * assertEquals("foo",mw.getSubject()); assertFalse(mw.isModified());
-     * mw.setSubject("newSubject"); assertEquals("newSubject",mw.getSubject());
-     * assertFalse(mw.messageParsed()); assertTrue(mw.isModified());
-     * mw.setMessageLoadable(true);
-     * 
-     * }
-     */
-    @Test
-    public void testDeferredHeaderLoading() throws MessagingException, IOException {
-        mw.setHeadersLoadable(false);
-
-        expectedException.expect(IllegalStateException.class);
-
-        mw.getSubject();
-    }
-
-    /**
-     * See JAMES-474 MimeMessageWrapper(MimeMessage) should clone the original
-     * message.
-     */
-    @Test
-    public void testMessageCloned() throws MessagingException, IOException, InterruptedException {
-        MimeMessageWrapper mmw = new MimeMessageWrapper(mw);
-        LifecycleUtil.dispose(mw);
-        mw = null;
-        System.gc();
-        Thread.sleep(200);
-        mmw.writeTo(System.out);
-    }
-
-    @Test
-    public void testGetSubjectFolding() throws Exception {
-        StringBuilder res = new StringBuilder();
-        BufferedReader r = new BufferedReader(new InputStreamReader(mw.getInputStream()));
-        String line;
-        while (r.ready()) {
-            line = r.readLine();
-            res.append(line).append("\r\n");
-        }
-        r.close();
-        assertEquals(body, res.toString());
-    }
-
-    @Test
-    public void testAddHeaderAndSave() throws Exception {
-        mw.addHeader("X-Test", "X-Value");
-
-        assertEquals("X-Value", mw.getHeader("X-Test")[0]);
-
-        mw.saveChanges();
-
-        ByteArrayOutputStream rawMessage = new ByteArrayOutputStream();
-        mw.writeTo(rawMessage);
-
-        assertEquals("X-Value", mw.getHeader("X-Test")[0]);
-
-        String res = rawMessage.toString();
-
-        boolean found = res.indexOf("X-Test: X-Value") > 0;
-        assertEquals(true, found);
-    }
-
-    @Test
-    public void testReplaceReturnPathOnBadMessage() throws Exception {
-        MimeMessage message = getMessageWithBadReturnPath();
-        message.setHeader(RFC2822Headers.RETURN_PATH, "<te...@test.de>");
-        @SuppressWarnings("unchecked")
-        Enumeration<String> e = message.getMatchingHeaderLines(new String[]{"Return-Path"});
-        assertEquals("Return-Path: <te...@test.de>", e.nextElement());
-        assertFalse(e.hasMoreElements());
-        @SuppressWarnings("unchecked")
-        Enumeration<String> h = message.getAllHeaderLines();
-        assertEquals("Return-Path: <te...@test.de>", h.nextElement());
-        assertFalse(h.nextElement().toString().startsWith("Return-Path:"));
-        LifecycleUtil.dispose(message);
-    }
-
-    @Test
-    public void testAddReturnPathOnBadMessage() throws Exception {
-        MimeMessage message = getMessageWithBadReturnPath();
-        message.addHeader(RFC2822Headers.RETURN_PATH, "<te...@test.de>");
-        // test that we have now 2 return-paths
-        @SuppressWarnings("unchecked")
-        Enumeration<String> e = message.getMatchingHeaderLines(new String[]{"Return-Path"});
-        assertEquals("Return-Path: <te...@test.de>", e.nextElement());
-        assertEquals("Return-Path: <my...@example.com>", e.nextElement());
-        // test that return-path is the first line
-        @SuppressWarnings("unchecked")
-        Enumeration<String> h = message.getAllHeaderLines();
-        assertEquals("Return-Path: <te...@test.de>", h.nextElement());
-        LifecycleUtil.dispose(message);
-    }
-
-    /**
-     * Test for JAMES-1154
-     */
-    @Test
-    public void testMessageStreamWithUpatedHeaders() throws MessagingException, IOException {
-        mw.addHeader("X-Test", "X-Value");
-
-        assertEquals("X-Value", mw.getHeader("X-Test")[0]);
-
-        mw.saveChanges();
-
-        BufferedReader reader = new BufferedReader(new InputStreamReader(mw.getMessageInputStream()));
-
-        boolean headerUpdated = reader.lines()
-            .anyMatch(line -> line.equals("X-Test: X-Value"));
-        reader.close();
-        assertTrue(headerUpdated);
-    }
-
-    /**
-     * Test for JAMES-1154
-     */
-    @Test
-    public void testMessageStreamWithUpatedContent() throws MessagingException, IOException {
-        String newContent = "This is the new message content!";
-        mw.setText(newContent);
-        assertEquals(newContent, mw.getContent());
-
-        mw.saveChanges();
-
-        BufferedReader reader = new BufferedReader(new InputStreamReader(mw.getMessageInputStream()));
-
-        boolean contentUpdated = reader.lines()
-            .anyMatch(line -> line.equals(newContent));
-        reader.close();
-        assertTrue(contentUpdated);
-    }
-
-    @Test
-    public void testSize() throws MessagingException {
-        assertEquals(body.length(), mw.getSize());
-    }
-
-    @Test
-    public void testSizeModifiedHeaders() throws MessagingException {
-        mw.addHeader("whatever", "test");
-        assertEquals(body.length(), mw.getSize());
-    }
-
-    @Test
-    public void testSizeModifiedBodyWithoutSave() throws MessagingException {
-        String newBody = "This is the new body of the message";
-        mw.setText(newBody);
-        assertEquals(body.length(), mw.getSize());
-    }
-
-    @Test
-    public void testSizeModifiedBodyWithSave() throws MessagingException {
-        String newBody = "This is the new body of the message";
-        mw.setText(newBody);
-        mw.saveChanges();
-        assertEquals(body.length(), mw.getSize());
-    }
-    
-    @Test
-    public void jiraJames1593() throws MessagingException, IOException {
-        Properties noProperties = new Properties();
-        Session session = Session.getDefaultInstance(noProperties);
-        InputStream stream = ClassLoader.getSystemResourceAsStream("JAMES-1593.eml");
-        MimeMessage message = new MimeMessage(session, stream);
-        MimeMessageWrapper wrapper = new MimeMessageWrapper(message);
-        assertEquals("\"base64\"", wrapper.getEncoding());
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/test/java/org/apache/james/core/filesystem/FileSystemImplTest.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/test/java/org/apache/james/core/filesystem/FileSystemImplTest.java b/server/container/core/src/test/java/org/apache/james/core/filesystem/FileSystemImplTest.java
deleted file mode 100644
index 28c9de4..0000000
--- a/server/container/core/src/test/java/org/apache/james/core/filesystem/FileSystemImplTest.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-package org.apache.james.core.filesystem;
-
-import org.apache.james.core.JamesServerResourceLoader;
-import org.apache.james.filesystem.api.AbstractFileSystemTest;
-import org.apache.james.filesystem.api.FileSystem;
-
-public class FileSystemImplTest extends AbstractFileSystemTest {
-
-    @Override
-    protected FileSystem buildFileSystem(String configurationRootDirectory) {
-        return new FileSystemImpl(new JamesServerResourceLoader(configurationRootDirectory));
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/test/java/org/apache/james/core/filesystem/SimpleUrlTest.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/test/java/org/apache/james/core/filesystem/SimpleUrlTest.java b/server/container/core/src/test/java/org/apache/james/core/filesystem/SimpleUrlTest.java
deleted file mode 100644
index 239592e..0000000
--- a/server/container/core/src/test/java/org/apache/james/core/filesystem/SimpleUrlTest.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-package org.apache.james.core.filesystem;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-import org.junit.Test;
-
-public class SimpleUrlTest {
-
-    @Test(expected=NullPointerException.class)
-    public void simplifyPathShouldThrowOnNull() {
-        SimpleUrl.simplifyPath(null);
-    }
-    
-    @Test
-    public void simplifyPathShouldReturnEmptyOnEmptyArray() {
-        String actual = SimpleUrl.simplifyPath("");
-        assertThat(actual).isEmpty();
-    }
-
-    @Test
-    public void simplifyPathShoudReturnEmptyWhenSimplifyingCurrentDir() {
-        String actual = SimpleUrl.simplifyPath("./bar/.././foo/..");
-        assertThat(actual).isEmpty();
-    }
-
-    @Test
-    public void simplifyPathShoudReturnSimplifiedDirectory() {
-        String actual = SimpleUrl.simplifyPath("../foo/../bar/./baz");
-        assertThat(actual).isEqualTo("../bar/baz");
-    }
-
-    @Test
-    public void simplifiedShouldReturnEmptyWhenEmptyInput() {
-        assertThat(new SimpleUrl("").getSimplified()).isEmpty();
-    }
-
-    @Test(expected=NullPointerException.class)
-    public void simplifiedShouldThrowWhenNullInput() {
-        new SimpleUrl(null);
-    }
-
-    @Test
-    public void simplifiedShouldReturnInputValueWhenProtocolOnlyInput() {
-        assertThat(new SimpleUrl("file:").getSimplified()).isEqualTo("file:");
-    }
-
-    @Test
-    public void simplifiedShouldReturnInputValueWhenRelativePath() {
-        assertThat(new SimpleUrl("abcd/ef/gh").getSimplified()).isEqualTo("abcd/ef/gh");
-    }
-
-    @Test
-    public void simplifiedShouldReturnInputValueWhenAbsolutePath() {
-        assertThat(new SimpleUrl("/abcd/ef/gh").getSimplified()).isEqualTo("/abcd/ef/gh");
-    }
-
-    @Test
-    public void simplifiedShouldReturnInputValueWhenHttpUrl() {
-        assertThat(new SimpleUrl("http://example.com/ef/gh").getSimplified()).isEqualTo("http://example.com/ef/gh");
-    }
-
-    @Test
-    public void simplifiedShouldReturnInputValueWhenPathContainsColumn() {
-        assertThat(new SimpleUrl("ab/cd:ef/gh").getSimplified()).isEqualTo("ab/cd:ef/gh");
-    }
-
-    @Test
-    public void simplifiedShouldCollapseComplexePathWhenContainingParentDirElement() {
-        assertThat(new SimpleUrl("file:///home/user/./foo/../.bar/baz").getSimplified()).isEqualTo("file:///home/user/.bar/baz");
-    }
-
-    @Test
-    public void simplifiedShouldCollapseComplexePathWhenContainingParentDirElementInRelativePath() {
-        assertThat(new SimpleUrl("file://../.././foo/../.bar/baz").getSimplified()).isEqualTo("file://../../.bar/baz");
-    }
-
-    @Test
-    public void simplifiedShouldCollapseComplexePathWhenContainingParentDirElementWithoutDoubleSlashes() {
-        assertThat(new SimpleUrl("file:/home/user/./foo/../.bar/baz").getSimplified()).isEqualTo("file:/home/user/.bar/baz");
-    }
-
-    @Test
-    public void simplifiedShouldCollapseComplexePathWhenContainingParentDirElementInRelativePathWithoutDoubleSlashes() {
-        assertThat(new SimpleUrl("file:../.././foo/../.bar/baz").getSimplified()).isEqualTo("file:../../.bar/baz");
-    }
-
-    @Test
-    public void simplifiedShouldReplaceASingleWindowSeperatorByASlash() {
-        assertThat(new SimpleUrl("\\").getSimplified()).isEqualTo("/");
-    }
-
-    @Test
-    public void simplifiedShouldReplaceAllWindowsSeperatorBySlashes() {
-        assertThat(new SimpleUrl("file:c:\\\\programs\\run.exe").getSimplified()).isEqualTo("file:c://programs/run.exe");
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/test/java/org/apache/james/server/core/MailHeadersTest.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/test/java/org/apache/james/server/core/MailHeadersTest.java b/server/container/core/src/test/java/org/apache/james/server/core/MailHeadersTest.java
new file mode 100644
index 0000000..cf75a12
--- /dev/null
+++ b/server/container/core/src/test/java/org/apache/james/server/core/MailHeadersTest.java
@@ -0,0 +1,43 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+package org.apache.james.server.core;
+
+import java.io.ByteArrayInputStream;
+import java.util.Enumeration;
+import javax.mail.MessagingException;
+import org.apache.mailet.base.RFC2822Headers;
+import static org.junit.Assert.assertEquals;
+import org.junit.Test;
+
+public class MailHeadersTest {
+
+    @Test
+    public void testHeadersOrder() throws MessagingException {
+        MailHeaders header = new MailHeaders(new ByteArrayInputStream((RFC2822Headers.SUBJECT + ": testsubject\r\n").
+                getBytes()));
+        header.setHeader(RFC2822Headers.RETURN_PATH, "<te...@test>");
+        header.setHeader(RFC2822Headers.FROM, "<te...@test.de>");
+        @SuppressWarnings("unchecked")
+        Enumeration<String> h = header.getAllHeaderLines();
+
+        assertEquals(h.nextElement(), "Return-Path: <te...@test>");
+        assertEquals(h.nextElement(), "From: <te...@test.de>");
+        assertEquals(h.nextElement(), "Subject: testsubject");
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/test/java/org/apache/james/server/core/MailImplTest.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/test/java/org/apache/james/server/core/MailImplTest.java b/server/container/core/src/test/java/org/apache/james/server/core/MailImplTest.java
new file mode 100644
index 0000000..ab5d9b7
--- /dev/null
+++ b/server/container/core/src/test/java/org/apache/james/server/core/MailImplTest.java
@@ -0,0 +1,115 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+package org.apache.james.server.core;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertNull;
+
+import java.io.ByteArrayInputStream;
+import java.util.ArrayList;
+
+import javax.mail.MessagingException;
+import javax.mail.Session;
+import javax.mail.internet.MimeMessage;
+
+import org.apache.james.core.MailAddress;
+import org.apache.mailet.Mail;
+import org.apache.mailet.base.test.MailUtil;
+import org.junit.Test;
+
+public class MailImplTest extends MailTestAllImplementations {
+
+    private static final Session NO_SESSION = null;
+    
+    @Override
+    protected Mail createMailImplementation() {
+        return new MailImpl();
+    }
+
+    @Test
+    public void testConstr1() throws MessagingException {
+        MailImpl mail = new MailImpl();
+
+        helperTestInitialState(mail);
+        helperTestMessageSize(mail, 0); // MimeMessageWrapper default is 0
+        assertNull("no initial message", mail.getMessage());
+        assertNull("no initial sender", mail.getSender());
+        assertNull("no initial name", mail.getName());
+    }
+
+    @Test
+    public void testConstr2() throws MessagingException {
+        ArrayList<MailAddress> recepients = new ArrayList<>();
+        String name = MailUtil.newId();
+        String sender = "sender@localhost";
+        MailAddress senderMailAddress = new MailAddress(sender);
+        MailImpl mail = new MailImpl(name, senderMailAddress, recepients);
+
+        helperTestInitialState(mail); // MimeMessageWrapper default is 0
+        helperTestMessageSize(mail, 0); // MimeMessageWrapper default is 0
+        assertNull("no initial message", mail.getMessage());
+        assertEquals("sender", sender, mail.getSender().toString());
+        assertEquals("name", name, mail.getName());
+
+        mail.setMessage(new MimeMessage(NO_SESSION));
+        assertNotNull("message", mail.getMessage());
+    }
+
+    @Test
+    public void testConstr3() throws MessagingException {
+        ArrayList<MailAddress> recepients = new ArrayList<>();
+        String name = MailUtil.newId();
+        String sender = "sender@localhost";
+        MailAddress senderMailAddress = new MailAddress(sender);
+        MimeMessage mimeMessage = new MimeMessage(NO_SESSION, new ByteArrayInputStream(new byte[0]));
+        MailImpl mail = new MailImpl(name, senderMailAddress, recepients, mimeMessage);
+
+        helperTestInitialState(mail);
+        helperTestMessageSize(mail, 0);
+        assertEquals("initial message", mimeMessage.getMessageID(), mail.getMessage().getMessageID());
+        assertEquals("sender", sender, mail.getSender().toString());
+        assertEquals("name", name, mail.getName());
+        mail.dispose();
+    }
+
+    @Test
+    public void testDuplicate() throws MessagingException {
+        MailImpl mail = new MailImpl();
+        MailImpl duplicate = (MailImpl) mail.duplicate();
+        assertNotSame("is real duplicate", mail, duplicate);
+        helperTestInitialState(duplicate);
+        helperTestMessageSize(duplicate, 0);
+    }
+
+    @Test
+    public void testDuplicateNewName() throws MessagingException {
+        String newName = "aNewName";
+
+        MailImpl mail = new MailImpl();
+        assertFalse("before + after names differ", newName.equals(mail.getName()));
+
+        MailImpl duplicate = (MailImpl) mail.duplicate(newName);
+        assertEquals("new name set", newName, duplicate.getName());
+        helperTestInitialState(duplicate);
+        helperTestMessageSize(duplicate, 0);
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/test/java/org/apache/james/server/core/MailTestAllImplementations.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/test/java/org/apache/james/server/core/MailTestAllImplementations.java b/server/container/core/src/test/java/org/apache/james/server/core/MailTestAllImplementations.java
new file mode 100644
index 0000000..1a133b2
--- /dev/null
+++ b/server/container/core/src/test/java/org/apache/james/server/core/MailTestAllImplementations.java
@@ -0,0 +1,72 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+package org.apache.james.server.core;
+
+import javax.mail.MessagingException;
+
+import org.apache.mailet.Mail;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ * testing common behavior of Mail implementors. subclasses automatically get
+ * their Mail-behavior tested.
+ */
+public abstract class MailTestAllImplementations {
+
+    /** provide the concrete implementation to test */
+    protected abstract Mail createMailImplementation();
+
+    protected void helperTestInitialState(Mail mail) {
+        assertFalse("no initial attributes", mail.hasAttributes());
+        assertNull("no initial error", mail.getErrorMessage());
+        assertNotNull("initial last update set", mail.getLastUpdated());
+        try {
+            assertTrue("no initial recipient", mail.getRecipients().isEmpty());
+        } catch (NullPointerException e) {
+            // current behavior. *BUT*, shouldn't this method better return with
+            // an empty list?!
+        }
+        assertEquals("initial remote address is localhost ip", "127.0.0.1", mail.getRemoteAddr());
+        assertEquals("initial remote host is localhost", "localhost", mail.getRemoteHost());
+        assertEquals("default initial state", Mail.DEFAULT, mail.getState());
+    }
+
+    protected void helperTestMessageSize(Mail mail, int expectedMsgSize) throws MessagingException {
+        try {
+            assertEquals("initial message size == " + expectedMsgSize, expectedMsgSize, mail.getMessageSize());
+        } catch (NullPointerException e) {
+            // current behavior. *BUT*, shouldn't this method return more
+            // gracefully?!
+        }
+    }
+
+    @Test
+    public void testAttributes() {
+        Mail mail = createMailImplementation();
+        assertFalse("no initial attributes", mail.hasAttributes());
+        assertFalse("attributes initially empty", mail.getAttributeNames().hasNext());
+        assertNull("not found on emtpy list", mail.getAttribute("test"));
+        assertNull("no previous item with key", mail.setAttribute("testKey", "testValue"));
+        assertEquals("item found", "testValue", mail.getAttribute("testKey"));
+        assertTrue("has attribute", mail.hasAttributes());
+        assertEquals("item removed", "testValue", mail.removeAttribute("testKey"));
+        assertNull("item no longer found", mail.getAttribute("testKey"));
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageCopyOnWriteProxyTest.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageCopyOnWriteProxyTest.java b/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageCopyOnWriteProxyTest.java
new file mode 100644
index 0000000..afea93c
--- /dev/null
+++ b/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageCopyOnWriteProxyTest.java
@@ -0,0 +1,279 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+package org.apache.james.server.core;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.ArrayList;
+import java.util.Properties;
+
+import javax.mail.MessagingException;
+import javax.mail.Session;
+import javax.mail.internet.MimeMessage;
+import javax.mail.util.SharedByteArrayInputStream;
+
+import org.apache.james.lifecycle.api.LifecycleUtil;
+import org.apache.james.core.MailAddress;
+import org.apache.mailet.Mail;
+import org.junit.Test;
+
+public class MimeMessageCopyOnWriteProxyTest extends MimeMessageFromStreamTest {
+
+    final String content = "Subject: foo\r\nContent-Transfer-Encoding2: plain";
+    final String sep = "\r\n\r\n";
+    final String body = "bar\r\n.\r\n";
+
+    @Override
+    protected MimeMessage getMessageFromSources(String sources) throws Exception {
+        MimeMessageInputStreamSource mmis = new MimeMessageInputStreamSource("test", new SharedByteArrayInputStream(sources.getBytes()));
+        return new MimeMessageCopyOnWriteProxy(mmis);
+        // return new MimeMessage(Session.getDefaultInstance(new
+        // Properties()),new ByteArrayInputStream(sources.getBytes()));
+    }
+
+    @Test
+    public void testMessageCloning1() throws Exception {
+        ArrayList<MailAddress> r = new ArrayList<>();
+        r.add(new MailAddress("recipient@test.com"));
+        MimeMessageCopyOnWriteProxy messageFromSources = (MimeMessageCopyOnWriteProxy) getMessageFromSources(
+                content + sep + body);
+        MailImpl mail = new MailImpl("test", new MailAddress("test@test.com"), r, messageFromSources);
+        MailImpl m2 = (MailImpl) mail.duplicate();
+        System.out.println("mail: " + getReferences(mail.getMessage()) + " m2: " + getReferences(m2.getMessage()));
+        assertNotSame(m2, mail);
+        assertNotSame(m2.getMessage(), mail.getMessage());
+        // test that the wrapped message is the same
+        assertTrue(isSameMimeMessage(m2.getMessage(), mail.getMessage()));
+        // test it is the same after read only operations!
+        mail.getMessage().getSubject();
+        assertTrue(isSameMimeMessage(m2.getMessage(), mail.getMessage()));
+        mail.getMessage().setText("new body");
+        mail.getMessage().saveChanges();
+        // test it is different after a write operation!
+        mail.getMessage().setSubject("new Subject");
+        assertTrue(!isSameMimeMessage(m2.getMessage(), mail.getMessage()));
+        LifecycleUtil.dispose(mail);
+        LifecycleUtil.dispose(m2);
+        LifecycleUtil.dispose(messageFromSources);
+    }
+
+    @Test
+    public void testMessageCloning2() throws Exception {
+        ArrayList<MailAddress> r = new ArrayList<>();
+        r.add(new MailAddress("recipient@test.com"));
+        MimeMessageCopyOnWriteProxy messageFromSources = (MimeMessageCopyOnWriteProxy) getMessageFromSources(
+                content + sep + body);
+        MailImpl mail = new MailImpl("test", new MailAddress("test@test.com"), r, messageFromSources);
+        MailImpl m2 = (MailImpl) mail.duplicate();
+        System.out.println("mail: " + getReferences(mail.getMessage()) + " m2: " + getReferences(m2.getMessage()));
+        assertNotSame(m2, mail);
+        assertNotSame(m2.getMessage(), mail.getMessage());
+        // test that the wrapped message is the same
+        assertTrue(isSameMimeMessage(m2.getMessage(), mail.getMessage()));
+        // test it is the same after real only operations!
+        m2.getMessage().getSubject();
+        assertTrue(isSameMimeMessage(m2.getMessage(), mail.getMessage()));
+        m2.getMessage().setText("new body");
+        m2.getMessage().saveChanges();
+        // test it is different after a write operation!
+        m2.getMessage().setSubject("new Subject");
+        assertTrue(!isSameMimeMessage(m2.getMessage(), mail.getMessage()));
+        // check that the subjects are correct on both mails!
+        assertEquals(m2.getMessage().getSubject(), "new Subject");
+        assertEquals(mail.getMessage().getSubject(), "foo");
+        // cloning again the messages
+        Mail m2clone = m2.duplicate();
+        assertTrue(isSameMimeMessage(m2clone.getMessage(), m2.getMessage()));
+        MimeMessage mm = getWrappedMessage(m2.getMessage());
+        assertNotSame(m2.getMessage(), m2clone.getMessage());
+        // test that m2clone has a valid wrapped message
+        MimeMessage mm3 = getWrappedMessage(m2clone.getMessage());
+        assertNotNull(mm3);
+        // dispose m2 and check that the clone has still a valid message and it
+        // is the same!
+        LifecycleUtil.dispose(m2);
+        assertEquals(mm3, getWrappedMessage(m2clone.getMessage()));
+        // change the message that should be not referenced by m2 that has
+        // been disposed, so it should not clone it!
+        m2clone.getMessage().setSubject("new Subject 2");
+        m2clone.getMessage().setText("new Body 3");
+        assertTrue(isSameMimeMessage(m2clone.getMessage(), mm));
+        LifecycleUtil.dispose(mail);
+        LifecycleUtil.dispose(messageFromSources);
+    }
+
+    /**
+     * If I create a new MimeMessageCopyOnWriteProxy from another
+     * MimeMessageCopyOnWriteProxy, I remove references to the first and I
+     * change the second, then it should not clone
+     */
+    @Test
+    public void testMessageAvoidCloning() throws Exception {
+        ArrayList<MailAddress> r = new ArrayList<>();
+        r.add(new MailAddress("recipient@test.com"));
+        MimeMessageCopyOnWriteProxy messageFromSources = (MimeMessageCopyOnWriteProxy) getMessageFromSources(
+                content + sep + body);
+        MailImpl mail = new MailImpl("test", new MailAddress("test@test.com"), r, messageFromSources);
+        // cloning the message
+        Mail mailClone = mail.duplicate();
+        assertTrue(isSameMimeMessage(mailClone.getMessage(), mail.getMessage()));
+        MimeMessage mm = getWrappedMessage(mail.getMessage());
+        assertNotSame(mail.getMessage(), mailClone.getMessage());
+        // dispose mail and check that the clone has still a valid message and
+        // it is the same!
+        LifecycleUtil.dispose(mail);
+        LifecycleUtil.dispose(messageFromSources);
+        // need to add a gc and a wait, because the original mimemessage should
+        // be finalized before the test.
+        System.gc();
+        Thread.sleep(1000);
+        // dumb test
+        assertTrue(isSameMimeMessage(mailClone.getMessage(), mailClone.getMessage()));
+        // change the message that should be not referenced by mail that has
+        // been disposed, so it should not clone it!
+        mailClone.getMessage().setSubject("new Subject 2");
+        mailClone.getMessage().setText("new Body 3");
+        assertTrue(isSameMimeMessage(mailClone.getMessage(), mm));
+        LifecycleUtil.dispose(mailClone);
+        LifecycleUtil.dispose(mm);
+    }
+
+    /**
+     * If I create a new MimeMessageCopyOnWriteProxy from a MimeMessage and I
+     * change the new message, the original should be unaltered and the proxy
+     * should clone the message.
+     */
+    @Test
+    public void testMessageCloning3() throws Exception {
+        ArrayList<MailAddress> r = new ArrayList<>();
+        r.add(new MailAddress("recipient@test.com"));
+        MimeMessage m = new MimeMessage(Session.getDefaultInstance(new Properties(null)));
+        m.setText("CIPS");
+        MailImpl mail = new MailImpl("test", new MailAddress("test@test.com"), r, m);
+        assertTrue(isSameMimeMessage(m, mail.getMessage()));
+        // change the message that should be not referenced by mail that has
+        // been disposed, so it should not clone it!
+        System.gc();
+        Thread.sleep(100);
+        mail.getMessage().setSubject("new Subject 2");
+        mail.getMessage().setText("new Body 3");
+        System.gc();
+        Thread.sleep(100);
+        assertFalse(isSameMimeMessage(m, mail.getMessage()));
+        LifecycleUtil.dispose(mail);
+        LifecycleUtil.dispose(m);
+    }
+
+    @Test
+    public void testMessageDisposing() throws Exception {
+        ArrayList<MailAddress> r = new ArrayList<>();
+        r.add(new MailAddress("recipient@test.com"));
+        MimeMessageCopyOnWriteProxy messageFromSources = (MimeMessageCopyOnWriteProxy) getMessageFromSources(
+                content + sep + body);
+        MailImpl mail = new MailImpl("test", new MailAddress("test@test.com"), r, messageFromSources);
+        // cloning the message
+        MailImpl mailClone = (MailImpl) mail.duplicate();
+        LifecycleUtil.dispose(mail);
+
+        assertNotNull(getWrappedMessage(mailClone.getMessage()));
+        assertNull(mail.getMessage());
+
+        LifecycleUtil.dispose(mailClone);
+
+        assertNull(mailClone.getMessage());
+        assertNull(mail.getMessage());
+        LifecycleUtil.dispose(mail);
+        LifecycleUtil.dispose(messageFromSources);
+    }
+
+    @Test
+    public void testNPE1() throws MessagingException, InterruptedException {
+        ArrayList<MailAddress> recipients = new ArrayList<>();
+        recipients.add(new MailAddress("recipient@test.com"));
+        MimeMessageCopyOnWriteProxy mw = new MimeMessageCopyOnWriteProxy(new MimeMessageInputStreamSource("test",
+                new SharedByteArrayInputStream(("Return-path: return@test.com\r\n" + "Content-Transfer-Encoding: plain\r\n" + "Subject: test\r\n\r\n" + "Body Text testNPE1\r\n").
+                getBytes())));
+
+        MimeMessageCopyOnWriteProxy mw2 = new MimeMessageCopyOnWriteProxy(mw);
+        LifecycleUtil.dispose(mw2);
+        mw2 = null;
+        System.gc();
+        Thread.sleep(1000);
+        // the NPE was inside this call
+        mw.getMessageSize();
+        LifecycleUtil.dispose(mw);
+    }
+
+    /**
+     * This test throw a NullPointerException when the original message was
+     * created by a MimeMessageInputStreamSource.
+     */
+    @Test
+    public void testMessageCloningViaCoW3() throws Exception {
+        MimeMessage mmorig = getSimpleMessage();
+
+        MimeMessage mm = new MimeMessageCopyOnWriteProxy(mmorig);
+
+        LifecycleUtil.dispose(mmorig);
+        mmorig = null;
+        System.gc();
+        Thread.sleep(200);
+
+        try {
+            mm.writeTo(System.out);
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail("Exception while writing the message to output");
+        }
+
+        LifecycleUtil.dispose(mm);
+    }
+
+    private static String getReferences(MimeMessage m) {
+        StringBuilder ref = new StringBuilder("/");
+        while (m instanceof MimeMessageCopyOnWriteProxy) {
+            ref.append(((MimeMessageCopyOnWriteProxy) m).refCount.getReferenceCount()).append("/");
+            m = ((MimeMessageCopyOnWriteProxy) m).getWrappedMessage();
+        }
+        if (m instanceof MimeMessageWrapper) {
+            ref.append("W");
+        } else {
+            ref.append("M");
+        }
+        return ref.toString();
+    }
+
+    private static MimeMessage getWrappedMessage(MimeMessage m) {
+        while (m instanceof MimeMessageCopyOnWriteProxy) {
+            m = ((MimeMessageCopyOnWriteProxy) m).getWrappedMessage();
+        }
+        return m;
+    }
+
+    private static boolean isSameMimeMessage(MimeMessage first, MimeMessage second) {
+        return getWrappedMessage(first) == getWrappedMessage(second);
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageFromMimeMessageTest.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageFromMimeMessageTest.java b/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageFromMimeMessageTest.java
new file mode 100644
index 0000000..b93d57d
--- /dev/null
+++ b/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageFromMimeMessageTest.java
@@ -0,0 +1,31 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.server.core;
+
+import javax.mail.internet.MimeMessage;
+
+public class MimeMessageFromMimeMessageTest extends MimeMessageFromStreamTest {
+
+    @Override
+    protected MimeMessage getMessageFromSources(String sources) throws Exception {
+        return new MimeMessage(super.getMessageFromSources(sources));
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageFromSharedStreamTest.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageFromSharedStreamTest.java b/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageFromSharedStreamTest.java
new file mode 100644
index 0000000..a11aedc
--- /dev/null
+++ b/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageFromSharedStreamTest.java
@@ -0,0 +1,36 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.server.core;
+
+import javax.mail.util.SharedByteArrayInputStream;
+
+import javax.mail.Session;
+import javax.mail.internet.MimeMessage;
+
+import java.util.Properties;
+
+public class MimeMessageFromSharedStreamTest extends MimeMessageFromStreamTest {
+
+    @Override
+    protected MimeMessage getMessageFromSources(String sources) throws Exception {
+        return new MimeMessage(Session.getDefaultInstance(new Properties()), new SharedByteArrayInputStream(sources.getBytes()));
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageFromStreamTest.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageFromStreamTest.java b/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageFromStreamTest.java
new file mode 100644
index 0000000..8b68c14
--- /dev/null
+++ b/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageFromStreamTest.java
@@ -0,0 +1,59 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.server.core;
+
+import javax.mail.Session;
+import javax.mail.internet.MimeMessage;
+
+import java.io.ByteArrayInputStream;
+import java.util.Properties;
+
+public class MimeMessageFromStreamTest extends MimeMessageTest {
+
+    protected MimeMessage getMessageFromSources(String sources) throws Exception {
+        return new MimeMessage(Session.getDefaultInstance(new Properties()), new ByteArrayInputStream(sources.getBytes()));
+    }
+
+    @Override
+    protected MimeMessage getMultipartMessage() throws Exception {
+        return getMessageFromSources(getMultipartMessageSource());
+    }
+
+    @Override
+    protected MimeMessage getSimpleMessage() throws Exception {
+        return getMessageFromSources(getSimpleMessageCleanedSource());
+    }
+
+    @Override
+    protected MimeMessage getMessageWithBadReturnPath() throws Exception {
+        return getMessageFromSources(getMessageWithBadReturnPathSource());
+    }
+
+    @Override
+    protected MimeMessage getMissingEncodingAddHeaderMessage() throws Exception {
+        return getMessageFromSources(getMissingEncodingAddHeaderSource());
+    }
+
+    @Override
+    protected MimeMessage getMissingEncodingMessage() throws Exception {
+        return getMessageFromSources(getMissingEncodingMessageSource());
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageInputStreamSourceTest.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageInputStreamSourceTest.java b/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageInputStreamSourceTest.java
new file mode 100644
index 0000000..642699b
--- /dev/null
+++ b/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageInputStreamSourceTest.java
@@ -0,0 +1,60 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+package org.apache.james.server.core;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.io.IOException;
+
+import javax.mail.MessagingException;
+
+import org.apache.james.util.ZeroedInputStream;
+import org.junit.After;
+import org.junit.Test;
+
+public class MimeMessageInputStreamSourceTest {
+
+    private static final int _1M = 1024*1024;
+    private static final int _10KB = 10*1024;
+    private MimeMessageInputStreamSource testee;
+
+    @After
+    public void tearDown() {
+        testee.dispose();
+    }
+    
+    @Test
+    public void streamWith1MBytesShouldBeReadable() throws MessagingException, IOException {
+        testee = new MimeMessageInputStreamSource("myKey", new ZeroedInputStream(_1M));
+        assertThat(testee.getInputStream()).hasSameContentAs(new ZeroedInputStream(_1M));
+    }
+    
+    @Test
+    public void streamWith10KBytesShouldBeReadable() throws MessagingException, IOException {
+        testee = new MimeMessageInputStreamSource("myKey", new ZeroedInputStream(_10KB));
+        assertThat(testee.getInputStream()).hasSameContentAs(new ZeroedInputStream(_10KB));
+    }
+
+    @Test
+    public void streamWithVeryShortNameShouldWork() throws MessagingException, IOException {
+        String veryShortName = "1";
+        testee = new MimeMessageInputStreamSource(veryShortName, new ZeroedInputStream(_1M));
+        assertThat(testee.getInputStream()).isNotNull();
+    }
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


[10/23] james-project git commit: JAMES-2138 move MailAddress to a new james-core project

Posted by bt...@apache.org.
http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/main/java/org/apache/james/server/core/MimeMessageWrapper.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/main/java/org/apache/james/server/core/MimeMessageWrapper.java b/server/container/core/src/main/java/org/apache/james/server/core/MimeMessageWrapper.java
new file mode 100644
index 0000000..a3a068e
--- /dev/null
+++ b/server/container/core/src/main/java/org/apache/james/server/core/MimeMessageWrapper.java
@@ -0,0 +1,705 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.server.core;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.LineNumberReader;
+import java.io.OutputStream;
+import java.io.SequenceInputStream;
+import java.util.Enumeration;
+import java.util.UUID;
+
+import javax.activation.DataHandler;
+import javax.mail.MessagingException;
+import javax.mail.Session;
+import javax.mail.internet.InternetHeaders;
+import javax.mail.internet.MimeMessage;
+import javax.mail.util.SharedByteArrayInputStream;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.james.lifecycle.api.Disposable;
+import org.apache.james.lifecycle.api.LifecycleUtil;
+
+/**
+ * This object wraps a MimeMessage, only loading the underlying MimeMessage
+ * object when needed. Also tracks if changes were made to reduce unnecessary
+ * saves.
+ */
+public class MimeMessageWrapper extends MimeMessage implements Disposable {
+
+    /**
+     * System property which tells JAMES if it should copy a message in memory
+     * or via a temporary file. Default is the file
+     */
+    public final static String USE_MEMORY_COPY = "james.message.usememorycopy";
+
+    /**
+     * Can provide an input stream to the data
+     */
+    protected MimeMessageSource source = null;
+
+    /**
+     * This is false until we parse the message
+     */
+    protected boolean messageParsed = false;
+
+    /**
+     * This is false until we parse the message
+     */
+    protected boolean headersModified = false;
+
+    /**
+     * This is false until we parse the message
+     */
+    protected boolean bodyModified = false;
+
+    /**
+     * Keep a reference to the sourceIn so we can close it only when we dispose
+     * the message.
+     */
+    private InputStream sourceIn;
+
+    private long initialHeaderSize;
+
+    private MimeMessageWrapper(Session session) {
+        super(session);
+        this.headers = null;
+        this.modified = false;
+        this.headersModified = false;
+        this.bodyModified = false;
+    }
+
+    /**
+     * A constructor that instantiates a MimeMessageWrapper based on a
+     * MimeMessageSource
+     * 
+     * @param source
+     *            the MimeMessageSource
+     * @throws MessagingException
+     */
+    public MimeMessageWrapper(Session session, MimeMessageSource source) {
+        this(session);
+        this.source = source;
+    }
+
+    /**
+     * A constructor that instantiates a MimeMessageWrapper based on a
+     * MimeMessageSource
+     * 
+     * @param source
+     *            the MimeMessageSource
+     * @throws MessagingException
+     * @throws MessagingException
+     */
+    public MimeMessageWrapper(MimeMessageSource source) {
+        this(Session.getDefaultInstance(System.getProperties()), source);
+    }
+
+    public MimeMessageWrapper(MimeMessage original) throws MessagingException {
+        this(Session.getDefaultInstance(System.getProperties()));
+        flags = original.getFlags();
+
+        if (source == null) {
+            InputStream in;
+
+            boolean useMemoryCopy = false;
+            String memoryCopy = System.getProperty(USE_MEMORY_COPY);
+            if (memoryCopy != null) {
+                useMemoryCopy = Boolean.valueOf(memoryCopy);
+            }
+            try {
+
+                if (useMemoryCopy) {
+                    ByteArrayOutputStream bos;
+                    int size = original.getSize();
+                    if (size > 0) {
+                        bos = new ByteArrayOutputStream(size);
+                    } else {
+                        bos = new ByteArrayOutputStream();
+                    }
+                    original.writeTo(bos);
+                    bos.close();
+                    in = new SharedByteArrayInputStream(bos.toByteArray());
+                    parse(in);
+                    in.close();
+                    saved = true;
+                } else {
+                    MimeMessageInputStreamSource src = new MimeMessageInputStreamSource("MailCopy-" + UUID.randomUUID().toString());
+                    OutputStream out = src.getWritableOutputStream();
+                    original.writeTo(out);
+                    out.close();
+                    source = src;
+                }
+
+            } catch (IOException ex) {
+                // should never happen, but just in case...
+                throw new MessagingException("IOException while copying message", ex);
+            }
+        }
+    }
+
+    /**
+     * Overrides default javamail behaviour by not altering the Message-ID by
+     * default, see <a href="https://issues.apache.org/jira/browse/JAMES-875">JAMES-875</a> and
+     * <a href="https://issues.apache.org/jira/browse/JAMES-1010">JAMES-1010</a>
+     *
+     * @see javax.mail.internet.MimeMessage#updateMessageID()
+     */
+    @Override
+    protected void updateMessageID() throws MessagingException {
+        if (getMessageID() == null)
+            super.updateMessageID();
+    }
+
+    /**
+     * Returns the source ID of the MimeMessageSource that is supplying this
+     * with data.
+     * 
+     * @see MimeMessageSource
+     */
+    public synchronized String getSourceId() {
+        return source != null ? source.getSourceId() : null;
+    }
+
+    /**
+     * Load the message headers from the internal source.
+     * 
+     * @throws MessagingException
+     *             if an error is encountered while loading the headers
+     */
+    protected synchronized void loadHeaders() throws MessagingException {
+        if (headers != null) {
+            // Another thread has already loaded these headers
+        } else if (source != null) {
+            try {
+                InputStream in = source.getInputStream();
+                try {
+                    headers = createInternetHeaders(in);
+
+                } finally {
+                    IOUtils.closeQuietly(in);
+                }
+            } catch (IOException ioe) {
+                throw new MessagingException("Unable to parse headers from stream: " + ioe.getMessage(), ioe);
+            }
+        } else {
+            throw new MessagingException("loadHeaders called for a message with no source, contentStream or stream");
+        }
+    }
+
+    /**
+     * Load the complete MimeMessage from the internal source.
+     * 
+     * @throws MessagingException
+     *             if an error is encountered while loading the message
+     */
+    public synchronized void loadMessage() throws MessagingException {
+        if (messageParsed) {
+            // Another thread has already loaded this message
+        } else if (source != null) {
+            sourceIn = null;
+            try {
+                sourceIn = source.getInputStream();
+
+                parse(sourceIn);
+                // TODO is it ok?
+                saved = true;
+
+            } catch (IOException ioe) {
+                IOUtils.closeQuietly(sourceIn);
+                sourceIn = null;
+                throw new MessagingException("Unable to parse stream: " + ioe.getMessage(), ioe);
+            }
+        } else {
+            throw new MessagingException("loadHeaders called for an unparsed message with no source");
+        }
+    }
+
+    /**
+     * Get whether the message has been modified.
+     * 
+     * @return whether the message has been modified
+     */
+    public synchronized boolean isModified() {
+        return headersModified || bodyModified || modified;
+    }
+
+    /**
+     * Get whether the body of the message has been modified
+     * 
+     * @return bodyModified
+     */
+    public synchronized boolean isBodyModified() {
+        return bodyModified;
+    }
+
+    /**
+     * Get whether the header of the message has been modified
+     * 
+     * @return headersModified
+     */
+    public synchronized boolean isHeaderModified() {
+        return headersModified;
+    }
+
+    /**
+     * Rewritten for optimization purposes
+     */
+    @Override
+    public void writeTo(OutputStream os) throws IOException, MessagingException {
+        writeTo(os, os);
+
+    }
+
+    /**
+     * Rewritten for optimization purposes
+     */
+    @Override
+    public void writeTo(OutputStream os, String[] ignoreList) throws IOException, MessagingException {
+        writeTo(os, os, ignoreList);
+    }
+
+    /**
+     * Write
+     */
+    public void writeTo(OutputStream headerOs, OutputStream bodyOs) throws IOException, MessagingException {
+        writeTo(headerOs, bodyOs, new String[0]);
+    }
+
+    public void writeTo(OutputStream headerOs, OutputStream bodyOs, String[] ignoreList) throws IOException, MessagingException {
+        writeTo(headerOs, bodyOs, ignoreList, false);
+    }
+
+    public synchronized void writeTo(OutputStream headerOs, OutputStream bodyOs, String[] ignoreList, boolean preLoad) throws IOException, MessagingException {
+        
+        if (!preLoad && source != null && !isBodyModified()) {
+            // We do not want to instantiate the message... just read from
+            // source
+            // and write to this outputstream
+
+            // First handle the headers
+            InputStream in = source.getInputStream();
+            try {
+                InternetHeaders myHeaders;
+                MailHeaders parsedHeaders = new MailHeaders(in);
+
+                // check if we should use the parsed headers or not
+                if (!isHeaderModified()) {
+                    myHeaders = parsedHeaders;
+                } else {
+                    // The headers was modified so we need to call saveChanges() just to be sure
+                    // See JAMES-1320
+                    if (!saved)
+                        saveChanges();
+                    myHeaders = headers;
+                }
+                @SuppressWarnings("unchecked")
+                Enumeration<String> filteredHeaders = myHeaders.getNonMatchingHeaderLines(ignoreList);
+                IOUtils.copy(new InternetHeadersInputStream(filteredHeaders), headerOs);
+                IOUtils.copy(in, bodyOs);
+            } finally {
+                IOUtils.closeQuietly(in);
+            }
+        } else {
+            // save the changes as the message was modified
+            // See JAMES-1320
+            if (!saved)
+                saveChanges();
+
+            // MimeMessageUtil.writeToInternal(this, headerOs, bodyOs,
+            // ignoreList);
+            if (headers == null) {
+                loadHeaders();
+            }
+            @SuppressWarnings("unchecked")
+            Enumeration<String> filteredHeaders = headers.getNonMatchingHeaderLines(ignoreList);
+            IOUtils.copy(new InternetHeadersInputStream(filteredHeaders), headerOs);
+
+            if (preLoad && !messageParsed) {
+                loadMessage();
+            }
+            MimeMessageUtil.writeMessageBodyTo(this, bodyOs);
+        }
+    }
+
+    /**
+     * This is the MimeMessage implementation - this should return ONLY the
+     * body, not the entire message (should not count headers). This size will
+     * never change on {@link #saveChanges()}
+     */
+    @Override
+    public synchronized int getSize() throws MessagingException {
+        if (source != null) {
+            try {
+                long fullSize = source.getMessageSize();
+                if (headers == null) {
+                    loadHeaders();
+                }
+                // 2 == CRLF
+                return (int) (fullSize - initialHeaderSize - 2);
+
+            } catch (IOException e) {
+                throw new MessagingException("Unable to calculate message size");
+            }
+        } else {
+            if (!messageParsed) {
+                loadMessage();
+            }
+
+            return super.getSize();
+        }
+
+    }
+
+    /**
+     * Corrects JavaMail 1.1 version which always returns -1. Only corrected for
+     * content less than 5000 bytes, to avoid memory hogging.
+     */
+    @Override
+    public int getLineCount() throws MessagingException {
+        InputStream in;
+        try {
+            in = getContentStream();
+        } catch (Exception e) {
+            return -1;
+        }
+        if (in == null) {
+            return -1;
+        }
+        // Wrap input stream in LineNumberReader
+        // Not sure what encoding to use really...
+        InputStreamReader isr = null;
+        LineNumberReader counter = null;
+        try {
+            if (getEncoding() != null) {
+                isr = new InputStreamReader(in, getEncoding());
+                counter = new LineNumberReader(isr);
+            } else {
+                isr = new InputStreamReader(in);
+                counter = new LineNumberReader(isr);
+            }
+            // Read through all the data
+            char[] block = new char[4096];
+            while (counter.read(block) > -1) {
+                // Just keep reading
+            }
+            return counter.getLineNumber();
+        } catch (IOException ioe) {
+            return -1;
+        } finally {
+            IOUtils.closeQuietly(counter);
+            IOUtils.closeQuietly(isr);
+            IOUtils.closeQuietly(in);
+        }
+    }
+
+    /**
+     * Returns size of message, ie headers and content
+     */
+    public long getMessageSize() throws MessagingException {
+        if (source != null && !isModified()) {
+            try {
+                return source.getMessageSize();
+            } catch (IOException ioe) {
+                throw new MessagingException("Error retrieving message size", ioe);
+            }
+        } else {
+            return MimeMessageUtil.calculateMessageSize(this);
+        }
+    }
+
+    /**
+     * We override all the "headers" access methods to be sure that we loaded
+     * the headers
+     */
+
+    @Override
+    public String[] getHeader(String name) throws MessagingException {
+        if (headers == null) {
+            loadHeaders();
+        }
+        return headers.getHeader(name);
+    }
+
+    @Override
+    public String getHeader(String name, String delimiter) throws MessagingException {
+        if (headers == null) {
+            loadHeaders();
+        }
+        return headers.getHeader(name, delimiter);
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public Enumeration<String> getAllHeaders() throws MessagingException {
+        if (headers == null) {
+            loadHeaders();
+        }
+        return headers.getAllHeaders();
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public Enumeration<String> getMatchingHeaders(String[] names) throws MessagingException {
+        if (headers == null) {
+            loadHeaders();
+        }
+        return headers.getMatchingHeaders(names);
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public Enumeration<String> getNonMatchingHeaders(String[] names) throws MessagingException {
+        if (headers == null) {
+            loadHeaders();
+        }
+        return headers.getNonMatchingHeaders(names);
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public Enumeration<String> getAllHeaderLines() throws MessagingException {
+        if (headers == null) {
+            loadHeaders();
+        }
+        return headers.getAllHeaderLines();
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public Enumeration<String> getMatchingHeaderLines(String[] names) throws MessagingException {
+        if (headers == null) {
+            loadHeaders();
+        }
+        return headers.getMatchingHeaderLines(names);
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public Enumeration<String> getNonMatchingHeaderLines(String[] names) throws MessagingException {
+        if (headers == null) {
+            loadHeaders();
+        }
+        return headers.getNonMatchingHeaderLines(names);
+    }
+
+    private synchronized void checkModifyHeaders() throws MessagingException {
+        // Disable only-header loading optimizations for JAMES-559
+        /*
+         * if (!messageParsed) { loadMessage(); }
+         */
+
+        // End JAMES-559
+        if (headers == null) {
+            loadHeaders();
+        }
+        modified = true;
+        saved = false;
+        headersModified = true;
+    }
+
+    @Override
+    public void setHeader(String name, String value) throws MessagingException {
+        checkModifyHeaders();
+        super.setHeader(name, value);
+    }
+
+    @Override
+    public void addHeader(String name, String value) throws MessagingException {
+        checkModifyHeaders();
+        super.addHeader(name, value);
+    }
+
+    @Override
+    public void removeHeader(String name) throws MessagingException {
+        checkModifyHeaders();
+        super.removeHeader(name);
+    }
+
+    @Override
+    public void addHeaderLine(String line) throws MessagingException {
+        checkModifyHeaders();
+        super.addHeaderLine(line);
+    }
+
+    /**
+     * The message is changed when working with headers and when altering the
+     * content. Every method that alter the content will fallback to this one.
+     * 
+     * @see javax.mail.Part#setDataHandler(javax.activation.DataHandler)
+     */
+    @Override
+    public synchronized void setDataHandler(DataHandler arg0) throws MessagingException {
+        modified = true;
+        saved = false;
+        bodyModified = true;
+        super.setDataHandler(arg0);
+    }
+
+    @Override
+    public void dispose() {
+        if (sourceIn != null) {
+            IOUtils.closeQuietly(sourceIn);
+        }
+        if (source != null) {
+            LifecycleUtil.dispose(source);
+        }
+    }
+
+    /**
+     * @see javax.mail.internet.MimeMessage#parse(java.io.InputStream)
+     */
+    @Override
+    protected synchronized void parse(InputStream is) throws MessagingException {
+        // the super implementation calls
+        // headers = createInternetHeaders(is);
+        super.parse(is);
+        messageParsed = true;
+    }
+
+    /**
+     * If we already parsed the headers then we simply return the updated ones.
+     * Otherwise we parse
+     * 
+     * @see javax.mail.internet.MimeMessage#createInternetHeaders(java.io.InputStream)
+     */
+    @Override
+    protected synchronized InternetHeaders createInternetHeaders(InputStream is) throws MessagingException {
+        /*
+         * This code is no more needed: see JAMES-570 and new tests
+         * 
+         * InternetHeaders can be a bit awkward to work with due to its own
+         * internal handling of header order. This hack may not always be
+         * necessary, but for now we are trying to ensure that there is a
+         * Return-Path header, even if just a placeholder, so that later, e.g.,
+         * in LocalDelivery, when we call setHeader, it will remove any other
+         * Return-Path headers, and ensure that ours is on the top. addHeader
+         * handles header order, but not setHeader. This may change in future
+         * JavaMail. But if there are other Return-Path header values, let's
+         * drop our placeholder.
+         * 
+         * MailHeaders newHeaders = new MailHeaders(new
+         * ByteArrayInputStream((f.RETURN_PATH + ": placeholder").getBytes()));
+         * newHeaders.setHeader(RFC2822Headers.RETURN_PATH, null);
+         * newHeaders.load(is); String[] returnPathHeaders =
+         * newHeaders.getHeader(RFC2822Headers.RETURN_PATH); if
+         * (returnPathHeaders.length > 1)
+         * newHeaders.setHeader(RFC2822Headers.RETURN_PATH,
+         * returnPathHeaders[1]);
+         */
+
+        // Keep this: skip the headers from the stream
+        // we could put that code in the else and simple write an "header"
+        // skipping
+        // reader for the others.
+        MailHeaders newHeaders = new MailHeaders(is);
+
+        if (headers != null) {
+            return headers;
+        } else {
+            initialHeaderSize = newHeaders.getSize();
+
+            return newHeaders;
+        }
+    }
+
+    /**
+     * @see javax.mail.internet.MimeMessage#getContentStream()
+     */
+    @Override
+    protected InputStream getContentStream() throws MessagingException {
+        if (!messageParsed) {
+            loadMessage();
+        }
+        return super.getContentStream();
+    }
+
+    /**
+     * @see javax.mail.internet.MimeMessage#getRawInputStream()
+     */
+    @Override
+    public synchronized InputStream getRawInputStream() throws MessagingException {
+        if (!messageParsed && !isModified() && source != null) {
+            InputStream is;
+            try {
+                is = source.getInputStream();
+                // skip the headers.
+                new MailHeaders(is);
+                return is;
+            } catch (IOException e) {
+                throw new MessagingException("Unable to read the stream: " + e.getMessage(), e);
+            }
+        } else {
+            return super.getRawInputStream();
+        }
+    }
+
+    /**
+     * Return an {@link InputStream} which holds the full content of the
+     * message. This method tries to optimize this call as far as possible. This
+     * stream contains the updated {@link MimeMessage} content if something was
+     * changed
+     * 
+     * @return messageInputStream
+     * @throws MessagingException
+     */
+
+    public synchronized InputStream getMessageInputStream() throws MessagingException {
+        if (!messageParsed && !isModified() && source != null) {
+            try {
+                return source.getInputStream();
+            } catch (IOException e) {
+                throw new MessagingException("Unable to get inputstream", e);
+            }
+        } else {
+            try {
+
+                // Try to optimize if possible to prevent OOM on big mails.
+                // See JAMES-1252 for an example
+                if (!bodyModified && source != null) {
+                    // ok only the headers were modified so we don't need to
+                    // copy the whole message content into memory
+                    InputStream in = source.getInputStream();
+                    
+                    // skip over headers from original stream we want to use the
+                    // in memory ones
+                    new MailHeaders(in);
+
+                    // now construct the new stream using the in memory headers
+                    // and the body from the original source
+                    return new SequenceInputStream(new InternetHeadersInputStream(getAllHeaderLines()), in);
+                } else {
+                    // the body was changed so we have no other solution to copy
+                    // it into memory first :(
+                    ByteArrayOutputStream out = new ByteArrayOutputStream();
+                    writeTo(out);
+                    return new ByteArrayInputStream(out.toByteArray());
+                }
+            } catch (IOException e) {
+                throw new MessagingException("Unable to get inputstream", e);
+            }
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/main/java/org/apache/james/server/core/filesystem/ClassPathResource.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/main/java/org/apache/james/server/core/filesystem/ClassPathResource.java b/server/container/core/src/main/java/org/apache/james/server/core/filesystem/ClassPathResource.java
new file mode 100644
index 0000000..d7c5378
--- /dev/null
+++ b/server/container/core/src/main/java/org/apache/james/server/core/filesystem/ClassPathResource.java
@@ -0,0 +1,110 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+package org.apache.james.server.core.filesystem;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+public class ClassPathResource implements Resource {
+    
+    private final String path;
+    private final ClassLoader classLoader;
+
+    public ClassPathResource(String path) {
+        this.path = sanitizePath(path);
+        this.classLoader = getDefaultClassLoader();
+    }
+
+    private String sanitizePath(String path) {
+        String pathToUse = new SimpleUrl(path).getSimplified();
+        if (pathToUse.startsWith("/")) {
+            return pathToUse.substring(1);
+        }
+        return pathToUse;
+    }
+
+    @Override
+    public File getFile() throws IOException {
+        URL url = getURL();
+        return ResourceUtils.getFile(url, getDescription());
+    }
+
+    public URL getURL() throws IOException {
+        URL url = resolveURL();
+        if (url == null) {
+            throw new FileNotFoundException(getDescription() + " cannot be resolved to URL because it does not exist");
+        }
+        return url;
+    }
+
+    protected URL resolveURL() {
+        return this.classLoader.getResource(this.path);
+    }
+
+    @Override
+    public InputStream getInputStream() throws IOException {
+        InputStream is = this.classLoader.getResourceAsStream(this.path);
+        if (is == null) {
+            throw new FileNotFoundException(getDescription() + " cannot be opened because it does not exist");
+        }
+        return is;
+    }
+
+    public String getDescription() {
+        return "class path resource [" + path + "]";
+    }
+
+    private ClassLoader getDefaultClassLoader() {
+        ClassLoader currentThreadClassLoader = getcurrentThreadClassLoader();
+        if (currentThreadClassLoader != null) {
+            return currentThreadClassLoader;
+        }
+        
+        // No thread context class loader -> use class loader of this class.
+        ClassLoader currentClassClassLoader = ClassPathResource.class.getClassLoader();
+        if (currentClassClassLoader != null) {
+            return currentClassClassLoader;
+        }
+        
+        // getClassLoader() returning null indicates the bootstrap ClassLoader
+        return getSystemClassLoader();
+    }
+
+    private ClassLoader getcurrentThreadClassLoader() {
+        try {
+            return Thread.currentThread().getContextClassLoader();
+        } catch (Throwable ex) {
+            // Cannot access thread context ClassLoader - falling back...
+            return null;
+        }
+    }
+    
+    private ClassLoader getSystemClassLoader() {
+        try {
+            return ClassLoader.getSystemClassLoader();
+        } catch (Throwable ex) {
+            // Cannot access system ClassLoader - oh well, maybe the
+            // caller can live with null...
+            return null;
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/main/java/org/apache/james/server/core/filesystem/FileSystemImpl.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/main/java/org/apache/james/server/core/filesystem/FileSystemImpl.java b/server/container/core/src/main/java/org/apache/james/server/core/filesystem/FileSystemImpl.java
new file mode 100644
index 0000000..a068f86
--- /dev/null
+++ b/server/container/core/src/main/java/org/apache/james/server/core/filesystem/FileSystemImpl.java
@@ -0,0 +1,60 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+package org.apache.james.server.core.filesystem;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.inject.Inject;
+
+import org.apache.james.filesystem.api.FileSystem;
+import org.apache.james.filesystem.api.JamesDirectoriesProvider;
+
+public class FileSystemImpl implements FileSystem {
+
+    private final JamesDirectoriesProvider directoryProvider;
+    private final ResourceFactory resourceLoader;
+
+    @Inject
+    public FileSystemImpl(JamesDirectoriesProvider directoryProvider) {
+        this.directoryProvider = directoryProvider;
+        this.resourceLoader = new ResourceFactory(directoryProvider);
+    }
+
+    @Override
+    public File getBasedir() throws FileNotFoundException {
+        return new File(directoryProvider.getRootDirectory());
+    }
+
+    @Override
+    public InputStream getResource(String url) throws IOException {
+        return resourceLoader.getResource(url).getInputStream();
+    }
+
+    @Override
+    public File getFile(String fileURL) throws FileNotFoundException {
+        try {
+            return resourceLoader.getResource(fileURL).getFile();
+        } catch (IOException e) {
+            throw new FileNotFoundException(e.getMessage());
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/main/java/org/apache/james/server/core/filesystem/FileSystemResource.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/main/java/org/apache/james/server/core/filesystem/FileSystemResource.java b/server/container/core/src/main/java/org/apache/james/server/core/filesystem/FileSystemResource.java
new file mode 100644
index 0000000..dd90612
--- /dev/null
+++ b/server/container/core/src/main/java/org/apache/james/server/core/filesystem/FileSystemResource.java
@@ -0,0 +1,44 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+package org.apache.james.server.core.filesystem;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+class FileSystemResource implements Resource {
+
+    private final File file;
+
+    public FileSystemResource(File file) {
+        this.file = file;
+    }
+
+    @Override
+    public File getFile() {
+        return this.file;
+    }
+
+    @Override
+    public InputStream getInputStream() throws IOException {
+        return new FileInputStream(this.file);
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/main/java/org/apache/james/server/core/filesystem/Resource.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/main/java/org/apache/james/server/core/filesystem/Resource.java b/server/container/core/src/main/java/org/apache/james/server/core/filesystem/Resource.java
new file mode 100644
index 0000000..d78abdd
--- /dev/null
+++ b/server/container/core/src/main/java/org/apache/james/server/core/filesystem/Resource.java
@@ -0,0 +1,29 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+package org.apache.james.server.core.filesystem;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+
+public interface Resource {
+    File getFile() throws IOException;
+
+    InputStream getInputStream() throws IOException;
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/main/java/org/apache/james/server/core/filesystem/ResourceFactory.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/main/java/org/apache/james/server/core/filesystem/ResourceFactory.java b/server/container/core/src/main/java/org/apache/james/server/core/filesystem/ResourceFactory.java
new file mode 100644
index 0000000..0cb9a18
--- /dev/null
+++ b/server/container/core/src/main/java/org/apache/james/server/core/filesystem/ResourceFactory.java
@@ -0,0 +1,100 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+package org.apache.james.server.core.filesystem;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.apache.james.filesystem.api.FileSystem;
+import org.apache.james.filesystem.api.JamesDirectoriesProvider;
+
+public class ResourceFactory {
+
+    private final JamesDirectoriesProvider directoryProvider;
+
+    public ResourceFactory(JamesDirectoriesProvider directoryProvider) {
+        this.directoryProvider = directoryProvider;
+    }
+    
+    public Resource getResource(String fileURL) {
+        if (fileURL.startsWith(FileSystem.CLASSPATH_PROTOCOL)) {
+            return handleClasspathProtocol(fileURL);
+        } else if (fileURL.startsWith(FileSystem.FILE_PROTOCOL)) {
+            return handleFileProtocol(fileURL);
+        } else {
+            try {
+                // Try to parse the location as a URL...
+                return handleUrlResource(fileURL);
+            } catch (MalformedURLException ex) {
+                // No URL -> resolve as resource path.
+                return new ClassPathResource(fileURL);
+            }
+        }
+    }
+
+    private Resource handleUrlResource(String fileURL) throws MalformedURLException {
+        URL url = new URL(fileURL);
+        return new UrlResource(url);
+    }
+
+    private Resource handleClasspathProtocol(String fileURL) {
+        String resourceName = fileURL.substring(FileSystem.CLASSPATH_PROTOCOL.length());
+        return new ClassPathResource(resourceName);
+    }
+    
+    private Resource handleFileProtocol(String fileURL) {
+        File file = interpretPath(fileURL);
+        return new FileSystemResource(file);
+    }
+
+    private File interpretPath(String fileURL) {
+        if (FileProtocol.CONF.match(fileURL)) {
+            return new File(directoryProvider.getConfDirectory() + "/" + FileProtocol.CONF.removeProtocolFromPath(fileURL));
+        } else if (FileProtocol.VAR.match(fileURL)) {
+            return new File(directoryProvider.getVarDirectory() + "/" + FileProtocol.VAR.removeProtocolFromPath(fileURL));
+        } else if (FileProtocol.ABSOLUTE.match(fileURL)) {
+            return new File(directoryProvider.getAbsoluteDirectory() + FileProtocol.ABSOLUTE.removeProtocolFromPath(fileURL));
+        } else {
+            // move to the root folder of the spring deployment
+            return new File(directoryProvider.getRootDirectory() + "/" + FileProtocol.OTHER.removeProtocolFromPath(fileURL));
+        }
+    }
+    
+    private enum FileProtocol {
+        CONF(FileSystem.FILE_PROTOCOL_AND_CONF),
+        VAR(FileSystem.FILE_PROTOCOL_AND_VAR),
+        ABSOLUTE(FileSystem.FILE_PROTOCOL_ABSOLUTE),
+        OTHER(FileSystem.FILE_PROTOCOL);
+        
+        private final String protocolPrefix;
+        
+        FileProtocol(String protocolPrefix) {
+            this.protocolPrefix = protocolPrefix;
+        }
+        
+        private boolean match(String path) {
+            return path.startsWith(protocolPrefix);
+        }
+        
+        private String removeProtocolFromPath(String path) {
+            return path.substring(protocolPrefix.length());
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/main/java/org/apache/james/server/core/filesystem/ResourceUtils.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/main/java/org/apache/james/server/core/filesystem/ResourceUtils.java b/server/container/core/src/main/java/org/apache/james/server/core/filesystem/ResourceUtils.java
new file mode 100644
index 0000000..b59336f
--- /dev/null
+++ b/server/container/core/src/main/java/org/apache/james/server/core/filesystem/ResourceUtils.java
@@ -0,0 +1,41 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+package org.apache.james.server.core.filesystem;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.net.URISyntaxException;
+import java.net.URL;
+
+public class ResourceUtils {
+    public static final String URL_PROTOCOL_FILE = "file";
+
+    public static File getFile(URL url, String description) throws FileNotFoundException {
+        if (!URL_PROTOCOL_FILE.equals(url.getProtocol())) {
+            throw new FileNotFoundException(description + " cannot be resolved to absolute file path " + "because it does not reside in the file system: " + url);
+        }
+        try {
+            return new File(url.toURI().getSchemeSpecificPart());
+        } catch (URISyntaxException ex) {
+            // Fallback for URLs that are not valid URIs (should hardly ever
+            // happen).
+            return new File(url.getFile());
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/main/java/org/apache/james/server/core/filesystem/SimpleUrl.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/main/java/org/apache/james/server/core/filesystem/SimpleUrl.java b/server/container/core/src/main/java/org/apache/james/server/core/filesystem/SimpleUrl.java
new file mode 100644
index 0000000..dfe3b3b
--- /dev/null
+++ b/server/container/core/src/main/java/org/apache/james/server/core/filesystem/SimpleUrl.java
@@ -0,0 +1,74 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+package org.apache.james.server.core.filesystem;
+
+import java.util.Optional;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.CharMatcher;
+import com.google.common.io.Files;
+
+public class SimpleUrl {
+    private static final String FOLDER_SEPARATOR = "/";
+
+    private static final char WINDOWS_FOLDER_SEPARATOR = '\\';
+
+    private static final String CURRENT_PATH = ".";
+
+    private static final Pattern URL_REGEXP = Pattern.compile("^([^/][^/]*:(?://)?)?(.*)");
+
+    private static String url;
+    private static String protocol;
+    private static String path;
+    private static String simplifiedUrl;
+
+    public SimpleUrl(String url) {
+        SimpleUrl.url = url;
+        String urlWithUnixSeparators = CharMatcher.is(WINDOWS_FOLDER_SEPARATOR).replaceFrom(url, FOLDER_SEPARATOR);
+        extractComponents(urlWithUnixSeparators);
+        simplifiedUrl = protocol + simplifyPath(path);
+    }
+
+    private static void extractComponents(String urlWithUnixSeparators) {
+        Matcher m = URL_REGEXP.matcher(urlWithUnixSeparators);
+        m.matches();
+        protocol = Optional.ofNullable(m.group(1)).orElse("");
+        path = Optional.ofNullable(m.group(2)).orElse("");
+    }
+
+    @VisibleForTesting
+    static String simplifyPath(String path) {
+        String simplified = Files.simplifyPath(path);
+        if (CURRENT_PATH.equals(simplified)) {
+            return "";
+        }
+        return simplified;
+    }
+
+    public String getUrl() {
+        return url;
+    }
+
+    public String getSimplified() {
+        return simplifiedUrl;
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/main/java/org/apache/james/server/core/filesystem/UrlResource.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/main/java/org/apache/james/server/core/filesystem/UrlResource.java b/server/container/core/src/main/java/org/apache/james/server/core/filesystem/UrlResource.java
new file mode 100644
index 0000000..781af4d
--- /dev/null
+++ b/server/container/core/src/main/java/org/apache/james/server/core/filesystem/UrlResource.java
@@ -0,0 +1,59 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+package org.apache.james.server.core.filesystem;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.net.URLConnection;
+
+public class UrlResource implements Resource {
+    public static final String URL_PROTOCOL_FILE = "file";
+    private final URL url;
+
+    public UrlResource(URL url) {
+        this.url = url;
+    }
+
+    @Override
+    public InputStream getInputStream() throws IOException {
+        URLConnection con = this.url.openConnection();
+        useCachesIfNecessary(con);
+        try {
+            return con.getInputStream();
+        } catch (IOException ex) {
+            // Close the HTTP connection (if applicable).
+            if (con instanceof HttpURLConnection) {
+                ((HttpURLConnection) con).disconnect();
+            }
+            throw ex;
+        }
+    }
+
+    public static void useCachesIfNecessary(URLConnection con) {
+        con.setUseCaches(con.getClass().getSimpleName().startsWith("JNLP"));
+    }
+
+    @Override
+    public File getFile() throws IOException {
+        return ResourceUtils.getFile(url, "URL [" + this.url + "]");
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/main/java/org/apache/james/server/core/package.html
----------------------------------------------------------------------
diff --git a/server/container/core/src/main/java/org/apache/james/server/core/package.html b/server/container/core/src/main/java/org/apache/james/server/core/package.html
new file mode 100644
index 0000000..a9ce61d
--- /dev/null
+++ b/server/container/core/src/main/java/org/apache/james/server/core/package.html
@@ -0,0 +1,21 @@
+<!--
+  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.    
+-->
+<body>
+<p>Implementations of core James services and concepts.</p>
+</body>

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/test/java/org/apache/james/core/MailHeadersTest.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/test/java/org/apache/james/core/MailHeadersTest.java b/server/container/core/src/test/java/org/apache/james/core/MailHeadersTest.java
deleted file mode 100644
index 0a24dd8..0000000
--- a/server/container/core/src/test/java/org/apache/james/core/MailHeadersTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-package org.apache.james.core;
-
-import java.io.ByteArrayInputStream;
-import java.util.Enumeration;
-import javax.mail.MessagingException;
-import org.apache.mailet.base.RFC2822Headers;
-import static org.junit.Assert.assertEquals;
-import org.junit.Test;
-
-public class MailHeadersTest {
-
-    @Test
-    public void testHeadersOrder() throws MessagingException {
-        MailHeaders header = new MailHeaders(new ByteArrayInputStream((RFC2822Headers.SUBJECT + ": testsubject\r\n").
-                getBytes()));
-        header.setHeader(RFC2822Headers.RETURN_PATH, "<te...@test>");
-        header.setHeader(RFC2822Headers.FROM, "<te...@test.de>");
-        @SuppressWarnings("unchecked")
-        Enumeration<String> h = header.getAllHeaderLines();
-
-        assertEquals(h.nextElement(), "Return-Path: <te...@test>");
-        assertEquals(h.nextElement(), "From: <te...@test.de>");
-        assertEquals(h.nextElement(), "Subject: testsubject");
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/test/java/org/apache/james/core/MailImplTest.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/test/java/org/apache/james/core/MailImplTest.java b/server/container/core/src/test/java/org/apache/james/core/MailImplTest.java
deleted file mode 100644
index aa82d0b..0000000
--- a/server/container/core/src/test/java/org/apache/james/core/MailImplTest.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-package org.apache.james.core;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertNull;
-
-import java.io.ByteArrayInputStream;
-import java.util.ArrayList;
-
-import javax.mail.MessagingException;
-import javax.mail.Session;
-import javax.mail.internet.MimeMessage;
-
-import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
-import org.apache.mailet.base.test.MailUtil;
-import org.junit.Test;
-
-public class MailImplTest extends MailTestAllImplementations {
-
-    private static final Session NO_SESSION = null;
-    
-    @Override
-    protected Mail createMailImplementation() {
-        return new MailImpl();
-    }
-
-    @Test
-    public void testConstr1() throws MessagingException {
-        MailImpl mail = new MailImpl();
-
-        helperTestInitialState(mail);
-        helperTestMessageSize(mail, 0); // MimeMessageWrapper default is 0
-        assertNull("no initial message", mail.getMessage());
-        assertNull("no initial sender", mail.getSender());
-        assertNull("no initial name", mail.getName());
-    }
-
-    @Test
-    public void testConstr2() throws MessagingException {
-        ArrayList<MailAddress> recepients = new ArrayList<>();
-        String name = MailUtil.newId();
-        String sender = "sender@localhost";
-        MailAddress senderMailAddress = new MailAddress(sender);
-        MailImpl mail = new MailImpl(name, senderMailAddress, recepients);
-
-        helperTestInitialState(mail); // MimeMessageWrapper default is 0
-        helperTestMessageSize(mail, 0); // MimeMessageWrapper default is 0
-        assertNull("no initial message", mail.getMessage());
-        assertEquals("sender", sender, mail.getSender().toString());
-        assertEquals("name", name, mail.getName());
-
-        mail.setMessage(new MimeMessage(NO_SESSION));
-        assertNotNull("message", mail.getMessage());
-    }
-
-    @Test
-    public void testConstr3() throws MessagingException {
-        ArrayList<MailAddress> recepients = new ArrayList<>();
-        String name = MailUtil.newId();
-        String sender = "sender@localhost";
-        MailAddress senderMailAddress = new MailAddress(sender);
-        MimeMessage mimeMessage = new MimeMessage(NO_SESSION, new ByteArrayInputStream(new byte[0]));
-        MailImpl mail = new MailImpl(name, senderMailAddress, recepients, mimeMessage);
-
-        helperTestInitialState(mail);
-        helperTestMessageSize(mail, 0);
-        assertEquals("initial message", mimeMessage.getMessageID(), mail.getMessage().getMessageID());
-        assertEquals("sender", sender, mail.getSender().toString());
-        assertEquals("name", name, mail.getName());
-        mail.dispose();
-    }
-
-    @Test
-    public void testDuplicate() throws MessagingException {
-        MailImpl mail = new MailImpl();
-        MailImpl duplicate = (MailImpl) mail.duplicate();
-        assertNotSame("is real duplicate", mail, duplicate);
-        helperTestInitialState(duplicate);
-        helperTestMessageSize(duplicate, 0);
-    }
-
-    @Test
-    public void testDuplicateNewName() throws MessagingException {
-        String newName = "aNewName";
-
-        MailImpl mail = new MailImpl();
-        assertFalse("before + after names differ", newName.equals(mail.getName()));
-
-        MailImpl duplicate = (MailImpl) mail.duplicate(newName);
-        assertEquals("new name set", newName, duplicate.getName());
-        helperTestInitialState(duplicate);
-        helperTestMessageSize(duplicate, 0);
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/test/java/org/apache/james/core/MailTestAllImplementations.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/test/java/org/apache/james/core/MailTestAllImplementations.java b/server/container/core/src/test/java/org/apache/james/core/MailTestAllImplementations.java
deleted file mode 100644
index 9e928f7..0000000
--- a/server/container/core/src/test/java/org/apache/james/core/MailTestAllImplementations.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-package org.apache.james.core;
-
-import javax.mail.MessagingException;
-
-import org.apache.mailet.Mail;
-import org.junit.Test;
-import static org.junit.Assert.*;
-
-/**
- * testing common behavior of Mail implementors. subclasses automatically get
- * their Mail-behavior tested.
- */
-public abstract class MailTestAllImplementations {
-
-    /** provide the concrete implementation to test */
-    protected abstract Mail createMailImplementation();
-
-    protected void helperTestInitialState(Mail mail) {
-        assertFalse("no initial attributes", mail.hasAttributes());
-        assertNull("no initial error", mail.getErrorMessage());
-        assertNotNull("initial last update set", mail.getLastUpdated());
-        try {
-            assertTrue("no initial recipient", mail.getRecipients().isEmpty());
-        } catch (NullPointerException e) {
-            // current behavior. *BUT*, shouldn't this method better return with
-            // an empty list?!
-        }
-        assertEquals("initial remote address is localhost ip", "127.0.0.1", mail.getRemoteAddr());
-        assertEquals("initial remote host is localhost", "localhost", mail.getRemoteHost());
-        assertEquals("default initial state", Mail.DEFAULT, mail.getState());
-    }
-
-    protected void helperTestMessageSize(Mail mail, int expectedMsgSize) throws MessagingException {
-        try {
-            assertEquals("initial message size == " + expectedMsgSize, expectedMsgSize, mail.getMessageSize());
-        } catch (NullPointerException e) {
-            // current behavior. *BUT*, shouldn't this method return more
-            // gracefully?!
-        }
-    }
-
-    @Test
-    public void testAttributes() {
-        Mail mail = createMailImplementation();
-        assertFalse("no initial attributes", mail.hasAttributes());
-        assertFalse("attributes initially empty", mail.getAttributeNames().hasNext());
-        assertNull("not found on emtpy list", mail.getAttribute("test"));
-        assertNull("no previous item with key", mail.setAttribute("testKey", "testValue"));
-        assertEquals("item found", "testValue", mail.getAttribute("testKey"));
-        assertTrue("has attribute", mail.hasAttributes());
-        assertEquals("item removed", "testValue", mail.removeAttribute("testKey"));
-        assertNull("item no longer found", mail.getAttribute("testKey"));
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/test/java/org/apache/james/core/MimeMessageCopyOnWriteProxyTest.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/test/java/org/apache/james/core/MimeMessageCopyOnWriteProxyTest.java b/server/container/core/src/test/java/org/apache/james/core/MimeMessageCopyOnWriteProxyTest.java
deleted file mode 100644
index 36c678b..0000000
--- a/server/container/core/src/test/java/org/apache/james/core/MimeMessageCopyOnWriteProxyTest.java
+++ /dev/null
@@ -1,279 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-package org.apache.james.core;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.util.ArrayList;
-import java.util.Properties;
-
-import javax.mail.MessagingException;
-import javax.mail.Session;
-import javax.mail.internet.MimeMessage;
-import javax.mail.util.SharedByteArrayInputStream;
-
-import org.apache.james.lifecycle.api.LifecycleUtil;
-import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
-import org.junit.Test;
-
-public class MimeMessageCopyOnWriteProxyTest extends MimeMessageFromStreamTest {
-
-    final String content = "Subject: foo\r\nContent-Transfer-Encoding2: plain";
-    final String sep = "\r\n\r\n";
-    final String body = "bar\r\n.\r\n";
-
-    @Override
-    protected MimeMessage getMessageFromSources(String sources) throws Exception {
-        MimeMessageInputStreamSource mmis = new MimeMessageInputStreamSource("test", new SharedByteArrayInputStream(sources.getBytes()));
-        return new MimeMessageCopyOnWriteProxy(mmis);
-        // return new MimeMessage(Session.getDefaultInstance(new
-        // Properties()),new ByteArrayInputStream(sources.getBytes()));
-    }
-
-    @Test
-    public void testMessageCloning1() throws Exception {
-        ArrayList<MailAddress> r = new ArrayList<>();
-        r.add(new MailAddress("recipient@test.com"));
-        MimeMessageCopyOnWriteProxy messageFromSources = (MimeMessageCopyOnWriteProxy) getMessageFromSources(
-                content + sep + body);
-        MailImpl mail = new MailImpl("test", new MailAddress("test@test.com"), r, messageFromSources);
-        MailImpl m2 = (MailImpl) mail.duplicate();
-        System.out.println("mail: " + getReferences(mail.getMessage()) + " m2: " + getReferences(m2.getMessage()));
-        assertNotSame(m2, mail);
-        assertNotSame(m2.getMessage(), mail.getMessage());
-        // test that the wrapped message is the same
-        assertTrue(isSameMimeMessage(m2.getMessage(), mail.getMessage()));
-        // test it is the same after read only operations!
-        mail.getMessage().getSubject();
-        assertTrue(isSameMimeMessage(m2.getMessage(), mail.getMessage()));
-        mail.getMessage().setText("new body");
-        mail.getMessage().saveChanges();
-        // test it is different after a write operation!
-        mail.getMessage().setSubject("new Subject");
-        assertTrue(!isSameMimeMessage(m2.getMessage(), mail.getMessage()));
-        LifecycleUtil.dispose(mail);
-        LifecycleUtil.dispose(m2);
-        LifecycleUtil.dispose(messageFromSources);
-    }
-
-    @Test
-    public void testMessageCloning2() throws Exception {
-        ArrayList<MailAddress> r = new ArrayList<>();
-        r.add(new MailAddress("recipient@test.com"));
-        MimeMessageCopyOnWriteProxy messageFromSources = (MimeMessageCopyOnWriteProxy) getMessageFromSources(
-                content + sep + body);
-        MailImpl mail = new MailImpl("test", new MailAddress("test@test.com"), r, messageFromSources);
-        MailImpl m2 = (MailImpl) mail.duplicate();
-        System.out.println("mail: " + getReferences(mail.getMessage()) + " m2: " + getReferences(m2.getMessage()));
-        assertNotSame(m2, mail);
-        assertNotSame(m2.getMessage(), mail.getMessage());
-        // test that the wrapped message is the same
-        assertTrue(isSameMimeMessage(m2.getMessage(), mail.getMessage()));
-        // test it is the same after real only operations!
-        m2.getMessage().getSubject();
-        assertTrue(isSameMimeMessage(m2.getMessage(), mail.getMessage()));
-        m2.getMessage().setText("new body");
-        m2.getMessage().saveChanges();
-        // test it is different after a write operation!
-        m2.getMessage().setSubject("new Subject");
-        assertTrue(!isSameMimeMessage(m2.getMessage(), mail.getMessage()));
-        // check that the subjects are correct on both mails!
-        assertEquals(m2.getMessage().getSubject(), "new Subject");
-        assertEquals(mail.getMessage().getSubject(), "foo");
-        // cloning again the messages
-        Mail m2clone = m2.duplicate();
-        assertTrue(isSameMimeMessage(m2clone.getMessage(), m2.getMessage()));
-        MimeMessage mm = getWrappedMessage(m2.getMessage());
-        assertNotSame(m2.getMessage(), m2clone.getMessage());
-        // test that m2clone has a valid wrapped message
-        MimeMessage mm3 = getWrappedMessage(m2clone.getMessage());
-        assertNotNull(mm3);
-        // dispose m2 and check that the clone has still a valid message and it
-        // is the same!
-        LifecycleUtil.dispose(m2);
-        assertEquals(mm3, getWrappedMessage(m2clone.getMessage()));
-        // change the message that should be not referenced by m2 that has
-        // been disposed, so it should not clone it!
-        m2clone.getMessage().setSubject("new Subject 2");
-        m2clone.getMessage().setText("new Body 3");
-        assertTrue(isSameMimeMessage(m2clone.getMessage(), mm));
-        LifecycleUtil.dispose(mail);
-        LifecycleUtil.dispose(messageFromSources);
-    }
-
-    /**
-     * If I create a new MimeMessageCopyOnWriteProxy from another
-     * MimeMessageCopyOnWriteProxy, I remove references to the first and I
-     * change the second, then it should not clone
-     */
-    @Test
-    public void testMessageAvoidCloning() throws Exception {
-        ArrayList<MailAddress> r = new ArrayList<>();
-        r.add(new MailAddress("recipient@test.com"));
-        MimeMessageCopyOnWriteProxy messageFromSources = (MimeMessageCopyOnWriteProxy) getMessageFromSources(
-                content + sep + body);
-        MailImpl mail = new MailImpl("test", new MailAddress("test@test.com"), r, messageFromSources);
-        // cloning the message
-        Mail mailClone = mail.duplicate();
-        assertTrue(isSameMimeMessage(mailClone.getMessage(), mail.getMessage()));
-        MimeMessage mm = getWrappedMessage(mail.getMessage());
-        assertNotSame(mail.getMessage(), mailClone.getMessage());
-        // dispose mail and check that the clone has still a valid message and
-        // it is the same!
-        LifecycleUtil.dispose(mail);
-        LifecycleUtil.dispose(messageFromSources);
-        // need to add a gc and a wait, because the original mimemessage should
-        // be finalized before the test.
-        System.gc();
-        Thread.sleep(1000);
-        // dumb test
-        assertTrue(isSameMimeMessage(mailClone.getMessage(), mailClone.getMessage()));
-        // change the message that should be not referenced by mail that has
-        // been disposed, so it should not clone it!
-        mailClone.getMessage().setSubject("new Subject 2");
-        mailClone.getMessage().setText("new Body 3");
-        assertTrue(isSameMimeMessage(mailClone.getMessage(), mm));
-        LifecycleUtil.dispose(mailClone);
-        LifecycleUtil.dispose(mm);
-    }
-
-    /**
-     * If I create a new MimeMessageCopyOnWriteProxy from a MimeMessage and I
-     * change the new message, the original should be unaltered and the proxy
-     * should clone the message.
-     */
-    @Test
-    public void testMessageCloning3() throws Exception {
-        ArrayList<MailAddress> r = new ArrayList<>();
-        r.add(new MailAddress("recipient@test.com"));
-        MimeMessage m = new MimeMessage(Session.getDefaultInstance(new Properties(null)));
-        m.setText("CIPS");
-        MailImpl mail = new MailImpl("test", new MailAddress("test@test.com"), r, m);
-        assertTrue(isSameMimeMessage(m, mail.getMessage()));
-        // change the message that should be not referenced by mail that has
-        // been disposed, so it should not clone it!
-        System.gc();
-        Thread.sleep(100);
-        mail.getMessage().setSubject("new Subject 2");
-        mail.getMessage().setText("new Body 3");
-        System.gc();
-        Thread.sleep(100);
-        assertFalse(isSameMimeMessage(m, mail.getMessage()));
-        LifecycleUtil.dispose(mail);
-        LifecycleUtil.dispose(m);
-    }
-
-    @Test
-    public void testMessageDisposing() throws Exception {
-        ArrayList<MailAddress> r = new ArrayList<>();
-        r.add(new MailAddress("recipient@test.com"));
-        MimeMessageCopyOnWriteProxy messageFromSources = (MimeMessageCopyOnWriteProxy) getMessageFromSources(
-                content + sep + body);
-        MailImpl mail = new MailImpl("test", new MailAddress("test@test.com"), r, messageFromSources);
-        // cloning the message
-        MailImpl mailClone = (MailImpl) mail.duplicate();
-        LifecycleUtil.dispose(mail);
-
-        assertNotNull(getWrappedMessage(mailClone.getMessage()));
-        assertNull(mail.getMessage());
-
-        LifecycleUtil.dispose(mailClone);
-
-        assertNull(mailClone.getMessage());
-        assertNull(mail.getMessage());
-        LifecycleUtil.dispose(mail);
-        LifecycleUtil.dispose(messageFromSources);
-    }
-
-    @Test
-    public void testNPE1() throws MessagingException, InterruptedException {
-        ArrayList<MailAddress> recipients = new ArrayList<>();
-        recipients.add(new MailAddress("recipient@test.com"));
-        MimeMessageCopyOnWriteProxy mw = new MimeMessageCopyOnWriteProxy(new MimeMessageInputStreamSource("test",
-                new SharedByteArrayInputStream(("Return-path: return@test.com\r\n" + "Content-Transfer-Encoding: plain\r\n" + "Subject: test\r\n\r\n" + "Body Text testNPE1\r\n").
-                getBytes())));
-
-        MimeMessageCopyOnWriteProxy mw2 = new MimeMessageCopyOnWriteProxy(mw);
-        LifecycleUtil.dispose(mw2);
-        mw2 = null;
-        System.gc();
-        Thread.sleep(1000);
-        // the NPE was inside this call
-        mw.getMessageSize();
-        LifecycleUtil.dispose(mw);
-    }
-
-    /**
-     * This test throw a NullPointerException when the original message was
-     * created by a MimeMessageInputStreamSource.
-     */
-    @Test
-    public void testMessageCloningViaCoW3() throws Exception {
-        MimeMessage mmorig = getSimpleMessage();
-
-        MimeMessage mm = new MimeMessageCopyOnWriteProxy(mmorig);
-
-        LifecycleUtil.dispose(mmorig);
-        mmorig = null;
-        System.gc();
-        Thread.sleep(200);
-
-        try {
-            mm.writeTo(System.out);
-        } catch (Exception e) {
-            e.printStackTrace();
-            fail("Exception while writing the message to output");
-        }
-
-        LifecycleUtil.dispose(mm);
-    }
-
-    private static String getReferences(MimeMessage m) {
-        StringBuilder ref = new StringBuilder("/");
-        while (m instanceof MimeMessageCopyOnWriteProxy) {
-            ref.append(((MimeMessageCopyOnWriteProxy) m).refCount.getReferenceCount()).append("/");
-            m = ((MimeMessageCopyOnWriteProxy) m).getWrappedMessage();
-        }
-        if (m instanceof MimeMessageWrapper) {
-            ref.append("W");
-        } else {
-            ref.append("M");
-        }
-        return ref.toString();
-    }
-
-    private static MimeMessage getWrappedMessage(MimeMessage m) {
-        while (m instanceof MimeMessageCopyOnWriteProxy) {
-            m = ((MimeMessageCopyOnWriteProxy) m).getWrappedMessage();
-        }
-        return m;
-    }
-
-    private static boolean isSameMimeMessage(MimeMessage first, MimeMessage second) {
-        return getWrappedMessage(first) == getWrappedMessage(second);
-
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/test/java/org/apache/james/core/MimeMessageFromMimeMessageTest.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/test/java/org/apache/james/core/MimeMessageFromMimeMessageTest.java b/server/container/core/src/test/java/org/apache/james/core/MimeMessageFromMimeMessageTest.java
deleted file mode 100644
index b554576..0000000
--- a/server/container/core/src/test/java/org/apache/james/core/MimeMessageFromMimeMessageTest.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-
-package org.apache.james.core;
-
-import javax.mail.internet.MimeMessage;
-
-public class MimeMessageFromMimeMessageTest extends MimeMessageFromStreamTest {
-
-    @Override
-    protected MimeMessage getMessageFromSources(String sources) throws Exception {
-        return new MimeMessage(super.getMessageFromSources(sources));
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/test/java/org/apache/james/core/MimeMessageFromSharedStreamTest.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/test/java/org/apache/james/core/MimeMessageFromSharedStreamTest.java b/server/container/core/src/test/java/org/apache/james/core/MimeMessageFromSharedStreamTest.java
deleted file mode 100644
index ac61aa1..0000000
--- a/server/container/core/src/test/java/org/apache/james/core/MimeMessageFromSharedStreamTest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-
-package org.apache.james.core;
-
-import javax.mail.util.SharedByteArrayInputStream;
-
-import javax.mail.Session;
-import javax.mail.internet.MimeMessage;
-
-import java.util.Properties;
-
-public class MimeMessageFromSharedStreamTest extends MimeMessageFromStreamTest {
-
-    @Override
-    protected MimeMessage getMessageFromSources(String sources) throws Exception {
-        return new MimeMessage(Session.getDefaultInstance(new Properties()), new SharedByteArrayInputStream(sources.getBytes()));
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/test/java/org/apache/james/core/MimeMessageFromStreamTest.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/test/java/org/apache/james/core/MimeMessageFromStreamTest.java b/server/container/core/src/test/java/org/apache/james/core/MimeMessageFromStreamTest.java
deleted file mode 100644
index e718dd8..0000000
--- a/server/container/core/src/test/java/org/apache/james/core/MimeMessageFromStreamTest.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-
-package org.apache.james.core;
-
-import javax.mail.Session;
-import javax.mail.internet.MimeMessage;
-
-import java.io.ByteArrayInputStream;
-import java.util.Properties;
-
-public class MimeMessageFromStreamTest extends MimeMessageTest {
-
-    protected MimeMessage getMessageFromSources(String sources) throws Exception {
-        return new MimeMessage(Session.getDefaultInstance(new Properties()), new ByteArrayInputStream(sources.getBytes()));
-    }
-
-    @Override
-    protected MimeMessage getMultipartMessage() throws Exception {
-        return getMessageFromSources(getMultipartMessageSource());
-    }
-
-    @Override
-    protected MimeMessage getSimpleMessage() throws Exception {
-        return getMessageFromSources(getSimpleMessageCleanedSource());
-    }
-
-    @Override
-    protected MimeMessage getMessageWithBadReturnPath() throws Exception {
-        return getMessageFromSources(getMessageWithBadReturnPathSource());
-    }
-
-    @Override
-    protected MimeMessage getMissingEncodingAddHeaderMessage() throws Exception {
-        return getMessageFromSources(getMissingEncodingAddHeaderSource());
-    }
-
-    @Override
-    protected MimeMessage getMissingEncodingMessage() throws Exception {
-        return getMessageFromSources(getMissingEncodingMessageSource());
-    }
-
-}


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


[16/23] james-project git commit: JAMES-2138 move MailAddress to a new james-core project

Posted by bt...@apache.org.
JAMES-2138 move MailAddress to a new james-core project

	move james.core package to james.server.core to avoid conflict


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/936746b9
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/936746b9
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/936746b9

Branch: refs/heads/master
Commit: 936746b9a8c85fbe2c303baedfdb7a067813f633
Parents: e9cb6e9
Author: Matthieu Baechler <ma...@apache.org>
Authored: Mon Sep 4 17:03:41 2017 +0200
Committer: benwa <bt...@linagora.com>
Committed: Sat Sep 9 10:46:01 2017 +0700

----------------------------------------------------------------------
 core/pom.xml                                    |  65 ++
 .../java/org/apache/james/core/MailAddress.java | 623 ++++++++++++++++
 .../org/apache/james/core/MailAddressTest.java  | 229 ++++++
 .../james/ai/classic/BayesianAnalysis.java      |   2 +-
 mailet/api/pom.xml                              |   4 +
 .../src/main/java/org/apache/mailet/Mail.java   |   1 +
 .../java/org/apache/mailet/MailAddress.java     | 550 +--------------
 .../java/org/apache/mailet/MailetContext.java   |   1 +
 .../main/java/org/apache/mailet/Matcher.java    |   2 +
 .../org/apache/mailet/PerRecipientHeaders.java  |   2 +
 .../java/org/apache/mailet/MailAddressTest.java | 229 ------
 .../base/AutomaticallySentMailDetectorImpl.java |   2 +-
 .../org/apache/mailet/base/GenericMatcher.java  |   2 +-
 .../mailet/base/GenericRecipientMatcher.java    |   2 +-
 .../org/apache/mailet/base/MatcherInverter.java |   2 +-
 .../AutomaticallySentMailDetectorImplTest.java  |   2 +-
 .../apache/mailet/base/MailAddressFixture.java  |   2 +-
 .../apache/mailet/base/MatcherInverterTest.java |   2 +-
 .../org/apache/mailet/base/test/FakeMail.java   |   2 +-
 .../mailet/base/test/FakeMailContext.java       |   2 +-
 .../org/apache/mailet/base/test/MailUtil.java   |   2 +-
 .../james/transport/mailets/AbstractSign.java   |   2 +-
 .../transport/matcher/IsSMIMEEncrypted.java     |   2 +-
 .../james/transport/matcher/IsSMIMESigned.java  |   2 +-
 .../matcher/IsX509CertificateSubject.java       |   2 +-
 .../transport/mailets/ICALToJsonAttribute.java  |   2 +-
 .../james/transport/mailets/model/ICAL.java     |   2 +-
 .../mailets/ICALToJsonAttributeTest.java        |   2 +-
 .../james/transport/mailets/model/ICALTest.java |   2 +-
 .../transport/mailets/AddDeliveredToHeader.java |   2 +-
 .../james/transport/mailets/ClamAVScan.java     |   2 +-
 .../transport/mailets/PostmasterAlias.java      |   2 +-
 .../transport/mailets/RecipientToLowerCase.java |   2 +-
 .../transport/mailets/UseHeaderRecipients.java  |   2 +-
 .../matchers/AbstractQuotaMatcher.java          |   2 +-
 .../apache/james/transport/matchers/All.java    |   2 +-
 .../matchers/AttachmentFileNameIs.java          |   2 +-
 .../transport/matchers/CommandForListserv.java  |   2 +-
 .../matchers/CommandListservMatcher.java        |   2 +-
 .../matchers/CompareNumericHeaderValue.java     |   2 +-
 .../james/transport/matchers/FetchedFrom.java   |   2 +-
 .../transport/matchers/GenericRegexMatcher.java |   2 +-
 .../james/transport/matchers/HasAttachment.java |   2 +-
 .../matchers/HasHabeasWarrantMark.java          |   2 +-
 .../james/transport/matchers/HasHeader.java     |   2 +-
 .../transport/matchers/HasHeaderWithPrefix.java |   2 +-
 .../transport/matchers/HasMailAttribute.java    |   2 +-
 .../matchers/HasMailAttributeWithValue.java     |   2 +-
 .../HasMailAttributeWithValueRegex.java         |   2 +-
 .../apache/james/transport/matchers/HostIs.java |   2 +-
 .../james/transport/matchers/HostIsLocal.java   |   2 +-
 .../transport/matchers/IsSingleRecipient.java   |   2 +-
 .../james/transport/matchers/RecipientIs.java   |   2 +-
 .../transport/matchers/RecipientIsLocal.java    |   2 +-
 .../transport/matchers/RecipientIsRegex.java    |   2 +-
 .../james/transport/matchers/RelayLimit.java    |   2 +-
 .../transport/matchers/SMTPAuthSuccessful.java  |   2 +-
 .../transport/matchers/SMTPAuthUserIs.java      |   2 +-
 .../transport/matchers/SMTPIsAuthNetwork.java   |   2 +-
 .../james/transport/matchers/SenderHostIs.java  |   2 +-
 .../transport/matchers/SenderHostIsLocal.java   |   2 +-
 .../james/transport/matchers/SenderIs.java      |   2 +-
 .../james/transport/matchers/SenderIsLocal.java |   2 +-
 .../james/transport/matchers/SenderIsNull.java  |   2 +-
 .../james/transport/matchers/SenderIsRegex.java |   2 +-
 .../james/transport/matchers/SentByMailet.java  |   2 +-
 .../transport/matchers/SizeGreaterThan.java     |   2 +-
 .../james/transport/matchers/SubjectIs.java     |   2 +-
 .../transport/matchers/SubjectStartsWith.java   |   2 +-
 .../james/transport/matchers/TooManyLines.java  |   2 +-
 .../transport/matchers/TooManyRecipients.java   |   2 +-
 .../apache/james/transport/matchers/UserIs.java |   2 +-
 .../utils/MailAddressCollectionReader.java      |   2 +-
 .../james/transport/mailets/LogMessageTest.java |   2 +-
 .../mailets/RecipientToLowerCaseTest.java       |   2 +-
 .../transport/mailets/ToProcessorTest.java      |   2 +-
 .../mailets/UseHeaderRecipientsTest.java        |   2 +-
 .../matchers/AbstractHasMailAttributeTest.java  |   2 +-
 .../HasMailAttributeWithValueRegexTest.java     |   2 +-
 .../matchers/HasMailAttributeWithValueTest.java |   2 +-
 .../matchers/RecipientIsLocalTest.java          |   2 +-
 .../matchers/SMTPAuthSuccessfulTest.java        |   2 +-
 .../transport/matchers/SMTPAuthUserIsTest.java  |   3 +-
 .../matchers/SMTPIsAuthNetworkTest.java         |   2 +-
 .../matchers/SenderHostIsLocalTest.java         |   2 +-
 .../transport/matchers/SenderHostIsTest.java    |   2 +-
 .../transport/matchers/SenderIsLocalTest.java   |   2 +-
 .../transport/matchers/SenderIsNullTest.java    |   2 +-
 .../transport/matchers/SenderIsRegexTest.java   |   2 +-
 .../james/transport/matchers/SenderIsTest.java  |   2 +-
 .../transport/matchers/SentByMailetTest.java    |   2 +-
 .../james/transport/matchers/SubjectIsTest.java |   2 +-
 .../matchers/SubjectStartsWithTest.java         |   2 +-
 .../transport/matchers/TooManyLinesTest.java    |   2 +-
 .../matchers/TooManyRecipientsTest.java         |   2 +-
 .../util/MailAddressCollectionReaderTest.java   |   2 +-
 pom.xml                                         |   6 +
 .../lmtp/core/DataLineMessageHookHandler.java   |   2 +-
 .../lmtp/hook/DeliverToRecipientHook.java       |   2 +-
 .../protocols/lmtp/AbstractLMTPServerTest.java  |   2 +-
 protocols/pom.xml                               |   5 +
 protocols/smtp/pom.xml                          |   5 +-
 .../james/protocols/smtp/MailAddress.java       | 469 +-----------
 .../protocols/smtp/MailAddressException.java    |  12 +-
 .../james/protocols/smtp/MailEnvelope.java      |   2 +
 .../james/protocols/smtp/MailEnvelopeImpl.java  |   2 +
 .../james/protocols/smtp/SMTPSessionImpl.java   |   1 +
 .../AbstractAuthRequiredToRelayRcptHook.java    |   2 +-
 ...tSenderAuthIdentifyVerificationRcptHook.java |   2 +-
 .../AcceptRecipientIfRelayingIsAllowed.java     |   2 +-
 .../protocols/smtp/core/DataCmdHandler.java     |   3 +-
 .../protocols/smtp/core/MailCmdHandler.java     |   2 +-
 .../smtp/core/PostmasterAbuseRcptHook.java      |   2 +-
 .../protocols/smtp/core/RcptCmdHandler.java     |   2 +-
 .../smtp/core/ReceivedDataLineFilter.java       |   2 +-
 .../core/fastfail/AbstractGreylistHandler.java  |   2 +-
 .../core/fastfail/AbstractValidRcptHandler.java |   6 +-
 .../smtp/core/fastfail/DNSRBLHandler.java       |   2 +-
 .../smtp/core/fastfail/MaxRcptHandler.java      |   2 +-
 .../fastfail/ResolvableEhloHeloHandler.java     |   3 +-
 .../smtp/core/fastfail/SpamTrapHandler.java     |   2 +-
 .../fastfail/SupressDuplicateRcptHandler.java   |   6 +-
 .../core/fastfail/ValidSenderDomainHandler.java |   2 +-
 .../james/protocols/smtp/hook/MailHook.java     |   6 +-
 .../james/protocols/smtp/hook/RcptHook.java     |   2 +-
 .../james/protocols/smtp/hook/SimpleHook.java   |  26 +-
 .../protocols/smtp/AbstractSMTPServerTest.java  |   1 +
 .../smtp/core/fastfail/DNSRBLHandlerTest.java   |  15 +-
 .../smtp/core/fastfail/MaxRcptHandlerTest.java  |   7 +-
 .../core/fastfail/MaxUnknownCmdHandlerTest.java |   3 +-
 .../fastfail/ResolvableEhloHeloHandlerTest.java |  11 +-
 .../smtp/core/fastfail/SpamTrapHandlerTest.java |   6 +-
 .../fastfail/ValidSenderDomainHandlerTest.java  |   5 +-
 .../james/core/InternetHeadersInputStream.java  |  93 ---
 .../james/core/JamesServerResourceLoader.java   |  72 --
 .../java/org/apache/james/core/MailHeaders.java | 187 -----
 .../java/org/apache/james/core/MailImpl.java    | 691 ------------------
 .../james/core/MimeMessageCopyOnWriteProxy.java | 561 ---------------
 .../james/core/MimeMessageInputStream.java      | 127 ----
 .../core/MimeMessageInputStreamSource.java      | 174 -----
 .../apache/james/core/MimeMessageSource.java    |  84 ---
 .../org/apache/james/core/MimeMessageUtil.java  | 311 --------
 .../apache/james/core/MimeMessageWrapper.java   | 705 -------------------
 .../core/filesystem/ClassPathResource.java      | 110 ---
 .../james/core/filesystem/FileSystemImpl.java   |  60 --
 .../core/filesystem/FileSystemResource.java     |  44 --
 .../apache/james/core/filesystem/Resource.java  |  29 -
 .../james/core/filesystem/ResourceFactory.java  | 100 ---
 .../james/core/filesystem/ResourceUtils.java    |  41 --
 .../apache/james/core/filesystem/SimpleUrl.java |  74 --
 .../james/core/filesystem/UrlResource.java      |  59 --
 .../java/org/apache/james/core/package.html     |  21 -
 .../server/core/InternetHeadersInputStream.java |  93 +++
 .../server/core/JamesServerResourceLoader.java  |  72 ++
 .../apache/james/server/core/MailHeaders.java   | 187 +++++
 .../org/apache/james/server/core/MailImpl.java  | 691 ++++++++++++++++++
 .../core/MimeMessageCopyOnWriteProxy.java       | 561 +++++++++++++++
 .../server/core/MimeMessageInputStream.java     | 127 ++++
 .../core/MimeMessageInputStreamSource.java      | 174 +++++
 .../james/server/core/MimeMessageSource.java    |  84 +++
 .../james/server/core/MimeMessageUtil.java      | 311 ++++++++
 .../james/server/core/MimeMessageWrapper.java   | 705 +++++++++++++++++++
 .../core/filesystem/ClassPathResource.java      | 110 +++
 .../server/core/filesystem/FileSystemImpl.java  |  60 ++
 .../core/filesystem/FileSystemResource.java     |  44 ++
 .../james/server/core/filesystem/Resource.java  |  29 +
 .../server/core/filesystem/ResourceFactory.java | 100 +++
 .../server/core/filesystem/ResourceUtils.java   |  41 ++
 .../james/server/core/filesystem/SimpleUrl.java |  74 ++
 .../server/core/filesystem/UrlResource.java     |  59 ++
 .../org/apache/james/server/core/package.html   |  21 +
 .../org/apache/james/core/MailHeadersTest.java  |  43 --
 .../org/apache/james/core/MailImplTest.java     | 115 ---
 .../james/core/MailTestAllImplementations.java  |  72 --
 .../core/MimeMessageCopyOnWriteProxyTest.java   | 279 --------
 .../core/MimeMessageFromMimeMessageTest.java    |  31 -
 .../core/MimeMessageFromSharedStreamTest.java   |  36 -
 .../james/core/MimeMessageFromStreamTest.java   |  59 --
 .../core/MimeMessageInputStreamSourceTest.java  |  60 --
 .../org/apache/james/core/MimeMessageTest.java  | 437 ------------
 .../apache/james/core/MimeMessageUtilTest.java  |  65 --
 .../james/core/MimeMessageWrapperTest.java      | 289 --------
 .../core/filesystem/FileSystemImplTest.java     |  32 -
 .../james/core/filesystem/SimpleUrlTest.java    | 114 ---
 .../james/server/core/MailHeadersTest.java      |  43 ++
 .../apache/james/server/core/MailImplTest.java  | 115 +++
 .../server/core/MailTestAllImplementations.java |  72 ++
 .../core/MimeMessageCopyOnWriteProxyTest.java   | 279 ++++++++
 .../core/MimeMessageFromMimeMessageTest.java    |  31 +
 .../core/MimeMessageFromSharedStreamTest.java   |  36 +
 .../server/core/MimeMessageFromStreamTest.java  |  59 ++
 .../core/MimeMessageInputStreamSourceTest.java  |  60 ++
 .../james/server/core/MimeMessageTest.java      | 437 ++++++++++++
 .../james/server/core/MimeMessageUtilTest.java  |  65 ++
 .../server/core/MimeMessageWrapperTest.java     | 289 ++++++++
 .../core/filesystem/FileSystemImplTest.java     |  32 +
 .../server/core/filesystem/SimpleUrlTest.java   | 114 +++
 .../com/custom/matchers/AnotherMatcher.java     |   2 +-
 .../james/transport/matchers/CustomMatcher.java |   2 +-
 .../james/modules/CommonServicesModule.java     |   4 +-
 .../james/modules/TestFilesystemModule.java     |   2 +-
 .../utils/FileConfigurationProviderTest.java    |   4 +-
 .../utils/InMemoryMailRepositoryStoreTest.java  |   4 +-
 .../modules/server/MemoryMailQueueFactory.java  |   2 +-
 .../context/JamesServerApplicationContext.java  |   2 +-
 .../container/spring/tool/James23Importer.java  |   2 +-
 .../spring/filesystem/FileSystemImplTest.java   |   2 +-
 .../apache/james/user/api/UsersRepository.java  |   2 +-
 .../apache/james/user/api/model/JamesUser.java  |   2 +-
 .../mailrepository/file/FileMailRepository.java |   4 +-
 .../mailrepository/file/MBoxMailRepository.java |   2 +-
 .../file/MimeMessageStreamRepositorySource.java |   4 +-
 .../mailrepository/jcr/JCRMailRepository.java   |   4 +-
 .../mailrepository/jdbc/JDBCMailRepository.java |   8 +-
 .../mailrepository/jdbc/MessageInputStream.java |   6 +-
 .../jdbc/MimeMessageJDBCSource.java             |   6 +-
 .../user/jdbc/JamesUsersJdbcRepository.java     |   2 +-
 .../james/jmap/api/vacation/RecipientId.java    |   2 +-
 .../AbstractNotificationRegistryTest.java       |   2 +-
 .../ldap/ReadOnlyUsersLDAPRepositoryTest.java   |   2 +-
 .../user/ldap/ReadOnlyUsersLDAPRepository.java  |   2 +-
 .../rrt/lib/AbstractRecipientRewriteTable.java  |   2 +-
 .../rrt/lib/RecipientRewriteTableUtil.java      |   2 +-
 .../james/user/lib/AbstractUsersRepository.java |   2 +-
 .../james/user/lib/model/DefaultJamesUser.java  |   4 +-
 .../AbstractMailRepositoryTest.java             |   8 +-
 .../user/lib/AbstractUsersRepositoryTest.java   |   2 +-
 .../mailets/TemporaryFilesystemModule.java      |   2 +-
 .../mailets/AmqpForwardAttachmentTest.java      |   2 +-
 .../mailets/ICSAttachmentWorkflowTest.java      |   2 +-
 .../transport/mailets/StripAttachmentTest.java  |   2 +-
 .../api/mock/ExceptionThrowingMatcher.java      |   2 +-
 .../api/mock/MockMailetContext.java             |   2 +-
 .../mailetcontainer/api/mock/MockMatcher.java   |   2 +-
 .../impl/JamesMailetContext.java                |   4 +-
 .../mailetcontainer/impl/ProcessorUtil.java     |   2 +-
 .../impl/camel/MatcherSplitter.java             |   4 +-
 .../jmx/JMXStateMailetProcessorListener.java    |   2 +-
 .../mailetcontainer/impl/matchers/And.java      |   2 +-
 .../mailetcontainer/impl/matchers/Not.java      |   2 +-
 .../james/mailetcontainer/impl/matchers/Or.java |   2 +-
 .../mailetcontainer/impl/matchers/Xor.java      |   2 +-
 .../lib/AbstractStateMailetProcessor.java       |   2 +-
 .../impl/JamesMailetContextTest.java            |   2 +-
 .../mailetcontainer/impl/matchers/AndTest.java  |   2 +-
 .../mailetcontainer/impl/matchers/NotTest.java  |   2 +-
 .../mailetcontainer/impl/matchers/OrTest.java   |   2 +-
 .../mailetcontainer/impl/matchers/XorTest.java  |   2 +-
 .../AbstractStateCompositeProcessorTest.java    |   2 +-
 .../lib/AbstractStateMailetProcessorTest.java   |   4 +-
 .../mailets/AbstractRecipientRewriteTable.java  |   4 +-
 .../transport/mailets/BayesianAnalysis.java     |   2 +-
 .../apache/james/transport/mailets/Bounce.java  |   2 +-
 .../james/transport/mailets/DSNBounce.java      |   4 +-
 .../apache/james/transport/mailets/Forward.java |   2 +-
 .../james/transport/mailets/JDBCAlias.java      |   2 +-
 .../mailets/JDBCRecipientRewriteTable.java      |   2 +-
 .../transport/mailets/NotifyPostmaster.java     |   2 +-
 .../james/transport/mailets/NotifySender.java   |   2 +-
 .../mailets/RecipientRewriteTableProcessor.java |   2 +-
 .../james/transport/mailets/Redirect.java       |   2 +-
 .../james/transport/mailets/RemoteDelivery.java |   2 +-
 .../apache/james/transport/mailets/Resend.java  |   2 +-
 .../org/apache/james/transport/mailets/SPF.java |   2 +-
 .../apache/james/transport/mailets/Sieve.java   |   2 +-
 .../james/transport/mailets/ToSenderFolder.java |   2 +-
 .../transport/mailets/WhiteListManager.java     |   2 +-
 .../mailets/XMLRecipientRewriteTable.java       |   2 +-
 .../mailets/delivery/DeliveryUtils.java         |   2 +-
 .../mailets/delivery/MailDispatcher.java        |   2 +-
 .../transport/mailets/delivery/MailStore.java   |   2 +-
 .../mailets/delivery/MailboxAppender.java       |   2 +-
 .../mailets/delivery/SimpleMailStore.java       |   2 +-
 .../transport/mailets/jsieve/ActionContext.java |   2 +-
 .../transport/mailets/jsieve/ActionUtils.java   |   2 +-
 .../mailets/jsieve/FileIntoAction.java          |   2 +-
 .../mailets/jsieve/RedirectAction.java          |   2 +-
 .../transport/mailets/jsieve/RejectAction.java  |   2 +-
 .../mailets/jsieve/ResourceLocator.java         |   2 +-
 .../mailets/jsieve/SieveMailAdapter.java        |   2 +-
 .../mailets/jsieve/VacationAction.java          |   2 +-
 .../transport/mailets/jsieve/VacationReply.java |   2 +-
 .../mailets/jsieve/delivery/SieveExecutor.java  |   2 +-
 .../mailets/jsieve/delivery/SievePoster.java    |   2 +-
 .../mailets/redirect/AddressExtractor.java      |   2 +-
 .../redirect/MailMessageAlteringUtils.java      |   2 +-
 .../mailets/redirect/MailModifier.java          |   4 +-
 .../mailets/redirect/NotifyMailetsMessage.java  |   2 +-
 .../mailets/redirect/ProcessRedirectNotify.java |   2 +-
 .../mailets/redirect/RedirectNotify.java        |   2 +-
 .../mailets/redirect/SpecialAddress.java        |   2 +-
 ...ddressesArrayToMailAddressListConverter.java |   2 +-
 .../mailets/remoteDelivery/Bouncer.java         |   2 +-
 .../InternetAddressConverter.java               |   2 +-
 .../mailets/remoteDelivery/MailDelivrer.java    |   2 +-
 .../matchers/AbstractSQLWhitelistMatcher.java   |   2 +-
 .../matchers/AbstractStorageQuota.java          |   2 +-
 .../transport/matchers/InSpammerBlacklist.java  |   2 +-
 .../james/transport/matchers/IsInWhiteList.java |   2 +-
 .../james/transport/matchers/IsOverQuota.java   |   2 +-
 .../transport/matchers/MailboxQuotaFixed.java   |   2 +-
 .../matchers/NetworkIsInWhitelist.java          |   2 +-
 .../transport/matchers/RemoteAddrInNetwork.java |   2 +-
 .../matchers/RemoteAddrNotInNetwork.java        |   2 +-
 .../transport/matchers/SenderInFakeDomain.java  |   2 +-
 .../james/transport/util/MailAddressUtils.java  |   2 +-
 .../james/transport/util/RecipientsUtils.java   |   2 +-
 .../james/transport/util/ReplyToUtils.java      |   2 +-
 .../james/transport/util/SenderUtils.java       |   2 +-
 .../transport/util/SpecialAddressesUtils.java   |   2 +-
 .../apache/james/transport/util/TosUtils.java   |   2 +-
 .../samples/mailets/InstrumentationMailet.java  |   2 +-
 .../james/transport/mailets/BounceTest.java     |   2 +-
 .../james/transport/mailets/DSNBounceTest.java  |   2 +-
 .../james/transport/mailets/ForwardTest.java    |   2 +-
 .../transport/mailets/NotifyPostmasterTest.java |   2 +-
 .../transport/mailets/NotifySenderTest.java     |   2 +-
 .../RecipientRewriteTableProcessorTest.java     |   2 +-
 .../transport/mailets/RecordingMailContext.java |   2 +-
 .../james/transport/mailets/RedirectTest.java   |   2 +-
 .../james/transport/mailets/ResendTest.java     |   2 +-
 .../transport/mailets/ResourceLocatorTest.java  |   2 +-
 .../mailets/delivery/LocalDeliveryTest.java     |   2 +-
 .../mailets/delivery/MailDispatcherTest.java    |   2 +-
 .../mailets/delivery/SieveIntegrationTest.java  |   2 +-
 .../mailets/delivery/SimpleMailStoreTest.java   |   2 +-
 .../mailets/delivery/ToRecipientFolderTest.java |   2 +-
 .../managesieve/ManageSieveMailetTestCase.java  |   2 +-
 .../mailets/redirect/AddressExtractorTest.java  |   2 +-
 .../mailets/redirect/MailModifierTest.java      |   2 +-
 .../redirect/NotifyMailetsMessageTest.java      |   2 +-
 .../mailets/redirect/SpecialAddressTest.java    |   2 +-
 .../InternetAddressConverterTest.java           |   2 +-
 .../matchers/InSpammerBlacklistTest.java        |   2 +-
 .../transport/matchers/IsOverQuotaTest.java     |   2 +-
 .../matchers/RemoteAddrInNetworkTest.java       |   2 +-
 .../matchers/RemoteAddrNotInNetworkTest.java    |   2 +-
 .../transport/util/MailAddressUtilsTest.java    |   2 +-
 .../transport/util/RecipientsUtilsTest.java     |   2 +-
 .../james/transport/util/ReplyToUtilsTest.java  |   2 +-
 .../james/transport/util/SenderUtilsTest.java   |   2 +-
 .../util/SpecialAddressesUtilsTest.java         |   2 +-
 .../james/transport/util/TosUtilsTest.java      |   2 +-
 .../org/apache/james/fetchmail/Account.java     |   2 +-
 .../james/fetchmail/MessageProcessor.java       |   4 +-
 .../james/fetchmail/ParsedConfiguration.java    |   2 +-
 .../james/fetchmail/ProcessorAbstract.java      |   2 +-
 .../james/jmap/UserProvisioningFilter.java      |   2 +-
 .../apache/james/jmap/mailet/SentByJmap.java    |   2 +-
 .../james/jmap/mailet/VacationMailet.java       |   2 +-
 .../apache/james/jmap/mailet/VacationReply.java |   2 +-
 .../org/apache/james/jmap/send/MailFactory.java |   4 +-
 .../james/jmap/mailet/SentByJmapTest.java       |   2 +-
 .../james/jmap/mailet/VacationMailetTest.java   |   2 +-
 .../james/jmap/mailet/VacationReplyTest.java    |   2 +-
 .../apache/james/jmap/send/MailFactoryTest.java |   2 +-
 .../james/lmtpserver/DataLineLMTPHandler.java   |   9 +-
 .../hook/MailboxDeliverToRecipientHandler.java  |   2 +-
 .../AddDefaultAttributesMessageHook.java        |   2 +-
 .../DataLineJamesMessageHookHandler.java        |  25 +-
 .../james/smtpserver/JamesDataCmdHandler.java   |   4 +-
 .../james/smtpserver/MailPriorityHandler.java   |   2 +-
 .../james/smtpserver/SendMailHandler.java       |   2 +-
 .../SenderAuthIdentifyVerificationRcptHook.java |   2 +-
 .../fastfail/JDBCGreylistHandler.java           |   2 +-
 .../james/smtpserver/fastfail/SPFHandler.java   |   2 +-
 .../smtpserver/fastfail/ValidRcptHandler.java   |   2 +-
 .../james/smtpserver/fastfail/ValidRcptMX.java  |   2 +-
 .../model/MailetMailAddressAdapter.java         |   4 +-
 .../model/ProtocolMailAddressAdapter.java       |  10 +-
 .../apache/james/smtpserver/SMTPServerTest.java |   2 +-
 .../apache/james/smtpserver/SPFHandlerTest.java |   2 +-
 .../java/org/apache/james/smtpserver/Util.java  |   2 +-
 .../james/smtpserver/ValidRcptHandlerTest.java  |   2 +-
 .../james/smtpserver/ValidRcptMXTest.java       |   7 +-
 .../james/smtpserver/mock/mailet/MockMail.java  |   2 +-
 .../smtpserver/mock/mailet/MockMailContext.java |   2 +-
 .../WebAdminServerIntegrationTest.java          |   2 +
 server/protocols/webadmin/webadmin-data/pom.xml |   4 +
 .../james/queue/activemq/ActiveMQMailQueue.java |   6 +-
 .../activemq/MimeMessageBlobMessageSource.java  |   6 +-
 .../james/queue/api/mock/MockMailQueue.java     |   2 +-
 .../apache/james/queue/file/FileMailQueue.java  |   4 +-
 .../apache/james/queue/jms/JMSMailQueue.java    |   6 +-
 .../jms/MimeMessageObjectMessageSource.java     |   2 +-
 .../queue/library/MailQueueManagement.java      |   2 +-
 .../queue/jms/AbstractJMSMailQueueTest.java     |  21 +-
 387 files changed, 6541 insertions(+), 6832 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/core/pom.xml
----------------------------------------------------------------------
diff --git a/core/pom.xml b/core/pom.xml
new file mode 100644
index 0000000..388652b
--- /dev/null
+++ b/core/pom.xml
@@ -0,0 +1,65 @@
+<?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
+
+    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 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/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>james-project</artifactId>
+        <groupId>org.apache.james</groupId>
+        <version>3.1.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>james-core</artifactId>
+
+    <name>Apache James :: Core Domain Objects</name>
+    <description>Provides core domain objects for Email concepts</description>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.james</groupId>
+            <artifactId>james-server-util-java8</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.google.guava</groupId>
+            <artifactId>guava</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.sun.mail</groupId>
+            <artifactId>javax.mail</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>nl.jqno.equalsverifier</groupId>
+            <artifactId>equalsverifier</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.assertj</groupId>
+            <artifactId>assertj-core</artifactId>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/core/src/main/java/org/apache/james/core/MailAddress.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/james/core/MailAddress.java b/core/src/main/java/org/apache/james/core/MailAddress.java
new file mode 100644
index 0000000..54a0f49
--- /dev/null
+++ b/core/src/main/java/org/apache/james/core/MailAddress.java
@@ -0,0 +1,623 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+
+package org.apache.james.core;
+
+import java.util.Locale;
+
+import javax.mail.internet.AddressException;
+import javax.mail.internet.InternetAddress;
+
+/**
+ * A representation of an email address.
+ * <p/>
+ * <p>This class encapsulates functionality to access different
+ * parts of an email address without dealing with its parsing.</p>
+ * <p/>
+ * <p>A MailAddress is an address specified in the MAIL FROM and
+ * RCPT TO commands in SMTP sessions.  These are either passed by
+ * an external server to the mailet-compliant SMTP server, or they
+ * are created programmatically by the mailet-compliant server to
+ * send to another (external) SMTP server.  Mailets and matchers
+ * use the MailAddress for the purpose of evaluating the sender
+ * and recipient(s) of a message.</p>
+ * <p/>
+ * <p>MailAddress parses an email address as defined in RFC 821
+ * (SMTP) p. 30 and 31 where addresses are defined in BNF convention.
+ * As the mailet API does not support the aged "SMTP-relayed mail"
+ * addressing protocol, this leaves all addresses to be a {@code <mailbox>},
+ * as per the spec.
+ * <p/>
+ * <p>This class is a good way to validate email addresses as there are
+ * some valid addresses which would fail with a simpler approach
+ * to parsing address. It also removes the parsing burden from
+ * mailets and matchers that might not realize the flexibility of an
+ * SMTP address. For instance, "serge@home"@lokitech.com is a valid
+ * SMTP address (the quoted text serge@home is the local-part and
+ * lokitech.com is the domain). This means all current parsing to date
+ * is incorrect as we just find the first '@' and use that to separate
+ * local-part from domain.</p>
+ * <p/>
+ * <p>This parses an address as per the BNF specification for <mailbox>
+ * from RFC 821 on page 30 and 31, section 4.1.2. COMMAND SYNTAX.
+ * http://www.freesoft.org/CIE/RFC/821/15.htm</p>
+ *
+ * @version 1.0
+ */
+public class MailAddress implements java.io.Serializable {
+    /**
+     * We hardcode the serialVersionUID
+     * This version (2779163542539434916L) retains compatibility back to
+     * Mailet version 1.2 (James 1.2) so that MailAddress will be
+     * deserializable and mail doesn't get lost after an upgrade.
+     */
+    public static final long serialVersionUID = 2779163542539434916L;
+
+    private final static char[] SPECIAL =
+            {'<', '>', '(', ')', '[', ']', '\\', '.', ',', ';', ':', '@', '\"'};
+
+    private static final MailAddress NULL_SENDER = new MailAddress() {
+
+        @Override
+        public String getDomain() {
+            return "";
+        }
+
+        @Override
+        public String getLocalPart() {
+            return "";
+        }
+
+        @Override
+        public String toString() {
+            return "";
+        }
+
+        @Override
+        public boolean isNullSender() {
+            return true;
+        }
+
+    };
+
+
+    public static MailAddress nullSender() {
+        return NULL_SENDER;
+    }
+
+    private String localPart = null;
+    private String domain = null;
+
+    private MailAddress() {
+
+    }
+
+    /**
+     * Strips source routing. According to RFC-2821 it is a valid approach
+     * to handle mails containing RFC-821 source-route information.
+     *
+     * @param address the address to strip
+     * @param pos     current position
+     * @return new pos
+     */
+    private int stripSourceRoute(String address, int pos) {
+        if (pos < address.length()) {
+            if (address.charAt(pos) == '@') {
+                int i = address.indexOf(':');
+                if (i != -1) {
+                    pos = i + 1;
+                }
+            }
+        }
+        return pos;
+    }
+
+    /**
+     * Constructs a MailAddress by parsing the provided address.
+     *
+     * @param address the email address, compliant to the RFC2822 3.4.1. addr-spec specification
+     * @throws AddressException if the parse failed
+     */
+    public MailAddress(String address) throws AddressException {
+        address = address.trim();
+        int pos = 0;
+
+        // Test if mail address has source routing information (RFC-821) and get rid of it!!
+        //must be called first!! (or at least prior to updating pos)
+        stripSourceRoute(address, pos);
+
+        StringBuffer localPartSB = new StringBuffer();
+        StringBuffer domainSB = new StringBuffer();
+        //Begin parsing
+        //<mailbox> ::= <local-part> "@" <domain>
+
+        try {
+            //parse local-part
+            //<local-part> ::= <dot-string> | <quoted-string>
+            if (address.charAt(pos) == '\"') {
+                pos = parseQuotedLocalPartOrThrowException(localPartSB, address, pos);
+            } else {
+                pos = parseUnquotedLocalPartOrThrowException(localPartSB, address, pos);
+            }
+
+            //find @
+            if (pos >= address.length() || address.charAt(pos) != '@') {
+                throw new AddressException("Did not find @ between local-part and domain at position " +
+                        (pos + 1) + " in '" + address + "'", address, pos + 1);
+            }
+            pos++;
+
+            //parse domain
+            //<domain> ::=  <element> | <element> "." <domain>
+            //<element> ::= <name> | "#" <number> | "[" <dotnum> "]"
+            while (true) {
+                if (address.charAt(pos) == '#') {
+                    pos = parseNumber(domainSB, address, pos);
+                } else if (address.charAt(pos) == '[') {
+                    pos = parseDomainLiteral(domainSB, address, pos);
+                } else {
+                    pos = parseDomain(domainSB, address, pos);
+                }
+                if (pos >= address.length()) {
+                    break;
+                }
+                if (address.charAt(pos) == '.') {
+                    char lastChar = address.charAt(pos - 1);
+                    if (lastChar == '@' || lastChar == '.') {
+                        throw new AddressException("Subdomain expected before '.' or duplicate '.' in " + address);
+                    }
+                    domainSB.append('.');
+                    pos++;
+                    continue;
+                }
+                break;
+            }
+
+            if (domainSB.toString().length() == 0) {
+                throw new AddressException("No domain found at position " +
+                        (pos + 1) + " in '" + address + "'", address, pos + 1);
+            }
+        } catch (IndexOutOfBoundsException ioobe) {
+            throw new AddressException("Out of data at position " +
+                    (pos + 1) + " in '" + address + "'", address, pos + 1);
+        }
+
+        localPart = localPartSB.toString();
+        domain = domainSB.toString();
+    }
+
+    private int parseUnquotedLocalPartOrThrowException(StringBuffer localPartSB, String address, int pos)
+            throws AddressException {
+        pos = parseUnquotedLocalPart(localPartSB, address, pos);
+        if (localPartSB.toString().length() == 0) {
+            throw new AddressException("No local-part (user account) found at position " +
+                    (pos + 1) + " in '" + address + "'", address, pos + 1);
+        }
+        return pos;
+    }
+
+    private int parseQuotedLocalPartOrThrowException(StringBuffer localPartSB, String address, int pos)
+            throws AddressException {
+        pos = parseQuotedLocalPart(localPartSB, address, pos);
+        if (localPartSB.toString().length() == 2) {
+            throw new AddressException("No quoted local-part (user account) found at position " +
+                    (pos + 2) + " in '" + address + "'", address, pos + 2);
+        }
+        return pos;
+    }
+
+    /**
+     * Constructs a MailAddress with the provided local part and domain.
+     *
+     * @param localPart the local-part portion. This is a domain dependent string.
+     *                  In addresses, it is simply interpreted on the particular host as a
+     *                  name of a particular mailbox. per RFC2822 3.4.1. addr-spec specification
+     * @param domain    the domain portion. This identifies the point to which the mail
+     *                  is delivered  per RFC2822 3.4.1. addr-spec specification
+     * @throws AddressException if the parse failed
+     */
+    public MailAddress(String localPart, String domain) throws AddressException {
+        this(new InternetAddress(localPart + "@" + domain));
+    }
+
+    /**
+     * Constructs a MailAddress from an InternetAddress, using only the
+     * email address portion (an "addr-spec", not "name-addr", as
+     * defined in the RFC2822 3.4. Address Specification)
+     *
+     * @param address the address
+     * @throws AddressException if the parse failed
+     */
+    public MailAddress(InternetAddress address) throws AddressException {
+        this(address.getAddress());
+    }
+
+    /**
+     * Returns the host part.
+     *
+     * @return the host part of this email address. If the host is of the
+     *         dotNum form (e.g. [yyy.yyy.yyy.yyy]), then strip the braces first.
+     * @deprecated use {@link #getDomain()}, whose name was changed to
+     *             align with RFC2822 3.4.1. addr-spec specification
+     */
+    @Deprecated
+    public String getHost() {
+        return getDomain();
+    }
+
+    /**
+     * Returns the domain part per RFC2822 3.4.1. addr-spec specification.
+     *
+     * @return the domain part of this email address. If the domain is of
+     *         the domain-literal form  (e.g. [yyy.yyy.yyy.yyy]), the braces will
+     *         have been stripped returning the raw IP address.
+     * @since Mailet API 2.4
+     */
+    public String getDomain() {
+        if (!(domain.startsWith("[") && domain.endsWith("]"))) {
+            return domain;
+        }
+        return domain.substring(1, domain.length() - 1);
+    }
+
+    /**
+     * Returns the user part.
+     *
+     * @return the user part of this email address
+     * @deprecated use {@link #getLocalPart()}, whose name was changed to
+     *             align with the RFC2822 3.4.1. addr-spec specification
+     */
+    @Deprecated
+    public String getUser() {
+        return getLocalPart();
+    }
+
+    /**
+     * Returns the local-part per RFC2822 3.4.1. addr-spec specification.
+     *
+     * @return the local-part of this email address as defined by the
+     *         RFC2822 3.4.1. addr-spec specification.
+     *         The local-part portion is a domain dependent string.
+     *         In addresses, it is simply interpreted on the particular
+     *         host as a name of a particular mailbox
+     *         (the part before the "@" character)
+     * @since Mailet API 2.4
+     */
+    public String getLocalPart() {
+        return localPart;
+    }
+
+    public String asString() {
+        return localPart + "@" + domain;
+    }
+
+    @Override
+    public String toString() {
+        return localPart + "@" + domain;
+    }
+    
+    public String asPrettyString() {
+        return '<' + asString() + '>';
+    }
+
+    /**
+     * Returns an InternetAddress representing the same address
+     * as this MailAddress.
+     *
+     * @return the address
+     */
+    public InternetAddress toInternetAddress() {
+        try {
+            return new InternetAddress(toString());
+        } catch (javax.mail.internet.AddressException ae) {
+            //impossible really
+            return null;
+        }
+    }
+
+    /**
+     * Indicates whether some other object is "equal to" this one.
+     * <p/>
+     * Note that this implementation breaks the general contract of the
+     * <code>equals</code> method by allowing an instance to equal to a
+     * <code>String</code>. It is recommended that implementations avoid
+     * relying on this design which may be removed in a future release.
+     *
+     * @returns true if the given object is equal to this one, false otherwise
+     */
+    @Override
+    public boolean equals(Object obj) {
+        if (obj == null) {
+            return false;
+        } else if (obj instanceof String) {
+            String theString = (String) obj;
+            return toString().equalsIgnoreCase(theString);
+        } else if (obj instanceof MailAddress) {
+            MailAddress addr = (MailAddress) obj;
+            return getLocalPart().equalsIgnoreCase(addr.getLocalPart()) && getDomain().equalsIgnoreCase(addr.getDomain());
+        }
+        return false;
+    }
+
+    /**
+     * Returns a hash code value for this object.
+     * <p/>
+     * This method is implemented by returning the hash code of the canonical
+     * string representation of this address, so that all instances representing
+     * the same address will return an identical hash code.
+     *
+     * @return the hashcode.
+     */
+    @Override
+    public int hashCode() {
+        return toString().toLowerCase(Locale.US).hashCode();
+    }
+
+    private int parseQuotedLocalPart(StringBuffer lpSB, String address, int pos) throws AddressException {
+        StringBuilder resultSB = new StringBuilder();
+        resultSB.append('\"');
+        pos++;
+        //<quoted-string> ::=  """ <qtext> """
+        //<qtext> ::=  "\" <x> | "\" <x> <qtext> | <q> | <q> <qtext>
+        while (true) {
+            if (address.charAt(pos) == '\"') {
+                resultSB.append('\"');
+                //end of quoted string... move forward
+                pos++;
+                break;
+            }
+            if (address.charAt(pos) == '\\') {
+                resultSB.append('\\');
+                pos++;
+                //<x> ::= any one of the 128 ASCII characters (no exceptions)
+                char x = address.charAt(pos);
+                if (x < 0 || x > 127) {
+                    throw new AddressException("Invalid \\ syntaxed character at position " +
+                            (pos + 1) + " in '" + address + "'", address, pos + 1);
+                }
+                resultSB.append(x);
+                pos++;
+            } else {
+                //<q> ::= any one of the 128 ASCII characters except <CR>,
+                //<LF>, quote ("), or backslash (\)
+                char q = address.charAt(pos);
+                if (q <= 0 || q == '\n' || q == '\r' || q == '\"' || q == '\\') {
+                    throw new AddressException("Unquoted local-part (user account) must be one of the 128 ASCI " +
+                            "characters exception <CR>, <LF>, quote (\"), or backslash (\\) at position " +
+                            (pos + 1) + " in '" + address + "'");
+                }
+                resultSB.append(q);
+                pos++;
+            }
+        }
+        lpSB.append(resultSB);
+        return pos;
+    }
+
+    private int parseUnquotedLocalPart(StringBuffer lpSB, String address, int pos) throws AddressException {
+        StringBuilder resultSB = new StringBuilder();
+        //<dot-string> ::= <string> | <string> "." <dot-string>
+        boolean lastCharDot = false;
+        while (true) {
+            //<string> ::= <char> | <char> <string>
+            //<char> ::= <c> | "\" <x>
+            if (address.charAt(pos) == '\\') {
+                resultSB.append('\\');
+                pos++;
+                //<x> ::= any one of the 128 ASCII characters (no exceptions)
+                char x = address.charAt(pos);
+                if (x < 0 || x > 127) {
+                    throw new AddressException("Invalid \\ syntaxed character at position " + (pos + 1) +
+                            " in '" + address + "'", address, pos + 1);
+                }
+                resultSB.append(x);
+                pos++;
+                lastCharDot = false;
+            } else if (address.charAt(pos) == '.') {
+                if (pos == 0) {
+                    throw new AddressException("Local part must not start with a '.'");
+                }
+                resultSB.append('.');
+                pos++;
+                lastCharDot = true;
+            } else if (address.charAt(pos) == '@') {
+                //End of local-part
+                break;
+            } else {
+                //<c> ::= any one of the 128 ASCII characters, but not any
+                //    <special> or <SP>
+                //<special> ::= "<" | ">" | "(" | ")" | "[" | "]" | "\" | "."
+                //    | "," | ";" | ":" | "@"  """ | the control
+                //    characters (ASCII codes 0 through 31 inclusive and
+                //    127)
+                //<SP> ::= the space character (ASCII code 32)
+                char c = address.charAt(pos);
+                if (c <= 31 || c >= 127 || c == ' ') {
+                    throw new AddressException("Invalid character in local-part (user account) at position " +
+                            (pos + 1) + " in '" + address + "'", address, pos + 1);
+                }
+                int i = 0;
+                while (i < SPECIAL.length) {
+                    if (c == SPECIAL[i]) {
+                        throw new AddressException("Invalid character in local-part (user account) at position " +
+                                (pos + 1) + " in '" + address + "'", address, pos + 1);
+                    }
+                    i++;
+                }
+                resultSB.append(c);
+                pos++;
+                lastCharDot = false;
+            }
+        }
+        if (lastCharDot) {
+            throw new AddressException("local-part (user account) ended with a \".\", which is invalid in address '" +
+                    address + "'", address, pos);
+        }
+        lpSB.append(resultSB);
+        return pos;
+    }
+
+    private int parseNumber(StringBuffer dSB, String address, int pos) throws AddressException {
+        //<number> ::= <d> | <d> <number>
+
+        StringBuilder resultSB = new StringBuilder();
+        // we were passed the string with pos pointing the the # char.
+        // take the first char (#), put it in the result buffer and increment pos
+        resultSB.append(address.charAt(pos));
+        pos++;
+        //We keep the position from the class level pos field
+        while (true) {
+            if (pos >= address.length()) {
+                break;
+            }
+            //<d> ::= any one of the ten digits 0 through 9
+            char d = address.charAt(pos);
+            if (d == '.') {
+                break;
+            }
+            if (d < '0' || d > '9') {
+                throw new AddressException("In domain, did not find a number in # address at position " +
+                        (pos + 1) + " in '" + address + "'", address, pos + 1);
+            }
+            resultSB.append(d);
+            pos++;
+        }
+        if (resultSB.length() < 2) {
+            throw new AddressException("In domain, did not find a number in # address at position " +
+                    (pos + 1) + " in '" + address + "'", address, pos + 1);
+        }
+        dSB.append(resultSB);
+        return pos;
+    }
+
+    private int parseDomainLiteral(StringBuffer dSB, String address, int pos) throws AddressException {
+        StringBuilder resultSB = new StringBuilder();
+        //we were passed the string with pos pointing the the [ char.
+        // take the first char ([), put it in the result buffer and increment pos
+        resultSB.append(address.charAt(pos));
+        pos++;
+
+        //<dotnum> ::= <snum> "." <snum> "." <snum> "." <snum>
+        for (int octet = 0; octet < 4; octet++) {
+            //<snum> ::= one, two, or three digits representing a decimal
+            //                      integer value in the range 0 through 255
+            //<d> ::= any one of the ten digits 0 through 9
+            StringBuilder snumSB = new StringBuilder();
+            for (int digits = 0; digits < 3; digits++) {
+                char currentChar = address.charAt(pos);
+                if (currentChar == '.' || currentChar == ']') {
+                    break;
+                } else if (currentChar < '0' || currentChar > '9') {
+                    throw new AddressException("Invalid number at position " +
+                            (pos + 1) + " in '" + address + "'", address, pos + 1);
+                }
+                snumSB.append(currentChar);
+                pos++;
+            }
+            if (snumSB.toString().length() == 0) {
+                throw new AddressException("Number not found at position " +
+                        (pos + 1) + " in '" + address + "'", address, pos + 1);
+            }
+            try {
+                int snum = Integer.parseInt(snumSB.toString());
+                if (snum > 255) {
+                    throw new AddressException("Invalid number at position " +
+                            (pos + 1) + " in '" + address + "'", address, pos + 1);
+                }
+            } catch (NumberFormatException nfe) {
+                throw new AddressException("Invalid number at position " +
+                        (pos + 1) + " in '" + address + "'", address, pos + 1);
+            }
+            resultSB.append(snumSB.toString());
+            if (address.charAt(pos) == ']') {
+                if (octet < 3) {
+                    throw new AddressException("End of number reached too quickly at " +
+                            (pos + 1) + " in '" + address + "'", address, pos + 1);
+                }
+                break;
+            }
+            if (address.charAt(pos) == '.') {
+                resultSB.append('.');
+                pos++;
+            }
+        }
+        if (address.charAt(pos) != ']') {
+            throw new AddressException("Did not find closing bracket \"]\" in domain at position " +
+                    (pos + 1) + " in '" + address + "'", address, pos + 1);
+        }
+        resultSB.append(']');
+        pos++;
+        dSB.append(resultSB);
+        return pos;
+    }
+
+    private int parseDomain(StringBuffer dSB, String address, int pos) throws AddressException {
+        StringBuilder resultSB = new StringBuilder();
+        //<name> ::= <a> <ldh-str> <let-dig>
+        //<ldh-str> ::= <let-dig-hyp> | <let-dig-hyp> <ldh-str>
+        //<let-dig> ::= <a> | <d>
+        //<let-dig-hyp> ::= <a> | <d> | "-"
+        //<a> ::= any one of the 52 alphabetic characters A through Z
+        //  in upper case and a through z in lower case
+        //<d> ::= any one of the ten digits 0 through 9
+
+        // basically, this is a series of letters, digits, and hyphens,
+        // but it can't start with a digit or hypthen
+        // and can't end with a hyphen
+
+        // in practice though, we should relax this as domain names can start
+        // with digits as well as letters.  So only check that doesn't start
+        // or end with hyphen.
+        while (true) {
+            if (pos >= address.length()) {
+                break;
+            }
+            char ch = address.charAt(pos);
+            if ((ch >= '0' && ch <= '9') ||
+                    (ch >= 'a' && ch <= 'z') ||
+                    (ch >= 'A' && ch <= 'Z') ||
+                    (ch == '-')) {
+                resultSB.append(ch);
+                pos++;
+                continue;
+            }
+            if (ch == '.') {
+                break;
+            }
+            throw new AddressException("Invalid character at " + pos + " in '" + address + "'", address, pos);
+        }
+        String result = resultSB.toString();
+        if (result.startsWith("-") || result.endsWith("-")) {
+            throw new AddressException("Domain name cannot begin or end with a hyphen \"-\" at position " +
+                    (pos + 1) + " in '" + address + "'", address, pos + 1);
+        }
+        dSB.append(result);
+        return pos;
+    }
+
+    /**
+     * Return <code>true</code> if the {@link MailAddress} should represent a null sender (<>)
+     *
+     * @return nullsender
+     */
+    public boolean isNullSender() {
+        return false;
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/core/src/test/java/org/apache/james/core/MailAddressTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/james/core/MailAddressTest.java b/core/src/test/java/org/apache/james/core/MailAddressTest.java
new file mode 100644
index 0000000..e4438ef
--- /dev/null
+++ b/core/src/test/java/org/apache/james/core/MailAddressTest.java
@@ -0,0 +1,229 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.core;
+
+import javax.mail.internet.AddressException;
+import javax.mail.internet.InternetAddress;
+
+import org.apache.james.core.MailAddress;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class MailAddressTest {
+
+    private static final String
+            GOOD_LOCAL_PART = "\"quoted@local part\"",
+            GOOD_QUOTED_LOCAL_PART = "\"quoted@local part\"@james.apache.org",
+            GOOD_ADDRESS = "server-dev@james.apache.org",
+            GOOD_DOMAIN = "james.apache.org";
+
+    private static final String[] GOOD_ADDRESSES = {
+            GOOD_ADDRESS,
+            GOOD_QUOTED_LOCAL_PART,
+            "server-dev@james-apache.org",
+            "server-dev@[127.0.0.1]",
+            "server-dev@#123",
+            "server-dev@#123.apache.org",
+            "server.dev@james.apache.org",
+            "\\.server-dev@james.apache.org",
+            "server-dev\\.@james.apache.org",
+    };
+
+    private static final String[] BAD_ADDRESSES = {
+            "",
+            "server-dev",
+            "server-dev@",
+            "[]",
+            "server-dev@[]",
+            "server-dev@#",
+            "quoted local-part@james.apache.org",
+            "quoted@local-part@james.apache.org",
+            "local-part.@james.apache.org",
+            ".local-part@james.apache.org",
+            "local-part@.james.apache.org",
+            "local-part@james.apache.org.",
+            "local-part@james.apache..org",
+            "server-dev@-james.apache.org",
+            "server-dev@james.apache.org-",
+            "server-dev@#james.apache.org",
+            "server-dev@#123james.apache.org",
+            "server-dev@#-123.james.apache.org",
+            "server-dev@james. apache.org",
+            "server-dev@james\\.apache.org",
+            "server-dev@[300.0.0.1]",
+            "server-dev@[127.0.1]",
+            "server-dev@[0127.0.0.1]",
+            "server-dev@[127.0.1.1a]",
+            "server-dev@[127\\.0.1.1]",
+            "server-dev@[127.0.1.1.1]",
+            "server-dev@[127.0.1.-1]"
+    };
+
+    /**
+     * Test method for {@link MailAddress#hashCode()}.
+     *
+     * @throws AddressException
+     */
+    @Test
+    public void testHashCode() throws AddressException {
+
+        MailAddress a = new MailAddress(GOOD_ADDRESS);
+        MailAddress b = new MailAddress(GOOD_ADDRESS);
+        Assert.assertTrue(a.hashCode() + " != " + b.hashCode(), a.hashCode() == b.hashCode());
+    }
+
+    /**
+     * Test method for {@link MailAddress#MailAddress(java.lang.String)}.
+     *
+     * @throws AddressException
+     */
+    @Test
+    public void testMailAddressString() throws AddressException {
+
+        MailAddress a = new MailAddress(GOOD_ADDRESS);
+        Assert.assertTrue(GOOD_ADDRESS.equals(a.toString()));
+
+        for (String goodAddress : GOOD_ADDRESSES) {
+            try {
+                a = new MailAddress(goodAddress);
+            } catch (AddressException e) {
+                Assert.fail(e.getMessage());
+            }
+        }
+
+        for (String badAddress : BAD_ADDRESSES) {
+            try {
+                a = new MailAddress(badAddress);
+                Assert.fail(badAddress);
+            } catch (AddressException ignore) {
+            }
+        }
+    }
+
+    /**
+     * Test method for {@link MailAddress#MailAddress(java.lang.String, java.lang.String)}.
+     */
+    @Test
+    public void testMailAddressStringString() {
+
+        try {
+            new MailAddress("local-part", "domain");
+        } catch (AddressException e) {
+            Assert.assertTrue(e.getMessage(), false);
+        }
+        try {
+            MailAddress a = new MailAddress("local-part", "-domain");
+            Assert.assertFalse(a.toString(), true);
+        } catch (AddressException e) {
+            Assert.assertTrue(true);
+        }
+    }
+
+    /**
+     * Test method for {@link MailAddress#MailAddress(javax.mail.internet.InternetAddress)}.
+     */
+    @Test
+    public void testMailAddressInternetAddress() {
+
+        try {
+            new MailAddress(new InternetAddress(GOOD_QUOTED_LOCAL_PART));
+        } catch (AddressException e) {
+            System.out.println("AddressException" + e.getMessage());
+            Assert.assertTrue(e.getMessage(), false);
+        }
+    }
+
+    /**
+     * Test method for {@link MailAddress#getDomain()}.
+     */
+    @Test
+    public void testGetDomain() {
+
+        try {
+            MailAddress a = new MailAddress(new InternetAddress(GOOD_ADDRESS));
+            Assert.assertTrue(a.getDomain() + " != " + GOOD_DOMAIN, a.getDomain().equals(GOOD_DOMAIN));
+        } catch (AddressException e) {
+            System.out.println("AddressException" + e.getMessage());
+            Assert.assertTrue(e.getMessage(), false);
+        }
+    }
+
+    /**
+     * Test method for {@link MailAddress#getLocalPart()}.
+     */
+    @Test
+    public void testGetLocalPart() {
+
+        try {
+            MailAddress a = new MailAddress(new InternetAddress(GOOD_QUOTED_LOCAL_PART));
+            Assert.assertTrue(GOOD_LOCAL_PART + " != " + a.getLocalPart(), a.getLocalPart().equals(GOOD_LOCAL_PART));
+        } catch (AddressException e) {
+            System.out.println("AddressException" + e.getMessage());
+            Assert.assertTrue(e.getMessage(), false);
+        }
+    }
+
+    /**
+     * Test method for {@link MailAddress#toString()}.
+     */
+    @Test
+    public void testToString() {
+
+        try {
+            MailAddress a = new MailAddress(new InternetAddress(GOOD_ADDRESS));
+            Assert.assertTrue(a.toString() + " != " + GOOD_ADDRESS, a.toString().equals(GOOD_ADDRESS));
+        } catch (AddressException e) {
+            System.out.println("AddressException" + e.getMessage());
+            Assert.assertTrue(e.getMessage(), false);
+        }
+    }
+
+    /**
+     * Test method for {@link MailAddress#toInternetAddress()}.
+     */
+    @Test
+    public void testToInternetAddress() {
+
+        try {
+            InternetAddress b = new InternetAddress(GOOD_ADDRESS);
+            MailAddress a = new MailAddress(b);
+            Assert.assertTrue(a.toInternetAddress().equals(b));
+            Assert.assertTrue(a.toString() + " != " + GOOD_ADDRESS, a.toString().equals(GOOD_ADDRESS));
+        } catch (AddressException e) {
+            System.out.println("AddressException" + e.getMessage());
+            Assert.assertTrue(e.getMessage(), false);
+        }
+    }
+
+    /**
+     * Test method for {@link MailAddress#equals(java.lang.Object)}.
+     *
+     * @throws AddressException
+     */
+    @Test
+    public void testEqualsObject() throws AddressException {
+
+        MailAddress a = new MailAddress(GOOD_ADDRESS);
+        MailAddress b = new MailAddress(GOOD_ADDRESS);
+
+        Assert.assertTrue(a.toString() + " != " + b.toString(), a.equals(b));
+        Assert.assertFalse(a.toString() + " != " + null, a.equals(null));
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/ai/src/main/java/org/apache/james/ai/classic/BayesianAnalysis.java
----------------------------------------------------------------------
diff --git a/mailet/ai/src/main/java/org/apache/james/ai/classic/BayesianAnalysis.java b/mailet/ai/src/main/java/org/apache/james/ai/classic/BayesianAnalysis.java
index b96e5a2..5acc119 100644
--- a/mailet/ai/src/main/java/org/apache/james/ai/classic/BayesianAnalysis.java
+++ b/mailet/ai/src/main/java/org/apache/james/ai/classic/BayesianAnalysis.java
@@ -34,7 +34,7 @@ import javax.sql.DataSource;
 
 import org.apache.mailet.Experimental;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.GenericMailet;
 import org.apache.mailet.base.RFC2822Headers;
 import org.slf4j.Logger;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/api/pom.xml
----------------------------------------------------------------------
diff --git a/mailet/api/pom.xml b/mailet/api/pom.xml
index 53b4764..e12bd4c 100644
--- a/mailet/api/pom.xml
+++ b/mailet/api/pom.xml
@@ -37,6 +37,10 @@
 
     <dependencies>
         <dependency>
+            <groupId>${groupId}</groupId>
+            <artifactId>james-core</artifactId>
+        </dependency>
+        <dependency>
             <groupId>com.github.steveash.guavate</groupId>
             <artifactId>guavate</artifactId>
         </dependency>

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/api/src/main/java/org/apache/mailet/Mail.java
----------------------------------------------------------------------
diff --git a/mailet/api/src/main/java/org/apache/mailet/Mail.java b/mailet/api/src/main/java/org/apache/mailet/Mail.java
index 158359a..3339370 100644
--- a/mailet/api/src/main/java/org/apache/mailet/Mail.java
+++ b/mailet/api/src/main/java/org/apache/mailet/Mail.java
@@ -22,6 +22,7 @@ package org.apache.mailet;
 import javax.mail.MessagingException;
 import javax.mail.internet.MimeMessage;
 
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.PerRecipientHeaders.Header;
 
 import java.io.Serializable;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/api/src/main/java/org/apache/mailet/MailAddress.java
----------------------------------------------------------------------
diff --git a/mailet/api/src/main/java/org/apache/mailet/MailAddress.java b/mailet/api/src/main/java/org/apache/mailet/MailAddress.java
index fbca0a5..0043ac9 100644
--- a/mailet/api/src/main/java/org/apache/mailet/MailAddress.java
+++ b/mailet/api/src/main/java/org/apache/mailet/MailAddress.java
@@ -17,564 +17,24 @@
  * under the License.                                           *
  ****************************************************************/
 
-
 package org.apache.mailet;
 
 import javax.mail.internet.AddressException;
 import javax.mail.internet.InternetAddress;
-import java.util.Locale;
-
-/**
- * A representation of an email address.
- * <p/>
- * <p>This class encapsulates functionality to access different
- * parts of an email address without dealing with its parsing.</p>
- * <p/>
- * <p>A MailAddress is an address specified in the MAIL FROM and
- * RCPT TO commands in SMTP sessions.  These are either passed by
- * an external server to the mailet-compliant SMTP server, or they
- * are created programmatically by the mailet-compliant server to
- * send to another (external) SMTP server.  Mailets and matchers
- * use the MailAddress for the purpose of evaluating the sender
- * and recipient(s) of a message.</p>
- * <p/>
- * <p>MailAddress parses an email address as defined in RFC 821
- * (SMTP) p. 30 and 31 where addresses are defined in BNF convention.
- * As the mailet API does not support the aged "SMTP-relayed mail"
- * addressing protocol, this leaves all addresses to be a {@code <mailbox>},
- * as per the spec.
- * <p/>
- * <p>This class is a good way to validate email addresses as there are
- * some valid addresses which would fail with a simpler approach
- * to parsing address. It also removes the parsing burden from
- * mailets and matchers that might not realize the flexibility of an
- * SMTP address. For instance, "serge@home"@lokitech.com is a valid
- * SMTP address (the quoted text serge@home is the local-part and
- * lokitech.com is the domain). This means all current parsing to date
- * is incorrect as we just find the first '@' and use that to separate
- * local-part from domain.</p>
- * <p/>
- * <p>This parses an address as per the BNF specification for <mailbox>
- * from RFC 821 on page 30 and 31, section 4.1.2. COMMAND SYNTAX.
- * http://www.freesoft.org/CIE/RFC/821/15.htm</p>
- *
- * @version 1.0
- */
-public class MailAddress implements java.io.Serializable {
-    /**
-     * We hardcode the serialVersionUID
-     * This version (2779163542539434916L) retains compatibility back to
-     * Mailet version 1.2 (James 1.2) so that MailAddress will be
-     * deserializable and mail doesn't get lost after an upgrade.
-     */
-    public static final long serialVersionUID = 2779163542539434916L;
-
-    private final static char[] SPECIAL =
-            {'<', '>', '(', ')', '[', ']', '\\', '.', ',', ';', ':', '@', '\"'};
 
-    private String localPart = null;
-    private String domain = null;
+@Deprecated
+public class MailAddress extends org.apache.james.core.MailAddress {
 
-    /**
-     * Strips source routing. According to RFC-2821 it is a valid approach
-     * to handle mails containing RFC-821 source-route information.
-     *
-     * @param address the address to strip
-     * @param pos     current position
-     * @return new pos
-     */
-    private int stripSourceRoute(String address, int pos) {
-        if (pos < address.length()) {
-            if (address.charAt(pos) == '@') {
-                int i = address.indexOf(':');
-                if (i != -1) {
-                    pos = i + 1;
-                }
-            }
-        }
-        return pos;
-    }
-
-    /**
-     * Constructs a MailAddress by parsing the provided address.
-     *
-     * @param address the email address, compliant to the RFC2822 3.4.1. addr-spec specification
-     * @throws AddressException if the parse failed
-     */
     public MailAddress(String address) throws AddressException {
-        address = address.trim();
-        int pos = 0;
-
-        // Test if mail address has source routing information (RFC-821) and get rid of it!!
-        //must be called first!! (or at least prior to updating pos)
-        stripSourceRoute(address, pos);
-
-        StringBuffer localPartSB = new StringBuffer();
-        StringBuffer domainSB = new StringBuffer();
-        //Begin parsing
-        //<mailbox> ::= <local-part> "@" <domain>
-
-        try {
-            //parse local-part
-            //<local-part> ::= <dot-string> | <quoted-string>
-            if (address.charAt(pos) == '\"') {
-                pos = parseQuotedLocalPartOrThrowException(localPartSB, address, pos);
-            } else {
-                pos = parseUnquotedLocalPartOrThrowException(localPartSB, address, pos);
-            }
-
-            //find @
-            if (pos >= address.length() || address.charAt(pos) != '@') {
-                throw new AddressException("Did not find @ between local-part and domain at position " +
-                        (pos + 1) + " in '" + address + "'", address, pos + 1);
-            }
-            pos++;
-
-            //parse domain
-            //<domain> ::=  <element> | <element> "." <domain>
-            //<element> ::= <name> | "#" <number> | "[" <dotnum> "]"
-            while (true) {
-                if (address.charAt(pos) == '#') {
-                    pos = parseNumber(domainSB, address, pos);
-                } else if (address.charAt(pos) == '[') {
-                    pos = parseDomainLiteral(domainSB, address, pos);
-                } else {
-                    pos = parseDomain(domainSB, address, pos);
-                }
-                if (pos >= address.length()) {
-                    break;
-                }
-                if (address.charAt(pos) == '.') {
-                    char lastChar = address.charAt(pos - 1);
-                    if (lastChar == '@' || lastChar == '.') {
-                        throw new AddressException("Subdomain expected before '.' or duplicate '.' in " + address);
-                    }
-                    domainSB.append('.');
-                    pos++;
-                    continue;
-                }
-                break;
-            }
-
-            if (domainSB.toString().length() == 0) {
-                throw new AddressException("No domain found at position " +
-                        (pos + 1) + " in '" + address + "'", address, pos + 1);
-            }
-        } catch (IndexOutOfBoundsException ioobe) {
-            throw new AddressException("Out of data at position " +
-                    (pos + 1) + " in '" + address + "'", address, pos + 1);
-        }
-
-        localPart = localPartSB.toString();
-        domain = domainSB.toString();
+        super(address);
     }
 
-    private int parseUnquotedLocalPartOrThrowException(StringBuffer localPartSB, String address, int pos)
-            throws AddressException {
-        pos = parseUnquotedLocalPart(localPartSB, address, pos);
-        if (localPartSB.toString().length() == 0) {
-            throw new AddressException("No local-part (user account) found at position " +
-                    (pos + 1) + " in '" + address + "'", address, pos + 1);
-        }
-        return pos;
-    }
-
-    private int parseQuotedLocalPartOrThrowException(StringBuffer localPartSB, String address, int pos)
-            throws AddressException {
-        pos = parseQuotedLocalPart(localPartSB, address, pos);
-        if (localPartSB.toString().length() == 2) {
-            throw new AddressException("No quoted local-part (user account) found at position " +
-                    (pos + 2) + " in '" + address + "'", address, pos + 2);
-        }
-        return pos;
-    }
-
-    /**
-     * Constructs a MailAddress with the provided local part and domain.
-     *
-     * @param localPart the local-part portion. This is a domain dependent string.
-     *                  In addresses, it is simply interpreted on the particular host as a
-     *                  name of a particular mailbox. per RFC2822 3.4.1. addr-spec specification
-     * @param domain    the domain portion. This identifies the point to which the mail
-     *                  is delivered  per RFC2822 3.4.1. addr-spec specification
-     * @throws AddressException if the parse failed
-     */
     public MailAddress(String localPart, String domain) throws AddressException {
-        this(new InternetAddress(localPart + "@" + domain));
+        super(localPart, domain);
     }
 
-    /**
-     * Constructs a MailAddress from an InternetAddress, using only the
-     * email address portion (an "addr-spec", not "name-addr", as
-     * defined in the RFC2822 3.4. Address Specification)
-     *
-     * @param address the address
-     * @throws AddressException if the parse failed
-     */
     public MailAddress(InternetAddress address) throws AddressException {
-        this(address.getAddress());
-    }
-
-    /**
-     * Returns the host part.
-     *
-     * @return the host part of this email address. If the host is of the
-     *         dotNum form (e.g. [yyy.yyy.yyy.yyy]), then strip the braces first.
-     * @deprecated use {@link #getDomain()}, whose name was changed to
-     *             align with RFC2822 3.4.1. addr-spec specification
-     */
-    @Deprecated
-    public String getHost() {
-        return getDomain();
-    }
-
-    /**
-     * Returns the domain part per RFC2822 3.4.1. addr-spec specification.
-     *
-     * @return the domain part of this email address. If the domain is of
-     *         the domain-literal form  (e.g. [yyy.yyy.yyy.yyy]), the braces will
-     *         have been stripped returning the raw IP address.
-     * @since Mailet API 2.4
-     */
-    public String getDomain() {
-        if (!(domain.startsWith("[") && domain.endsWith("]"))) {
-            return domain;
-        }
-        return domain.substring(1, domain.length() - 1);
-    }
-
-    /**
-     * Returns the user part.
-     *
-     * @return the user part of this email address
-     * @deprecated use {@link #getLocalPart()}, whose name was changed to
-     *             align with the RFC2822 3.4.1. addr-spec specification
-     */
-    @Deprecated
-    public String getUser() {
-        return getLocalPart();
-    }
-
-    /**
-     * Returns the local-part per RFC2822 3.4.1. addr-spec specification.
-     *
-     * @return the local-part of this email address as defined by the
-     *         RFC2822 3.4.1. addr-spec specification.
-     *         The local-part portion is a domain dependent string.
-     *         In addresses, it is simply interpreted on the particular
-     *         host as a name of a particular mailbox
-     *         (the part before the "@" character)
-     * @since Mailet API 2.4
-     */
-    public String getLocalPart() {
-        return localPart;
+        super(address);
     }
 
-    public String asString() {
-        return localPart + "@" + domain;
-    }
-
-    @Override
-    public String toString() {
-        return localPart + "@" + domain;
-    }
-    
-    public String asPrettyString() {
-        return '<' + asString() + '>';
-    }
-
-    /**
-     * Returns an InternetAddress representing the same address
-     * as this MailAddress.
-     *
-     * @return the address
-     */
-    public InternetAddress toInternetAddress() {
-        try {
-            return new InternetAddress(toString());
-        } catch (javax.mail.internet.AddressException ae) {
-            //impossible really
-            return null;
-        }
-    }
-
-    /**
-     * Indicates whether some other object is "equal to" this one.
-     * <p/>
-     * Note that this implementation breaks the general contract of the
-     * <code>equals</code> method by allowing an instance to equal to a
-     * <code>String</code>. It is recommended that implementations avoid
-     * relying on this design which may be removed in a future release.
-     *
-     * @returns true if the given object is equal to this one, false otherwise
-     */
-    @Override
-    public boolean equals(Object obj) {
-        if (obj == null) {
-            return false;
-        } else if (obj instanceof String) {
-            String theString = (String) obj;
-            return toString().equalsIgnoreCase(theString);
-        } else if (obj instanceof MailAddress) {
-            MailAddress addr = (MailAddress) obj;
-            return getLocalPart().equalsIgnoreCase(addr.getLocalPart()) && getDomain().equalsIgnoreCase(addr.getDomain());
-        }
-        return false;
-    }
-
-    /**
-     * Returns a hash code value for this object.
-     * <p/>
-     * This method is implemented by returning the hash code of the canonical
-     * string representation of this address, so that all instances representing
-     * the same address will return an identical hash code.
-     *
-     * @return the hashcode.
-     */
-    @Override
-    public int hashCode() {
-        return toString().toLowerCase(Locale.US).hashCode();
-    }
-
-    private int parseQuotedLocalPart(StringBuffer lpSB, String address, int pos) throws AddressException {
-        StringBuilder resultSB = new StringBuilder();
-        resultSB.append('\"');
-        pos++;
-        //<quoted-string> ::=  """ <qtext> """
-        //<qtext> ::=  "\" <x> | "\" <x> <qtext> | <q> | <q> <qtext>
-        while (true) {
-            if (address.charAt(pos) == '\"') {
-                resultSB.append('\"');
-                //end of quoted string... move forward
-                pos++;
-                break;
-            }
-            if (address.charAt(pos) == '\\') {
-                resultSB.append('\\');
-                pos++;
-                //<x> ::= any one of the 128 ASCII characters (no exceptions)
-                char x = address.charAt(pos);
-                if (x < 0 || x > 127) {
-                    throw new AddressException("Invalid \\ syntaxed character at position " +
-                            (pos + 1) + " in '" + address + "'", address, pos + 1);
-                }
-                resultSB.append(x);
-                pos++;
-            } else {
-                //<q> ::= any one of the 128 ASCII characters except <CR>,
-                //<LF>, quote ("), or backslash (\)
-                char q = address.charAt(pos);
-                if (q <= 0 || q == '\n' || q == '\r' || q == '\"' || q == '\\') {
-                    throw new AddressException("Unquoted local-part (user account) must be one of the 128 ASCI " +
-                            "characters exception <CR>, <LF>, quote (\"), or backslash (\\) at position " +
-                            (pos + 1) + " in '" + address + "'");
-                }
-                resultSB.append(q);
-                pos++;
-            }
-        }
-        lpSB.append(resultSB);
-        return pos;
-    }
-
-    private int parseUnquotedLocalPart(StringBuffer lpSB, String address, int pos) throws AddressException {
-        StringBuilder resultSB = new StringBuilder();
-        //<dot-string> ::= <string> | <string> "." <dot-string>
-        boolean lastCharDot = false;
-        while (true) {
-            //<string> ::= <char> | <char> <string>
-            //<char> ::= <c> | "\" <x>
-            if (address.charAt(pos) == '\\') {
-                resultSB.append('\\');
-                pos++;
-                //<x> ::= any one of the 128 ASCII characters (no exceptions)
-                char x = address.charAt(pos);
-                if (x < 0 || x > 127) {
-                    throw new AddressException("Invalid \\ syntaxed character at position " + (pos + 1) +
-                            " in '" + address + "'", address, pos + 1);
-                }
-                resultSB.append(x);
-                pos++;
-                lastCharDot = false;
-            } else if (address.charAt(pos) == '.') {
-                if (pos == 0) {
-                    throw new AddressException("Local part must not start with a '.'");
-                }
-                resultSB.append('.');
-                pos++;
-                lastCharDot = true;
-            } else if (address.charAt(pos) == '@') {
-                //End of local-part
-                break;
-            } else {
-                //<c> ::= any one of the 128 ASCII characters, but not any
-                //    <special> or <SP>
-                //<special> ::= "<" | ">" | "(" | ")" | "[" | "]" | "\" | "."
-                //    | "," | ";" | ":" | "@"  """ | the control
-                //    characters (ASCII codes 0 through 31 inclusive and
-                //    127)
-                //<SP> ::= the space character (ASCII code 32)
-                char c = address.charAt(pos);
-                if (c <= 31 || c >= 127 || c == ' ') {
-                    throw new AddressException("Invalid character in local-part (user account) at position " +
-                            (pos + 1) + " in '" + address + "'", address, pos + 1);
-                }
-                int i = 0;
-                while (i < SPECIAL.length) {
-                    if (c == SPECIAL[i]) {
-                        throw new AddressException("Invalid character in local-part (user account) at position " +
-                                (pos + 1) + " in '" + address + "'", address, pos + 1);
-                    }
-                    i++;
-                }
-                resultSB.append(c);
-                pos++;
-                lastCharDot = false;
-            }
-        }
-        if (lastCharDot) {
-            throw new AddressException("local-part (user account) ended with a \".\", which is invalid in address '" +
-                    address + "'", address, pos);
-        }
-        lpSB.append(resultSB);
-        return pos;
-    }
-
-    private int parseNumber(StringBuffer dSB, String address, int pos) throws AddressException {
-        //<number> ::= <d> | <d> <number>
-
-        StringBuilder resultSB = new StringBuilder();
-        // we were passed the string with pos pointing the the # char.
-        // take the first char (#), put it in the result buffer and increment pos
-        resultSB.append(address.charAt(pos));
-        pos++;
-        //We keep the position from the class level pos field
-        while (true) {
-            if (pos >= address.length()) {
-                break;
-            }
-            //<d> ::= any one of the ten digits 0 through 9
-            char d = address.charAt(pos);
-            if (d == '.') {
-                break;
-            }
-            if (d < '0' || d > '9') {
-                throw new AddressException("In domain, did not find a number in # address at position " +
-                        (pos + 1) + " in '" + address + "'", address, pos + 1);
-            }
-            resultSB.append(d);
-            pos++;
-        }
-        if (resultSB.length() < 2) {
-            throw new AddressException("In domain, did not find a number in # address at position " +
-                    (pos + 1) + " in '" + address + "'", address, pos + 1);
-        }
-        dSB.append(resultSB);
-        return pos;
-    }
-
-    private int parseDomainLiteral(StringBuffer dSB, String address, int pos) throws AddressException {
-        StringBuilder resultSB = new StringBuilder();
-        //we were passed the string with pos pointing the the [ char.
-        // take the first char ([), put it in the result buffer and increment pos
-        resultSB.append(address.charAt(pos));
-        pos++;
-
-        //<dotnum> ::= <snum> "." <snum> "." <snum> "." <snum>
-        for (int octet = 0; octet < 4; octet++) {
-            //<snum> ::= one, two, or three digits representing a decimal
-            //                      integer value in the range 0 through 255
-            //<d> ::= any one of the ten digits 0 through 9
-            StringBuilder snumSB = new StringBuilder();
-            for (int digits = 0; digits < 3; digits++) {
-                char currentChar = address.charAt(pos);
-                if (currentChar == '.' || currentChar == ']') {
-                    break;
-                } else if (currentChar < '0' || currentChar > '9') {
-                    throw new AddressException("Invalid number at position " +
-                            (pos + 1) + " in '" + address + "'", address, pos + 1);
-                }
-                snumSB.append(currentChar);
-                pos++;
-            }
-            if (snumSB.toString().length() == 0) {
-                throw new AddressException("Number not found at position " +
-                        (pos + 1) + " in '" + address + "'", address, pos + 1);
-            }
-            try {
-                int snum = Integer.parseInt(snumSB.toString());
-                if (snum > 255) {
-                    throw new AddressException("Invalid number at position " +
-                            (pos + 1) + " in '" + address + "'", address, pos + 1);
-                }
-            } catch (NumberFormatException nfe) {
-                throw new AddressException("Invalid number at position " +
-                        (pos + 1) + " in '" + address + "'", address, pos + 1);
-            }
-            resultSB.append(snumSB.toString());
-            if (address.charAt(pos) == ']') {
-                if (octet < 3) {
-                    throw new AddressException("End of number reached too quickly at " +
-                            (pos + 1) + " in '" + address + "'", address, pos + 1);
-                }
-                break;
-            }
-            if (address.charAt(pos) == '.') {
-                resultSB.append('.');
-                pos++;
-            }
-        }
-        if (address.charAt(pos) != ']') {
-            throw new AddressException("Did not find closing bracket \"]\" in domain at position " +
-                    (pos + 1) + " in '" + address + "'", address, pos + 1);
-        }
-        resultSB.append(']');
-        pos++;
-        dSB.append(resultSB);
-        return pos;
-    }
-
-    private int parseDomain(StringBuffer dSB, String address, int pos) throws AddressException {
-        StringBuilder resultSB = new StringBuilder();
-        //<name> ::= <a> <ldh-str> <let-dig>
-        //<ldh-str> ::= <let-dig-hyp> | <let-dig-hyp> <ldh-str>
-        //<let-dig> ::= <a> | <d>
-        //<let-dig-hyp> ::= <a> | <d> | "-"
-        //<a> ::= any one of the 52 alphabetic characters A through Z
-        //  in upper case and a through z in lower case
-        //<d> ::= any one of the ten digits 0 through 9
-
-        // basically, this is a series of letters, digits, and hyphens,
-        // but it can't start with a digit or hypthen
-        // and can't end with a hyphen
-
-        // in practice though, we should relax this as domain names can start
-        // with digits as well as letters.  So only check that doesn't start
-        // or end with hyphen.
-        while (true) {
-            if (pos >= address.length()) {
-                break;
-            }
-            char ch = address.charAt(pos);
-            if ((ch >= '0' && ch <= '9') ||
-                    (ch >= 'a' && ch <= 'z') ||
-                    (ch >= 'A' && ch <= 'Z') ||
-                    (ch == '-')) {
-                resultSB.append(ch);
-                pos++;
-                continue;
-            }
-            if (ch == '.') {
-                break;
-            }
-            throw new AddressException("Invalid character at " + pos + " in '" + address + "'", address, pos);
-        }
-        String result = resultSB.toString();
-        if (result.startsWith("-") || result.endsWith("-")) {
-            throw new AddressException("Domain name cannot begin or end with a hyphen \"-\" at position " +
-                    (pos + 1) + " in '" + address + "'", address, pos + 1);
-        }
-        dSB.append(result);
-        return pos;
-    }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/api/src/main/java/org/apache/mailet/MailetContext.java
----------------------------------------------------------------------
diff --git a/mailet/api/src/main/java/org/apache/mailet/MailetContext.java b/mailet/api/src/main/java/org/apache/mailet/MailetContext.java
index 2b2dd96..202caf7 100644
--- a/mailet/api/src/main/java/org/apache/mailet/MailetContext.java
+++ b/mailet/api/src/main/java/org/apache/mailet/MailetContext.java
@@ -27,6 +27,7 @@ import java.util.List;
 import javax.mail.MessagingException;
 import javax.mail.internet.MimeMessage;
 
+import org.apache.james.core.MailAddress;
 import org.slf4j.Logger;
 
 /**

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/api/src/main/java/org/apache/mailet/Matcher.java
----------------------------------------------------------------------
diff --git a/mailet/api/src/main/java/org/apache/mailet/Matcher.java b/mailet/api/src/main/java/org/apache/mailet/Matcher.java
index a444a84..3d71072 100644
--- a/mailet/api/src/main/java/org/apache/mailet/Matcher.java
+++ b/mailet/api/src/main/java/org/apache/mailet/Matcher.java
@@ -23,6 +23,8 @@ package org.apache.mailet;
 import java.util.Collection;
 import javax.mail.MessagingException;
 
+import org.apache.james.core.MailAddress;
+
 /**
  * This interface defines the behaviour of the message "routing" inside
  * the mailet container. At its heart is the {@link #match(Mail)} method,

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/mailet/api/src/main/java/org/apache/mailet/PerRecipientHeaders.java
----------------------------------------------------------------------
diff --git a/mailet/api/src/main/java/org/apache/mailet/PerRecipientHeaders.java b/mailet/api/src/main/java/org/apache/mailet/PerRecipientHeaders.java
index af9b233..0b7bcdb 100644
--- a/mailet/api/src/main/java/org/apache/mailet/PerRecipientHeaders.java
+++ b/mailet/api/src/main/java/org/apache/mailet/PerRecipientHeaders.java
@@ -21,6 +21,8 @@ package org.apache.mailet;
 
 import java.util.Collection;
 
+import org.apache.james.core.MailAddress;
+
 import com.github.steveash.guavate.Guavate;
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.MoreObjects;


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


[14/23] james-project git commit: JAMES-2138 move MailAddress to a new james-core project

Posted by bt...@apache.org.
http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 20ddced..a5f045b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -525,6 +525,7 @@
 
     <modules>
         <module>backends-common</module>
+        <module>core</module>
         <module>mailbox</module>
         <module>mailet</module>
         <module>mdn</module>
@@ -945,6 +946,11 @@
             </dependency>
             <dependency>
                 <groupId>${project.groupId}</groupId>
+                <artifactId>james-core</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>${project.groupId}</groupId>
                 <artifactId>james-mdn</artifactId>
                 <version>${project.version}</version>
             </dependency>

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/protocols/lmtp/src/main/java/org/apache/james/protocols/lmtp/core/DataLineMessageHookHandler.java
----------------------------------------------------------------------
diff --git a/protocols/lmtp/src/main/java/org/apache/james/protocols/lmtp/core/DataLineMessageHookHandler.java b/protocols/lmtp/src/main/java/org/apache/james/protocols/lmtp/core/DataLineMessageHookHandler.java
index 5df57f9..51251de 100644
--- a/protocols/lmtp/src/main/java/org/apache/james/protocols/lmtp/core/DataLineMessageHookHandler.java
+++ b/protocols/lmtp/src/main/java/org/apache/james/protocols/lmtp/core/DataLineMessageHookHandler.java
@@ -23,11 +23,11 @@ import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
 
+import org.apache.james.core.MailAddress;
 import org.apache.james.protocols.api.Response;
 import org.apache.james.protocols.api.handler.WiringException;
 import org.apache.james.protocols.lmtp.LMTPMultiResponse;
 import org.apache.james.protocols.lmtp.hook.DeliverToRecipientHook;
-import org.apache.james.protocols.smtp.MailAddress;
 import org.apache.james.protocols.smtp.MailEnvelopeImpl;
 import org.apache.james.protocols.smtp.SMTPResponse;
 import org.apache.james.protocols.smtp.SMTPRetCode;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/protocols/lmtp/src/main/java/org/apache/james/protocols/lmtp/hook/DeliverToRecipientHook.java
----------------------------------------------------------------------
diff --git a/protocols/lmtp/src/main/java/org/apache/james/protocols/lmtp/hook/DeliverToRecipientHook.java b/protocols/lmtp/src/main/java/org/apache/james/protocols/lmtp/hook/DeliverToRecipientHook.java
index abfde07..7053cf8 100644
--- a/protocols/lmtp/src/main/java/org/apache/james/protocols/lmtp/hook/DeliverToRecipientHook.java
+++ b/protocols/lmtp/src/main/java/org/apache/james/protocols/lmtp/hook/DeliverToRecipientHook.java
@@ -19,7 +19,7 @@
 
 package org.apache.james.protocols.lmtp.hook;
 
-import org.apache.james.protocols.smtp.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.james.protocols.smtp.MailEnvelope;
 import org.apache.james.protocols.smtp.SMTPSession;
 import org.apache.james.protocols.smtp.hook.Hook;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/protocols/lmtp/src/test/java/org/apache/james/protocols/lmtp/AbstractLMTPServerTest.java
----------------------------------------------------------------------
diff --git a/protocols/lmtp/src/test/java/org/apache/james/protocols/lmtp/AbstractLMTPServerTest.java b/protocols/lmtp/src/test/java/org/apache/james/protocols/lmtp/AbstractLMTPServerTest.java
index dee82d3..b2978c2 100644
--- a/protocols/lmtp/src/test/java/org/apache/james/protocols/lmtp/AbstractLMTPServerTest.java
+++ b/protocols/lmtp/src/test/java/org/apache/james/protocols/lmtp/AbstractLMTPServerTest.java
@@ -34,6 +34,7 @@ import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.net.smtp.RelayPath;
 import org.apache.commons.net.smtp.SMTPClient;
 import org.apache.commons.net.smtp.SMTPReply;
+import org.apache.james.core.MailAddress;
 import org.apache.james.protocols.api.Protocol;
 import org.apache.james.protocols.api.ProtocolServer;
 import org.apache.james.protocols.api.handler.ProtocolHandler;
@@ -41,7 +42,6 @@ import org.apache.james.protocols.api.handler.WiringException;
 import org.apache.james.protocols.api.utils.ProtocolServerUtils;
 import org.apache.james.protocols.lmtp.hook.DeliverToRecipientHook;
 import org.apache.james.protocols.smtp.AbstractSMTPServerTest;
-import org.apache.james.protocols.smtp.MailAddress;
 import org.apache.james.protocols.smtp.MailEnvelope;
 import org.apache.james.protocols.smtp.SMTPProtocol;
 import org.apache.james.protocols.smtp.SMTPSession;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/protocols/pom.xml
----------------------------------------------------------------------
diff --git a/protocols/pom.xml b/protocols/pom.xml
index 7110834..0f58e8b 100644
--- a/protocols/pom.xml
+++ b/protocols/pom.xml
@@ -83,6 +83,11 @@
             </dependency>
             <dependency>
                 <groupId>org.apache.james</groupId>
+                <artifactId>james-core</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>org.apache.james</groupId>
                 <artifactId>james-server-data-api</artifactId>
                 <version>${project.version}</version>
             </dependency>

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/protocols/smtp/pom.xml
----------------------------------------------------------------------
diff --git a/protocols/smtp/pom.xml b/protocols/smtp/pom.xml
index 497ff47..14af535 100644
--- a/protocols/smtp/pom.xml
+++ b/protocols/smtp/pom.xml
@@ -35,6 +35,10 @@
 
     <dependencies>
         <dependency>
+            <groupId>org.apache.james</groupId>
+            <artifactId>james-core</artifactId>
+        </dependency>
+        <dependency>
             <groupId>${project.groupId}</groupId>
             <artifactId>protocols-api</artifactId>
         </dependency>
@@ -59,7 +63,6 @@
         <dependency>
             <groupId>com.sun.mail</groupId>
             <artifactId>javax.mail</artifactId>
-            <scope>test</scope>
         </dependency>
         <dependency>
             <groupId>commons-codec</groupId>

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/MailAddress.java
----------------------------------------------------------------------
diff --git a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/MailAddress.java b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/MailAddress.java
index 8cdd964..d420602 100644
--- a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/MailAddress.java
+++ b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/MailAddress.java
@@ -17,10 +17,10 @@
  * under the License.                                           *
  ****************************************************************/
 
-
 package org.apache.james.protocols.smtp;
 
-import java.util.Locale;
+import javax.mail.internet.AddressException;
+import javax.mail.internet.InternetAddress;
 
 /**
  * A representation of an email address.
@@ -57,465 +57,24 @@ import java.util.Locale;
  * http://www.freesoft.org/CIE/RFC/821/15.htm</p>
  *
  * <strong>This version is copied from mailet-api with a few changes to not make it depend on javamail</strong>
+ *
+ * @Deprecated Use james-core {@link org.apache.james.core.MailAddress} instead.
  */
-public class MailAddress {
-
-    private final static char[] SPECIAL =
-    {'<', '>', '(', ')', '[', ']', '\\', '.', ',', ';', ':', '@', '\"'};
-
-    private String localPart = null;
-    private String domain = null;
-
-    private static final MailAddress NULL_SENDER = new MailAddress() {
-
-        @Override
-        public String getDomain() {
-            return "";
-        }
-
-        @Override
-        public String getLocalPart() {
-            return "";
-        }
-
-        @Override
-        public String toString() {
-            return "";
-        }
-
-        @Override
-        public boolean isNullSender() {
-            return true;
-        }
-        
-    };
-    
-    /**
-     * Strips source routing. According to RFC-2821 it is a valid approach
-     * to handle mails containing RFC-821 source-route information.
-     * 
-     * @param address the address to strip
-     * @param pos current position
-     * @return new pos
-     */
-    private int stripSourceRoute(String address, int pos) {
-        if (pos < address.length()) {
-            if (address.charAt(pos)=='@') { 
-                int i = address.indexOf(':');
-                if (i != -1) {
-                    pos = i+1;
-                }
-            }
-        }
-        return pos;
-    }
-    
-    public static MailAddress nullSender() {
-        return NULL_SENDER;
-    }
-    
-    private MailAddress() {
-        
-    }
-    /**
-     * Constructs a MailAddress by parsing the provided address.
-     *
-     * @param address the email address, compliant to the RFC2822 3.4.1. addr-spec specification
-     * @throws MailAddressException if the parse failed
-     */
-    public MailAddress(String address) throws MailAddressException {
-        address = address.trim();
-        int pos = 0;
-        
-        // Test if mail address has source routing information (RFC-821) and get rid of it!!
-        //must be called first!! (or at least prior to updating pos)
-        stripSourceRoute(address, pos);
-
-        StringBuffer localPartSB = new StringBuffer();
-        StringBuffer domainSB = new StringBuffer();
-        //Begin parsing
-        //<mailbox> ::= <local-part> "@" <domain>
-
-        try {
-            //parse local-part
-            //<local-part> ::= <dot-string> | <quoted-string>
-            if (address.charAt(pos) == '\"') {
-                pos = parseQuotedLocalPart(localPartSB, address, pos);
-                if (localPartSB.toString().length() == 2) {
-                    throw new MailAddressException("No quoted local-part (user account) found at position " + (pos + 2) + " in '" + address + "'",address,pos+2);
-                }
-            } else {
-                pos = parseUnquotedLocalPart(localPartSB, address, pos);
-                if (localPartSB.toString().length() == 0) {
-                    throw new MailAddressException("No local-part (user account) found at position " + (pos + 1) + " in '" + address + "'",address,pos+1);
-                }
-            }
-
-            //find @
-            if (pos >= address.length() || address.charAt(pos) != '@') {
-                throw new MailAddressException("Did not find @ between local-part and domain at position " + (pos + 1) + " in '" + address + "'",address,pos+1);
-            }
-            pos++;
-
-            //parse domain
-            //<domain> ::=  <element> | <element> "." <domain>
-            //<element> ::= <name> | "#" <number> | "[" <dotnum> "]"
-            while (true) {
-                if (address.charAt(pos) == '#') {
-                    pos = parseNumber(domainSB, address, pos);
-                } else if (address.charAt(pos) == '[') {
-                    pos = parseDomainLiteral(domainSB, address, pos);
-                } else {
-                    pos = parseDomain(domainSB, address, pos);
-                }
-                if (pos >= address.length()) {
-                    break;
-                }
-                if (address.charAt(pos) == '.') {
-                    domainSB.append('.');
-                    pos++;
-                    continue;
-                }
-                break;
-            }
-
-            if (domainSB.toString().length() == 0) {
-                throw new MailAddressException("No domain found at position " + (pos + 1) + " in '" + address + "'",address,pos+1);
-            }
-        } catch (IndexOutOfBoundsException ioobe) {
-            throw new MailAddressException("Out of data at position " + (pos + 1) + " in '" + address + "'",address,pos+1);
-        }
-
-        localPart = localPartSB.toString();
-        domain = domainSB.toString();
-    }
-
-    /**
-     * Constructs a MailAddress with the provided local part and domain.
-     *
-     * @param localPart the local-part portion. This is a domain dependent string.
-     *        In addresses, it is simply interpreted on the particular host as a
-     *        name of a particular mailbox. per RFC2822 3.4.1. addr-spec specification
-     * @param domain the domain portion. This identifies the point to which the mail
-     *        is delivered  per RFC2822 3.4.1. addr-spec specification
-     * @throws AddressException if the parse failed
-     */
-    public MailAddress(String localPart, String domain) throws MailAddressException {
-        this(localPart+"@"+domain);
+@Deprecated
+public class MailAddress extends org.apache.james.core.MailAddress {
+    public MailAddress(String address) throws AddressException {
+        super(address);
     }
 
-
-    
-    /**
-     * Returns the domain part per RFC2822 3.4.1. addr-spec specification.
-     *
-     * @return the domain part of this email address. If the domain is of
-     * the domain-literal form  (e.g. [yyy.yyy.yyy.yyy]), the braces will
-     * have been stripped returning the raw IP address.
-     * 
-     */
-    public String getDomain() {
-        if (!(domain.startsWith("[") && domain.endsWith("]"))) {
-            return domain;
-        } 
-        return domain.substring(1, domain.length() -1);
-    }
-
-
-    
-    /**
-     * Returns the local-part per RFC2822 3.4.1. addr-spec specification.
-     *
-     * @return  the local-part of this email address as defined by the
-     *          RFC2822 3.4.1. addr-spec specification. 
-     *          The local-part portion is a domain dependent string.
-     *          In addresses, it is simply interpreted on the particular
-     *          host as a name of a particular mailbox
-     *          (the part before the "@" character)
-     *          
-     * @since Mailet API 2.4
-     */
-    public String getLocalPart() {
-        return localPart;
-    }
-
-    @Override
-    public String toString() {
-        StringBuffer addressBuffer =
-            new StringBuffer(128)
-                    .append(localPart)
-                    .append("@")
-                    .append(domain);
-        return addressBuffer.toString();
-    }
-    
-    
-    /**
-     * Indicates whether some other object is "equal to" this one.
-     * 
-     * Note that this implementation breaks the general contract of the
-     * <code>equals</code> method by allowing an instance to equal to a
-     * <code>String</code>. It is recommended that implementations avoid
-     * relying on this design which may be removed in a future release.
-     * 
-     * @returns true if the given object is equal to this one, false otherwise
-     */
-    @Override
-    public boolean equals(Object obj) {
-        if (obj == null) {
-            return false;
-        } else if (obj instanceof String) {
-            String theString = (String)obj;
-            return toString().equalsIgnoreCase(theString);
-        } else if (obj instanceof MailAddress) {
-            MailAddress addr = (MailAddress)obj;
-            return getLocalPart().equalsIgnoreCase(addr.getLocalPart()) && getDomain().equalsIgnoreCase(addr.getDomain());
-        }
-        return false;
-    }
-
-    /**
-     * Returns a hash code value for this object.
-     * <p>
-     * This method is implemented by returning the hash code of the canonical
-     * string representation of this address, so that all instances representing
-     * the same address will return an identical hash code.
-     *
-     * @return the hashcode.
-     */
-    @Override
-    public int hashCode() {
-        return toString().toLowerCase(Locale.US).hashCode();
-    }
-
-    private int parseQuotedLocalPart(StringBuffer lpSB, String address, int pos) throws MailAddressException {
-        StringBuffer resultSB = new StringBuffer();
-        resultSB.append('\"');
-        pos++;
-        //<quoted-string> ::=  """ <qtext> """
-        //<qtext> ::=  "\" <x> | "\" <x> <qtext> | <q> | <q> <qtext>
-        while (true) {
-            if (address.charAt(pos) == '\"') {
-                resultSB.append('\"');
-                //end of quoted string... move forward
-                pos++;
-                break;
-            }
-            if (address.charAt(pos) == '\\') {
-                resultSB.append('\\');
-                pos++;
-                //<x> ::= any one of the 128 ASCII characters (no exceptions)
-                char x = address.charAt(pos);
-                if (x < 0 || x > 127) {
-                    throw new MailAddressException("Invalid \\ syntaxed character at position " + (pos + 1) + " in '" + address + "'",address,pos+1);
-                }
-                resultSB.append(x);
-                pos++;
-            } else {
-                //<q> ::= any one of the 128 ASCII characters except <CR>,
-                //<LF>, quote ("), or backslash (\)
-                char q = address.charAt(pos);
-                if (q <= 0 || q == '\n' || q == '\r' || q == '\"' || q == '\\') {
-                    throw new MailAddressException("Unquoted local-part (user account) must be one of the 128 ASCI characters exception <CR>, <LF>, quote (\"), or backslash (\\) at position " + (pos + 1) + " in '" + address + "'", address, pos+1);
-                }
-                resultSB.append(q);
-                pos++;
-            }
-        }
-        lpSB.append(resultSB);
-        return pos;
-    }
-
-    private int parseUnquotedLocalPart(StringBuffer lpSB, String address, int pos) throws MailAddressException {
-        StringBuffer resultSB = new StringBuffer();
-        //<dot-string> ::= <string> | <string> "." <dot-string>
-        boolean lastCharDot = false;
-        while (true) {
-            //<string> ::= <char> | <char> <string>
-            //<char> ::= <c> | "\" <x>
-            if (address.charAt(pos) == '\\') {
-                resultSB.append('\\');
-                pos++;
-                //<x> ::= any one of the 128 ASCII characters (no exceptions)
-                char x = address.charAt(pos);
-                if (x < 0 || x > 127) {
-                    throw new MailAddressException("Invalid \\ syntaxed character at position " + (pos + 1) + " in '" + address + "'",address,pos+1);
-                }
-                resultSB.append(x);
-                pos++;
-                lastCharDot = false;
-            } else if (address.charAt(pos) == '.') {
-                resultSB.append('.');
-                pos++;
-                lastCharDot = true;
-            } else if (address.charAt(pos) == '@') {
-                //End of local-part
-                break;
-            } else {
-                //<c> ::= any one of the 128 ASCII characters, but not any
-                //    <special> or <SP>
-                //<special> ::= "<" | ">" | "(" | ")" | "[" | "]" | "\" | "."
-                //    | "," | ";" | ":" | "@"  """ | the control
-                //    characters (ASCII codes 0 through 31 inclusive and
-                //    127)
-                //<SP> ::= the space character (ASCII code 32)
-                char c = address.charAt(pos);
-                if (c <= 31 || c >= 127 || c == ' ') {
-                    throw new MailAddressException("Invalid character in local-part (user account) at position " + (pos + 1) + " in '" + address + "'",address,pos+1);
-                }
-                for (char aChar : SPECIAL) {
-                    if (c == aChar) {
-                        throw new MailAddressException("Invalid character in local-part (user account) at position " + (pos + 1) + " in '" + address + "'", address, pos + 1);
-                    }
-                }
-                resultSB.append(c);
-                pos++;
-                lastCharDot = false;
-            }
-        }
-        if (lastCharDot) {
-            throw new MailAddressException("local-part (user account) ended with a \".\", which is invalid in address '" + address + "'",address,pos);
-        }
-        lpSB.append(resultSB);
-        return pos;
-    }
-
-    private int parseNumber(StringBuffer dSB, String address, int pos) throws MailAddressException {
-        //<number> ::= <d> | <d> <number>
-
-        StringBuffer resultSB = new StringBuffer();
-        //We keep the position from the class level pos field
-        while (true) {
-            if (pos >= address.length()) {
-                break;
-            }
-            //<d> ::= any one of the ten digits 0 through 9
-            char d = address.charAt(pos);
-            if (d == '.') {
-                break;
-            }
-            if (d < '0' || d > '9') {
-                throw new MailAddressException("In domain, did not find a number in # address at position " + (pos + 1) + " in '" + address + "'",address,pos+1);
-            }
-            resultSB.append(d);
-            pos++;
-        }
-        dSB.append(resultSB);
-        return pos;
+    public MailAddress(String localPart, String domain) throws AddressException {
+        super(localPart, domain);
     }
 
-    private int parseDomainLiteral(StringBuffer dSB, String address, int pos) throws MailAddressException {
-        //throw away all irrelevant '\' they're not necessary for escaping of '.' or digits, and are illegal as part of the domain-literal
-        while(address.contains("\\")){
-             address= address.substring(0,address.indexOf("\\")) + address.substring(address.indexOf("\\")+1);
-        }
-        StringBuffer resultSB = new StringBuffer();
-        //we were passed the string with pos pointing the the [ char.
-        // take the first char ([), put it in the result buffer and increment pos
-        resultSB.append(address.charAt(pos));
-        pos++;
-
-        //<dotnum> ::= <snum> "." <snum> "." <snum> "." <snum>
-        for (int octet = 0; octet < 4; octet++) {
-            //<snum> ::= one, two, or three digits representing a decimal
-            //                      integer value in the range 0 through 255
-            //<d> ::= any one of the ten digits 0 through 9
-            StringBuffer snumSB = new StringBuffer();
-            for (int digits = 0; digits < 3; digits++) {
-                char d = address.charAt(pos);
-                if (d == '.') {
-                    break;
-                }
-                if (d == ']') {
-                    break;
-                }
-                if (d < '0' || d > '9') {
-                    throw new MailAddressException("Invalid number at position " + (pos + 1) + " in '" + address + "'",address,pos+1);
-                }
-                snumSB.append(d);
-                pos++;
-            }
-            if (snumSB.toString().length() == 0) {
-                throw new MailAddressException("Number not found at position " + (pos + 1) + " in '" + address + "'",address,pos+1);
-            }
-            try {
-                int snum = Integer.parseInt(snumSB.toString());
-                if (snum > 255) {
-                    throw new MailAddressException("Invalid number at position " + (pos + 1) + " in '" + address + "'",address,pos+1);
-                }
-            } catch (NumberFormatException nfe) {
-                throw new MailAddressException("Invalid number at position " + (pos + 1) + " in '" + address + "'",address,pos+1);
-            }
-            resultSB.append(snumSB.toString());
-            if (address.charAt(pos) == ']') {
-                if (octet < 3) {
-                    throw new MailAddressException("End of number reached too quickly at " + (pos + 1) + " in '" + address + "'",address,pos+1);
-                } 
-                break;
-            }
-            if (address.charAt(pos) == '.') {
-                resultSB.append('.');
-                pos++;
-            }
-        }
-        if (address.charAt(pos) != ']') {
-            throw new MailAddressException("Did not find closing bracket \"]\" in domain at position " + (pos + 1) + " in '" + address + "'",address,pos+1);
-        }
-        resultSB.append(']');
-        pos++;
-        dSB.append(resultSB);
-        return pos;
+    public MailAddress(InternetAddress address) throws AddressException {
+        super(address);
     }
 
-    private int parseDomain(StringBuffer dSB, String address, int pos) throws MailAddressException {
-        StringBuffer resultSB = new StringBuffer();
-        //<name> ::= <a> <ldh-str> <let-dig>
-        //<ldh-str> ::= <let-dig-hyp> | <let-dig-hyp> <ldh-str>
-        //<let-dig> ::= <a> | <d>
-        //<let-dig-hyp> ::= <a> | <d> | "-"
-        //<a> ::= any one of the 52 alphabetic characters A through Z
-        //  in upper case and a through z in lower case
-        //<d> ::= any one of the ten digits 0 through 9
-
-        // basically, this is a series of letters, digits, and hyphens,
-        // but it can't start with a digit or hypthen
-        // and can't end with a hyphen
-
-        // in practice though, we should relax this as domain names can start
-        // with digits as well as letters.  So only check that doesn't start
-        // or end with hyphen.
-        while (true) {
-            if (pos >= address.length()) {
-                break;
-            }
-            char ch = address.charAt(pos);
-            if ((ch >= '0' && ch <= '9') ||
-                (ch >= 'a' && ch <= 'z') ||
-                (ch >= 'A' && ch <= 'Z') ||
-                (ch == '-')) {
-                resultSB.append(ch);
-                pos++;
-                continue;
-            }
-            if (ch == '.') {
-                break;
-            }
-            throw new MailAddressException("Invalid character at " + pos + " in '" + address + "'",address,pos);
-        }
-        String result = resultSB.toString();
-        if (result.startsWith("-") || result.endsWith("-")) {
-            throw new MailAddressException("Domain name cannot begin or end with a hyphen \"-\" at position " + (pos + 1) + " in '" + address + "'",address,pos+1);
-        }
-        dSB.append(result);
-        return pos;
-    }
-    
-    /**
-     * Return <code>true</code> if the {@link MailAddress} should represent a null sender (<>)
-     * 
-     * @return nullsender
-     */
-    public boolean isNullSender() {
-        return false;
+    public MailAddress(org.apache.james.core.MailAddress address) throws AddressException {
+        super(address.asString());
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/MailAddressException.java
----------------------------------------------------------------------
diff --git a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/MailAddressException.java b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/MailAddressException.java
index e3a3b29..dc94811 100644
--- a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/MailAddressException.java
+++ b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/MailAddressException.java
@@ -17,20 +17,17 @@
  * under the License.                                           *
  ****************************************************************/
 
-
 package org.apache.james.protocols.smtp;
 
+/**
+ * @Deprecated see {@link org.apache.james.protocols.smtp.MailAddress} for more details.
+ */
+@Deprecated
 public class MailAddressException extends Exception{
-
-    /**
-     * 
-     */
     private static final long serialVersionUID = -2845113080526615146L;
     private final String address;
     private final int pos;
 
-   
-
     public MailAddressException(String message, String address, int pos) {
         super(message);
         this.address = address;
@@ -45,5 +42,4 @@ public class MailAddressException extends Exception{
         return pos;
     }
 
-
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/MailEnvelope.java
----------------------------------------------------------------------
diff --git a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/MailEnvelope.java b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/MailEnvelope.java
index b463ed1..f85d861 100644
--- a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/MailEnvelope.java
+++ b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/MailEnvelope.java
@@ -24,6 +24,8 @@ import java.io.InputStream;
 import java.io.OutputStream;
 import java.util.List;
 
+import org.apache.james.core.MailAddress;
+
 /**
  * The MailEnvelope of a SMTP-Transaction
  * 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/MailEnvelopeImpl.java
----------------------------------------------------------------------
diff --git a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/MailEnvelopeImpl.java b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/MailEnvelopeImpl.java
index a3a0342..c30d81e 100644
--- a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/MailEnvelopeImpl.java
+++ b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/MailEnvelopeImpl.java
@@ -26,6 +26,8 @@ import java.io.InputStream;
 import java.io.OutputStream;
 import java.util.List;
 
+import org.apache.james.core.MailAddress;
+
 /**
  * MailEnvelope implementation which stores everything in memory
  * 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/SMTPSessionImpl.java
----------------------------------------------------------------------
diff --git a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/SMTPSessionImpl.java b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/SMTPSessionImpl.java
index c5fad00..570075b 100644
--- a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/SMTPSessionImpl.java
+++ b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/SMTPSessionImpl.java
@@ -20,6 +20,7 @@ package org.apache.james.protocols.smtp;
 
 import java.util.Collection;
 
+import org.apache.james.core.MailAddress;
 import org.apache.james.protocols.api.ProtocolSessionImpl;
 import org.apache.james.protocols.api.ProtocolTransport;
 import org.apache.james.protocols.api.Response;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/AbstractAuthRequiredToRelayRcptHook.java
----------------------------------------------------------------------
diff --git a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/AbstractAuthRequiredToRelayRcptHook.java b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/AbstractAuthRequiredToRelayRcptHook.java
index 1ea59ec..57dde32 100644
--- a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/AbstractAuthRequiredToRelayRcptHook.java
+++ b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/AbstractAuthRequiredToRelayRcptHook.java
@@ -18,7 +18,7 @@
  ****************************************************************/
 package org.apache.james.protocols.smtp.core;
 
-import org.apache.james.protocols.smtp.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.james.protocols.smtp.SMTPRetCode;
 import org.apache.james.protocols.smtp.SMTPSession;
 import org.apache.james.protocols.smtp.dsn.DSNStatus;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/AbstractSenderAuthIdentifyVerificationRcptHook.java
----------------------------------------------------------------------
diff --git a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/AbstractSenderAuthIdentifyVerificationRcptHook.java b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/AbstractSenderAuthIdentifyVerificationRcptHook.java
index f625f2b..baa390f 100644
--- a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/AbstractSenderAuthIdentifyVerificationRcptHook.java
+++ b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/AbstractSenderAuthIdentifyVerificationRcptHook.java
@@ -20,8 +20,8 @@ package org.apache.james.protocols.smtp.core;
 
 import java.util.Locale;
 
+import org.apache.james.core.MailAddress;
 import org.apache.james.protocols.api.ProtocolSession;
-import org.apache.james.protocols.smtp.MailAddress;
 import org.apache.james.protocols.smtp.SMTPRetCode;
 import org.apache.james.protocols.smtp.SMTPSession;
 import org.apache.james.protocols.smtp.dsn.DSNStatus;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/AcceptRecipientIfRelayingIsAllowed.java
----------------------------------------------------------------------
diff --git a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/AcceptRecipientIfRelayingIsAllowed.java b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/AcceptRecipientIfRelayingIsAllowed.java
index 373a133..70289bf 100644
--- a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/AcceptRecipientIfRelayingIsAllowed.java
+++ b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/AcceptRecipientIfRelayingIsAllowed.java
@@ -20,7 +20,7 @@ package org.apache.james.protocols.smtp.core;
 
 import org.apache.commons.configuration.Configuration;
 import org.apache.commons.configuration.ConfigurationException;
-import org.apache.james.protocols.smtp.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.james.protocols.smtp.SMTPSession;
 import org.apache.james.protocols.smtp.hook.HookResult;
 import org.apache.james.protocols.smtp.hook.RcptHook;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/DataCmdHandler.java
----------------------------------------------------------------------
diff --git a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/DataCmdHandler.java b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/DataCmdHandler.java
index d20c1d0..485cb21 100644
--- a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/DataCmdHandler.java
+++ b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/DataCmdHandler.java
@@ -30,6 +30,7 @@ import javax.inject.Inject;
 
 import org.apache.commons.configuration.Configuration;
 import org.apache.commons.configuration.ConfigurationException;
+import org.apache.james.core.MailAddress;
 import org.apache.james.metrics.api.MetricFactory;
 import org.apache.james.metrics.api.TimeMetric;
 import org.apache.james.protocols.api.ProtocolSession;
@@ -39,7 +40,6 @@ import org.apache.james.protocols.api.handler.CommandHandler;
 import org.apache.james.protocols.api.handler.ExtensibleHandler;
 import org.apache.james.protocols.api.handler.LineHandler;
 import org.apache.james.protocols.api.handler.WiringException;
-import org.apache.james.protocols.smtp.MailAddress;
 import org.apache.james.protocols.smtp.MailEnvelope;
 import org.apache.james.protocols.smtp.MailEnvelopeImpl;
 import org.apache.james.protocols.smtp.SMTPResponse;
@@ -49,7 +49,6 @@ import org.apache.james.protocols.smtp.dsn.DSNStatus;
 import org.apache.james.util.MDCBuilder;
 
 import com.google.common.base.Throwables;
-
 import com.google.common.collect.ImmutableSet;
 
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/MailCmdHandler.java
----------------------------------------------------------------------
diff --git a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/MailCmdHandler.java b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/MailCmdHandler.java
index a47726f..4d3cb54 100644
--- a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/MailCmdHandler.java
+++ b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/MailCmdHandler.java
@@ -30,11 +30,11 @@ import javax.inject.Inject;
 
 import org.apache.commons.configuration.Configuration;
 import org.apache.commons.configuration.ConfigurationException;
+import org.apache.james.core.MailAddress;
 import org.apache.james.metrics.api.MetricFactory;
 import org.apache.james.protocols.api.ProtocolSession.State;
 import org.apache.james.protocols.api.Request;
 import org.apache.james.protocols.api.Response;
-import org.apache.james.protocols.smtp.MailAddress;
 import org.apache.james.protocols.smtp.SMTPResponse;
 import org.apache.james.protocols.smtp.SMTPRetCode;
 import org.apache.james.protocols.smtp.SMTPSession;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/PostmasterAbuseRcptHook.java
----------------------------------------------------------------------
diff --git a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/PostmasterAbuseRcptHook.java b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/PostmasterAbuseRcptHook.java
index 6c9f54e..dcc9151 100644
--- a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/PostmasterAbuseRcptHook.java
+++ b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/PostmasterAbuseRcptHook.java
@@ -20,7 +20,7 @@ package org.apache.james.protocols.smtp.core;
 
 import org.apache.commons.configuration.Configuration;
 import org.apache.commons.configuration.ConfigurationException;
-import org.apache.james.protocols.smtp.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.james.protocols.smtp.SMTPSession;
 import org.apache.james.protocols.smtp.hook.HookResult;
 import org.apache.james.protocols.smtp.hook.RcptHook;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/RcptCmdHandler.java
----------------------------------------------------------------------
diff --git a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/RcptCmdHandler.java b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/RcptCmdHandler.java
index 719cabc..7e00dc8 100644
--- a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/RcptCmdHandler.java
+++ b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/RcptCmdHandler.java
@@ -28,11 +28,11 @@ import javax.inject.Inject;
 
 import org.apache.commons.configuration.Configuration;
 import org.apache.commons.configuration.ConfigurationException;
+import org.apache.james.core.MailAddress;
 import org.apache.james.metrics.api.MetricFactory;
 import org.apache.james.protocols.api.ProtocolSession.State;
 import org.apache.james.protocols.api.Response;
 import org.apache.james.protocols.api.handler.CommandHandler;
-import org.apache.james.protocols.smtp.MailAddress;
 import org.apache.james.protocols.smtp.SMTPResponse;
 import org.apache.james.protocols.smtp.SMTPRetCode;
 import org.apache.james.protocols.smtp.SMTPSession;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/ReceivedDataLineFilter.java
----------------------------------------------------------------------
diff --git a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/ReceivedDataLineFilter.java b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/ReceivedDataLineFilter.java
index af4cac2..6960d6d 100644
--- a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/ReceivedDataLineFilter.java
+++ b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/ReceivedDataLineFilter.java
@@ -28,8 +28,8 @@ import java.util.Locale;
 
 import org.apache.commons.configuration.Configuration;
 import org.apache.commons.configuration.ConfigurationException;
+import org.apache.james.core.MailAddress;
 import org.apache.james.protocols.api.ProtocolSession.State;
-import org.apache.james.protocols.smtp.MailAddress;
 import org.apache.james.protocols.smtp.SMTPSession;
 
 /**

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/fastfail/AbstractGreylistHandler.java
----------------------------------------------------------------------
diff --git a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/fastfail/AbstractGreylistHandler.java b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/fastfail/AbstractGreylistHandler.java
index 2fe36b0..c69b5f2 100644
--- a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/fastfail/AbstractGreylistHandler.java
+++ b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/fastfail/AbstractGreylistHandler.java
@@ -21,7 +21,7 @@ package org.apache.james.protocols.smtp.core.fastfail;
 
 import java.util.Iterator;
 
-import org.apache.james.protocols.smtp.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.james.protocols.smtp.SMTPRetCode;
 import org.apache.james.protocols.smtp.SMTPSession;
 import org.apache.james.protocols.smtp.dsn.DSNStatus;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/fastfail/AbstractValidRcptHandler.java
----------------------------------------------------------------------
diff --git a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/fastfail/AbstractValidRcptHandler.java b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/fastfail/AbstractValidRcptHandler.java
index 8a148ba..54233ec 100644
--- a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/fastfail/AbstractValidRcptHandler.java
+++ b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/fastfail/AbstractValidRcptHandler.java
@@ -17,12 +17,9 @@
  * under the License.                                           *
  ****************************************************************/
 
-
-
-
 package org.apache.james.protocols.smtp.core.fastfail;
 
-import org.apache.james.protocols.smtp.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.james.protocols.smtp.SMTPRetCode;
 import org.apache.james.protocols.smtp.SMTPSession;
 import org.apache.james.protocols.smtp.dsn.DSNStatus;
@@ -32,7 +29,6 @@ import org.apache.james.protocols.smtp.hook.RcptHook;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-
 /**
  * Handler which want todo an recipient check should extend this
  *

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/fastfail/DNSRBLHandler.java
----------------------------------------------------------------------
diff --git a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/fastfail/DNSRBLHandler.java b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/fastfail/DNSRBLHandler.java
index 312708e..bd2b65f 100644
--- a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/fastfail/DNSRBLHandler.java
+++ b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/fastfail/DNSRBLHandler.java
@@ -26,8 +26,8 @@ import java.util.StringTokenizer;
 
 import org.apache.commons.configuration.Configuration;
 import org.apache.commons.configuration.ConfigurationException;
+import org.apache.james.core.MailAddress;
 import org.apache.james.protocols.api.ProtocolSession.State;
-import org.apache.james.protocols.smtp.MailAddress;
 import org.apache.james.protocols.smtp.SMTPSession;
 import org.apache.james.protocols.smtp.dsn.DSNStatus;
 import org.apache.james.protocols.smtp.hook.HookResult;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/fastfail/MaxRcptHandler.java
----------------------------------------------------------------------
diff --git a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/fastfail/MaxRcptHandler.java b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/fastfail/MaxRcptHandler.java
index 43c4b5b..de38ac1 100644
--- a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/fastfail/MaxRcptHandler.java
+++ b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/fastfail/MaxRcptHandler.java
@@ -24,7 +24,7 @@ package org.apache.james.protocols.smtp.core.fastfail;
 
 import org.apache.commons.configuration.Configuration;
 import org.apache.commons.configuration.ConfigurationException;
-import org.apache.james.protocols.smtp.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.james.protocols.smtp.SMTPRetCode;
 import org.apache.james.protocols.smtp.SMTPSession;
 import org.apache.james.protocols.smtp.dsn.DSNStatus;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/fastfail/ResolvableEhloHeloHandler.java
----------------------------------------------------------------------
diff --git a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/fastfail/ResolvableEhloHeloHandler.java b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/fastfail/ResolvableEhloHeloHandler.java
index b3a47eb..5450773 100644
--- a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/fastfail/ResolvableEhloHeloHandler.java
+++ b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/fastfail/ResolvableEhloHeloHandler.java
@@ -22,11 +22,10 @@ package org.apache.james.protocols.smtp.core.fastfail;
 import java.net.InetAddress;
 import java.net.UnknownHostException;
 
-
 import org.apache.commons.configuration.Configuration;
 import org.apache.commons.configuration.ConfigurationException;
+import org.apache.james.core.MailAddress;
 import org.apache.james.protocols.api.ProtocolSession.State;
-import org.apache.james.protocols.smtp.MailAddress;
 import org.apache.james.protocols.smtp.SMTPRetCode;
 import org.apache.james.protocols.smtp.SMTPSession;
 import org.apache.james.protocols.smtp.dsn.DSNStatus;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/fastfail/SpamTrapHandler.java
----------------------------------------------------------------------
diff --git a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/fastfail/SpamTrapHandler.java b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/fastfail/SpamTrapHandler.java
index 73df529..4b77129 100644
--- a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/fastfail/SpamTrapHandler.java
+++ b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/fastfail/SpamTrapHandler.java
@@ -28,7 +28,7 @@ import java.util.Map;
 
 import org.apache.commons.configuration.Configuration;
 import org.apache.commons.configuration.ConfigurationException;
-import org.apache.james.protocols.smtp.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.james.protocols.smtp.SMTPSession;
 import org.apache.james.protocols.smtp.hook.HookResult;
 import org.apache.james.protocols.smtp.hook.RcptHook;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/fastfail/SupressDuplicateRcptHandler.java
----------------------------------------------------------------------
diff --git a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/fastfail/SupressDuplicateRcptHandler.java b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/fastfail/SupressDuplicateRcptHandler.java
index 69c823e..8424f48 100644
--- a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/fastfail/SupressDuplicateRcptHandler.java
+++ b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/fastfail/SupressDuplicateRcptHandler.java
@@ -17,17 +17,14 @@
  * under the License.                                           *
  ****************************************************************/
 
-
-
-
 package org.apache.james.protocols.smtp.core.fastfail;
 
 import java.util.Collection;
 
 import org.apache.commons.configuration.Configuration;
 import org.apache.commons.configuration.ConfigurationException;
+import org.apache.james.core.MailAddress;
 import org.apache.james.protocols.api.ProtocolSession.State;
-import org.apache.james.protocols.smtp.MailAddress;
 import org.apache.james.protocols.smtp.SMTPRetCode;
 import org.apache.james.protocols.smtp.SMTPSession;
 import org.apache.james.protocols.smtp.dsn.DSNStatus;
@@ -38,7 +35,6 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * 
  * This handler can be used to just ignore duplicated recipients. 
  */
 public class SupressDuplicateRcptHandler implements RcptHook {

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/fastfail/ValidSenderDomainHandler.java
----------------------------------------------------------------------
diff --git a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/fastfail/ValidSenderDomainHandler.java b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/fastfail/ValidSenderDomainHandler.java
index 1118f3f..c1341bb 100644
--- a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/fastfail/ValidSenderDomainHandler.java
+++ b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/fastfail/ValidSenderDomainHandler.java
@@ -18,7 +18,7 @@
  ****************************************************************/
 package org.apache.james.protocols.smtp.core.fastfail;
 
-import org.apache.james.protocols.smtp.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.james.protocols.smtp.SMTPRetCode;
 import org.apache.james.protocols.smtp.SMTPSession;
 import org.apache.james.protocols.smtp.dsn.DSNStatus;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/hook/MailHook.java
----------------------------------------------------------------------
diff --git a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/hook/MailHook.java b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/hook/MailHook.java
index 8548ef0..a0feafa 100644
--- a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/hook/MailHook.java
+++ b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/hook/MailHook.java
@@ -17,13 +17,9 @@
  * under the License.                                           *
  ****************************************************************/
 
-
-
-
-
 package org.apache.james.protocols.smtp.hook;
 
-import org.apache.james.protocols.smtp.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.james.protocols.smtp.SMTPSession;
 
 /**

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/hook/RcptHook.java
----------------------------------------------------------------------
diff --git a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/hook/RcptHook.java b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/hook/RcptHook.java
index 8ab2b2f..bbc65b1 100644
--- a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/hook/RcptHook.java
+++ b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/hook/RcptHook.java
@@ -18,7 +18,7 @@
  ****************************************************************/
 package org.apache.james.protocols.smtp.hook;
 
-import org.apache.james.protocols.smtp.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.james.protocols.smtp.SMTPSession;
 
 /**

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/hook/SimpleHook.java
----------------------------------------------------------------------
diff --git a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/hook/SimpleHook.java b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/hook/SimpleHook.java
index ffc3bc6..fd43d40 100644
--- a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/hook/SimpleHook.java
+++ b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/hook/SimpleHook.java
@@ -19,9 +19,9 @@
 
 package org.apache.james.protocols.smtp.hook;
 
-import org.apache.commons.configuration.Configuration;
-import org.apache.commons.configuration.ConfigurationException;
-import org.apache.james.protocols.smtp.MailAddress;
+import org.apache.commons.configuration.Configuration;
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.james.core.MailAddress;
 import org.apache.james.protocols.smtp.MailEnvelope;
 import org.apache.james.protocols.smtp.SMTPSession;
 
@@ -34,16 +34,16 @@ import org.apache.james.protocols.smtp.SMTPSession;
  */
 public class SimpleHook implements HeloHook, MailHook, RcptHook, MessageHook {
 
-    @Override
-    public void init(Configuration config) throws ConfigurationException {
-
-    }
-
-    @Override
-    public void destroy() {
-
-    }
-
+    @Override
+    public void init(Configuration config) throws ConfigurationException {
+
+    }
+
+    @Override
+    public void destroy() {
+
+    }
+
     /**
      * Return {@link HookResult} with {@link HookReturnCode#OK}
      */

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/AbstractSMTPServerTest.java
----------------------------------------------------------------------
diff --git a/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/AbstractSMTPServerTest.java b/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/AbstractSMTPServerTest.java
index bae1991..e92676b 100644
--- a/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/AbstractSMTPServerTest.java
+++ b/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/AbstractSMTPServerTest.java
@@ -35,6 +35,7 @@ import org.apache.commons.configuration.Configuration;
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.net.smtp.SMTPClient;
 import org.apache.commons.net.smtp.SMTPReply;
+import org.apache.james.core.MailAddress;
 import org.apache.james.metrics.api.NoopMetricFactory;
 import org.apache.james.protocols.api.Protocol;
 import org.apache.james.protocols.api.ProtocolServer;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/core/fastfail/DNSRBLHandlerTest.java
----------------------------------------------------------------------
diff --git a/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/core/fastfail/DNSRBLHandlerTest.java b/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/core/fastfail/DNSRBLHandlerTest.java
index fb798e4..8496bee 100644
--- a/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/core/fastfail/DNSRBLHandlerTest.java
+++ b/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/core/fastfail/DNSRBLHandlerTest.java
@@ -31,9 +31,8 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.james.core.MailAddress;
 import org.apache.james.protocols.api.ProtocolSession.State;
-import org.apache.james.protocols.smtp.MailAddress;
-import org.apache.james.protocols.smtp.MailAddressException;
 import org.apache.james.protocols.smtp.SMTPSession;
 import org.apache.james.protocols.smtp.utils.BaseFakeSMTPSession;
 import org.junit.Before;
@@ -172,7 +171,7 @@ public class DNSRBLHandlerTest {
 
     // ip is blacklisted and has txt details
     @Test
-    public void testBlackListedTextPresent() throws MailAddressException {
+    public void testBlackListedTextPresent() throws Exception {
         DNSRBLHandler rbl = createHandler();
        
         setupMockedSMTPSession(new MailAddress("any@domain"));
@@ -187,7 +186,7 @@ public class DNSRBLHandlerTest {
 
     // ip is blacklisted and has txt details but we don'T want to retrieve the txt record
     @Test
-    public void testGetNoDetail() throws MailAddressException {
+    public void testGetNoDetail() throws Exception {
         DNSRBLHandler rbl = createHandler();
         setupMockedSMTPSession(new MailAddress("any@domain"));
 
@@ -200,7 +199,7 @@ public class DNSRBLHandlerTest {
 
     // ip is allowed to relay
     @Test
-    public void testRelayAllowed() throws MailAddressException {
+    public void testRelayAllowed() throws Exception {
         DNSRBLHandler rbl = createHandler();
         setRelayingAllowed(true);
         setupMockedSMTPSession(new MailAddress("any@domain"));
@@ -214,7 +213,7 @@ public class DNSRBLHandlerTest {
 
     // ip not on blacklist
     @Test
-    public void testNotBlackListed() throws MailAddressException {
+    public void testNotBlackListed() throws Exception {
         DNSRBLHandler rbl = createHandler();
 
         setRemoteIp("192.168.0.1");
@@ -229,7 +228,7 @@ public class DNSRBLHandlerTest {
 
     // ip on blacklist without txt details
     @Test
-    public void testBlackListedNoTxt() throws MailAddressException {
+    public void testBlackListedNoTxt() throws Exception {
         DNSRBLHandler rbl = createHandler();
 
         setRemoteIp("127.0.0.3");
@@ -244,7 +243,7 @@ public class DNSRBLHandlerTest {
 
     // ip on whitelist
     @Test
-    public void testWhiteListed() throws MailAddressException {
+    public void testWhiteListed() throws Exception {
         DNSRBLHandler rbl = createHandler();
 
         setRemoteIp("127.0.0.2");

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/core/fastfail/MaxRcptHandlerTest.java
----------------------------------------------------------------------
diff --git a/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/core/fastfail/MaxRcptHandlerTest.java b/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/core/fastfail/MaxRcptHandlerTest.java
index 345cf09..b715049 100644
--- a/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/core/fastfail/MaxRcptHandlerTest.java
+++ b/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/core/fastfail/MaxRcptHandlerTest.java
@@ -24,8 +24,7 @@ import static org.junit.Assert.assertEquals;
 import java.util.HashMap;
 import java.util.Map;
 
-import org.apache.james.protocols.smtp.MailAddress;
-import org.apache.james.protocols.smtp.MailAddressException;
+import org.apache.james.core.MailAddress;
 import org.apache.james.protocols.smtp.SMTPSession;
 import org.apache.james.protocols.smtp.hook.HookReturnCode;
 import org.apache.james.protocols.smtp.utils.BaseFakeSMTPSession;
@@ -53,7 +52,7 @@ public class MaxRcptHandlerTest {
     }
     
     @Test
-    public void testRejectMaxRcpt() throws MailAddressException {
+    public void testRejectMaxRcpt() throws Exception {
         SMTPSession session = setupMockedSession(3);
         MaxRcptHandler handler = new MaxRcptHandler();
         
@@ -65,7 +64,7 @@ public class MaxRcptHandlerTest {
   
   
     @Test
-    public void testNotRejectMaxRcpt() throws MailAddressException {
+    public void testNotRejectMaxRcpt() throws Exception {
         SMTPSession session = setupMockedSession(3);
         MaxRcptHandler handler = new MaxRcptHandler();    
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/core/fastfail/MaxUnknownCmdHandlerTest.java
----------------------------------------------------------------------
diff --git a/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/core/fastfail/MaxUnknownCmdHandlerTest.java b/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/core/fastfail/MaxUnknownCmdHandlerTest.java
index 70606f9..9f5f68c 100644
--- a/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/core/fastfail/MaxUnknownCmdHandlerTest.java
+++ b/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/core/fastfail/MaxUnknownCmdHandlerTest.java
@@ -25,7 +25,6 @@ import static org.junit.Assert.assertEquals;
 import java.util.HashMap;
 import java.util.Map;
 
-import org.apache.james.protocols.smtp.MailAddressException;
 import org.apache.james.protocols.smtp.SMTPSession;
 import org.apache.james.protocols.smtp.hook.HookReturnCode;
 import org.apache.james.protocols.smtp.utils.BaseFakeSMTPSession;
@@ -35,7 +34,7 @@ public class MaxUnknownCmdHandlerTest {
 
     
     @Test
-    public void testRejectAndClose() throws MailAddressException {
+    public void testRejectAndClose() throws Exception {
         SMTPSession session = new BaseFakeSMTPSession() {
             private final HashMap<String,Object> map = new HashMap<>();
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/core/fastfail/ResolvableEhloHeloHandlerTest.java
----------------------------------------------------------------------
diff --git a/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/core/fastfail/ResolvableEhloHeloHandlerTest.java b/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/core/fastfail/ResolvableEhloHeloHandlerTest.java
index ec7ea8a..e5cee47 100644
--- a/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/core/fastfail/ResolvableEhloHeloHandlerTest.java
+++ b/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/core/fastfail/ResolvableEhloHeloHandlerTest.java
@@ -28,9 +28,8 @@ import java.net.UnknownHostException;
 import java.util.HashMap;
 import java.util.Map;
 
+import org.apache.james.core.MailAddress;
 import org.apache.james.protocols.api.ProtocolSession.State;
-import org.apache.james.protocols.smtp.MailAddress;
-import org.apache.james.protocols.smtp.MailAddressException;
 import org.apache.james.protocols.smtp.SMTPSession;
 import org.apache.james.protocols.smtp.hook.HookReturnCode;
 import org.apache.james.protocols.smtp.utils.BaseFakeSMTPSession;
@@ -120,7 +119,7 @@ public class ResolvableEhloHeloHandlerTest {
     }
     
     @Test
-    public void testRejectInvalidHelo() throws MailAddressException {
+    public void testRejectInvalidHelo() throws Exception {
         MailAddress mailAddress = new MailAddress("test@localhost");
         SMTPSession session = setupMockSession(INVALID_HOST,false,false,null,mailAddress);
         ResolvableEhloHeloHandler handler = createHandler();
@@ -133,7 +132,7 @@ public class ResolvableEhloHeloHandlerTest {
     }
     
     @Test
-    public void testNotRejectValidHelo() throws MailAddressException {
+    public void testNotRejectValidHelo() throws Exception {
         MailAddress mailAddress = new MailAddress("test@localhost");
         SMTPSession session = setupMockSession(VALID_HOST,false,false,null,mailAddress);
         ResolvableEhloHeloHandler handler = createHandler();
@@ -147,7 +146,7 @@ public class ResolvableEhloHeloHandlerTest {
     }
    
     @Test
-    public void testRejectInvalidHeloAuthUser() throws MailAddressException {
+    public void testRejectInvalidHeloAuthUser() throws Exception {
         MailAddress mailAddress = new MailAddress("test@localhost");
         SMTPSession session = setupMockSession(INVALID_HOST,false,true,"valid@user",mailAddress);
         ResolvableEhloHeloHandler handler = createHandler();
@@ -163,7 +162,7 @@ public class ResolvableEhloHeloHandlerTest {
     
    
     @Test
-    public void testRejectRelay() throws MailAddressException {
+    public void testRejectRelay() throws Exception {
         MailAddress mailAddress = new MailAddress("test@localhost");
         SMTPSession session = setupMockSession(INVALID_HOST,true,false,null,mailAddress);
         ResolvableEhloHeloHandler handler = createHandler();

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/core/fastfail/SpamTrapHandlerTest.java
----------------------------------------------------------------------
diff --git a/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/core/fastfail/SpamTrapHandlerTest.java b/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/core/fastfail/SpamTrapHandlerTest.java
index c12df5a..8eff79e 100644
--- a/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/core/fastfail/SpamTrapHandlerTest.java
+++ b/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/core/fastfail/SpamTrapHandlerTest.java
@@ -17,7 +17,6 @@
  * under the License.                                           *
  ****************************************************************/
 
-
 package org.apache.james.protocols.smtp.core.fastfail;
 
 import static org.junit.Assert.assertEquals;
@@ -26,8 +25,7 @@ import static org.junit.Assert.fail;
 import java.net.InetSocketAddress;
 import java.util.ArrayList;
 
-import org.apache.james.protocols.smtp.MailAddress;
-import org.apache.james.protocols.smtp.MailAddressException;
+import org.apache.james.core.MailAddress;
 import org.apache.james.protocols.smtp.SMTPSession;
 import org.apache.james.protocols.smtp.hook.HookReturnCode;
 import org.apache.james.protocols.smtp.utils.BaseFakeSMTPSession;
@@ -52,7 +50,7 @@ public class SpamTrapHandlerTest {
     }
     
     @Test
-    public void testSpamTrap() throws MailAddressException {
+    public void testSpamTrap() throws Exception {
         String ip = "192.168.100.1";
         String ip2 = "192.168.100.2";
         long blockTime = 2000;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/core/fastfail/ValidSenderDomainHandlerTest.java
----------------------------------------------------------------------
diff --git a/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/core/fastfail/ValidSenderDomainHandlerTest.java b/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/core/fastfail/ValidSenderDomainHandlerTest.java
index 9dee55c..794cc5b 100644
--- a/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/core/fastfail/ValidSenderDomainHandlerTest.java
+++ b/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/core/fastfail/ValidSenderDomainHandlerTest.java
@@ -26,9 +26,8 @@ import java.util.Map;
 
 import org.apache.commons.configuration.Configuration;
 import org.apache.commons.configuration.ConfigurationException;
+import org.apache.james.core.MailAddress;
 import org.apache.james.protocols.api.ProtocolSession.State;
-import org.apache.james.protocols.smtp.MailAddress;
-import org.apache.james.protocols.smtp.MailAddressException;
 import org.apache.james.protocols.smtp.SMTPSession;
 import org.apache.james.protocols.smtp.hook.HookReturnCode;
 import org.apache.james.protocols.smtp.utils.BaseFakeSMTPSession;
@@ -116,7 +115,7 @@ public class ValidSenderDomainHandlerTest {
     }
 
     @Test
-    public void testInvalidSenderDomainReject() throws MailAddressException {
+    public void testInvalidSenderDomainReject() throws Exception {
         ValidSenderDomainHandler handler = createHandler();
         SMTPSession session = setupMockedSession(new MailAddress("invalid@invalid"));
         int response = handler.doMail(session,(MailAddress) session.getAttachment(SMTPSession.SENDER, State.Transaction)).getResult();

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/main/java/org/apache/james/core/InternetHeadersInputStream.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/main/java/org/apache/james/core/InternetHeadersInputStream.java b/server/container/core/src/main/java/org/apache/james/core/InternetHeadersInputStream.java
deleted file mode 100644
index a94dd5e..0000000
--- a/server/container/core/src/main/java/org/apache/james/core/InternetHeadersInputStream.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-
-package org.apache.james.core;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-import java.util.Enumeration;
-
-import javax.mail.internet.InternetHeaders;
-
-/**
- * Provide an {@link InputStream} over an {@link InternetHeaders} instance. When
- * the end of {@link InternetHeaders} are reached a {@link #LINE_SEPERATOR} is
- * append
- */
-public class InternetHeadersInputStream extends InputStream {
-
-    private final static String LINE_SEPERATOR = "\r\n";
-
-    private final Enumeration<String> headerLines;
-    private byte[] currLine;
-    private int pos = 0;
-
-    @SuppressWarnings("unchecked")
-    public InternetHeadersInputStream(InternetHeaders headers) {
-        this(headers.getAllHeaderLines());
-    }
-
-    public InternetHeadersInputStream(Enumeration<String> headerLines) {
-        this.headerLines = headerLines;
-    }
-
-    @Override
-    public int read() throws IOException {
-        if (currLine == null || pos == currLine.length) {
-            if (!readNextLine()) {
-                return -1;
-            }
-        }
-        return currLine[pos++];
-    }
-
-    /**
-     * Load the next header line if possible
-     * 
-     * @return true if there was an headerline which could be read
-     * 
-     * @throws IOException
-     */
-    private boolean readNextLine() throws IOException {
-        if (headerLines.hasMoreElements()) {
-            try {
-                pos = 0;
-                String line = (headerLines.nextElement() + LINE_SEPERATOR);
-                // Add seperator to show that headers are complete
-                if (!headerLines.hasMoreElements()) {
-                    line += LINE_SEPERATOR;
-                }
-                currLine = line.getBytes("US-ASCII");
-                return true;
-            } catch (UnsupportedEncodingException e) {
-                // should never happen
-                throw new IOException("US-ASCII encoding not supported by this platform ?!");
-            }
-        } else {
-            return false;
-        }
-    }
-
-    @Override
-    public void close() throws IOException {
-        currLine = null;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/main/java/org/apache/james/core/JamesServerResourceLoader.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/main/java/org/apache/james/core/JamesServerResourceLoader.java b/server/container/core/src/main/java/org/apache/james/core/JamesServerResourceLoader.java
deleted file mode 100644
index 4b3e5cb..0000000
--- a/server/container/core/src/main/java/org/apache/james/core/JamesServerResourceLoader.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-package org.apache.james.core;
-
-import org.apache.james.filesystem.api.JamesDirectoriesProvider;
-
-public class JamesServerResourceLoader implements JamesDirectoriesProvider {
-
-    private final String rootDirectory;
-
-    public JamesServerResourceLoader(String rootDirectory) {
-        this.rootDirectory = rootDirectory;
-    }
-
-    /**
-     * @see org.apache.james.container.spring.resource.JamesResourceLoader#getAbsoluteDirectory()
-     */
-    public String getAbsoluteDirectory() {
-        return "/";
-    }
-
-    /**
-     * @see
-     * org.apache.james.container.spring.resource.JamesResourceLoader#getConfDirectory()
-     */
-    public String getConfDirectory() {
-        return getRootDirectory() + "/conf/";
-    }
-
-    /**
-     * @see
-     * org.apache.james.container.spring.resource.JamesResourceLoader#getVarDirectory()
-     */
-    public String getVarDirectory() {
-        return getRootDirectory() + "/var/";
-    }
-
-    /**
-     * Return the directory where the external jar libraries must be placed
-     * by the administrator. The jars may contain mailets, jdbc drivers,...
-     * 
-     * @return externalLibraryDirectory
-     */
-    public String getExternalLibraryDirectory() {
-        return getRootDirectory() + "/conf/lib/";
-    }
-
-    /**
-     * @see
-     * org.apache.james.container.spring.resource.JamesResourceLoader#getRootDirectory()
-     */
-    public String getRootDirectory() {
-        return rootDirectory;
-    }
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/container/core/src/main/java/org/apache/james/core/MailHeaders.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/main/java/org/apache/james/core/MailHeaders.java b/server/container/core/src/main/java/org/apache/james/core/MailHeaders.java
deleted file mode 100644
index 9603bc2..0000000
--- a/server/container/core/src/main/java/org/apache/james/core/MailHeaders.java
+++ /dev/null
@@ -1,187 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-
-package org.apache.james.core;
-
-import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.Serializable;
-import java.util.Enumeration;
-
-import javax.mail.MessagingException;
-import javax.mail.internet.InternetHeaders;
-
-import org.apache.mailet.base.RFC2822Headers;
-
-/**
- * This interface defines a container for mail headers. Each header must use
- * MIME format:
- * 
- * <pre>
- * name: value
- * </pre>
- */
-public class MailHeaders extends InternetHeaders implements Serializable, Cloneable {
-
-    private static final long serialVersionUID = 238748126601L;
-    private boolean modified = false;
-    private long size = -1;
-
-    /**
-     * No argument constructor
-     * 
-     * @throws MessagingException
-     *             if the super class cannot be properly instantiated
-     */
-    public MailHeaders() {
-        super();
-    }
-
-    /**
-     * Constructor that takes an InputStream containing the contents of the set
-     * of mail headers.
-     * 
-     * @param in
-     *            the InputStream containing the header data
-     * 
-     * @throws MessagingException
-     *             if the super class cannot be properly instantiated based on
-     *             the stream
-     */
-    public MailHeaders(InputStream in) throws MessagingException {
-        super();
-        load(in);
-    }
-
-    /**
-     * Write the headers to an output stream
-     * 
-     * @param out
-     *            the OutputStream to which to write the headers
-     */
-    @SuppressWarnings("unchecked")
-    public void writeTo(OutputStream out) throws MessagingException {
-        MimeMessageUtil.writeHeadersTo(getAllHeaderLines(), out);
-    }
-
-    /**
-     * Generate a representation of the headers as a series of bytes.
-     * 
-     * @return the byte array containing the headers
-     */
-    public byte[] toByteArray() throws MessagingException {
-        ByteArrayOutputStream headersBytes = new ByteArrayOutputStream();
-        writeTo(headersBytes);
-        return headersBytes.toByteArray();
-    }
-
-    /**
-     * Check if a particular header is present.
-     * 
-     * @return true if the header is present, false otherwise
-     */
-    public boolean isSet(String name) {
-        String[] value = super.getHeader(name);
-        return (value != null && value.length != 0);
-    }
-
-    /**
-     * If the new header is a Return-Path we get sure that we add it to the top
-     * Javamail, at least until 1.4.0 does the wrong thing if it loaded a stream
-     * with a return-path in the middle.
-     * 
-     * @see javax.mail.internet.InternetHeaders#addHeader(java.lang.String,
-     *      java.lang.String)
-     */
-    @SuppressWarnings("unchecked")
-    public synchronized void addHeader(String arg0, String arg1) {
-        if (RFC2822Headers.RETURN_PATH.equalsIgnoreCase(arg0)) {
-            headers.add(0, new InternetHeader(arg0, arg1));
-        } else {
-            super.addHeader(arg0, arg1);
-        }
-        modified();
-    }
-
-    /**
-     * If the new header is a Return-Path we get sure that we add it to the top
-     * Javamail, at least until 1.4.0 does the wrong thing if it loaded a stream
-     * with a return-path in the middle.
-     * 
-     * @see javax.mail.internet.InternetHeaders#setHeader(java.lang.String,
-     *      java.lang.String)
-     */
-    public synchronized void setHeader(String arg0, String arg1) {
-        if (RFC2822Headers.RETURN_PATH.equalsIgnoreCase(arg0)) {
-            super.removeHeader(arg0);
-        }
-        super.setHeader(arg0, arg1);
-
-        modified();
-    }
-
-    @Override
-    public synchronized void removeHeader(String name) {
-        super.removeHeader(name);
-        modified();
-    }
-
-    @Override
-    public synchronized void addHeaderLine(String line) {
-        super.addHeaderLine(line);
-        modified();
-    }
-
-    private void modified() {
-        modified = true;
-        size = -1;
-    }
-
-    /**
-     * Check if all REQUIRED headers fields as specified in RFC 822 are present.
-     * 
-     * @return true if the headers are present, false otherwise
-     */
-    public boolean isValid() {
-        return (isSet(RFC2822Headers.DATE) && isSet(RFC2822Headers.TO) && isSet(RFC2822Headers.FROM));
-    }
-
-    /**
-     * Return the size of the headers
-     * 
-     * @return size
-     */
-    @SuppressWarnings("unchecked")
-    public synchronized long getSize() {
-        if (size == -1 || modified) {
-            long c = 0;
-            Enumeration<String> headerLines = getAllHeaderLines();
-            while (headerLines.hasMoreElements()) {
-                c += headerLines.nextElement().length();
-                // CRLF
-                c += 2;
-            }
-            size = c;
-            modified = false;
-        }
-        return size;
-
-    }
-}


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


[06/23] james-project git commit: JAMES-2138 move MailAddress to a new james-core project

Posted by bt...@apache.org.
http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/delivery/LocalDeliveryTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/delivery/LocalDeliveryTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/delivery/LocalDeliveryTest.java
index 644be9f..c5c19d2 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/delivery/LocalDeliveryTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/delivery/LocalDeliveryTest.java
@@ -44,7 +44,7 @@ import org.apache.james.metrics.api.MetricFactory;
 import org.apache.james.transport.mailets.LocalDelivery;
 import org.apache.james.user.api.UsersRepository;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMailContext;
 import org.apache.mailet.base.test.FakeMailetConfig;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/delivery/MailDispatcherTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/delivery/MailDispatcherTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/delivery/MailDispatcherTest.java
index c855eff..19932f3 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/delivery/MailDispatcherTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/delivery/MailDispatcherTest.java
@@ -34,7 +34,7 @@ import javax.mail.internet.MimeMessage;
 
 import org.apache.commons.io.IOUtils;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.PerRecipientHeaders.Header;
 import org.apache.mailet.base.MailAddressFixture;
 import org.apache.mailet.base.RFC2822Headers;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/delivery/SieveIntegrationTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/delivery/SieveIntegrationTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/delivery/SieveIntegrationTest.java
index f333e20..7cb7c23 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/delivery/SieveIntegrationTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/delivery/SieveIntegrationTest.java
@@ -34,7 +34,7 @@ import org.apache.james.transport.mailets.Sieve;
 import org.apache.james.transport.mailets.jsieve.ResourceLocator;
 import org.apache.james.user.api.UsersRepository;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMailContext;
 import org.apache.mailet.base.test.FakeMailetConfig;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/delivery/SimpleMailStoreTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/delivery/SimpleMailStoreTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/delivery/SimpleMailStoreTest.java
index ebf9e9d..32a3844 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/delivery/SimpleMailStoreTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/delivery/SimpleMailStoreTest.java
@@ -30,7 +30,7 @@ import javax.mail.internet.MimeMessage;
 import org.apache.james.metrics.api.Metric;
 import org.apache.james.user.api.UsersRepository;
 import org.apache.james.user.api.UsersRepositoryException;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.MailAddressFixture;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.MimeMessageBuilder;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/delivery/ToRecipientFolderTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/delivery/ToRecipientFolderTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/delivery/ToRecipientFolderTest.java
index 7b8f15e..760909c 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/delivery/ToRecipientFolderTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/delivery/ToRecipientFolderTest.java
@@ -45,7 +45,7 @@ import org.apache.james.metrics.api.MetricFactory;
 import org.apache.james.transport.mailets.ToRecipientFolder;
 import org.apache.james.user.api.UsersRepository;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMailContext;
 import org.apache.mailet.base.test.FakeMailetConfig;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/managesieve/ManageSieveMailetTestCase.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/managesieve/ManageSieveMailetTestCase.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/managesieve/ManageSieveMailetTestCase.java
index 1f743ba..7095a4c 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/managesieve/ManageSieveMailetTestCase.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/managesieve/ManageSieveMailetTestCase.java
@@ -43,7 +43,7 @@ import org.apache.james.sieverepository.api.SieveRepository;
 import org.apache.james.sieverepository.api.exception.ScriptNotFoundException;
 import org.apache.james.user.api.UsersRepository;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMailContext;
 import org.apache.mailet.base.test.FakeMailetConfig;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/redirect/AddressExtractorTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/redirect/AddressExtractorTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/redirect/AddressExtractorTest.java
index f9db7eb..302a8a3 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/redirect/AddressExtractorTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/redirect/AddressExtractorTest.java
@@ -26,7 +26,7 @@ import java.util.List;
 import java.util.Optional;
 import javax.mail.MessagingException;
 
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.MailetContext;
 import org.junit.Before;
 import org.junit.Rule;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/redirect/MailModifierTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/redirect/MailModifierTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/redirect/MailModifierTest.java
index f996bf5..187847f 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/redirect/MailModifierTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/redirect/MailModifierTest.java
@@ -20,7 +20,7 @@ package org.apache.james.transport.mailets.redirect;
 
 import static org.mockito.Mockito.mock;
 
-import org.apache.james.core.MailImpl;
+import org.apache.james.server.core.MailImpl;
 import org.apache.james.dnsservice.api.DNSService;
 import org.junit.Rule;
 import org.junit.Test;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/redirect/NotifyMailetsMessageTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/redirect/NotifyMailetsMessageTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/redirect/NotifyMailetsMessageTest.java
index 0cdaca2..0619cf8 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/redirect/NotifyMailetsMessageTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/redirect/NotifyMailetsMessageTest.java
@@ -30,7 +30,7 @@ import javax.mail.Session;
 import javax.mail.internet.InternetAddress;
 import javax.mail.internet.MimeMessage;
 
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.test.FakeMail;
 import org.joda.time.DateTime;
 import org.junit.After;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/redirect/SpecialAddressTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/redirect/SpecialAddressTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/redirect/SpecialAddressTest.java
index ddddccb..6a4bf2c 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/redirect/SpecialAddressTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/redirect/SpecialAddressTest.java
@@ -21,7 +21,7 @@ package org.apache.james.transport.mailets.redirect;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.junit.Test;
 
 public class SpecialAddressTest {

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/remoteDelivery/InternetAddressConverterTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/remoteDelivery/InternetAddressConverterTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/remoteDelivery/InternetAddressConverterTest.java
index 9020533..a0326a4 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/remoteDelivery/InternetAddressConverterTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/remoteDelivery/InternetAddressConverterTest.java
@@ -23,7 +23,7 @@ import static org.assertj.core.api.Assertions.assertThat;
 
 import javax.mail.internet.InternetAddress;
 
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.MailAddressFixture;
 import org.junit.Rule;
 import org.junit.Test;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/InSpammerBlacklistTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/InSpammerBlacklistTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/InSpammerBlacklistTest.java
index 698960c..e4e2c58 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/InSpammerBlacklistTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/InSpammerBlacklistTest.java
@@ -31,7 +31,7 @@ import javax.mail.MessagingException;
 import org.apache.james.dnsservice.api.DNSService;
 import org.apache.james.dnsservice.api.mock.MockDNSService;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMatcherConfig;
 import org.junit.Test;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/IsOverQuotaTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/IsOverQuotaTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/IsOverQuotaTest.java
index 5acf65f..21afe44 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/IsOverQuotaTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/IsOverQuotaTest.java
@@ -42,7 +42,7 @@ import org.apache.james.mailbox.store.quota.CurrentQuotaCalculator;
 import org.apache.james.mailbox.store.quota.DefaultQuotaRootResolver;
 import org.apache.james.mailbox.store.quota.StoreQuotaManager;
 import org.apache.james.user.api.UsersRepository;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.MailAddressFixture;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMatcherConfig;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/RemoteAddrInNetworkTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/RemoteAddrInNetworkTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/RemoteAddrInNetworkTest.java
index fa8521d..ac631ed 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/RemoteAddrInNetworkTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/RemoteAddrInNetworkTest.java
@@ -27,7 +27,7 @@ import java.util.Collection;
 import javax.mail.MessagingException;
 
 import org.apache.james.dnsservice.api.mock.MockDNSService;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMatcherConfig;
 import org.junit.Before;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/RemoteAddrNotInNetworkTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/RemoteAddrNotInNetworkTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/RemoteAddrNotInNetworkTest.java
index 374c97a..f08db89 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/RemoteAddrNotInNetworkTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/RemoteAddrNotInNetworkTest.java
@@ -27,7 +27,7 @@ import java.util.Collection;
 import javax.mail.MessagingException;
 
 import org.apache.james.dnsservice.api.mock.MockDNSService;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMatcherConfig;
 import org.junit.Before;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/test/java/org/apache/james/transport/util/MailAddressUtilsTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/util/MailAddressUtilsTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/util/MailAddressUtilsTest.java
index 651c19c..4f1e862 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/util/MailAddressUtilsTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/util/MailAddressUtilsTest.java
@@ -25,7 +25,7 @@ import java.util.List;
 import javax.mail.internet.InternetAddress;
 
 import org.apache.james.transport.mailets.redirect.SpecialAddress;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/test/java/org/apache/james/transport/util/RecipientsUtilsTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/util/RecipientsUtilsTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/util/RecipientsUtilsTest.java
index 8649088..8f85bf7 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/util/RecipientsUtilsTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/util/RecipientsUtilsTest.java
@@ -31,7 +31,7 @@ import javax.mail.internet.MimeMessage.RecipientType;
 
 import org.apache.james.transport.mailets.redirect.RedirectNotify;
 import org.apache.james.transport.mailets.redirect.SpecialAddress;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.test.FakeMail;
 import org.junit.Before;
 import org.junit.Test;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/test/java/org/apache/james/transport/util/ReplyToUtilsTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/util/ReplyToUtilsTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/util/ReplyToUtilsTest.java
index 77ad785..5776782 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/util/ReplyToUtilsTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/util/ReplyToUtilsTest.java
@@ -22,7 +22,7 @@ import static org.assertj.core.api.Assertions.assertThat;
 import java.util.Optional;
 
 import org.apache.james.transport.mailets.redirect.SpecialAddress;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.test.FakeMail;
 import org.junit.Test;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/test/java/org/apache/james/transport/util/SenderUtilsTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/util/SenderUtilsTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/util/SenderUtilsTest.java
index 12994c3..fa0627e 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/util/SenderUtilsTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/util/SenderUtilsTest.java
@@ -22,7 +22,7 @@ import static org.assertj.core.api.Assertions.assertThat;
 import java.util.Optional;
 
 import org.apache.james.transport.mailets.redirect.SpecialAddress;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.test.FakeMail;
 import org.junit.Test;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/test/java/org/apache/james/transport/util/SpecialAddressesUtilsTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/util/SpecialAddressesUtilsTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/util/SpecialAddressesUtilsTest.java
index 550fdb3..15a2a48 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/util/SpecialAddressesUtilsTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/util/SpecialAddressesUtilsTest.java
@@ -31,7 +31,7 @@ import javax.mail.internet.MimeMessage;
 
 import org.apache.james.transport.mailets.redirect.RedirectNotify;
 import org.apache.james.transport.mailets.redirect.SpecialAddress;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.MailetContext;
 import org.apache.mailet.base.MailAddressFixture;
 import org.apache.mailet.base.RFC2822Headers;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/mailet/mailets/src/test/java/org/apache/james/transport/util/TosUtilsTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/util/TosUtilsTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/util/TosUtilsTest.java
index 21c8846..4e647e2 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/util/TosUtilsTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/util/TosUtilsTest.java
@@ -32,7 +32,7 @@ import javax.mail.internet.MimeMessage.RecipientType;
 
 import org.apache.james.transport.mailets.redirect.RedirectNotify;
 import org.apache.james.transport.mailets.redirect.SpecialAddress;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.test.FakeMail;
 import org.junit.Before;
 import org.junit.Test;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/protocols/fetchmail/src/main/java/org/apache/james/fetchmail/Account.java
----------------------------------------------------------------------
diff --git a/server/protocols/fetchmail/src/main/java/org/apache/james/fetchmail/Account.java b/server/protocols/fetchmail/src/main/java/org/apache/james/fetchmail/Account.java
index 9c6296f..631914d 100644
--- a/server/protocols/fetchmail/src/main/java/org/apache/james/fetchmail/Account.java
+++ b/server/protocols/fetchmail/src/main/java/org/apache/james/fetchmail/Account.java
@@ -26,7 +26,7 @@ import javax.mail.Session;
 import javax.mail.internet.ParseException;
 
 import org.apache.commons.configuration.ConfigurationException;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 
 /**
  * <p>

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/protocols/fetchmail/src/main/java/org/apache/james/fetchmail/MessageProcessor.java
----------------------------------------------------------------------
diff --git a/server/protocols/fetchmail/src/main/java/org/apache/james/fetchmail/MessageProcessor.java b/server/protocols/fetchmail/src/main/java/org/apache/james/fetchmail/MessageProcessor.java
index 8a7dbf2..a33eb59 100644
--- a/server/protocols/fetchmail/src/main/java/org/apache/james/fetchmail/MessageProcessor.java
+++ b/server/protocols/fetchmail/src/main/java/org/apache/james/fetchmail/MessageProcessor.java
@@ -32,11 +32,11 @@ import javax.mail.internet.InternetAddress;
 import javax.mail.internet.MimeMessage;
 import javax.mail.internet.ParseException;
 
-import org.apache.james.core.MailImpl;
+import org.apache.james.server.core.MailImpl;
 import org.apache.james.domainlist.api.DomainListException;
 import org.apache.james.user.api.UsersRepositoryException;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.RFC2822Headers;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/protocols/fetchmail/src/main/java/org/apache/james/fetchmail/ParsedConfiguration.java
----------------------------------------------------------------------
diff --git a/server/protocols/fetchmail/src/main/java/org/apache/james/fetchmail/ParsedConfiguration.java b/server/protocols/fetchmail/src/main/java/org/apache/james/fetchmail/ParsedConfiguration.java
index b0f540d..fb1e2f2 100644
--- a/server/protocols/fetchmail/src/main/java/org/apache/james/fetchmail/ParsedConfiguration.java
+++ b/server/protocols/fetchmail/src/main/java/org/apache/james/fetchmail/ParsedConfiguration.java
@@ -33,7 +33,7 @@ import org.apache.james.domainlist.api.DomainList;
 import org.apache.james.domainlist.api.DomainListException;
 import org.apache.james.queue.api.MailQueue;
 import org.apache.james.user.api.UsersRepository;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/protocols/fetchmail/src/main/java/org/apache/james/fetchmail/ProcessorAbstract.java
----------------------------------------------------------------------
diff --git a/server/protocols/fetchmail/src/main/java/org/apache/james/fetchmail/ProcessorAbstract.java b/server/protocols/fetchmail/src/main/java/org/apache/james/fetchmail/ProcessorAbstract.java
index 2e82905..7bee2a2 100644
--- a/server/protocols/fetchmail/src/main/java/org/apache/james/fetchmail/ProcessorAbstract.java
+++ b/server/protocols/fetchmail/src/main/java/org/apache/james/fetchmail/ProcessorAbstract.java
@@ -28,7 +28,7 @@ import javax.mail.Session;
 import org.apache.james.dnsservice.api.DNSService;
 import org.apache.james.queue.api.MailQueue;
 import org.apache.james.user.api.UsersRepository;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 
 /**
  * <p>

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/protocols/jmap/src/main/java/org/apache/james/jmap/UserProvisioningFilter.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/UserProvisioningFilter.java b/server/protocols/jmap/src/main/java/org/apache/james/jmap/UserProvisioningFilter.java
index 6857479..043a363 100644
--- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/UserProvisioningFilter.java
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/UserProvisioningFilter.java
@@ -38,7 +38,7 @@ import org.apache.james.metrics.api.TimeMetric;
 import org.apache.james.user.api.AlreadyExistInUsersRepositoryException;
 import org.apache.james.user.api.UsersRepository;
 import org.apache.james.user.api.UsersRepositoryException;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Throwables;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/protocols/jmap/src/main/java/org/apache/james/jmap/mailet/SentByJmap.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/mailet/SentByJmap.java b/server/protocols/jmap/src/main/java/org/apache/james/jmap/mailet/SentByJmap.java
index 68bcb55..53475c5 100644
--- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/mailet/SentByJmap.java
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/mailet/SentByJmap.java
@@ -25,7 +25,7 @@ import java.util.Collection;
 
 import org.apache.james.jmap.send.MailMetadata;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.GenericMatcher;
 
 import com.google.common.collect.ImmutableList;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/protocols/jmap/src/main/java/org/apache/james/jmap/mailet/VacationMailet.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/mailet/VacationMailet.java b/server/protocols/jmap/src/main/java/org/apache/james/jmap/mailet/VacationMailet.java
index 2ec52b3..1f47b14 100644
--- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/mailet/VacationMailet.java
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/mailet/VacationMailet.java
@@ -35,7 +35,7 @@ import org.apache.james.jmap.utils.MimeMessageBodyGenerator;
 import org.apache.james.util.CompletableFutureUtil;
 import org.apache.james.util.date.ZonedDateTimeProvider;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.AutomaticallySentMailDetector;
 import org.apache.mailet.base.GenericMailet;
 import org.slf4j.Logger;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/protocols/jmap/src/main/java/org/apache/james/jmap/mailet/VacationReply.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/mailet/VacationReply.java b/server/protocols/jmap/src/main/java/org/apache/james/jmap/mailet/VacationReply.java
index 9ad8e0f..6e01ce6 100644
--- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/mailet/VacationReply.java
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/mailet/VacationReply.java
@@ -27,7 +27,7 @@ import javax.mail.internet.MimeMessage;
 import org.apache.james.jmap.api.vacation.Vacation;
 import org.apache.james.jmap.utils.MimeMessageBodyGenerator;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.AutomaticallySentMailDetector;
 
 import com.github.fge.lambdas.Throwing;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/protocols/jmap/src/main/java/org/apache/james/jmap/send/MailFactory.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/send/MailFactory.java b/server/protocols/jmap/src/main/java/org/apache/james/jmap/send/MailFactory.java
index bbe5fa8..4fa46c5 100644
--- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/send/MailFactory.java
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/send/MailFactory.java
@@ -27,12 +27,12 @@ import java.util.stream.Collectors;
 import javax.mail.MessagingException;
 import javax.mail.internet.AddressException;
 
-import org.apache.james.core.MailImpl;
+import org.apache.james.server.core.MailImpl;
 import org.apache.james.jmap.model.Emailer;
 import org.apache.james.jmap.model.Message;
 import org.apache.james.jmap.model.MessageFactory.MetaDataWithContent;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/protocols/jmap/src/test/java/org/apache/james/jmap/mailet/SentByJmapTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/mailet/SentByJmapTest.java b/server/protocols/jmap/src/test/java/org/apache/james/jmap/mailet/SentByJmapTest.java
index f318565..ea25479 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/mailet/SentByJmapTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/mailet/SentByJmapTest.java
@@ -24,7 +24,7 @@ import static org.assertj.core.api.Assertions.assertThat;
 import java.util.Collection;
 
 import org.apache.james.jmap.send.MailMetadata;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.MailAddressFixture;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMailContext;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/protocols/jmap/src/test/java/org/apache/james/jmap/mailet/VacationMailetTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/mailet/VacationMailetTest.java b/server/protocols/jmap/src/test/java/org/apache/james/jmap/mailet/VacationMailetTest.java
index 5fc3297..6890acf 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/mailet/VacationMailetTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/mailet/VacationMailetTest.java
@@ -40,7 +40,7 @@ import org.apache.james.jmap.api.vacation.Vacation;
 import org.apache.james.jmap.api.vacation.VacationRepository;
 import org.apache.james.jmap.utils.MimeMessageBodyGenerator;
 import org.apache.james.util.date.ZonedDateTimeProvider;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.MailetContext;
 import org.apache.mailet.base.AutomaticallySentMailDetector;
 import org.apache.mailet.base.test.FakeMail;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/protocols/jmap/src/test/java/org/apache/james/jmap/mailet/VacationReplyTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/mailet/VacationReplyTest.java b/server/protocols/jmap/src/test/java/org/apache/james/jmap/mailet/VacationReplyTest.java
index 8174995..fd02f3c 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/mailet/VacationReplyTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/mailet/VacationReplyTest.java
@@ -35,7 +35,7 @@ import javax.mail.internet.MimeMessage;
 
 import org.apache.james.jmap.api.vacation.Vacation;
 import org.apache.james.jmap.utils.MimeMessageBodyGenerator;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.test.FakeMail;
 import org.hamcrest.BaseMatcher;
 import org.hamcrest.Description;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/protocols/jmap/src/test/java/org/apache/james/jmap/send/MailFactoryTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/send/MailFactoryTest.java b/server/protocols/jmap/src/test/java/org/apache/james/jmap/send/MailFactoryTest.java
index 81e3992..bec084b 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/send/MailFactoryTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/send/MailFactoryTest.java
@@ -41,7 +41,7 @@ import org.apache.james.mailbox.inmemory.InMemoryId;
 import org.apache.james.mailbox.model.TestMessageId;
 import org.apache.james.util.mime.MessageContentExtractor;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.junit.Before;
 import org.junit.Test;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/protocols/protocols-lmtp/src/main/java/org/apache/james/lmtpserver/DataLineLMTPHandler.java
----------------------------------------------------------------------
diff --git a/server/protocols/protocols-lmtp/src/main/java/org/apache/james/lmtpserver/DataLineLMTPHandler.java b/server/protocols/protocols-lmtp/src/main/java/org/apache/james/lmtpserver/DataLineLMTPHandler.java
index 98e885a..514effd 100644
--- a/server/protocols/protocols-lmtp/src/main/java/org/apache/james/lmtpserver/DataLineLMTPHandler.java
+++ b/server/protocols/protocols-lmtp/src/main/java/org/apache/james/lmtpserver/DataLineLMTPHandler.java
@@ -24,12 +24,13 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 
+import javax.mail.internet.AddressException;
+
+import org.apache.james.core.MailAddress;
 import org.apache.james.protocols.api.Response;
 import org.apache.james.protocols.api.handler.WiringException;
 import org.apache.james.protocols.lmtp.LMTPMultiResponse;
 import org.apache.james.protocols.lmtp.hook.DeliverToRecipientHook;
-import org.apache.james.protocols.smtp.MailAddress;
-import org.apache.james.protocols.smtp.MailAddressException;
 import org.apache.james.protocols.smtp.SMTPResponse;
 import org.apache.james.protocols.smtp.SMTPRetCode;
 import org.apache.james.protocols.smtp.SMTPSession;
@@ -53,12 +54,12 @@ public class DataLineLMTPHandler extends DataLineJamesMessageHookHandler {
         // build a wrapper around the Mail
         final ReadOnlyMailEnvelope env = new ReadOnlyMailEnvelope(mail);
 
-        for (org.apache.mailet.MailAddress recipient : mail.getRecipients()) {
+        for (MailAddress recipient : mail.getRecipients()) {
             // TODO: the transformation code between MailAddress is purely to compile. No idea if it does what it's supposed
             MailAddress recipientAddress;
             try {
                 recipientAddress = new MailAddress(recipient.getLocalPart(), recipient.getDomain());
-            } catch (MailAddressException e) {
+            } catch (AddressException e) {
                 throw new RuntimeException(e);
             }
             Response response = null;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/protocols/protocols-lmtp/src/main/java/org/apache/james/lmtpserver/hook/MailboxDeliverToRecipientHandler.java
----------------------------------------------------------------------
diff --git a/server/protocols/protocols-lmtp/src/main/java/org/apache/james/lmtpserver/hook/MailboxDeliverToRecipientHandler.java b/server/protocols/protocols-lmtp/src/main/java/org/apache/james/lmtpserver/hook/MailboxDeliverToRecipientHandler.java
index 32c8ab2..dd213e6 100644
--- a/server/protocols/protocols-lmtp/src/main/java/org/apache/james/lmtpserver/hook/MailboxDeliverToRecipientHandler.java
+++ b/server/protocols/protocols-lmtp/src/main/java/org/apache/james/lmtpserver/hook/MailboxDeliverToRecipientHandler.java
@@ -27,12 +27,12 @@ import javax.inject.Named;
 
 import org.apache.commons.configuration.Configuration;
 import org.apache.commons.configuration.ConfigurationException;
+import org.apache.james.core.MailAddress;
 import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.protocols.lmtp.hook.DeliverToRecipientHook;
-import org.apache.james.protocols.smtp.MailAddress;
 import org.apache.james.protocols.smtp.MailEnvelope;
 import org.apache.james.protocols.smtp.SMTPRetCode;
 import org.apache.james.protocols.smtp.SMTPSession;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/AddDefaultAttributesMessageHook.java
----------------------------------------------------------------------
diff --git a/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/AddDefaultAttributesMessageHook.java b/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/AddDefaultAttributesMessageHook.java
index d56ad6f..8cd5d67 100644
--- a/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/AddDefaultAttributesMessageHook.java
+++ b/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/AddDefaultAttributesMessageHook.java
@@ -20,7 +20,7 @@ package org.apache.james.smtpserver;
 
 import org.apache.commons.configuration.Configuration;
 import org.apache.commons.configuration.ConfigurationException;
-import org.apache.james.core.MailImpl;
+import org.apache.james.server.core.MailImpl;
 import org.apache.james.protocols.smtp.SMTPSession;
 import org.apache.james.protocols.smtp.hook.HookResult;
 import org.apache.james.protocols.smtp.hook.HookReturnCode;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/DataLineJamesMessageHookHandler.java
----------------------------------------------------------------------
diff --git a/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/DataLineJamesMessageHookHandler.java b/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/DataLineJamesMessageHookHandler.java
index 5c41c2b..f82523e 100644
--- a/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/DataLineJamesMessageHookHandler.java
+++ b/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/DataLineJamesMessageHookHandler.java
@@ -32,18 +32,13 @@ import javax.mail.internet.AddressException;
 
 import org.apache.commons.configuration.Configuration;
 import org.apache.commons.configuration.ConfigurationException;
-import org.apache.james.core.MailImpl;
-import org.apache.james.core.MimeMessageCopyOnWriteProxy;
-import org.apache.james.core.MimeMessageInputStream;
-import org.apache.james.core.MimeMessageInputStreamSource;
+import org.apache.james.core.MailAddress;
 import org.apache.james.lifecycle.api.LifecycleUtil;
 import org.apache.james.protocols.api.ProtocolSession.State;
 import org.apache.james.protocols.api.Response;
 import org.apache.james.protocols.api.handler.ExtensibleHandler;
 import org.apache.james.protocols.api.handler.LineHandler;
 import org.apache.james.protocols.api.handler.WiringException;
-import org.apache.james.protocols.smtp.MailAddress;
-import org.apache.james.protocols.smtp.MailAddressException;
 import org.apache.james.protocols.smtp.MailEnvelope;
 import org.apache.james.protocols.smtp.SMTPResponse;
 import org.apache.james.protocols.smtp.SMTPRetCode;
@@ -54,8 +49,11 @@ import org.apache.james.protocols.smtp.dsn.DSNStatus;
 import org.apache.james.protocols.smtp.hook.HookResult;
 import org.apache.james.protocols.smtp.hook.HookResultHook;
 import org.apache.james.protocols.smtp.hook.MessageHook;
+import org.apache.james.server.core.MailImpl;
+import org.apache.james.server.core.MimeMessageCopyOnWriteProxy;
+import org.apache.james.server.core.MimeMessageInputStream;
+import org.apache.james.server.core.MimeMessageInputStreamSource;
 import org.apache.james.smtpserver.model.MailetMailAddressAdapter;
-import org.apache.james.smtpserver.model.ProtocolMailAddressAdapter;
 import org.apache.mailet.Mail;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -102,7 +100,7 @@ public class DataLineJamesMessageHookHandler implements DataLineFilter, Extensib
                 List<MailAddress> recipientCollection = (List<MailAddress>) session.getAttachment(SMTPSession.RCPT_LIST, State.Transaction);
                 MailAddress mailAddress = (MailAddress) session.getAttachment(SMTPSession.SENDER, State.Transaction);
 
-                List<org.apache.mailet.MailAddress> rcpts = new ArrayList<>();
+                List<MailAddress> rcpts = new ArrayList<>();
                 for (MailAddress address : recipientCollection) {
                     rcpts.add(new MailetMailAddressAdapter(address));
                 }
@@ -275,10 +273,10 @@ public class DataLineJamesMessageHookHandler implements DataLineFilter, Extensib
         public List<MailAddress> getRecipients() {
             //TODO: not sure this MailAddress transformation code does the right thing
             List<MailAddress> mailAddressList = new ArrayList<>();
-            for (org.apache.mailet.MailAddress address : mail.getRecipients()) {
+            for (MailAddress address : mail.getRecipients()) {
                 try {
                     mailAddressList.add(new MailAddress(address.getLocalPart(), address.getDomain()));
-                } catch (MailAddressException ex) {
+                } catch (AddressException ex) {
                     throw new RuntimeException(ex);
                 }
             }
@@ -287,12 +285,7 @@ public class DataLineJamesMessageHookHandler implements DataLineFilter, Extensib
 
         @Override
         public MailAddress getSender() {
-            try {
-                return new ProtocolMailAddressAdapter(mail.getSender());
-            } catch (MailAddressException e) {
-                // should not occur here, cause it should have happened before
-                throw new RuntimeException(e);
-            }
+            return mail.getSender();
         }
 
         @Override

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/JamesDataCmdHandler.java
----------------------------------------------------------------------
diff --git a/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/JamesDataCmdHandler.java b/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/JamesDataCmdHandler.java
index 212e1bd..2d50b89 100644
--- a/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/JamesDataCmdHandler.java
+++ b/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/JamesDataCmdHandler.java
@@ -20,8 +20,8 @@ package org.apache.james.smtpserver;
 
 import javax.inject.Inject;
 
-import org.apache.james.core.MailImpl;
-import org.apache.james.core.MimeMessageInputStreamSource;
+import org.apache.james.server.core.MailImpl;
+import org.apache.james.server.core.MimeMessageInputStreamSource;
 import org.apache.james.metrics.api.MetricFactory;
 import org.apache.james.protocols.api.ProtocolSession.State;
 import org.apache.james.protocols.smtp.SMTPResponse;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/MailPriorityHandler.java
----------------------------------------------------------------------
diff --git a/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/MailPriorityHandler.java b/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/MailPriorityHandler.java
index 864c737..18d9ffd 100644
--- a/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/MailPriorityHandler.java
+++ b/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/MailPriorityHandler.java
@@ -33,7 +33,7 @@ import org.apache.james.protocols.smtp.hook.HookResult;
 import org.apache.james.protocols.smtp.hook.HookReturnCode;
 import org.apache.james.queue.api.MailPrioritySupport;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 
 /**
  * Handler which set a configured {@link Mail} priority for the mail.

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/SendMailHandler.java
----------------------------------------------------------------------
diff --git a/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/SendMailHandler.java b/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/SendMailHandler.java
index 2cf9d52..8a24d28 100644
--- a/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/SendMailHandler.java
+++ b/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/SendMailHandler.java
@@ -33,7 +33,7 @@ import org.apache.james.protocols.smtp.hook.HookReturnCode;
 import org.apache.james.queue.api.MailQueue;
 import org.apache.james.queue.api.MailQueueFactory;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/SenderAuthIdentifyVerificationRcptHook.java
----------------------------------------------------------------------
diff --git a/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/SenderAuthIdentifyVerificationRcptHook.java b/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/SenderAuthIdentifyVerificationRcptHook.java
index 8f9e027..60173c0 100644
--- a/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/SenderAuthIdentifyVerificationRcptHook.java
+++ b/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/SenderAuthIdentifyVerificationRcptHook.java
@@ -22,9 +22,9 @@ import javax.inject.Inject;
 
 import org.apache.commons.configuration.Configuration;
 import org.apache.commons.configuration.ConfigurationException;
+import org.apache.james.core.MailAddress;
 import org.apache.james.domainlist.api.DomainList;
 import org.apache.james.domainlist.api.DomainListException;
-import org.apache.james.protocols.smtp.MailAddress;
 import org.apache.james.protocols.smtp.SMTPSession;
 import org.apache.james.protocols.smtp.core.AbstractSenderAuthIdentifyVerificationRcptHook;
 import org.apache.james.protocols.smtp.hook.HookResult;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/fastfail/JDBCGreylistHandler.java
----------------------------------------------------------------------
diff --git a/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/fastfail/JDBCGreylistHandler.java b/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/fastfail/JDBCGreylistHandler.java
index 97c0a6d..e8fa8bf 100644
--- a/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/fastfail/JDBCGreylistHandler.java
+++ b/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/fastfail/JDBCGreylistHandler.java
@@ -37,11 +37,11 @@ import javax.sql.DataSource;
 
 import org.apache.commons.configuration.Configuration;
 import org.apache.commons.configuration.ConfigurationException;
+import org.apache.james.core.MailAddress;
 import org.apache.james.dnsservice.api.DNSService;
 import org.apache.james.dnsservice.library.netmatcher.NetMatcher;
 import org.apache.james.filesystem.api.FileSystem;
 import org.apache.james.protocols.api.handler.ProtocolHandler;
-import org.apache.james.protocols.smtp.MailAddress;
 import org.apache.james.protocols.smtp.SMTPSession;
 import org.apache.james.protocols.smtp.core.fastfail.AbstractGreylistHandler;
 import org.apache.james.protocols.smtp.hook.HookResult;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/fastfail/SPFHandler.java
----------------------------------------------------------------------
diff --git a/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/fastfail/SPFHandler.java b/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/fastfail/SPFHandler.java
index 523f8b6..f5f3e2e 100644
--- a/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/fastfail/SPFHandler.java
+++ b/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/fastfail/SPFHandler.java
@@ -22,6 +22,7 @@ import javax.inject.Inject;
 
 import org.apache.commons.configuration.Configuration;
 import org.apache.commons.configuration.ConfigurationException;
+import org.apache.james.core.MailAddress;
 import org.apache.james.jspf.core.DNSService;
 import org.apache.james.jspf.core.exceptions.SPFErrorConstants;
 import org.apache.james.jspf.executor.SPFResult;
@@ -29,7 +30,6 @@ import org.apache.james.jspf.impl.DefaultSPF;
 import org.apache.james.jspf.impl.SPF;
 import org.apache.james.protocols.api.ProtocolSession.State;
 import org.apache.james.protocols.api.handler.ProtocolHandler;
-import org.apache.james.protocols.smtp.MailAddress;
 import org.apache.james.protocols.smtp.SMTPRetCode;
 import org.apache.james.protocols.smtp.SMTPSession;
 import org.apache.james.protocols.smtp.dsn.DSNStatus;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/fastfail/ValidRcptHandler.java
----------------------------------------------------------------------
diff --git a/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/fastfail/ValidRcptHandler.java b/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/fastfail/ValidRcptHandler.java
index 7d4362f..882f0c0 100644
--- a/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/fastfail/ValidRcptHandler.java
+++ b/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/fastfail/ValidRcptHandler.java
@@ -22,10 +22,10 @@ import javax.inject.Inject;
 
 import org.apache.commons.configuration.Configuration;
 import org.apache.commons.configuration.ConfigurationException;
+import org.apache.james.core.MailAddress;
 import org.apache.james.domainlist.api.DomainList;
 import org.apache.james.domainlist.api.DomainListException;
 import org.apache.james.protocols.api.handler.ProtocolHandler;
-import org.apache.james.protocols.smtp.MailAddress;
 import org.apache.james.protocols.smtp.SMTPSession;
 import org.apache.james.protocols.smtp.core.fastfail.AbstractValidRcptHandler;
 import org.apache.james.rrt.api.RecipientRewriteTable;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/fastfail/ValidRcptMX.java
----------------------------------------------------------------------
diff --git a/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/fastfail/ValidRcptMX.java b/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/fastfail/ValidRcptMX.java
index 2047306..10df4e1 100644
--- a/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/fastfail/ValidRcptMX.java
+++ b/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/fastfail/ValidRcptMX.java
@@ -27,11 +27,11 @@ import javax.inject.Inject;
 
 import org.apache.commons.configuration.Configuration;
 import org.apache.commons.configuration.ConfigurationException;
+import org.apache.james.core.MailAddress;
 import org.apache.james.dnsservice.api.DNSService;
 import org.apache.james.dnsservice.api.TemporaryResolutionException;
 import org.apache.james.dnsservice.library.netmatcher.NetMatcher;
 import org.apache.james.protocols.api.handler.ProtocolHandler;
-import org.apache.james.protocols.smtp.MailAddress;
 import org.apache.james.protocols.smtp.SMTPRetCode;
 import org.apache.james.protocols.smtp.SMTPSession;
 import org.apache.james.protocols.smtp.dsn.DSNStatus;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/model/MailetMailAddressAdapter.java
----------------------------------------------------------------------
diff --git a/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/model/MailetMailAddressAdapter.java b/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/model/MailetMailAddressAdapter.java
index 4eaede1..1acb936 100644
--- a/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/model/MailetMailAddressAdapter.java
+++ b/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/model/MailetMailAddressAdapter.java
@@ -20,13 +20,13 @@ package org.apache.james.smtpserver.model;
 
 import javax.mail.internet.AddressException;
 
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 
 public class MailetMailAddressAdapter extends MailAddress {
     
     private static final long serialVersionUID = 1L;
 
-    public MailetMailAddressAdapter(org.apache.james.protocols.smtp.MailAddress mailAddress) throws AddressException {
+    public MailetMailAddressAdapter(MailAddress mailAddress) throws AddressException {
         super(mailAddress.getLocalPart(), mailAddress.getDomain());
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/model/ProtocolMailAddressAdapter.java
----------------------------------------------------------------------
diff --git a/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/model/ProtocolMailAddressAdapter.java b/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/model/ProtocolMailAddressAdapter.java
index 8aa0019..a128f04 100644
--- a/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/model/ProtocolMailAddressAdapter.java
+++ b/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/model/ProtocolMailAddressAdapter.java
@@ -18,13 +18,15 @@
  ****************************************************************/
 package org.apache.james.smtpserver.model;
 
-import org.apache.james.protocols.smtp.MailAddress;
-import org.apache.james.protocols.smtp.MailAddressException;
+import javax.mail.internet.AddressException;
 
+import org.apache.james.core.MailAddress;
+
+@Deprecated
 public class ProtocolMailAddressAdapter extends MailAddress {
     
-    public ProtocolMailAddressAdapter(org.apache.mailet.MailAddress mailAddress) throws MailAddressException {
-        super(mailAddress.toString());
+    public ProtocolMailAddressAdapter(MailAddress mailAddress) throws AddressException {
+        super(mailAddress.asString());
     }
 
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java b/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java
index 98bbbd1..ce4b504 100644
--- a/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java
+++ b/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java
@@ -69,7 +69,7 @@ import org.apache.james.user.api.UsersRepository;
 import org.apache.james.user.lib.mock.InMemoryUsersRepository;
 import org.apache.mailet.HostAddress;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Ignore;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SPFHandlerTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SPFHandlerTest.java b/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SPFHandlerTest.java
index 3018bee..243536e 100644
--- a/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SPFHandlerTest.java
+++ b/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SPFHandlerTest.java
@@ -24,10 +24,10 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 
+import org.apache.james.core.MailAddress;
 import org.apache.james.jspf.core.DNSRequest;
 import org.apache.james.jspf.core.DNSService;
 import org.apache.james.jspf.core.exceptions.TimeoutException;
-import org.apache.james.protocols.smtp.MailAddress;
 import org.apache.james.protocols.smtp.SMTPSession;
 import org.apache.james.protocols.smtp.hook.HookReturnCode;
 import org.apache.james.protocols.smtp.utils.BaseFakeSMTPSession;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/Util.java
----------------------------------------------------------------------
diff --git a/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/Util.java b/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/Util.java
index ec007af..e46f5d5 100644
--- a/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/Util.java
+++ b/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/Util.java
@@ -26,7 +26,7 @@ import javax.mail.internet.MimeMessage;
 import javax.mail.internet.ParseException;
 import org.apache.james.smtpserver.mock.MockMimeMessage;
 import org.apache.james.smtpserver.mock.mailet.MockMail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 
 /**
  * some utilities for James unit testing

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/ValidRcptHandlerTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/ValidRcptHandlerTest.java b/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/ValidRcptHandlerTest.java
index 79a8589..34efb66 100644
--- a/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/ValidRcptHandlerTest.java
+++ b/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/ValidRcptHandlerTest.java
@@ -25,9 +25,9 @@ import java.util.Arrays;
 import java.util.HashMap;
 import java.util.Map;
 
+import org.apache.james.core.MailAddress;
 import org.apache.james.domainlist.api.mock.SimpleDomainList;
 import org.apache.james.protocols.api.ProtocolSession.State;
-import org.apache.james.protocols.smtp.MailAddress;
 import org.apache.james.protocols.smtp.SMTPConfiguration;
 import org.apache.james.protocols.smtp.SMTPSession;
 import org.apache.james.protocols.smtp.hook.HookReturnCode;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/ValidRcptMXTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/ValidRcptMXTest.java b/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/ValidRcptMXTest.java
index 523dc9c..ab94a2d 100644
--- a/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/ValidRcptMXTest.java
+++ b/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/ValidRcptMXTest.java
@@ -26,12 +26,9 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
 
-import javax.mail.internet.ParseException;
-
+import org.apache.james.core.MailAddress;
 import org.apache.james.dnsservice.api.DNSService;
 import org.apache.james.dnsservice.api.mock.MockDNSService;
-import org.apache.james.protocols.smtp.MailAddress;
-import org.apache.james.protocols.smtp.MailAddressException;
 import org.apache.james.protocols.smtp.SMTPSession;
 import org.apache.james.protocols.smtp.hook.HookReturnCode;
 import org.apache.james.protocols.smtp.utils.BaseFakeSMTPSession;
@@ -103,7 +100,7 @@ public class ValidRcptMXTest {
     }
 
     @Test
-    public void testRejectLoopbackMX() throws ParseException, MailAddressException {
+    public void testRejectLoopbackMX() throws Exception {
         Collection<String> bNetworks = new ArrayList<>();
         bNetworks.add("127.0.0.1");
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/mock/mailet/MockMail.java
----------------------------------------------------------------------
diff --git a/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/mock/mailet/MockMail.java b/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/mock/mailet/MockMail.java
index 6f1aac2..e66fed8 100644
--- a/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/mock/mailet/MockMail.java
+++ b/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/mock/mailet/MockMail.java
@@ -30,7 +30,7 @@ import javax.mail.internet.MimeMessage;
 
 import org.apache.commons.lang.NotImplementedException;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.PerRecipientHeaders;
 import org.apache.mailet.PerRecipientHeaders.Header;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/mock/mailet/MockMailContext.java
----------------------------------------------------------------------
diff --git a/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/mock/mailet/MockMailContext.java b/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/mock/mailet/MockMailContext.java
index 2686fd8..9e1b342 100644
--- a/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/mock/mailet/MockMailContext.java
+++ b/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/mock/mailet/MockMailContext.java
@@ -29,7 +29,7 @@ import javax.mail.internet.MimeMessage;
 import org.apache.mailet.HostAddress;
 import org.apache.mailet.LookupException;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.apache.mailet.MailetContext;
 import org.slf4j.Logger;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/WebAdminServerIntegrationTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/WebAdminServerIntegrationTest.java b/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/WebAdminServerIntegrationTest.java
index 028f8b3..919ac42 100644
--- a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/WebAdminServerIntegrationTest.java
+++ b/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/WebAdminServerIntegrationTest.java
@@ -271,4 +271,6 @@ public class WebAdminServerIntegrationTest {
         ;
     }
 
+    //TODO: check Groups full path
+
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/protocols/webadmin/webadmin-data/pom.xml
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-data/pom.xml b/server/protocols/webadmin/webadmin-data/pom.xml
index fc67952..6f302db 100644
--- a/server/protocols/webadmin/webadmin-data/pom.xml
+++ b/server/protocols/webadmin/webadmin-data/pom.xml
@@ -35,6 +35,10 @@
     <dependencies>
         <dependency>
             <groupId>${project.groupId}</groupId>
+            <artifactId>james-core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
             <artifactId>james-server-data-api</artifactId>
         </dependency>
         <dependency>

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/queue/queue-activemq/src/main/java/org/apache/james/queue/activemq/ActiveMQMailQueue.java
----------------------------------------------------------------------
diff --git a/server/queue/queue-activemq/src/main/java/org/apache/james/queue/activemq/ActiveMQMailQueue.java b/server/queue/queue-activemq/src/main/java/org/apache/james/queue/activemq/ActiveMQMailQueue.java
index bd41981..7e35cdb 100644
--- a/server/queue/queue-activemq/src/main/java/org/apache/james/queue/activemq/ActiveMQMailQueue.java
+++ b/server/queue/queue-activemq/src/main/java/org/apache/james/queue/activemq/ActiveMQMailQueue.java
@@ -40,9 +40,9 @@ import org.apache.activemq.ActiveMQSession;
 import org.apache.activemq.BlobMessage;
 import org.apache.activemq.command.ActiveMQBlobMessage;
 import org.apache.activemq.util.JMSExceptionSupport;
-import org.apache.james.core.MimeMessageCopyOnWriteProxy;
-import org.apache.james.core.MimeMessageInputStream;
-import org.apache.james.core.MimeMessageSource;
+import org.apache.james.server.core.MimeMessageCopyOnWriteProxy;
+import org.apache.james.server.core.MimeMessageInputStream;
+import org.apache.james.server.core.MimeMessageSource;
 import org.apache.james.metrics.api.MetricFactory;
 import org.apache.james.queue.api.MailQueue;
 import org.apache.james.queue.api.MailQueueItemDecoratorFactory;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/queue/queue-activemq/src/main/java/org/apache/james/queue/activemq/MimeMessageBlobMessageSource.java
----------------------------------------------------------------------
diff --git a/server/queue/queue-activemq/src/main/java/org/apache/james/queue/activemq/MimeMessageBlobMessageSource.java b/server/queue/queue-activemq/src/main/java/org/apache/james/queue/activemq/MimeMessageBlobMessageSource.java
index d1f1aef..e8153ec 100644
--- a/server/queue/queue-activemq/src/main/java/org/apache/james/queue/activemq/MimeMessageBlobMessageSource.java
+++ b/server/queue/queue-activemq/src/main/java/org/apache/james/queue/activemq/MimeMessageBlobMessageSource.java
@@ -24,7 +24,7 @@ import java.io.InputStream;
 import javax.jms.JMSException;
 
 import org.apache.activemq.BlobMessage;
-import org.apache.james.core.MimeMessageSource;
+import org.apache.james.server.core.MimeMessageSource;
 
 /**
  *
@@ -40,7 +40,7 @@ public class MimeMessageBlobMessageSource extends MimeMessageSource implements A
     }
 
     /**
-     * @see org.apache.james.core.MimeMessageSource#getInputStream()
+     * @see org.apache.james.server.core.MimeMessageSource#getInputStream()
      */
     public InputStream getInputStream() throws IOException {
         try {
@@ -51,7 +51,7 @@ public class MimeMessageBlobMessageSource extends MimeMessageSource implements A
     }
 
     /**
-     * @see org.apache.james.core.MimeMessageSource#getSourceId()
+     * @see org.apache.james.server.core.MimeMessageSource#getSourceId()
      */
     public String getSourceId() {
         return sourceId;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/queue/queue-api/src/test/java/org/apache/james/queue/api/mock/MockMailQueue.java
----------------------------------------------------------------------
diff --git a/server/queue/queue-api/src/test/java/org/apache/james/queue/api/mock/MockMailQueue.java b/server/queue/queue-api/src/test/java/org/apache/james/queue/api/mock/MockMailQueue.java
index 0ec3281..6488e80 100644
--- a/server/queue/queue-api/src/test/java/org/apache/james/queue/api/mock/MockMailQueue.java
+++ b/server/queue/queue-api/src/test/java/org/apache/james/queue/api/mock/MockMailQueue.java
@@ -31,7 +31,7 @@ import java.util.concurrent.TimeUnit;
 import javax.mail.MessagingException;
 
 import org.apache.commons.io.IOUtils;
-import org.apache.james.core.MailImpl;
+import org.apache.james.server.core.MailImpl;
 import org.apache.james.queue.api.MailQueue;
 import org.apache.mailet.Mail;
 import org.slf4j.Logger;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/queue/queue-file/src/main/java/org/apache/james/queue/file/FileMailQueue.java
----------------------------------------------------------------------
diff --git a/server/queue/queue-file/src/main/java/org/apache/james/queue/file/FileMailQueue.java b/server/queue/queue-file/src/main/java/org/apache/james/queue/file/FileMailQueue.java
index 7a14a4b..076d96e 100644
--- a/server/queue/queue-file/src/main/java/org/apache/james/queue/file/FileMailQueue.java
+++ b/server/queue/queue-file/src/main/java/org/apache/james/queue/file/FileMailQueue.java
@@ -41,8 +41,8 @@ import javax.mail.util.SharedFileInputStream;
 
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.IOUtils;
-import org.apache.james.core.MimeMessageCopyOnWriteProxy;
-import org.apache.james.core.MimeMessageSource;
+import org.apache.james.server.core.MimeMessageCopyOnWriteProxy;
+import org.apache.james.server.core.MimeMessageSource;
 import org.apache.james.lifecycle.api.Disposable;
 import org.apache.james.lifecycle.api.LifecycleUtil;
 import org.apache.james.queue.api.MailQueueItemDecoratorFactory;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/queue/queue-jms/src/main/java/org/apache/james/queue/jms/JMSMailQueue.java
----------------------------------------------------------------------
diff --git a/server/queue/queue-jms/src/main/java/org/apache/james/queue/jms/JMSMailQueue.java b/server/queue/queue-jms/src/main/java/org/apache/james/queue/jms/JMSMailQueue.java
index f39653d..4cd4f02 100644
--- a/server/queue/queue-jms/src/main/java/org/apache/james/queue/jms/JMSMailQueue.java
+++ b/server/queue/queue-jms/src/main/java/org/apache/james/queue/jms/JMSMailQueue.java
@@ -47,8 +47,8 @@ import javax.mail.MessagingException;
 import javax.mail.internet.AddressException;
 import javax.mail.internet.MimeMessage;
 
-import org.apache.james.core.MailImpl;
-import org.apache.james.core.MimeMessageCopyOnWriteProxy;
+import org.apache.james.server.core.MailImpl;
+import org.apache.james.server.core.MimeMessageCopyOnWriteProxy;
 import org.apache.james.lifecycle.api.Disposable;
 import org.apache.james.metrics.api.Metric;
 import org.apache.james.metrics.api.MetricFactory;
@@ -58,7 +58,7 @@ import org.apache.james.queue.api.MailQueue;
 import org.apache.james.queue.api.MailQueueItemDecoratorFactory;
 import org.apache.james.queue.api.ManageableMailQueue;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/queue/queue-jms/src/main/java/org/apache/james/queue/jms/MimeMessageObjectMessageSource.java
----------------------------------------------------------------------
diff --git a/server/queue/queue-jms/src/main/java/org/apache/james/queue/jms/MimeMessageObjectMessageSource.java b/server/queue/queue-jms/src/main/java/org/apache/james/queue/jms/MimeMessageObjectMessageSource.java
index 0b223dd..2a70a98 100644
--- a/server/queue/queue-jms/src/main/java/org/apache/james/queue/jms/MimeMessageObjectMessageSource.java
+++ b/server/queue/queue-jms/src/main/java/org/apache/james/queue/jms/MimeMessageObjectMessageSource.java
@@ -26,7 +26,7 @@ import javax.jms.ObjectMessage;
 import javax.mail.util.SharedByteArrayInputStream;
 
 import org.apache.commons.io.IOUtils;
-import org.apache.james.core.MimeMessageSource;
+import org.apache.james.server.core.MimeMessageSource;
 import org.apache.james.lifecycle.api.Disposable;
 import org.apache.james.lifecycle.api.LifecycleUtil;
 import org.slf4j.Logger;

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/queue/queue-jms/src/main/java/org/apache/james/queue/library/MailQueueManagement.java
----------------------------------------------------------------------
diff --git a/server/queue/queue-jms/src/main/java/org/apache/james/queue/library/MailQueueManagement.java b/server/queue/queue-jms/src/main/java/org/apache/james/queue/library/MailQueueManagement.java
index e0b042a..1348388 100644
--- a/server/queue/queue-jms/src/main/java/org/apache/james/queue/library/MailQueueManagement.java
+++ b/server/queue/queue-jms/src/main/java/org/apache/james/queue/library/MailQueueManagement.java
@@ -41,7 +41,7 @@ import org.apache.james.queue.api.ManageableMailQueue.MailQueueItemView;
 import org.apache.james.queue.api.ManageableMailQueue.MailQueueIterator;
 import org.apache.james.queue.api.ManageableMailQueue.Type;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import org.apache.james.core.MailAddress;
 
 /**
  * JMX MBean implementation which expose management functions by wrapping a

http://git-wip-us.apache.org/repos/asf/james-project/blob/936746b9/server/queue/queue-jms/src/test/java/org/apache/james/queue/jms/AbstractJMSMailQueueTest.java
----------------------------------------------------------------------
diff --git a/server/queue/queue-jms/src/test/java/org/apache/james/queue/jms/AbstractJMSMailQueueTest.java b/server/queue/queue-jms/src/test/java/org/apache/james/queue/jms/AbstractJMSMailQueueTest.java
index 1e2af52..56211d8 100644
--- a/server/queue/queue-jms/src/test/java/org/apache/james/queue/jms/AbstractJMSMailQueueTest.java
+++ b/server/queue/queue-jms/src/test/java/org/apache/james/queue/jms/AbstractJMSMailQueueTest.java
@@ -38,16 +38,15 @@ import javax.mail.Session;
 import javax.mail.internet.MimeMessage;
 
 import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.james.core.MailImpl;
+import org.apache.james.core.MailAddress;
 import org.apache.james.metrics.api.NoopMetricFactory;
-import org.apache.james.protocols.smtp.MailAddressException;
 import org.apache.james.queue.api.MailQueue.MailQueueItem;
 import org.apache.james.queue.api.MailQueueItemDecoratorFactory;
 import org.apache.james.queue.api.ManageableMailQueue;
 import org.apache.james.queue.api.ManageableMailQueue.MailQueueIterator;
 import org.apache.james.queue.api.RawMailQueueItemDecoratorFactory;
+import org.apache.james.server.core.MailImpl;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -76,7 +75,7 @@ public abstract class AbstractJMSMailQueueTest {
     }
 
     @Test
-    public void testFIFO() throws MessagingException, InterruptedException, IOException, MailAddressException {
+    public void testFIFO() throws Exception {
         // should be empty
         assertEquals(0, queue.getSize());
 
@@ -116,7 +115,7 @@ public abstract class AbstractJMSMailQueueTest {
     }
 
     @Test
-    public void testDelayedDeQueue() throws MessagingException, InterruptedException, IOException, MailAddressException {
+    public void testDelayedDeQueue() throws Exception {
         // should be empty
         assertEquals(0, queue.getSize());
 
@@ -151,7 +150,7 @@ public abstract class AbstractJMSMailQueueTest {
     }
 
     @Test
-    public void testFlush() throws MessagingException, InterruptedException, IOException, MailAddressException {
+    public void testFlush() throws Exception {
         // should be empty
         assertEquals(0, queue.getSize());
 
@@ -190,7 +189,7 @@ public abstract class AbstractJMSMailQueueTest {
     }
 
     @Test
-    public void testRemoveWithRecipient() throws MessagingException, InterruptedException, MailAddressException {
+    public void testRemoveWithRecipient() throws Exception {
         assertEquals(0, queue.getSize());
 
         Mail mail = createMail();
@@ -216,7 +215,7 @@ public abstract class AbstractJMSMailQueueTest {
     }
 
     @Test
-    public void testRemoveWithSender() throws MessagingException, InterruptedException, MailAddressException {
+    public void testRemoveWithSender() throws Exception {
         assertEquals(0, queue.getSize());
 
         MailImpl mail = createMail();
@@ -242,7 +241,7 @@ public abstract class AbstractJMSMailQueueTest {
     }
 
     @Test
-    public void testRemoveWithName() throws MessagingException, InterruptedException, MailAddressException {
+    public void testRemoveWithName() throws Exception {
         assertEquals(0, queue.getSize());
 
         MailImpl mail = createMail();
@@ -318,7 +317,7 @@ public abstract class AbstractJMSMailQueueTest {
     }
 
     @Test
-    public void testPrioritySupport() throws InterruptedException, MessagingException, IOException, MailAddressException {
+    public void testPrioritySupport() throws Exception {
         // should be empty
         assertEquals(0, queue.getSize());
 
@@ -353,7 +352,7 @@ public abstract class AbstractJMSMailQueueTest {
     }
 
     @Test
-    public void testBrowse() throws MessagingException, InterruptedException, IOException, MailAddressException {
+    public void testBrowse() throws Exception {
         // should be empty
         assertEquals(0, queue.getSize());
 


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


[02/23] james-project git commit: JAMES-2138 Top-level entities are usually in plural form

Posted by bt...@apache.org.
JAMES-2138 Top-level entities are usually in plural form


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/840a885c
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/840a885c
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/840a885c

Branch: refs/heads/master
Commit: 840a885caf0bc5761e4d52f835a3df4626dea429
Parents: 73b650e
Author: Matthieu Baechler <ma...@apache.org>
Authored: Mon Sep 4 10:17:42 2017 +0200
Committer: benwa <bt...@linagora.com>
Committed: Sat Sep 9 10:40:29 2017 +0700

----------------------------------------------------------------------
 .../james/modules/server/DataRoutesModules.java |   4 +-
 .../integration/JwtFilterIntegrationTest.java   |   4 +-
 .../WebAdminServerIntegrationTest.java          |   4 +-
 .../james/webadmin/routes/DomainRoutes.java     | 191 -----------
 .../james/webadmin/routes/DomainsRoutes.java    | 191 +++++++++++
 .../james/webadmin/routes/DomainRoutesTest.java | 319 -------------------
 .../webadmin/routes/DomainsRoutesTest.java      | 319 +++++++++++++++++++
 7 files changed, 516 insertions(+), 516 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/840a885c/server/container/guice/protocols/webadmin-data/src/main/java/org/apache/james/modules/server/DataRoutesModules.java
----------------------------------------------------------------------
diff --git a/server/container/guice/protocols/webadmin-data/src/main/java/org/apache/james/modules/server/DataRoutesModules.java b/server/container/guice/protocols/webadmin-data/src/main/java/org/apache/james/modules/server/DataRoutesModules.java
index 3fb6669..48233d7 100644
--- a/server/container/guice/protocols/webadmin-data/src/main/java/org/apache/james/modules/server/DataRoutesModules.java
+++ b/server/container/guice/protocols/webadmin-data/src/main/java/org/apache/james/modules/server/DataRoutesModules.java
@@ -20,7 +20,7 @@
 package org.apache.james.modules.server;
 
 import org.apache.james.webadmin.Routes;
-import org.apache.james.webadmin.routes.DomainRoutes;
+import org.apache.james.webadmin.routes.DomainsRoutes;
 import org.apache.james.webadmin.routes.UserRoutes;
 
 import com.google.inject.AbstractModule;
@@ -31,7 +31,7 @@ public class DataRoutesModules extends AbstractModule {
     @Override
     protected void configure() {
         Multibinder<Routes> routesMultibinder = Multibinder.newSetBinder(binder(), Routes.class);
-        routesMultibinder.addBinding().to(DomainRoutes.class);
+        routesMultibinder.addBinding().to(DomainsRoutes.class);
         routesMultibinder.addBinding().to(UserRoutes.class);
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/840a885c/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/JwtFilterIntegrationTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/JwtFilterIntegrationTest.java b/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/JwtFilterIntegrationTest.java
index e15f178..97e6deb 100644
--- a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/JwtFilterIntegrationTest.java
+++ b/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/JwtFilterIntegrationTest.java
@@ -36,7 +36,7 @@ import org.apache.james.utils.DataProbeImpl;
 import org.apache.james.utils.WebAdminGuiceProbe;
 import org.apache.james.webadmin.authentication.AuthenticationFilter;
 import org.apache.james.webadmin.authentication.JwtFilter;
-import org.apache.james.webadmin.routes.DomainRoutes;
+import org.apache.james.webadmin.routes.DomainsRoutes;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.ClassRule;
@@ -52,7 +52,7 @@ import com.jayway.restassured.response.Header;
 public class JwtFilterIntegrationTest {
 
     private static final String DOMAIN = "domain";
-    private static final String SPECIFIC_DOMAIN = DomainRoutes.DOMAINS + SEPARATOR + DOMAIN;
+    private static final String SPECIFIC_DOMAIN = DomainsRoutes.DOMAINS + SEPARATOR + DOMAIN;
     private static final String VALID_TOKEN_ADMIN_TRUE = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJhZG1pbkBvcGVuL" +
         "XBhYXMub3JnIiwiYWRtaW4iOnRydWUsImlhdCI6MTQ4OTAzODQzOH0.rgxCkdWEa-92a4R-72a9Z49k4LRvQDShgci5Y7qWRUP9IGJCK-lMkrHF" +
         "4H0a6L87BYppxVW701zaZ6dNxRMvHnjLBBWnPsC2B0rkkr2hEL2zfz7sb-iNGV-J4ICx97t8-TfQ5rz3VOX0FwdusPL_rJtmlGEGRivPkR6_aBe1" +

http://git-wip-us.apache.org/repos/asf/james-project/blob/840a885c/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/WebAdminServerIntegrationTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/WebAdminServerIntegrationTest.java b/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/WebAdminServerIntegrationTest.java
index bb243cc..028f8b3 100644
--- a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/WebAdminServerIntegrationTest.java
+++ b/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/WebAdminServerIntegrationTest.java
@@ -35,7 +35,7 @@ import org.apache.james.modules.MailboxProbeImpl;
 import org.apache.james.probe.DataProbe;
 import org.apache.james.utils.DataProbeImpl;
 import org.apache.james.utils.WebAdminGuiceProbe;
-import org.apache.james.webadmin.routes.DomainRoutes;
+import org.apache.james.webadmin.routes.DomainsRoutes;
 import org.apache.james.webadmin.routes.UserMailboxesRoutes;
 import org.apache.james.webadmin.routes.UserRoutes;
 import org.apache.james.webadmin.swagger.routes.SwaggerRoutes;
@@ -54,7 +54,7 @@ public class WebAdminServerIntegrationTest {
 
     public static final String DOMAIN = "domain";
     public static final String USERNAME = "username@" + DOMAIN;
-    public static final String SPECIFIC_DOMAIN = DomainRoutes.DOMAINS + SEPARATOR + DOMAIN;
+    public static final String SPECIFIC_DOMAIN = DomainsRoutes.DOMAINS + SEPARATOR + DOMAIN;
     public static final String SPECIFIC_USER = UserRoutes.USERS + SEPARATOR + USERNAME;
     public static final String MAILBOX = "mailbox";
     public static final String SPECIFIC_MAILBOX = SPECIFIC_USER + SEPARATOR + UserMailboxesRoutes.MAILBOXES + SEPARATOR + MAILBOX;

http://git-wip-us.apache.org/repos/asf/james-project/blob/840a885c/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/DomainRoutes.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/DomainRoutes.java b/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/DomainRoutes.java
deleted file mode 100644
index 60c8952..0000000
--- a/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/DomainRoutes.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-
-package org.apache.james.webadmin.routes;
-
-import static org.apache.james.webadmin.Constants.SEPARATOR;
-
-import java.util.List;
-import javax.inject.Inject;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-
-import org.apache.james.domainlist.api.DomainList;
-import org.apache.james.domainlist.api.DomainListException;
-import org.apache.james.webadmin.Constants;
-import org.apache.james.webadmin.Routes;
-import org.apache.james.webadmin.utils.JsonTransformer;
-
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiImplicitParams;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiResponse;
-import io.swagger.annotations.ApiResponses;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Preconditions;
-import com.google.common.base.Strings;
-
-import spark.Request;
-import spark.Response;
-import spark.Service;
-
-@Api(tags = "Domains")
-@Path(DomainRoutes.DOMAINS)
-@Produces("application/json")
-public class DomainRoutes implements Routes {
-
-    private static final String DOMAIN_NAME = ":domainName";
-    private static final Logger LOGGER = LoggerFactory.getLogger(DomainRoutes.class);
-
-    public static final String DOMAINS = "/domains";
-    public static final String SPECIFIC_DOMAIN = DOMAINS + SEPARATOR + DOMAIN_NAME;
-    public static final int MAXIMUM_DOMAIN_SIZE = 256;
-
-
-    private final DomainList domainList;
-    private final JsonTransformer jsonTransformer;
-    private Service service;
-
-    @Inject
-    public DomainRoutes(DomainList domainList, JsonTransformer jsonTransformer) {
-        this.domainList = domainList;
-        this.jsonTransformer = jsonTransformer;
-    }
-
-    @Override
-    public void define(Service service) {
-        this.service = service;
-
-        defineGetDomains();
-
-        defineDomainExists();
-
-        defineAddDomain();
-
-        defineDeleteDomain();
-    }
-
-    @DELETE
-    @Path("/{domainName}")
-    @ApiOperation(value = "Deleting a domain")
-    @ApiImplicitParams({
-            @ApiImplicitParam(required = true, dataType = "string", name = "domainName", paramType = "path")
-    })
-    @ApiResponses(value = {
-            @ApiResponse(code = 204, message = "OK. Domain is removed."),
-            @ApiResponse(code = 500, message = "Internal server error - Something went bad on the server side.")
-    })
-    public void defineDeleteDomain() {
-        service.delete(SPECIFIC_DOMAIN, this::removeDomain);
-    }
-
-    @PUT
-    @Path("/{domainName}")
-    @ApiOperation(value = "Creating new domain")
-    @ApiImplicitParams({
-            @ApiImplicitParam(required = true, dataType = "string", name = "domainName", paramType = "path")
-    })
-    @ApiResponses(value = {
-            @ApiResponse(code = 204, message = "OK. New domain is created."),
-            @ApiResponse(code = 400, message = "Invalid request for domain creation"),
-            @ApiResponse(code = 500, message = "Internal server error - Something went bad on the server side.")
-    })
-    public void defineAddDomain() {
-        service.put(SPECIFIC_DOMAIN, this::addDomain);
-    }
-
-    @GET
-    @Path("/{domainName}")
-    @ApiImplicitParams({
-            @ApiImplicitParam(required = true, dataType = "string", name = "domainName", paramType = "path")
-    })
-    @ApiOperation(value = "Testing existence of a domain.")
-    @ApiResponses(value = {
-            @ApiResponse(code = 204, message = "The domain exists", response = String.class),
-            @ApiResponse(code = 404, message = "The domain does not exist."),
-            @ApiResponse(code = 500, message = "Internal server error - Something went bad on the server side.")
-    })
-    public void defineDomainExists() {
-        service.get(SPECIFIC_DOMAIN, this::exists);
-    }
-
-    @GET
-    @ApiOperation(value = "Getting all domains")
-    @ApiResponses(value = {
-            @ApiResponse(code = 204, message = "OK", response = List.class),
-            @ApiResponse(code = 500, message = "Internal server error - Something went bad on the server side.")
-    })
-    public void defineGetDomains() {
-        service.get(DOMAINS,
-            (request, response) -> domainList.getDomains(),
-            jsonTransformer);
-    }
-
-    private String removeDomain(Request request, Response response) {
-        try {
-            String domain = request.params(DOMAIN_NAME);
-            removeDomain(domain);
-        } catch (DomainListException e) {
-            LOGGER.info("{} did not exists", request.params(DOMAIN_NAME));
-        }
-        response.status(204);
-        return Constants.EMPTY_BODY;
-    }
-
-    private void removeDomain(String domain) throws DomainListException {
-        Preconditions.checkArgument(!Strings.isNullOrEmpty(domain));
-        domainList.removeDomain(domain);
-    }
-
-    private String addDomain(Request request, Response response) {
-        try {
-            addDomain(request.params(DOMAIN_NAME));
-            response.status(204);
-        } catch (DomainListException e) {
-            LOGGER.info("{} already exists", request.params(DOMAIN_NAME));
-            response.status(204);
-        } catch (IllegalArgumentException e) {
-            LOGGER.info("Invalid request for domain creation");
-            response.status(400);
-        }
-        return Constants.EMPTY_BODY;
-    }
-
-    private void addDomain(String domain) throws DomainListException {
-        Preconditions.checkArgument(!Strings.isNullOrEmpty(domain));
-        Preconditions.checkArgument(!domain.contains("@"));
-        Preconditions.checkArgument(domain.length() < MAXIMUM_DOMAIN_SIZE);
-        domainList.addDomain(domain);
-    }
-
-    private String exists(Request request, Response response) throws DomainListException {
-        if (!domainList.containsDomain(request.params(DOMAIN_NAME))) {
-            response.status(404);
-        } else {
-            response.status(204);
-        }
-        return Constants.EMPTY_BODY;
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/840a885c/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/DomainsRoutes.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/DomainsRoutes.java b/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/DomainsRoutes.java
new file mode 100644
index 0000000..6b6fb9a
--- /dev/null
+++ b/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/DomainsRoutes.java
@@ -0,0 +1,191 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.webadmin.routes;
+
+import static org.apache.james.webadmin.Constants.SEPARATOR;
+
+import java.util.List;
+import javax.inject.Inject;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+
+import org.apache.james.domainlist.api.DomainList;
+import org.apache.james.domainlist.api.DomainListException;
+import org.apache.james.webadmin.Constants;
+import org.apache.james.webadmin.Routes;
+import org.apache.james.webadmin.utils.JsonTransformer;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.Preconditions;
+import com.google.common.base.Strings;
+
+import spark.Request;
+import spark.Response;
+import spark.Service;
+
+@Api(tags = "Domains")
+@Path(DomainsRoutes.DOMAINS)
+@Produces("application/json")
+public class DomainsRoutes implements Routes {
+
+    private static final String DOMAIN_NAME = ":domainName";
+    private static final Logger LOGGER = LoggerFactory.getLogger(DomainsRoutes.class);
+
+    public static final String DOMAINS = "/domains";
+    public static final String SPECIFIC_DOMAIN = DOMAINS + SEPARATOR + DOMAIN_NAME;
+    public static final int MAXIMUM_DOMAIN_SIZE = 256;
+
+
+    private final DomainList domainList;
+    private final JsonTransformer jsonTransformer;
+    private Service service;
+
+    @Inject
+    public DomainsRoutes(DomainList domainList, JsonTransformer jsonTransformer) {
+        this.domainList = domainList;
+        this.jsonTransformer = jsonTransformer;
+    }
+
+    @Override
+    public void define(Service service) {
+        this.service = service;
+
+        defineGetDomains();
+
+        defineDomainExists();
+
+        defineAddDomain();
+
+        defineDeleteDomain();
+    }
+
+    @DELETE
+    @Path("/{domainName}")
+    @ApiOperation(value = "Deleting a domain")
+    @ApiImplicitParams({
+            @ApiImplicitParam(required = true, dataType = "string", name = "domainName", paramType = "path")
+    })
+    @ApiResponses(value = {
+            @ApiResponse(code = 204, message = "OK. Domain is removed."),
+            @ApiResponse(code = 500, message = "Internal server error - Something went bad on the server side.")
+    })
+    public void defineDeleteDomain() {
+        service.delete(SPECIFIC_DOMAIN, this::removeDomain);
+    }
+
+    @PUT
+    @Path("/{domainName}")
+    @ApiOperation(value = "Creating new domain")
+    @ApiImplicitParams({
+            @ApiImplicitParam(required = true, dataType = "string", name = "domainName", paramType = "path")
+    })
+    @ApiResponses(value = {
+            @ApiResponse(code = 204, message = "OK. New domain is created."),
+            @ApiResponse(code = 400, message = "Invalid request for domain creation"),
+            @ApiResponse(code = 500, message = "Internal server error - Something went bad on the server side.")
+    })
+    public void defineAddDomain() {
+        service.put(SPECIFIC_DOMAIN, this::addDomain);
+    }
+
+    @GET
+    @Path("/{domainName}")
+    @ApiImplicitParams({
+            @ApiImplicitParam(required = true, dataType = "string", name = "domainName", paramType = "path")
+    })
+    @ApiOperation(value = "Testing existence of a domain.")
+    @ApiResponses(value = {
+            @ApiResponse(code = 204, message = "The domain exists", response = String.class),
+            @ApiResponse(code = 404, message = "The domain does not exist."),
+            @ApiResponse(code = 500, message = "Internal server error - Something went bad on the server side.")
+    })
+    public void defineDomainExists() {
+        service.get(SPECIFIC_DOMAIN, this::exists);
+    }
+
+    @GET
+    @ApiOperation(value = "Getting all domains")
+    @ApiResponses(value = {
+            @ApiResponse(code = 204, message = "OK", response = List.class),
+            @ApiResponse(code = 500, message = "Internal server error - Something went bad on the server side.")
+    })
+    public void defineGetDomains() {
+        service.get(DOMAINS,
+            (request, response) -> domainList.getDomains(),
+            jsonTransformer);
+    }
+
+    private String removeDomain(Request request, Response response) {
+        try {
+            String domain = request.params(DOMAIN_NAME);
+            removeDomain(domain);
+        } catch (DomainListException e) {
+            LOGGER.info("{} did not exists", request.params(DOMAIN_NAME));
+        }
+        response.status(204);
+        return Constants.EMPTY_BODY;
+    }
+
+    private void removeDomain(String domain) throws DomainListException {
+        Preconditions.checkArgument(!Strings.isNullOrEmpty(domain));
+        domainList.removeDomain(domain);
+    }
+
+    private String addDomain(Request request, Response response) {
+        try {
+            addDomain(request.params(DOMAIN_NAME));
+            response.status(204);
+        } catch (DomainListException e) {
+            LOGGER.info("{} already exists", request.params(DOMAIN_NAME));
+            response.status(204);
+        } catch (IllegalArgumentException e) {
+            LOGGER.info("Invalid request for domain creation");
+            response.status(400);
+        }
+        return Constants.EMPTY_BODY;
+    }
+
+    private void addDomain(String domain) throws DomainListException {
+        Preconditions.checkArgument(!Strings.isNullOrEmpty(domain));
+        Preconditions.checkArgument(!domain.contains("@"));
+        Preconditions.checkArgument(domain.length() < MAXIMUM_DOMAIN_SIZE);
+        domainList.addDomain(domain);
+    }
+
+    private String exists(Request request, Response response) throws DomainListException {
+        if (!domainList.containsDomain(request.params(DOMAIN_NAME))) {
+            response.status(404);
+        } else {
+            response.status(204);
+        }
+        return Constants.EMPTY_BODY;
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/840a885c/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/DomainRoutesTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/DomainRoutesTest.java b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/DomainRoutesTest.java
deleted file mode 100644
index f17acd3..0000000
--- a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/DomainRoutesTest.java
+++ /dev/null
@@ -1,319 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-
-package org.apache.james.webadmin.routes;
-
-import static com.jayway.restassured.RestAssured.given;
-import static com.jayway.restassured.RestAssured.when;
-import static com.jayway.restassured.RestAssured.with;
-import static com.jayway.restassured.config.EncoderConfig.encoderConfig;
-import static com.jayway.restassured.config.RestAssuredConfig.newConfig;
-import static org.apache.james.webadmin.Constants.SEPARATOR;
-import static org.apache.james.webadmin.WebAdminServer.NO_CONFIGURATION;
-import static org.hamcrest.CoreMatchers.containsString;
-import static org.hamcrest.CoreMatchers.is;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.doThrow;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import java.net.InetAddress;
-import java.nio.charset.StandardCharsets;
-
-import org.apache.james.dnsservice.api.DNSService;
-import org.apache.james.domainlist.api.DomainList;
-import org.apache.james.domainlist.api.DomainListException;
-import org.apache.james.domainlist.memory.MemoryDomainList;
-import org.apache.james.metrics.logger.DefaultMetricFactory;
-import org.apache.james.webadmin.WebAdminServer;
-import org.apache.james.webadmin.utils.JsonTransformer;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import com.jayway.restassured.RestAssured;
-import com.jayway.restassured.builder.RequestSpecBuilder;
-import com.jayway.restassured.http.ContentType;
-import de.bechte.junit.runners.context.HierarchicalContextRunner;
-
-@RunWith(HierarchicalContextRunner.class)
-public class DomainRoutesTest {
-    public static final String DOMAIN = "domain";
-
-    private WebAdminServer webAdminServer;
-
-    private void createServer(DomainList domainList) throws Exception {
-        webAdminServer = new WebAdminServer(
-            new DefaultMetricFactory(),
-            new DomainRoutes(domainList, new JsonTransformer()));
-        webAdminServer.configure(NO_CONFIGURATION);
-        webAdminServer.await();
-
-        RestAssured.requestSpecification = new RequestSpecBuilder()
-        		.setContentType(ContentType.JSON)
-        		.setAccept(ContentType.JSON)
-        		.setConfig(newConfig().encoderConfig(encoderConfig().defaultContentCharset(StandardCharsets.UTF_8)))
-        		.setPort(webAdminServer.getPort().toInt())
-        		.setBasePath(DomainRoutes.DOMAINS)
-        		.build();
-
-    }
-
-    @After
-    public void stop() {
-        webAdminServer.destroy();
-    }
-
-    public class NormalBehaviour {
-
-        @Before
-        public void setUp() throws Exception {
-            DNSService dnsService = mock(DNSService.class);
-            when(dnsService.getHostName(any())).thenReturn("localhost");
-            when(dnsService.getLocalHost()).thenReturn(InetAddress.getByName("localhost"));
-
-            MemoryDomainList domainList = new MemoryDomainList(dnsService);
-            domainList.setAutoDetectIP(false);
-            createServer(domainList);
-        }
-
-        @Test
-        public void getDomainsShouldBeEmptyByDefault() {
-            given()
-                .get()
-            .then()
-                .statusCode(200)
-                .body(is("[]"));
-        }
-
-        @Test
-        public void putShouldReturnErrorWhenUsedWithEmptyDomain() {
-            given()
-                .put(SEPARATOR)
-            .then()
-                .statusCode(404);
-        }
-
-        @Test
-        public void deleteShouldReturnErrorWhenUsedWithEmptyDomain() {
-            given()
-                .delete(SEPARATOR)
-            .then()
-                .statusCode(404);
-        }
-
-        @Test
-        public void putShouldBeOk() {
-            given()
-                .put(DOMAIN)
-            .then()
-                .statusCode(204);
-        }
-
-        @Test
-        public void getDomainsShouldDisplayAddedDomains() {
-            with()
-                .put(DOMAIN);
-
-            when()
-                .get()
-            .then()
-                .statusCode(200)
-                .body(containsString(DOMAIN));
-        }
-
-        @Test
-        public void putShouldReturnUserErrorWhenNameContainsAT() {
-            when()
-                .put(DOMAIN + "@" + DOMAIN)
-            .then()
-                .statusCode(400);
-        }
-
-        @Test
-        public void putShouldReturnUserErrorWhenNameContainsUrlSeparator() {
-            when()
-                .put(DOMAIN + "/" + DOMAIN)
-            .then()
-                .statusCode(404);
-        }
-
-        @Test
-        public void putShouldReturnUserErrorWhenNameIsTooLong() {
-            when()
-                .put(DOMAIN + "0123456789.0123456789.0123456789.0123456789.0123456789.0123456789.0123456789.0123456789.0123456789.0123456789." +
-                    "0123456789.0123456789.0123456789.0123456789.0123456789.0123456789.0123456789.0123456789.0123456789.0123456789." +
-                    "0123456789.0123456789.0123456789.")
-            .then()
-                .statusCode(400);
-        }
-
-        @Test
-        public void putShouldWorkOnTheSecondTimeForAGivenValue() {
-            with()
-                .put(DOMAIN);
-
-            when()
-                .put(DOMAIN)
-            .then()
-                .statusCode(204);
-        }
-
-        @Test
-        public void deleteShouldRemoveTheGivenDomain() {
-            with()
-                .put(DOMAIN);
-
-            when()
-                .delete(DOMAIN)
-            .then()
-                .statusCode(204);
-
-            when()
-                .get()
-            .then()
-                .statusCode(200)
-                .body(is("[]"));
-        }
-
-        @Test
-        public void deleteShouldBeOkWhenTheDomainIsNotPresent() {
-            given()
-                .delete(DOMAIN)
-            .then()
-                .statusCode(204);
-        }
-
-        @Test
-        public void getDomainShouldReturnOkWhenTheDomainIsPresent() {
-            with()
-                .put(DOMAIN);
-
-            when()
-                .get(DOMAIN)
-            .then()
-                .statusCode(204);
-        }
-
-        @Test
-        public void getDomainShouldReturnNotFoundWhenTheDomainIsAbsent() {
-            given()
-                .get(DOMAIN)
-            .then()
-                .statusCode(404);
-        }
-
-    }
-
-    public class ExceptionHandling {
-
-        private DomainList domainList;
-        private String domain;
-
-        @Before
-        public void setUp() throws Exception {
-            domainList = mock(DomainList.class);
-            createServer(domainList);
-            domain = "domain";
-        }
-
-        @Test
-        public void deleteShouldReturnErrorOnUnknownException() throws Exception {
-            doThrow(new RuntimeException()).when(domainList).removeDomain(domain);
-
-            when()
-                .delete(DOMAIN)
-            .then()
-                .statusCode(500);
-        }
-
-        @Test
-        public void putShouldReturnErrorOnUnknownException() throws Exception {
-            doThrow(new RuntimeException()).when(domainList).addDomain(domain);
-
-            when()
-                .put(DOMAIN)
-            .then()
-                .statusCode(500);
-        }
-
-        @Test
-        public void getDomainShouldReturnErrorOnUnknownException() throws Exception {
-            when(domainList.containsDomain(domain)).thenThrow(new RuntimeException());
-
-            when()
-                .get(DOMAIN)
-            .then()
-                .statusCode(500);
-        }
-
-        @Test
-        public void getDomainsShouldReturnErrorOnUnknownException() throws Exception {
-            when(domainList.getDomains()).thenThrow(new RuntimeException());
-
-            when()
-                .get()
-            .then()
-                .statusCode(500);
-        }
-
-        @Test
-        public void deleteShouldReturnOkWhenDomainListException() throws Exception {
-            doThrow(new DomainListException("message")).when(domainList).removeDomain(domain);
-
-            when()
-                .delete(DOMAIN)
-            .then()
-                .statusCode(204);
-        }
-
-        @Test
-        public void putShouldReturnOkWhenDomainListException() throws Exception {
-            doThrow(new DomainListException("message")).when(domainList).addDomain(domain);
-
-            when()
-                .put(DOMAIN)
-            .then()
-                .statusCode(204);
-        }
-
-        @Test
-        public void getDomainShouldReturnErrorOnDomainListException() throws Exception {
-            when(domainList.containsDomain(domain)).thenThrow(new DomainListException("message"));
-
-            when()
-                .get(DOMAIN)
-            .then()
-                .statusCode(500);
-        }
-
-        @Test
-        public void getDomainsShouldReturnErrorOnDomainListException() throws Exception {
-            when(domainList.getDomains()).thenThrow(new DomainListException("message"));
-
-            when()
-                .get()
-            .then()
-                .statusCode(500);
-        }
-
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/840a885c/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/DomainsRoutesTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/DomainsRoutesTest.java b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/DomainsRoutesTest.java
new file mode 100644
index 0000000..23739f9
--- /dev/null
+++ b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/DomainsRoutesTest.java
@@ -0,0 +1,319 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.webadmin.routes;
+
+import static com.jayway.restassured.RestAssured.given;
+import static com.jayway.restassured.RestAssured.when;
+import static com.jayway.restassured.RestAssured.with;
+import static com.jayway.restassured.config.EncoderConfig.encoderConfig;
+import static com.jayway.restassured.config.RestAssuredConfig.newConfig;
+import static org.apache.james.webadmin.Constants.SEPARATOR;
+import static org.apache.james.webadmin.WebAdminServer.NO_CONFIGURATION;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.is;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.net.InetAddress;
+import java.nio.charset.StandardCharsets;
+
+import org.apache.james.dnsservice.api.DNSService;
+import org.apache.james.domainlist.api.DomainList;
+import org.apache.james.domainlist.api.DomainListException;
+import org.apache.james.domainlist.memory.MemoryDomainList;
+import org.apache.james.metrics.logger.DefaultMetricFactory;
+import org.apache.james.webadmin.WebAdminServer;
+import org.apache.james.webadmin.utils.JsonTransformer;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import com.jayway.restassured.RestAssured;
+import com.jayway.restassured.builder.RequestSpecBuilder;
+import com.jayway.restassured.http.ContentType;
+import de.bechte.junit.runners.context.HierarchicalContextRunner;
+
+@RunWith(HierarchicalContextRunner.class)
+public class DomainsRoutesTest {
+    public static final String DOMAIN = "domain";
+
+    private WebAdminServer webAdminServer;
+
+    private void createServer(DomainList domainList) throws Exception {
+        webAdminServer = new WebAdminServer(
+            new DefaultMetricFactory(),
+            new DomainsRoutes(domainList, new JsonTransformer()));
+        webAdminServer.configure(NO_CONFIGURATION);
+        webAdminServer.await();
+
+        RestAssured.requestSpecification = new RequestSpecBuilder()
+        		.setContentType(ContentType.JSON)
+        		.setAccept(ContentType.JSON)
+        		.setConfig(newConfig().encoderConfig(encoderConfig().defaultContentCharset(StandardCharsets.UTF_8)))
+        		.setPort(webAdminServer.getPort().toInt())
+        		.setBasePath(DomainsRoutes.DOMAINS)
+        		.build();
+
+    }
+
+    @After
+    public void stop() {
+        webAdminServer.destroy();
+    }
+
+    public class NormalBehaviour {
+
+        @Before
+        public void setUp() throws Exception {
+            DNSService dnsService = mock(DNSService.class);
+            when(dnsService.getHostName(any())).thenReturn("localhost");
+            when(dnsService.getLocalHost()).thenReturn(InetAddress.getByName("localhost"));
+
+            MemoryDomainList domainList = new MemoryDomainList(dnsService);
+            domainList.setAutoDetectIP(false);
+            createServer(domainList);
+        }
+
+        @Test
+        public void getDomainsShouldBeEmptyByDefault() {
+            given()
+                .get()
+            .then()
+                .statusCode(200)
+                .body(is("[]"));
+        }
+
+        @Test
+        public void putShouldReturnErrorWhenUsedWithEmptyDomain() {
+            given()
+                .put(SEPARATOR)
+            .then()
+                .statusCode(404);
+        }
+
+        @Test
+        public void deleteShouldReturnErrorWhenUsedWithEmptyDomain() {
+            given()
+                .delete(SEPARATOR)
+            .then()
+                .statusCode(404);
+        }
+
+        @Test
+        public void putShouldBeOk() {
+            given()
+                .put(DOMAIN)
+            .then()
+                .statusCode(204);
+        }
+
+        @Test
+        public void getDomainsShouldDisplayAddedDomains() {
+            with()
+                .put(DOMAIN);
+
+            when()
+                .get()
+            .then()
+                .statusCode(200)
+                .body(containsString(DOMAIN));
+        }
+
+        @Test
+        public void putShouldReturnUserErrorWhenNameContainsAT() {
+            when()
+                .put(DOMAIN + "@" + DOMAIN)
+            .then()
+                .statusCode(400);
+        }
+
+        @Test
+        public void putShouldReturnUserErrorWhenNameContainsUrlSeparator() {
+            when()
+                .put(DOMAIN + "/" + DOMAIN)
+            .then()
+                .statusCode(404);
+        }
+
+        @Test
+        public void putShouldReturnUserErrorWhenNameIsTooLong() {
+            when()
+                .put(DOMAIN + "0123456789.0123456789.0123456789.0123456789.0123456789.0123456789.0123456789.0123456789.0123456789.0123456789." +
+                    "0123456789.0123456789.0123456789.0123456789.0123456789.0123456789.0123456789.0123456789.0123456789.0123456789." +
+                    "0123456789.0123456789.0123456789.")
+            .then()
+                .statusCode(400);
+        }
+
+        @Test
+        public void putShouldWorkOnTheSecondTimeForAGivenValue() {
+            with()
+                .put(DOMAIN);
+
+            when()
+                .put(DOMAIN)
+            .then()
+                .statusCode(204);
+        }
+
+        @Test
+        public void deleteShouldRemoveTheGivenDomain() {
+            with()
+                .put(DOMAIN);
+
+            when()
+                .delete(DOMAIN)
+            .then()
+                .statusCode(204);
+
+            when()
+                .get()
+            .then()
+                .statusCode(200)
+                .body(is("[]"));
+        }
+
+        @Test
+        public void deleteShouldBeOkWhenTheDomainIsNotPresent() {
+            given()
+                .delete(DOMAIN)
+            .then()
+                .statusCode(204);
+        }
+
+        @Test
+        public void getDomainShouldReturnOkWhenTheDomainIsPresent() {
+            with()
+                .put(DOMAIN);
+
+            when()
+                .get(DOMAIN)
+            .then()
+                .statusCode(204);
+        }
+
+        @Test
+        public void getDomainShouldReturnNotFoundWhenTheDomainIsAbsent() {
+            given()
+                .get(DOMAIN)
+            .then()
+                .statusCode(404);
+        }
+
+    }
+
+    public class ExceptionHandling {
+
+        private DomainList domainList;
+        private String domain;
+
+        @Before
+        public void setUp() throws Exception {
+            domainList = mock(DomainList.class);
+            createServer(domainList);
+            domain = "domain";
+        }
+
+        @Test
+        public void deleteShouldReturnErrorOnUnknownException() throws Exception {
+            doThrow(new RuntimeException()).when(domainList).removeDomain(domain);
+
+            when()
+                .delete(DOMAIN)
+            .then()
+                .statusCode(500);
+        }
+
+        @Test
+        public void putShouldReturnErrorOnUnknownException() throws Exception {
+            doThrow(new RuntimeException()).when(domainList).addDomain(domain);
+
+            when()
+                .put(DOMAIN)
+            .then()
+                .statusCode(500);
+        }
+
+        @Test
+        public void getDomainShouldReturnErrorOnUnknownException() throws Exception {
+            when(domainList.containsDomain(domain)).thenThrow(new RuntimeException());
+
+            when()
+                .get(DOMAIN)
+            .then()
+                .statusCode(500);
+        }
+
+        @Test
+        public void getDomainsShouldReturnErrorOnUnknownException() throws Exception {
+            when(domainList.getDomains()).thenThrow(new RuntimeException());
+
+            when()
+                .get()
+            .then()
+                .statusCode(500);
+        }
+
+        @Test
+        public void deleteShouldReturnOkWhenDomainListException() throws Exception {
+            doThrow(new DomainListException("message")).when(domainList).removeDomain(domain);
+
+            when()
+                .delete(DOMAIN)
+            .then()
+                .statusCode(204);
+        }
+
+        @Test
+        public void putShouldReturnOkWhenDomainListException() throws Exception {
+            doThrow(new DomainListException("message")).when(domainList).addDomain(domain);
+
+            when()
+                .put(DOMAIN)
+            .then()
+                .statusCode(204);
+        }
+
+        @Test
+        public void getDomainShouldReturnErrorOnDomainListException() throws Exception {
+            when(domainList.containsDomain(domain)).thenThrow(new DomainListException("message"));
+
+            when()
+                .get(DOMAIN)
+            .then()
+                .statusCode(500);
+        }
+
+        @Test
+        public void getDomainsShouldReturnErrorOnDomainListException() throws Exception {
+            when(domainList.getDomains()).thenThrow(new DomainListException("message"));
+
+            when()
+                .get()
+            .then()
+                .statusCode(500);
+        }
+
+    }
+
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org