james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [02/21] james-project git commit: JAMES-1902 split probes to prevent them to pull unwanted dependencies
Date Tue, 14 Mar 2017 11:14:43 GMT
http://git-wip-us.apache.org/repos/asf/james-project/blob/793dae76/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/GetMessagesMethodStepdefs.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/GetMessagesMethodStepdefs.java
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/GetMessagesMethodStepdefs.java
index f1a9e55..23afc1d 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/GetMessagesMethodStepdefs.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/GetMessagesMethodStepdefs.java
@@ -45,6 +45,7 @@ import org.apache.james.mailbox.model.MailboxConstants;
 import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.model.MessageId;
+import org.apache.james.modules.MailboxProbeImpl;
 import org.apache.james.utils.JmapGuiceProbe;
 import org.javatuples.Pair;
 
@@ -100,8 +101,8 @@ public class GetMessagesMethodStepdefs {
     @Given("^the user has a message \"([^\"]*)\" in \"([^\"]*)\" and \"([^\"]*)\" mailboxes
with subject \"([^\"]*)\", content \"([^\"]*)\"$")
     public void appendMessageInTwoMailboxes(String messageName, String mailbox1, String mailbox2,
String subject, String content) throws Throwable {
         MessageId id = appendMessage(mailbox1, ContentType.noContentType(), subject, content,
NO_HEADERS);
-        MailboxId mailboxId1 = mainStepdefs.jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE,
userStepdefs.lastConnectedUser, mailbox1).getMailboxId();
-        MailboxId mailboxId2 = mainStepdefs.jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE,
userStepdefs.lastConnectedUser, mailbox2).getMailboxId();
+        MailboxId mailboxId1 = mainStepdefs.jmapServer.getProbe(MailboxProbeImpl.class).getMailbox(MailboxConstants.USER_NAMESPACE,
userStepdefs.lastConnectedUser, mailbox1).getMailboxId();
+        MailboxId mailboxId2 = mainStepdefs.jmapServer.getProbe(MailboxProbeImpl.class).getMailbox(MailboxConstants.USER_NAMESPACE,
userStepdefs.lastConnectedUser, mailbox2).getMailboxId();
 
         mainStepdefs.jmapServer.getProbe(JmapGuiceProbe.class).setInMailboxes(id, userStepdefs.lastConnectedUser,
mailboxId1, mailboxId2);
         messageIdsByName.put(messageName, id);
