JAMES-2352 port webadmin tests to junit5

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

Branch: refs/heads/master
Commit: b588e8c235416518d8fdede21886542d25a2a791
Parents: 33cb12e
Author: Matthieu Baechler <matth...@apache.org>
Authored: Thu Mar 15 15:52:48 2018 +0100
Committer: benwa <btell...@linagora.com>
Committed: Tue Mar 27 15:13:46 2018 +0700

----------------------------------------------------------------------
 server/protocols/webadmin/webadmin-data/pom.xml |  21 ++--
 .../webadmin/routes/DomainsRoutesTest.java      |  71 ++++++------
 .../james/webadmin/routes/GroupsRoutesTest.java | 112 +++++++++----------
 .../james/webadmin/routes/UsersRoutesTest.java  |  89 ++++++++-------
 4 files changed, 146 insertions(+), 147 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/b588e8c2/server/protocols/webadmin/webadmin-data/pom.xml
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-data/pom.xml 
b/server/protocols/webadmin/webadmin-data/pom.xml
index 5fbad1a..e6c876b 100644
--- a/server/protocols/webadmin/webadmin-data/pom.xml
+++ b/server/protocols/webadmin/webadmin-data/pom.xml
@@ -76,21 +76,10 @@
             <scope>test</scope>
         </dependency>
         <dependency>
-            <groupId>de.bechte.junit</groupId>
-            <artifactId>junit-hierarchicalcontextrunner</artifactId>
-            <version>4.11.3</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
             <groupId>javax.inject</groupId>
             <artifactId>javax.inject</artifactId>
         </dependency>
         <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
             <groupId>org.assertj</groupId>
             <artifactId>assertj-core</artifactId>
             <scope>test</scope>
@@ -106,6 +95,16 @@
             <scope>test</scope>
         </dependency>
         <dependency>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter-engine</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.junit.platform</groupId>
+            <artifactId>junit-platform-launcher</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-api</artifactId>
         </dependency>

http://git-wip-us.apache.org/repos/asf/james-project/blob/b588e8c2/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/DomainsRoutesTest.java
----------------------------------------------------------------------
diff --git 
a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/DomainsRoutesTest.java
 
b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/DomainsRoutesTest.java
index 1925284..7c83988 100644
--- 
a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/DomainsRoutesTest.java
+++ 
b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/DomainsRoutesTest.java
@@ -44,16 +44,15 @@ import org.apache.james.webadmin.WebAdminServer;
 import org.apache.james.webadmin.WebAdminUtils;
 import org.apache.james.webadmin.utils.JsonTransformer;
 import org.eclipse.jetty.http.HttpStatus;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Nested;
+import org.junit.jupiter.api.Test;
 
 import com.jayway.restassured.RestAssured;
 import com.jayway.restassured.http.ContentType;
-import de.bechte.junit.runners.context.HierarchicalContextRunner;
 
