This is an automated email from the ASF dual-hosted git repository. rouazana pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 6727dada135a6da6e01c1d490ea5da1b7f173a0c Author: Rémi Kowalski <[email protected]> AuthorDate: Thu May 2 14:08:49 2019 +0200 JAMES-2754 extract external James configuration --- .../compilation/java-8/integration_tests.sh | 12 +++++- .../external/james/ExternalJamesModule.java | 11 +++-- .../ExternalJamesConfiguration.java} | 23 +++------- ...alJamesConfigurationEnvironnementVariables.java | 50 ++++++++++++++++++++++ ...ystem.java => ExternalJamesImapHostSystem.java} | 14 ++---- 5 files changed, 77 insertions(+), 33 deletions(-) diff --git a/dockerfiles/compilation/java-8/integration_tests.sh b/dockerfiles/compilation/java-8/integration_tests.sh index bfef037..bbe13ed 100755 --- a/dockerfiles/compilation/java-8/integration_tests.sh +++ b/dockerfiles/compilation/java-8/integration_tests.sh @@ -5,6 +5,7 @@ printUsage() { echo "./integration_tests.sh URL BRANCH JAMES_IP JAMES_IMAP_PORT" echo " JAMES_IP: IP of the James server to be tests" echo " JAMES_IMAP_PORT: Exposed IMAP port of this James server" + echo " JAMES_SMTP_PORT: Exposed SMTP port of this James server" echo " SHA1(optional): Branch to build or master if none" exit 1 } @@ -26,7 +27,10 @@ do JAMES_IMAP_PORT=$2 fi if ! [ -z "$3" ]; then - SHA1=$3 + JAMES_SMTP_PORT=$3 + fi + if ! [ -z "$4" ]; then + SHA1=$4 fi ;; esac @@ -42,12 +46,18 @@ if [ -z "$JAMES_IMAP_PORT" ]; then printUsage fi +if [ -z "JAMES_SMTP_PORT" ]; then + echo "You must provide a JAMES_SMTP_PORT" + printUsage +fi + if [ -z "$SHA1" ]; then SHA1=master fi export JAMES_ADDRESS=$JAMES_ADDRESS export JAMES_IMAP_PORT=$JAMES_IMAP_PORT +export JAMES_SMTP_PORT=$JAMES_SMTP_PORT git clone $ORIGIN/. git checkout $SHA1 diff --git a/mpt/impl/imap-mailbox/external-james/src/test/java/org/apache/james/mpt/imapmailbox/external/james/ExternalJamesModule.java b/mpt/impl/imap-mailbox/external-james/src/test/java/org/apache/james/mpt/imapmailbox/external/james/ExternalJamesModule.java index 0d3f7f1..2daf013 100644 --- a/mpt/impl/imap-mailbox/external-james/src/test/java/org/apache/james/mpt/imapmailbox/external/james/ExternalJamesModule.java +++ b/mpt/impl/imap-mailbox/external-james/src/test/java/org/apache/james/mpt/imapmailbox/external/james/ExternalJamesModule.java @@ -23,7 +23,9 @@ import org.apache.james.mpt.api.HostSystem; import org.apache.james.mpt.api.ImapHostSystem; import org.apache.james.mpt.api.UserAdder; import org.apache.james.mpt.host.ExternalHostSystem; -import org.apache.james.mpt.imapmailbox.external.james.host.ExternalJamesHostSystem; +import org.apache.james.mpt.imapmailbox.external.james.host.ExternalJamesConfiguration; +import org.apache.james.mpt.imapmailbox.external.james.host.ExternalJamesConfigurationEnvironnementVariables; +import org.apache.james.mpt.imapmailbox.external.james.host.ExternalJamesImapHostSystem; import org.apache.james.mpt.imapmailbox.external.james.host.ExternalJamesUserAdder; import com.google.inject.AbstractModule; @@ -32,9 +34,10 @@ public class ExternalJamesModule extends AbstractModule { @Override protected void configure() { - bind(ImapHostSystem.class).to(ExternalJamesHostSystem.class); - bind(HostSystem.class).to(ExternalJamesHostSystem.class); - bind(ExternalHostSystem.class).to(ExternalJamesHostSystem.class); + bind(ExternalJamesConfiguration.class).to(ExternalJamesConfigurationEnvironnementVariables.class); + bind(ImapHostSystem.class).to(ExternalJamesImapHostSystem.class); + bind(HostSystem.class).to(ExternalJamesImapHostSystem.class); + bind(ExternalHostSystem.class).to(ExternalJamesImapHostSystem.class); bind(UserAdder.class).to(ExternalJamesUserAdder.class); } diff --git a/mpt/impl/imap-mailbox/external-james/src/test/java/org/apache/james/mpt/imapmailbox/external/james/ExternalJamesModule.java b/mpt/impl/imap-mailbox/external-james/src/test/java/org/apache/james/mpt/imapmailbox/external/james/host/ExternalJamesConfiguration.java similarity index 58% copy from mpt/impl/imap-mailbox/external-james/src/test/java/org/apache/james/mpt/imapmailbox/external/james/ExternalJamesModule.java copy to mpt/impl/imap-mailbox/external-james/src/test/java/org/apache/james/mpt/imapmailbox/external/james/host/ExternalJamesConfiguration.java index 0d3f7f1..209218b 100644 --- a/mpt/impl/imap-mailbox/external-james/src/test/java/org/apache/james/mpt/imapmailbox/external/james/ExternalJamesModule.java +++ b/mpt/impl/imap-mailbox/external-james/src/test/java/org/apache/james/mpt/imapmailbox/external/james/host/ExternalJamesConfiguration.java @@ -16,26 +16,13 @@ * specific language governing permissions and limitations * * under the License. * ****************************************************************/ +package org.apache.james.mpt.imapmailbox.external.james.host; -package org.apache.james.mpt.imapmailbox.external.james; +import org.apache.james.util.Port; -import org.apache.james.mpt.api.HostSystem; -import org.apache.james.mpt.api.ImapHostSystem; -import org.apache.james.mpt.api.UserAdder; -import org.apache.james.mpt.host.ExternalHostSystem; -import org.apache.james.mpt.imapmailbox.external.james.host.ExternalJamesHostSystem; -import org.apache.james.mpt.imapmailbox.external.james.host.ExternalJamesUserAdder; +public interface ExternalJamesConfiguration { + String getAddress(); -import com.google.inject.AbstractModule; - -public class ExternalJamesModule extends AbstractModule { - - @Override - protected void configure() { - bind(ImapHostSystem.class).to(ExternalJamesHostSystem.class); - bind(HostSystem.class).to(ExternalJamesHostSystem.class); - bind(ExternalHostSystem.class).to(ExternalJamesHostSystem.class); - bind(UserAdder.class).to(ExternalJamesUserAdder.class); - } + Port getImapPort(); } diff --git a/mpt/impl/imap-mailbox/external-james/src/test/java/org/apache/james/mpt/imapmailbox/external/james/host/ExternalJamesConfigurationEnvironnementVariables.java b/mpt/impl/imap-mailbox/external-james/src/test/java/org/apache/james/mpt/imapmailbox/external/james/host/ExternalJamesConfigurationEnvironnementVariables.java new file mode 100644 index 0000000..5dde686 --- /dev/null +++ b/mpt/impl/imap-mailbox/external-james/src/test/java/org/apache/james/mpt/imapmailbox/external/james/host/ExternalJamesConfigurationEnvironnementVariables.java @@ -0,0 +1,50 @@ +/**************************************************************** + * 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.imapmailbox.external.james.host; + +import org.apache.james.util.Port; + +import com.google.common.base.Preconditions; + +public class ExternalJamesConfigurationEnvironnementVariables implements ExternalJamesConfiguration { + + private static final String ENV_JAMES_ADDRESS = "JAMES_ADDRESS"; + private static final String ENV_JAMES_IMAP_PORT = "JAMES_IMAP_PORT"; + + private final String address; + private final Port imapPort; + + public ExternalJamesConfigurationEnvironnementVariables() { + Preconditions.checkState(System.getenv(ENV_JAMES_ADDRESS) != null, "You must have exported an environment variable called JAMES_ADDRESS in order to run these tests. For instance export JAMES_ADDRESS=127.0.0.1"); + Preconditions.checkState(System.getenv(ENV_JAMES_IMAP_PORT) != null, "You must have exported an environment variable called JAMES_IMAP_PORT in order to run these tests. For instance export JAMES_IMAP_PORT=143"); + this.address = System.getenv(ENV_JAMES_ADDRESS); + this.imapPort = Port.of(Integer.parseInt(System.getenv(ENV_JAMES_IMAP_PORT))); + } + + @Override + public String getAddress() { + return address; + } + + @Override + public Port getImapPort() { + return imapPort; + } + +} diff --git a/mpt/impl/imap-mailbox/external-james/src/test/java/org/apache/james/mpt/imapmailbox/external/james/host/ExternalJamesHostSystem.java b/mpt/impl/imap-mailbox/external-james/src/test/java/org/apache/james/mpt/imapmailbox/external/james/host/ExternalJamesImapHostSystem.java similarity index 76% rename from mpt/impl/imap-mailbox/external-james/src/test/java/org/apache/james/mpt/imapmailbox/external/james/host/ExternalJamesHostSystem.java rename to mpt/impl/imap-mailbox/external-james/src/test/java/org/apache/james/mpt/imapmailbox/external/james/host/ExternalJamesImapHostSystem.java index 150a32b..ac75f4c 100644 --- a/mpt/impl/imap-mailbox/external-james/src/test/java/org/apache/james/mpt/imapmailbox/external/james/host/ExternalJamesHostSystem.java +++ b/mpt/impl/imap-mailbox/external-james/src/test/java/org/apache/james/mpt/imapmailbox/external/james/host/ExternalJamesImapHostSystem.java @@ -35,23 +35,17 @@ import com.google.inject.Inject; import com.google.inject.Singleton; @Singleton -public class ExternalJamesHostSystem extends ExternalHostSystem { - - private static final String ENV_JAMES_ADDRESS = "JAMES_ADDRESS"; - private static final String ENV_JAMES_IMAP_PORT = "JAMES_IMAP_PORT"; +public class ExternalJamesImapHostSystem extends ExternalHostSystem { + private static final ImapFeatures SUPPORTED_FEATURES = ImapFeatures.of(Feature.NAMESPACE_SUPPORT); private static final String SHABANG = "* OK IMAP4rev1 Server ready"; private final Supplier<InetSocketAddress> addressSupplier; @Inject - private ExternalJamesHostSystem(ExternalJamesUserAdder userAdder) { + private ExternalJamesImapHostSystem(ExternalJamesUserAdder userAdder, ExternalJamesConfiguration configuration) { super(SUPPORTED_FEATURES, new NullMonitor(), SHABANG, userAdder); - Preconditions.checkState(System.getenv(ENV_JAMES_ADDRESS) != null, "You must have exported an environment variable called JAMES_ADDRESS in order to run these tests. For instance export JAMES_ADDRESS=127.0.0.1"); - Preconditions.checkState(System.getenv(ENV_JAMES_IMAP_PORT) != null,"You must have exported an environment variable called JAMES_IMAP_PORT in order to run these tests. For instance export JAMES_IMAP_PORT=143"); - this.addressSupplier = () -> new InetSocketAddress( - System.getenv(ENV_JAMES_ADDRESS), - Integer.parseInt(System.getenv(ENV_JAMES_IMAP_PORT))); + this.addressSupplier = () -> new InetSocketAddress(configuration.getAddress(), configuration.getImapPort().getValue()); } @Override --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
