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 1e062c6532a67383650b2394c16cf9e3a8068497 Author: Benoit Tellier <btell...@linagora.com> AuthorDate: Tue Sep 3 11:38:55 2019 +0700 JAMES-2867 Allow to clear stored mails in Mock SMTP Server --- .../mock/smtp/server/HTTPConfigurationServer.java | 6 +++++ .../smtp/server/HTTPConfigurationServerTest.java | 27 ++++++++++++++++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/server/mailet/mock-smtp-server/src/main/java/org/apache/james/mock/smtp/server/HTTPConfigurationServer.java b/server/mailet/mock-smtp-server/src/main/java/org/apache/james/mock/smtp/server/HTTPConfigurationServer.java index 08f0f8c..cfc6e2f 100644 --- a/server/mailet/mock-smtp-server/src/main/java/org/apache/james/mock/smtp/server/HTTPConfigurationServer.java +++ b/server/mailet/mock-smtp-server/src/main/java/org/apache/james/mock/smtp/server/HTTPConfigurationServer.java @@ -93,6 +93,12 @@ public class HTTPConfigurationServer { resp.setContentType("application/json"); OBJECT_MAPPER.writeValue(resp.getOutputStream(), mails); } + + @Override + protected void doDelete(HttpServletRequest req, HttpServletResponse resp) { + receivedMailRepository.clear(); + resp.setStatus(SC_NO_CONTENT); + } } private static final String SMTP_BEHAVIORS = "/smtpBehaviors"; diff --git a/server/mailet/mock-smtp-server/src/test/java/org/apache/james/mock/smtp/server/HTTPConfigurationServerTest.java b/server/mailet/mock-smtp-server/src/test/java/org/apache/james/mock/smtp/server/HTTPConfigurationServerTest.java index 65435b4..a65d261 100644 --- a/server/mailet/mock-smtp-server/src/test/java/org/apache/james/mock/smtp/server/HTTPConfigurationServerTest.java +++ b/server/mailet/mock-smtp-server/src/test/java/org/apache/james/mock/smtp/server/HTTPConfigurationServerTest.java @@ -24,6 +24,7 @@ import static io.restassured.RestAssured.when; import static io.restassured.RestAssured.with; import static io.restassured.config.EncoderConfig.encoderConfig; import static io.restassured.config.RestAssuredConfig.newConfig; +import static javax.servlet.http.HttpServletResponse.SC_NO_CONTENT; import static net.javacrumbs.jsonunit.assertj.JsonAssertions.assertThatJson; import static org.apache.james.mock.smtp.server.Fixture.ALICE; import static org.apache.james.mock.smtp.server.Fixture.BOB; @@ -193,7 +194,7 @@ class HTTPConfigurationServerTest { } @Test - void getShouldReturnPreviouslyStoredData() throws Exception { + void getShouldReturnPreviouslyStoredData() { mailRepository.store(mail1); String response = when() @@ -209,7 +210,7 @@ class HTTPConfigurationServerTest { } @Test - void getShouldReturnMultipleEmails() throws Exception { + void getShouldReturnMultipleEmails() { mailRepository.store(mail1); mailRepository.store(mail2); @@ -226,6 +227,28 @@ class HTTPConfigurationServerTest { } @Test + void getShouldNotReturnClearedEmails() { + mailRepository.store(mail1); + mailRepository.store(mail2); + + with() + .delete(); + + when() + .get() + .then() + .body(".", hasSize(0)); + } + + @Test + void deleteShouldReturnNoContent() { + when() + .delete() + .then() + .statusCode(SC_NO_CONTENT); + } + + @Test void getShouldReturnEmptyAfterClear() { mailRepository.store(mail1); --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org