james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [03/10] james-project git commit: JAMES-1709 Allow to add domain from an ENV variable
Date Tue, 08 Aug 2017 10:46:38 GMT
JAMES-1709 Allow to add domain from an ENV variable


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

Branch: refs/heads/master
Commit: 6e36b22fa812c3af7ac01c3ecd8b73a337a9941e
Parents: ff51cee
Author: benwa <btellier@linagora.com>
Authored: Fri Jul 28 17:36:57 2017 +0700
Committer: benwa <btellier@linagora.com>
Committed: Tue Aug 8 17:08:50 2017 +0700

----------------------------------------------------------------------
 .../META-INF/org/apache/james/spring-server.xml |  2 ++
 .../cassandra/CassandraDomainList.java          |  9 ++++---
 .../cassandra/CassandraDomainListTest.java      |  3 +--
 .../james/domainlist/xml/XMLDomainList.java     |  8 ++++++
 .../james/domainlist/hbase/HBaseDomainList.java |  9 +++++++
 .../domainlist/hbase/HBaseDomainListTest.java   |  4 +--
 .../james/domainlist/jpa/JPADomainList.java     |  8 ++++++
 .../james/domainlist/jpa/JPADomainListTest.java |  7 +++---
 .../domainlist/lib/AbstractDomainList.java      | 26 +++++++++++++++++---
 .../james/domainlist/lib/EnvDetector.java       | 26 ++++++++++++++++++++
 .../AbstractDomainListPrivateMethodsTest.java   | 24 ++++++++++++++----
 .../domainlist/memory/MemoryDomainList.java     |  8 +++++-
 .../domainlist/memory/MemoryDomainListTest.java |  4 +--
 .../impl/JamesMailetContextTest.java            |  5 +++-
 .../james/webadmin/routes/DomainRoutesTest.java |  4 +--
 15 files changed, 122 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/6e36b22f/server/container/spring/src/main/resources/META-INF/org/apache/james/spring-server.xml
----------------------------------------------------------------------
diff --git a/server/container/spring/src/main/resources/META-INF/org/apache/james/spring-server.xml
b/server/container/spring/src/main/resources/META-INF/org/apache/james/spring-server.xml
index 322c4c6..cf5b986 100644
--- a/server/container/spring/src/main/resources/META-INF/org/apache/james/spring-server.xml
+++ b/server/container/spring/src/main/resources/META-INF/org/apache/james/spring-server.xml
@@ -316,4 +316,6 @@
 
     <bean id="jspfLogger" class="org.apache.james.smtpserver.fastfail.SPFHandler.SPFLogger"/>
 
+    <bean id="envDetector" class="org.apache.james.domainlist.lib.EnvDetector"/>
+
 </beans>

http://git-wip-us.apache.org/repos/asf/james-project/blob/6e36b22f/server/data/data-cassandra/src/main/java/org/apache/james/domainlist/cassandra/CassandraDomainList.java
----------------------------------------------------------------------
diff --git a/server/data/data-cassandra/src/main/java/org/apache/james/domainlist/cassandra/CassandraDomainList.java
b/server/data/data-cassandra/src/main/java/org/apache/james/domainlist/cassandra/CassandraDomainList.java
index ae889aa..1619f9e 100644
--- a/server/data/data-cassandra/src/main/java/org/apache/james/domainlist/cassandra/CassandraDomainList.java
+++ b/server/data/data-cassandra/src/main/java/org/apache/james/domainlist/cassandra/CassandraDomainList.java
@@ -35,8 +35,10 @@ import javax.inject.Inject;
 
 import org.apache.james.backends.cassandra.utils.CassandraAsyncExecutor;
 import org.apache.james.backends.cassandra.utils.CassandraUtils;
+import org.apache.james.dnsservice.api.DNSService;
 import org.apache.james.domainlist.api.DomainListException;
 import org.apache.james.domainlist.lib.AbstractDomainList;
+import org.apache.james.domainlist.lib.EnvDetector;
 
 import com.datastax.driver.core.PreparedStatement;
 import com.datastax.driver.core.Session;