@@ -128,7 +129,7 @@ public class GetMessagesMethodStepdefs {
     @Given("^the user has a message \"([^\"]*)\" in \"([^\"]*)\" mailbox, composed of a multipart
with inlined text part and inlined html part$")
     public void appendMessageFromFileInlinedMultipart(String messageName, String mailbox)
throws Throwable {
         ZonedDateTime dateTime = ZonedDateTime.parse("2014-10-30T14:12:00Z");
-        MessageId id = mainStepdefs.jmapServer.serverProbe().appendMessage(userStepdefs.lastConnectedUser,
+        MessageId id = mainStepdefs.jmapServer.getProbe(MailboxProbeImpl.class).appendMessage(userStepdefs.lastConnectedUser,
                     new MailboxPath(MailboxConstants.USER_NAMESPACE, userStepdefs.lastConnectedUser,
mailbox),
                     ClassLoader.getSystemResourceAsStream("eml/inlinedMultipart.eml"),
                     Date.from(dateTime.toInstant()), false, new Flags())
@@ -138,7 +139,7 @@ public class GetMessagesMethodStepdefs {
 
     private MessageId appendMessage(String mailbox, ContentType contentType, String subject,
String content, Optional<Map<String, String>> headers) throws Exception {
         ZonedDateTime dateTime = ZonedDateTime.parse("2014-10-30T14:12:00Z");
-        return mainStepdefs.jmapServer.serverProbe().appendMessage(userStepdefs.lastConnectedUser,

+        return mainStepdefs.jmapServer.getProbe(MailboxProbeImpl.class).appendMessage(userStepdefs.lastConnectedUser,

                 new MailboxPath(MailboxConstants.USER_NAMESPACE, userStepdefs.lastConnectedUser,
mailbox),
                 new ByteArrayInputStream(message(contentType, subject, content, headers).getBytes(Charsets.UTF_8)),

                 Date.from(dateTime.toInstant()), false, new Flags()).getMessageId();
@@ -204,7 +205,7 @@ public class GetMessagesMethodStepdefs {
 
     private void appendMessage(String messageName, String emlFileName) throws Exception {
         ZonedDateTime dateTime = ZonedDateTime.parse("2014-10-30T14:12:00Z");
-        MessageId id = mainStepdefs.jmapServer.serverProbe().appendMessage(userStepdefs.lastConnectedUser,
+        MessageId id = mainStepdefs.jmapServer.getProbe(MailboxProbeImpl.class).appendMessage(userStepdefs.lastConnectedUser,
                 new MailboxPath(MailboxConstants.USER_NAMESPACE, userStepdefs.lastConnectedUser,
DefaultMailboxes.INBOX),
                 ClassLoader.getSystemResourceAsStream(emlFileName),
                 Date.from(dateTime.toInstant()), false, new Flags())
@@ -350,7 +351,7 @@ public class GetMessagesMethodStepdefs {
         List<String> values = Splitter.on(",")
             .splitToList(mailboxIds).stream()
             .map(Throwing.function(name -> mainStepdefs.jmapServer
-                .serverProbe()
+                .getProbe(MailboxProbeImpl.class)
                 .getMailbox(MailboxConstants.USER_NAMESPACE, userStepdefs.lastConnectedUser,
name)
                 .getMailboxId()
                 .serialize()))

http://git-wip-us.apache.org/repos/asf/james-project/blob/793dae76/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/SetMailboxesMethodStepdefs.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/SetMailboxesMethodStepdefs.java
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/SetMailboxesMethodStepdefs.java
index 74698ad..39b7e3f 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/SetMailboxesMethodStepdefs.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/SetMailboxesMethodStepdefs.java
@@ -36,6 +36,7 @@ import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.model.MailboxConstants;
 import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.store.mail.model.Mailbox;
+import org.apache.james.modules.MailboxProbeImpl;
 
 import com.github.fge.lambdas.Throwing;
 import com.jayway.awaitility.Awaitility;
@@ -65,7 +66,7 @@ public class SetMailboxesMethodStepdefs {
 
     @Given("^mailbox \"([^\"]*)\" with (\\d+) messages$")
     public void mailboxWithMessages(String mailboxName, int messageCount) throws Throwable
{
-        mainStepdefs.jmapServer.serverProbe().createMailbox("#private", userStepdefs.lastConnectedUser,
mailboxName);
+        mainStepdefs.jmapServer.getProbe(MailboxProbeImpl.class).createMailbox("#private",
userStepdefs.lastConnectedUser, mailboxName);
         MailboxPath mailboxPath = new MailboxPath(MailboxConstants.USER_NAMESPACE, userStepdefs.lastConnectedUser,
mailboxName);
         IntStream
             .range(0, messageCount)
@@ -76,14 +77,14 @@ public class SetMailboxesMethodStepdefs {
     private void appendMessage(MailboxPath mailboxPath, int i) throws MailboxException {
         String content = "Subject: test" + i + "\r\n\r\n"
                 + "testBody" + i;
-        mainStepdefs.jmapServer.serverProbe().appendMessage(userStepdefs.lastConnectedUser,
mailboxPath,
+        mainStepdefs.jmapServer.getProbe(MailboxProbeImpl.class).appendMessage(userStepdefs.lastConnectedUser,
mailboxPath,
                 new ByteArrayInputStream(content.getBytes()), new Date(), false, new Flags());
     }
 
     @When("^renaming mailbox \"([^\"]*)\" to \"([^\"]*)\"")
     public void renamingMailbox(String actualMailboxName, String newMailboxName) throws Throwable
{
         String username = userStepdefs.lastConnectedUser;
-        Mailbox mailbox = mainStepdefs.jmapServer.serverProbe().getMailbox("#private", userStepdefs.lastConnectedUser,
actualMailboxName);
+        Mailbox mailbox = mainStepdefs.jmapServer.getProbe(MailboxProbeImpl.class).getMailbox("#private",
userStepdefs.lastConnectedUser, actualMailboxName);
         String mailboxId = mailbox.getMailboxId().serialize();
         String requestBody =
                 "[" +
@@ -108,9 +109,9 @@ public class SetMailboxesMethodStepdefs {
     @When("^moving mailbox \"([^\"]*)\" to \"([^\"]*)\"$")
     public void movingMailbox(String actualMailboxPath, String newParentMailboxPath) throws
Throwable {
         String username = userStepdefs.lastConnectedUser;
-        Mailbox mailbox = mainStepdefs.jmapServer.serverProbe().getMailbox("#private", username,
actualMailboxPath);
+        Mailbox mailbox = mainStepdefs.jmapServer.getProbe(MailboxProbeImpl.class).getMailbox("#private",
username, actualMailboxPath);
         String mailboxId = mailbox.getMailboxId().serialize();
-        Mailbox parent = mainStepdefs.jmapServer.serverProbe().getMailbox("#private", username,
newParentMailboxPath);
+        Mailbox parent = mainStepdefs.jmapServer.getProbe(MailboxProbeImpl.class).getMailbox("#private",
username, newParentMailboxPath);
         String parentId = parent.getMailboxId().serialize();
 
         String requestBody =
@@ -138,7 +139,7 @@ public class SetMailboxesMethodStepdefs {
     public void mailboxContainsMessages(String mailboxName, int messageCount) throws Throwable
{
         Duration slowPacedPollInterval = Duration.FIVE_HUNDRED_MILLISECONDS;
         String username = userStepdefs.lastConnectedUser;
-        Mailbox mailbox = mainStepdefs.jmapServer.serverProbe().getMailbox("#private", username,
mailboxName);
+        Mailbox mailbox = mainStepdefs.jmapServer.getProbe(MailboxProbeImpl.class).getMailbox("#private",
username, mailboxName);
         String mailboxId = mailbox.getMailboxId().serialize();
 
         Awaitility.await().atMost(Duration.FIVE_SECONDS).pollDelay(slowPacedPollInterval).pollInterval(slowPacedPollInterval).until(()
-> {

http://git-wip-us.apache.org/repos/asf/james-project/blob/793dae76/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/SetMessagesMethodStepdefs.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/SetMessagesMethodStepdefs.java
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/SetMessagesMethodStepdefs.java
index 20ffcf9..3d9f7bb 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/SetMessagesMethodStepdefs.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/SetMessagesMethodStepdefs.java
@@ -25,6 +25,7 @@ import org.apache.http.client.fluent.Request;
 import org.apache.james.mailbox.model.MailboxConstants;
 import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.model.MessageId;
+import org.apache.james.modules.MailboxProbeImpl;
 
 import cucumber.api.java.en.When;
 import cucumber.runtime.java.guice.ScenarioScoped;
@@ -48,7 +49,7 @@ public class SetMessagesMethodStepdefs {
         String username = userStepdefs.lastConnectedUser;
         MessageId messageId = getMessagesMethodStepdefs.getMessageId(message);
         MailboxId mailboxId = mainStepdefs.jmapServer
-            .serverProbe()
+            .getProbe(MailboxProbeImpl.class)
             .getMailbox(MailboxConstants.USER_NAMESPACE, userStepdefs.lastConnectedUser,
mailbox)
             .getMailboxId();
 
@@ -75,11 +76,11 @@ public class SetMessagesMethodStepdefs {
         String username = userStepdefs.lastConnectedUser;
         MessageId messageId = getMessagesMethodStepdefs.getMessageId(message);
         MailboxId sourceMailboxId = mainStepdefs.jmapServer
-            .serverProbe()
+            .getProbe(MailboxProbeImpl.class)
             .getMailbox(MailboxConstants.USER_NAMESPACE, userStepdefs.lastConnectedUser,
sourceMailbox)
             .getMailboxId();
         MailboxId destinationMailboxId = mainStepdefs.jmapServer
-            .serverProbe()
+            .getProbe(MailboxProbeImpl.class)
             .getMailbox(MailboxConstants.USER_NAMESPACE, userStepdefs.lastConnectedUser,
destinationMailbox)
             .getMailboxId();
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/793dae76/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/UserStepdefs.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/UserStepdefs.java
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/UserStepdefs.java
index c805105..fb0aff4 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/UserStepdefs.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/UserStepdefs.java
@@ -30,6 +30,8 @@ import javax.inject.Inject;
 import org.apache.james.jmap.HttpJmapAuthentication;
 import org.apache.james.jmap.api.access.AccessToken;
 import org.apache.james.mailbox.model.MailboxConstants;
+import org.apache.james.modules.MailboxProbeImpl;
+import org.apache.james.utils.DataProbeImpl;
 
 import com.github.fge.lambdas.Throwing;
 import com.google.common.base.Charsets;
@@ -60,7 +62,7 @@ public class UserStepdefs {
 
     @Given("^a domain named \"([^\"]*)\"$")
     public void createDomain(String domain) throws Exception {
-        mainStepdefs.jmapServer.serverProbe().addDomain(domain);
+        mainStepdefs.jmapServer.getProbe(DataProbeImpl.class).addDomain(domain);
         domains.add(domain);
     }
 
@@ -78,7 +80,7 @@ public class UserStepdefs {
     @Given("^a user \"([^\"]*)\"$")
     public void createUser(String username) throws Exception {
         String password = generatePassword(username);
-        mainStepdefs.jmapServer.serverProbe().addUser(username, password);
+        mainStepdefs.jmapServer.getProbe(DataProbeImpl.class).addUser(username, password);
         passwordByUser.put(username, password);
     }
 
@@ -90,7 +92,7 @@ public class UserStepdefs {
     
     @Given("^\"([^\"]*)\" has a mailbox \"([^\"]*)\"$")
     public void createMailbox(String username, String mailbox) throws Throwable {
-        mainStepdefs.jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE,
username, mailbox);
+        mainStepdefs.jmapServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE,
username, mailbox);
     }
 
     

http://git-wip-us.apache.org/repos/asf/james-project/blob/793dae76/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/WebAdminServerIntegrationTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/WebAdminServerIntegrationTest.java
b/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/WebAdminServerIntegrationTest.java
index f6194bc..c91eec4 100644
--- a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/WebAdminServerIntegrationTest.java
+++ b/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/WebAdminServerIntegrationTest.java
@@ -29,6 +29,9 @@ import static org.hamcrest.Matchers.is;
 
 import org.apache.james.CassandraJmapTestRule;
 import org.apache.james.GuiceJamesServer;
+import org.apache.james.modules.MailboxProbeImpl;
+import org.apache.james.probe.DataProbe;
+import org.apache.james.utils.DataProbeImpl;
 import org.apache.james.utils.WebAdminGuiceProbe;
 import org.apache.james.webadmin.routes.DomainRoutes;
 import org.apache.james.webadmin.routes.UserMailboxesRoutes;
@@ -56,12 +59,14 @@ public class WebAdminServerIntegrationTest {
     public CassandraJmapTestRule cassandraJmapTestRule = CassandraJmapTestRule.defaultTestRule();
 
     private GuiceJamesServer guiceJamesServer;
+    private DataProbe dataProbe;
 
     @Before
     public void setUp() throws Exception {
         guiceJamesServer = cassandraJmapTestRule.jmapServer()
                 .overrideWith(new WebAdminConfigurationModule());
         guiceJamesServer.start();
+        dataProbe = guiceJamesServer.getProbe(DataProbeImpl.class);
 
         RestAssured.requestSpecification = new RequestSpecBuilder()
         		.setContentType(ContentType.JSON)
@@ -83,24 +88,24 @@ public class WebAdminServerIntegrationTest {
         .then()
             .statusCode(204);
 
-        assertThat(guiceJamesServer.serverProbe().listDomains()).contains(DOMAIN);
+        assertThat(dataProbe.listDomains()).contains(DOMAIN);
     }
 
     @Test
     public void deleteShouldRemoveTheGivenDomain() throws Exception {
-        guiceJamesServer.serverProbe().addDomain(DOMAIN);
+        dataProbe.addDomain(DOMAIN);
 
         when()
             .delete(SPECIFIC_DOMAIN)
         .then()
             .statusCode(204);
 
-        assertThat(guiceJamesServer.serverProbe().listDomains()).doesNotContain(DOMAIN);
+        assertThat(dataProbe.listDomains()).doesNotContain(DOMAIN);
     }
 
     @Test
     public void postShouldAddTheUser() throws Exception {
-        guiceJamesServer.serverProbe().addDomain(DOMAIN);
+        dataProbe.addDomain(DOMAIN);
 
         given()
             .body("{\"password\":\"password\"}")
@@ -109,13 +114,13 @@ public class WebAdminServerIntegrationTest {
         .then()
             .statusCode(204);
 
-        assertThat(guiceJamesServer.serverProbe().listUsers()).contains(USERNAME);
+        assertThat(dataProbe.listUsers()).contains(USERNAME);
     }
 
     @Test
     public void deleteShouldRemoveTheUser() throws Exception {
-        guiceJamesServer.serverProbe().addDomain(DOMAIN);
-        guiceJamesServer.serverProbe().addUser(USERNAME, "anyPassword");
+        dataProbe.addDomain(DOMAIN);
+        dataProbe.addUser(USERNAME, "anyPassword");
 
         given()
             .body("{\"username\":\"" + USERNAME + "\",\"password\":\"password\"}")
@@ -124,13 +129,13 @@ public class WebAdminServerIntegrationTest {
         .then()
             .statusCode(204);
 
-        assertThat(guiceJamesServer.serverProbe().listUsers()).doesNotContain(USERNAME);
+        assertThat(dataProbe.listUsers()).doesNotContain(USERNAME);
     }
 
     @Test
     public void getUsersShouldDisplayUsers() throws Exception {
-        guiceJamesServer.serverProbe().addDomain(DOMAIN);
-        guiceJamesServer.serverProbe().addUser(USERNAME, "anyPassword");
+        dataProbe.addDomain(DOMAIN);
+        dataProbe.addUser(USERNAME, "anyPassword");
 
         when()
             .get(UserRoutes.USERS)
@@ -141,29 +146,29 @@ public class WebAdminServerIntegrationTest {
 
     @Test
     public void putMailboxShouldAddAMailbox() throws Exception {
-        guiceJamesServer.serverProbe().addDomain(DOMAIN);
-        guiceJamesServer.serverProbe().addUser(USERNAME, "anyPassword");
+        dataProbe.addDomain(DOMAIN);
+        dataProbe.addUser(USERNAME, "anyPassword");
 
         when()
             .put(SPECIFIC_MAILBOX)
         .then()
             .statusCode(204);
 
-        assertThat(guiceJamesServer.serverProbe().listUserMailboxes(USERNAME)).containsExactly(MAILBOX);
+        assertThat(guiceJamesServer.getProbe(MailboxProbeImpl.class).listUserMailboxes(USERNAME)).containsExactly(MAILBOX);
     }
 
     @Test
     public void deleteMailboxShouldRemoveAMailbox() throws Exception {
-        guiceJamesServer.serverProbe().addDomain(DOMAIN);
-        guiceJamesServer.serverProbe().addUser(USERNAME, "anyPassword");
-        guiceJamesServer.serverProbe().createMailbox("#private", USERNAME, MAILBOX);
+        dataProbe.addDomain(DOMAIN);
+        dataProbe.addUser(USERNAME, "anyPassword");
+        guiceJamesServer.getProbe(MailboxProbeImpl.class).createMailbox("#private", USERNAME,
MAILBOX);
 
         when()
             .delete(SPECIFIC_MAILBOX)
         .then()
             .statusCode(204);
 
-        assertThat(guiceJamesServer.serverProbe().listUserMailboxes(USERNAME)).isEmpty();
+        assertThat(guiceJamesServer.getProbe(MailboxProbeImpl.class).listUserMailboxes(USERNAME)).isEmpty();
     }
 
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message