-@RunWith(HierarchicalContextRunner.class)
+
 public class DomainsRoutesTest {
     public static final String DOMAIN = "domain";
 
@@ -71,15 +70,16 @@ public class DomainsRoutesTest {
             .build();
     }
 
-    @After
-    public void stop() {
+    @AfterEach
+    void stop() {
         webAdminServer.destroy();
     }
 
-    public class NormalBehaviour {
+    @Nested
+    class NormalBehaviour {
 
-        @Before
-        public void setUp() throws Exception {
+        @BeforeEach
+        void setUp() throws Exception {
             DNSService dnsService = mock(DNSService.class);
             when(dnsService.getHostName(any())).thenReturn("localhost");
             
when(dnsService.getLocalHost()).thenReturn(InetAddress.getByName("localhost"));
@@ -90,7 +90,7 @@ public class DomainsRoutesTest {
         }
 
         @Test
-        public void getDomainsShouldBeEmptyByDefault() {
+        void getDomainsShouldBeEmptyByDefault() {
             List<String> domains =
                 given()
                     .get()
@@ -106,7 +106,7 @@ public class DomainsRoutesTest {
         }
 
         @Test
-        public void putShouldReturnErrorWhenUsedWithEmptyDomain() {
+        void putShouldReturnErrorWhenUsedWithEmptyDomain() {
             given()
                 .put(SEPARATOR)
             .then()
@@ -114,7 +114,7 @@ public class DomainsRoutesTest {
         }
 
         @Test
-        public void deleteShouldReturnErrorWhenUsedWithEmptyDomain() {
+        void deleteShouldReturnErrorWhenUsedWithEmptyDomain() {
             given()
                 .delete(SEPARATOR)
             .then()
@@ -122,7 +122,7 @@ public class DomainsRoutesTest {
         }
 
         @Test
-        public void putShouldBeOk() {
+        void putShouldBeOk() {
             given()
                 .put(DOMAIN)
             .then()
@@ -130,7 +130,7 @@ public class DomainsRoutesTest {
         }
 
         @Test
-        public void getDomainsShouldDisplayAddedDomains() {
+        void getDomainsShouldDisplayAddedDomains() {
             with()
                 .put(DOMAIN);
 
@@ -149,7 +149,7 @@ public class DomainsRoutesTest {
         }
 
         @Test
-        public void putShouldReturnUserErrorWhenNameContainsAT() {
+        void putShouldReturnUserErrorWhenNameContainsAT() {
             Map<String, Object> errors = when()
                 .put(DOMAIN + "@" + DOMAIN)
             .then()
@@ -167,7 +167,7 @@ public class DomainsRoutesTest {
         }
 
         @Test
-        public void putShouldReturnUserErrorWhenNameContainsUrlSeparator() {
+        void putShouldReturnUserErrorWhenNameContainsUrlSeparator() {
             when()
                 .put(DOMAIN + "/" + DOMAIN)
             .then()
@@ -175,7 +175,7 @@ public class DomainsRoutesTest {
         }
 
         @Test
-        public void putShouldReturnUserErrorWhenNameIsTooLong() {
+        void putShouldReturnUserErrorWhenNameIsTooLong() {
             Map<String, Object> errors = when()
                 .put(DOMAIN + 
"0123456789.0123456789.0123456789.0123456789.0123456789.0123456789.0123456789.0123456789.0123456789.0123456789."
 +
                     
"0123456789.0123456789.0123456789.0123456789.0123456789.0123456789.0123456789.0123456789.0123456789.0123456789."
 +
@@ -194,7 +194,7 @@ public class DomainsRoutesTest {
         }
 
         @Test
-        public void putShouldWorkOnTheSecondTimeForAGivenValue() {
+        void putShouldWorkOnTheSecondTimeForAGivenValue() {
             with()
                 .put(DOMAIN);
 
@@ -205,7 +205,7 @@ public class DomainsRoutesTest {
         }
 
         @Test
-        public void deleteShouldRemoveTheGivenDomain() {
+        void deleteShouldRemoveTheGivenDomain() {
             with()
                 .put(DOMAIN);
 
@@ -229,7 +229,7 @@ public class DomainsRoutesTest {
         }
 
         @Test
-        public void deleteShouldBeOkWhenTheDomainIsNotPresent() {
+        void deleteShouldBeOkWhenTheDomainIsNotPresent() {
             given()
                 .delete(DOMAIN)
             .then()
@@ -237,7 +237,7 @@ public class DomainsRoutesTest {
         }
 
         @Test
-        public void getDomainShouldReturnOkWhenTheDomainIsPresent() {
+        void getDomainShouldReturnOkWhenTheDomainIsPresent() {
             with()
                 .put(DOMAIN);
 
@@ -248,7 +248,7 @@ public class DomainsRoutesTest {
         }
 
         @Test
-        public void getDomainShouldReturnNotFoundWhenTheDomainIsAbsent() {
+        void getDomainShouldReturnNotFoundWhenTheDomainIsAbsent() {
             given()
                 .get(DOMAIN)
             .then()
@@ -257,20 +257,21 @@ public class DomainsRoutesTest {
 
     }
 
-    public class ExceptionHandling {
+    @Nested
+    class ExceptionHandling {
 
         private DomainList domainList;
         private Domain domain;
 
-        @Before
-        public void setUp() throws Exception {
+        @BeforeEach
+        void setUp() throws Exception {
             domainList = mock(DomainList.class);
             createServer(domainList);
             domain = Domain.of("domain");
         }
 
         @Test
-        public void deleteShouldReturnErrorOnUnknownException() throws 
Exception {
+        void deleteShouldReturnErrorOnUnknownException() throws Exception {
             doThrow(new 
RuntimeException()).when(domainList).removeDomain(domain);
 
             when()
@@ -280,7 +281,7 @@ public class DomainsRoutesTest {
         }
 
         @Test
-        public void putShouldReturnErrorOnUnknownException() throws Exception {
+        void putShouldReturnErrorOnUnknownException() throws Exception {
             doThrow(new RuntimeException()).when(domainList).addDomain(domain);
 
             when()
@@ -290,7 +291,7 @@ public class DomainsRoutesTest {
         }
 
         @Test
-        public void getDomainShouldReturnErrorOnUnknownException() throws 
Exception {
+        void getDomainShouldReturnErrorOnUnknownException() throws Exception {
             when(domainList.containsDomain(domain)).thenThrow(new 
RuntimeException());
 
             when()
@@ -300,7 +301,7 @@ public class DomainsRoutesTest {
         }
 
         @Test
-        public void getDomainsShouldReturnErrorOnUnknownException() throws 
Exception {
+        void getDomainsShouldReturnErrorOnUnknownException() throws Exception {
             when(domainList.getDomains()).thenThrow(new RuntimeException());
 
             when()
@@ -310,7 +311,7 @@ public class DomainsRoutesTest {
         }
 
         @Test
-        public void deleteShouldReturnOkWhenDomainListException() throws 
Exception {
+        void deleteShouldReturnOkWhenDomainListException() throws Exception {
             doThrow(new 
DomainListException("message")).when(domainList).removeDomain(domain);
 
             when()
@@ -320,7 +321,7 @@ public class DomainsRoutesTest {
         }
 
         @Test
-        public void putShouldReturnOkWhenDomainListException() throws 
Exception {
+        void putShouldReturnOkWhenDomainListException() throws Exception {
             doThrow(new 
DomainListException("message")).when(domainList).addDomain(domain);
 
             when()
@@ -330,7 +331,7 @@ public class DomainsRoutesTest {
         }
 
         @Test
-        public void getDomainShouldReturnErrorOnDomainListException() throws 
Exception {
+        void getDomainShouldReturnErrorOnDomainListException() throws 
Exception {
             when(domainList.containsDomain(domain)).thenThrow(new 
DomainListException("message"));
 
             when()
@@ -340,7 +341,7 @@ public class DomainsRoutesTest {
         }
 
         @Test
-        public void getDomainsShouldReturnErrorOnDomainListException() throws 
Exception {
+        void getDomainsShouldReturnErrorOnDomainListException() throws 
Exception {
             when(domainList.getDomains()).thenThrow(new 
DomainListException("message"));
 
             when()

http://git-wip-us.apache.org/repos/asf/james-project/blob/b588e8c2/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/GroupsRoutesTest.java
----------------------------------------------------------------------
diff --git 
a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/GroupsRoutesTest.java
 
b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/GroupsRoutesTest.java
index 33bba7c..acd0005 100644
--- 
a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/GroupsRoutesTest.java
+++ 
b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/GroupsRoutesTest.java
@@ -37,7 +37,6 @@ import java.util.Map;
 import org.apache.james.core.Domain;
 import org.apache.james.dnsservice.api.DNSService;
 import org.apache.james.domainlist.api.DomainList;
-import org.apache.james.domainlist.api.DomainListException;
 import org.apache.james.domainlist.memory.MemoryDomainList;
 import org.apache.james.metrics.logger.DefaultMetricFactory;
 import org.apache.james.rrt.api.RecipientRewriteTable;
@@ -50,19 +49,17 @@ import org.apache.james.webadmin.WebAdminServer;
 import org.apache.james.webadmin.WebAdminUtils;
 import org.apache.james.webadmin.utils.JsonTransformer;
 import org.eclipse.jetty.http.HttpStatus;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Nested;
+import org.junit.jupiter.api.Test;
 import org.mockito.Mockito;
 
 import com.jayway.restassured.RestAssured;
 import com.jayway.restassured.filter.log.LogDetail;
 import com.jayway.restassured.http.ContentType;
-import de.bechte.junit.runners.context.HierarchicalContextRunner;
 
-@RunWith(HierarchicalContextRunner.class)
-public class GroupsRoutesTest {
+class GroupsRoutesTest {
 
     private static final Domain DOMAIN = Domain.of("b.com");
     private static final String GROUP1 = "group1" + "@" + DOMAIN.name();
@@ -89,19 +86,20 @@ public class GroupsRoutesTest {
             .build();
     }
 
-    @After
-    public void stop() {
+    @AfterEach
+    void stop() {
         webAdminServer.destroy();
     }
 
-    public class NormalBehaviour {
+    @Nested
+    class NormalBehaviour {
 
         MemoryUsersRepository usersRepository;
         MemoryDomainList domainList;
         MemoryRecipientRewriteTable memoryRecipientRewriteTable;
 
-        @Before
-        public void setUp() throws Exception {
+        @BeforeEach
+        void setUp() throws Exception {
             memoryRecipientRewriteTable = new MemoryRecipientRewriteTable();
             DNSService dnsService = mock(DNSService.class);
             domainList = new MemoryDomainList(dnsService);
@@ -112,7 +110,7 @@ public class GroupsRoutesTest {
         }
 
         @Test
-        public void getGroupsShouldBeEmpty() {
+        void getGroupsShouldBeEmpty() {
             when()
                 .get()
             .then()
@@ -122,7 +120,7 @@ public class GroupsRoutesTest {
         }
 
         @Test
-        public void getGroupsShouldListExistingGroupsInOrder() {
+        void getGroupsShouldListExistingGroupsInOrder() {
             given()
                 .put(GROUP2 + SEPARATOR + USER_A);
 
@@ -143,7 +141,7 @@ public class GroupsRoutesTest {
         }
 
         @Test
-        public void getUnregisteredGroupShouldReturnNotFound() {
+        void getUnregisteredGroupShouldReturnNotFound() {
             Map<String, Object> errors = when()
                 .get("unknown@domain.travel")
             .then()
@@ -161,7 +159,7 @@ public class GroupsRoutesTest {
         }
 
         @Test
-        public void putUserInGroupShouldReturnCreated() {
+        void putUserInGroupShouldReturnCreated() {
             when()
                 .put(GROUP1 + SEPARATOR + USER_A)
             .then()
@@ -169,7 +167,7 @@ public class GroupsRoutesTest {
         }
 
         @Test
-        public void putUserWithSlashInGroupShouldReturnCreated() {
+        void putUserWithSlashInGroupShouldReturnCreated() {
             when()
                 .put(GROUP1 + SEPARATOR + USER_WITH_ENCODED_SLASH)
             .then()
@@ -177,7 +175,7 @@ public class GroupsRoutesTest {
         }
 
         @Test
-        public void putUserWithSlashInGroupShouldCreateUser() {
+        void putUserWithSlashInGroupShouldCreateUser() {
             when()
                 .put(GROUP1 + SEPARATOR + USER_WITH_ENCODED_SLASH);
 
@@ -195,7 +193,7 @@ public class GroupsRoutesTest {
         }
 
         @Test
-        public void putUserInGroupShouldCreateGroup() {
+        void putUserInGroupShouldCreateGroup() {
             when()
                 .put(GROUP1 + SEPARATOR + USER_A);
 
@@ -213,7 +211,7 @@ public class GroupsRoutesTest {
         }
 
         @Test
-        public void putUserInGroupWithEncodedSlashShouldReturnCreated() {
+        void putUserInGroupWithEncodedSlashShouldReturnCreated() {
             when()
                 .put(GROUP_WITH_ENCODED_SLASH + SEPARATOR + USER_A)
             .then()
@@ -221,7 +219,7 @@ public class GroupsRoutesTest {
         }
 
         @Test
-        public void putUserInGroupWithEncodedSlashShouldCreateGroup() {
+        void putUserInGroupWithEncodedSlashShouldCreateGroup() {
             when()
                 .put(GROUP_WITH_ENCODED_SLASH + SEPARATOR + USER_A);
 
@@ -239,7 +237,7 @@ public class GroupsRoutesTest {
         }
 
         @Test
-        public void putSameUserInGroupTwiceShouldBeIdempotent() {
+        void putSameUserInGroupTwiceShouldBeIdempotent() {
             given()
                 .put(GROUP1 + SEPARATOR + USER_A);
 
@@ -260,7 +258,7 @@ public class GroupsRoutesTest {
         }
 
         @Test
-        public void putUserInGroupShouldAllowSeveralUsers() {
+        void putUserInGroupShouldAllowSeveralUsers() {
             given()
                 .put(GROUP1 + SEPARATOR + USER_A);
 
@@ -281,7 +279,7 @@ public class GroupsRoutesTest {
         }
 
         @Test
-        public void putUserInGroupShouldNotAllowGroupOnUnregisteredDomain() 
throws UsersRepositoryException, DomainListException {
+        void putUserInGroupShouldNotAllowGroupOnUnregisteredDomain() {
             Map<String, Object> errors = when()
                 .put("group@unregisteredDomain" + SEPARATOR + USER_A)
             .then()
@@ -300,7 +298,7 @@ public class GroupsRoutesTest {
 
 
         @Test
-        public void putUserInGroupShouldNotAllowUserShadowing() throws 
UsersRepositoryException, DomainListException {
+        void putUserInGroupShouldNotAllowUserShadowing() throws 
UsersRepositoryException {
             usersRepository.addUser(USER_A, "whatever");
 
             Map<String, Object> errors = when()
@@ -320,7 +318,7 @@ public class GroupsRoutesTest {
         }
 
         @Test
-        public void getGroupShouldReturnMembersInOrder() {
+        void getGroupShouldReturnMembersInOrder() {
             given()
                 .put(GROUP1 + SEPARATOR + USER_B);
 
@@ -342,7 +340,7 @@ public class GroupsRoutesTest {
 
 
         @Test
-        public void deleteUserNotInGroupShouldReturnOK() {
+        void deleteUserNotInGroupShouldReturnOK() {
             when()
                 .delete(GROUP1 + SEPARATOR + USER_A)
             .then()
@@ -350,7 +348,7 @@ public class GroupsRoutesTest {
         }
 
         @Test
-        public void deleteLastUserInGroupShouldDeleteGroup() {
+        void deleteLastUserInGroupShouldDeleteGroup() {
             given()
                 .put(GROUP1 + SEPARATOR + USER_A);
 
@@ -366,10 +364,11 @@ public class GroupsRoutesTest {
         }
     }
 
-    public class FilteringOtherRewriteRuleTypes extends NormalBehaviour {
+    @Nested
+    class FilteringOtherRewriteRuleTypes extends NormalBehaviour {
 
-        @Before
-        public void setup() throws Exception {
+        @BeforeEach
+        void setup() throws Exception {
             super.setUp();
             memoryRecipientRewriteTable.addErrorMapping("error", DOMAIN, 
"disabled");
             memoryRecipientRewriteTable.addRegexMapping("regex", DOMAIN, 
".*@b\\.com");
@@ -379,12 +378,13 @@ public class GroupsRoutesTest {
 
     }
 
-    public class ExceptionHandling {
+    @Nested
+    class ExceptionHandling {
 
         private RecipientRewriteTable memoryRecipientRewriteTable;
 
-        @Before
-        public void setUp() throws Exception {
+        @BeforeEach
+        void setUp() throws Exception {
             memoryRecipientRewriteTable = mock(RecipientRewriteTable.class);
             UsersRepository userRepository = mock(UsersRepository.class);
             DomainList domainList = mock(DomainList.class);
@@ -393,7 +393,7 @@ public class GroupsRoutesTest {
         }
 
         @Test
-        public void getMalformedGroupShouldReturnBadRequest() {
+        void getMalformedGroupShouldReturnBadRequest() {
             Map<String, Object> errors = when()
                 .get("not-an-address")
             .then()
@@ -412,7 +412,7 @@ public class GroupsRoutesTest {
         }
 
         @Test
-        public void putMalformedGroupShouldReturnBadRequest() {
+        void putMalformedGroupShouldReturnBadRequest() {
             Map<String, Object> errors = when()
                 .put("not-an-address" + SEPARATOR + USER_A)
             .then()
@@ -431,7 +431,7 @@ public class GroupsRoutesTest {
         }
 
         @Test
-        public void putUserInGroupWithSlashShouldReturnNotFound() {
+        void putUserInGroupWithSlashShouldReturnNotFound() {
             when()
                 .put(GROUP_WITH_SLASH + SEPARATOR + USER_A)
             .then()
@@ -440,7 +440,7 @@ public class GroupsRoutesTest {
         }
 
         @Test
-        public void putUserWithSlashInGroupShouldReturnNotFound() {
+        void putUserWithSlashInGroupShouldReturnNotFound() {
             when()
                 .put(GROUP1 + SEPARATOR + USER_WITH_SLASH)
             .then()
@@ -449,7 +449,7 @@ public class GroupsRoutesTest {
         }
 
         @Test
-        public void putMalformedAddressShouldReturnBadRequest() {
+        void putMalformedAddressShouldReturnBadRequest() {
             Map<String, Object> errors = when()
                 .put(GROUP1 + SEPARATOR + "not-an-address")
             .then()
@@ -468,7 +468,7 @@ public class GroupsRoutesTest {
         }
 
         @Test
-        public void putRequiresTwoPathParams() {
+        void putRequiresTwoPathParams() {
             when()
                 .put(GROUP1)
             .then()
@@ -477,7 +477,7 @@ public class GroupsRoutesTest {
         }
 
         @Test
-        public void deleteMalformedGroupShouldReturnBadRequest() {
+        void deleteMalformedGroupShouldReturnBadRequest() {
             Map<String, Object> errors = when()
                 .delete("not-an-address" + SEPARATOR + USER_A)
             .then()
@@ -496,7 +496,7 @@ public class GroupsRoutesTest {
         }
 
         @Test
-        public void deleteMalformedAddressShouldReturnBadRequest() {
+        void deleteMalformedAddressShouldReturnBadRequest() {
             Map<String, Object> errors = when()
                 .delete(GROUP1 + SEPARATOR + "not-an-address")
             .then()
@@ -515,7 +515,7 @@ public class GroupsRoutesTest {
         }
 
         @Test
-        public void deleteRequiresTwoPathParams() {
+        void deleteRequiresTwoPathParams() {
             when()
                 .delete(GROUP1)
             .then()
@@ -524,7 +524,7 @@ public class GroupsRoutesTest {
         }
 
         @Test
-        public void 
putShouldReturnErrorWhenRecipientRewriteTableExceptionIsThrown() throws 
Exception {
+        void putShouldReturnErrorWhenRecipientRewriteTableExceptionIsThrown() 
throws Exception {
             doThrow(RecipientRewriteTableException.class)
                 .when(memoryRecipientRewriteTable)
                 .addAddressMapping(anyString(), any(), anyString());
@@ -537,7 +537,7 @@ public class GroupsRoutesTest {
         }
 
         @Test
-        public void putShouldReturnErrorWhenErrorMappingExceptionIsThrown() 
throws Exception {
+        void putShouldReturnErrorWhenErrorMappingExceptionIsThrown() throws 
Exception {
             doThrow(RecipientRewriteTable.ErrorMappingException.class)
                 .when(memoryRecipientRewriteTable)
                 .addAddressMapping(anyString(), any(), anyString());
@@ -550,7 +550,7 @@ public class GroupsRoutesTest {
         }
 
         @Test
-        public void putShouldReturnErrorWhenRuntimeExceptionIsThrown() throws 
Exception {
+        void putShouldReturnErrorWhenRuntimeExceptionIsThrown() throws 
Exception {
             doThrow(RuntimeException.class)
                 .when(memoryRecipientRewriteTable)
                 .addAddressMapping(anyString(), any(), anyString());
@@ -563,7 +563,7 @@ public class GroupsRoutesTest {
         }
 
         @Test
-        public void 
getAllShouldReturnErrorWhenRecipientRewriteTableExceptionIsThrown() throws 
Exception {
+        void 
getAllShouldReturnErrorWhenRecipientRewriteTableExceptionIsThrown() throws 
Exception {
             doThrow(RecipientRewriteTableException.class)
                 .when(memoryRecipientRewriteTable)
                 .getAllMappings();
@@ -576,7 +576,7 @@ public class GroupsRoutesTest {
         }
 
         @Test
-        public void getAllShouldReturnErrorWhenErrorMappingExceptionIsThrown() 
throws Exception {
+        void getAllShouldReturnErrorWhenErrorMappingExceptionIsThrown() throws 
Exception {
             doThrow(RecipientRewriteTable.ErrorMappingException.class)
                 .when(memoryRecipientRewriteTable)
                 .getAllMappings();
@@ -589,7 +589,7 @@ public class GroupsRoutesTest {
         }
 
         @Test
-        public void getAllShouldReturnErrorWhenRuntimeExceptionIsThrown() 
throws Exception {
+        void getAllShouldReturnErrorWhenRuntimeExceptionIsThrown() throws 
Exception {
             doThrow(RuntimeException.class)
                 .when(memoryRecipientRewriteTable)
                 .getAllMappings();
@@ -602,7 +602,7 @@ public class GroupsRoutesTest {
         }
 
         @Test
-        public void 
deleteShouldReturnErrorWhenRecipientRewriteTableExceptionIsThrown() throws 
Exception {
+        void 
deleteShouldReturnErrorWhenRecipientRewriteTableExceptionIsThrown() throws 
Exception {
             doThrow(RecipientRewriteTableException.class)
                 .when(memoryRecipientRewriteTable)
                 .removeAddressMapping(anyString(), any(), anyString());
@@ -615,7 +615,7 @@ public class GroupsRoutesTest {
         }
 
         @Test
-        public void deleteShouldReturnErrorWhenErrorMappingExceptionIsThrown() 
throws Exception {
+        void deleteShouldReturnErrorWhenErrorMappingExceptionIsThrown() throws 
Exception {
             doThrow(RecipientRewriteTable.ErrorMappingException.class)
                 .when(memoryRecipientRewriteTable)
                 .removeAddressMapping(anyString(), any(), anyString());
@@ -628,7 +628,7 @@ public class GroupsRoutesTest {
         }
 
         @Test
-        public void deleteShouldReturnErrorWhenRuntimeExceptionIsThrown() 
throws Exception {
+        void deleteShouldReturnErrorWhenRuntimeExceptionIsThrown() throws 
Exception {
             doThrow(RuntimeException.class)
                 .when(memoryRecipientRewriteTable)
                 .removeAddressMapping(anyString(), any(), anyString());
@@ -641,7 +641,7 @@ public class GroupsRoutesTest {
         }
 
         @Test
-        public void 
getShouldReturnErrorWhenRecipientRewriteTableExceptionIsThrown() throws 
Exception {
+        void getShouldReturnErrorWhenRecipientRewriteTableExceptionIsThrown() 
throws Exception {
             doThrow(RecipientRewriteTableException.class)
                 .when(memoryRecipientRewriteTable)
                 .getMappings(anyString(), any());
@@ -654,7 +654,7 @@ public class GroupsRoutesTest {
         }
 
         @Test
-        public void getShouldReturnErrorWhenErrorMappingExceptionIsThrown() 
throws Exception {
+        void getShouldReturnErrorWhenErrorMappingExceptionIsThrown() throws 
Exception {
             doThrow(RecipientRewriteTable.ErrorMappingException.class)
                 .when(memoryRecipientRewriteTable)
                 .getMappings(anyString(), any());
@@ -667,7 +667,7 @@ public class GroupsRoutesTest {
         }
 
         @Test
-        public void getShouldReturnErrorWhenRuntimeExceptionIsThrown() throws 
Exception {
+        void getShouldReturnErrorWhenRuntimeExceptionIsThrown() throws 
Exception {
             doThrow(RuntimeException.class)
                 .when(memoryRecipientRewriteTable)
                 .getMappings(anyString(), any());

http://git-wip-us.apache.org/repos/asf/james-project/blob/b588e8c2/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/UsersRoutesTest.java
----------------------------------------------------------------------
diff --git 
a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/UsersRoutesTest.java
 
b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/UsersRoutesTest.java
index a9349a2..873f246 100644
--- 
a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/UsersRoutesTest.java
+++ 
b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/UsersRoutesTest.java
@@ -44,22 +44,19 @@ import org.apache.james.webadmin.WebAdminUtils;
 import org.apache.james.webadmin.service.UserService;
 import org.apache.james.webadmin.utils.JsonTransformer;
 import org.eclipse.jetty.http.HttpStatus;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Nested;
+import org.junit.jupiter.api.Test;
 
 import com.google.common.collect.ImmutableMap;
 import com.jayway.restassured.RestAssured;
 import com.jayway.restassured.http.ContentType;
 
-import de.bechte.junit.runners.context.HierarchicalContextRunner;
+class UsersRoutesTest {
 
-@RunWith(HierarchicalContextRunner.class)
-public class UsersRoutesTest {
-
-    public static final Domain DOMAIN = Domain.of("domain");
-    public static final String USERNAME = "username@" + DOMAIN.name();
+    private static final Domain DOMAIN = Domain.of("domain");
+    private static final String USERNAME = "username@" + DOMAIN.name();
     private WebAdminServer webAdminServer;
 
     private void createServer(UsersRepository usersRepository) throws 
Exception {
@@ -74,15 +71,16 @@ public class UsersRoutesTest {
             .build();
     }
 
-    @After
-    public void stop() {
+    @AfterEach
+    void stop() {
         webAdminServer.destroy();
     }
 
-    public class NormalBehaviour {
+    @Nested
+    class NormalBehaviour {
 
-        @Before
-        public void setUp() throws Exception {
+        @BeforeEach
+        void setUp() throws Exception {
             DomainList domainList = mock(DomainList.class);
             when(domainList.containsDomain(DOMAIN)).thenReturn(true);
 
@@ -93,7 +91,7 @@ public class UsersRoutesTest {
         }
 
         @Test
-        public void getUsersShouldBeEmptyByDefault() {
+        void getUsersShouldBeEmptyByDefault() {
             List<Map<String, String>> users =
                 when()
                     .get()
@@ -109,7 +107,7 @@ public class UsersRoutesTest {
         }
 
         @Test
-        public void putShouldReturnUserErrorWhenNoBody() {
+        void putShouldReturnUserErrorWhenNoBody() {
             when()
                 .put(USERNAME)
             .then()
@@ -117,7 +115,7 @@ public class UsersRoutesTest {
         }
 
         @Test
-        public void postShouldReturnUserErrorWhenEmptyJsonBody() {
+        void postShouldReturnUserErrorWhenEmptyJsonBody() {
             given()
                 .body("{}")
             .when()
@@ -127,7 +125,7 @@ public class UsersRoutesTest {
         }
 
         @Test
-        public void postShouldReturnUserErrorWhenWrongJsonBody() {
+        void postShouldReturnUserErrorWhenWrongJsonBody() {
             given()
                 .body("{\"bad\":\"any\"}")
             .when()
@@ -137,7 +135,7 @@ public class UsersRoutesTest {
         }
 
         @Test
-        public void postShouldReturnOkWhenValidJsonBody() {
+        void postShouldReturnOkWhenValidJsonBody() {
             given()
                 .body("{\"password\":\"password\"}")
             .when()
@@ -147,7 +145,7 @@ public class UsersRoutesTest {
         }
 
         @Test
-        public void postShouldReturnRequireNonNullPassword() {
+        void postShouldReturnRequireNonNullPassword() {
             given()
                 .body("{\"password\":null}")
             .when()
@@ -157,7 +155,7 @@ public class UsersRoutesTest {
         }
 
         @Test
-        public void postShouldAddTheUser() {
+        void postShouldAddTheUser() {
             with()
                 .body("{\"password\":\"password\"}")
                 .put(USERNAME);
@@ -177,7 +175,7 @@ public class UsersRoutesTest {
         }
 
         @Test
-        public void postingTwoTimesShouldBeAllowed() {
+        void postingTwoTimesShouldBeAllowed() {
             // Given
             with()
                 .body("{\"password\":\"password\"}")
@@ -207,7 +205,7 @@ public class UsersRoutesTest {
         }
 
         @Test
-        public void deleteShouldReturnOk() {
+        void deleteShouldReturnOk() {
             when()
                 .delete(USERNAME)
             .then()
@@ -215,7 +213,7 @@ public class UsersRoutesTest {
         }
 
         @Test
-        public void deleteShouldReturnBadRequestWhenEmptyUserName() {
+        void deleteShouldReturnBadRequestWhenEmptyUserName() {
             when()
                 .delete("/")
             .then()
@@ -223,7 +221,7 @@ public class UsersRoutesTest {
         }
 
         @Test
-        public void deleteShouldReturnBadRequestWhenUsernameIsTooLong() {
+        void deleteShouldReturnBadRequestWhenUsernameIsTooLong() {
             when()
                 .delete(USERNAME + 
"0123456789.0123456789.0123456789.0123456789.0123456789.0123456789.0123456789.0123456789.0123456789.0123456789."
 +
                     
"0123456789.0123456789.0123456789.0123456789.0123456789.0123456789.0123456789.0123456789.0123456789.0123456789."
 +
@@ -233,7 +231,7 @@ public class UsersRoutesTest {
         }
 
         @Test
-        public void deleteShouldReturnNotFoundWhenUsernameContainsSlash() {
+        void deleteShouldReturnNotFoundWhenUsernameContainsSlash() {
             given()
                 .body("{\"password\":\"password\"}")
             .when()
@@ -243,7 +241,7 @@ public class UsersRoutesTest {
         }
 
         @Test
-        public void putShouldReturnBadRequestWhenEmptyUserName() {
+        void putShouldReturnBadRequestWhenEmptyUserName() {
             given()
                 .body("{\"password\":\"password\"}")
             .when()
@@ -253,7 +251,7 @@ public class UsersRoutesTest {
         }
 
         @Test
-        public void putShouldReturnBadRequestWhenUsernameIsTooLong() {
+        void putShouldReturnBadRequestWhenUsernameIsTooLong() {
             given()
                 .body("{\"password\":\"password\"}")
             .when()
@@ -265,7 +263,7 @@ public class UsersRoutesTest {
         }
 
         @Test
-        public void putShouldReturnNotFoundWhenUsernameContainsSlash() {
+        void putShouldReturnNotFoundWhenUsernameContainsSlash() {
             given()
                 .body("{\"password\":\"password\"}")
             .when()
@@ -275,7 +273,7 @@ public class UsersRoutesTest {
         }
 
         @Test
-        public void deleteShouldRemoveAssociatedUser() {
+        void deleteShouldRemoveAssociatedUser() {
             // Given
             with()
                 .body("{\"password\":\"password\"}")
@@ -303,7 +301,7 @@ public class UsersRoutesTest {
         }
 
         @Test
-        public void deleteShouldStillBeValidWithExtraBody() {
+        void deleteShouldStillBeValidWithExtraBody() {
             given()
                 .body("{\"bad\":\"any\"}")
             .when()
@@ -313,14 +311,15 @@ public class UsersRoutesTest {
         }
     }
 
-    public class ErrorHandling {
+    @Nested
+    class ErrorHandling {
 
         private UsersRepository usersRepository;
         private String username;
         private String password;
 
-        @Before
-        public void setUp() throws Exception {
+        @BeforeEach
+        void setUp() throws Exception {
             usersRepository = mock(UsersRepository.class);
             createServer(usersRepository);
             username = "username@domain";
@@ -328,7 +327,7 @@ public class UsersRoutesTest {
         }
 
         @Test
-        public void deleteShouldStillBeOkWhenNoUser() throws Exception {
+        void deleteShouldStillBeOkWhenNoUser() throws Exception {
             doThrow(new 
UsersRepositoryException("message")).when(usersRepository).removeUser(username);
 
             when()
@@ -338,7 +337,7 @@ public class UsersRoutesTest {
         }
 
         @Test
-        public void getShouldFailOnRepositoryException() throws Exception {
+        void getShouldFailOnRepositoryException() throws Exception {
             when(usersRepository.list()).thenThrow(new 
UsersRepositoryException("message"));
 
             when()
@@ -348,7 +347,7 @@ public class UsersRoutesTest {
         }
 
         @Test
-        public void postShouldFailOnRepositoryExceptionOnGetUserByName() 
throws Exception {
+        void postShouldFailOnRepositoryExceptionOnGetUserByName() throws 
Exception {
             when(usersRepository.getUserByName(username)).thenThrow(new 
UsersRepositoryException("message"));
 
             given()
@@ -360,7 +359,7 @@ public class UsersRoutesTest {
         }
 
         @Test
-        public void postShouldNotFailOnRepositoryExceptionOnAddUser() throws 
Exception {
+        void postShouldNotFailOnRepositoryExceptionOnAddUser() throws 
Exception {
             when(usersRepository.getUserByName(username)).thenReturn(null);
             doThrow(new 
UsersRepositoryException("message")).when(usersRepository).addUser(username, 
password);
 
@@ -373,7 +372,7 @@ public class UsersRoutesTest {
         }
 
         @Test
-        public void postShouldFailOnRepositoryExceptionOnUpdateUser() throws 
Exception {
+        void postShouldFailOnRepositoryExceptionOnUpdateUser() throws 
Exception {
             
when(usersRepository.getUserByName(username)).thenReturn(mock(User.class));
             doThrow(new 
UsersRepositoryException("message")).when(usersRepository).updateUser(any());
 
@@ -387,7 +386,7 @@ public class UsersRoutesTest {
 
 
         @Test
-        public void deleteShouldFailOnUnknownException() throws Exception {
+        void deleteShouldFailOnUnknownException() throws Exception {
             doThrow(new 
RuntimeException()).when(usersRepository).removeUser(username);
 
             when()
@@ -397,7 +396,7 @@ public class UsersRoutesTest {
         }
 
         @Test
-        public void getShouldFailOnUnknownException() throws Exception {
+        void getShouldFailOnUnknownException() throws Exception {
             when(usersRepository.list()).thenThrow(new RuntimeException());
 
             when()
@@ -407,7 +406,7 @@ public class UsersRoutesTest {
         }
 
         @Test
-        public void postShouldFailOnUnknownExceptionOnGetUserByName() throws 
Exception {
+        void postShouldFailOnUnknownExceptionOnGetUserByName() throws 
Exception {
             when(usersRepository.getUserByName(username)).thenThrow(new 
RuntimeException());
 
             given()
@@ -419,7 +418,7 @@ public class UsersRoutesTest {
         }
 
         @Test
-        public void postShouldFailOnUnknownExceptionOnAddUser() throws 
Exception {
+        void postShouldFailOnUnknownExceptionOnAddUser() throws Exception {
             when(usersRepository.getUserByName(username)).thenReturn(null);
             doThrow(new 
RuntimeException()).when(usersRepository).addUser(username, password);
 
@@ -432,7 +431,7 @@ public class UsersRoutesTest {
         }
 
         @Test
-        public void postShouldFailOnUnknownExceptionOnGetUpdateUser() throws 
Exception {
+        void postShouldFailOnUnknownExceptionOnGetUpdateUser() throws 
Exception {
             
when(usersRepository.getUserByName(username)).thenReturn(mock(User.class));
             doThrow(new 
RuntimeException()).when(usersRepository).updateUser(any());
 


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

Reply via email to