JAMES-1617 MPT test for ManageSieve with Cassandra Storage
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/a081bfd8 Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/a081bfd8 Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/a081bfd8 Branch: refs/heads/master Commit: a081bfd8689a7818207e2fad10c44a0ef719ab1c Parents: 96dfc5d Author: Benoit Tellier <btell...@apache.org> Authored: Wed Feb 17 14:20:26 2016 +0700 Committer: Benoit Tellier <btell...@linagora.com> Committed: Thu Apr 7 09:13:35 2016 +0700 ---------------------------------------------------------------------- mpt/impl/managesieve/cassandra/pom.xml | 216 +++++++++++++++++++ .../managesieve/cassandra/CassandraModule.java | 40 ++++ .../cassandra/ManageSieveCassandraTest.java | 60 ++++++ .../cassandra/host/CassandraHostSystem.java | 59 +++++ mpt/impl/managesieve/file/pom.xml | 2 - .../managesieve/file/host/FileHostSystem.java | 1 + mpt/impl/managesieve/pom.xml | 71 ++++++ mpt/pom.xml | 5 + .../cassandra/CassandraUsersRepository.java | 10 +- .../james/user/lib/AbstractUsersRepository.java | 6 +- 10 files changed, 462 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/a081bfd8/mpt/impl/managesieve/cassandra/pom.xml ---------------------------------------------------------------------- diff --git a/mpt/impl/managesieve/cassandra/pom.xml b/mpt/impl/managesieve/cassandra/pom.xml new file mode 100644 index 0000000..c823357 --- /dev/null +++ b/mpt/impl/managesieve/cassandra/pom.xml @@ -0,0 +1,216 @@ +<?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>apache-james-mpt-managesieve</artifactId> + <groupId>org.apache.james</groupId> + <version>0.2-SNAPSHOT</version> + <relativePath>..</relativePath> + </parent> + <modelVersion>4.0.0</modelVersion> + + <artifactId>apache-james-mpt-managesieve-cassandra</artifactId> + + <name>Apache James MPT ManageSieve Cassandra</name> + + <profiles> + <profile> + <id>disable-build-for-older-jdk</id> + <activation> + <jdk>(,1.8)</jdk> + </activation> + <build> + <plugins> + <plugin> + <artifactId>maven-jar-plugin</artifactId> + <executions> + <execution> + <id>default-jar</id> + <phase>none</phase> + </execution> + <execution> + <id>jar</id> + <phase>none</phase> + </execution> + <execution> + <id>test-jar</id> + <phase>none</phase> + </execution> + </executions> + </plugin> + <plugin> + <artifactId>maven-compiler-plugin</artifactId> + <executions> + <execution> + <id>default-compile</id> + <phase>none</phase> + </execution> + <execution> + <id>default-testCompile</id> + <phase>none</phase> + </execution> + </executions> + </plugin> + <plugin> + <artifactId>maven-surefire-plugin</artifactId> + <executions> + <execution> + <id>default-test</id> + <phase>none</phase> + </execution> + </executions> + </plugin> + <plugin> + <artifactId>maven-source-plugin</artifactId> + <executions> + <execution> + <id>attach-sources</id> + <phase>none</phase> + </execution> + </executions> + </plugin> + <plugin> + <artifactId>maven-install-plugin</artifactId> + <executions> + <execution> + <id>default-install</id> + <phase>none</phase> + </execution> + </executions> + </plugin> + <plugin> + <artifactId>maven-resources-plugin</artifactId> + <executions> + <execution> + <id>default-resources</id> + <phase>none</phase> + </execution> + <execution> + <id>default-testResources</id> + <phase>none</phase> + </execution> + </executions> + </plugin> + <plugin> + <artifactId>maven-site-plugin</artifactId> + <executions> + <execution> + <id>attach-descriptor</id> + <phase>none</phase> + </execution> + </executions> + </plugin> + </plugins> + </build> + </profile> + <profile> + <id>build-for-jdk-8</id> + <activation> + <jdk>[1.8,)</jdk> + </activation> + <dependencies> + <dependency> + <groupId>org.apache.james</groupId> + <artifactId>apache-james-mpt-managesieve-core</artifactId> + </dependency> + <dependency> + <groupId>org.apache.james</groupId> + <artifactId>apache-james-backends-cassandra</artifactId> + </dependency> + <dependency> + <groupId>org.apache.james</groupId> + <artifactId>apache-james-backends-cassandra</artifactId> + <type>test-jar</type> + </dependency> + <dependency> + <groupId>org.apache.james</groupId> + <artifactId>james-server-data-cassandra</artifactId> + </dependency> + <dependency> + <groupId>org.cassandraunit</groupId> + <artifactId>cassandra-unit</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + <build> + <plugins> + <plugin> + <artifactId>maven-assembly-plugin</artifactId> + <configuration> + <archive> + <manifest> + <mainClass>fully.qualified.MainClass</mainClass> + </manifest> + </archive> + <descriptorRefs> + <descriptorRef>jar-with-dependencies</descriptorRef> + </descriptorRefs> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <source>1.8</source> + <target>1.8</target> + </configuration> + </plugin> + </plugins> + </build> + </profile> + <profile> + <id>disable-animal-sniffer</id> + <activation> + <jdk>[1.6,)</jdk> + </activation> + <build> + <plugins> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>animal-sniffer-maven-plugin</artifactId> + <executions> + <execution> + <id>check_java_6</id> + <phase>none</phase> + </execution> + </executions> + </plugin> + </plugins> + </build> + </profile> + </profiles> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <configuration> + <excludes> + <exclude>**/suite/*.java</exclude> + <exclude>**/suite/**/*.java</exclude> + </excludes> + </configuration> + </plugin> + </plugins> + </build> +</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/james-project/blob/a081bfd8/mpt/impl/managesieve/cassandra/src/test/java/org/apache/james/mpt/managesieve/cassandra/CassandraModule.java ---------------------------------------------------------------------- diff --git a/mpt/impl/managesieve/cassandra/src/test/java/org/apache/james/mpt/managesieve/cassandra/CassandraModule.java b/mpt/impl/managesieve/cassandra/src/test/java/org/apache/james/mpt/managesieve/cassandra/CassandraModule.java new file mode 100644 index 0000000..6c22f05 --- /dev/null +++ b/mpt/impl/managesieve/cassandra/src/test/java/org/apache/james/mpt/managesieve/cassandra/CassandraModule.java @@ -0,0 +1,40 @@ +/**************************************************************** + * 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.mpt.managesieve.cassandra; + +import com.google.inject.AbstractModule; +import com.google.inject.Provides; +import com.google.inject.Singleton; +import org.apache.james.mpt.host.ManageSieveHostSystem; +import org.apache.james.mpt.managesieve.cassandra.host.CassandraHostSystem; + +public class CassandraModule extends AbstractModule { + + @Override + protected void configure() { + + } + + @Provides + @Singleton + public ManageSieveHostSystem provideHostSystem() throws Exception { + return new CassandraHostSystem(); + } +} http://git-wip-us.apache.org/repos/asf/james-project/blob/a081bfd8/mpt/impl/managesieve/cassandra/src/test/java/org/apache/james/mpt/managesieve/cassandra/ManageSieveCassandraTest.java ---------------------------------------------------------------------- diff --git a/mpt/impl/managesieve/cassandra/src/test/java/org/apache/james/mpt/managesieve/cassandra/ManageSieveCassandraTest.java b/mpt/impl/managesieve/cassandra/src/test/java/org/apache/james/mpt/managesieve/cassandra/ManageSieveCassandraTest.java new file mode 100644 index 0000000..f41af26 --- /dev/null +++ b/mpt/impl/managesieve/cassandra/src/test/java/org/apache/james/mpt/managesieve/cassandra/ManageSieveCassandraTest.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.mpt.managesieve.cassandra; + +import org.apache.james.mpt.testsuite.AuthenticateTest; +import org.apache.james.mpt.testsuite.CapabilityTest; +import org.apache.james.mpt.testsuite.CheckScriptTest; +import org.apache.james.mpt.testsuite.DeleteScriptTest; +import org.apache.james.mpt.testsuite.GetScriptTest; +import org.apache.james.mpt.testsuite.HaveSpaceTest; +import org.apache.james.mpt.testsuite.ListScriptsTest; +import org.apache.james.mpt.testsuite.LogoutTest; +import org.apache.james.mpt.testsuite.NoopTest; +import org.apache.james.mpt.testsuite.PutScriptTest; +import org.apache.james.mpt.testsuite.RenameScriptTest; +import org.apache.james.mpt.testsuite.SetActiveTest; +import org.apache.james.mpt.testsuite.StartTlsTest; +import org.apache.james.mpt.testsuite.UnauthenticatedTest; +import org.apache.onami.test.OnamiSuite; +import org.apache.onami.test.annotation.GuiceModules; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +@GuiceModules({ CassandraModule.class }) +@RunWith(OnamiSuite.class) +@Suite.SuiteClasses({ + NoopTest.class, + UnauthenticatedTest.class, + LogoutTest.class, + AuthenticateTest.class, + StartTlsTest.class, + CapabilityTest.class, + HaveSpaceTest.class, + PutScriptTest.class, + SetActiveTest.class, + GetScriptTest.class, + DeleteScriptTest.class, + RenameScriptTest.class, + CheckScriptTest.class, + ListScriptsTest.class +}) +public class ManageSieveCassandraTest { +} http://git-wip-us.apache.org/repos/asf/james-project/blob/a081bfd8/mpt/impl/managesieve/cassandra/src/test/java/org/apache/james/mpt/managesieve/cassandra/host/CassandraHostSystem.java ---------------------------------------------------------------------- diff --git a/mpt/impl/managesieve/cassandra/src/test/java/org/apache/james/mpt/managesieve/cassandra/host/CassandraHostSystem.java b/mpt/impl/managesieve/cassandra/src/test/java/org/apache/james/mpt/managesieve/cassandra/host/CassandraHostSystem.java new file mode 100644 index 0000000..4f317e8 --- /dev/null +++ b/mpt/impl/managesieve/cassandra/src/test/java/org/apache/james/mpt/managesieve/cassandra/host/CassandraHostSystem.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.mpt.managesieve.cassandra.host; + +import org.apache.james.backends.cassandra.init.CassandraModuleComposite; +import org.apache.james.backends.cassandra.utils.CassandraAsyncExecutor; +import org.apache.james.mpt.host.JamesManageSieveHostSystem; +import org.apache.james.sieve.cassandra.CassandraSieveDAO; +import org.apache.james.sieve.cassandra.CassandraSieveRepository; +import org.apache.james.sieve.cassandra.CassandraSieveRepositoryModule; +import org.apache.james.sieverepository.api.SieveRepository; +import org.apache.james.user.api.UsersRepository; +import org.apache.james.user.cassandra.CassandraUsersRepository; +import org.apache.james.backends.cassandra.CassandraCluster; +import org.apache.james.user.cassandra.CassandraUsersRepositoryModule; + +public class CassandraHostSystem extends JamesManageSieveHostSystem { + private static CassandraCluster CASSANDRA_CLUSTER = CassandraCluster.create(new CassandraModuleComposite( + new CassandraSieveRepositoryModule(), + new CassandraUsersRepositoryModule())); + + public CassandraHostSystem() throws Exception { + super(createUsersRepository(), createSieveRepository()); + } + + protected static SieveRepository createSieveRepository() throws Exception { + return new CassandraSieveRepository(new CassandraSieveDAO(CASSANDRA_CLUSTER.getConf())); + } + + protected static UsersRepository createUsersRepository() { + CassandraUsersRepository cassandraUsersRepository = new CassandraUsersRepository(); + cassandraUsersRepository.setSession(CASSANDRA_CLUSTER.getConf()); + cassandraUsersRepository.setEnableVirtualHosting(false); + return cassandraUsersRepository; + } + + @Override + protected void resetData() throws Exception { + CASSANDRA_CLUSTER.clearAllTables(); + } + +} http://git-wip-us.apache.org/repos/asf/james-project/blob/a081bfd8/mpt/impl/managesieve/file/pom.xml ---------------------------------------------------------------------- diff --git a/mpt/impl/managesieve/file/pom.xml b/mpt/impl/managesieve/file/pom.xml index 937df41..4fa2df9 100644 --- a/mpt/impl/managesieve/file/pom.xml +++ b/mpt/impl/managesieve/file/pom.xml @@ -35,7 +35,6 @@ <dependency> <groupId>org.apache.james</groupId> <artifactId>apache-james-mpt-managesieve-core</artifactId> - <version>0.2-SNAPSHOT</version> </dependency> <dependency> <groupId>org.apache.james</groupId> @@ -45,7 +44,6 @@ <dependency> <groupId>org.apache.james</groupId> <artifactId>james-server-data-memory</artifactId> - <version>${james.version}</version> </dependency> </dependencies> http://git-wip-us.apache.org/repos/asf/james-project/blob/a081bfd8/mpt/impl/managesieve/file/src/test/java/org/apache/james/mpt/managesieve/file/host/FileHostSystem.java ---------------------------------------------------------------------- diff --git a/mpt/impl/managesieve/file/src/test/java/org/apache/james/mpt/managesieve/file/host/FileHostSystem.java b/mpt/impl/managesieve/file/src/test/java/org/apache/james/mpt/managesieve/file/host/FileHostSystem.java index 2ed61f3..a6260bf 100644 --- a/mpt/impl/managesieve/file/src/test/java/org/apache/james/mpt/managesieve/file/host/FileHostSystem.java +++ b/mpt/impl/managesieve/file/src/test/java/org/apache/james/mpt/managesieve/file/host/FileHostSystem.java @@ -11,6 +11,7 @@ import org.apache.james.filesystem.api.FileSystem; import org.apache.james.mpt.host.JamesManageSieveHostSystem; import org.apache.james.sieverepository.api.SieveRepository; import org.apache.james.sieverepository.file.SieveFileRepository; +import org.apache.james.user.api.UsersRepository; import org.apache.james.user.memory.MemoryUsersRepository; public class FileHostSystem extends JamesManageSieveHostSystem { http://git-wip-us.apache.org/repos/asf/james-project/blob/a081bfd8/mpt/impl/managesieve/pom.xml ---------------------------------------------------------------------- diff --git a/mpt/impl/managesieve/pom.xml b/mpt/impl/managesieve/pom.xml index a802e5d..7c604a7 100644 --- a/mpt/impl/managesieve/pom.xml +++ b/mpt/impl/managesieve/pom.xml @@ -14,10 +14,81 @@ <artifactId>apache-james-mpt-managesieve</artifactId> <packaging>pom</packaging> + <modules> <module>core</module> <module>file</module> + <module>cassandra</module> </modules> + <dependencyManagement> + <dependencies> + <dependency> + <groupId>org.apache.james</groupId> + <artifactId>apache-james-mpt-managesieve-cassandra</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.james</groupId> + <artifactId>apache-james-mpt-managesieve-file</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.james</groupId> + <artifactId>apache-james-mpt-managesieve-core</artifactId> + <version>0.2-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.apache.james</groupId> + <artifactId>james-server-data-memory</artifactId> + <version>${james.version}</version> + </dependency> + </dependencies> + </dependencyManagement> + + <profiles> + <profile> + <id>cassandra</id> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <configuration> + <includes> + <include>**/cassandra/**/*.java</include> + </includes> + <excludes> + <exclude>**/suite/*.java</exclude> + <exclude>**/suite/**/*.java</exclude> + </excludes> + </configuration> + </plugin> + </plugins> + </build> + </profile> + <profile> + <id>file</id> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <configuration> + <includes> + <include>**/file/**/*.java</include> + </includes> + <excludes> + <exclude>**/suite/*.java</exclude> + <exclude>**/suite/**/*.java</exclude> + </excludes> + </configuration> + </plugin> + </plugins> + </build> + </profile> + </profiles> </project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/james-project/blob/a081bfd8/mpt/pom.xml ---------------------------------------------------------------------- diff --git a/mpt/pom.xml b/mpt/pom.xml index afc2fd6..fbe5819 100644 --- a/mpt/pom.xml +++ b/mpt/pom.xml @@ -251,6 +251,11 @@ </dependency> <dependency> <groupId>org.apache.james</groupId> + <artifactId>james-server-data-cassandra</artifactId> + <version>${james.version}</version> + </dependency> + <dependency> + <groupId>org.apache.james</groupId> <artifactId>james-server-dnsservice-api</artifactId> <version>${james.version}</version> </dependency> http://git-wip-us.apache.org/repos/asf/james-project/blob/a081bfd8/server/data/data-cassandra/src/main/java/org/apache/james/user/cassandra/CassandraUsersRepository.java ---------------------------------------------------------------------- diff --git a/server/data/data-cassandra/src/main/java/org/apache/james/user/cassandra/CassandraUsersRepository.java b/server/data/data-cassandra/src/main/java/org/apache/james/user/cassandra/CassandraUsersRepository.java index a51fbfa..958dca9 100644 --- a/server/data/data-cassandra/src/main/java/org/apache/james/user/cassandra/CassandraUsersRepository.java +++ b/server/data/data-cassandra/src/main/java/org/apache/james/user/cassandra/CassandraUsersRepository.java @@ -60,11 +60,6 @@ public class CassandraUsersRepository extends AbstractUsersRepository { public void setSession(Session session) { this.session = session; } - - @Override - public boolean supportVirtualHosting() { - return true; - } @Override public User getUserByName(String name){ @@ -163,4 +158,9 @@ public class CassandraUsersRepository extends AbstractUsersRepository { throw new UsersRepositoryException("User with username " + username + " already exist!"); } } + + @Override + protected boolean getDefaultVirtualHostingValue() { + return true; + } } http://git-wip-us.apache.org/repos/asf/james-project/blob/a081bfd8/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 b3988ab..3f57dba 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 @@ -55,11 +55,15 @@ public abstract class AbstractUsersRepository implements UsersRepository, LogEna */ public void configure(HierarchicalConfiguration configuration) throws ConfigurationException { - virtualHosting = configuration.getBoolean("enableVirtualHosting", false); + virtualHosting = configuration.getBoolean("enableVirtualHosting", getDefaultVirtualHostingValue()); doConfigure(configuration); } + protected boolean getDefaultVirtualHostingValue() { + return false; + } + protected void doConfigure(HierarchicalConfiguration config) throws ConfigurationException { } --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org