http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/main/java/org/apache/james/utils/InMemoryMailRepositoryStore.java ---------------------------------------------------------------------- diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/utils/InMemoryMailRepositoryStore.java b/server/container/cassandra-guice/src/main/java/org/apache/james/utils/InMemoryMailRepositoryStore.java deleted file mode 100644 index 066f57a..0000000 --- a/server/container/cassandra-guice/src/main/java/org/apache/james/utils/InMemoryMailRepositoryStore.java +++ /dev/null @@ -1,164 +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.utils; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; -import java.util.stream.Collectors; - -import javax.inject.Singleton; - -import org.apache.commons.configuration.CombinedConfiguration; -import org.apache.commons.configuration.ConfigurationException; -import org.apache.commons.configuration.DefaultConfigurationBuilder; -import org.apache.commons.configuration.HierarchicalConfiguration; -import org.apache.james.lifecycle.api.Configurable; -import org.apache.james.lifecycle.api.LogEnabled; -import org.apache.james.mailrepository.api.MailRepository; -import org.apache.james.mailrepository.api.MailRepositoryStore; -import org.apache.james.repository.api.Initializable; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.inject.Inject; - -@Singleton -public class InMemoryMailRepositoryStore implements MailRepositoryStore { - - private static final Logger LOGGER = LoggerFactory.getLogger(InMemoryMailRepositoryStore.class); - - private final Set<MailRepositoryProvider> mailRepositories; - private final ConcurrentMap<String, MailRepository> destinationToRepositoryAssociations; - private final Map<String, MailRepositoryProvider> protocolToRepositoryProvider; - private final Map<String, HierarchicalConfiguration> perProtocolMailRepositoryDefaultConfiguration; - private HierarchicalConfiguration configuration; - - @Inject - public InMemoryMailRepositoryStore(Set<MailRepositoryProvider> mailRepositories) { - this.mailRepositories = mailRepositories; - this.destinationToRepositoryAssociations = new ConcurrentHashMap<>(); - this.protocolToRepositoryProvider = new HashMap<>(); - this.perProtocolMailRepositoryDefaultConfiguration = new HashMap<>(); - } - - @Override - public List<String> getUrls() { - return destinationToRepositoryAssociations.keySet() - .stream() - .collect(Collectors.toList()); - } - - public void configure(HierarchicalConfiguration configuration) throws ConfigurationException { - this.configuration = configuration; - } - - public void init() throws Exception { - LOGGER.info("JamesMailStore init... " + this); - List<HierarchicalConfiguration> registeredClasses = configuration.configurationsAt("mailrepositories.mailrepository"); - for (HierarchicalConfiguration registeredClass : registeredClasses) { - readConfigurationEntry(registeredClass); - } - } - - @Override - public MailRepository select(String destination) throws MailRepositoryStoreException { - MailRepository mailRepository = destinationToRepositoryAssociations.get(destination); - if (mailRepository != null) { - return mailRepository; - } - String protocol = retrieveProtocol(destination); - mailRepository = retrieveMailRepository(protocol); - mailRepository = initialiseNewRepository(mailRepository, createRepositoryCombinedConfig(destination, protocol)); - destinationToRepositoryAssociations.putIfAbsent(destination, mailRepository); - return mailRepository; - } - - private void readConfigurationEntry(HierarchicalConfiguration repositoryConfiguration) throws ConfigurationException { - String className = repositoryConfiguration.getString("[@class]"); - MailRepositoryProvider usedMailRepository = mailRepositories.stream() - .filter(mailRepositoryProvider -> mailRepositoryProvider.canonicalName().equals(className)) - .findAny() - .orElseThrow(() -> new ConfigurationException("MailRepository " + className + " has not been registered")); - for (String protocol : repositoryConfiguration.getStringArray("protocols.protocol")) { - protocolToRepositoryProvider.put(protocol, usedMailRepository); - registerRepositoryDefaultConfiguration(repositoryConfiguration, protocol); - } - } - - private void registerRepositoryDefaultConfiguration(HierarchicalConfiguration repositoryConfiguration, String protocol) { - HierarchicalConfiguration defConf = null; - if (repositoryConfiguration.getKeys("config").hasNext()) { - defConf = repositoryConfiguration.configurationAt("config"); - } - if (defConf != null) { - perProtocolMailRepositoryDefaultConfiguration.put(protocol, defConf); - } - } - - private CombinedConfiguration createRepositoryCombinedConfig(String destination, String protocol) { - final CombinedConfiguration config = new CombinedConfiguration(); - HierarchicalConfiguration defaultProtocolConfig = perProtocolMailRepositoryDefaultConfiguration.get(protocol); - if (defaultProtocolConfig != null) { - config.addConfiguration(defaultProtocolConfig); - } - DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder(); - builder.addProperty("[@destinationURL]", destination); - config.addConfiguration(builder); - return config; - } - - private MailRepository initialiseNewRepository(MailRepository mailRepository, CombinedConfiguration config) throws MailRepositoryStoreException { - try { - if (mailRepository instanceof LogEnabled) { - ((LogEnabled) mailRepository).setLog(LOGGER); - } - if (mailRepository instanceof Configurable) { - ((Configurable) mailRepository).configure(config); - } - if (mailRepository instanceof Initializable) { - ((Initializable) mailRepository).init(); - } - return mailRepository; - } catch (Exception e) { - throw new MailRepositoryStoreException("Cannot init mail repository", e); - } - } - - private MailRepository retrieveMailRepository(String protocol) throws MailRepositoryStoreException { - MailRepositoryProvider repositoryProvider = protocolToRepositoryProvider.get(protocol); - if (repositoryProvider == null) { - throw new MailRepositoryStoreException("No Mail Repository associated with " + protocol); - } - return repositoryProvider.get(); - } - - private String retrieveProtocol(String destination) throws MailRepositoryStoreException { - int protocolSeparatorPosition = destination.indexOf(':'); - if (protocolSeparatorPosition == -1) { - throw new MailRepositoryStoreException("Destination is malformed. Must be a valid URL: " + destination); - } - return destination.substring(0, protocolSeparatorPosition); - } - -}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/main/java/org/apache/james/utils/MailRepositoryProvider.java ---------------------------------------------------------------------- diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/utils/MailRepositoryProvider.java b/server/container/cassandra-guice/src/main/java/org/apache/james/utils/MailRepositoryProvider.java deleted file mode 100644 index 52b7d15..0000000 --- a/server/container/cassandra-guice/src/main/java/org/apache/james/utils/MailRepositoryProvider.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.utils; - -import org.apache.james.mailrepository.api.MailRepository; - -import javax.inject.Provider; - -public interface MailRepositoryProvider extends Provider<MailRepository> { - - String canonicalName(); -} http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/main/java/org/apache/james/utils/MailboxManagerDefinition.java ---------------------------------------------------------------------- diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/utils/MailboxManagerDefinition.java b/server/container/cassandra-guice/src/main/java/org/apache/james/utils/MailboxManagerDefinition.java deleted file mode 100644 index 211398a..0000000 --- a/server/container/cassandra-guice/src/main/java/org/apache/james/utils/MailboxManagerDefinition.java +++ /dev/null @@ -1,57 +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.utils; - -import org.apache.james.mailbox.MailboxManager; - -import com.google.common.base.Objects; - -public class MailboxManagerDefinition { - - private final String name; - private final MailboxManager manager; - - public MailboxManagerDefinition(String name, MailboxManager manager) { - this.name = name; - this.manager = manager; - } - - public MailboxManager getManager() { - return manager; - } - - public String getName() { - return name; - } - - @Override - public int hashCode() { - return Objects.hashCode(name, manager); - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof MailboxManagerDefinition) { - MailboxManagerDefinition other = (MailboxManagerDefinition) obj; - return Objects.equal(name, other.name) && Objects.equal(manager, other.manager); - } - return false; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/main/java/org/apache/james/utils/PropertiesReader.java ---------------------------------------------------------------------- diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/utils/PropertiesReader.java b/server/container/cassandra-guice/src/main/java/org/apache/james/utils/PropertiesReader.java deleted file mode 100644 index e859ff7..0000000 --- a/server/container/cassandra-guice/src/main/java/org/apache/james/utils/PropertiesReader.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.utils; - -import com.google.common.base.Throwables; - -import java.io.IOException; -import java.util.Properties; - -public class PropertiesReader { - - private final Properties properties; - - public PropertiesReader(String fileName) { - properties = new Properties(); - try { - properties.load(ClassLoader.getSystemResourceAsStream(fileName)); - } catch (IOException e) { - throw Throwables.propagate(e); - } - } - - public String getProperty(String key) { - return properties.getProperty(key); - } -} http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/test/java/org/apache/james/CassandraJamesServerTest.java ---------------------------------------------------------------------- diff --git a/server/container/cassandra-guice/src/test/java/org/apache/james/CassandraJamesServerTest.java b/server/container/cassandra-guice/src/test/java/org/apache/james/CassandraJamesServerTest.java deleted file mode 100644 index 9b7127e..0000000 --- a/server/container/cassandra-guice/src/test/java/org/apache/james/CassandraJamesServerTest.java +++ /dev/null @@ -1,157 +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; - -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.assertj.core.api.Assertions.assertThat; - -import java.io.IOException; -import java.net.InetSocketAddress; -import java.nio.ByteBuffer; -import java.nio.channels.SocketChannel; -import java.nio.charset.Charset; - -import org.apache.james.backends.cassandra.CassandraCluster; -import org.apache.james.backends.cassandra.components.CassandraModule; -import org.apache.james.jmap.methods.GetMessageListMethod; -import org.apache.james.mailbox.elasticsearch.EmbeddedElasticSearch; -import org.apache.james.modules.TestElasticSearchModule; -import org.apache.james.modules.TestFilesystemModule; -import org.apache.james.modules.TestJMAPServerModule; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.RuleChain; -import org.junit.rules.TemporaryFolder; - -import com.google.common.base.Charsets; -import com.google.inject.AbstractModule; -import com.google.inject.Module; -import com.google.inject.Provides; -import com.google.inject.Singleton; -import com.google.inject.util.Modules; -import com.jayway.restassured.RestAssured; -import com.jayway.restassured.http.ContentType; - -public class CassandraJamesServerTest { - - private static final int IMAP_PORT = 1143; // You need to be root (superuser) to bind to ports under 1024. - private static final int IMAP_PORT_SSL = 1993; - private static final int POP3_PORT = 1110; - private static final int SMTP_PORT = 1025; - private static final int LMTP_PORT = 1024; - public static final int BUFFER_SIZE = 1000; - - private CassandraJamesServer server; - private TemporaryFolder temporaryFolder = new TemporaryFolder(); - private EmbeddedElasticSearch embeddedElasticSearch = new EmbeddedElasticSearch(); - private SocketChannel socketChannel; - - @Rule - public RuleChain chain = RuleChain.outerRule(temporaryFolder).around(embeddedElasticSearch); - - @Before - public void setup() throws Exception { - server = new CassandraJamesServer(createModule()); - socketChannel = SocketChannel.open(); - - server.start(); - - RestAssured.port = server.getJmapPort(); - RestAssured.config = newConfig().encoderConfig(encoderConfig().defaultContentCharset(Charsets.UTF_8)); - } - - private Module createModule() { - return Modules.override(CassandraJamesServerMain.defaultModule) - .with(new TestElasticSearchModule(embeddedElasticSearch), - new TestFilesystemModule(temporaryFolder), - new TestJMAPServerModule(GetMessageListMethod.DEFAULT_MAXIMUM_LIMIT), - new AbstractModule() { - - @Override - protected void configure() { - } - - @Provides - @Singleton - com.datastax.driver.core.Session provideSession(CassandraModule cassandraModule) { - CassandraCluster cassandra = CassandraCluster.create(cassandraModule); - return cassandra.getConf(); - } - - }); - } - - @After - public void tearDown() throws Exception { - server.stop(); - } - - @Test - public void connectIMAPServerShouldSendShabangOnConnect() throws Exception { - socketChannel.connect(new InetSocketAddress("127.0.0.1", IMAP_PORT)); - assertThat(getServerConnectionResponse(socketChannel)).startsWith("* OK JAMES IMAP4rev1 Server"); - } - - @Test - public void connectOnSecondaryIMAPServerIMAPServerShouldSendShabangOnConnect() throws Exception { - socketChannel.connect(new InetSocketAddress("127.0.0.1", IMAP_PORT_SSL)); - assertThat(getServerConnectionResponse(socketChannel)).startsWith("* OK JAMES IMAP4rev1 Server"); - } - - @Test - public void connectPOP3ServerShouldSendShabangOnConnect() throws Exception { - socketChannel.connect(new InetSocketAddress("127.0.0.1", POP3_PORT)); - assertThat(getServerConnectionResponse(socketChannel)).contains("POP3 server (JAMES POP3 Server ) ready"); - } - - @Test - public void connectSMTPServerShouldSendShabangOnConnect() throws Exception { - socketChannel.connect(new InetSocketAddress("127.0.0.1", SMTP_PORT)); - assertThat(getServerConnectionResponse(socketChannel)).startsWith("220 JAMES Linagora's SMTP awesome Server"); - } - - @Test - public void connectLMTPServerShouldSendShabangOnConnect() throws Exception { - socketChannel.connect(new InetSocketAddress("127.0.0.1", LMTP_PORT)); - assertThat(getServerConnectionResponse(socketChannel)).contains("LMTP Server (JAMES Protocols Server) ready"); - } - - @Test - public void connectJMAPServerShouldRespondBadRequest() throws Exception { - given() - .contentType(ContentType.JSON) - .accept(ContentType.JSON) - .body("{\"badAttributeName\": \"value\"}") - .when() - .post("/authentication") - .then() - .statusCode(400); - } - - private String getServerConnectionResponse(SocketChannel socketChannel) throws IOException { - ByteBuffer byteBuffer = ByteBuffer.allocate(1000); - socketChannel.read(byteBuffer); - byte[] bytes = byteBuffer.array(); - return new String(bytes, Charset.forName("UTF-8")); - } -} http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/test/java/org/apache/james/modules/TestElasticSearchModule.java ---------------------------------------------------------------------- diff --git a/server/container/cassandra-guice/src/test/java/org/apache/james/modules/TestElasticSearchModule.java b/server/container/cassandra-guice/src/test/java/org/apache/james/modules/TestElasticSearchModule.java deleted file mode 100644 index 6da278f..0000000 --- a/server/container/cassandra-guice/src/test/java/org/apache/james/modules/TestElasticSearchModule.java +++ /dev/null @@ -1,52 +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; - -import com.google.inject.AbstractModule; -import com.google.inject.Provides; -import org.apache.james.mailbox.elasticsearch.ClientProvider; -import org.apache.james.mailbox.elasticsearch.EmbeddedElasticSearch; -import org.apache.james.mailbox.elasticsearch.IndexCreationFactory; -import org.apache.james.mailbox.elasticsearch.NodeMappingFactory; -import org.apache.james.mailbox.elasticsearch.utils.TestingClientProvider; - -import javax.inject.Singleton; - -public class TestElasticSearchModule extends AbstractModule{ - - private final EmbeddedElasticSearch embeddedElasticSearch; - - public TestElasticSearchModule(EmbeddedElasticSearch embeddedElasticSearch) { - this.embeddedElasticSearch = embeddedElasticSearch; - } - - @Override - protected void configure() { - - } - - @Provides - @Singleton - protected ClientProvider provideClientProvider() { - return NodeMappingFactory.applyMapping( - IndexCreationFactory.createIndex(new TestingClientProvider(embeddedElasticSearch.getNode())) - ); - } -} http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/test/java/org/apache/james/modules/TestFilesystemModule.java ---------------------------------------------------------------------- diff --git a/server/container/cassandra-guice/src/test/java/org/apache/james/modules/TestFilesystemModule.java b/server/container/cassandra-guice/src/test/java/org/apache/james/modules/TestFilesystemModule.java deleted file mode 100644 index 9f5bba4..0000000 --- a/server/container/cassandra-guice/src/test/java/org/apache/james/modules/TestFilesystemModule.java +++ /dev/null @@ -1,61 +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; - -import java.io.File; -import java.io.IOException; -import java.util.function.Supplier; - -import org.apache.james.core.JamesServerResourceLoader; -import org.apache.james.filesystem.api.FileSystem; -import org.apache.james.filesystem.api.JamesDirectoriesProvider; -import org.junit.rules.TemporaryFolder; - -import com.google.common.base.Throwables; -import com.google.inject.AbstractModule; -import com.google.inject.name.Names; - -public class TestFilesystemModule extends AbstractModule { - - private final Supplier<File> workingDirectory; - - private static File createTempDir(TemporaryFolder temporaryFolder) { - try { - return temporaryFolder.newFolder(); - } catch (IOException e) { - throw Throwables.propagate(e); - } - } - - public TestFilesystemModule(TemporaryFolder temporaryFolder) { - this(() -> TestFilesystemModule.createTempDir(temporaryFolder)); - } - - public TestFilesystemModule(Supplier<File> workingDirectory) { - this.workingDirectory = workingDirectory; - } - - @Override - protected void configure() { - bind(JamesDirectoriesProvider.class).toInstance(new JamesServerResourceLoader(workingDirectory.get().getAbsolutePath())); - bindConstant().annotatedWith(Names.named(CommonServicesModule.CONFIGURATION_PATH)).to(FileSystem.CLASSPATH_PROTOCOL); - } - -} http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/test/java/org/apache/james/modules/TestJMAPServerModule.java ---------------------------------------------------------------------- diff --git a/server/container/cassandra-guice/src/test/java/org/apache/james/modules/TestJMAPServerModule.java b/server/container/cassandra-guice/src/test/java/org/apache/james/modules/TestJMAPServerModule.java deleted file mode 100644 index 6512fac..0000000 --- a/server/container/cassandra-guice/src/test/java/org/apache/james/modules/TestJMAPServerModule.java +++ /dev/null @@ -1,68 +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; - -import java.io.FileNotFoundException; -import java.util.Optional; - -import javax.inject.Singleton; - -import org.apache.commons.configuration.ConfigurationException; -import org.apache.james.jmap.JMAPConfiguration; -import org.apache.james.jmap.methods.GetMessageListMethod; - -import com.google.inject.AbstractModule; -import com.google.inject.Provides; -import com.google.inject.name.Names; - -public class TestJMAPServerModule extends AbstractModule{ - - private static final String PUBLIC_PEM_KEY = "-----BEGIN PUBLIC KEY-----\n" + - "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtlChO/nlVP27MpdkG0Bh\n" + - "16XrMRf6M4NeyGa7j5+1UKm42IKUf3lM28oe82MqIIRyvskPc11NuzSor8HmvH8H\n" + - "lhDs5DyJtx2qp35AT0zCqfwlaDnlDc/QDlZv1CoRZGpQk1Inyh6SbZwYpxxwh0fi\n" + - "+d/4RpE3LBVo8wgOaXPylOlHxsDizfkL8QwXItyakBfMO6jWQRrj7/9WDhGf4Hi+\n" + - "GQur1tPGZDl9mvCoRHjFrD5M/yypIPlfMGWFVEvV5jClNMLAQ9bYFuOc7H1fEWw6\n" + - "U1LZUUbJW9/CH45YXz82CYqkrfbnQxqRb2iVbVjs/sHopHd1NTiCfUtwvcYJiBVj\n" + - "kwIDAQAB\n" + - "-----END PUBLIC KEY-----"; - - private final int maximumLimit; - - public TestJMAPServerModule(int maximumLimit) { - this.maximumLimit = maximumLimit; - } - - @Override - protected void configure() { - bindConstant().annotatedWith(Names.named(GetMessageListMethod.MAXIMUM_LIMIT)).to(maximumLimit); - } - - @Provides - @Singleton - JMAPConfiguration provideConfiguration() throws FileNotFoundException, ConfigurationException{ - return JMAPConfiguration.builder() - .keystore("keystore") - .secret("james72laBalle") - .jwtPublicKeyPem(Optional.of(PUBLIC_PEM_KEY)) - .randomPort() - .build(); - } -} http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/test/java/org/apache/james/utils/FileConfigurationProviderTest.java ---------------------------------------------------------------------- diff --git a/server/container/cassandra-guice/src/test/java/org/apache/james/utils/FileConfigurationProviderTest.java b/server/container/cassandra-guice/src/test/java/org/apache/james/utils/FileConfigurationProviderTest.java deleted file mode 100644 index 4fe0360..0000000 --- a/server/container/cassandra-guice/src/test/java/org/apache/james/utils/FileConfigurationProviderTest.java +++ /dev/null @@ -1,119 +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.utils; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.apache.commons.cli.MissingArgumentException; -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.filesystem.api.FileSystem; -import org.junit.Before; -import org.junit.Test; - -public class FileConfigurationProviderTest { - - private static final String CONFIG_KEY_1 = "test2"; - private static final String CONFIG_KEY_2 = "property"; - private static final String CONFIG_KEY_4 = "james"; - private static final String CONFIG_KEY_5 = "internal"; - private static final String VALUE_1 = "0"; - private static final String VALUE_2 = "awesome"; - private static final String VALUE_3 = "james"; - private static final String FAKE_CONFIG_KEY = "fake"; - private static final String ROOT_CONFIG_KEY = "test"; - private static final String CONFIG_SEPARATOR = "."; - - private FileConfigurationProvider configurationProvider; - - @Before - public void setUp() throws MissingArgumentException { - FileSystemImpl fileSystem = new FileSystemImpl(new JamesServerResourceLoader("../")); - configurationProvider = new FileConfigurationProvider(fileSystem, FileSystem.CLASSPATH_PROTOCOL); - } - - @Test(expected = IllegalArgumentException.class) - public void emptyArgumentShouldThrow() throws Exception { - configurationProvider.getConfiguration(""); - } - - @Test(expected = NullPointerException.class) - public void nullArgumentShouldThrow() throws Exception { - configurationProvider.getConfiguration(null); - } - - @Test(expected = IllegalArgumentException.class) - public void configSeparatorArgumentShouldThrow() throws Exception { - configurationProvider.getConfiguration(CONFIG_SEPARATOR); - } - - @Test(expected = IllegalArgumentException.class) - public void emptyFileNameShouldThrow() throws Exception { - configurationProvider.getConfiguration(CONFIG_SEPARATOR + ROOT_CONFIG_KEY); - } - - @Test - public void getConfigurationShouldLoadCorrespondingXMLFile() throws Exception { - HierarchicalConfiguration hierarchicalConfiguration = configurationProvider.getConfiguration(ROOT_CONFIG_KEY); - assertThat(hierarchicalConfiguration.getKeys()).containsOnly(CONFIG_KEY_1, - String.join(CONFIG_SEPARATOR, CONFIG_KEY_4, CONFIG_KEY_2), - String.join(CONFIG_SEPARATOR, CONFIG_KEY_4, CONFIG_KEY_5, CONFIG_KEY_2)); - assertThat(hierarchicalConfiguration.getProperty(CONFIG_KEY_1)).isEqualTo(VALUE_1); - } - - @Test - public void getConfigurationShouldLoadCorrespondingXMLFilePart() throws Exception { - HierarchicalConfiguration hierarchicalConfiguration = configurationProvider.getConfiguration( - String.join(CONFIG_SEPARATOR, ROOT_CONFIG_KEY, CONFIG_KEY_4)); - assertThat(hierarchicalConfiguration.getKeys()).containsOnly(CONFIG_KEY_2, - String.join(CONFIG_SEPARATOR, CONFIG_KEY_5, CONFIG_KEY_2)); - assertThat(hierarchicalConfiguration.getProperty(CONFIG_KEY_2)).isEqualTo(VALUE_2); - } - - @Test - public void getConfigurationShouldLoadCorrespondingXMLFileWhenAPathIsProvidedPart() throws Exception { - HierarchicalConfiguration hierarchicalConfiguration = configurationProvider.getConfiguration( - String.join(CONFIG_SEPARATOR, ROOT_CONFIG_KEY, CONFIG_KEY_4, CONFIG_KEY_5)); - assertThat(hierarchicalConfiguration.getKeys()).containsOnly(CONFIG_KEY_2); - assertThat(hierarchicalConfiguration.getProperty(CONFIG_KEY_2)).isEqualTo(VALUE_3); - } - - @Test - public void multiplesSeparatorsShouldBeTolerated() throws Exception { - HierarchicalConfiguration hierarchicalConfiguration = configurationProvider.getConfiguration( - ROOT_CONFIG_KEY + CONFIG_SEPARATOR + CONFIG_SEPARATOR + CONFIG_KEY_4); - assertThat(hierarchicalConfiguration.getKeys()).containsOnly(CONFIG_KEY_2, - String.join(CONFIG_SEPARATOR, CONFIG_KEY_5, CONFIG_KEY_2)); - assertThat(hierarchicalConfiguration.getProperty(CONFIG_KEY_2)).isEqualTo(VALUE_2); - } - - @Test(expected = ConfigurationException.class) - public void getConfigurationShouldThrowOnNonExistingXMLFile() throws Exception { - assertThat(configurationProvider.getConfiguration(FAKE_CONFIG_KEY)).isNotNull(); - } - - @Test(expected = IllegalArgumentException.class) - public void getConfigurationShouldThrowOnNonExistingXMLFilePart() throws Exception { - configurationProvider.getConfiguration(String.join(CONFIG_SEPARATOR, ROOT_CONFIG_KEY, FAKE_CONFIG_KEY)); - } - -} http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/test/java/org/apache/james/utils/InMemoryMailRepositoryStoreTest.java ---------------------------------------------------------------------- diff --git a/server/container/cassandra-guice/src/test/java/org/apache/james/utils/InMemoryMailRepositoryStoreTest.java b/server/container/cassandra-guice/src/test/java/org/apache/james/utils/InMemoryMailRepositoryStoreTest.java deleted file mode 100644 index d8582b3..0000000 --- a/server/container/cassandra-guice/src/test/java/org/apache/james/utils/InMemoryMailRepositoryStoreTest.java +++ /dev/null @@ -1,109 +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.utils; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.fail; - -import org.apache.commons.configuration.ConfigurationException; -import org.apache.james.core.JamesServerResourceLoader; -import org.apache.james.core.filesystem.FileSystemImpl; -import org.apache.james.filesystem.api.FileSystem; -import org.apache.james.mailrepository.api.MailRepositoryStore; -import org.apache.james.mailrepository.file.FileMailRepository; -import org.apache.james.modules.server.MailStoreRepositoryModule; -import org.junit.Before; -import org.junit.Test; - -import com.google.common.collect.Sets; - -public class InMemoryMailRepositoryStoreTest { - - private InMemoryMailRepositoryStore repositoryStore; - private FileSystemImpl fileSystem; - - @Before - public void setUp() throws Exception { - fileSystem = new FileSystemImpl(new JamesServerResourceLoader("../")); - repositoryStore = new InMemoryMailRepositoryStore(Sets.newHashSet( - new MailStoreRepositoryModule.FileMailRepositoryProvider( - fileSystem))); - repositoryStore.configure(new FileConfigurationProvider(fileSystem, FileSystem.CLASSPATH_PROTOCOL).getConfiguration("mailrepositorystore")); - repositoryStore.init(); - } - - @Test(expected = MailRepositoryStore.MailRepositoryStoreException.class) - public void selectingANonRegisteredProtocolShouldFail() throws Exception { - repositoryStore.select("proto://repo"); - } - - @Test - public void selectingARegisteredProtocolShouldWork() throws Exception { - assertThat(repositoryStore.select("file://repo")).isInstanceOf(FileMailRepository.class); - } - - @Test - public void selectingTwiceARegisteredProtocolWithSameDestinationShouldReturnTheSameResult() throws Exception { - assertThat(repositoryStore.select("file://repo")).isEqualTo(repositoryStore.select("file://repo")); - } - - @Test - public void selectingTwiceARegisteredProtocolWithDifferentDestinationShouldReturnDifferentResults() throws Exception { - assertThat(repositoryStore.select("file://repo")).isNotEqualTo(repositoryStore.select("file://repo1")); - } - - @Test(expected = ConfigurationException.class) - public void configureShouldThrowWhenNonValidClassesAreProvided() throws Exception { - try { - repositoryStore = new InMemoryMailRepositoryStore(Sets.newHashSet( - new MailStoreRepositoryModule.FileMailRepositoryProvider( - fileSystem))); - repositoryStore.configure(new FileConfigurationProvider(fileSystem, FileSystem.CLASSPATH_PROTOCOL).getConfiguration("fakemailrepositorystore")); - } catch (ConfigurationException e) { - fail("Unexpected failure : ", e); - } - repositoryStore.init(); - } - - @Test - public void getUrlsShouldBeEmptyIfNoSelectWerePerformed() { - assertThat(repositoryStore.getUrls()).isEmpty(); - } - - @Test - public void getUrlsShouldReturnUsedUrls() throws Exception { - String url1 = "file://repo1"; - String url2 = "file://repo2"; - String url3 = "file://repo3"; - repositoryStore.select(url1); - repositoryStore.select(url2); - repositoryStore.select(url3); - assertThat(repositoryStore.getUrls()).containsOnly(url1, url2, url3); - } - - @Test - public void getUrlsResultsShouldNotBeDuplicated() throws Exception { - String url1 = "file://repo1"; - repositoryStore.select(url1); - repositoryStore.select(url1); - assertThat(repositoryStore.getUrls()).containsExactly(url1); - } - -} http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/test/java/org/apache/james/utils/PropertiesReadTest.java ---------------------------------------------------------------------- diff --git a/server/container/cassandra-guice/src/test/java/org/apache/james/utils/PropertiesReadTest.java b/server/container/cassandra-guice/src/test/java/org/apache/james/utils/PropertiesReadTest.java deleted file mode 100644 index 1d3de34..0000000 --- a/server/container/cassandra-guice/src/test/java/org/apache/james/utils/PropertiesReadTest.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.utils; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.junit.Test; - -public class PropertiesReadTest { - - @Test - public void getPropertyShouldWork() throws Exception { - PropertiesReader propertiesReader = new PropertiesReader("test.properties"); - assertThat(propertiesReader.getProperty("cassandra.ip")).isEqualTo("127.0.0.1"); - } - - @Test - public void getAbsentPropertyShouldReturnNull() throws Exception { - PropertiesReader propertiesReader = new PropertiesReader("test.properties"); - assertThat(propertiesReader.getProperty("cassandra.isslow")).isNull(); - } - - @Test(expected = RuntimeException.class) - public void buildingAPropertiesReaderOnNonExistingValuesShouldThrow() throws Exception { - new PropertiesReader("fake.properties"); - } -} http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/test/resources/dnsservice.xml ---------------------------------------------------------------------- diff --git a/server/container/cassandra-guice/src/test/resources/dnsservice.xml b/server/container/cassandra-guice/src/test/resources/dnsservice.xml deleted file mode 100644 index 0978a00..0000000 --- a/server/container/cassandra-guice/src/test/resources/dnsservice.xml +++ /dev/null @@ -1,29 +0,0 @@ -<?xml version="1.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. - --> - -<dnsservice> - <servers> - <server>8.8.8.8</server> - <server>62.210.16.6</server> - </servers> - <autodiscover>false</autodiscover> - <authoritative>false</authoritative> - <maxcachesize>50000</maxcachesize> -</dnsservice> http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/test/resources/fakemailrepositorystore.xml ---------------------------------------------------------------------- diff --git a/server/container/cassandra-guice/src/test/resources/fakemailrepositorystore.xml b/server/container/cassandra-guice/src/test/resources/fakemailrepositorystore.xml deleted file mode 100644 index 2d19a80..0000000 --- a/server/container/cassandra-guice/src/test/resources/fakemailrepositorystore.xml +++ /dev/null @@ -1,31 +0,0 @@ -<?xml version="1.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. - --> - -<mailrepositorystore> - <mailrepositories> - <mailrepository class="org.apache.james.mailrepository.None"> - <protocols> - <protocol>file</protocol> - </protocols> - <config FIFO="false" CACHEKEYS="true"/> - </mailrepository> - </mailrepositories> -</mailrepositorystore> http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/test/resources/imapserver.xml ---------------------------------------------------------------------- diff --git a/server/container/cassandra-guice/src/test/resources/imapserver.xml b/server/container/cassandra-guice/src/test/resources/imapserver.xml deleted file mode 100644 index ff478a9..0000000 --- a/server/container/cassandra-guice/src/test/resources/imapserver.xml +++ /dev/null @@ -1,54 +0,0 @@ -<?xml version="1.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. ---> - - -<imapservers> - <imapserver enabled="true"> - <jmxName>imapserver</jmxName> - <bind>0.0.0.0:1143</bind> - <connectionBacklog>200</connectionBacklog> - <tls socketTLS="false" startTLS="false"> - <!-- To create a new keystore execute: - keytool -genkey -alias james -keyalg RSA -keystore /path/to/james/conf/keystore - --> - <keystore>file://conf/keystore</keystore> - <secret>james72laBalle</secret> - <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider> - </tls> - <connectionLimit>0</connectionLimit> - <connectionLimitPerIP>0</connectionLimitPerIP> - </imapserver> - <imapserver enabled="true"> - <jmxName>imapserver-ssl</jmxName> - <bind>0.0.0.0:1993</bind> - <connectionBacklog>200</connectionBacklog> - <tls socketTLS="false" startTLS="false"> - <!-- To create a new keystore execute: - keytool -genkey -alias james -keyalg RSA -keystore /path/to/james/conf/keystore - --> - <keystore>file://conf/keystore</keystore> - <secret>james72laBalle</secret> - <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider> - </tls> - <connectionLimit>0</connectionLimit> - <connectionLimitPerIP>0</connectionLimitPerIP> - </imapserver> -</imapservers> http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/test/resources/keystore ---------------------------------------------------------------------- diff --git a/server/container/cassandra-guice/src/test/resources/keystore b/server/container/cassandra-guice/src/test/resources/keystore deleted file mode 100644 index 536a6c7..0000000 Binary files a/server/container/cassandra-guice/src/test/resources/keystore and /dev/null differ http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/test/resources/lmtpserver.xml ---------------------------------------------------------------------- diff --git a/server/container/cassandra-guice/src/test/resources/lmtpserver.xml b/server/container/cassandra-guice/src/test/resources/lmtpserver.xml deleted file mode 100644 index 5c4a9c7..0000000 --- a/server/container/cassandra-guice/src/test/resources/lmtpserver.xml +++ /dev/null @@ -1,41 +0,0 @@ -<?xml version="1.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. - --> - -<lmtpservers> - - <lmtpserver enabled="true"> - <jmxName>lmtpserver</jmxName> - <!-- LMTP should not be reachable from outside your network so bind it to loopback--> - <bind>127.0.0.1:1024</bind> - <connectionBacklog>200</connectionBacklog> - <connectiontimeout>1200</connectiontimeout> - <!-- Set the maximum simultaneous incoming connections for this service --> - <connectionLimit>0</connectionLimit> - <!-- Set the maximum simultaneous incoming connections per IP for this service --> - <connectionLimitPerIP>0</connectionLimitPerIP> - <!-- This sets the maximum allowed message size (in kilobytes) for this --> - <!-- LMTP service. If unspecified, the value defaults to 0, which means no limit. --> - <maxmessagesize>0</maxmessagesize> - <handlerchain> - <handler class="org.apache.james.lmtpserver.CoreCmdHandlerLoader"/> - </handlerchain> - </lmtpserver> - -</lmtpservers> http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/test/resources/mailetcontainer.xml ---------------------------------------------------------------------- diff --git a/server/container/cassandra-guice/src/test/resources/mailetcontainer.xml b/server/container/cassandra-guice/src/test/resources/mailetcontainer.xml deleted file mode 100644 index 57c5784..0000000 --- a/server/container/cassandra-guice/src/test/resources/mailetcontainer.xml +++ /dev/null @@ -1,168 +0,0 @@ -<?xml version="1.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. - --> - -<mailetcontainer enableJmx="false"> - - <context> - <postmaster>postmas...@james.minet.net</postmaster> - </context> - - <spooler> - <threads>20</threads> - </spooler> - - <processors> - <processor state="root" enableJmx="false"> - <mailet match="All" class="PostmasterAlias"/> - <mailet match="RelayLimit=30" class="Null"/> - <!-- Hook on sievemana...@james.linagora.com - Mail send to this address will get interpreted with SIEVE Manage --> - <mailet match="RecipientIs=sievemana...@james.linagora.com" class="ToProcessor"> - <processor>sieve-manager-check</processor> - </mailet> - <mailet match="HasMailAttribute=spamChecked" class="ToProcessor"> - <processor>transport</processor> - </mailet> - <mailet match="All" class="SetMailAttribute"> - <spamChecked>true</spamChecked> - </mailet> - <mailet match="SMTPAuthSuccessful" class="ToProcessor"> - <processor>transport</processor> - </mailet> - <mailet match="InSpammerBlacklist=query.bondedsender.org." class="ToProcessor"> - <processor>transport</processor> - </mailet> - <!-- Check for delivery from a known spam server --> - <!-- This set of matchers/mailets redirect all emails from known --> - <!-- black holes, open relays, and spam servers to the spam processor --> - <!-- For this set to function properly, the spam processor must be configured. --> - <mailet match="InSpammerBlacklist=dnsbl.njabl.org." class="ToProcessor"> - <processor>spam</processor> - <notice>550 Requested action not taken: rejected - see http://njabl.org/</notice> - </mailet> - <mailet match="All" class="ToProcessor"> - <processor>transport</processor> - </mailet> - </processor> - - <processor state="error" enableJmx="false"> - <mailet match="All" class="Bounce"/> - <mailet match="All" class="ToRepository"> - <repositoryPath>file://var/mail/error/</repositoryPath> - </mailet> - </processor> - - - <processor state="transport" enableJmx="false"> - <mailet match="SMTPAuthSuccessful" class="SetMimeHeader"> - <name>X-UserIsAuth</name> - <value>true</value> - </mailet> - <mailet match="HasMailAttribute=org.apache.james.SMIMECheckSignature" class="SetMimeHeader"> - <name>X-WasSigned</name> - <value>true</value> - </mailet> - <mailet match="All" class="RemoveMimeHeader"> - <name>bcc</name> - </mailet> - <mailet match="All" class="RecipientRewriteTable" /> - <mailet match="RecipientIsLocal" class="LocalDelivery"/> - <mailet match="HostIsLocal" class="ToProcessor"> - <processor>local-address-error</processor> - <notice>550 - Requested action not taken: no such user here</notice> - </mailet> - <mailet match="SMTPAuthSuccessful" class="RemoteDelivery"> - <outgoingQueue>outgoing</outgoingQueue> - <delayTime>5000, 100000, 500000</delayTime> - <maxRetries>25</maxRetries> - <maxDnsProblemRetries>0</maxDnsProblemRetries> - <deliveryThreads>10</deliveryThreads> - <sendpartial>true</sendpartial> - <bounceProcessor>bounces</bounceProcessor> - </mailet> - <mailet match="All" class="ToProcessor"> - <processor>relay-denied</processor> - </mailet> - </processor> - - <processor state="spam" enableJmx="false"> - <mailet match="All" class="ToRepository"> - <repositoryPath>file://var/mail/spam/</repositoryPath> - </mailet> - </processor> - - <processor state="local-address-error" enableJmx="false"> - <mailet match="All" class="Bounce"> - <attachment>none</attachment> - </mailet> - <mailet match="All" class="ToRepository"> - <repositoryPath>file://var/mail/address-error/</repositoryPath> - </mailet> - </processor> - - <processor state="relay-denied" enableJmx="false"> - <mailet match="All" class="Bounce"> - <attachment>none</attachment> - </mailet> - <mailet match="All" class="ToRepository"> - <repositoryPath>file://var/mail/relay-denied/</repositoryPath> - <notice>Warning: You are sending an e-mail to a remote server. You must be authentified to perform such an operation</notice> - </mailet> - </processor> - - <processor state="bounces" enableJmx="false"> - <mailet match="All" class="DSNBounce"> - <passThrough>false</passThrough> - </mailet> - </processor> - - <processor state="sieve-manager-check" enableJmx="false"> - <!-- Only local users can manage their scripts --> - <mailet match="RecipientIsLocal" class="ToProcessor"> - <processor>sieve-manager</processor> - </mailet> - <!-- Notify other people about their failure --> - <mailet match="All" class="Bounce"> - <inline>heads</inline> - <attachment>none</attachment> - <passThrough>false</passThrough> - <prefix>[REJECTED]</prefix> - <notice> - You can't send messages to configure SIEVE on this serveur unless you are the official SIEVE manager. - </notice> - </mailet> - <mailet match="All" class="Null"/> - </processor> - - <processor state="sieve-manager"> - <mailet match="All" class="SetMailAttribute"> - <org.apache.james.SMTPAuthUser>true</org.apache.james.SMTPAuthUser> - </mailet> - <mailet match="All" class="org.apache.james.transport.mailets.managesieve.ManageSieveMailet"> - <helpURL>file:/root/james-server-app-3.0.0-beta5-SNAPSHOT/conf/managesieve.help.txt</helpURL> - </mailet> - <mailet match="All" class="Null"/> - </processor> - </processors> - -</mailetcontainer> - - http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/test/resources/mailrepositorystore.xml ---------------------------------------------------------------------- diff --git a/server/container/cassandra-guice/src/test/resources/mailrepositorystore.xml b/server/container/cassandra-guice/src/test/resources/mailrepositorystore.xml deleted file mode 100644 index 3ca4a1d..0000000 --- a/server/container/cassandra-guice/src/test/resources/mailrepositorystore.xml +++ /dev/null @@ -1,31 +0,0 @@ -<?xml version="1.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. - --> - -<mailrepositorystore> - <mailrepositories> - <mailrepository class="org.apache.james.mailrepository.file.FileMailRepository"> - <protocols> - <protocol>file</protocol> - </protocols> - <config FIFO="false" CACHEKEYS="true"/> - </mailrepository> - </mailrepositories> -</mailrepositorystore> http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/test/resources/managesieveserver.xml ---------------------------------------------------------------------- diff --git a/server/container/cassandra-guice/src/test/resources/managesieveserver.xml b/server/container/cassandra-guice/src/test/resources/managesieveserver.xml deleted file mode 100644 index ec57e09..0000000 --- a/server/container/cassandra-guice/src/test/resources/managesieveserver.xml +++ /dev/null @@ -1,65 +0,0 @@ -<?xml version="1.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. - --> - -<!-- - This template file can be used as example for James Server configuration - DO NOT USE IT AS SUCH AND ADAPT IT TO YOUR NEEDS ---> - -<!-- See http://james.apache.org/server/3/config.html for usage --> - -<managesieveservers> - - <managesieveserver enabled="true"> - - <jmxName>managesieveserver</jmxName> - - <bind>0.0.0.0:4190</bind> - - <connectionBacklog>200</connectionBacklog> - - <tls socketTLS="false" startTLS="false"> - <!-- To create a new keystore execute: - keytool -genkey -alias james -keyalg RSA -keystore /path/to/james/conf/keystore - --> - <keystore>file://conf/keystore</keystore> - <secret>james72laBalle</secret> - <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider> - <!-- The algorithm is optional and only needs to be specified when using something other - than the Sun JCE provider - You could use IbmX509 with IBM Java runtime. --> - <algorithm>SunX509</algorithm> - </tls> - - <!-- connection timeout in secconds --> - <connectiontimeout>360</connectiontimeout> - - <!-- Set the maximum simultaneous incoming connections for this service --> - <connectionLimit>0</connectionLimit> - - <!-- Set the maximum simultaneous incoming connections per IP for this service --> - <connectionLimitPerIP>0</connectionLimitPerIP> - <maxmessagesize>0</maxmessagesize> - <addressBracketsEnforcement>true</addressBracketsEnforcement> - - </managesieveserver> - -</managesieveservers> - - http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/test/resources/pop3server.xml ---------------------------------------------------------------------- diff --git a/server/container/cassandra-guice/src/test/resources/pop3server.xml b/server/container/cassandra-guice/src/test/resources/pop3server.xml deleted file mode 100644 index e4187da..0000000 --- a/server/container/cassandra-guice/src/test/resources/pop3server.xml +++ /dev/null @@ -1,42 +0,0 @@ -<?xml version="1.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. - --> - - -<pop3servers> - <pop3server enabled="true"> - <jmxName>pop3server</jmxName> - <bind>0.0.0.0:1110</bind> - <connectionBacklog>200</connectionBacklog> - <tls socketTLS="false" startTLS="false"> - <!-- To create a new keystore execute: - keytool -genkey -alias james -keyalg RSA -keystore /path/to/james/conf/keystore - --> - <keystore>file://conf/keystore</keystore> - <secret>james72laBalle</secret> - <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider> - </tls> - <connectiontimeout>1200</connectiontimeout> - <connectionLimit>0</connectionLimit> - <connectionLimitPerIP>0</connectionLimitPerIP> - <handlerchain> - <handler class="org.apache.james.pop3server.core.CoreCmdHandlerLoader"/> - </handlerchain> - </pop3server> -</pop3servers> http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/test/resources/smtpserver.xml ---------------------------------------------------------------------- diff --git a/server/container/cassandra-guice/src/test/resources/smtpserver.xml b/server/container/cassandra-guice/src/test/resources/smtpserver.xml deleted file mode 100644 index a3d4b8f..0000000 --- a/server/container/cassandra-guice/src/test/resources/smtpserver.xml +++ /dev/null @@ -1,105 +0,0 @@ -<?xml version="1.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. - --> - -<smtpservers> - <smtpserver enabled="true"> - <jmxName>smtpserver-global</jmxName> - <bind>0.0.0.0:1025</bind> - <connectionBacklog>200</connectionBacklog> - <tls socketTLS="false" startTLS="false"> - <keystore>file://conf/keystore</keystore> - <secret>james72laBalle</secret> - <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider> - <algorithm>SunX509</algorithm> - </tls> - <connectiontimeout>360</connectiontimeout> - <connectionLimit>0</connectionLimit> - <connectionLimitPerIP>0</connectionLimitPerIP> - <authRequired>false</authRequired> - <authorizedAddresses>0.0.0.0/0</authorizedAddresses> - <verifyIdentity>true</verifyIdentity> - <maxmessagesize>0</maxmessagesize> - <addressBracketsEnforcement>true</addressBracketsEnforcement> - <smtpGreeting>JAMES Linagora's SMTP awesome Server</smtpGreeting> - <handlerchain> - <handler class="org.apache.james.smtpserver.fastfail.ValidRcptHandler"/> - <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/> - </handlerchain> - </smtpserver> - <smtpserver enabled="true"> - <jmxName>smtpserver-TLS</jmxName> - <bind>0.0.0.0:10465</bind> - <connectionBacklog>200</connectionBacklog> - <tls socketTLS="false" startTLS="false"> - <keystore>file://conf/keystore</keystore> - <secret>james72laBalle</secret> - <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider> - <algorithm>SunX509</algorithm> - </tls> - <connectiontimeout>360</connectiontimeout> - <connectionLimit>0</connectionLimit> - <connectionLimitPerIP>0</connectionLimitPerIP> - <!-- - Authorize only local users - --> - <authRequired>true</authRequired> - <authorizedAddresses>0.0.0.0/0</authorizedAddresses> - <!-- Trust authenticated users --> - <verifyIdentity>false</verifyIdentity> - <maxmessagesize>0</maxmessagesize> - <addressBracketsEnforcement>true</addressBracketsEnforcement> - <smtpGreeting>JAMES Linagora's SMTP awesome Server</smtpGreeting> - <handlerchain> - <handler class="org.apache.james.smtpserver.fastfail.ValidRcptHandler"/> - <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/> - </handlerchain> - </smtpserver> - <smtpserver enabled="true"> - <jmxName>smtpserver-authenticated</jmxName> - <bind>0.0.0.0:1587</bind> - <connectionBacklog>200</connectionBacklog> - <tls socketTLS="false" startTLS="false"> - <keystore>file://conf/keystore</keystore> - <secret>james72laBalle</secret> - <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider> - <algorithm>SunX509</algorithm> - </tls> - <connectiontimeout>360</connectiontimeout> - <connectionLimit>0</connectionLimit> - <connectionLimitPerIP>0</connectionLimitPerIP> - <!-- - Authorize only local users - --> - <authRequired>true</authRequired> - <authorizedAddresses>0.0.0.0/0</authorizedAddresses> - <!-- Trust authenticated users --> - <verifyIdentity>false</verifyIdentity> - <maxmessagesize>0</maxmessagesize> - <addressBracketsEnforcement>true</addressBracketsEnforcement> - <smtpGreeting>JAMES Linagora's SMTP awesome Server</smtpGreeting> - <handlerchain> - <handler class="org.apache.james.smtpserver.fastfail.ValidRcptHandler"/> - <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/> - </handlerchain> - </smtpserver> -</smtpservers> - - http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/test/resources/test.properties ---------------------------------------------------------------------- diff --git a/server/container/cassandra-guice/src/test/resources/test.properties b/server/container/cassandra-guice/src/test/resources/test.properties deleted file mode 100644 index b4db9c1..0000000 --- a/server/container/cassandra-guice/src/test/resources/test.properties +++ /dev/null @@ -1,6 +0,0 @@ -# Configuration file for cassandra mailbox - -cassandra.ip=127.0.0.1 -cassandra.port=9142 -cassandra.keyspace=apache_james -cassandra.replication.factor=1 \ No newline at end of file http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/test/resources/test.xml ---------------------------------------------------------------------- diff --git a/server/container/cassandra-guice/src/test/resources/test.xml b/server/container/cassandra-guice/src/test/resources/test.xml deleted file mode 100644 index 8d89ecc..0000000 --- a/server/container/cassandra-guice/src/test/resources/test.xml +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.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. - --> -<test> - <test2>0</test2> - <james> - <property>awesome</property> - <internal> - <property>james</property> - </internal> - </james> -</test> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/cassandra-guice/README.adoc ---------------------------------------------------------------------- diff --git a/server/container/guice/cassandra-guice/README.adoc b/server/container/guice/cassandra-guice/README.adoc new file mode 100644 index 0000000..e3648ff --- /dev/null +++ b/server/container/guice/cassandra-guice/README.adoc @@ -0,0 +1,45 @@ += Guice-Cassandra Module How-to + +== Building + +=== Requirements + + * Java 8 SDK + * Docker + * Maven + +=== Building the artifacts + +An usual compilation using maven will produce two artifacts into target directory : + + * james-server-cassandra-guice-${version}.jar + * james-server-cassandra-guice-${version}.lib + +== Running + +=== Requirements + + * Cassandra + * ElasticSearch 1.5.2 + +=== James Launch + +To run james, you have to create a directory containing required configuration files. + +A sample directory (appropriately named sample-directory) is provided with some +default value you may need to replace. + +You also need to generate a keystore with the following command : +[source] +---- +$ keytool -genkey -alias james -keyalg RSA -keystore conf/keystore +---- + +You need to have a Cassandra and an ElasticSearch instance running. + +Once everything is set up, you just have to run the jar with : + +[source] +---- +$ java -Dworking.directory=sample-configuration -jar target/james-server-cassandra-guice-${version}.jar +---- --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org