JAMES-2015 put InMemoryDnsService into test classpath

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

Branch: refs/heads/master
Commit: 02ae885381c127b084920b19eab7e9e99e43964f
Parents: 2aba6ef
Author: Luc DUZAN <[email protected]>
Authored: Fri May 5 15:38:18 2017 +0200
Committer: benwa <[email protected]>
Committed: Wed May 17 15:12:55 2017 +0700

----------------------------------------------------------------------
 mpt/impl/smtp/core/pom.xml                      |   5 +
 mpt/pom.xml                                     |   6 +
 .../dnsservice/api/InMemoryDNSService.java      | 137 -------------------
 .../dnsservice/api/InMemoryDNSService.java      | 137 +++++++++++++++++++
 .../cassandra-jmap-integration-testing/pom.xml  |  12 ++
 .../CassandraVacationRelayIntegrationTest.java  |   6 +-
 .../jmap-integration-testing-common/pom.xml     |   8 ++
 .../james/jmap/VacationIntegrationTest.java     |  20 ++-
 .../jmap/VacationRelayIntegrationTest.java      |  72 +++-------
 .../memory-jmap-integration-testing/pom.xml     |   7 +
 10 files changed, 209 insertions(+), 201 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/02ae8853/mpt/impl/smtp/core/pom.xml
----------------------------------------------------------------------
diff --git a/mpt/impl/smtp/core/pom.xml b/mpt/impl/smtp/core/pom.xml
index f9d9800..26a196e 100644
--- a/mpt/impl/smtp/core/pom.xml
+++ b/mpt/impl/smtp/core/pom.xml
@@ -156,6 +156,11 @@
                 <dependency>
                     <groupId>org.apache.james</groupId>
                     <artifactId>james-server-dnsservice-api</artifactId>
+                    <type>test-jar</type>
+                </dependency>
+                <dependency>
+                    <groupId>org.apache.james</groupId>
+                    <artifactId>james-server-dnsservice-api</artifactId>
                 </dependency>
                 <dependency>
                     <groupId>org.apache.james</groupId>

http://git-wip-us.apache.org/repos/asf/james-project/blob/02ae8853/mpt/pom.xml
----------------------------------------------------------------------
diff --git a/mpt/pom.xml b/mpt/pom.xml
index dadbf58..2ea006a 100644
--- a/mpt/pom.xml
+++ b/mpt/pom.xml
@@ -276,6 +276,12 @@
             </dependency>
             <dependency>
                 <groupId>org.apache.james</groupId>