@@ -52,7 +54,8 @@ public class CassandraDomainList extends AbstractDomainList {
     private final PreparedStatement removeStatement;
 
     @Inject
-    public CassandraDomainList(Session session, CassandraUtils cassandraUtils) {
+    public CassandraDomainList(DNSService dnsService, EnvDetector envDetector, Session session,
CassandraUtils cassandraUtils) {
+        super(dnsService, envDetector);
         this.executor = new CassandraAsyncExecutor(session);
         this.cassandraUtils = cassandraUtils;
         this.readAllStatement = prepareReadAllStatement(session);
@@ -86,8 +89,8 @@ public class CassandraDomainList extends AbstractDomainList {
     }
 
     @VisibleForTesting
-    CassandraDomainList(Session session) {
-        this(session, CassandraUtils.WITH_DEFAULT_CONFIGURATION);
+    CassandraDomainList(DNSService dnsService, Session session) {
+        this(dnsService, new EnvDetector(), session, CassandraUtils.WITH_DEFAULT_CONFIGURATION);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/james-project/blob/6e36b22f/server/data/data-cassandra/src/test/java/org/apache/james/domainlist/cassandra/CassandraDomainListTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-cassandra/src/test/java/org/apache/james/domainlist/cassandra/CassandraDomainListTest.java
b/server/data/data-cassandra/src/test/java/org/apache/james/domainlist/cassandra/CassandraDomainListTest.java
index 411aa1b..89c0438 100644
--- a/server/data/data-cassandra/src/test/java/org/apache/james/domainlist/cassandra/CassandraDomainListTest.java
+++ b/server/data/data-cassandra/src/test/java/org/apache/james/domainlist/cassandra/CassandraDomainListTest.java
@@ -31,9 +31,8 @@ public class CassandraDomainListTest extends AbstractDomainListTest {
     @Override
     protected DomainList createDomainList() {
         cassandra = CassandraCluster.create(new CassandraDomainListModule());
-        CassandraDomainList testee = new CassandraDomainList(cassandra.getConf());
+        CassandraDomainList testee = new CassandraDomainList(getDNSServer("localhost"), cassandra.getConf());
         testee.setLog(LoggerFactory.getLogger(getClass()));
-        testee.setDNSService(getDNSServer("localhost"));
         testee.setAutoDetect(false);
         testee.setAutoDetectIP(false);
         return testee;

http://git-wip-us.apache.org/repos/asf/james-project/blob/6e36b22f/server/data/data-file/src/main/java/org/apache/james/domainlist/xml/XMLDomainList.java
----------------------------------------------------------------------
diff --git a/server/data/data-file/src/main/java/org/apache/james/domainlist/xml/XMLDomainList.java
b/server/data/data-file/src/main/java/org/apache/james/domainlist/xml/XMLDomainList.java
index 6848ab5..813f521 100644
--- a/server/data/data-file/src/main/java/org/apache/james/domainlist/xml/XMLDomainList.java
+++ b/server/data/data-file/src/main/java/org/apache/james/domainlist/xml/XMLDomainList.java
@@ -23,12 +23,15 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.Locale;
 
+import javax.inject.Inject;
 import javax.inject.Singleton;
 
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.configuration.HierarchicalConfiguration;
+import org.apache.james.dnsservice.api.DNSService;
 import org.apache.james.domainlist.api.DomainListException;
 import org.apache.james.domainlist.lib.AbstractDomainList;
+import org.apache.james.domainlist.lib.EnvDetector;
 import org.apache.james.lifecycle.api.Configurable;
 
 /**
@@ -40,6 +43,11 @@ public class XMLDomainList extends AbstractDomainList implements Configurable
{
     private final List<String> domainNames = new ArrayList<String>();
     private boolean isConfigured = false;
 
+    @Inject
+    public XMLDomainList(DNSService dns, EnvDetector envDetector) {
+        super(dns, envDetector);
+    }
+
     @Override
     public void configure(HierarchicalConfiguration config) throws ConfigurationException
{
         super.configure(config);

http://git-wip-us.apache.org/repos/asf/james-project/blob/6e36b22f/server/data/data-hbase/src/main/java/org/apache/james/domainlist/hbase/HBaseDomainList.java
----------------------------------------------------------------------
diff --git a/server/data/data-hbase/src/main/java/org/apache/james/domainlist/hbase/HBaseDomainList.java
b/server/data/data-hbase/src/main/java/org/apache/james/domainlist/hbase/HBaseDomainList.java
index dbeb21b..6e24ced 100644
--- a/server/data/data-hbase/src/main/java/org/apache/james/domainlist/hbase/HBaseDomainList.java
+++ b/server/data/data-hbase/src/main/java/org/apache/james/domainlist/hbase/HBaseDomainList.java
@@ -23,6 +23,8 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.Locale;
 
+import javax.inject.Inject;
+
 import org.apache.hadoop.hbase.client.Delete;
 import org.apache.hadoop.hbase.client.Get;
 import org.apache.hadoop.hbase.client.HTableInterface;
@@ -31,9 +33,11 @@ import org.apache.hadoop.hbase.client.Result;
 import org.apache.hadoop.hbase.client.ResultScanner;
 import org.apache.hadoop.hbase.client.Scan;
 import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.james.dnsservice.api.DNSService;
 import org.apache.james.domainlist.api.DomainListException;
 import org.apache.james.domainlist.hbase.def.HDomainList;
 import org.apache.james.domainlist.lib.AbstractDomainList;
+import org.apache.james.domainlist.lib.EnvDetector;
 import org.apache.james.system.hbase.TablePool;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -48,6 +52,11 @@ public class HBaseDomainList extends AbstractDomainList {
      */
     private static final Logger log = LoggerFactory.getLogger(HBaseDomainList.class.getName());
 
+    @Inject
+    public HBaseDomainList(DNSService dns, EnvDetector envDetector) {
+        super(dns, envDetector);
+    }
+
     /**
      * @see org.apache.james.domainlist.api.DomainList#containsDomain(String)
      */

http://git-wip-us.apache.org/repos/asf/james-project/blob/6e36b22f/server/data/data-hbase/src/test/java/org/apache/james/domainlist/hbase/HBaseDomainListTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-hbase/src/test/java/org/apache/james/domainlist/hbase/HBaseDomainListTest.java
b/server/data/data-hbase/src/test/java/org/apache/james/domainlist/hbase/HBaseDomainListTest.java
index 97e71d6..bcb38c5 100644
--- a/server/data/data-hbase/src/test/java/org/apache/james/domainlist/hbase/HBaseDomainListTest.java
+++ b/server/data/data-hbase/src/test/java/org/apache/james/domainlist/hbase/HBaseDomainListTest.java
@@ -22,6 +22,7 @@ import java.io.IOException;
 import org.apache.james.domainlist.api.DomainList;
 import org.apache.james.domainlist.api.DomainListException;
 import org.apache.james.domainlist.lib.AbstractDomainListTest;
+import org.apache.james.domainlist.lib.EnvDetector;
 import org.apache.james.mailbox.hbase.HBaseClusterSingleton;
 import org.apache.james.system.hbase.TablePool;
 import org.junit.BeforeClass;
@@ -49,9 +50,8 @@ public class HBaseDomainListTest extends AbstractDomainListTest {
      */
     @Override
     protected DomainList createDomainList() {
-        HBaseDomainList domainList = new HBaseDomainList();
+        HBaseDomainList domainList = new HBaseDomainList(getDNSServer("localhost"), new EnvDetector());
         domainList.setLog(LoggerFactory.getLogger("MockLog"));
-        domainList.setDNSService(getDNSServer("localhost"));
         domainList.setAutoDetect(false);
         domainList.setAutoDetectIP(false);
         return domainList;

http://git-wip-us.apache.org/repos/asf/james-project/blob/6e36b22f/server/data/data-jpa/src/main/java/org/apache/james/domainlist/jpa/JPADomainList.java
----------------------------------------------------------------------
diff --git a/server/data/data-jpa/src/main/java/org/apache/james/domainlist/jpa/JPADomainList.java
b/server/data/data-jpa/src/main/java/org/apache/james/domainlist/jpa/JPADomainList.java
index af9ea44..03fdfdd 100644
--- a/server/data/data-jpa/src/main/java/org/apache/james/domainlist/jpa/JPADomainList.java
+++ b/server/data/data-jpa/src/main/java/org/apache/james/domainlist/jpa/JPADomainList.java
@@ -31,9 +31,11 @@ import javax.persistence.NoResultException;
 import javax.persistence.PersistenceException;
 import javax.persistence.PersistenceUnit;
 
+import org.apache.james.dnsservice.api.DNSService;
 import org.apache.james.domainlist.api.DomainListException;
 import org.apache.james.domainlist.jpa.model.JPADomain;
 import org.apache.james.domainlist.lib.AbstractDomainList;
+import org.apache.james.domainlist.lib.EnvDetector;
 
 import com.google.common.collect.ImmutableList;
 
@@ -49,6 +51,12 @@ public class JPADomainList extends AbstractDomainList {
      */
     private EntityManagerFactory entityManagerFactory;
 
+    @Inject
+    public JPADomainList(DNSService dns, EnvDetector envDetector, EntityManagerFactory entityManagerFactory)
{
+        super(dns, envDetector);
+        this.entityManagerFactory = entityManagerFactory;
+    }
+
     /**
      * Set the entity manager to use.
      *

http://git-wip-us.apache.org/repos/asf/james-project/blob/6e36b22f/server/data/data-jpa/src/test/java/org/apache/james/domainlist/jpa/JPADomainListTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-jpa/src/test/java/org/apache/james/domainlist/jpa/JPADomainListTest.java
b/server/data/data-jpa/src/test/java/org/apache/james/domainlist/jpa/JPADomainListTest.java
index 6e5d9a0..8c225f5 100644
--- a/server/data/data-jpa/src/test/java/org/apache/james/domainlist/jpa/JPADomainListTest.java
+++ b/server/data/data-jpa/src/test/java/org/apache/james/domainlist/jpa/JPADomainListTest.java
@@ -22,6 +22,7 @@ import org.apache.james.backends.jpa.JpaTestCluster;
 import org.apache.james.domainlist.api.DomainList;
 import org.apache.james.domainlist.jpa.model.JPADomain;
 import org.apache.james.domainlist.lib.AbstractDomainListTest;
+import org.apache.james.domainlist.lib.EnvDetector;
 import org.slf4j.LoggerFactory;
 
 /**
@@ -33,12 +34,12 @@ public class JPADomainListTest extends AbstractDomainListTest {
 
     @Override
     protected DomainList createDomainList() {
-        JPADomainList jpaDomainList = new JPADomainList();
+        JPADomainList jpaDomainList = new JPADomainList(getDNSServer("localhost"),
+            new EnvDetector(),
+            JPA_TEST_CLUSTER.getEntityManagerFactory());
         jpaDomainList.setLog(LoggerFactory.getLogger("JPADomainListMockLog"));
-        jpaDomainList.setDNSService(getDNSServer("localhost"));
         jpaDomainList.setAutoDetect(false);
         jpaDomainList.setAutoDetectIP(false);
-        jpaDomainList.setEntityManagerFactory(JPA_TEST_CLUSTER.getEntityManagerFactory());
         
         return jpaDomainList;
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/6e36b22f/server/data/data-library/src/main/java/org/apache/james/domainlist/lib/AbstractDomainList.java
----------------------------------------------------------------------
diff --git a/server/data/data-library/src/main/java/org/apache/james/domainlist/lib/AbstractDomainList.java
b/server/data/data-library/src/main/java/org/apache/james/domainlist/lib/AbstractDomainList.java
index d2b564c..c08abbe 100644
--- a/server/data/data-library/src/main/java/org/apache/james/domainlist/lib/AbstractDomainList.java
+++ b/server/data/data-library/src/main/java/org/apache/james/domainlist/lib/AbstractDomainList.java
@@ -39,6 +39,8 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Strings;
+import com.google.common.base.Throwables;
 import com.google.common.collect.ImmutableList;
 
 /**
@@ -53,16 +55,19 @@ public abstract class AbstractDomainList implements DomainList, LogEnabled,
Conf
     public static final String CONFIGURE_AUTODETECT = "autodetect";
     public static final String CONFIGURE_AUTODETECT_IP = "autodetectIP";
     public static final String CONFIGURE_DEFAULT_DOMAIN = "defaultDomain";
+    public static final String ENV_DOMAIN = "DOMAIN";
 
-    private DNSService dns;
+    private final DNSService dns;
+    private final EnvDetector envDetector;
     private boolean autoDetect = true;
     private boolean autoDetectIP = true;
     private Logger logger;
     private String defaultDomain;
 
     @Inject
-    public void setDNSService(DNSService dns) {
+    public AbstractDomainList(DNSService dns, EnvDetector envDetector) {
         this.dns = dns;
+        this.envDetector = envDetector;
     }
 
     public void setLog(Logger logger) {
@@ -77,12 +82,25 @@ public abstract class AbstractDomainList implements DomainList, LogEnabled,
Conf
     public void configure(HierarchicalConfiguration config) throws ConfigurationException
{
         configureDefaultDomain(config);
 
+        addEnvDomain();
+
         setAutoDetect(config.getBoolean(CONFIGURE_AUTODETECT, true));
         setAutoDetectIP(config.getBoolean(CONFIGURE_AUTODETECT_IP, true));
     }
 
+    private void addEnvDomain() {
+        String envDomain = envDetector.getEnv(ENV_DOMAIN);
+        if (!Strings.isNullOrEmpty(envDomain)) {
+            try {
+                LOGGER.info("Adding environment defined domain {}", envDomain);
+                addDomain(envDomain);
+            } catch (DomainListException e) {
+                throw Throwables.propagate(e);
+            }
+        }
+    }
+
     @VisibleForTesting void configureDefaultDomain(HierarchicalConfiguration config) throws
ConfigurationException {
-        
         try {
             setDefaultDomain(config.getString(CONFIGURE_DEFAULT_DOMAIN, LOCALHOST));
 
@@ -133,7 +151,7 @@ public abstract class AbstractDomainList implements DomainList, LogEnabled,
Conf
         mutableDomains.addAll(detectedDomains);
         mutableDomains.addAll(detectIps(mutableDomains));
 
-        if (getLogger().isInfoEnabled()) {
+        if (getLogger().isDebugEnabled()) {
             for (String domain : mutableDomains) {
                 getLogger().debug("Handling mail for: " + domain);
             }

http://git-wip-us.apache.org/repos/asf/james-project/blob/6e36b22f/server/data/data-library/src/main/java/org/apache/james/domainlist/lib/EnvDetector.java
----------------------------------------------------------------------
diff --git a/server/data/data-library/src/main/java/org/apache/james/domainlist/lib/EnvDetector.java
b/server/data/data-library/src/main/java/org/apache/james/domainlist/lib/EnvDetector.java
new file mode 100644
index 0000000..9410295
--- /dev/null
+++ b/server/data/data-library/src/main/java/org/apache/james/domainlist/lib/EnvDetector.java
@@ -0,0 +1,26 @@
+/****************************************************************
+ * 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.domainlist.lib;
+
+public class EnvDetector {
+    public String getEnv(String variableName) {
+        return System.getenv(variableName);
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/6e36b22f/server/data/data-library/src/test/java/org/apache/james/domainlist/lib/AbstractDomainListPrivateMethodsTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-library/src/test/java/org/apache/james/domainlist/lib/AbstractDomainListPrivateMethodsTest.java
b/server/data/data-library/src/test/java/org/apache/james/domainlist/lib/AbstractDomainListPrivateMethodsTest.java
index 5098c08..9f6de93 100644
--- a/server/data/data-library/src/test/java/org/apache/james/domainlist/lib/AbstractDomainListPrivateMethodsTest.java
+++ b/server/data/data-library/src/test/java/org/apache/james/domainlist/lib/AbstractDomainListPrivateMethodsTest.java
@@ -45,12 +45,13 @@ public class AbstractDomainListPrivateMethodsTest {
     public static final Logger LOGGER = LoggerFactory.getLogger(AbstractDomainListPrivateMethodsTest.class);
     private MyDomainList domainList;
     private DNSService dnsService;
+    private EnvDetector envDetector;
 
     @Before
     public void setup() {
-        domainList = new MyDomainList();
         dnsService = mock(DNSService.class);
-        domainList.setDNSService(dnsService);
+        envDetector = mock(EnvDetector.class);
+        domainList = new MyDomainList(dnsService, envDetector);
         domainList.setLog(LOGGER);
     }
 
@@ -58,8 +59,9 @@ public class AbstractDomainListPrivateMethodsTest {
 
         private List<String> domains;
 
-        public MyDomainList() {
-            domains = Lists.newArrayList();
+        public MyDomainList(DNSService dns, EnvDetector envDetector) {
+            super(dns, envDetector);
+            this.domains = Lists.newArrayList();
         }
 
         @Override
@@ -307,7 +309,6 @@ public class AbstractDomainListPrivateMethodsTest {
 
         when(configuration.getBoolean(AbstractDomainList.CONFIGURE_AUTODETECT, true)).thenReturn(true);
         when(configuration.getBoolean(AbstractDomainList.CONFIGURE_AUTODETECT_IP, true)).thenReturn(false);
-        domainList.setLog(LOGGER);
         domainList.configure(configuration);
 
         String detected = "detected.tld";
@@ -316,4 +317,17 @@ public class AbstractDomainListPrivateMethodsTest {
         assertThat(domainList.containsDomain(detected)).isTrue();
     }
 
+    @Test
+    public void envDomainShouldBeAddedUponConfiguration() throws Exception {
+        String envDomain = "env.tld";
+        when(envDetector.getEnv(AbstractDomainList.ENV_DOMAIN)).thenReturn(envDomain);
+
+        HierarchicalConfiguration configuration = mock(HierarchicalConfiguration.class);
+        when(configuration.getBoolean(AbstractDomainList.CONFIGURE_AUTODETECT, true)).thenReturn(true);
+        when(configuration.getBoolean(AbstractDomainList.CONFIGURE_AUTODETECT_IP, true)).thenReturn(false);
+        domainList.configure(configuration);
+
+        assertThat(domainList.containsDomain(envDomain)).isTrue();
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/6e36b22f/server/data/data-memory/src/main/java/org/apache/james/domainlist/memory/MemoryDomainList.java
----------------------------------------------------------------------
diff --git a/server/data/data-memory/src/main/java/org/apache/james/domainlist/memory/MemoryDomainList.java
b/server/data/data-memory/src/main/java/org/apache/james/domainlist/memory/MemoryDomainList.java
index 5e135f7..d6c9033 100644
--- a/server/data/data-memory/src/main/java/org/apache/james/domainlist/memory/MemoryDomainList.java
+++ b/server/data/data-memory/src/main/java/org/apache/james/domainlist/memory/MemoryDomainList.java
@@ -23,8 +23,12 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.Locale;
 
+import javax.inject.Inject;
+
+import org.apache.james.dnsservice.api.DNSService;
 import org.apache.james.domainlist.api.DomainListException;
 import org.apache.james.domainlist.lib.AbstractDomainList;
+import org.apache.james.domainlist.lib.EnvDetector;
 
 import com.google.common.collect.ImmutableList;
 
@@ -32,7 +36,9 @@ public class MemoryDomainList extends AbstractDomainList {
 
     private final List<String> domains;
 
-    public MemoryDomainList() {
+    @Inject
+    public MemoryDomainList(DNSService dns, EnvDetector envDetector) {
+        super(dns, envDetector);
         this.domains = new ArrayList<String>();
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/6e36b22f/server/data/data-memory/src/test/java/org/apache/james/domainlist/memory/MemoryDomainListTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-memory/src/test/java/org/apache/james/domainlist/memory/MemoryDomainListTest.java
b/server/data/data-memory/src/test/java/org/apache/james/domainlist/memory/MemoryDomainListTest.java
index d23f6ef..0766c94 100644
--- a/server/data/data-memory/src/test/java/org/apache/james/domainlist/memory/MemoryDomainListTest.java
+++ b/server/data/data-memory/src/test/java/org/apache/james/domainlist/memory/MemoryDomainListTest.java
@@ -21,15 +21,15 @@ package org.apache.james.domainlist.memory;
 
 import org.apache.james.domainlist.api.DomainList;
 import org.apache.james.domainlist.lib.AbstractDomainListTest;
+import org.apache.james.domainlist.lib.EnvDetector;
 import org.slf4j.LoggerFactory;
 
 public class MemoryDomainListTest extends AbstractDomainListTest {
 
     @Override
     protected DomainList createDomainList() {
-        MemoryDomainList testee = new MemoryDomainList();
+        MemoryDomainList testee = new MemoryDomainList(getDNSServer("localhost"), new EnvDetector());
         testee.setLog(LoggerFactory.getLogger(getClass()));
-        testee.setDNSService(getDNSServer("localhost"));
         testee.setAutoDetect(false);
         testee.setAutoDetectIP(false);
         return testee;

http://git-wip-us.apache.org/repos/asf/james-project/blob/6e36b22f/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 a70d8a9..ab0dc93 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
@@ -26,6 +26,8 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 import org.apache.commons.configuration.HierarchicalConfiguration;
+import org.apache.james.dnsservice.api.DNSService;
+import org.apache.james.domainlist.lib.EnvDetector;
 import org.apache.james.domainlist.memory.MemoryDomainList;
 import org.apache.james.user.memory.MemoryUsersRepository;
 import org.apache.mailet.MailAddress;
@@ -41,6 +43,7 @@ public class JamesMailetContextTest {
     public static final String USERNAME = "user";
     public static final String USERMAIL = USERNAME + "@" + DOMAIN_COM;
     public static final String PASSWORD = "password";
+    public static final DNSService DNS_SERVICE = null;
 
     private MemoryDomainList domainList;
     private MemoryUsersRepository usersRepository;
@@ -49,7 +52,7 @@ public class JamesMailetContextTest {
 
     @Before
     public void setUp() throws Exception {
-        domainList = new MemoryDomainList();
+        domainList = new MemoryDomainList(DNS_SERVICE, new EnvDetector());
         domainList.setLog(LOGGER);
         usersRepository = MemoryUsersRepository.withVirtualHosting();
         usersRepository.setDomainList(domainList);

http://git-wip-us.apache.org/repos/asf/james-project/blob/6e36b22f/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 1df89d2..c30b106 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
@@ -38,6 +38,7 @@ import java.net.InetAddress;
 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.lib.EnvDetector;
 import org.apache.james.domainlist.memory.MemoryDomainList;
 import org.apache.james.metrics.logger.DefaultMetricFactory;
 import org.apache.james.webadmin.WebAdminServer;
@@ -94,8 +95,7 @@ public class DomainRoutesTest {
             when(dnsService.getHostName(any())).thenReturn("localhost");
             when(dnsService.getLocalHost()).thenReturn(InetAddress.getByName("localhost"));
 
-            MemoryDomainList domainList = new MemoryDomainList();
-            domainList.setDNSService(dnsService);
+            MemoryDomainList domainList = new MemoryDomainList(dnsService, new EnvDetector());
             domainList.setLog(LOGGER);
             domainList.setAutoDetectIP(false);
             createServer(domainList);


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


Mime
View raw message