You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by bt...@apache.org on 2019/12/19 10:38:37 UTC
[james-project] 03/14: JAMES-3012 Move linshare integration tests
to webadmin-integration-tests
This is an automated email from the ASF dual-hosted git repository.
btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 6551174ca2b1a4ee2f598d86f9ea14fc3a763d70
Author: Tran Tien Duc <dt...@linagora.com>
AuthorDate: Fri Dec 13 11:13:00 2019 +0700
JAMES-3012 Move linshare integration tests to webadmin-integration-tests
---
.../james/modules/LinshareGuiceExtension.java | 4 ++
.../pom.xml | 6 --
...LinshareBlobExportMechanismIntegrationTest.java | 54 --------------
.../jmap-draft-integration-testing-common/pom.xml | 10 ---
.../james/jmap/DeletedMessagesVaultRequests.java | 83 ----------------------
.../java/org/apache/james/jmap/ExportRequest.java | 62 ----------------
.../memory-jmap-draft-integration-testing/pom.xml | 6 --
...LinshareBlobExportMechanismIntegrationTest.java | 51 -------------
server/protocols/webadmin-integration-test/pom.xml | 17 +++++
.../vault/DeletedMessageVaultIntegrationTest.java | 5 +-
...LinshareBlobExportMechanismIntegrationTest.java | 83 ++++++++++++++++------
11 files changed, 84 insertions(+), 297 deletions(-)
diff --git a/server/container/guice/blob-export-guice/src/test/java/org/apache/james/modules/LinshareGuiceExtension.java b/server/container/guice/blob-export-guice/src/test/java/org/apache/james/modules/LinshareGuiceExtension.java
index 9ed556c..856e0fb 100644
--- a/server/container/guice/blob-export-guice/src/test/java/org/apache/james/modules/LinshareGuiceExtension.java
+++ b/server/container/guice/blob-export-guice/src/test/java/org/apache/james/modules/LinshareGuiceExtension.java
@@ -61,4 +61,8 @@ public class LinshareGuiceExtension implements GuiceModuleTestExtension {
}
);
}
+
+ public LinshareExtension getLinshareJunitExtension() {
+ return linshareExtension;
+ }
}
diff --git a/server/protocols/jmap-draft-integration-testing/cassandra-jmap-draft-integration-testing/pom.xml b/server/protocols/jmap-draft-integration-testing/cassandra-jmap-draft-integration-testing/pom.xml
index be5be85..9330511 100644
--- a/server/protocols/jmap-draft-integration-testing/cassandra-jmap-draft-integration-testing/pom.xml
+++ b/server/protocols/jmap-draft-integration-testing/cassandra-jmap-draft-integration-testing/pom.xml
@@ -35,12 +35,6 @@
<dependencies>
<dependency>
<groupId>${james.groupId}</groupId>
- <artifactId>apache-james-linshare</artifactId>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>${james.groupId}</groupId>
<artifactId>apache-james-backends-es</artifactId>
<type>test-jar</type>
<scope>test</scope>
diff --git a/server/protocols/jmap-draft-integration-testing/cassandra-jmap-draft-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraLinshareBlobExportMechanismIntegrationTest.java b/server/protocols/jmap-draft-integration-testing/cassandra-jmap-draft-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraLinshareBlobExportMechanismIntegrationTest.java
deleted file mode 100644
index 3d83160..0000000
--- a/server/protocols/jmap-draft-integration-testing/cassandra-jmap-draft-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraLinshareBlobExportMechanismIntegrationTest.java
+++ /dev/null
@@ -1,54 +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.jmap.cassandra;
-
-import static org.apache.james.CassandraJamesServerMain.ALL_BUT_JMX_CASSANDRA_MODULE;
-
-import org.apache.james.CassandraExtension;
-import org.apache.james.DockerElasticSearchExtension;
-import org.apache.james.GuiceJamesServer;
-import org.apache.james.JamesServerBuilder;
-import org.apache.james.JamesServerExtension;
-import org.apache.james.jmap.draft.methods.integration.LinshareBlobExportMechanismIntegrationTest;
-import org.apache.james.modules.LinshareGuiceExtension;
-import org.apache.james.modules.TestJMAPServerModule;
-import org.apache.james.modules.vault.TestDeleteMessageVaultPreDeletionHookModule;
-import org.apache.james.webadmin.WebAdminConfiguration;
-import org.junit.jupiter.api.extension.RegisterExtension;
-
-class CassandraLinshareBlobExportMechanismIntegrationTest extends LinshareBlobExportMechanismIntegrationTest {
-
- private static final long LIMIT_TO_10_MESSAGES = 10;
-
- private static final LinshareGuiceExtension linshareGuiceExtension = new LinshareGuiceExtension();
-
- @RegisterExtension
- JamesServerExtension testExtension = new JamesServerBuilder()
- .extension(linshareGuiceExtension)
- .extension(new DockerElasticSearchExtension())
- .extension(new CassandraExtension())
- .server(configuration -> GuiceJamesServer.forConfiguration(configuration)
- .combineWith(ALL_BUT_JMX_CASSANDRA_MODULE)
- .overrideWith(new TestJMAPServerModule(LIMIT_TO_10_MESSAGES))
- .overrideWith(new TestDeleteMessageVaultPreDeletionHookModule())
- .overrideWith(binder -> binder.bind(WebAdminConfiguration.class)
- .toInstance(WebAdminConfiguration.TEST_CONFIGURATION)))
- .build();
-}
diff --git a/server/protocols/jmap-draft-integration-testing/jmap-draft-integration-testing-common/pom.xml b/server/protocols/jmap-draft-integration-testing/jmap-draft-integration-testing-common/pom.xml
index e96d995..9b4d141 100644
--- a/server/protocols/jmap-draft-integration-testing/jmap-draft-integration-testing-common/pom.xml
+++ b/server/protocols/jmap-draft-integration-testing/jmap-draft-integration-testing-common/pom.xml
@@ -35,16 +35,6 @@
<dependencies>
<dependency>
<groupId>${james.groupId}</groupId>
- <artifactId>apache-james-linshare</artifactId>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>${james.groupId}</groupId>
- <artifactId>apache-james-linshare</artifactId>
- </dependency>
- <dependency>
- <groupId>${james.groupId}</groupId>
<artifactId>apache-james-mailbox-api</artifactId>
<type>test-jar</type>
<scope>test</scope>
diff --git a/server/protocols/jmap-draft-integration-testing/jmap-draft-integration-testing-common/src/test/java/org/apache/james/jmap/DeletedMessagesVaultRequests.java b/server/protocols/jmap-draft-integration-testing/jmap-draft-integration-testing-common/src/test/java/org/apache/james/jmap/DeletedMessagesVaultRequests.java
deleted file mode 100644
index 21ace61..0000000
--- a/server/protocols/jmap-draft-integration-testing/jmap-draft-integration-testing-common/src/test/java/org/apache/james/jmap/DeletedMessagesVaultRequests.java
+++ /dev/null
@@ -1,83 +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.jmap;
-
-import static org.hamcrest.Matchers.is;
-
-import io.restassured.specification.RequestSpecification;
-
-public class DeletedMessagesVaultRequests {
-
- public static void exportVaultContent(RequestSpecification webAdminApi, ExportRequest exportRequest) {
- String taskId =
- webAdminApi.with()
- .queryParam("action", "export")
- .queryParam("exportTo", exportRequest.getSharee())
- .body(exportRequest.getMatchingQuery())
- .post("/deletedMessages/users/" + exportRequest.getUserExportFrom())
- .jsonPath()
- .get("taskId");
-
- webAdminApi.with()
- .get("/tasks/" + taskId + "/await")
- .then()
- .body("status", is("completed"));
- }
-
- public static void restoreMessagesForUserWithQuery(RequestSpecification webAdminApi, String user, String criteria) {
- String taskId = webAdminApi.with()
- .body(criteria)
- .post("/deletedMessages/users/" + user + "?action=restore")
- .jsonPath()
- .get("taskId");
-
- webAdminApi.given()
- .get("/tasks/" + taskId + "/await")
- .then()
- .body("status", is("completed"));
- }
-
- public static void purgeVault(RequestSpecification webAdminApi) {
- String taskId =
- webAdminApi.with()
- .queryParam("scope", "expired")
- .delete("/deletedMessages")
- .jsonPath()
- .get("taskId");
-
- webAdminApi.with()
- .get("/tasks/" + taskId + "/await")
- .then()
- .body("status", is("completed"));
- }
-
- public static void deleteFromVault(RequestSpecification webAdminApi, String user, String messageId) {
- String taskId =
- webAdminApi.with()
- .delete("/deletedMessages/users/" + user + "/messages/" + messageId)
- .jsonPath()
- .get("taskId");
-
- webAdminApi.with()
- .get("/tasks/" + taskId + "/await")
- .then()
- .body("status", is("completed"));
- }
-}
diff --git a/server/protocols/jmap-draft-integration-testing/jmap-draft-integration-testing-common/src/test/java/org/apache/james/jmap/ExportRequest.java b/server/protocols/jmap-draft-integration-testing/jmap-draft-integration-testing-common/src/test/java/org/apache/james/jmap/ExportRequest.java
deleted file mode 100644
index 328701e..0000000
--- a/server/protocols/jmap-draft-integration-testing/jmap-draft-integration-testing-common/src/test/java/org/apache/james/jmap/ExportRequest.java
+++ /dev/null
@@ -1,62 +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.jmap;
-
-public class ExportRequest {
-
- public static class Builder {
-
- @FunctionalInterface
- public interface RequireSharee {
- RequireMatchingQuery exportTo(String sharee);
- }
-
- @FunctionalInterface
- public interface RequireMatchingQuery {
- ExportRequest query(String query);
- }
- }
-
- public static Builder.RequireSharee userExportFrom(String userExportFrom) {
- return sharee -> query -> new ExportRequest(userExportFrom, sharee, query);
- }
-
- private final String userExportFrom;
- private final String sharee;
- private final String matchingQuery;
-
- private ExportRequest(String userExportFrom, String sharee, String matchingQuery) {
- this.userExportFrom = userExportFrom;
- this.sharee = sharee;
- this.matchingQuery = matchingQuery;
- }
-
- public String getUserExportFrom() {
- return userExportFrom;
- }
-
- public String getSharee() {
- return sharee;
- }
-
- public String getMatchingQuery() {
- return matchingQuery;
- }
-}
diff --git a/server/protocols/jmap-draft-integration-testing/memory-jmap-draft-integration-testing/pom.xml b/server/protocols/jmap-draft-integration-testing/memory-jmap-draft-integration-testing/pom.xml
index 67e79f1..37fe1f4 100644
--- a/server/protocols/jmap-draft-integration-testing/memory-jmap-draft-integration-testing/pom.xml
+++ b/server/protocols/jmap-draft-integration-testing/memory-jmap-draft-integration-testing/pom.xml
@@ -35,12 +35,6 @@
<dependencies>
<dependency>
<groupId>${james.groupId}</groupId>
- <artifactId>apache-james-linshare</artifactId>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>${james.groupId}</groupId>
<artifactId>apache-james-mailbox-api</artifactId>
<type>test-jar</type>
<scope>test</scope>
diff --git a/server/protocols/jmap-draft-integration-testing/memory-jmap-draft-integration-testing/src/test/java/org/apache/james/jmap/memory/MemoryLinshareBlobExportMechanismIntegrationTest.java b/server/protocols/jmap-draft-integration-testing/memory-jmap-draft-integration-testing/src/test/java/org/apache/james/jmap/memory/MemoryLinshareBlobExportMechanismIntegrationTest.java
deleted file mode 100644
index 20172e2..0000000
--- a/server/protocols/jmap-draft-integration-testing/memory-jmap-draft-integration-testing/src/test/java/org/apache/james/jmap/memory/MemoryLinshareBlobExportMechanismIntegrationTest.java
+++ /dev/null
@@ -1,51 +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.jmap.memory;
-
-import org.apache.james.GuiceJamesServer;
-import org.apache.james.JamesServerBuilder;
-import org.apache.james.JamesServerExtension;
-import org.apache.james.MemoryJamesServerMain;
-import org.apache.james.jmap.draft.methods.integration.LinshareBlobExportMechanismIntegrationTest;
-import org.apache.james.modules.LinshareGuiceExtension;
-import org.apache.james.modules.TestJMAPServerModule;
-import org.apache.james.modules.vault.TestDeleteMessageVaultPreDeletionHookModule;
-import org.apache.james.webadmin.WebAdminConfiguration;
-import org.junit.jupiter.api.extension.RegisterExtension;
-
-class MemoryLinshareBlobExportMechanismIntegrationTest extends LinshareBlobExportMechanismIntegrationTest {
-
- private static final int LIMIT_TO_10_MESSAGES = 10;
-
- private static final LinshareGuiceExtension linshareGuiceExtension = new LinshareGuiceExtension();
-
- @RegisterExtension
- JamesServerExtension jamesServerExtension = new JamesServerBuilder()
- .extension(linshareGuiceExtension)
- .server(configuration -> GuiceJamesServer.forConfiguration(configuration)
- .combineWith(MemoryJamesServerMain.IN_MEMORY_SERVER_AGGREGATE_MODULE)
- .overrideWith(new TestJMAPServerModule(LIMIT_TO_10_MESSAGES))
- .overrideWith(new TestDeleteMessageVaultPreDeletionHookModule())
- .overrideWith(binder -> {
- binder.bind(WebAdminConfiguration.class)
- .toInstance(WebAdminConfiguration.TEST_CONFIGURATION);
- }))
- .build();
-}
diff --git a/server/protocols/webadmin-integration-test/pom.xml b/server/protocols/webadmin-integration-test/pom.xml
index 9ef15ce..87fd9e0 100644
--- a/server/protocols/webadmin-integration-test/pom.xml
+++ b/server/protocols/webadmin-integration-test/pom.xml
@@ -70,12 +70,24 @@
</dependency>
<dependency>
<groupId>${james.groupId}</groupId>
+ <artifactId>apache-james-linshare</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>${james.groupId}</groupId>
<artifactId>backup</artifactId>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>${james.groupId}</groupId>
+ <artifactId>blob-export-guice</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>${james.groupId}</groupId>
<artifactId>blob-objectstorage</artifactId>
<type>test-jar</type>
<scope>test</scope>
@@ -172,5 +184,10 @@
<artifactId>testcontainers</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.james</groupId>
+ <artifactId>james-server-jmap-draft-integration-testing</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
diff --git a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/vault/DeletedMessageVaultIntegrationTest.java b/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/vault/DeletedMessageVaultIntegrationTest.java
index 07755af..1cfb5e2 100644
--- a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/vault/DeletedMessageVaultIntegrationTest.java
+++ b/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/vault/DeletedMessageVaultIntegrationTest.java
@@ -67,6 +67,7 @@ import org.apache.james.modules.vault.TestDeleteMessageVaultPreDeletionHookModul
import org.apache.james.probe.DataProbe;
import org.apache.james.server.core.JamesServerResourceLoader;
import org.apache.james.server.core.filesystem.FileSystemImpl;
+import org.apache.james.util.Port;
import org.apache.james.utils.DataProbeImpl;
import org.apache.james.utils.IMAPMessageReader;
import org.apache.james.utils.UpdatableTickingClock;
@@ -154,8 +155,8 @@ public class DeletedMessageVaultIntegrationTest {
dataProbe.addUser(JACK, PASSWORD);
mailboxProbe.createMailbox("#private", HOMER, DefaultMailboxes.INBOX);
otherMailboxId = mailboxProbe.createMailbox("#private", HOMER, MAILBOX_NAME);
- int jmapPort = jmapServer.getProbe(JmapGuiceProbe.class)
- .getJmapPort();
+ Port jmapPort = Port.of(jmapServer.getProbe(JmapGuiceProbe.class)
+ .getJmapPort());
homerAccessToken = authenticateJamesUser(baseUri(jmapPort), Username.of(HOMER), PASSWORD);
bartAccessToken = authenticateJamesUser(baseUri(jmapPort), Username.of(BART), BOB_PASSWORD);
jackAccessToken = authenticateJamesUser(baseUri(jmapPort), Username.of(JACK), PASSWORD);
diff --git a/server/protocols/jmap-draft-integration-testing/jmap-draft-integration-testing-common/src/test/java/org/apache/james/jmap/draft/methods/integration/LinshareBlobExportMechanismIntegrationTest.java b/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/vault/LinshareBlobExportMechanismIntegrationTest.java
similarity index 76%
rename from server/protocols/jmap-draft-integration-testing/jmap-draft-integration-testing-common/src/test/java/org/apache/james/jmap/draft/methods/integration/LinshareBlobExportMechanismIntegrationTest.java
rename to server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/vault/LinshareBlobExportMechanismIntegrationTest.java
index 2eec969..cd38122 100644
--- a/server/protocols/jmap-draft-integration-testing/jmap-draft-integration-testing-common/src/test/java/org/apache/james/jmap/draft/methods/integration/LinshareBlobExportMechanismIntegrationTest.java
+++ b/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/vault/LinshareBlobExportMechanismIntegrationTest.java
@@ -17,24 +17,24 @@
* under the License. *
****************************************************************/
-package org.apache.james.jmap.draft.methods.integration;
+package org.apache.james.webadmin.integration.vault;
import static io.restassured.RestAssured.given;
import static io.restassured.RestAssured.with;
-import static org.apache.james.jmap.DeletedMessagesVaultRequests.exportVaultContent;
import static org.apache.james.jmap.HttpJmapAuthentication.authenticateJamesUser;
+import static org.apache.james.jmap.JMAPTestingConstants.ARGUMENTS;
+import static org.apache.james.jmap.JMAPTestingConstants.DOMAIN;
+import static org.apache.james.jmap.JMAPTestingConstants.LOCALHOST_IP;
+import static org.apache.james.jmap.JMAPTestingConstants.calmlyAwait;
+import static org.apache.james.jmap.JMAPTestingConstants.jmapRequestSpecBuilder;
import static org.apache.james.jmap.JmapCommonRequests.deleteMessages;
import static org.apache.james.jmap.JmapCommonRequests.getOutboxId;
import static org.apache.james.jmap.JmapCommonRequests.listMessageIdsForAccount;
import static org.apache.james.jmap.JmapURIBuilder.baseUri;
-import static org.apache.james.jmap.TestingConstants.ARGUMENTS;
-import static org.apache.james.jmap.TestingConstants.DOMAIN;
-import static org.apache.james.jmap.TestingConstants.LOCALHOST_IP;
-import static org.apache.james.jmap.TestingConstants.calmlyAwait;
-import static org.apache.james.jmap.TestingConstants.jmapRequestSpecBuilder;
import static org.apache.james.linshare.LinshareFixture.MATCH_ALL_QUERY;
import static org.apache.james.linshare.LinshareFixture.USER_1;
import static org.apache.james.mailbox.backup.ZipAssert.assertThatZip;
+import static org.apache.james.webadmin.integration.vault.DeletedMessagesVaultRequests.exportVaultContent;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.hasItem;
@@ -43,23 +43,37 @@ import static org.hamcrest.Matchers.hasSize;
import java.io.ByteArrayInputStream;
import java.util.List;
+import org.apache.james.CassandraExtension;
+import org.apache.james.CassandraRabbitMQJamesServerMain;
+import org.apache.james.DockerElasticSearchExtension;
import org.apache.james.GuiceJamesServer;
+import org.apache.james.JamesServerBuilder;
+import org.apache.james.JamesServerExtension;
+import org.apache.james.backends.rabbitmq.DockerRabbitMQSingleton;
import org.apache.james.core.Username;
-import org.apache.james.jmap.ExportRequest;
-import org.apache.james.jmap.api.access.AccessToken;
-import org.apache.james.linshare.LinshareExtension;
+import org.apache.james.jmap.AccessToken;
+import org.apache.james.jmap.draft.JmapGuiceProbe;
import org.apache.james.linshare.client.Document;
import org.apache.james.linshare.client.LinshareAPI;
import org.apache.james.mailbox.DefaultMailboxes;
import org.apache.james.mailbox.backup.ZipAssert;
+import org.apache.james.mailbox.extractor.TextExtractor;
import org.apache.james.mailbox.model.MailboxConstants;
import org.apache.james.mailbox.probe.MailboxProbe;
+import org.apache.james.mailbox.store.search.PDFTextExtractor;
+import org.apache.james.modules.AwsS3BlobStoreExtension;
+import org.apache.james.modules.LinshareGuiceExtension;
import org.apache.james.modules.MailboxProbeImpl;
+import org.apache.james.modules.RabbitMQExtension;
+import org.apache.james.modules.TestJMAPServerModule;
+import org.apache.james.modules.TestRabbitMQModule;
import org.apache.james.modules.protocols.ImapGuiceProbe;
+import org.apache.james.modules.vault.TestDeleteMessageVaultPreDeletionHookModule;
+import org.apache.james.util.Port;
import org.apache.james.utils.DataProbeImpl;
import org.apache.james.utils.IMAPMessageReader;
-import org.apache.james.jmap.draft.JmapGuiceProbe;
import org.apache.james.utils.WebAdminGuiceProbe;
+import org.apache.james.webadmin.WebAdminConfiguration;
import org.apache.james.webadmin.WebAdminUtils;
import org.awaitility.Duration;
import org.awaitility.core.ConditionFactory;
@@ -71,7 +85,8 @@ import io.restassured.RestAssured;
import io.restassured.parsing.Parser;
import io.restassured.specification.RequestSpecification;
-public abstract class LinshareBlobExportMechanismIntegrationTest {
+class LinshareBlobExportMechanismIntegrationTest {
+
private static final String HOMER = "homer@" + DOMAIN;
private static final String BART = "bart@" + DOMAIN;
private static final String HOMER_PASSWORD = "homerPassword";
@@ -83,7 +98,27 @@ public abstract class LinshareBlobExportMechanismIntegrationTest {
.exportTo(USER_1.getUsername())
.query(MATCH_ALL_QUERY);
- private static LinshareExtension linshareExtension = new LinshareExtension();
+ private static final int LIMIT_TO_20_MESSAGES = 20;
+
+ private static final LinshareGuiceExtension linshareGuiceExtension = new LinshareGuiceExtension();
+ @RegisterExtension
+ static JamesServerExtension testExtension = new JamesServerBuilder()
+ .extension(new DockerElasticSearchExtension())
+ .extension(new CassandraExtension())
+ .extension(new RabbitMQExtension())
+ .extension(new AwsS3BlobStoreExtension())
+ .extension(linshareGuiceExtension)
+ .server(configuration -> GuiceJamesServer.forConfiguration(configuration)
+ .combineWith(CassandraRabbitMQJamesServerMain.MODULES)
+ .overrideWith(binder -> binder.bind(TextExtractor.class).to(PDFTextExtractor.class))
+ .overrideWith(new TestJMAPServerModule(LIMIT_TO_20_MESSAGES))
+ .overrideWith(new TestRabbitMQModule(DockerRabbitMQSingleton.SINGLETON))
+ .overrideWith(binder -> binder.bind(WebAdminConfiguration.class).toInstance(WebAdminConfiguration.TEST_CONFIGURATION))
+ .overrideWith(new TestDeleteMessageVaultPreDeletionHookModule()))
+ .build();
+
+ @RegisterExtension
+ IMAPMessageReader imapMessageReader = new IMAPMessageReader();
private AccessToken homerAccessToken;
private AccessToken bartAccessToken;
@@ -92,9 +127,6 @@ public abstract class LinshareBlobExportMechanismIntegrationTest {
private RequestSpecification fakeSmtpRequestSpecification;
private LinshareAPI user1LinshareAPI;
- @RegisterExtension
- IMAPMessageReader imapMessageReader = new IMAPMessageReader();
-
@BeforeEach
void setup(GuiceJamesServer jmapServer) throws Throwable {
this.jmapServer = jmapServer;
@@ -115,11 +147,14 @@ public abstract class LinshareBlobExportMechanismIntegrationTest {
MailboxProbe mailboxProbe = jmapServer.getProbe(MailboxProbeImpl.class);
mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, HOMER, DefaultMailboxes.INBOX);
- homerAccessToken = authenticateJamesUser(baseUri(jmapServer), Username.of(HOMER), HOMER_PASSWORD);
- bartAccessToken = authenticateJamesUser(baseUri(jmapServer), Username.of(BART), BART_PASSWORD);
- user1LinshareAPI = linshareExtension.getAPIFor(USER_1);
+ Port jmapPort = Port.of(jmapServer.getProbe(JmapGuiceProbe.class)
+ .getJmapPort());
+ homerAccessToken = authenticateJamesUser(baseUri(jmapPort), Username.of(HOMER), HOMER_PASSWORD);
+ bartAccessToken = authenticateJamesUser(baseUri(jmapPort), Username.of(BART), BART_PASSWORD);
+ user1LinshareAPI = linshareGuiceExtension.getLinshareJunitExtension().getAPIFor(USER_1);
- fakeSmtpRequestSpecification = given(linshareExtension.getLinshare().fakeSmtpRequestSpecification());
+ fakeSmtpRequestSpecification = given(linshareGuiceExtension.getLinshareJunitExtension()
+ .getLinshare().fakeSmtpRequestSpecification());
}
@Test
@@ -226,7 +261,8 @@ public abstract class LinshareBlobExportMechanismIntegrationTest {
exportVaultContent(webAdminApi, EXPORT_ALL_HOMER_MESSAGES_TO_USER_1);
Document sharedDoc = user1LinshareAPI.receivedShares().get(0).getDocument();
- byte[] sharedFile = linshareExtension.downloadSharedFile(USER_1, sharedDoc.getId(), sharedDoc.getName());
+ byte[] sharedFile = linshareGuiceExtension.getLinshareJunitExtension()
+ .downloadSharedFile(USER_1, sharedDoc.getId(), sharedDoc.getName());
try (ZipAssert zipAssert = assertThatZip(new ByteArrayInputStream(sharedFile))) {
zipAssert.hasEntriesSize(1);
@@ -250,7 +286,8 @@ public abstract class LinshareBlobExportMechanismIntegrationTest {
exportVaultContent(webAdminApi, EXPORT_ALL_HOMER_MESSAGES_TO_USER_1);
Document sharedDoc = user1LinshareAPI.receivedShares().get(0).getDocument();
- byte[] sharedFile = linshareExtension.downloadSharedFile(USER_1, sharedDoc.getId(), sharedDoc.getName());
+ byte[] sharedFile = linshareGuiceExtension.getLinshareJunitExtension()
+ .downloadSharedFile(USER_1, sharedDoc.getId(), sharedDoc.getName());
try (ZipAssert zipAssert = assertThatZip(new ByteArrayInputStream(sharedFile))) {
zipAssert.hasEntriesSize(1);
@@ -279,7 +316,7 @@ public abstract class LinshareBlobExportMechanismIntegrationTest {
"]";
with()
- .header("Authorization", bartAccessToken.serialize())
+ .header("Authorization", bartAccessToken.asString())
.body(requestBody)
.post("/jmap")
.then()
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org