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 ma...@apache.org on 2016/03/23 20:46:46 UTC
[03/24] james-project git commit: JAMES-1693 Provide an InMemory
domain list
JAMES-1693 Provide an InMemory domain list
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/e62f6f66
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/e62f6f66
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/e62f6f66
Branch: refs/heads/master
Commit: e62f6f66739ff21e9229d925cbcb6f82f0875d42
Parents: 70f6925
Author: Benoit Tellier <bt...@linagora.com>
Authored: Mon Feb 29 11:00:58 2016 +0700
Committer: Matthieu Baechler <ma...@linagora.com>
Committed: Wed Mar 23 17:03:55 2016 +0100
----------------------------------------------------------------------
server/data/data-memory/pom.xml | 6 ++
.../domainlist/memory/MemoryDomainList.java | 62 ++++++++++++++++++++
.../domainlist/memory/MemoryDomainListTest.java | 38 ++++++++++++
3 files changed, 106 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/e62f6f66/server/data/data-memory/pom.xml
----------------------------------------------------------------------
diff --git a/server/data/data-memory/pom.xml b/server/data/data-memory/pom.xml
index e8fbcc1..fcd01e3 100644
--- a/server/data/data-memory/pom.xml
+++ b/server/data/data-memory/pom.xml
@@ -53,6 +53,12 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>org.apache.james</groupId>
+ <artifactId>james-server-dnsservice-api</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
http://git-wip-us.apache.org/repos/asf/james-project/blob/e62f6f66/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
new file mode 100644
index 0000000..f6da3f7
--- /dev/null
+++ b/server/data/data-memory/src/main/java/org/apache/james/domainlist/memory/MemoryDomainList.java
@@ -0,0 +1,62 @@
+/****************************************************************
+ * 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.memory;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.james.domainlist.api.DomainListException;
+import org.apache.james.domainlist.lib.AbstractDomainList;
+
+import com.google.common.collect.ImmutableList;
+
+public class MemoryDomainList extends AbstractDomainList {
+
+ private final List<String> domains;
+
+ public MemoryDomainList() {
+ this.domains = new ArrayList<String>();
+ }
+
+ @Override
+ protected List<String> getDomainListInternal() throws DomainListException {
+ return ImmutableList.copyOf(domains);
+ }
+
+ @Override
+ public boolean containsDomain(String domain) throws DomainListException {
+ return domains.contains(domain.toLowerCase());
+ }
+
+ @Override
+ public void addDomain(String domain) throws DomainListException {
+ if (containsDomain(domain)) {
+ throw new DomainListException(domain.toLowerCase() + " already exists.");
+ }
+ domains.add(domain.toLowerCase());
+ }
+
+ @Override
+ public void removeDomain(String domain) throws DomainListException {
+ if (!domains.remove(domain.toLowerCase())) {
+ throw new DomainListException(domain.toLowerCase() + " was not found");
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/e62f6f66/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
new file mode 100644
index 0000000..d23f6ef
--- /dev/null
+++ b/server/data/data-memory/src/test/java/org/apache/james/domainlist/memory/MemoryDomainListTest.java
@@ -0,0 +1,38 @@
+/****************************************************************
+ * 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.memory;
+
+import org.apache.james.domainlist.api.DomainList;
+import org.apache.james.domainlist.lib.AbstractDomainListTest;
+import org.slf4j.LoggerFactory;
+
+public class MemoryDomainListTest extends AbstractDomainListTest {
+
+ @Override
+ protected DomainList createDomainList() {
+ MemoryDomainList testee = new MemoryDomainList();
+ testee.setLog(LoggerFactory.getLogger(getClass()));
+ testee.setDNSService(getDNSServer("localhost"));
+ testee.setAutoDetect(false);
+ testee.setAutoDetectIP(false);
+ return testee;
+ }
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org