+                <artifactId>james-server-dnsservice-api</artifactId>
+                <type>test-jar</type>
+                <version>${project.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>org.apache.james</groupId>
                 <artifactId>james-server-guice-common</artifactId>
                 <version>${project.version}</version>
                 <type>test-jar</type>

http://git-wip-us.apache.org/repos/asf/james-project/blob/02ae8853/server/dns-service/dnsservice-api/src/main/java/org/apache/james/dnsservice/api/InMemoryDNSService.java
----------------------------------------------------------------------
diff --git 
a/server/dns-service/dnsservice-api/src/main/java/org/apache/james/dnsservice/api/InMemoryDNSService.java
 
b/server/dns-service/dnsservice-api/src/main/java/org/apache/james/dnsservice/api/InMemoryDNSService.java
deleted file mode 100644
index 16085d3..0000000
--- 
a/server/dns-service/dnsservice-api/src/main/java/org/apache/james/dnsservice/api/InMemoryDNSService.java
+++ /dev/null
@@ -1,137 +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.dnsservice.api;
-
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import com.google.common.base.Predicate;
-import com.google.common.collect.FluentIterable;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Maps;
-import com.google.common.net.InetAddresses;
-
-public class InMemoryDNSService implements DNSService {
-
-    private Map<String,DNSRecord> records;
-
-    public InMemoryDNSService() {
-        records = Maps.newHashMap();
-        records.put("0.0.0.0", 
dnsRecordFor(InetAddresses.forString("0.0.0.0")));
-        records.put("127.0.0.1", 
dnsRecordFor(InetAddresses.forString("127.0.0.1")));
-    }
-
-    private DNSRecord dnsRecordFor(InetAddress addresses) {
-        Collection<String> emptyList = ImmutableList.of();
-        return dnsRecordFor(emptyList, emptyList, ImmutableList.of(addresses));
-    }
-
-    private DNSRecord dnsRecordFor(Collection<String> mxRecords, 
Collection<String> txtRecords, List<InetAddress> addresses) {
-        return new DNSRecord(addresses, mxRecords, txtRecords);
-    }
-
-    public void registerRecord(String hostname, InetAddress address, String 
mxRecord) {
-        Collection<String> emptyTxtRecords = ImmutableList.of();
-        registerRecord(hostname, ImmutableList.of(address), 
ImmutableList.of(mxRecord), emptyTxtRecords);
-    }
-
-    public void registerRecord(String hostname, List<InetAddress> addresses, 
Collection<String> mxRecords, Collection<String> txtRecords ){
-        records.put(hostname, dnsRecordFor(mxRecords, txtRecords, addresses));
-    }
-
-    public void dropRecord(String hostname){
-        records.remove(hostname);
-    }
-
-    @Override
-    public Collection<String> findMXRecords(String hostname) throws 
TemporaryResolutionException {
-        return hostRecord(hostname).mxRecords;
-    }
-
-    @Override
-    public Collection<String> findTXTRecords(String hostname) {
-        return hostRecord(hostname).txtRecords;
-    }
-
-    @Override
-    public List<InetAddress> getAllByName(String host) throws 
UnknownHostException {
-        return hostRecord(host).addresses;
-    }
-
-    @Override
-    public InetAddress getByName(String host) throws UnknownHostException {
-        return hostRecord(host).addresses.get(0);
-    }
-
-    private DNSRecord hostRecord(final String host) {
-        Predicate<? super Entry<String, DNSRecord>> filterByKey = new 
Predicate<Entry<String, DNSRecord>>() {
-            @Override
-            public boolean apply(Entry<String, DNSRecord> entry) {
-                return entry.getKey().equals(host);
-            }
-        };
-        return getDNSEntry(filterByKey).getValue();
-    }
-
-    @Override
-    public InetAddress getLocalHost() throws UnknownHostException {
-        return InetAddress.getLocalHost();
-    }
-
-    @Override
-    public String getHostName(final InetAddress addr) {
-        Predicate<? super Entry<String, DNSRecord>> filterByValue = new 
Predicate<Entry<String, DNSRecord>>() {
-            @Override
-            public boolean apply(Entry<String, DNSRecord> entry) {
-                return entry.getValue().contains(addr);
-            }
-        };
-
-        return getDNSEntry(filterByValue).getKey();
-    }
-
-    private Entry<String, DNSRecord> getDNSEntry(Predicate<? super 
Entry<String, DNSRecord>> filter) {
-        return FluentIterable.from(records.entrySet())
-                    .filter(filter)
-                    .first()
-                    .get();
-    }
-
-    private static class DNSRecord {
-
-        final Collection<String> mxRecords;
-        final Collection<String> txtRecords;
-        private final List<InetAddress> addresses;
-
-        public DNSRecord(List<InetAddress> addresses, Collection<String> 
mxRecords, Collection<String> txtRecords) {
-            this.addresses = addresses;
-            this.mxRecords = mxRecords;
-            this.txtRecords = txtRecords;
-        }
-
-        public boolean contains(InetAddress address){
-            return addresses.contains(address);
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/02ae8853/server/dns-service/dnsservice-api/src/test/java/org/apache/james/dnsservice/api/InMemoryDNSService.java
----------------------------------------------------------------------
diff --git 
a/server/dns-service/dnsservice-api/src/test/java/org/apache/james/dnsservice/api/InMemoryDNSService.java
 
b/server/dns-service/dnsservice-api/src/test/java/org/apache/james/dnsservice/api/InMemoryDNSService.java
new file mode 100644
index 0000000..16085d3
--- /dev/null
+++ 
b/server/dns-service/dnsservice-api/src/test/java/org/apache/james/dnsservice/api/InMemoryDNSService.java
@@ -0,0 +1,137 @@
+/****************************************************************
+ * 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.dnsservice.api;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.FluentIterable;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Maps;
+import com.google.common.net.InetAddresses;
+
+public class InMemoryDNSService implements DNSService {
+
+    private Map<String,DNSRecord> records;
+
+    public InMemoryDNSService() {
+        records = Maps.newHashMap();
+        records.put("0.0.0.0", 
dnsRecordFor(InetAddresses.forString("0.0.0.0")));
+        records.put("127.0.0.1", 
dnsRecordFor(InetAddresses.forString("127.0.0.1")));
+    }
+
+    private DNSRecord dnsRecordFor(InetAddress addresses) {
+        Collection<String> emptyList = ImmutableList.of();
+        return dnsRecordFor(emptyList, emptyList, ImmutableList.of(addresses));
+    }
+
+    private DNSRecord dnsRecordFor(Collection<String> mxRecords, 
Collection<String> txtRecords, List<InetAddress> addresses) {
+        return new DNSRecord(addresses, mxRecords, txtRecords);
+    }
+
+    public void registerRecord(String hostname, InetAddress address, String 
mxRecord) {
+        Collection<String> emptyTxtRecords = ImmutableList.of();
+        registerRecord(hostname, ImmutableList.of(address), 
ImmutableList.of(mxRecord), emptyTxtRecords);
+    }
+
+    public void registerRecord(String hostname, List<InetAddress> addresses, 
Collection<String> mxRecords, Collection<String> txtRecords ){
+        records.put(hostname, dnsRecordFor(mxRecords, txtRecords, addresses));
+    }
+
+    public void dropRecord(String hostname){
+        records.remove(hostname);
+    }
+
+    @Override
+    public Collection<String> findMXRecords(String hostname) throws 
TemporaryResolutionException {
+        return hostRecord(hostname).mxRecords;
+    }
+
+    @Override
+    public Collection<String> findTXTRecords(String hostname) {
+        return hostRecord(hostname).txtRecords;
+    }
+
+    @Override
+    public List<InetAddress> getAllByName(String host) throws 
UnknownHostException {
+        return hostRecord(host).addresses;
+    }
+
+    @Override
+    public InetAddress getByName(String host) throws UnknownHostException {
+        return hostRecord(host).addresses.get(0);
+    }
+
+    private DNSRecord hostRecord(final String host) {
+        Predicate<? super Entry<String, DNSRecord>> filterByKey = new 
Predicate<Entry<String, DNSRecord>>() {
+            @Override
+            public boolean apply(Entry<String, DNSRecord> entry) {
+                return entry.getKey().equals(host);
+            }
+        };
+        return getDNSEntry(filterByKey).getValue();
+    }
+
+    @Override
+    public InetAddress getLocalHost() throws UnknownHostException {
+        return InetAddress.getLocalHost();
+    }
+
+    @Override
+    public String getHostName(final InetAddress addr) {
+        Predicate<? super Entry<String, DNSRecord>> filterByValue = new 
Predicate<Entry<String, DNSRecord>>() {
+            @Override
+            public boolean apply(Entry<String, DNSRecord> entry) {
+                return entry.getValue().contains(addr);
+            }
+        };
+
+        return getDNSEntry(filterByValue).getKey();
+    }
+
+    private Entry<String, DNSRecord> getDNSEntry(Predicate<? super 
Entry<String, DNSRecord>> filter) {
+        return FluentIterable.from(records.entrySet())
+                    .filter(filter)
+                    .first()
+                    .get();
+    }
+
+    private static class DNSRecord {
+
+        final Collection<String> mxRecords;
+        final Collection<String> txtRecords;
+        private final List<InetAddress> addresses;
+
+        public DNSRecord(List<InetAddress> addresses, Collection<String> 
mxRecords, Collection<String> txtRecords) {
+            this.addresses = addresses;
+            this.mxRecords = mxRecords;
+            this.txtRecords = txtRecords;
+        }
+
+        public boolean contains(InetAddress address){
+            return addresses.contains(address);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/02ae8853/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/pom.xml
----------------------------------------------------------------------
diff --git 
a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/pom.xml
 
b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/pom.xml
index 4243872..660cb2c 100644
--- 
a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/pom.xml
+++ 
b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/pom.xml
@@ -197,6 +197,12 @@
                 </dependency>
                 <dependency>
                     <groupId>org.apache.james</groupId>
+                    <artifactId>james-server-dnsservice-api</artifactId>
+                    <type>test-jar</type>
+                    <version>${project.version}</version>
+                </dependency>
+                <dependency>
+                    <groupId>org.apache.james</groupId>
                     <artifactId>james-server-testing</artifactId>
                     <scope>test</scope>
                 </dependency>
@@ -242,6 +248,12 @@
                     <artifactId>java-hamcrest</artifactId>
                     <scope>test</scope>
                 </dependency>
+                <dependency>
+                    <groupId>org.apache.james</groupId>
+                    <artifactId>james-server-util-java8</artifactId>
+                    <type>test-jar</type>
+                    <scope>test</scope>
+                </dependency>
             </dependencies>
             <build>
                 <plugins>

http://git-wip-us.apache.org/repos/asf/james-project/blob/02ae8853/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraVacationRelayIntegrationTest.java
----------------------------------------------------------------------
diff --git 
a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraVacationRelayIntegrationTest.java
 
b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraVacationRelayIntegrationTest.java
index e5555f8..57c5ff5 100644
--- 
a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraVacationRelayIntegrationTest.java
+++ 
b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraVacationRelayIntegrationTest.java
@@ -31,16 +31,16 @@ public class CassandraVacationRelayIntegrationTest extends 
VacationRelayIntegrat
     private final InMemoryDNSService inMemoryDNSService = new 
InMemoryDNSService();
 
     @Rule
-    public CassandraJmapTestRule rule = 
CassandraJmapTestRule.defaultTestRule();
+    public CassandraJmapTestRule jamesServerRule = 
CassandraJmapTestRule.defaultTestRule();
 
     @Override
     protected GuiceJamesServer getJmapServer() {
-        return rule.jmapServer((binder) -> 
binder.bind(DNSService.class).toInstance(inMemoryDNSService));
+        return jamesServerRule.jmapServer((binder) -> 
binder.bind(DNSService.class).toInstance(inMemoryDNSService));
     }
 
     @Override
     protected void await() {
-        rule.await();
+        jamesServerRule.await();
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/james-project/blob/02ae8853/server/protocols/jmap-integration-testing/jmap-integration-testing-common/pom.xml
----------------------------------------------------------------------
diff --git 
a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/pom.xml
 
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/pom.xml
index 7efb7bd..18ec7a3 100644
--- 
a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/pom.xml
+++ 
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/pom.xml
@@ -180,8 +180,16 @@
                 </dependency>
                 <dependency>
                     <groupId>org.apache.james</groupId>
+                    <artifactId>james-server-dnsservice-api</artifactId>
+                    <type>test-jar</type>
+                    <scope>test</scope>
+                    <version>${project.version}</version>
+                </dependency>
+                <dependency>
+                    <groupId>org.apache.james</groupId>
                     <artifactId>james-server-util-java8</artifactId>
                     <type>test-jar</type>
+                    <scope>test</scope>
                 </dependency>
                 <dependency>
                     <groupId>com.google.guava</groupId>

http://git-wip-us.apache.org/repos/asf/james-project/blob/02ae8853/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/VacationIntegrationTest.java
----------------------------------------------------------------------
diff --git 
a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/VacationIntegrationTest.java
 
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/VacationIntegrationTest.java
index b845c66..7b37044 100644
--- 
a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/VacationIntegrationTest.java
+++ 
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/VacationIntegrationTest.java
@@ -94,15 +94,21 @@ public abstract class VacationIntegrationTest {
 
         jmapGuiceProbe = guiceJamesServer.getProbe(JmapGuiceProbe.class);
         RestAssured.requestSpecification = new RequestSpecBuilder()
-                       .setContentType(ContentType.JSON)
-                       .setAccept(ContentType.JSON)
-                       
.setConfig(newConfig().encoderConfig(encoderConfig().defaultContentCharset(Charsets.UTF_8)))
-                       .setPort(jmapGuiceProbe
-                    .getJmapPort())
-                       .build();
+            .setContentType(ContentType.JSON)
+            .setAccept(ContentType.JSON)
+            .setConfig(newConfig()
+                .encoderConfig(
+                    encoderConfig().defaultContentCharset(Charsets.UTF_8)))
+            .setPort(jmapGuiceProbe
+                .getJmapPort())
+            .build();
 
         Duration slowPacedPollInterval = Duration.FIVE_HUNDRED_MILLISECONDS;
-        calmlyAwait = 
Awaitility.with().pollInterval(slowPacedPollInterval).and().with().pollDelay(slowPacedPollInterval).await();
+        calmlyAwait = Awaitility
+            .with()
+            .pollInterval(slowPacedPollInterval)
+            .and()
+            .pollDelay(slowPacedPollInterval).await();
     }
 
     private URIBuilder baseUri() {

http://git-wip-us.apache.org/repos/asf/james-project/blob/02ae8853/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/VacationRelayIntegrationTest.java
----------------------------------------------------------------------
diff --git 
a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/VacationRelayIntegrationTest.java
 
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/VacationRelayIntegrationTest.java
index 149d3ce..9c27644 100644
--- 
a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/VacationRelayIntegrationTest.java
+++ 
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/VacationRelayIntegrationTest.java
@@ -19,7 +19,7 @@
 
 package org.apache.james.jmap;
 
-import static com.jayway.restassured.RestAssured.given;
+import static com.jayway.restassured.RestAssured.when;
 import static com.jayway.restassured.config.EncoderConfig.encoderConfig;
 import static com.jayway.restassured.config.RestAssuredConfig.newConfig;
 import static org.hamcrest.Matchers.equalTo;
@@ -27,12 +27,13 @@ import static org.hamcrest.Matchers.equalTo;
 import java.net.InetAddress;
 import java.util.concurrent.TimeUnit;
 
+import com.jayway.restassured.RestAssured;
 import com.jayway.restassured.specification.RequestSpecification;
 import org.apache.commons.net.smtp.SMTPClient;
-import org.apache.http.client.utils.URIBuilder;
 import org.apache.james.GuiceJamesServer;
 import org.apache.james.dnsservice.api.InMemoryDNSService;
-import org.apache.james.jmap.api.access.AccessToken;
+import org.apache.james.jmap.api.vacation.AccountId;
+import org.apache.james.jmap.api.vacation.VacationPatch;
 import org.apache.james.mailbox.model.MailboxConstants;
 import org.apache.james.mailbox.store.probe.MailboxProbe;
 import org.apache.james.modules.MailboxProbeImpl;
@@ -55,7 +56,6 @@ import 
org.testcontainers.shaded.com.google.common.net.InetAddresses;
 
 public abstract class VacationRelayIntegrationTest {
 
-
     @Rule
     public final SwarmGenericContainer fakeSmtp = new 
SwarmGenericContainer("weave/rest-smtp-sink:latest");
 
@@ -72,9 +72,6 @@ public abstract class VacationRelayIntegrationTest {
     private GuiceJamesServer guiceJamesServer;
     private JmapGuiceProbe jmapGuiceProbe;
 
-    private RequestSpecification jmapRequestSpecification;
-    private RequestSpecification restSmtpSinkSpec;
-
     protected abstract void await();
 
     protected abstract GuiceJamesServer getJmapServer();
@@ -100,15 +97,8 @@ public abstract class VacationRelayIntegrationTest {
         await();
 
         jmapGuiceProbe = guiceJamesServer.getProbe(JmapGuiceProbe.class);
-        jmapRequestSpecification = new RequestSpecBuilder()
-                       .setContentType(ContentType.JSON)
-                       .setAccept(ContentType.JSON)
-                       
.setConfig(newConfig().encoderConfig(encoderConfig().defaultContentCharset(Charsets.UTF_8)))
-                       .setPort(jmapGuiceProbe
-                    .getJmapPort())
-                       .build();
-
-        restSmtpSinkSpec = new RequestSpecBuilder()
+
+        RestAssured.requestSpecification = new RequestSpecBuilder()
             .setContentType(ContentType.JSON)
             .setAccept(ContentType.JSON)
             
.setConfig(newConfig().encoderConfig(encoderConfig().defaultContentCharset(Charsets.UTF_8)))
@@ -117,7 +107,11 @@ public abstract class VacationRelayIntegrationTest {
             .build();
 
         Duration slowPacedPollInterval = Duration.FIVE_HUNDRED_MILLISECONDS;
-        calmlyAwait = 
Awaitility.with().pollInterval(slowPacedPollInterval).and().with().pollDelay(slowPacedPollInterval).await();
+        calmlyAwait = Awaitility
+            .with()
+            .pollInterval(slowPacedPollInterval)
+            .and()
+            .pollDelay(slowPacedPollInterval).await();
     }
 
     @After
@@ -125,33 +119,14 @@ public abstract class VacationRelayIntegrationTest {
         guiceJamesServer.stop();
     }
 
-    private void setVacationResponse(AccessToken accessToken) {
-        String bodyRequest = "[[" +
-            "\"setVacationResponse\", " +
-            "{" +
-            "  \"update\":{" +
-            "    \"singleton\" : {" +
-            "      \"id\": \"singleton\"," +
-            "      \"isEnabled\": \"true\"," +
-            "      \"textBody\": \"" + REASON + "\"" +
-            "    }" +
-            "  }" +
-            "}, \"#0\"" +
-            "]]";
-        given()
-            .spec(jmapRequestSpecification)
-            .header("Authorization", accessToken.serialize())
-            .body(bodyRequest)
-        .when()
-            .post("/jmap")
-        .then()
-            .statusCode(200);
-    }
-
     @Test
     public void forwardingAnEmailShouldWork() throws Exception {
-        AccessToken accessToken = 
HttpJmapAuthentication.authenticateJamesUser(baseUri(), USER_WITH_DOMAIN, 
PASSWORD);
-        setVacationResponse(accessToken);
+        jmapGuiceProbe.modifyVacation(AccountId.fromString(USER_WITH_DOMAIN), 
VacationPatch
+            .builder()
+            .isEnabled(true)
+            .textBody(REASON)
+            .build());
+
         String externalMail = "[email protected]";
 
         SMTPClient smtpClient = new SMTPClient();
@@ -164,9 +139,7 @@ public abstract class VacationRelayIntegrationTest {
         calmlyAwait.atMost(1, TimeUnit.MINUTES)
             .until(() -> {
                 try {
-                    given()
-                        .spec(restSmtpSinkSpec)
-                    .when()
+                    when()
                         .get("/api/email")
                     .then()
                         .statusCode(200)
@@ -180,13 +153,4 @@ public abstract class VacationRelayIntegrationTest {
                 }
             });
     }
-
-    private URIBuilder baseUri() {
-        return new URIBuilder()
-            .setScheme("http")
-            .setHost("localhost")
-            .setPort(guiceJamesServer.getProbe(JmapGuiceProbe.class)
-                .getJmapPort())
-            .setCharset(Charsets.UTF_8);
-    }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/02ae8853/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/pom.xml
----------------------------------------------------------------------
diff --git 
a/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/pom.xml
 
b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/pom.xml
index 6b33376..4c1c2bf 100644
--- 
a/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/pom.xml
+++ 
b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/pom.xml
@@ -180,6 +180,13 @@
                     <groupId>org.apache.james</groupId>
                     <artifactId>james-server-util-java8</artifactId>
                     <type>test-jar</type>
+                    <scope>test</scope>
+                </dependency>
+                <dependency>
+                    <groupId>org.apache.james</groupId>
+                    <artifactId>james-server-dnsservice-api</artifactId>
+                    <type>test-jar</type>
+                    <version>${project.version}</version>
                 </dependency>
                 <dependency>
                     <groupId>org.apache.james</groupId>


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to