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 ad...@apache.org on 2017/02/09 13:01:16 UTC

[1/7] james-project git commit: JAMES-1925 Rename FirstUserConnectionFilter to UserProvisioningFilter

Repository: james-project
Updated Branches:
  refs/heads/master ff3c9517f -> a4d8c8e00


JAMES-1925 Rename FirstUserConnectionFilter to UserProvisioningFilter


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

Branch: refs/heads/master
Commit: dea8f2eb1498612a1ad171e00a43f43edfb38f37
Parents: 4473335
Author: Antoine Duprat <ad...@linagora.com>
Authored: Tue Feb 7 10:30:45 2017 +0100
Committer: Antoine Duprat <ad...@linagora.com>
Committed: Thu Feb 9 09:44:21 2017 +0100

----------------------------------------------------------------------
 .../james/jmap/FirstUserConnectionFilter.java   | 127 ---------
 .../java/org/apache/james/jmap/JMAPServer.java  |   4 +-
 .../james/jmap/UserProvisioningFilter.java      | 127 +++++++++
 .../jmap/FirstUserConnectionFilterTest.java     |  59 ----
 .../FirstUserConnectionFilterThreadTest.java    | 271 -------------------
 .../james/jmap/UserProvisioningFilterTest.java  |  59 ++++
 .../jmap/UserProvisioningFilterThreadTest.java  | 271 +++++++++++++++++++
 7 files changed, 459 insertions(+), 459 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/dea8f2eb/server/protocols/jmap/src/main/java/org/apache/james/jmap/FirstUserConnectionFilter.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/FirstUserConnectionFilter.java b/server/protocols/jmap/src/main/java/org/apache/james/jmap/FirstUserConnectionFilter.java
deleted file mode 100644
index 8de6195..0000000
--- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/FirstUserConnectionFilter.java
+++ /dev/null
@@ -1,127 +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 java.io.IOException;
-import java.util.Optional;
-import java.util.UUID;
-import java.util.function.Function;
-
-import javax.inject.Inject;
-import javax.servlet.Filter;
-import javax.servlet.FilterChain;
-import javax.servlet.FilterConfig;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-
-import org.apache.james.mailbox.MailboxManager;
-import org.apache.james.mailbox.MailboxSession;
-import org.apache.james.mailbox.MailboxSession.User;
-import org.apache.james.mailbox.exception.BadCredentialsException;
-import org.apache.james.mailbox.exception.MailboxException;
-import org.apache.james.mailbox.model.MailboxPath;
-import org.apache.james.user.api.AlreadyExistInUsersRepositoryException;
-import org.apache.james.user.api.UsersRepository;
-import org.apache.james.user.api.UsersRepositoryException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Throwables;
-import com.google.common.collect.ImmutableList;
-
-public class FirstUserConnectionFilter implements Filter {
-
-    private static final ImmutableList<String> DEFAULT_MAILBOXES = ImmutableList.of("INBOX", "Outbox", "Sent", "Trash");
-    private static final Logger LOGGER = LoggerFactory.getLogger(FirstUserConnectionFilter.class);
-    private final UsersRepository usersRepository;
-    private final MailboxManager mailboxManager;
-
-    @Inject
-    @VisibleForTesting FirstUserConnectionFilter(UsersRepository usersRepository, MailboxManager mailboxManager) {
-        this.usersRepository = usersRepository;
-        this.mailboxManager = mailboxManager;
-    }
-    
-    @Override
-    public void init(FilterConfig filterConfig) throws ServletException {
-    }
-    
-    @Override
-    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
-        Optional<MailboxSession> session = Optional.ofNullable((MailboxSession)request.getAttribute(AuthenticationFilter.MAILBOX_SESSION));
-        session.ifPresent(this::createAccountIfNeeded);
-        chain.doFilter(request, response);
-    }
-    
-    @VisibleForTesting
-    void createAccountIfNeeded(MailboxSession session) {
-        try {
-            User user = session.getUser();
-            if (needsAccountCreation(user)) {
-                createAccount(user);
-            }
-        } catch (AlreadyExistInUsersRepositoryException e) {
-            // Ignore
-        } catch (UsersRepositoryException|MailboxException e) {
-            throw Throwables.propagate(e);
-        }
-    }
-
-    private boolean needsAccountCreation(User user) throws UsersRepositoryException {
-        return !usersRepository.contains(user.getUserName());
-    }
-
-    private void createAccount(User user) throws UsersRepositoryException, BadCredentialsException, MailboxException {
-        createUser(user);
-        createDefaultMailboxes(user);
-    }
-
-    private void createUser(User user) throws UsersRepositoryException {
-        usersRepository.addUser(user.getUserName(), generatePassword());
-    }
-    
-    private String generatePassword() {
-        return UUID.randomUUID().toString();
-    }
-    
-    private void createDefaultMailboxes(User user) throws BadCredentialsException, MailboxException {
-        MailboxSession session = mailboxManager.createSystemSession(user.getUserName(), LOGGER);
-        DEFAULT_MAILBOXES.stream()
-            .map(toMailboxPath(session))
-            .forEach(mailboxPath -> createMailbox(mailboxPath, session));
-    }
-
-    private Function<String, MailboxPath> toMailboxPath(MailboxSession session) {
-        return mailbox -> new MailboxPath(session.getPersonalSpace(), session.getUser().getUserName(), mailbox);
-    }
-    
-    private void createMailbox(MailboxPath mailboxPath, MailboxSession session) {
-        try {
-            mailboxManager.createMailbox(mailboxPath, session);
-        } catch (MailboxException e) {
-            throw Throwables.propagate(e);
-        }
-    }
-
-    @Override
-    public void destroy() {
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/dea8f2eb/server/protocols/jmap/src/main/java/org/apache/james/jmap/JMAPServer.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/JMAPServer.java b/server/protocols/jmap/src/main/java/org/apache/james/jmap/JMAPServer.java
index e1c3ba5..25242f4 100644
--- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/JMAPServer.java
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/JMAPServer.java
@@ -40,7 +40,7 @@ public class JMAPServer implements Configurable {
     @Inject
     private JMAPServer(JMAPConfiguration jmapConfiguration,
                        AuthenticationServlet authenticationServlet, JMAPServlet jmapServlet, DownloadServlet downloadServlet, UploadServlet uploadServlet,
-                       AuthenticationFilter authenticationFilter, FirstUserConnectionFilter firstUserConnectionFilter) {
+                       AuthenticationFilter authenticationFilter, UserProvisioningFilter userProvisioningFilter) {
 
         server = JettyHttpServer.create(
                 configurationBuilderFor(jmapConfiguration)
@@ -53,7 +53,7 @@ public class JMAPServer implements Configurable {
                             .with(jmapServlet)
                         .filter(JMAPUrls.JMAP)
                             .with(new AllowAllCrossOriginRequests(bypass(authenticationFilter).on("OPTIONS").only()))
-                            .and(firstUserConnectionFilter)
+                            .and(userProvisioningFilter)
                             .only()
                         .serveAsOneLevelTemplate(JMAPUrls.DOWNLOAD)
                             .with(downloadServlet)

http://git-wip-us.apache.org/repos/asf/james-project/blob/dea8f2eb/server/protocols/jmap/src/main/java/org/apache/james/jmap/UserProvisioningFilter.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/UserProvisioningFilter.java b/server/protocols/jmap/src/main/java/org/apache/james/jmap/UserProvisioningFilter.java
new file mode 100644
index 0000000..6145a79
--- /dev/null
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/UserProvisioningFilter.java
@@ -0,0 +1,127 @@
+/****************************************************************
+ * 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 java.io.IOException;
+import java.util.Optional;
+import java.util.UUID;
+import java.util.function.Function;
+
+import javax.inject.Inject;
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+
+import org.apache.james.mailbox.MailboxManager;
+import org.apache.james.mailbox.MailboxSession;
+import org.apache.james.mailbox.MailboxSession.User;
+import org.apache.james.mailbox.exception.BadCredentialsException;
+import org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.mailbox.model.MailboxPath;
+import org.apache.james.user.api.AlreadyExistInUsersRepositoryException;
+import org.apache.james.user.api.UsersRepository;
+import org.apache.james.user.api.UsersRepositoryException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Throwables;
+import com.google.common.collect.ImmutableList;
+
+public class UserProvisioningFilter implements Filter {
+
+    private static final ImmutableList<String> DEFAULT_MAILBOXES = ImmutableList.of("INBOX", "Outbox", "Sent", "Trash");
+    private static final Logger LOGGER = LoggerFactory.getLogger(UserProvisioningFilter.class);
+    private final UsersRepository usersRepository;
+    private final MailboxManager mailboxManager;
+
+    @Inject
+    @VisibleForTesting UserProvisioningFilter(UsersRepository usersRepository, MailboxManager mailboxManager) {
+        this.usersRepository = usersRepository;
+        this.mailboxManager = mailboxManager;
+    }
+    
+    @Override
+    public void init(FilterConfig filterConfig) throws ServletException {
+    }
+    
+    @Override
+    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
+        Optional<MailboxSession> session = Optional.ofNullable((MailboxSession)request.getAttribute(AuthenticationFilter.MAILBOX_SESSION));
+        session.ifPresent(this::createAccountIfNeeded);
+        chain.doFilter(request, response);
+    }
+    
+    @VisibleForTesting
+    void createAccountIfNeeded(MailboxSession session) {
+        try {
+            User user = session.getUser();
+            if (needsAccountCreation(user)) {
+                createAccount(user);
+            }
+        } catch (AlreadyExistInUsersRepositoryException e) {
+            // Ignore
+        } catch (UsersRepositoryException|MailboxException e) {
+            throw Throwables.propagate(e);
+        }
+    }
+
+    private boolean needsAccountCreation(User user) throws UsersRepositoryException {
+        return !usersRepository.contains(user.getUserName());
+    }
+
+    private void createAccount(User user) throws UsersRepositoryException, BadCredentialsException, MailboxException {
+        createUser(user);
+        createDefaultMailboxes(user);
+    }
+
+    private void createUser(User user) throws UsersRepositoryException {
+        usersRepository.addUser(user.getUserName(), generatePassword());
+    }
+    
+    private String generatePassword() {
+        return UUID.randomUUID().toString();
+    }
+    
+    private void createDefaultMailboxes(User user) throws BadCredentialsException, MailboxException {
+        MailboxSession session = mailboxManager.createSystemSession(user.getUserName(), LOGGER);
+        DEFAULT_MAILBOXES.stream()
+            .map(toMailboxPath(session))
+            .forEach(mailboxPath -> createMailbox(mailboxPath, session));
+    }
+
+    private Function<String, MailboxPath> toMailboxPath(MailboxSession session) {
+        return mailbox -> new MailboxPath(session.getPersonalSpace(), session.getUser().getUserName(), mailbox);
+    }
+    
+    private void createMailbox(MailboxPath mailboxPath, MailboxSession session) {
+        try {
+            mailboxManager.createMailbox(mailboxPath, session);
+        } catch (MailboxException e) {
+            throw Throwables.propagate(e);
+        }
+    }
+
+    @Override
+    public void destroy() {
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/dea8f2eb/server/protocols/jmap/src/test/java/org/apache/james/jmap/FirstUserConnectionFilterTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/FirstUserConnectionFilterTest.java b/server/protocols/jmap/src/test/java/org/apache/james/jmap/FirstUserConnectionFilterTest.java
deleted file mode 100644
index 540ca0a..0000000
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/FirstUserConnectionFilterTest.java
+++ /dev/null
@@ -1,59 +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.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-
-import java.io.IOException;
-
-import javax.servlet.FilterChain;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.james.mailbox.MailboxManager;
-import org.apache.james.user.api.UsersRepositoryException;
-import org.apache.james.user.lib.mock.InMemoryUsersRepository;
-import org.junit.Before;
-import org.junit.Test;
-
-public class FirstUserConnectionFilterTest {
-
-    private FirstUserConnectionFilter sut;
-    private InMemoryUsersRepository usersRepository;
-
-    @Before
-    public void setup() {
-        usersRepository = new InMemoryUsersRepository();
-        MailboxManager mailboxManager = mock(MailboxManager.class);
-        sut = new FirstUserConnectionFilter(usersRepository, mailboxManager);
-    }
-    
-    @Test
-    public void filterShouldDoNothingOnNullSession() throws IOException, ServletException, UsersRepositoryException {
-        HttpServletRequest request = mock(HttpServletRequest.class);
-        HttpServletResponse response = mock(HttpServletResponse.class);
-        FilterChain chain = mock(FilterChain.class);
-        sut.doFilter(request, response, chain);
-        verify(chain).doFilter(request, response);
-        assertThat(usersRepository.list()).isEmpty();
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/dea8f2eb/server/protocols/jmap/src/test/java/org/apache/james/jmap/FirstUserConnectionFilterThreadTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/FirstUserConnectionFilterThreadTest.java b/server/protocols/jmap/src/test/java/org/apache/james/jmap/FirstUserConnectionFilterThreadTest.java
deleted file mode 100644
index b2fe1d5..0000000
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/FirstUserConnectionFilterThreadTest.java
+++ /dev/null
@@ -1,271 +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 java.util.EnumSet;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.james.mailbox.MailboxListener;
-import org.apache.james.mailbox.MailboxManager;
-import org.apache.james.mailbox.MailboxSession;
-import org.apache.james.mailbox.MessageManager;
-import org.apache.james.mailbox.exception.BadCredentialsException;
-import org.apache.james.mailbox.exception.MailboxException;
-import org.apache.james.mailbox.mock.MockMailboxSession;
-import org.apache.james.mailbox.model.MailboxACL.MailboxACLCommand;
-import org.apache.james.mailbox.model.MailboxACL.MailboxACLEntryKey;
-import org.apache.james.mailbox.model.MailboxACL.MailboxACLRight;
-import org.apache.james.mailbox.model.MailboxACL.MailboxACLRights;
-import org.apache.james.mailbox.model.MailboxAnnotation;
-import org.apache.james.mailbox.model.MailboxAnnotationKey;
-import org.apache.james.mailbox.model.MailboxId;
-import org.apache.james.mailbox.model.MailboxMetaData;
-import org.apache.james.mailbox.model.MailboxPath;
-import org.apache.james.mailbox.model.MailboxQuery;
-import org.apache.james.mailbox.model.MessageId;
-import org.apache.james.mailbox.model.MessageRange;
-import org.apache.james.mailbox.model.MultimailboxesSearchQuery;
-import org.apache.james.user.lib.mock.InMemoryUsersRepository;
-import org.junit.Test;
-import org.slf4j.Logger;
-
-import com.google.testing.threadtester.AnnotatedTestRunner;
-import com.google.testing.threadtester.ThreadedAfter;
-import com.google.testing.threadtester.ThreadedBefore;
-import com.google.testing.threadtester.ThreadedMain;
-import com.google.testing.threadtester.ThreadedSecondary;
-
-public class FirstUserConnectionFilterThreadTest {
-
-    private FirstUserConnectionFilter sut;
-    private InMemoryUsersRepository usersRepository;
-    private MailboxSession session;
-    private MailboxManager mailboxManager;
-
-    @ThreadedBefore
-    public void before() {
-        usersRepository = new InMemoryUsersRepository();
-        session = new MockMailboxSession("username");
-        mailboxManager = new FakeMailboxManager(session) ;
-        sut = new FirstUserConnectionFilter(usersRepository, mailboxManager);
-    }
-    
-    @ThreadedMain
-    public void mainThread() {
-        sut.createAccountIfNeeded(session);
-    }
-    
-    @ThreadedSecondary
-    public void secondThread() {
-        sut.createAccountIfNeeded(session);
-    }
-    
-    @ThreadedAfter
-    public void after() {
-        // Exception is thrown if test fails
-    }
-    
-    @Test
-    public void testConcurrentAccessToFilterShouldNotThrow() {
-        AnnotatedTestRunner runner = new AnnotatedTestRunner();
-        runner.runTests(this.getClass(), FirstUserConnectionFilter.class);
-    }
-    
-    private static class FakeMailboxManager implements MailboxManager {
-        private MailboxSession mailboxSession;
-
-        public FakeMailboxManager(MailboxSession mailboxSession) {
-            this.mailboxSession = mailboxSession;
-        }
-
-        @Override
-        public EnumSet<SearchCapabilities> getSupportedSearchCapabilities() {
-            return EnumSet.noneOf(SearchCapabilities.class);
-        }
-        
-        @Override
-        public void startProcessingRequest(MailboxSession session) {
-        }
-
-        @Override
-        public void endProcessingRequest(MailboxSession session) {
-        }
-
-        @Override
-        public void addListener(MailboxPath mailboxPath, MailboxListener listener, MailboxSession session) throws MailboxException {
-        }
-
-        @Override
-        public void removeListener(MailboxPath mailboxPath, MailboxListener listner, MailboxSession session) throws MailboxException {
-        }
-
-        @Override
-        public void addGlobalListener(MailboxListener listener, MailboxSession session) throws MailboxException {
-        }
-
-        @Override
-        public void removeGlobalListener(MailboxListener listner, MailboxSession session) throws MailboxException {
-        }
-
-        @Override
-        public char getDelimiter() {
-            return 0;
-        }
-
-        @Override
-        public MessageManager getMailbox(MailboxPath mailboxPath, MailboxSession session) throws MailboxException {
-            return null;
-        }
-
-        @Override
-        public MessageManager getMailbox(MailboxId mailboxId, MailboxSession session) throws MailboxException {
-            return null;
-        }
-
-        @Override
-        public void createMailbox(MailboxPath mailboxPath, MailboxSession mailboxSession) throws MailboxException {
-        }
-
-        @Override
-        public void deleteMailbox(MailboxPath mailboxPath, MailboxSession session) throws MailboxException {
-        }
-
-        @Override
-        public void renameMailbox(MailboxPath from, MailboxPath to, MailboxSession session) throws MailboxException {
-        }
-
-        @Override
-        public List<MessageRange> copyMessages(MessageRange set, MailboxPath from, MailboxPath to, MailboxSession session) throws MailboxException {
-            return null;
-        }
-
-        @Override
-        public List<MessageRange> copyMessages(MessageRange set, MailboxId from, MailboxId to, MailboxSession session)
-                throws MailboxException {
-            return null;
-        }
-        
-        @Override
-        public List<MessageRange> moveMessages(MessageRange set, MailboxPath from, MailboxPath to, MailboxSession session) throws MailboxException {
-            return null;
-        }
-
-        @Override
-        public List<MailboxMetaData> search(MailboxQuery expression, MailboxSession session) throws MailboxException {
-            return null;
-        }
-
-        @Override
-        public boolean mailboxExists(MailboxPath mailboxPath, MailboxSession session) throws MailboxException {
-            return false;
-        }
-
-        @Override
-        public MailboxSession createSystemSession(String userName, Logger log) throws BadCredentialsException, MailboxException {
-            return mailboxSession;
-        }
-
-        @Override
-        public MailboxSession login(String userid, String passwd, Logger log) throws BadCredentialsException, MailboxException {
-            return null;
-        }
-
-        @Override
-        public void logout(MailboxSession session, boolean force) throws MailboxException {
-        }
-
-        @Override
-        public boolean hasRight(MailboxPath mailboxPath, MailboxACLRight right, MailboxSession session) throws MailboxException {
-            return false;
-        }
-
-        @Override
-        public MailboxACLRights myRights(MailboxPath mailboxPath, MailboxSession session) throws MailboxException {
-            return null;
-        }
-
-        @Override
-        public MailboxACLRights[] listRigths(MailboxPath mailboxPath, MailboxACLEntryKey identifier, MailboxSession session) throws MailboxException {
-            return null;
-        }
-
-        @Override
-        public void setRights(MailboxPath mailboxPath, MailboxACLCommand mailboxACLCommand, MailboxSession session) throws MailboxException {
-        }
-
-        @Override
-        public List<MailboxPath> list(MailboxSession session) throws MailboxException {
-            return null;
-        }
-
-        @Override
-        public EnumSet<MailboxCapabilities> getSupportedMailboxCapabilities() {
-            return null;
-        }
-        
-        @Override
-        public EnumSet<MessageCapabilities> getSupportedMessageCapabilities() {
-            return null;
-        }
-
-        @Override
-        public List<MailboxAnnotation> getAllAnnotations(MailboxPath mailboxPath, MailboxSession session) throws MailboxException {
-            return null;
-        }
-
-        @Override
-        public List<MailboxAnnotation> getAnnotationsByKeys(MailboxPath mailboxPath, MailboxSession session, Set<MailboxAnnotationKey> keys) throws MailboxException {
-            return null;
-        }
-
-        @Override
-        public void updateAnnotations(MailboxPath mailboxPath, MailboxSession session, List<MailboxAnnotation> mailboxAnnotations) throws MailboxException {
-            
-        }
-
-        @Override
-        public boolean hasCapability(MailboxCapabilities capability) {
-            return false;
-        }
-
-        @Override
-        public List<MessageId> search(MultimailboxesSearchQuery expression, MailboxSession session, long limit) throws MailboxException {
-            return null;
-        }
-
-        @Override
-        public List<MailboxAnnotation> getAnnotationsByKeysWithOneDepth(MailboxPath mailboxPath, MailboxSession session,
-                Set<MailboxAnnotationKey> keys) throws MailboxException {
-            return null;
-        }
-
-        @Override
-        public List<MailboxAnnotation> getAnnotationsByKeysWithAllDepth(MailboxPath mailboxPath, MailboxSession session,
-                Set<MailboxAnnotationKey> keys) throws MailboxException {
-            return null;
-        }
-
-        @Override
-        public boolean hasChildren(MailboxPath mailboxPath, MailboxSession session) throws MailboxException {
-            return false;
-        }
-    }
-}
-

http://git-wip-us.apache.org/repos/asf/james-project/blob/dea8f2eb/server/protocols/jmap/src/test/java/org/apache/james/jmap/UserProvisioningFilterTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/UserProvisioningFilterTest.java b/server/protocols/jmap/src/test/java/org/apache/james/jmap/UserProvisioningFilterTest.java
new file mode 100644
index 0000000..ffc37b0
--- /dev/null
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/UserProvisioningFilterTest.java
@@ -0,0 +1,59 @@
+/****************************************************************
+ * 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.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+
+import java.io.IOException;
+
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.james.mailbox.MailboxManager;
+import org.apache.james.user.api.UsersRepositoryException;
+import org.apache.james.user.lib.mock.InMemoryUsersRepository;
+import org.junit.Before;
+import org.junit.Test;
+
+public class UserProvisioningFilterTest {
+
+    private UserProvisioningFilter sut;
+    private InMemoryUsersRepository usersRepository;
+
+    @Before
+    public void setup() {
+        usersRepository = new InMemoryUsersRepository();
+        MailboxManager mailboxManager = mock(MailboxManager.class);
+        sut = new UserProvisioningFilter(usersRepository, mailboxManager);
+    }
+    
+    @Test
+    public void filterShouldDoNothingOnNullSession() throws IOException, ServletException, UsersRepositoryException {
+        HttpServletRequest request = mock(HttpServletRequest.class);
+        HttpServletResponse response = mock(HttpServletResponse.class);
+        FilterChain chain = mock(FilterChain.class);
+        sut.doFilter(request, response, chain);
+        verify(chain).doFilter(request, response);
+        assertThat(usersRepository.list()).isEmpty();
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/dea8f2eb/server/protocols/jmap/src/test/java/org/apache/james/jmap/UserProvisioningFilterThreadTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/UserProvisioningFilterThreadTest.java b/server/protocols/jmap/src/test/java/org/apache/james/jmap/UserProvisioningFilterThreadTest.java
new file mode 100644
index 0000000..eb5ec5c
--- /dev/null
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/UserProvisioningFilterThreadTest.java
@@ -0,0 +1,271 @@
+/****************************************************************
+ * 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 java.util.EnumSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.james.mailbox.MailboxListener;
+import org.apache.james.mailbox.MailboxManager;
+import org.apache.james.mailbox.MailboxSession;
+import org.apache.james.mailbox.MessageManager;
+import org.apache.james.mailbox.exception.BadCredentialsException;
+import org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.mailbox.mock.MockMailboxSession;
+import org.apache.james.mailbox.model.MailboxACL.MailboxACLCommand;
+import org.apache.james.mailbox.model.MailboxACL.MailboxACLEntryKey;
+import org.apache.james.mailbox.model.MailboxACL.MailboxACLRight;
+import org.apache.james.mailbox.model.MailboxACL.MailboxACLRights;
+import org.apache.james.mailbox.model.MailboxAnnotation;
+import org.apache.james.mailbox.model.MailboxAnnotationKey;
+import org.apache.james.mailbox.model.MailboxId;
+import org.apache.james.mailbox.model.MailboxMetaData;
+import org.apache.james.mailbox.model.MailboxPath;
+import org.apache.james.mailbox.model.MailboxQuery;
+import org.apache.james.mailbox.model.MessageId;
+import org.apache.james.mailbox.model.MessageRange;
+import org.apache.james.mailbox.model.MultimailboxesSearchQuery;
+import org.apache.james.user.lib.mock.InMemoryUsersRepository;
+import org.junit.Test;
+import org.slf4j.Logger;
+
+import com.google.testing.threadtester.AnnotatedTestRunner;
+import com.google.testing.threadtester.ThreadedAfter;
+import com.google.testing.threadtester.ThreadedBefore;
+import com.google.testing.threadtester.ThreadedMain;
+import com.google.testing.threadtester.ThreadedSecondary;
+
+public class UserProvisioningFilterThreadTest {
+
+    private UserProvisioningFilter sut;
+    private InMemoryUsersRepository usersRepository;
+    private MailboxSession session;
+    private MailboxManager mailboxManager;
+
+    @ThreadedBefore
+    public void before() {
+        usersRepository = new InMemoryUsersRepository();
+        session = new MockMailboxSession("username");
+        mailboxManager = new FakeMailboxManager(session) ;
+        sut = new UserProvisioningFilter(usersRepository, mailboxManager);
+    }
+    
+    @ThreadedMain
+    public void mainThread() {
+        sut.createAccountIfNeeded(session);
+    }
+    
+    @ThreadedSecondary
+    public void secondThread() {
+        sut.createAccountIfNeeded(session);
+    }
+    
+    @ThreadedAfter
+    public void after() {
+        // Exception is thrown if test fails
+    }
+    
+    @Test
+    public void testConcurrentAccessToFilterShouldNotThrow() {
+        AnnotatedTestRunner runner = new AnnotatedTestRunner();
+        runner.runTests(this.getClass(), UserProvisioningFilter.class);
+    }
+    
+    private static class FakeMailboxManager implements MailboxManager {
+        private MailboxSession mailboxSession;
+
+        public FakeMailboxManager(MailboxSession mailboxSession) {
+            this.mailboxSession = mailboxSession;
+        }
+
+        @Override
+        public EnumSet<SearchCapabilities> getSupportedSearchCapabilities() {
+            return EnumSet.noneOf(SearchCapabilities.class);
+        }
+        
+        @Override
+        public void startProcessingRequest(MailboxSession session) {
+        }
+
+        @Override
+        public void endProcessingRequest(MailboxSession session) {
+        }
+
+        @Override
+        public void addListener(MailboxPath mailboxPath, MailboxListener listener, MailboxSession session) throws MailboxException {
+        }
+
+        @Override
+        public void removeListener(MailboxPath mailboxPath, MailboxListener listner, MailboxSession session) throws MailboxException {
+        }
+
+        @Override
+        public void addGlobalListener(MailboxListener listener, MailboxSession session) throws MailboxException {
+        }
+
+        @Override
+        public void removeGlobalListener(MailboxListener listner, MailboxSession session) throws MailboxException {
+        }
+
+        @Override
+        public char getDelimiter() {
+            return 0;
+        }
+
+        @Override
+        public MessageManager getMailbox(MailboxPath mailboxPath, MailboxSession session) throws MailboxException {
+            return null;
+        }
+
+        @Override
+        public MessageManager getMailbox(MailboxId mailboxId, MailboxSession session) throws MailboxException {
+            return null;
+        }
+
+        @Override
+        public void createMailbox(MailboxPath mailboxPath, MailboxSession mailboxSession) throws MailboxException {
+        }
+
+        @Override
+        public void deleteMailbox(MailboxPath mailboxPath, MailboxSession session) throws MailboxException {
+        }
+
+        @Override
+        public void renameMailbox(MailboxPath from, MailboxPath to, MailboxSession session) throws MailboxException {
+        }
+
+        @Override
+        public List<MessageRange> copyMessages(MessageRange set, MailboxPath from, MailboxPath to, MailboxSession session) throws MailboxException {
+            return null;
+        }
+
+        @Override
+        public List<MessageRange> copyMessages(MessageRange set, MailboxId from, MailboxId to, MailboxSession session)
+                throws MailboxException {
+            return null;
+        }
+        
+        @Override
+        public List<MessageRange> moveMessages(MessageRange set, MailboxPath from, MailboxPath to, MailboxSession session) throws MailboxException {
+            return null;
+        }
+
+        @Override
+        public List<MailboxMetaData> search(MailboxQuery expression, MailboxSession session) throws MailboxException {
+            return null;
+        }
+
+        @Override
+        public boolean mailboxExists(MailboxPath mailboxPath, MailboxSession session) throws MailboxException {
+            return false;
+        }
+
+        @Override
+        public MailboxSession createSystemSession(String userName, Logger log) throws BadCredentialsException, MailboxException {
+            return mailboxSession;
+        }
+
+        @Override
+        public MailboxSession login(String userid, String passwd, Logger log) throws BadCredentialsException, MailboxException {
+            return null;
+        }
+
+        @Override
+        public void logout(MailboxSession session, boolean force) throws MailboxException {
+        }
+
+        @Override
+        public boolean hasRight(MailboxPath mailboxPath, MailboxACLRight right, MailboxSession session) throws MailboxException {
+            return false;
+        }
+
+        @Override
+        public MailboxACLRights myRights(MailboxPath mailboxPath, MailboxSession session) throws MailboxException {
+            return null;
+        }
+
+        @Override
+        public MailboxACLRights[] listRigths(MailboxPath mailboxPath, MailboxACLEntryKey identifier, MailboxSession session) throws MailboxException {
+            return null;
+        }
+
+        @Override
+        public void setRights(MailboxPath mailboxPath, MailboxACLCommand mailboxACLCommand, MailboxSession session) throws MailboxException {
+        }
+
+        @Override
+        public List<MailboxPath> list(MailboxSession session) throws MailboxException {
+            return null;
+        }
+
+        @Override
+        public EnumSet<MailboxCapabilities> getSupportedMailboxCapabilities() {
+            return null;
+        }
+        
+        @Override
+        public EnumSet<MessageCapabilities> getSupportedMessageCapabilities() {
+            return null;
+        }
+
+        @Override
+        public List<MailboxAnnotation> getAllAnnotations(MailboxPath mailboxPath, MailboxSession session) throws MailboxException {
+            return null;
+        }
+
+        @Override
+        public List<MailboxAnnotation> getAnnotationsByKeys(MailboxPath mailboxPath, MailboxSession session, Set<MailboxAnnotationKey> keys) throws MailboxException {
+            return null;
+        }
+
+        @Override
+        public void updateAnnotations(MailboxPath mailboxPath, MailboxSession session, List<MailboxAnnotation> mailboxAnnotations) throws MailboxException {
+            
+        }
+
+        @Override
+        public boolean hasCapability(MailboxCapabilities capability) {
+            return false;
+        }
+
+        @Override
+        public List<MessageId> search(MultimailboxesSearchQuery expression, MailboxSession session, long limit) throws MailboxException {
+            return null;
+        }
+
+        @Override
+        public List<MailboxAnnotation> getAnnotationsByKeysWithOneDepth(MailboxPath mailboxPath, MailboxSession session,
+                Set<MailboxAnnotationKey> keys) throws MailboxException {
+            return null;
+        }
+
+        @Override
+        public List<MailboxAnnotation> getAnnotationsByKeysWithAllDepth(MailboxPath mailboxPath, MailboxSession session,
+                Set<MailboxAnnotationKey> keys) throws MailboxException {
+            return null;
+        }
+
+        @Override
+        public boolean hasChildren(MailboxPath mailboxPath, MailboxSession session) throws MailboxException {
+            return false;
+        }
+    }
+}
+


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


[7/7] james-project git commit: Merge remote-tracking branch 'mine/JAMES-1925'

Posted by ad...@apache.org.
Merge remote-tracking branch 'mine/JAMES-1925'


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

Branch: refs/heads/master
Commit: a4d8c8e00f87e315050ec666e1b8767a6e773f60
Parents: ff3c951 0e104c2
Author: Antoine Duprat <ad...@linagora.com>
Authored: Thu Feb 9 14:00:52 2017 +0100
Committer: Antoine Duprat <ad...@linagora.com>
Committed: Thu Feb 9 14:00:52 2017 +0100

----------------------------------------------------------------------
 .../backends/es/ElasticSearchIndexerTest.java   |   1 -
 .../modules/CassandraMailboxRecentsModule.java  |   1 -
 .../elasticsearch/MailboxMappingFactory.java    |   1 -
 .../elasticsearch/query/SortConverter.java      |   1 -
 .../store/AbstractCombinationManagerTest.java   |   1 -
 mpt/impl/imap-mailbox/elasticsearch/pom.xml     |   7 -
 mpt/pom.xml                                     |   6 +-
 .../org/apache/james/utils/JmapGuiceProbe.java  |   5 +
 .../james/jmap/VacationIntegrationTest.java     |  16 +-
 .../integration/GetMailboxesMethodTest.java     |  94 ++++---
 .../integration/GetMessageListMethodTest.java   |  23 +-
 .../integration/SetMailboxesMethodTest.java     | 233 ++++++++--------
 .../integration/SetMessagesMethodTest.java      | 165 +++++------
 .../cucumber/GetMessagesMethodStepdefs.java     |   3 +-
 .../test/resources/cucumber/DownloadGet.feature |  10 +-
 .../resources/cucumber/DownloadPost.feature     |   4 +-
 .../test/resources/cucumber/GetMessages.feature |  44 +--
 .../protocols/jmap-integration-testing/pom.xml  |   1 -
 .../org/apache/james/jmap/DefaultMailboxes.java |  36 +++
 .../DefaultMailboxesProvisioningFilter.java     | 106 ++++++++
 .../james/jmap/FirstUserConnectionFilter.java   | 127 ---------
 .../java/org/apache/james/jmap/JMAPServer.java  |   5 +-
 .../james/jmap/UserProvisioningFilter.java      |  97 +++++++
 .../methods/SetMessagesUpdateProcessor.java     |   6 +-
 ...ltMailboxesProvisioningFilterThreadTest.java | 268 ++++++++++++++++++
 .../jmap/FirstUserConnectionFilterTest.java     |  59 ----
 .../FirstUserConnectionFilterThreadTest.java    | 271 -------------------
 .../james/jmap/UserProvisioningFilterTest.java  |  57 ++++
 .../jmap/UserProvisioningFilterThreadTest.java  |  66 +++++
 .../methods/SetMessagesUpdateProcessorTest.java |   4 +-
 30 files changed, 922 insertions(+), 796 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/a4d8c8e0/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/GetMessages.feature
----------------------------------------------------------------------


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


[2/7] james-project git commit: JAMES-1925 Fix Eclipse warnings

Posted by ad...@apache.org.
JAMES-1925 Fix Eclipse warnings


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

Branch: refs/heads/master
Commit: 447333577dae5c79cbabd422198a5546c208daef
Parents: 11b9eee
Author: Antoine Duprat <ad...@linagora.com>
Authored: Tue Feb 7 10:29:14 2017 +0100
Committer: Antoine Duprat <ad...@linagora.com>
Committed: Thu Feb 9 09:44:21 2017 +0100

----------------------------------------------------------------------
 .../apache/james/backends/es/ElasticSearchIndexerTest.java    | 1 -
 .../cassandra/modules/CassandraMailboxRecentsModule.java      | 1 -
 .../james/mailbox/elasticsearch/MailboxMappingFactory.java    | 1 -
 .../james/mailbox/elasticsearch/query/SortConverter.java      | 1 -
 .../james/mailbox/store/AbstractCombinationManagerTest.java   | 1 -
 mpt/impl/imap-mailbox/elasticsearch/pom.xml                   | 7 -------
 mpt/pom.xml                                                   | 6 +++++-
 .../apache/james/jmap/methods/SetMessagesUpdateProcessor.java | 6 +-----
 .../james/jmap/methods/SetMessagesUpdateProcessorTest.java    | 4 ++--
 9 files changed, 8 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/44733357/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/ElasticSearchIndexerTest.java
----------------------------------------------------------------------
diff --git a/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/ElasticSearchIndexerTest.java b/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/ElasticSearchIndexerTest.java
index 60ce997..ec9582e 100644
--- a/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/ElasticSearchIndexerTest.java
+++ b/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/ElasticSearchIndexerTest.java
@@ -42,7 +42,6 @@ import com.google.common.collect.Lists;
 public class ElasticSearchIndexerTest {
 
     private static final int MINIMUM_BATCH_SIZE = 1;
-    private static final String CONTENT = "content";
     private static final IndexName INDEX_NAME = new IndexName("index_name");
     private static final TypeName TYPE_NAME = new TypeName("type_name");
     private TemporaryFolder temporaryFolder = new TemporaryFolder();

http://git-wip-us.apache.org/repos/asf/james-project/blob/44733357/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/modules/CassandraMailboxRecentsModule.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/modules/CassandraMailboxRecentsModule.java b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/modules/CassandraMailboxRecentsModule.java
index 6cccbd8..14f00c7 100644
--- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/modules/CassandraMailboxRecentsModule.java
+++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/modules/CassandraMailboxRecentsModule.java
@@ -20,7 +20,6 @@
 package org.apache.james.mailbox.cassandra.modules;
 
 import static com.datastax.driver.core.DataType.bigint;
-import static com.datastax.driver.core.DataType.list;
 import static com.datastax.driver.core.DataType.timeuuid;
 
 import java.util.Collections;

http://git-wip-us.apache.org/repos/asf/james-project/blob/44733357/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/MailboxMappingFactory.java
----------------------------------------------------------------------
diff --git a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/MailboxMappingFactory.java b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/MailboxMappingFactory.java
index ad2d16b..aaa0009 100644
--- a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/MailboxMappingFactory.java
+++ b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/MailboxMappingFactory.java
@@ -23,7 +23,6 @@ import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
 
 import java.io.IOException;
 
-import org.apache.james.backends.es.ElasticSearchIndexer;
 import org.apache.james.backends.es.IndexCreationFactory;
 import org.apache.james.backends.es.NodeMappingFactory;
 import org.apache.james.mailbox.elasticsearch.json.JsonMessageConstants;

http://git-wip-us.apache.org/repos/asf/james-project/blob/44733357/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/query/SortConverter.java
----------------------------------------------------------------------
diff --git a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/query/SortConverter.java b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/query/SortConverter.java
index bb11268..6daa1a8 100644
--- a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/query/SortConverter.java
+++ b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/query/SortConverter.java
@@ -20,7 +20,6 @@
 package org.apache.james.mailbox.elasticsearch.query;
 
 import org.apache.james.backends.es.NodeMappingFactory;
-import org.apache.james.mailbox.elasticsearch.MailboxMappingFactory;
 import org.apache.james.mailbox.elasticsearch.json.JsonMessageConstants;
 import org.apache.james.mailbox.model.SearchQuery;
 import org.elasticsearch.search.sort.FieldSortBuilder;

http://git-wip-us.apache.org/repos/asf/james-project/blob/44733357/mailbox/store/src/test/java/org/apache/james/mailbox/store/AbstractCombinationManagerTest.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/AbstractCombinationManagerTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/AbstractCombinationManagerTest.java
index a646bc4..2bfa4dd 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/AbstractCombinationManagerTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/AbstractCombinationManagerTest.java
@@ -92,7 +92,6 @@ public abstract class AbstractCombinationManagerTest {
     }
 
     @Test
-    @SuppressWarnings("deprecation")
     public void getMessageCountFromMessageManagerShouldReturnDataSetInMailboxesFromMessageIdManager() throws Exception {
         MessageId messageId = messageManager1.appendMessage(new ByteArrayInputStream(MAIL_CONTENT), new Date(), session, false, FLAGS).getMessageId();
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/44733357/mpt/impl/imap-mailbox/elasticsearch/pom.xml
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/elasticsearch/pom.xml b/mpt/impl/imap-mailbox/elasticsearch/pom.xml
index 0a4e36f..611239e 100644
--- a/mpt/impl/imap-mailbox/elasticsearch/pom.xml
+++ b/mpt/impl/imap-mailbox/elasticsearch/pom.xml
@@ -129,22 +129,15 @@
                 <dependency>
                     <groupId>org.apache.james</groupId>
                     <artifactId>apache-james-backends-es</artifactId>
-                    <version>${project.version}</version>
                 </dependency>
                 <dependency>
                     <groupId>org.apache.james</groupId>
                     <artifactId>apache-james-backends-es</artifactId>
-                    <version>${project.version}</version>
                     <type>test-jar</type>
                     <scope>test</scope>
                 </dependency>
                 <dependency>
                     <groupId>org.apache.james</groupId>
-                    <artifactId>apache-james-backends-es</artifactId>
-                    <version>3.0.0-beta6-SNAPSHOT</version>
-                </dependency>
-                <dependency>
-                    <groupId>org.apache.james</groupId>
                     <artifactId>apache-james-mailbox-api</artifactId>
                 </dependency>
                 <dependency>

http://git-wip-us.apache.org/repos/asf/james-project/blob/44733357/mpt/pom.xml
----------------------------------------------------------------------
diff --git a/mpt/pom.xml b/mpt/pom.xml
index aa4edb4..4815d79 100644
--- a/mpt/pom.xml
+++ b/mpt/pom.xml
@@ -170,8 +170,12 @@
             <dependency>
                 <groupId>org.apache.james</groupId>
                 <artifactId>apache-james-backends-es</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>org.apache.james</groupId>
+                <artifactId>apache-james-backends-es</artifactId>
                 <type>test-jar</type>
-                <scope>test</scope>
                 <version>${project.version}</version>
             </dependency>
             <dependency>

http://git-wip-us.apache.org/repos/asf/james-project/blob/44733357/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMessagesUpdateProcessor.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMessagesUpdateProcessor.java b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMessagesUpdateProcessor.java
index faf228c..d72f7c9 100644
--- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMessagesUpdateProcessor.java
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMessagesUpdateProcessor.java
@@ -33,7 +33,6 @@ import org.apache.james.jmap.model.SetError;
 import org.apache.james.jmap.model.SetMessagesRequest;
 import org.apache.james.jmap.model.SetMessagesResponse;
 import org.apache.james.jmap.model.UpdateMessagePatch;
-import org.apache.james.jmap.utils.SystemMailboxesProvider;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.MessageIdManager;
 import org.apache.james.mailbox.MessageManager;
@@ -59,18 +58,15 @@ public class SetMessagesUpdateProcessor implements SetMessagesProcessor {
     private final UpdateMessagePatchConverter updatePatchConverter;
     private final MessageIdManager messageIdManager;
     private final Factory mailboxIdFactory;
-    private final SystemMailboxesProvider systemMailboxesProvider;
 
     @Inject
     @VisibleForTesting SetMessagesUpdateProcessor(
             UpdateMessagePatchConverter updatePatchConverter,
             MessageIdManager messageIdManager,
-            Factory mailboxIdFactory,
-            SystemMailboxesProvider systemMailboxesProvider) {
+            Factory mailboxIdFactory) {
         this.updatePatchConverter = updatePatchConverter;
         this.messageIdManager = messageIdManager;
         this.mailboxIdFactory = mailboxIdFactory;
-        this.systemMailboxesProvider = systemMailboxesProvider;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/james-project/blob/44733357/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/SetMessagesUpdateProcessorTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/SetMessagesUpdateProcessorTest.java b/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/SetMessagesUpdateProcessorTest.java
index 0c7ea1b..e2d2090 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/SetMessagesUpdateProcessorTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/SetMessagesUpdateProcessorTest.java
@@ -41,7 +41,7 @@ public class SetMessagesUpdateProcessorTest {
 
     @Test
     public void processShouldReturnEmptyUpdatedWhenRequestHasEmptyUpdate() {
-        SetMessagesUpdateProcessor sut = new SetMessagesUpdateProcessor(null, null, null, null);
+        SetMessagesUpdateProcessor sut = new SetMessagesUpdateProcessor(null, null, null);
         SetMessagesRequest requestWithEmptyUpdate = SetMessagesRequest.builder().build();
 
         SetMessagesResponse result = sut.process(requestWithEmptyUpdate, null);
@@ -65,7 +65,7 @@ public class SetMessagesUpdateProcessorTest {
         when(mockConverter.fromJsonNode(any(ObjectNode.class)))
                 .thenReturn(mockInvalidPatch);
 
-        SetMessagesUpdateProcessor sut = new SetMessagesUpdateProcessor(mockConverter, null, null, null);
+        SetMessagesUpdateProcessor sut = new SetMessagesUpdateProcessor(mockConverter, null, null);
         MessageId requestMessageId = TestMessageId.of(1);
         SetMessagesRequest requestWithInvalidUpdate = SetMessagesRequest.builder()
                 .update(ImmutableMap.of(requestMessageId, JsonNodeFactory.instance.objectNode()))


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


[6/7] james-project git commit: JAMES-1925 Rely on event to ensure addition to Outbox when sending a message

Posted by ad...@apache.org.
JAMES-1925 Rely on event to ensure addition to Outbox when sending a message

Otherwise test are failing because too fast


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

Branch: refs/heads/master
Commit: 0e104c2c509dfe62aec30876adca6b40398ffa13
Parents: c10cfae
Author: Benoit Tellier <bt...@linagora.com>
Authored: Wed Feb 8 10:02:27 2017 +0700
Committer: Antoine Duprat <ad...@linagora.com>
Committed: Thu Feb 9 09:44:51 2017 +0100

----------------------------------------------------------------------
 .../org/apache/james/utils/JmapGuiceProbe.java  |  5 ++
 .../integration/SetMessagesMethodTest.java      | 49 ++++++++++++++------
 2 files changed, 41 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/0e104c2c/server/container/guice/guice-common/src/main/java/org/apache/james/utils/JmapGuiceProbe.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/utils/JmapGuiceProbe.java b/server/container/guice/guice-common/src/main/java/org/apache/james/utils/JmapGuiceProbe.java
index 05e1646..627d1c6 100644
--- a/server/container/guice/guice-common/src/main/java/org/apache/james/utils/JmapGuiceProbe.java
+++ b/server/container/guice/guice-common/src/main/java/org/apache/james/utils/JmapGuiceProbe.java
@@ -28,6 +28,7 @@ import org.apache.james.jmap.api.vacation.AccountId;
 import org.apache.james.jmap.api.vacation.Vacation;
 import org.apache.james.jmap.api.vacation.VacationPatch;
 import org.apache.james.jmap.api.vacation.VacationRepository;
+import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.MessageIdManager;
@@ -58,6 +59,10 @@ public class JmapGuiceProbe implements GuiceProbe {
         return jmapServer.getPort();
     }
 
+    public void addMailboxListener(MailboxListener listener) throws MailboxException {
+        mailboxManager.addGlobalListener(listener, mailboxManager.createSystemSession("jmap", LOGGER));
+    }
+
     public void modifyVacation(AccountId accountId, VacationPatch vacationPatch) {
         vacationRepository.modifyVacation(accountId, vacationPatch).join();
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/0e104c2c/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java
index 1fd27ad..7b34308 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java
@@ -57,12 +57,14 @@ import org.apache.james.jmap.DefaultMailboxes;
 import org.apache.james.jmap.HttpJmapAuthentication;
 import org.apache.james.jmap.api.access.AccessToken;
 import org.apache.james.jmap.model.mailbox.Role;
+import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.model.Attachment;
 import org.apache.james.mailbox.model.ComposedMessageId;
 import org.apache.james.mailbox.model.MailboxConstants;
 import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.model.MessageId;
+import org.apache.james.mailbox.store.event.EventFactory;
 import org.apache.james.mailbox.store.mail.model.Mailbox;
 import org.apache.james.util.ZeroedInputStream;
 import org.hamcrest.Matcher;
@@ -74,6 +76,7 @@ import org.junit.Test;
 
 import com.google.common.base.Charsets;
 import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Lists;
 import com.google.common.io.ByteStreams;
 import com.jayway.awaitility.Awaitility;
 import com.jayway.awaitility.Duration;
@@ -856,6 +859,7 @@ public abstract class SetMessagesMethodTest {
         String fromAddress = USERNAME;
         String messageSubject = "Thank you for joining example.com!";
         String outboxId = getOutboxId(accessToken);
+
         String requestBody = "[" +
             "  [" +
             "    \"setMessages\","+
@@ -872,6 +876,24 @@ public abstract class SetMessagesMethodTest {
             "  ]" +
             "]";
 
+        List<MailboxListener.Event> events = Lists.newArrayList();
+        jmapServer.getJmapProbe().addMailboxListener(new MailboxListener() {
+            @Override
+            public ListenerType getType() {
+                return ListenerType.ONCE;
+            }
+
+            @Override
+            public ExecutionMode getExecutionMode() {
+                return ExecutionMode.SYNCHRONOUS;
+            }
+
+            @Override
+            public void event(Event event) {
+                events.add(event);
+            }
+        });
+
         String messageId = with()
             .header("Authorization", accessToken.serialize())
             .body(requestBody)
@@ -882,19 +904,20 @@ public abstract class SetMessagesMethodTest {
             .body()
             .<String>path(ARGUMENTS + ".created."+ messageCreationId +".id");
 
-        // Then
-        given()
-            .header("Authorization", accessToken.serialize())
-            .body("[[\"getMessages\", {\"ids\": [\"" + messageId + "\"]}, \"#0\"]]")
-        .when()
-            .post("/jmap")
-        .then()
-            .log().ifValidationFails()
-            .body(NAME, equalTo("messages"))
-            .body(ARGUMENTS + ".list", hasSize(1))
-            .body(ARGUMENTS + ".list[0].subject", equalTo(messageSubject))
-            .body(ARGUMENTS + ".list[0].mailboxIds", contains(outboxId))
-            ;
+
+
+        calmlyAwait.atMost(5, TimeUnit.SECONDS).until(() -> events.stream()
+            .anyMatch(event -> isAddedToOutboxEvent(messageId, event)));
+    }
+
+    private boolean isAddedToOutboxEvent(String messageId, MailboxListener.Event event) {
+        if (!(event instanceof EventFactory.AddedImpl)) {
+            return false;
+        }
+        EventFactory.AddedImpl added = (EventFactory.AddedImpl) event;
+        return added.getMailboxPath().equals(new MailboxPath(MailboxConstants.USER_NAMESPACE, USERNAME, DefaultMailboxes.OUTBOX))
+            && added.getUids().size() == 1
+            && added.getMetaData(added.getUids().get(0)).getMessageId().serialize().equals(messageId);
     }
 
     @Test


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


[5/7] james-project git commit: JAMES-1925 Split user provisioning and mailboxes provisioning filters

Posted by ad...@apache.org.
JAMES-1925 Split user provisioning and mailboxes provisioning filters


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

Branch: refs/heads/master
Commit: 844efe2a5a731299caf207f254916c7a26d23816
Parents: dea8f2e
Author: Antoine Duprat <ad...@linagora.com>
Authored: Tue Feb 7 11:20:31 2017 +0100
Committer: Antoine Duprat <ad...@linagora.com>
Committed: Thu Feb 9 09:44:50 2017 +0100

----------------------------------------------------------------------
 .../james/jmap/VacationIntegrationTest.java     |  16 +-
 .../integration/GetMailboxesMethodTest.java     |  94 ++++---
 .../integration/GetMessageListMethodTest.java   |  23 +-
 .../integration/SetMailboxesMethodTest.java     | 233 ++++++++--------
 .../integration/SetMessagesMethodTest.java      | 116 +++-----
 .../cucumber/GetMessagesMethodStepdefs.java     |   3 +-
 .../test/resources/cucumber/DownloadGet.feature |  10 +-
 .../resources/cucumber/DownloadPost.feature     |   4 +-
 .../test/resources/cucumber/GetMessages.feature |  44 +--
 .../org/apache/james/jmap/DefaultMailboxes.java |  36 +++
 .../DefaultMailboxesProvisioningFilter.java     | 106 ++++++++
 .../java/org/apache/james/jmap/JMAPServer.java  |   3 +-
 .../james/jmap/UserProvisioningFilter.java      |  32 +--
 ...ltMailboxesProvisioningFilterThreadTest.java | 268 +++++++++++++++++++
 .../james/jmap/UserProvisioningFilterTest.java  |   4 +-
 .../jmap/UserProvisioningFilterThreadTest.java  | 207 +-------------
 16 files changed, 655 insertions(+), 544 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/844efe2a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/VacationIntegrationTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/VacationIntegrationTest.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/VacationIntegrationTest.java
index 0ad710d..d3221f0 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/VacationIntegrationTest.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/VacationIntegrationTest.java
@@ -79,11 +79,11 @@ public abstract class VacationIntegrationTest {
         guiceJamesServer.serverProbe().addDomain(DOMAIN);
         guiceJamesServer.serverProbe().addUser(USER_1, PASSWORD);
         guiceJamesServer.serverProbe().addUser(USER_2, PASSWORD);
-        guiceJamesServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USER_2, "outbox");
-        guiceJamesServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USER_1, "sent");
-        guiceJamesServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USER_2, "sent");
-        guiceJamesServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USER_1, "INBOX");
-        guiceJamesServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USER_2, "INBOX");
+        guiceJamesServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USER_2, DefaultMailboxes.OUTBOX);
+        guiceJamesServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USER_1, DefaultMailboxes.SENT);
+        guiceJamesServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USER_2, DefaultMailboxes.SENT);
+        guiceJamesServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USER_1, DefaultMailboxes.INBOX);
+        guiceJamesServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USER_2, DefaultMailboxes.INBOX);
         await();
 
         jmapGuiceProbe = guiceJamesServer.getJmapProbe();
@@ -436,16 +436,16 @@ public abstract class VacationIntegrationTest {
     }
 
     private String getOutboxId(AccessToken accessToken) {
-        return getMailboxIdByRole(accessToken, "outbox");
+        return getMailboxIdByRole(accessToken, DefaultMailboxes.OUTBOX);
     }
 
     private String getInboxId(AccessToken accessToken) {
-        return getMailboxIdByRole(accessToken, "inbox");
+        return getMailboxIdByRole(accessToken, DefaultMailboxes.INBOX);
     }
 
     private String getMailboxIdByRole(AccessToken accessToken, String role) {
         return getAllMailboxesIds(accessToken).stream()
-            .filter(x -> x.get("role").equals(role))
+            .filter(x -> x.get("role").equalsIgnoreCase(role))
             .map(x -> x.get("id"))
             .findFirst()
             .get();

http://git-wip-us.apache.org/repos/asf/james-project/blob/844efe2a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMailboxesMethodTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMailboxesMethodTest.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMailboxesMethodTest.java
index e75167d..49caa3e 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMailboxesMethodTest.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMailboxesMethodTest.java
@@ -24,6 +24,7 @@ import static com.jayway.restassured.config.EncoderConfig.encoderConfig;
 import static com.jayway.restassured.config.RestAssuredConfig.newConfig;
 import static org.hamcrest.Matchers.empty;
 import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.hasItem;
 import static org.hamcrest.Matchers.hasItems;
 import static org.hamcrest.Matchers.hasSize;
 import static org.hamcrest.Matchers.isEmptyOrNullString;
@@ -32,14 +33,18 @@ import static org.hamcrest.Matchers.nullValue;
 
 import java.io.ByteArrayInputStream;
 import java.util.Date;
+import java.util.List;
+import java.util.Locale;
 
 import javax.mail.Flags;
 
 import org.apache.http.client.utils.URIBuilder;
 import org.apache.james.JmapJamesServer;
+import org.apache.james.jmap.DefaultMailboxes;
 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.mailbox.model.MailboxId;
 import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.store.mail.model.Mailbox;
 import org.junit.After;
@@ -47,6 +52,7 @@ import org.junit.Before;
 import org.junit.Test;
 
 import com.google.common.base.Charsets;
+import com.google.common.collect.ImmutableList;
 import com.jayway.restassured.RestAssured;
 import com.jayway.restassured.builder.RequestSpecBuilder;
 import com.jayway.restassured.http.ContentType;
@@ -142,10 +148,10 @@ public abstract class GetMailboxesMethodTest {
 
     @Test
     public void getMailboxesShouldReturnMailboxesWhenIdsMatch() throws Exception {
-        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "INBOX");
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, DefaultMailboxes.INBOX);
         jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myMailbox");
 
-        Mailbox mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "INBOX");
+        Mailbox mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, DefaultMailboxes.INBOX);
         Mailbox mailbox2 = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "myMailbox");
 
         String mailboxId = mailbox.getMailboxId().serialize();
@@ -166,10 +172,10 @@ public abstract class GetMailboxesMethodTest {
 
     @Test
     public void getMailboxesShouldReturnOnlyMatchingMailboxesWhenIdsGiven() throws Exception {
-        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "INBOX");
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, DefaultMailboxes.INBOX);
         jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myMailbox");
 
-        Mailbox mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "INBOX");
+        Mailbox mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, DefaultMailboxes.INBOX);
 
         String mailboxId = mailbox.getMailboxId().serialize();
 
@@ -187,7 +193,7 @@ public abstract class GetMailboxesMethodTest {
 
     @Test
     public void getMailboxesShouldReturnEmptyWhenIdsIsEmpty() throws Exception {
-        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "INBOX");
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, DefaultMailboxes.INBOX);
 
         given()
             .header("Authorization", accessToken.serialize())
@@ -202,15 +208,14 @@ public abstract class GetMailboxesMethodTest {
 
     @Test
     public void getMailboxesShouldReturnAllMailboxesWhenIdsIsNull() throws Exception {
-        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "INBOX");
         jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myMailbox");
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myMailbox2");
 
-        Mailbox mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "INBOX");
-        Mailbox mailbox2 = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "myMailbox");
-
-        String mailboxId = mailbox.getMailboxId().serialize();
-        String mailboxId2 = mailbox2.getMailboxId().serialize();
-
+        List<String> expectedMailboxes = ImmutableList.<String> builder()
+                .addAll(DefaultMailboxes.DEFAULT_MAILBOXES)
+                .add("myMailbox")
+                .add("myMailbox2")
+                .build();
         given()
             .header("Authorization", accessToken.serialize())
             .body("[[\"getMailboxes\", {\"ids\": null}, \"#0\"]]")
@@ -219,9 +224,8 @@ public abstract class GetMailboxesMethodTest {
         .then()
             .statusCode(200)
             .body(NAME, equalTo("mailboxes"))
-            .body(ARGUMENTS + ".list", hasSize(2))
-            .body(ARGUMENTS + ".list[0].id", equalTo(mailboxId))
-            .body(ARGUMENTS + ".list[1].id", equalTo(mailboxId2));
+            .body(ARGUMENTS + ".list", hasSize(7))
+            .body(ARGUMENTS + ".list.name", hasItems(expectedMailboxes.toArray()));
     }
     
     @Test
@@ -240,19 +244,6 @@ public abstract class GetMailboxesMethodTest {
     }
 
     @Test
-    public void getMailboxesShouldReturnEmptyListWhenNoMailboxes() throws Exception {
-        given()
-            .header("Authorization", accessToken.serialize())
-            .body("[[\"getMailboxes\", {}, \"#0\"]]")
-        .when()
-            .post("/jmap")
-        .then()
-            .statusCode(200)
-            .body(NAME, equalTo("mailboxes"))
-            .body(ARGUMENTS + ".list", empty());
-    }
-
-    @Test
     public void getMailboxesShouldReturnDefaultMailboxesWhenAuthenticatedUserDoesntHaveAnAccountYet() throws Exception {
 
         String token = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMzM3QGRvbWFpbi50bGQiLCJuYW1lIjoiTmV3IFVzZXIif"
@@ -269,8 +260,8 @@ public abstract class GetMailboxesMethodTest {
         .then()
             .statusCode(200)
             .body(NAME, equalTo("mailboxes"))
-            .body(ARGUMENTS + ".list", hasSize(4))
-            .body(ARGUMENTS + ".list.name", hasItems("INBOX", "Outbox", "Sent", "Trash"));
+            .body(ARGUMENTS + ".list", hasSize(5))
+            .body(ARGUMENTS + ".list.name", hasItems(DefaultMailboxes.DEFAULT_MAILBOXES.toArray()));
     }
 
     @Test
@@ -306,7 +297,26 @@ public abstract class GetMailboxesMethodTest {
         .then()
             .statusCode(200)
             .body(NAME, equalTo("mailboxes"))
-            .body(ARGUMENTS + ".list[0].name", equalTo("name"))
+            .body(ARGUMENTS + ".list.name", hasItem("name"));
+    }
+
+    @Test
+    public void getMailboxesShouldReturnMailboxPropertiesWhenAvailable() throws Exception {
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "name");
+
+        jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "name"),
+                new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags());
+
+        MailboxId mailboxId = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "name").getMailboxId();
+        given()
+            .header("Authorization", accessToken.serialize())
+            .body("[[\"getMailboxes\", {\"ids\": [\"" + mailboxId.serialize() + "\"]}, \"#0\"]]")
+        .when()
+            .post("/jmap")
+        .then()
+            .statusCode(200)
+            .body(NAME, equalTo("mailboxes"))
+            .body(ARGUMENTS + ".list.name", hasItem("name"))
             .body(ARGUMENTS + ".list[0].parentId", nullValue())
             .body(ARGUMENTS + ".list[0].role", nullValue())
             .body(ARGUMENTS + ".list[0].sortOrder", equalTo(1000))
@@ -326,9 +336,10 @@ public abstract class GetMailboxesMethodTest {
     public void getMailboxesShouldReturnFilteredMailboxesPropertiesWhenRequestContainsFilterProperties() throws Exception {
         jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "name");
 
+        MailboxId mailboxId = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "name").getMailboxId();
         given()
             .header("Authorization", accessToken.serialize())
-            .body("[[\"getMailboxes\", {\"properties\" : [\"unreadMessages\", \"sortOrder\"]}, \"#0\"]]")
+            .body("[[\"getMailboxes\", {\"ids\": [\"" + mailboxId.serialize() + "\"], \"properties\" : [\"unreadMessages\", \"sortOrder\"]}, \"#0\"]]")
         .when()
             .post("/jmap")
         .then()
@@ -385,38 +396,41 @@ public abstract class GetMailboxesMethodTest {
 
     @Test
     public void getMailboxesShouldReturnMailboxesWithSortOrder() throws Exception {
-        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "inbox");
-        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "trash");
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, DefaultMailboxes.INBOX);
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, DefaultMailboxes.TRASH);
 
+        MailboxId inboxId = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, DefaultMailboxes.INBOX).getMailboxId();
+        MailboxId trashId = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, DefaultMailboxes.TRASH).getMailboxId();
         given()
             .header("Authorization", accessToken.serialize())
-            .body("[[\"getMailboxes\", {}, \"#0\"]]")
+            .body("[[\"getMailboxes\", {\"ids\": [\"" + inboxId.serialize() + "\", \"" + trashId.serialize() + "\"]}, \"#0\"]]")
         .when()
             .post("/jmap")
         .then()
             .statusCode(200)
             .body(NAME, equalTo("mailboxes"))
             .body(ARGUMENTS + ".list", hasSize(2))
-            .body(ARGUMENTS + ".list[0].name", equalTo("inbox"))
+            .body(ARGUMENTS + ".list[0].name", equalTo(DefaultMailboxes.INBOX))
             .body(ARGUMENTS + ".list[0].sortOrder", equalTo(10))
-            .body(ARGUMENTS + ".list[1].name", equalTo("trash"))
+            .body(ARGUMENTS + ".list[1].name", equalTo(DefaultMailboxes.TRASH))
             .body(ARGUMENTS + ".list[1].sortOrder", equalTo(60));
     }
 
     @Test
     public void getMailboxesShouldReturnMailboxesWithRolesInLowerCase() throws Exception {
-        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "outbox");
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, DefaultMailboxes.OUTBOX);
 
+        MailboxId mailboxId = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, DefaultMailboxes.OUTBOX).getMailboxId();
         given()
             .header("Authorization", accessToken.serialize())
-            .body("[[\"getMailboxes\", {}, \"#0\"]]")
+            .body("[[\"getMailboxes\", {\"ids\": [\"" + mailboxId.serialize() + "\"]}, \"#0\"]]")
         .when()
             .post("/jmap")
         .then()
             .statusCode(200)
             .body(NAME, equalTo("mailboxes"))
             .body(ARGUMENTS + ".list", hasSize(1))
-            .body(ARGUMENTS + ".list[0].role", equalTo("outbox"));
+            .body(ARGUMENTS + ".list[0].role", equalTo(DefaultMailboxes.OUTBOX.toLowerCase(Locale.US)));
     }
 
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/844efe2a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMessageListMethodTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMessageListMethodTest.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMessageListMethodTest.java
index ff7d30a..be275d9 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMessageListMethodTest.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMessageListMethodTest.java
@@ -20,7 +20,6 @@
 package org.apache.james.jmap.methods.integration;
 
 import static com.jayway.restassured.RestAssured.given;
-import static com.jayway.restassured.RestAssured.with;
 import static com.jayway.restassured.config.EncoderConfig.encoderConfig;
 import static com.jayway.restassured.config.RestAssuredConfig.newConfig;
 import static org.hamcrest.Matchers.contains;
@@ -33,7 +32,6 @@ import java.io.ByteArrayInputStream;
 import java.time.LocalDate;
 import java.time.ZoneId;
 import java.util.Date;
-import java.util.List;
 
 import javax.mail.Flags;
 
@@ -221,16 +219,11 @@ public abstract class GetMessageListMethodTest {
                 new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags());
         await();
 
-        String mailboxId = 
-                with()
-                .header("Authorization", accessToken.serialize())
-                .body("[[\"getMailboxes\", {}, \"#0\"]]")
-                .post("/jmap")
-                .path("[0][1].list[0].id");
+        MailboxId mailboxId = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox").getMailboxId();
         
         given()
             .header("Authorization", accessToken.serialize())
-            .body("[[\"getMessageList\", {\"filter\":{\"inMailboxes\":[\"" + mailboxId + "\"]}}, \"#0\"]]")
+            .body("[[\"getMessageList\", {\"filter\":{\"inMailboxes\":[\"" + mailboxId.serialize() + "\"]}}, \"#0\"]]")
         .when()
             .post("/jmap")
         .then()
@@ -248,16 +241,12 @@ public abstract class GetMessageListMethodTest {
         jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox2");
         await();
 
-        List<String> mailboxIds = 
-                with()
-                .header("Authorization", accessToken.serialize())
-                .body("[[\"getMailboxes\", {}, \"#0\"]]")
-                .post("/jmap")
-                .path("[0][1].list.id");
-        
+        MailboxId mailboxId = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox").getMailboxId();
+        MailboxId mailboxId2 = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox2").getMailboxId();
+
         given()
             .header("Authorization", accessToken.serialize())
-            .body(String.format("[[\"getMessageList\", {\"filter\":{\"inMailboxes\":[\"%s\", \"%s\"]}}, \"#0\"]]", mailboxIds.get(0), mailboxIds.get(1)))
+            .body(String.format("[[\"getMessageList\", {\"filter\":{\"inMailboxes\":[\"%s\", \"%s\"]}}, \"#0\"]]", mailboxId.serialize(), mailboxId2.serialize()))
         .when()
             .post("/jmap")
         .then()

http://git-wip-us.apache.org/repos/asf/james-project/blob/844efe2a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMailboxesMethodTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMailboxesMethodTest.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMailboxesMethodTest.java
index 1e67427..3a310f0 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMailboxesMethodTest.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMailboxesMethodTest.java
@@ -29,7 +29,7 @@ import static org.hamcrest.Matchers.containsInAnyOrder;
 import static org.hamcrest.Matchers.containsString;
 import static org.hamcrest.Matchers.equalTo;
 import static org.hamcrest.Matchers.hasEntry;
-import static org.hamcrest.Matchers.hasItems;
+import static org.hamcrest.Matchers.hasItem;
 import static org.hamcrest.Matchers.hasKey;
 import static org.hamcrest.Matchers.hasSize;
 import static org.hamcrest.Matchers.isEmptyOrNullString;
@@ -40,6 +40,7 @@ import static org.hamcrest.collection.IsMapWithSize.aMapWithSize;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.http.client.utils.URIBuilder;
 import org.apache.james.JmapJamesServer;
+import org.apache.james.jmap.DefaultMailboxes;
 import org.apache.james.jmap.HttpJmapAuthentication;
 import org.apache.james.jmap.api.access.AccessToken;
 import org.apache.james.mailbox.model.MailboxConstants;
@@ -88,7 +89,7 @@ public abstract class SetMailboxesMethodTest {
         String password = "password";
         jmapServer.serverProbe().addDomain(USERS_DOMAIN);
         jmapServer.serverProbe().addUser(username, password);
-        jmapServer.serverProbe().createMailbox("#private", username, "inbox");
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, MailboxConstants.INBOX);
         accessToken = HttpJmapAuthentication.authenticateJamesUser(baseUri(), username, password);
 
         await();
@@ -143,8 +144,8 @@ public abstract class SetMailboxesMethodTest {
     @Test
     public void setMailboxesShouldNotUpdateMailboxWhenOverLimitName() {
         String overLimitName = StringUtils.repeat("a", MAILBOX_NAME_LENGTH_64K);
-        jmapServer.serverProbe().createMailbox("#private", username, "myBox");
-        Mailbox mailbox = jmapServer.serverProbe().getMailbox("#private", username, "myBox");
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox");
+        Mailbox mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox");
         String mailboxId = mailbox.getMailboxId().serialize();
         String requestBody =
             "[" +
@@ -205,8 +206,8 @@ public abstract class SetMailboxesMethodTest {
     @Test
     public void setMailboxesShouldUpdateMailboxWhenOverLimitName() throws Exception {
         String overLimitName = StringUtils.repeat("a", MAILBOX_NAME_LENGTH_64K);
-        jmapServer.serverProbe().createMailbox("#private", username, "myBox");
-        Mailbox mailbox = jmapServer.serverProbe().getMailbox("#private", username, "myBox");
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox");
+        Mailbox mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox");
         String mailboxId = mailbox.getMailboxId().serialize();
         String requestBody =
             "[" +
@@ -265,16 +266,7 @@ public abstract class SetMailboxesMethodTest {
 
     @Test
     public void userShouldBeSubscribedOnCreatedMailboxWhenCreateChildOfInboxMailbox() throws Exception {
-        String inboxId =
-            with()
-                .header("Authorization", this.accessToken.serialize())
-                .body("[[\"getMailboxes\", {}, \"#0\"]]")
-            .when()
-                .post("/jmap")
-            .then()
-                .extract()
-                .jsonPath()
-                .getString(ARGUMENTS + ".list[0].id");
+        MailboxId inboxId = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, MailboxConstants.INBOX).getMailboxId();
 
         String requestBody =
             "[" +
@@ -283,7 +275,7 @@ public abstract class SetMailboxesMethodTest {
                 "      \"create\": {" +
                 "        \"create-id01\" : {" +
                 "          \"name\" : \"foo\"," +
-                "          \"parentId\" : \"" + inboxId + "\"" +
+                "          \"parentId\" : \"" + inboxId.serialize() + "\"" +
                 "        }" +
                 "      }" +
                 "    }," +
@@ -297,15 +289,15 @@ public abstract class SetMailboxesMethodTest {
         .when()
             .post("/jmap");
 
-        assertThat(jmapServer.serverProbe().listSubscriptions(username)).containsOnly("inbox.foo");
+        assertThat(jmapServer.serverProbe().listSubscriptions(username)).containsOnly(DefaultMailboxes.INBOX + ".foo");
     }
 
     @Test
     public void subscriptionUserShouldBeChangedWhenUpdateMailbox() throws Exception {
-        jmapServer.serverProbe().createMailbox("#private", username, "root");
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "root");
 
-        jmapServer.serverProbe().createMailbox("#private", username, "root.myBox");
-        Mailbox mailbox = jmapServer.serverProbe().getMailbox("#private", username, "root.myBox");
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "root.myBox");
+        Mailbox mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "root.myBox");
         String mailboxId = mailbox.getMailboxId().serialize();
 
         String requestBody =
@@ -355,7 +347,7 @@ public abstract class SetMailboxesMethodTest {
             .body(NAME, equalTo("mailboxesSet"))
             .body(ARGUMENTS + ".created", hasKey("create-id01"));
 
-        Mailbox mailbox = jmapServer.serverProbe().getMailbox("#private", username, "foo");
+        Mailbox mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "foo");
         String mailboxId = mailbox.getMailboxId().serialize();
 
         requestBody =
@@ -382,8 +374,8 @@ public abstract class SetMailboxesMethodTest {
 
     @Test
     public void subscriptionUserShouldBeDeletedWhenDestroyMailbox() throws Exception {
-        jmapServer.serverProbe().createMailbox("#private", username, "myBox");
-        Mailbox mailbox = jmapServer.serverProbe().getMailbox("#private", username, "myBox");
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox");
+        Mailbox mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox");
         String requestBody =
             "[" +
                 "  [ \"setMailboxes\"," +
@@ -431,7 +423,7 @@ public abstract class SetMailboxesMethodTest {
             .body(NAME, equalTo("mailboxesSet"))
             .body(ARGUMENTS + ".created", hasKey("create-id01"));
 
-        Mailbox mailbox = jmapServer.serverProbe().getMailbox("#private", username, "foo");
+        Mailbox mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "foo");
 
         requestBody =
             "[" +
@@ -567,8 +559,7 @@ public abstract class SetMailboxesMethodTest {
         .then()
             .statusCode(200)
             .body(NAME, equalTo("mailboxes"))
-            .body(ARGUMENTS + ".list", hasSize(2))
-            .body(ARGUMENTS + ".list.name", hasItems("foo"));
+            .body(ARGUMENTS + ".list.name", hasItem("foo"));
     }
 
     @Test
@@ -615,16 +606,7 @@ public abstract class SetMailboxesMethodTest {
 
     @Test
     public void setMailboxesShouldCreateMailboxWhenChildOfInboxMailbox() {
-        String inboxId =
-            with()
-                .header("Authorization", this.accessToken.serialize())
-                .body("[[\"getMailboxes\", {}, \"#0\"]]")
-            .when()
-                .post("/jmap")
-            .then()
-                .extract()
-                .jsonPath()
-                .getString(ARGUMENTS + ".list[0].id");
+        MailboxId inboxId = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, MailboxConstants.INBOX).getMailboxId();
 
         String requestBody =
             "[" +
@@ -633,7 +615,7 @@ public abstract class SetMailboxesMethodTest {
                 "      \"create\": {" +
                 "        \"create-id01\" : {" +
                 "          \"name\" : \"foo\"," +
-                "          \"parentId\" : \"" + inboxId + "\"" +
+                "          \"parentId\" : \"" + inboxId.serialize() + "\"" +
                 "        }" +
                 "      }" +
                 "    }," +
@@ -655,8 +637,7 @@ public abstract class SetMailboxesMethodTest {
         .then()
             .statusCode(200)
             .body(NAME, equalTo("mailboxes"))
-            .body(ARGUMENTS + ".list", hasSize(2))
-            .body(ARGUMENTS + ".list.name", hasItems("foo"));
+            .body(ARGUMENTS + ".list.name", hasItem("foo"));
     }
 
     @Test
@@ -766,7 +747,7 @@ public abstract class SetMailboxesMethodTest {
 
     @Test
     public void setMailboxesShouldReturnNotCreatedWhenMailboxAlreadyExists() {
-        jmapServer.serverProbe().createMailbox("#private", username, "myBox");
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox");
         String requestBody =
             "[" +
                 "  [ \"setMailboxes\"," +
@@ -868,8 +849,8 @@ public abstract class SetMailboxesMethodTest {
 
     @Test
     public void setMailboxesShouldReturnDestroyedMailbox() {
-        jmapServer.serverProbe().createMailbox("#private", username, "myBox");
-        Mailbox mailbox = jmapServer.serverProbe().getMailbox("#private", username, "myBox");
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox");
+        Mailbox mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox");
         String mailboxId = mailbox.getMailboxId().serialize();
         String requestBody =
             "[" +
@@ -894,8 +875,8 @@ public abstract class SetMailboxesMethodTest {
 
     @Test
     public void setMailboxesShouldDestroyMailbox() {
-        jmapServer.serverProbe().createMailbox("#private", username, "myBox");
-        Mailbox mailbox = jmapServer.serverProbe().getMailbox("#private", username, "myBox");
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox");
+        Mailbox mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox");
         String requestBody =
             "[" +
                 "  [ \"setMailboxes\"," +
@@ -922,7 +903,7 @@ public abstract class SetMailboxesMethodTest {
         .then()
             .statusCode(200)
             .body(NAME, equalTo("mailboxes"))
-            .body(ARGUMENTS + ".list", hasSize(1));
+            .body(ARGUMENTS + ".list.name", not(hasItem("myBox")));
     }
 
     @Test
@@ -954,9 +935,9 @@ public abstract class SetMailboxesMethodTest {
 
     @Test
     public void setMailboxesShouldReturnNotDestroyedWhenMailboxHasChild() {
-        jmapServer.serverProbe().createMailbox("#private", username, "myBox");
-        jmapServer.serverProbe().createMailbox("#private", username, "myBox.child");
-        Mailbox mailbox = jmapServer.serverProbe().getMailbox("#private", username, "myBox");
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox");
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox.child");
+        Mailbox mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox");
         String mailboxId = mailbox.getMailboxId().serialize();
         String requestBody =
             "[" +
@@ -984,7 +965,7 @@ public abstract class SetMailboxesMethodTest {
 
     @Test
     public void setMailboxesShouldReturnNotDestroyedWhenSystemMailbox() {
-        Mailbox mailbox = jmapServer.serverProbe().getMailbox("#private", username, "inbox");
+        Mailbox mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, MailboxConstants.INBOX);
         String mailboxId = mailbox.getMailboxId().serialize();
         String requestBody =
             "[" +
@@ -1012,11 +993,11 @@ public abstract class SetMailboxesMethodTest {
 
     @Test
     public void setMailboxesShouldReturnDestroyedWhenParentThenChildMailboxes() {
-        jmapServer.serverProbe().createMailbox("#private", username, "parent");
-        Mailbox parentMailbox = jmapServer.serverProbe().getMailbox("#private", username, "parent");
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "parent");
+        Mailbox parentMailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "parent");
         String parentMailboxId = parentMailbox.getMailboxId().serialize();
-        jmapServer.serverProbe().createMailbox("#private", username, "parent.child");
-        Mailbox childMailbox = jmapServer.serverProbe().getMailbox("#private", username, "parent.child");
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "parent.child");
+        Mailbox childMailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "parent.child");
         String childMailboxId = childMailbox.getMailboxId().serialize();
         String requestBody =
             "[" +
@@ -1041,11 +1022,11 @@ public abstract class SetMailboxesMethodTest {
 
     @Test
     public void setMailboxesShouldReturnDestroyedWhenChildThenParentMailboxes() {
-        jmapServer.serverProbe().createMailbox("#private", username, "parent");
-        Mailbox parentMailbox = jmapServer.serverProbe().getMailbox("#private", username, "parent");
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "parent");
+        Mailbox parentMailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "parent");
         String parentMailboxId = parentMailbox.getMailboxId().serialize();
-        jmapServer.serverProbe().createMailbox("#private", username, "parent.child");
-        Mailbox childMailbox = jmapServer.serverProbe().getMailbox("#private", username, "parent.child");
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "parent.child");
+        Mailbox childMailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "parent.child");
         String childMailboxId = childMailbox.getMailboxId().serialize();
         String requestBody =
             "[" +
@@ -1107,8 +1088,8 @@ public abstract class SetMailboxesMethodTest {
 
     @Test
     public void setMailboxesShouldReturnUpdatedMailboxIdWhenNoUpdateAskedOnExistingMailbox() {
-        jmapServer.serverProbe().createMailbox("#private", username, "myBox");
-        Mailbox mailbox = jmapServer.serverProbe().getMailbox("#private", username, "myBox");
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox");
+        Mailbox mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox");
         String mailboxId = mailbox.getMailboxId().serialize();
         String requestBody =
                 "[" +
@@ -1136,8 +1117,8 @@ public abstract class SetMailboxesMethodTest {
 
     @Test
     public void setMailboxesShouldReturnUpdatedWhenNameUpdateAskedOnExistingMailbox() {
-        jmapServer.serverProbe().createMailbox("#private", username, "myBox");
-        Mailbox mailbox = jmapServer.serverProbe().getMailbox("#private", username, "myBox");
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox");
+        Mailbox mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox");
         String mailboxId = mailbox.getMailboxId().serialize();
         String requestBody =
                 "[" +
@@ -1166,8 +1147,8 @@ public abstract class SetMailboxesMethodTest {
 
     @Test
     public void setMailboxesShouldUpdateMailboxNameWhenNameUpdateAskedOnExistingMailbox() {
-        jmapServer.serverProbe().createMailbox("#private", username, "myBox");
-        Mailbox mailbox = jmapServer.serverProbe().getMailbox("#private", username, "myBox");
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox");
+        Mailbox mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox");
         String mailboxId = mailbox.getMailboxId().serialize();
         String requestBody =
                 "[" +
@@ -1202,12 +1183,12 @@ public abstract class SetMailboxesMethodTest {
 
     @Test
     public void setMailboxesShouldReturnMailboxIdWhenMovingToAnotherParentMailbox() {
-        jmapServer.serverProbe().createMailbox("#private", username, "myBox");
-        Mailbox mailbox = jmapServer.serverProbe().getMailbox("#private", username, "myBox");
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox");
+        Mailbox mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox");
         String mailboxId = mailbox.getMailboxId().serialize();
 
-        jmapServer.serverProbe().createMailbox("#private", username, "myChosenParentBox");
-        Mailbox chosenMailboxParent = jmapServer.serverProbe().getMailbox("#private", username, "myChosenParentBox");
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myChosenParentBox");
+        Mailbox chosenMailboxParent = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "myChosenParentBox");
         String chosenMailboxParentId = chosenMailboxParent.getMailboxId().serialize();
         
         String requestBody =
@@ -1237,12 +1218,12 @@ public abstract class SetMailboxesMethodTest {
 
     @Test
     public void setMailboxesShouldUpdateMailboxParentIdWhenMovingToAnotherParentMailbox() {
-        jmapServer.serverProbe().createMailbox("#private", username, "myPreviousParentBox.myBox");
-        Mailbox mailbox = jmapServer.serverProbe().getMailbox("#private", username, "myPreviousParentBox.myBox");
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox.myBox");
+        Mailbox mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox.myBox");
         String mailboxId = mailbox.getMailboxId().serialize();
         
-        jmapServer.serverProbe().createMailbox("#private", username, "myNewParentBox");
-        Mailbox newParentMailbox = jmapServer.serverProbe().getMailbox("#private", username, "myNewParentBox");
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myNewParentBox");
+        Mailbox newParentMailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "myNewParentBox");
         String newParentMailboxId = newParentMailbox.getMailboxId().serialize();
 
         String requestBody =
@@ -1278,14 +1259,14 @@ public abstract class SetMailboxesMethodTest {
 
     @Test
     public void setMailboxesShouldReturnMailboxIdWhenParentIdUpdateAskedOnExistingMailbox() {
-        jmapServer.serverProbe().createMailbox("#private", username, "myPreviousParentBox");
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox");
 
-        jmapServer.serverProbe().createMailbox("#private", username, "myPreviousParentBox.myBox");
-        Mailbox mailbox = jmapServer.serverProbe().getMailbox("#private", username, "myPreviousParentBox.myBox");
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox.myBox");
+        Mailbox mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox.myBox");
         String mailboxId = mailbox.getMailboxId().serialize();
         
-        jmapServer.serverProbe().createMailbox("#private", username, "myNewParentBox");
-        Mailbox newParentMailbox = jmapServer.serverProbe().getMailbox("#private", username, "myNewParentBox");
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myNewParentBox");
+        Mailbox newParentMailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "myNewParentBox");
         String newParentMailboxId = newParentMailbox.getMailboxId().serialize();
 
         String requestBody =
@@ -1315,14 +1296,14 @@ public abstract class SetMailboxesMethodTest {
 
     @Test
     public void setMailboxesShouldUpdateMailboxParentIdWhenParentIdUpdateAskedOnExistingMailbox() {
-        jmapServer.serverProbe().createMailbox("#private", username, "myPreviousParentBox");
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox");
 
-        jmapServer.serverProbe().createMailbox("#private", username, "myPreviousParentBox.myBox");
-        Mailbox mailbox = jmapServer.serverProbe().getMailbox("#private", username, "myPreviousParentBox.myBox");
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox.myBox");
+        Mailbox mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox.myBox");
         String mailboxId = mailbox.getMailboxId().serialize();
         
-        jmapServer.serverProbe().createMailbox("#private", username, "myNewParentBox");
-        Mailbox newParentMailbox = jmapServer.serverProbe().getMailbox("#private", username, "myNewParentBox");
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myNewParentBox");
+        Mailbox newParentMailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "myNewParentBox");
         String newParentMailboxId = newParentMailbox.getMailboxId().serialize();
 
         String requestBody =
@@ -1358,10 +1339,10 @@ public abstract class SetMailboxesMethodTest {
 
     @Test
     public void setMailboxesShouldReturnMailboxIdWhenParentIdUpdateAskedAsOrphanForExistingMailbox() {
-        jmapServer.serverProbe().createMailbox("#private", username, "myPreviousParentBox");
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox");
 
-        jmapServer.serverProbe().createMailbox("#private", username, "myPreviousParentBox.myBox");
-        Mailbox mailbox = jmapServer.serverProbe().getMailbox("#private", username, "myPreviousParentBox.myBox");
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox.myBox");
+        Mailbox mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox.myBox");
         String mailboxId = mailbox.getMailboxId().serialize();
 
         String requestBody =
@@ -1391,10 +1372,10 @@ public abstract class SetMailboxesMethodTest {
 
     @Test
     public void setMailboxesShouldUpdateParentIdWhenAskedAsOrphanForExistingMailbox() {
-        jmapServer.serverProbe().createMailbox("#private", username, "myPreviousParentBox");
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox");
 
-        jmapServer.serverProbe().createMailbox("#private", username, "myPreviousParentBox.myBox");
-        Mailbox mailbox = jmapServer.serverProbe().getMailbox("#private", username, "myPreviousParentBox.myBox");
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox.myBox");
+        Mailbox mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox.myBox");
         String mailboxId = mailbox.getMailboxId().serialize();
 
         String requestBody =
@@ -1430,14 +1411,14 @@ public abstract class SetMailboxesMethodTest {
 
     @Test
     public void setMailboxesShouldReturnMailboxIdWhenNameAndParentIdUpdateForExistingMailbox() {
-        jmapServer.serverProbe().createMailbox("#private", username, "myPreviousParentBox");
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox");
 
-        jmapServer.serverProbe().createMailbox("#private", username, "myPreviousParentBox.myBox");
-        Mailbox mailbox = jmapServer.serverProbe().getMailbox("#private", username, "myPreviousParentBox.myBox");
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox.myBox");
+        Mailbox mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox.myBox");
         String mailboxId = mailbox.getMailboxId().serialize();
 
-        jmapServer.serverProbe().createMailbox("#private", username, "myNewParentBox");
-        Mailbox newParentMailbox = jmapServer.serverProbe().getMailbox("#private", username, "myNewParentBox");
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myNewParentBox");
+        Mailbox newParentMailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "myNewParentBox");
         String newParentMailboxId = newParentMailbox.getMailboxId().serialize();
 
         String requestBody =
@@ -1468,14 +1449,14 @@ public abstract class SetMailboxesMethodTest {
 
     @Test
     public void setMailboxesShoulUpdateMailboxIAndParentIddWhenBothUpdatedForExistingMailbox() {
-        jmapServer.serverProbe().createMailbox("#private", username, "myPreviousParentBox");
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox");
 
-        jmapServer.serverProbe().createMailbox("#private", username, "myPreviousParentBox.myBox");
-        Mailbox mailbox = jmapServer.serverProbe().getMailbox("#private", username, "myPreviousParentBox.myBox");
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox.myBox");
+        Mailbox mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox.myBox");
         String mailboxId = mailbox.getMailboxId().serialize();
 
-        jmapServer.serverProbe().createMailbox("#private", username, "myNewParentBox");
-        Mailbox newParentMailbox = jmapServer.serverProbe().getMailbox("#private", username, "myNewParentBox");
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myNewParentBox");
+        Mailbox newParentMailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "myNewParentBox");
         String newParentMailboxId = newParentMailbox.getMailboxId().serialize();
 
         String requestBody =
@@ -1513,8 +1494,8 @@ public abstract class SetMailboxesMethodTest {
 
     @Test
     public void setMailboxesShouldReturnNotUpdatedWhenNameContainsPathDelimiter() {
-        jmapServer.serverProbe().createMailbox("#private", username, "myBox");
-        Mailbox mailbox = jmapServer.serverProbe().getMailbox("#private", username, "myBox");
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox");
+        Mailbox mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox");
         String mailboxId = mailbox.getMailboxId().serialize();
         String requestBody =
                 "[" +
@@ -1545,8 +1526,8 @@ public abstract class SetMailboxesMethodTest {
 
     @Test
     public void setMailboxesShouldReturnNotUpdatedWhenNewParentDoesntExist() {
-        jmapServer.serverProbe().createMailbox("#private", username, "myBox");
-        Mailbox mailbox = jmapServer.serverProbe().getMailbox("#private", username, "myBox");
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox");
+        Mailbox mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox");
         String mailboxId = mailbox.getMailboxId().serialize();
         String badParentId = getRemovedMailboxId().serialize();
         String requestBody =
@@ -1578,16 +1559,16 @@ public abstract class SetMailboxesMethodTest {
 
     @Test
     public void setMailboxesShouldReturnNotUpdatedWhenUpdatingParentIdOfAParentMailbox() {
-        jmapServer.serverProbe().createMailbox("#private", username, "root");
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "root");
 
-        jmapServer.serverProbe().createMailbox("#private", username, "root.myBox");
-        Mailbox mailbox = jmapServer.serverProbe().getMailbox("#private", username, "root.myBox");
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "root.myBox");
+        Mailbox mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "root.myBox");
         String mailboxId = mailbox.getMailboxId().serialize();
 
-        jmapServer.serverProbe().createMailbox("#private", username, "root.myBox.child");
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "root.myBox.child");
 
-        jmapServer.serverProbe().createMailbox("#private", username, "myNewParentBox");
-        Mailbox newParentMailbox = jmapServer.serverProbe().getMailbox("#private", username, "myNewParentBox");
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myNewParentBox");
+        Mailbox newParentMailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "myNewParentBox");
         String newParentMailboxId = newParentMailbox.getMailboxId().serialize();
 
 
@@ -1620,11 +1601,11 @@ public abstract class SetMailboxesMethodTest {
 
     @Test
     public void setMailboxesShouldReturnNotUpdatedWhenRenamingAMailboxToAnAlreadyExistingMailbox() {
-        jmapServer.serverProbe().createMailbox("#private", username, "myBox");
-        Mailbox mailbox = jmapServer.serverProbe().getMailbox("#private", username, "myBox");
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox");
+        Mailbox mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox");
         String mailboxId = mailbox.getMailboxId().serialize();
 
-        jmapServer.serverProbe().createMailbox("#private", username, "mySecondBox");
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mySecondBox");
 
         String requestBody =
                 "[" +
@@ -1655,10 +1636,10 @@ public abstract class SetMailboxesMethodTest {
 
     @Test
     public void setMailboxesShouldReturnUpdatedWhenRenamingAChildMailbox() {
-        jmapServer.serverProbe().createMailbox("#private", username, "root");
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "root");
 
-        jmapServer.serverProbe().createMailbox("#private", username, "root.myBox");
-        Mailbox mailbox = jmapServer.serverProbe().getMailbox("#private", username, "root.myBox");
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "root.myBox");
+        Mailbox mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "root.myBox");
         String mailboxId = mailbox.getMailboxId().serialize();
 
         String requestBody =
@@ -1688,10 +1669,10 @@ public abstract class SetMailboxesMethodTest {
 
     @Test
     public void setMailboxesShouldUpdateMailboxNameWhenRenamingAChildMailbox() {
-        jmapServer.serverProbe().createMailbox("#private", username, "root");
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "root");
 
-        jmapServer.serverProbe().createMailbox("#private", username, "root.myBox");
-        Mailbox mailbox = jmapServer.serverProbe().getMailbox("#private", username, "root.myBox");
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "root.myBox");
+        Mailbox mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "root.myBox");
         String mailboxId = mailbox.getMailboxId().serialize();
 
         String requestBody =
@@ -1728,7 +1709,7 @@ public abstract class SetMailboxesMethodTest {
     @Test
     public void setMailboxesShouldReturnNotUpdatedWhenRenamingSystemMailbox() {
 
-        Mailbox mailbox = jmapServer.serverProbe().getMailbox("#private", username, "inbox");
+        Mailbox mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, MailboxConstants.INBOX);
         String mailboxId = mailbox.getMailboxId().serialize();
 
         String requestBody =
@@ -1761,8 +1742,8 @@ public abstract class SetMailboxesMethodTest {
     @Test
     public void setMailboxesShouldReturnNotUpdatedWhenRenameToSystemMailboxName() {
 
-        jmapServer.serverProbe().createMailbox("#private", username, "myBox");
-        Mailbox mailboxMyBox = jmapServer.serverProbe().getMailbox("#private", username, "myBox");
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox");
+        Mailbox mailboxMyBox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox");
         String mailboxIdMyBox = mailboxMyBox.getMailboxId().serialize();
 
         String requestBody =
@@ -1795,15 +1776,15 @@ public abstract class SetMailboxesMethodTest {
     @Test
     public void setMailboxesShouldReturnNotUpdatedErrorWhenMovingMailboxTriggersNameConflict() {
 
-        jmapServer.serverProbe().createMailbox("#private", username, "A");
-        Mailbox mailboxRootA = jmapServer.serverProbe().getMailbox("#private", username, "A");
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "A");
+        Mailbox mailboxRootA = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "A");
         String mailboxRootAId = mailboxRootA.getMailboxId().serialize();
 
-        jmapServer.serverProbe().createMailbox("#private", username, "A.B");
-        jmapServer.serverProbe().createMailbox("#private", username, "A.C");
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "A.B");
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "A.C");
 
-        jmapServer.serverProbe().createMailbox("#private", username, "A.B.C");
-        Mailbox mailboxChildToMoveC = jmapServer.serverProbe().getMailbox("#private", username, "A.B.C");
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "A.B.C");
+        Mailbox mailboxChildToMoveC = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "A.B.C");
         String mailboxChildToMoveCId = mailboxChildToMoveC.getMailboxId().serialize();
 
         String requestBody =

http://git-wip-us.apache.org/repos/asf/james-project/blob/844efe2a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java
index 82b052a..1fd27ad 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java
@@ -53,6 +53,7 @@ import javax.mail.Flags;
 import org.apache.commons.io.IOUtils;
 import org.apache.http.client.utils.URIBuilder;
 import org.apache.james.JmapJamesServer;
+import org.apache.james.jmap.DefaultMailboxes;
 import org.apache.james.jmap.HttpJmapAuthentication;
 import org.apache.james.jmap.api.access.AccessToken;
 import org.apache.james.jmap.model.mailbox.Role;
@@ -122,12 +123,12 @@ public abstract class SetMessagesMethodTest {
         String password = "password";
         jmapServer.serverProbe().addDomain(USERS_DOMAIN);
         jmapServer.serverProbe().addUser(USERNAME, password);
-        jmapServer.serverProbe().createMailbox("#private", USERNAME, "inbox");
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, DefaultMailboxes.INBOX);
         accessToken = HttpJmapAuthentication.authenticateJamesUser(baseUri(), USERNAME, password);
 
-        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, "outbox");
-        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, "trash");
-        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, "draft");
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, DefaultMailboxes.OUTBOX);
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, DefaultMailboxes.TRASH);
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, DefaultMailboxes.DRAFTS);
         await();
 
         Duration slowPacedPollInterval = Duration.FIVE_HUNDRED_MILLISECONDS;
@@ -154,7 +155,7 @@ public abstract class SetMessagesMethodTest {
 
     private String getMailboxId(AccessToken accessToken, Role role) {
         return getAllMailboxesIds(accessToken).stream()
-            .filter(x -> x.get("role").equals(role.serialize()))
+            .filter(x -> x.get("role").equalsIgnoreCase(role.serialize()))
             .map(x -> x.get("id"))
             .findFirst().get();
     }
@@ -899,7 +900,6 @@ public abstract class SetMessagesMethodTest {
     @Test
     public void setMessagesShouldMoveMessageInSentWhenMessageIsSent() throws MailboxException {
         // Given
-        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, "sent");
         String sentMailboxId = getMailboxId(accessToken, Role.SENT);
 
         String fromAddress = USERNAME;
@@ -1098,7 +1098,6 @@ public abstract class SetMessagesMethodTest {
 
     @Test
     public void setMessagesShouldMoveToSentWhenSendingMessageWithOnlyFromAddress() {
-        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, "sent");
         String sentMailboxId = getMailboxId(accessToken, Role.SENT);
 
         String messageCreationId = "creationId1337";
@@ -1203,13 +1202,10 @@ public abstract class SetMessagesMethodTest {
     @Test
     public void setMessagesShouldDeliverMessageToRecipient() throws Exception {
         // Sender
-        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, "sent");
         // Recipient
         String recipientAddress = "recipient" + "@" + USERS_DOMAIN;
         String password = "password";
         jmapServer.serverProbe().addUser(recipientAddress, password);
-        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, recipientAddress, "inbox");
-        await();
         AccessToken recipientToken = HttpJmapAuthentication.authenticateJamesUser(baseUri(), recipientAddress, password);
 
         String messageCreationId = "creationId1337";
@@ -1245,16 +1241,12 @@ public abstract class SetMessagesMethodTest {
 
     @Test
     public void setMessagesShouldStripBccFromDeliveredEmail() throws Exception {
-        // Sender
-        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, "sent");
         // Recipient
         String recipientAddress = "recipient" + "@" + USERS_DOMAIN;
         String bccRecipient = "bob@" + USERS_DOMAIN;
         String password = "password";
         jmapServer.serverProbe().addUser(recipientAddress, password);
         jmapServer.serverProbe().addUser(bccRecipient, password);
-        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, recipientAddress, "inbox");
-        await();
         AccessToken recipientToken = HttpJmapAuthentication.authenticateJamesUser(baseUri(), recipientAddress, password);
 
         String messageCreationId = "creationId1337";
@@ -1303,14 +1295,12 @@ public abstract class SetMessagesMethodTest {
     @Test
     public void setMessagesShouldKeepBccInSentMailbox() throws Exception {
         // Sender
-        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, "sent");
         String sentMailboxId = getMailboxId(accessToken, Role.SENT);
 
         // Recipient
         String recipientAddress = "recipient" + "@" + USERS_DOMAIN;
         String password = "password";
         jmapServer.serverProbe().addUser(recipientAddress, password);
-        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, recipientAddress, "inbox");
         await();
 
         String messageCreationId = "creationId1337";
@@ -1359,17 +1349,14 @@ public abstract class SetMessagesMethodTest {
     @Test
     public void setMessagesShouldSendMessageToBcc() throws Exception {
         // Sender
-        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, "sent");
 
         // Recipient
         String recipientAddress = "recipient" + "@" + USERS_DOMAIN;
         String password = "password";
         jmapServer.serverProbe().addUser(recipientAddress, password);
-        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, recipientAddress, "inbox");
 
         String bccAddress = "bob" + "@" + USERS_DOMAIN;
         jmapServer.serverProbe().addUser(bccAddress, password);
-        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, bccAddress, "inbox");
         await();
         AccessToken bccToken = HttpJmapAuthentication.authenticateJamesUser(baseUri(), bccAddress, password);
 
@@ -1438,12 +1425,10 @@ public abstract class SetMessagesMethodTest {
     @Test
     public void setMessagesShouldSendAReadableHtmlMessage() throws Exception {
         // Sender
-        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, "sent");
         // Recipient
         String recipientAddress = "recipient" + "@" + USERS_DOMAIN;
         String password = "password";
         jmapServer.serverProbe().addUser(recipientAddress, password);
-        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, recipientAddress, "inbox");
         await();
         AccessToken recipientToken = HttpJmapAuthentication.authenticateJamesUser(baseUri(), recipientAddress, password);
 
@@ -1480,14 +1465,9 @@ public abstract class SetMessagesMethodTest {
 
     @Test
     public void setMessagesWhenSavingToDraftsShouldNotSendMessage() throws Exception {
-        String sender = USERNAME;
-        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, sender, "sent");
-        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, sender, "drafts");
         String recipientAddress = "recipient" + "@" + USERS_DOMAIN;
         String recipientPassword = "password";
         jmapServer.serverProbe().addUser(recipientAddress, recipientPassword);
-        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, recipientAddress, "inbox");
-        await();
         AccessToken recipientToken = HttpJmapAuthentication.authenticateJamesUser(baseUri(), recipientAddress, recipientPassword);
 
         String senderDraftsMailboxId = getMailboxId(accessToken, Role.DRAFTS);
@@ -1529,8 +1509,6 @@ public abstract class SetMessagesMethodTest {
     @Test
     public void setMessagesWhenSavingToRegularMailboxShouldNotSendMessage() throws Exception {
         String sender = USERNAME;
-        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, sender, "sent");
-        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, sender, "drafts");
         jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, sender, "regular");
         Mailbox regularMailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, sender, "regular");
         String recipientAddress = "recipient" + "@" + USERS_DOMAIN;
@@ -1592,14 +1570,10 @@ public abstract class SetMessagesMethodTest {
     
     @Test
     public void setMessagesShouldSendAReadableTextPlusHtmlMessage() throws Exception {
-        // Sender
-        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, "sent");
         // Recipient
         String recipientAddress = "recipient" + "@" + USERS_DOMAIN;
         String password = "password";
         jmapServer.serverProbe().addUser(recipientAddress, password);
-        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, recipientAddress, "inbox");
-        await();
         AccessToken recipientToken = HttpJmapAuthentication.authenticateJamesUser(baseUri(), recipientAddress, password);
 
         String messageCreationId = "creationId1337";
@@ -1655,7 +1629,7 @@ public abstract class SetMessagesMethodTest {
     @Test
     public void mailboxIdsShouldReturnUpdatedWhenNoChange() throws Exception {
         ZonedDateTime dateTime = ZonedDateTime.parse("2014-10-30T14:12:00Z");
-        ComposedMessageId message = jmapServer.serverProbe().appendMessage(USERNAME, new MailboxPath("#private", USERNAME, "inbox"),
+        ComposedMessageId message = jmapServer.serverProbe().appendMessage(USERNAME, new MailboxPath(MailboxConstants.USER_NAMESPACE, USERNAME, MailboxConstants.INBOX),
             new ByteArrayInputStream("Subject: my test subject\r\n\r\ntestmail".getBytes(Charsets.UTF_8)), Date.from(dateTime.toInstant()), false, new Flags());
 
         String messageToMoveId = message.getMessageId().serialize();
@@ -1685,12 +1659,12 @@ public abstract class SetMessagesMethodTest {
     @Test
     public void mailboxIdsShouldBeInDestinationWhenUsingForMove() throws Exception {
         String newMailboxName = "heartFolder";
-        jmapServer.serverProbe().createMailbox("#private", USERNAME, newMailboxName);
-        Mailbox heartFolder = jmapServer.serverProbe().getMailbox("#private", USERNAME, newMailboxName);
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, newMailboxName);
+        Mailbox heartFolder = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, newMailboxName);
         String heartFolderId = heartFolder.getMailboxId().serialize();
 
         ZonedDateTime dateTime = ZonedDateTime.parse("2014-10-30T14:12:00Z");
-        ComposedMessageId message = jmapServer.serverProbe().appendMessage(USERNAME, new MailboxPath("#private", USERNAME, "inbox"),
+        ComposedMessageId message = jmapServer.serverProbe().appendMessage(USERNAME, new MailboxPath(MailboxConstants.USER_NAMESPACE, USERNAME, MailboxConstants.INBOX),
             new ByteArrayInputStream("Subject: my test subject\r\n\r\ntestmail".getBytes(Charsets.UTF_8)), Date.from(dateTime.toInstant()), false, new Flags());
 
         String messageToMoveId = message.getMessageId().serialize();
@@ -1729,14 +1703,14 @@ public abstract class SetMessagesMethodTest {
 
     @Test
     public void mailboxIdsShouldBeInDestinationWhenUsingForMoveWithoutTrashFolder() throws Exception {
-        jmapServer.serverProbe().deleteMailbox("#private", USERNAME, "trash");
+        jmapServer.serverProbe().deleteMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, DefaultMailboxes.TRASH);
         String newMailboxName = "heartFolder";
-        jmapServer.serverProbe().createMailbox("#private", USERNAME, newMailboxName);
-        Mailbox heartFolder = jmapServer.serverProbe().getMailbox("#private", USERNAME, newMailboxName);
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, newMailboxName);
+        Mailbox heartFolder = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, newMailboxName);
         String heartFolderId = heartFolder.getMailboxId().serialize();
 
         ZonedDateTime dateTime = ZonedDateTime.parse("2014-10-30T14:12:00Z");
-        ComposedMessageId message = jmapServer.serverProbe().appendMessage(USERNAME, new MailboxPath("#private", USERNAME, "inbox"),
+        ComposedMessageId message = jmapServer.serverProbe().appendMessage(USERNAME, new MailboxPath(MailboxConstants.USER_NAMESPACE, USERNAME, MailboxConstants.INBOX),
             new ByteArrayInputStream("Subject: my test subject\r\n\r\ntestmail".getBytes(Charsets.UTF_8)), Date.from(dateTime.toInstant()), false, new Flags());
 
         String messageToMoveId = message.getMessageId().serialize();
@@ -1775,12 +1749,12 @@ public abstract class SetMessagesMethodTest {
     @Test
     public void mailboxIdsShouldNotBeAnymoreInSourceWhenUsingForMove() throws Exception {
         String newMailboxName = "heartFolder";
-        jmapServer.serverProbe().createMailbox("#private", USERNAME, newMailboxName);
-        Mailbox heartFolder = jmapServer.serverProbe().getMailbox("#private", USERNAME, newMailboxName);
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, newMailboxName);
+        Mailbox heartFolder = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, newMailboxName);
         String heartFolderId = heartFolder.getMailboxId().serialize();
 
         ZonedDateTime dateTime = ZonedDateTime.parse("2014-10-30T14:12:00Z");
-        ComposedMessageId message = jmapServer.serverProbe().appendMessage(USERNAME, new MailboxPath("#private", USERNAME, "inbox"),
+        ComposedMessageId message = jmapServer.serverProbe().appendMessage(USERNAME, new MailboxPath(MailboxConstants.USER_NAMESPACE, USERNAME, MailboxConstants.INBOX),
             new ByteArrayInputStream("Subject: my test subject\r\n\r\ntestmail".getBytes(Charsets.UTF_8)), Date.from(dateTime.toInstant()), false, new Flags());
 
         String messageToMoveId = message.getMessageId().serialize();
@@ -1820,12 +1794,12 @@ public abstract class SetMessagesMethodTest {
     @Test
     public void mailboxIdsShouldBeInBothMailboxWhenUsingForCopy() throws Exception {
         String newMailboxName = "heartFolder";
-        jmapServer.serverProbe().createMailbox("#private", USERNAME, newMailboxName);
-        Mailbox heartFolder = jmapServer.serverProbe().getMailbox("#private", USERNAME, newMailboxName);
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, newMailboxName);
+        Mailbox heartFolder = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, newMailboxName);
         String heartFolderId = heartFolder.getMailboxId().serialize();
 
         ZonedDateTime dateTime = ZonedDateTime.parse("2014-10-30T14:12:00Z");
-        ComposedMessageId message = jmapServer.serverProbe().appendMessage(USERNAME, new MailboxPath("#private", USERNAME, "inbox"),
+        ComposedMessageId message = jmapServer.serverProbe().appendMessage(USERNAME, new MailboxPath(MailboxConstants.USER_NAMESPACE, USERNAME, MailboxConstants.INBOX),
             new ByteArrayInputStream("Subject: my test subject\r\n\r\ntestmail".getBytes(Charsets.UTF_8)), Date.from(dateTime.toInstant()), false, new Flags());
 
         String messageToMoveId = message.getMessageId().serialize();
@@ -1865,7 +1839,7 @@ public abstract class SetMessagesMethodTest {
     @Test
     public void mailboxIdsShouldBeInOriginalMailboxWhenNoChange() throws Exception {
         ZonedDateTime dateTime = ZonedDateTime.parse("2014-10-30T14:12:00Z");
-        ComposedMessageId message = jmapServer.serverProbe().appendMessage(USERNAME, new MailboxPath("#private", USERNAME, "inbox"),
+        ComposedMessageId message = jmapServer.serverProbe().appendMessage(USERNAME, new MailboxPath(MailboxConstants.USER_NAMESPACE, USERNAME, MailboxConstants.INBOX),
             new ByteArrayInputStream("Subject: my test subject\r\n\r\ntestmail".getBytes(Charsets.UTF_8)), Date.from(dateTime.toInstant()), false, new Flags());
 
         String messageToMoveId = message.getMessageId().serialize();
@@ -1905,7 +1879,7 @@ public abstract class SetMessagesMethodTest {
     @Test
     public void mailboxIdsShouldReturnErrorWhenMovingToADeletedMailbox() throws Exception {
         ZonedDateTime dateTime = ZonedDateTime.parse("2014-10-30T14:12:00Z");
-        ComposedMessageId message = jmapServer.serverProbe().appendMessage(USERNAME, new MailboxPath("#private", USERNAME, "inbox"),
+        ComposedMessageId message = jmapServer.serverProbe().appendMessage(USERNAME, new MailboxPath(MailboxConstants.USER_NAMESPACE, USERNAME, MailboxConstants.INBOX),
             new ByteArrayInputStream("Subject: my test subject\r\n\r\ntestmail".getBytes(Charsets.UTF_8)), Date.from(dateTime.toInstant()), false, new Flags());
 
         jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, "any");
@@ -1944,7 +1918,7 @@ public abstract class SetMessagesMethodTest {
     @Test
     public void mailboxIdsShouldReturnErrorWhenSetToEmpty() throws Exception {
         ZonedDateTime dateTime = ZonedDateTime.parse("2014-10-30T14:12:00Z");
-        ComposedMessageId message = jmapServer.serverProbe().appendMessage(USERNAME, new MailboxPath("#private", USERNAME, "inbox"),
+        ComposedMessageId message = jmapServer.serverProbe().appendMessage(USERNAME, new MailboxPath(MailboxConstants.USER_NAMESPACE, USERNAME, MailboxConstants.INBOX),
             new ByteArrayInputStream("Subject: my test subject\r\n\r\ntestmail".getBytes(Charsets.UTF_8)), Date.from(dateTime.toInstant()), false, new Flags());
 
         String messageToMoveId = message.getMessageId().serialize();
@@ -1979,12 +1953,12 @@ public abstract class SetMessagesMethodTest {
     @Test
     public void updateShouldNotReturnErrorWithFlagsAndMailboxUpdate() throws Exception {
         String newMailboxName = "heartFolder";
-        jmapServer.serverProbe().createMailbox("#private", USERNAME, newMailboxName);
-        Mailbox heartFolder = jmapServer.serverProbe().getMailbox("#private", USERNAME, newMailboxName);
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, newMailboxName);
+        Mailbox heartFolder = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, newMailboxName);
         String heartFolderId = heartFolder.getMailboxId().serialize();
 
         ZonedDateTime dateTime = ZonedDateTime.parse("2014-10-30T14:12:00Z");
-        ComposedMessageId message = jmapServer.serverProbe().appendMessage(USERNAME, new MailboxPath("#private", USERNAME, "inbox"),
+        ComposedMessageId message = jmapServer.serverProbe().appendMessage(USERNAME, new MailboxPath(MailboxConstants.USER_NAMESPACE, USERNAME, MailboxConstants.INBOX),
             new ByteArrayInputStream("Subject: my test subject\r\n\r\ntestmail".getBytes(Charsets.UTF_8)), Date.from(dateTime.toInstant()), false, new Flags());
 
         String messageToMoveId = message.getMessageId().serialize();
@@ -2014,12 +1988,12 @@ public abstract class SetMessagesMethodTest {
     @Test
     public void updateShouldWorkWithFlagsAndMailboxUpdate() throws Exception {
         String newMailboxName = "heartFolder";
-        jmapServer.serverProbe().createMailbox("#private", USERNAME, newMailboxName);
-        Mailbox heartFolder = jmapServer.serverProbe().getMailbox("#private", USERNAME, newMailboxName);
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, newMailboxName);
+        Mailbox heartFolder = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, newMailboxName);
         String heartFolderId = heartFolder.getMailboxId().serialize();
 
         ZonedDateTime dateTime = ZonedDateTime.parse("2014-10-30T14:12:00Z");
-        ComposedMessageId message = jmapServer.serverProbe().appendMessage(USERNAME, new MailboxPath("#private", USERNAME, "inbox"),
+        ComposedMessageId message = jmapServer.serverProbe().appendMessage(USERNAME, new MailboxPath(MailboxConstants.USER_NAMESPACE, USERNAME, MailboxConstants.INBOX),
             new ByteArrayInputStream("Subject: my test subject\r\n\r\ntestmail".getBytes(Charsets.UTF_8)), Date.from(dateTime.toInstant()), false, new Flags());
 
         String messageToMoveId = message.getMessageId().serialize();
@@ -2059,10 +2033,10 @@ public abstract class SetMessagesMethodTest {
 
     @Test
     public void setMessagesShouldWorkForMoveToTrash() throws Exception {
-        String trashId = jmapServer.serverProbe().getMailbox("#private", USERNAME, "trash").getMailboxId().serialize();
+        String trashId = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, DefaultMailboxes.TRASH).getMailboxId().serialize();
 
         ZonedDateTime dateTime = ZonedDateTime.parse("2014-10-30T14:12:00Z");
-        ComposedMessageId message = jmapServer.serverProbe().appendMessage(USERNAME, new MailboxPath("#private", USERNAME, "inbox"),
+        ComposedMessageId message = jmapServer.serverProbe().appendMessage(USERNAME, new MailboxPath(MailboxConstants.USER_NAMESPACE, USERNAME, MailboxConstants.INBOX),
             new ByteArrayInputStream("Subject: my test subject\r\n\r\ntestmail".getBytes(Charsets.UTF_8)), Date.from(dateTime.toInstant()), false, new Flags());
 
         String messageToMoveId = message.getMessageId().serialize();
@@ -2094,11 +2068,11 @@ public abstract class SetMessagesMethodTest {
     @Test
     public void copyToTrashShouldWork() throws Exception {
         String newMailboxName = "heartFolder";
-        jmapServer.serverProbe().createMailbox("#private", USERNAME, newMailboxName);
-        String trashId = jmapServer.serverProbe().getMailbox("#private", USERNAME, "trash").getMailboxId().serialize();
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, newMailboxName);
+        String trashId = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, DefaultMailboxes.TRASH).getMailboxId().serialize();
 
         ZonedDateTime dateTime = ZonedDateTime.parse("2014-10-30T14:12:00Z");
-        ComposedMessageId message = jmapServer.serverProbe().appendMessage(USERNAME, new MailboxPath("#private", USERNAME, "inbox"),
+        ComposedMessageId message = jmapServer.serverProbe().appendMessage(USERNAME, new MailboxPath(MailboxConstants.USER_NAMESPACE, USERNAME, MailboxConstants.INBOX),
             new ByteArrayInputStream("Subject: my test subject\r\n\r\ntestmail".getBytes(Charsets.UTF_8)), Date.from(dateTime.toInstant()), false, new Flags());
 
         String messageToMoveId = message.getMessageId().serialize();
@@ -2137,8 +2111,6 @@ public abstract class SetMessagesMethodTest {
     
     @Test
     public void setMessagesShouldReturnAttachmentsNotFoundWhenBlobIdDoesntExist() throws Exception {
-        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, "sent");
-        await();
         String messageCreationId = "creationId";
         String fromAddress = USERNAME;
         String outboxId = getOutboxId(accessToken);
@@ -2180,8 +2152,6 @@ public abstract class SetMessagesMethodTest {
 
     @Test
     public void setMessagesShouldReturnAttachmentsWhenMessageHasAttachment() throws Exception {
-        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, "sent");
-
         Attachment attachment = Attachment.builder()
             .bytes("attachment".getBytes(Charsets.UTF_8))
             .type("application/octet-stream")
@@ -2251,8 +2221,6 @@ public abstract class SetMessagesMethodTest {
 
     @Test
     public void setMessagesShouldReturnAttachmentsWithNonASCIINames() throws Exception {
-        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, "sent");
-
         Attachment attachment = Attachment.builder()
             .bytes("attachment".getBytes(Charsets.UTF_8))
             .type("application/octet-stream")
@@ -2339,8 +2307,6 @@ public abstract class SetMessagesMethodTest {
 
     @Test
     public void filenamesAttachmentsWithNonASCIICharactersShouldBeRetrievedWhenChainingSetMessagesAndGetMessages() throws Exception {
-        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, "sent");
-
         Attachment attachment = Attachment.builder()
             .bytes("attachment".getBytes(Charsets.UTF_8))
             .type("application/octet-stream")
@@ -2463,8 +2429,6 @@ public abstract class SetMessagesMethodTest {
 
     @Test
     public void attachmentsShouldBeRetrievedWhenChainingSetMessagesAndGetMessagesBinaryAttachment() throws Exception {
-        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, "sent");
-
         byte[] rawBytes = new byte[]{-128,-127,-126,-125,-124,-123,-122,-121,-120,-119,-118,-117,-116,-115,-114,-113,-112,-111,-110,-109,-108,-107,-106,-105,-104,-103,-102,-101,-100,
             -99,-98,-97,-96,-95,-94,-93,-92,-91,-90,-89,-88,-87,-86,-85,-84,-83,-82,-81,-80,-79,-78,-77,-76,-75,-74,-73,-72,-71,-70,-69,-68,-67,-66,-65,-64,-63,-62,-61,-60,-59,-58,-57,-56,-55,-54,-53,-52,-51,
             -50,-49,-48,-47,-46,-45,-44,-43,-42,-41,-40,-39,-38,-37,-36,-35,-34,-33,-32,-31,-30,-29,-28,-27,-26,-25,-24,-23,-22,-21,-20,-19,-18,-17,-16,-15,-14,-13,-12,-11,-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,
@@ -2543,8 +2507,6 @@ public abstract class SetMessagesMethodTest {
 
     @Test
     public void attachmentsShouldBeRetrievedWhenChainingSetMessagesAndGetMessagesTextAttachment() throws Exception {
-        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, "sent");
-
         Attachment attachment = Attachment.builder()
             .bytes(ByteStreams.toByteArray(new ZeroedInputStream(_1MB)))
             .type("application/octet-stream")
@@ -2636,8 +2598,6 @@ public abstract class SetMessagesMethodTest {
 
     @Test
     public void attachmentsAndBodysShouldBeRetrievedWhenChainingSetMessagesAndGetMessagesWithMixedTextAndHtmlBodyAndHtmlAttachment() throws Exception {
-        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, "sent");
-
         Attachment attachment = Attachment.builder()
             .bytes(("<html>\n" +
                     "  <body>attachment</body>\n" + // needed indentation, else restassured is adding some
@@ -2712,8 +2672,6 @@ public abstract class SetMessagesMethodTest {
 
     @Test
     public void attachmentsAndBodyShouldBeRetrievedWhenChainingSetMessagesAndGetMessagesWithTextBodyAndHtmlAttachment() throws Exception {
-        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, "sent");
-
         Attachment attachment = Attachment.builder()
             .bytes(("<html>\n" +
                     "  <body>attachment</body>\n" + // needed indentation, else restassured is adding some
@@ -2786,8 +2744,6 @@ public abstract class SetMessagesMethodTest {
     }
     @Test
     public void attachmentAndEmptyBodyShouldBeRetrievedWhenChainingSetMessagesAndGetMessagesWithTextAttachmentWithoutMailBody() throws Exception {
-        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, "sent");
-
         Attachment attachment = Attachment.builder()
             .bytes(("some text").getBytes(Charsets.UTF_8))
             .type("text/plain; charset=UTF-8")
@@ -2860,9 +2816,7 @@ public abstract class SetMessagesMethodTest {
         String toUsername = "username1@" + USERS_DOMAIN;
         String password = "password";
         jmapServer.serverProbe().addUser(toUsername, password);
-        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, toUsername, "inbox");
 
-        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, "sent");
         String messageCreationId = "creationId1337";
         String fromAddress = USERNAME;
         String requestBody = "[" +
@@ -2898,9 +2852,7 @@ public abstract class SetMessagesMethodTest {
         String toUsername = "username1@" + USERS_DOMAIN;
         String password = "password";
         jmapServer.serverProbe().addUser(toUsername, password);
-        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, toUsername, "inbox");
 
-        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, "sent");
         String messageCreationId = "creationId1337";
         String fromAddress = USERNAME;
         String requestBody = "[" +

http://git-wip-us.apache.org/repos/asf/james-project/blob/844efe2a/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 e84b91b..9d91811 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
@@ -39,6 +39,7 @@ import javax.mail.Flags;
 import org.apache.commons.lang3.StringEscapeUtils;
 import org.apache.http.HttpResponse;
 import org.apache.http.client.fluent.Request;
+import org.apache.james.jmap.DefaultMailboxes;
 import org.apache.james.jmap.methods.integration.cucumber.util.TableRow;
 import org.apache.james.mailbox.model.MailboxConstants;
 import org.apache.james.mailbox.model.MailboxId;
@@ -203,7 +204,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,
-                new MailboxPath(MailboxConstants.USER_NAMESPACE, userStepdefs.lastConnectedUser, "inbox"),
+                new MailboxPath(MailboxConstants.USER_NAMESPACE, userStepdefs.lastConnectedUser, DefaultMailboxes.INBOX),
                 ClassLoader.getSystemResourceAsStream(emlFileName),
                 Date.from(dateTime.toInstant()), false, new Flags())
                 .getMessageId();


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


[4/7] james-project git commit: JAMES-1925 Split user provisioning and mailboxes provisioning filters

Posted by ad...@apache.org.
http://git-wip-us.apache.org/repos/asf/james-project/blob/844efe2a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/DownloadGet.feature
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/DownloadGet.feature b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/DownloadGet.feature
index 82828d1..80570cc 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/DownloadGet.feature
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/DownloadGet.feature
@@ -5,26 +5,26 @@ Feature: Download GET
   Background:
     Given a domain named "domain.tld"
     And a connected user "username@domain.tld"
-    And "username@domain.tld" has a mailbox "inbox"
+    And "username@domain.tld" has a mailbox "INBOX"
 
   Scenario: Getting an attachment previously stored
-    Given "username@domain.tld" mailbox "inbox" contains a message "1" with an attachment "2"
+    Given "username@domain.tld" mailbox "INBOX" contains a message "1" with an attachment "2"
     When "username@domain.tld" downloads "2"
     Then the user should receive that attachment
 
   Scenario: Getting an attachment with an unknown blobId
-    Given "username@domain.tld" mailbox "inbox" contains a message "1" with an attachment "2"
+    Given "username@domain.tld" mailbox "INBOX" contains a message "1" with an attachment "2"
     When "username@domain.tld" downloads "2" with a valid authentication token but a bad blobId
     Then the user should receive a not found response
 
   Scenario: Getting an attachment previously stored with a desired name
-    Given "username@domain.tld" mailbox "inbox" contains a message "1" with an attachment "2"
+    Given "username@domain.tld" mailbox "INBOX" contains a message "1" with an attachment "2"
     When "username@domain.tld" downloads "2" with "myFileName.txt" name
     Then the user should receive that attachment
     And the attachment is named "myFileName.txt"
 
   Scenario: Getting an attachment previously stored with a non ASCII name
-    Given "username@domain.tld" mailbox "inbox" contains a message "1" with an attachment "2"
+    Given "username@domain.tld" mailbox "INBOX" contains a message "1" with an attachment "2"
     When "username@domain.tld" downloads "2" with "\u062f\u064a\u0646\u0627\u0635\u0648\u0631.odt" name
     Then the user should receive that attachment
     And the attachment is named "\u062f\u064a\u0646\u0627\u0635\u0648\u0631.odt"
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/844efe2a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/DownloadPost.feature
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/DownloadPost.feature b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/DownloadPost.feature
index c748014..12d655d 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/DownloadPost.feature
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/DownloadPost.feature
@@ -5,13 +5,13 @@ Feature: Alternative authentication mechanism for getting attachment via a POST
   Background:
     Given a domain named "domain.tld"
     And a connected user "username@domain.tld"
-    And "username@domain.tld" has a mailbox "inbox"
+    And "username@domain.tld" has a mailbox "INBOX"
 
   Scenario: Asking for an attachment access token with an unknown blobId
     When "username@domain.tld" asks for a token for attachment "123"
     Then the user should receive a not found response
 
   Scenario: Asking for an attachment access token with a previously stored blobId
-    Given "username@domain.tld" mailbox "inbox" contains a message "1" with an attachment "2"
+    Given "username@domain.tld" mailbox "INBOX" contains a message "1" with an attachment "2"
     When "username@domain.tld" asks for a token for attachment "2"
     Then the user should receive an attachment access token

http://git-wip-us.apache.org/repos/asf/james-project/blob/844efe2a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/GetMessages.feature
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/GetMessages.feature b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/GetMessages.feature
index 0cd93d1..8c0bb04 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/GetMessages.feature
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/GetMessages.feature
@@ -5,16 +5,16 @@ Feature: GetMessages method
   Background:
     Given a domain named "domain.tld"
     And a connected user "username@domain.tld"
-    And "username@domain.tld" has a mailbox "inbox"
+    And "username@domain.tld" has a mailbox "INBOX"
 
   Scenario: Retrieving a message in several mailboxes should return a single message in these mailboxes
     Given "username@domain.tld" has a mailbox "custom"
-    And the user has a message "m1" in "inbox" and "custom" mailboxes with subject "my test subject", content "testmail"
+    And the user has a message "m1" in "INBOX" and "custom" mailboxes with subject "my test subject", content "testmail"
     When the user ask for messages "m1"
     Then no error is returned
     And the list should contain 1 message
     And the id of the message is "m1"
-    And the message is in "custom,inbox" mailboxes
+    And the message is in "custom,INBOX" mailboxes
 
   Scenario: Retrieving messages with a non null accountId should return a NotSupported error
     When the user ask for messages using its accountId
@@ -42,7 +42,7 @@ Feature: GetMessages method
     And the notFound list should contain the requested message id
 
   Scenario: Retrieving message should return messages when exists
-    Given the user has a message "m1" in "inbox" mailbox with subject "my test subject", content "testmail"
+    Given the user has a message "m1" in "INBOX" mailbox with subject "my test subject", content "testmail"
     When the user ask for messages "m1"
     Then no error is returned
     And the list should contain 1 message
@@ -76,9 +76,9 @@ Feature: GetMessages method
 
     Examples:
       |mailbox |content-type |subject           |subject-header  |content                                                                                                                         |preview                                                                                      |
-      |"inbox" |"text/html"  |"my test subject" |my test subject |"This is a <b>HTML</b> mail"                                                                                                    |"This is a HTML mail"                                                                        |
-      |"inbox" |"text/html"  |"my test subject" |my test subject |"This is a <b>HTML</b> mail containing <u>underlined part</u>, <i>italic part</i> and <u><i>underlined AND italic part</i></u>" |"This is a HTML mail containing underlined part, italic part and underlined AND italic part" |
-      |"inbox" |"text/html"  |"my test subject" |my test subject |"This is a <ganan>HTML</b> mail"                                                                                                |"This is a HTML mail"                                                                        |
+      |"INBOX" |"text/html"  |"my test subject" |my test subject |"This is a <b>HTML</b> mail"                                                                                                    |"This is a HTML mail"                                                                        |
+      |"INBOX" |"text/html"  |"my test subject" |my test subject |"This is a <b>HTML</b> mail containing <u>underlined part</u>, <i>italic part</i> and <u><i>underlined AND italic part</i></u>" |"This is a HTML mail containing underlined part, italic part and underlined AND italic part" |
+      |"INBOX" |"text/html"  |"my test subject" |my test subject |"This is a <ganan>HTML</b> mail"                                                                                                |"This is a HTML mail"                                                                        |
 
   Scenario Outline: Retrieving message should return preview with tags when text message
     Given the user has a message "m1" in <mailbox> mailbox with content-type <content-type> subject <subject>, content <content>
@@ -89,10 +89,10 @@ Feature: GetMessages method
 
     Examples:
       |mailbox |content-type |subject           |content                                                                               |preview                                                                               |
-      |"inbox" |"text/plain" |"my test subject" |"Here is a listing of HTML tags : <b>jfjfjfj</b>, <i>jfhdgdgdfj</i>, <u>jfjaaafj</u>" |"Here is a listing of HTML tags : <b>jfjfjfj</b>, <i>jfhdgdgdfj</i>, <u>jfjaaafj</u>" |
+      |"INBOX" |"text/plain" |"my test subject" |"Here is a listing of HTML tags : <b>jfjfjfj</b>, <i>jfhdgdgdfj</i>, <u>jfjaaafj</u>" |"Here is a listing of HTML tags : <b>jfjfjfj</b>, <i>jfhdgdgdfj</i>, <u>jfjaaafj</u>" |
 
   Scenario: Retrieving message should filter properties
-    Given the user has a message "m1" in "inbox" mailbox with subject "my test subject", content "testmail"
+    Given the user has a message "m1" in "INBOX" mailbox with subject "my test subject", content "testmail"
     When the user is getting messages "m1" with properties "id, subject"
     Then no error is returned
     And the list should contain 1 message
@@ -105,7 +105,7 @@ Feature: GetMessages method
     And the property "date" of the message is null
 
   Scenario: Retrieving message should filter header properties
-    Given the user has a message "m1" in "inbox" mailbox with subject "my test subject", content "testmail", headers
+    Given the user has a message "m1" in "INBOX" mailbox with subject "my test subject", content "testmail", headers
       |From    |user@domain.tld |
       |header1 |Header1Content  |
       |HEADer2 |Header2Content  |
@@ -123,14 +123,14 @@ Feature: GetMessages method
     And the property "date" of the message is null
 
   Scenario: Retrieving message should return not found when id does not match
-    Given the user has a message "m1" in "inbox" mailbox with subject "my test subject", content "testmail"
+    Given the user has a message "m1" in "INBOX" mailbox with subject "my test subject", content "testmail"
     When the user ask for an unknown message
     Then no error is returned
     And the list of messages is empty
     And the notFound list should contain the requested message id
     
   Scenario: Retrieving message should return mandatory properties when not asked
-    Given the user has a message "m1" in "inbox" mailbox with subject "my test subject", content "testmail"
+    Given the user has a message "m1" in "INBOX" mailbox with subject "my test subject", content "testmail"
     When the user is getting messages "m1" with properties "subject"
     Then no error is returned
     And the list should contain 1 message
@@ -138,7 +138,7 @@ Feature: GetMessages method
     And the subject of the message is "my test subject"
 
   Scenario: Retrieving message should return attachments when some
-    Given the user has a message "m1" in "inbox" mailbox with two attachments
+    Given the user has a message "m1" in "INBOX" mailbox with two attachments
     When the user ask for messages "m1"
     Then no error is returned
     And the list should contain 1 message
@@ -160,7 +160,7 @@ Feature: GetMessages method
       |isInline |true                                       |
 
   Scenario: Retrieving message should return attachments and html body when some attachments and html message
-    Given the user has a message "m1" in "inbox" mailbox with two attachments
+    Given the user has a message "m1" in "INBOX" mailbox with two attachments
     When the user ask for messages "m1"
     Then no error is returned
     And the list should contain 1 message
@@ -171,7 +171,7 @@ Feature: GetMessages method
     And the htmlBody of the message is "<b>html</b>\n"
 
   Scenario: Retrieving message should return attachments and text body when some attachments and text message
-    Given the user has a message "m1" in "inbox" mailbox with two attachments in text
+    Given the user has a message "m1" in "INBOX" mailbox with two attachments in text
     When the user ask for messages "m1"
     Then no error is returned
     And the list should contain 1 message
@@ -182,7 +182,7 @@ Feature: GetMessages method
     And the property "htmlBody" of the message is null
 
   Scenario: Retrieving message should return attachments and both html/text body when some attachments and both html/text message
-    Given the user has a multipart message "m1" in "inbox" mailbox
+    Given the user has a multipart message "m1" in "INBOX" mailbox
     When the user ask for messages "m1"
     Then no error is returned
     And the list should contain 1 message
@@ -193,7 +193,7 @@ Feature: GetMessages method
     And the htmlBody of the message is "<i>blabla</i>\n<b>bloblo</b>\n"
 
   Scenario: Retrieving message should return image and html body when multipart/alternative where first part is multipart/related with html and image
-    Given the user has a multipart/related message "m1" in "inbox" mailbox
+    Given the user has a multipart/related message "m1" in "INBOX" mailbox
     When the user ask for messages "m1"
     Then no error is returned
     And the list should contain 1 message
@@ -204,7 +204,7 @@ Feature: GetMessages method
     And the htmlBody of the message is "<html>multipart/related content</html>\n"
 
   Scenario: Retrieving message should return textBody and htmlBody when incoming mail have an inlined HTML and text body without Content-ID
-    Given the user has a message "m1" in "inbox" mailbox, composed of a multipart with inlined text part and inlined html part
+    Given the user has a message "m1" in "INBOX" mailbox, composed of a multipart with inlined text part and inlined html part
     When the user ask for messages "m1"
     Then no error is returned
     And the list should contain 1 message
@@ -212,20 +212,20 @@ Feature: GetMessages method
     And the htmlBody of the message is "<html>Hello html body</html>\n"
     
   Scenario: Retrieving message with more than 1000 char by line should return message when exists
-    Given the user has a message "m1" in "inbox" mailbox beginning by a long line
+    Given the user has a message "m1" in "INBOX" mailbox beginning by a long line
     When the user ask for messages "m1"
     Then no error is returned
     And the list should contain 1 message
     And the id of the message is "m1"
 
   Scenario:
-    Given the user has a message "m1" in "inbox" mailbox with two same attachments in text
+    Given the user has a message "m1" in "INBOX" mailbox with two same attachments in text
     When the user ask for messages "m1"
     Then no error is returned
     And the list of attachments of the message contains 2 attachments
 
   Scenario: Retrieving message should read content from multipart when some inline attachment and both html/text multipart
-    Given the user has a message "m1" in "inbox" mailbox with plain/text inline attachment
+    Given the user has a message "m1" in "INBOX" mailbox with plain/text inline attachment
     When the user ask for messages "m1"
     Then no error is returned
     And the list should contain 1 message
@@ -233,7 +233,7 @@ Feature: GetMessages method
     And the htmlBody of the message is "<i>blabla</i>\n<b>bloblo</b>\n"
 
   Scenario: Retrieving message should find html body when text in main multipart and html in inner multipart
-    Given the user has a message "m1" in "inbox" mailbox with text in main multipart and html in inner multipart
+    Given the user has a message "m1" in "INBOX" mailbox with text in main multipart and html in inner multipart
     When the user ask for messages "m1"
     Then no error is returned
     And the list should contain 1 message

http://git-wip-us.apache.org/repos/asf/james-project/blob/844efe2a/server/protocols/jmap/src/main/java/org/apache/james/jmap/DefaultMailboxes.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/DefaultMailboxes.java b/server/protocols/jmap/src/main/java/org/apache/james/jmap/DefaultMailboxes.java
new file mode 100644
index 0000000..7a91514
--- /dev/null
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/DefaultMailboxes.java
@@ -0,0 +1,36 @@
+/****************************************************************
+ * 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 java.util.List;
+
+import org.apache.james.mailbox.model.MailboxConstants;
+
+import com.google.common.collect.ImmutableList;
+
+public interface DefaultMailboxes {
+
+    String INBOX = MailboxConstants.INBOX;
+    String OUTBOX = "Outbox";
+    String SENT = "Sent";
+    String TRASH = "Trash";
+    String DRAFTS = "Drafts";
+
+    List<String> DEFAULT_MAILBOXES = ImmutableList.of(INBOX, OUTBOX, SENT, TRASH, DRAFTS);
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/844efe2a/server/protocols/jmap/src/main/java/org/apache/james/jmap/DefaultMailboxesProvisioningFilter.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/DefaultMailboxesProvisioningFilter.java b/server/protocols/jmap/src/main/java/org/apache/james/jmap/DefaultMailboxesProvisioningFilter.java
new file mode 100644
index 0000000..e12014c
--- /dev/null
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/DefaultMailboxesProvisioningFilter.java
@@ -0,0 +1,106 @@
+/****************************************************************
+ * 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 java.io.IOException;
+import java.util.Optional;
+import java.util.function.Function;
+
+import javax.inject.Inject;
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+
+import org.apache.james.mailbox.MailboxManager;
+import org.apache.james.mailbox.MailboxSession;
+import org.apache.james.mailbox.MailboxSession.User;
+import org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.mailbox.model.MailboxPath;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Throwables;
+
+public class DefaultMailboxesProvisioningFilter implements Filter {
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(DefaultMailboxesProvisioningFilter.class);
+    private final MailboxManager mailboxManager;
+
+    @Inject
+    @VisibleForTesting DefaultMailboxesProvisioningFilter(MailboxManager mailboxManager) {
+        this.mailboxManager = mailboxManager;
+    }
+    
+    @Override
+    public void init(FilterConfig filterConfig) throws ServletException {
+    }
+    
+    @Override
+    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
+        Optional<MailboxSession> session = Optional.ofNullable((MailboxSession)request.getAttribute(AuthenticationFilter.MAILBOX_SESSION));
+        session.ifPresent(this::createMailboxesIfNeeded);
+        chain.doFilter(request, response);
+    }
+    
+    @VisibleForTesting
+    void createMailboxesIfNeeded(MailboxSession session) {
+        try {
+            User user = session.getUser();
+            createDefaultMailboxes(user);
+        } catch (MailboxException e) {
+            throw Throwables.propagate(e);
+        }
+    }
+
+    private void createDefaultMailboxes(User user) throws MailboxException {
+        MailboxSession session = mailboxManager.createSystemSession(user.getUserName(), LOGGER);
+        DefaultMailboxes.DEFAULT_MAILBOXES.stream()
+            .map(toMailboxPath(session))
+            .filter(mailboxPath -> mailboxDoesntExist(mailboxPath, session))
+            .forEach(mailboxPath -> createMailbox(mailboxPath, session));
+    }
+
+    private boolean mailboxDoesntExist(MailboxPath mailboxPath, MailboxSession session) {
+        try {
+            return !mailboxManager.mailboxExists(mailboxPath, session);
+        } catch (MailboxException e) {
+            throw Throwables.propagate(e);
+        }
+    }
+
+    private Function<String, MailboxPath> toMailboxPath(MailboxSession session) {
+        return mailbox -> new MailboxPath(session.getPersonalSpace(), session.getUser().getUserName(), mailbox);
+    }
+    
+    private void createMailbox(MailboxPath mailboxPath, MailboxSession session) {
+        try {
+            mailboxManager.createMailbox(mailboxPath, session);
+        } catch (MailboxException e) {
+            throw Throwables.propagate(e);
+        }
+    }
+
+    @Override
+    public void destroy() {
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/844efe2a/server/protocols/jmap/src/main/java/org/apache/james/jmap/JMAPServer.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/JMAPServer.java b/server/protocols/jmap/src/main/java/org/apache/james/jmap/JMAPServer.java
index 25242f4..de3ac75 100644
--- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/JMAPServer.java
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/JMAPServer.java
@@ -40,7 +40,7 @@ public class JMAPServer implements Configurable {
     @Inject
     private JMAPServer(JMAPConfiguration jmapConfiguration,
                        AuthenticationServlet authenticationServlet, JMAPServlet jmapServlet, DownloadServlet downloadServlet, UploadServlet uploadServlet,
-                       AuthenticationFilter authenticationFilter, UserProvisioningFilter userProvisioningFilter) {
+                       AuthenticationFilter authenticationFilter, UserProvisioningFilter userProvisioningFilter, DefaultMailboxesProvisioningFilter defaultMailboxesProvisioningFilter) {
 
         server = JettyHttpServer.create(
                 configurationBuilderFor(jmapConfiguration)
@@ -54,6 +54,7 @@ public class JMAPServer implements Configurable {
                         .filter(JMAPUrls.JMAP)
                             .with(new AllowAllCrossOriginRequests(bypass(authenticationFilter).on("OPTIONS").only()))
                             .and(userProvisioningFilter)
+                            .and(defaultMailboxesProvisioningFilter)
                             .only()
                         .serveAsOneLevelTemplate(JMAPUrls.DOWNLOAD)
                             .with(downloadServlet)

http://git-wip-us.apache.org/repos/asf/james-project/blob/844efe2a/server/protocols/jmap/src/main/java/org/apache/james/jmap/UserProvisioningFilter.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/UserProvisioningFilter.java b/server/protocols/jmap/src/main/java/org/apache/james/jmap/UserProvisioningFilter.java
index 6145a79..726d37f 100644
--- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/UserProvisioningFilter.java
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/UserProvisioningFilter.java
@@ -21,7 +21,6 @@ package org.apache.james.jmap;
 import java.io.IOException;
 import java.util.Optional;
 import java.util.UUID;
-import java.util.function.Function;
 
 import javax.inject.Inject;
 import javax.servlet.Filter;
@@ -31,33 +30,24 @@ import javax.servlet.ServletException;
 import javax.servlet.ServletRequest;
 import javax.servlet.ServletResponse;
 
-import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.MailboxSession.User;
 import org.apache.james.mailbox.exception.BadCredentialsException;
 import org.apache.james.mailbox.exception.MailboxException;
-import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.user.api.AlreadyExistInUsersRepositoryException;
 import org.apache.james.user.api.UsersRepository;
 import org.apache.james.user.api.UsersRepositoryException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Throwables;
-import com.google.common.collect.ImmutableList;
 
 public class UserProvisioningFilter implements Filter {
 
-    private static final ImmutableList<String> DEFAULT_MAILBOXES = ImmutableList.of("INBOX", "Outbox", "Sent", "Trash");
-    private static final Logger LOGGER = LoggerFactory.getLogger(UserProvisioningFilter.class);
     private final UsersRepository usersRepository;
-    private final MailboxManager mailboxManager;
 
     @Inject
-    @VisibleForTesting UserProvisioningFilter(UsersRepository usersRepository, MailboxManager mailboxManager) {
+    @VisibleForTesting UserProvisioningFilter(UsersRepository usersRepository) {
         this.usersRepository = usersRepository;
-        this.mailboxManager = mailboxManager;
     }
     
     @Override
@@ -91,7 +81,6 @@ public class UserProvisioningFilter implements Filter {
 
     private void createAccount(User user) throws UsersRepositoryException, BadCredentialsException, MailboxException {
         createUser(user);
-        createDefaultMailboxes(user);
     }
 
     private void createUser(User user) throws UsersRepositoryException {
@@ -101,25 +90,6 @@ public class UserProvisioningFilter implements Filter {
     private String generatePassword() {
         return UUID.randomUUID().toString();
     }
-    
-    private void createDefaultMailboxes(User user) throws BadCredentialsException, MailboxException {
-        MailboxSession session = mailboxManager.createSystemSession(user.getUserName(), LOGGER);
-        DEFAULT_MAILBOXES.stream()
-            .map(toMailboxPath(session))
-            .forEach(mailboxPath -> createMailbox(mailboxPath, session));
-    }
-
-    private Function<String, MailboxPath> toMailboxPath(MailboxSession session) {
-        return mailbox -> new MailboxPath(session.getPersonalSpace(), session.getUser().getUserName(), mailbox);
-    }
-    
-    private void createMailbox(MailboxPath mailboxPath, MailboxSession session) {
-        try {
-            mailboxManager.createMailbox(mailboxPath, session);
-        } catch (MailboxException e) {
-            throw Throwables.propagate(e);
-        }
-    }
 
     @Override
     public void destroy() {

http://git-wip-us.apache.org/repos/asf/james-project/blob/844efe2a/server/protocols/jmap/src/test/java/org/apache/james/jmap/DefaultMailboxesProvisioningFilterThreadTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/DefaultMailboxesProvisioningFilterThreadTest.java b/server/protocols/jmap/src/test/java/org/apache/james/jmap/DefaultMailboxesProvisioningFilterThreadTest.java
new file mode 100644
index 0000000..ab0c546
--- /dev/null
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/DefaultMailboxesProvisioningFilterThreadTest.java
@@ -0,0 +1,268 @@
+/****************************************************************
+ * 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 java.util.EnumSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.james.mailbox.MailboxListener;
+import org.apache.james.mailbox.MailboxManager;
+import org.apache.james.mailbox.MailboxSession;
+import org.apache.james.mailbox.MessageManager;
+import org.apache.james.mailbox.exception.BadCredentialsException;
+import org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.mailbox.mock.MockMailboxSession;
+import org.apache.james.mailbox.model.MailboxACL.MailboxACLCommand;
+import org.apache.james.mailbox.model.MailboxACL.MailboxACLEntryKey;
+import org.apache.james.mailbox.model.MailboxACL.MailboxACLRight;
+import org.apache.james.mailbox.model.MailboxACL.MailboxACLRights;
+import org.apache.james.mailbox.model.MailboxAnnotation;
+import org.apache.james.mailbox.model.MailboxAnnotationKey;
+import org.apache.james.mailbox.model.MailboxId;
+import org.apache.james.mailbox.model.MailboxMetaData;
+import org.apache.james.mailbox.model.MailboxPath;
+import org.apache.james.mailbox.model.MailboxQuery;
+import org.apache.james.mailbox.model.MessageId;
+import org.apache.james.mailbox.model.MessageRange;
+import org.apache.james.mailbox.model.MultimailboxesSearchQuery;
+import org.junit.Test;
+import org.slf4j.Logger;
+
+import com.google.testing.threadtester.AnnotatedTestRunner;
+import com.google.testing.threadtester.ThreadedAfter;
+import com.google.testing.threadtester.ThreadedBefore;
+import com.google.testing.threadtester.ThreadedMain;
+import com.google.testing.threadtester.ThreadedSecondary;
+
+public class DefaultMailboxesProvisioningFilterThreadTest {
+
+    private DefaultMailboxesProvisioningFilter sut;
+    private MailboxSession session;
+    private MailboxManager mailboxManager;
+
+    @ThreadedBefore
+    public void before() {
+        session = new MockMailboxSession("username");
+        mailboxManager = new FakeMailboxManager(session) ;
+        sut = new DefaultMailboxesProvisioningFilter(mailboxManager);
+    }
+    
+    @ThreadedMain
+    public void mainThread() {
+        sut.createMailboxesIfNeeded(session);
+    }
+    
+    @ThreadedSecondary
+    public void secondThread() {
+        sut.createMailboxesIfNeeded(session);
+    }
+    
+    @ThreadedAfter
+    public void after() {
+        // Exception is thrown if test fails
+    }
+    
+    @Test
+    public void testConcurrentAccessToFilterShouldNotThrow() {
+        AnnotatedTestRunner runner = new AnnotatedTestRunner();
+        runner.runTests(this.getClass(), DefaultMailboxesProvisioningFilter.class);
+    }
+    
+    private static class FakeMailboxManager implements MailboxManager {
+        private MailboxSession mailboxSession;
+
+        public FakeMailboxManager(MailboxSession mailboxSession) {
+            this.mailboxSession = mailboxSession;
+        }
+
+        @Override
+        public EnumSet<SearchCapabilities> getSupportedSearchCapabilities() {
+            return EnumSet.noneOf(SearchCapabilities.class);
+        }
+        
+        @Override
+        public void startProcessingRequest(MailboxSession session) {
+        }
+
+        @Override
+        public void endProcessingRequest(MailboxSession session) {
+        }
+
+        @Override
+        public void addListener(MailboxPath mailboxPath, MailboxListener listener, MailboxSession session) throws MailboxException {
+        }
+
+        @Override
+        public void removeListener(MailboxPath mailboxPath, MailboxListener listner, MailboxSession session) throws MailboxException {
+        }
+
+        @Override
+        public void addGlobalListener(MailboxListener listener, MailboxSession session) throws MailboxException {
+        }
+
+        @Override
+        public void removeGlobalListener(MailboxListener listner, MailboxSession session) throws MailboxException {
+        }
+
+        @Override
+        public char getDelimiter() {
+            return 0;
+        }
+
+        @Override
+        public MessageManager getMailbox(MailboxPath mailboxPath, MailboxSession session) throws MailboxException {
+            return null;
+        }
+
+        @Override
+        public MessageManager getMailbox(MailboxId mailboxId, MailboxSession session) throws MailboxException {
+            return null;
+        }
+
+        @Override
+        public void createMailbox(MailboxPath mailboxPath, MailboxSession mailboxSession) throws MailboxException {
+        }
+
+        @Override
+        public void deleteMailbox(MailboxPath mailboxPath, MailboxSession session) throws MailboxException {
+        }
+
+        @Override
+        public void renameMailbox(MailboxPath from, MailboxPath to, MailboxSession session) throws MailboxException {
+        }
+
+        @Override
+        public List<MessageRange> copyMessages(MessageRange set, MailboxPath from, MailboxPath to, MailboxSession session) throws MailboxException {
+            return null;
+        }
+
+        @Override
+        public List<MessageRange> copyMessages(MessageRange set, MailboxId from, MailboxId to, MailboxSession session)
+                throws MailboxException {
+            return null;
+        }
+        
+        @Override
+        public List<MessageRange> moveMessages(MessageRange set, MailboxPath from, MailboxPath to, MailboxSession session) throws MailboxException {
+            return null;
+        }
+
+        @Override
+        public List<MailboxMetaData> search(MailboxQuery expression, MailboxSession session) throws MailboxException {
+            return null;
+        }
+
+        @Override
+        public boolean mailboxExists(MailboxPath mailboxPath, MailboxSession session) throws MailboxException {
+            return false;
+        }
+
+        @Override
+        public MailboxSession createSystemSession(String userName, Logger log) throws BadCredentialsException, MailboxException {
+            return mailboxSession;
+        }
+
+        @Override
+        public MailboxSession login(String userid, String passwd, Logger log) throws BadCredentialsException, MailboxException {
+            return null;
+        }
+
+        @Override
+        public void logout(MailboxSession session, boolean force) throws MailboxException {
+        }
+
+        @Override
+        public boolean hasRight(MailboxPath mailboxPath, MailboxACLRight right, MailboxSession session) throws MailboxException {
+            return false;
+        }
+
+        @Override
+        public MailboxACLRights myRights(MailboxPath mailboxPath, MailboxSession session) throws MailboxException {
+            return null;
+        }
+
+        @Override
+        public MailboxACLRights[] listRigths(MailboxPath mailboxPath, MailboxACLEntryKey identifier, MailboxSession session) throws MailboxException {
+            return null;
+        }
+
+        @Override
+        public void setRights(MailboxPath mailboxPath, MailboxACLCommand mailboxACLCommand, MailboxSession session) throws MailboxException {
+        }
+
+        @Override
+        public List<MailboxPath> list(MailboxSession session) throws MailboxException {
+            return null;
+        }
+
+        @Override
+        public EnumSet<MailboxCapabilities> getSupportedMailboxCapabilities() {
+            return null;
+        }
+        
+        @Override
+        public EnumSet<MessageCapabilities> getSupportedMessageCapabilities() {
+            return null;
+        }
+
+        @Override
+        public List<MailboxAnnotation> getAllAnnotations(MailboxPath mailboxPath, MailboxSession session) throws MailboxException {
+            return null;
+        }
+
+        @Override
+        public List<MailboxAnnotation> getAnnotationsByKeys(MailboxPath mailboxPath, MailboxSession session, Set<MailboxAnnotationKey> keys) throws MailboxException {
+            return null;
+        }
+
+        @Override
+        public void updateAnnotations(MailboxPath mailboxPath, MailboxSession session, List<MailboxAnnotation> mailboxAnnotations) throws MailboxException {
+            
+        }
+
+        @Override
+        public boolean hasCapability(MailboxCapabilities capability) {
+            return false;
+        }
+
+        @Override
+        public List<MessageId> search(MultimailboxesSearchQuery expression, MailboxSession session, long limit) throws MailboxException {
+            return null;
+        }
+
+        @Override
+        public List<MailboxAnnotation> getAnnotationsByKeysWithOneDepth(MailboxPath mailboxPath, MailboxSession session,
+                Set<MailboxAnnotationKey> keys) throws MailboxException {
+            return null;
+        }
+
+        @Override
+        public List<MailboxAnnotation> getAnnotationsByKeysWithAllDepth(MailboxPath mailboxPath, MailboxSession session,
+                Set<MailboxAnnotationKey> keys) throws MailboxException {
+            return null;
+        }
+
+        @Override
+        public boolean hasChildren(MailboxPath mailboxPath, MailboxSession session) throws MailboxException {
+            return false;
+        }
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/james-project/blob/844efe2a/server/protocols/jmap/src/test/java/org/apache/james/jmap/UserProvisioningFilterTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/UserProvisioningFilterTest.java b/server/protocols/jmap/src/test/java/org/apache/james/jmap/UserProvisioningFilterTest.java
index ffc37b0..b5f6964 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/UserProvisioningFilterTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/UserProvisioningFilterTest.java
@@ -29,7 +29,6 @@ import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.user.api.UsersRepositoryException;
 import org.apache.james.user.lib.mock.InMemoryUsersRepository;
 import org.junit.Before;
@@ -43,8 +42,7 @@ public class UserProvisioningFilterTest {
     @Before
     public void setup() {
         usersRepository = new InMemoryUsersRepository();
-        MailboxManager mailboxManager = mock(MailboxManager.class);
-        sut = new UserProvisioningFilter(usersRepository, mailboxManager);
+        sut = new UserProvisioningFilter(usersRepository);
     }
     
     @Test

http://git-wip-us.apache.org/repos/asf/james-project/blob/844efe2a/server/protocols/jmap/src/test/java/org/apache/james/jmap/UserProvisioningFilterThreadTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/UserProvisioningFilterThreadTest.java b/server/protocols/jmap/src/test/java/org/apache/james/jmap/UserProvisioningFilterThreadTest.java
index eb5ec5c..d375a09 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/UserProvisioningFilterThreadTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/UserProvisioningFilterThreadTest.java
@@ -18,33 +18,10 @@
  ****************************************************************/
 package org.apache.james.jmap;
 
-import java.util.EnumSet;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.james.mailbox.MailboxListener;
-import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.MailboxSession;
-import org.apache.james.mailbox.MessageManager;
-import org.apache.james.mailbox.exception.BadCredentialsException;
-import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.mock.MockMailboxSession;
-import org.apache.james.mailbox.model.MailboxACL.MailboxACLCommand;
-import org.apache.james.mailbox.model.MailboxACL.MailboxACLEntryKey;
-import org.apache.james.mailbox.model.MailboxACL.MailboxACLRight;
-import org.apache.james.mailbox.model.MailboxACL.MailboxACLRights;
-import org.apache.james.mailbox.model.MailboxAnnotation;
-import org.apache.james.mailbox.model.MailboxAnnotationKey;
-import org.apache.james.mailbox.model.MailboxId;
-import org.apache.james.mailbox.model.MailboxMetaData;
-import org.apache.james.mailbox.model.MailboxPath;
-import org.apache.james.mailbox.model.MailboxQuery;
-import org.apache.james.mailbox.model.MessageId;
-import org.apache.james.mailbox.model.MessageRange;
-import org.apache.james.mailbox.model.MultimailboxesSearchQuery;
 import org.apache.james.user.lib.mock.InMemoryUsersRepository;
 import org.junit.Test;
-import org.slf4j.Logger;
 
 import com.google.testing.threadtester.AnnotatedTestRunner;
 import com.google.testing.threadtester.ThreadedAfter;
@@ -57,14 +34,12 @@ public class UserProvisioningFilterThreadTest {
     private UserProvisioningFilter sut;
     private InMemoryUsersRepository usersRepository;
     private MailboxSession session;
-    private MailboxManager mailboxManager;
 
     @ThreadedBefore
     public void before() {
         usersRepository = new InMemoryUsersRepository();
         session = new MockMailboxSession("username");
-        mailboxManager = new FakeMailboxManager(session) ;
-        sut = new UserProvisioningFilter(usersRepository, mailboxManager);
+        sut = new UserProvisioningFilter(usersRepository);
     }
     
     @ThreadedMain
@@ -87,185 +62,5 @@ public class UserProvisioningFilterThreadTest {
         AnnotatedTestRunner runner = new AnnotatedTestRunner();
         runner.runTests(this.getClass(), UserProvisioningFilter.class);
     }
-    
-    private static class FakeMailboxManager implements MailboxManager {
-        private MailboxSession mailboxSession;
-
-        public FakeMailboxManager(MailboxSession mailboxSession) {
-            this.mailboxSession = mailboxSession;
-        }
-
-        @Override
-        public EnumSet<SearchCapabilities> getSupportedSearchCapabilities() {
-            return EnumSet.noneOf(SearchCapabilities.class);
-        }
-        
-        @Override
-        public void startProcessingRequest(MailboxSession session) {
-        }
-
-        @Override
-        public void endProcessingRequest(MailboxSession session) {
-        }
-
-        @Override
-        public void addListener(MailboxPath mailboxPath, MailboxListener listener, MailboxSession session) throws MailboxException {
-        }
-
-        @Override
-        public void removeListener(MailboxPath mailboxPath, MailboxListener listner, MailboxSession session) throws MailboxException {
-        }
-
-        @Override
-        public void addGlobalListener(MailboxListener listener, MailboxSession session) throws MailboxException {
-        }
-
-        @Override
-        public void removeGlobalListener(MailboxListener listner, MailboxSession session) throws MailboxException {
-        }
-
-        @Override
-        public char getDelimiter() {
-            return 0;
-        }
-
-        @Override
-        public MessageManager getMailbox(MailboxPath mailboxPath, MailboxSession session) throws MailboxException {
-            return null;
-        }
-
-        @Override
-        public MessageManager getMailbox(MailboxId mailboxId, MailboxSession session) throws MailboxException {
-            return null;
-        }
-
-        @Override
-        public void createMailbox(MailboxPath mailboxPath, MailboxSession mailboxSession) throws MailboxException {
-        }
-
-        @Override
-        public void deleteMailbox(MailboxPath mailboxPath, MailboxSession session) throws MailboxException {
-        }
-
-        @Override
-        public void renameMailbox(MailboxPath from, MailboxPath to, MailboxSession session) throws MailboxException {
-        }
-
-        @Override
-        public List<MessageRange> copyMessages(MessageRange set, MailboxPath from, MailboxPath to, MailboxSession session) throws MailboxException {
-            return null;
-        }
-
-        @Override
-        public List<MessageRange> copyMessages(MessageRange set, MailboxId from, MailboxId to, MailboxSession session)
-                throws MailboxException {
-            return null;
-        }
-        
-        @Override
-        public List<MessageRange> moveMessages(MessageRange set, MailboxPath from, MailboxPath to, MailboxSession session) throws MailboxException {
-            return null;
-        }
-
-        @Override
-        public List<MailboxMetaData> search(MailboxQuery expression, MailboxSession session) throws MailboxException {
-            return null;
-        }
-
-        @Override
-        public boolean mailboxExists(MailboxPath mailboxPath, MailboxSession session) throws MailboxException {
-            return false;
-        }
-
-        @Override
-        public MailboxSession createSystemSession(String userName, Logger log) throws BadCredentialsException, MailboxException {
-            return mailboxSession;
-        }
-
-        @Override
-        public MailboxSession login(String userid, String passwd, Logger log) throws BadCredentialsException, MailboxException {
-            return null;
-        }
-
-        @Override
-        public void logout(MailboxSession session, boolean force) throws MailboxException {
-        }
-
-        @Override
-        public boolean hasRight(MailboxPath mailboxPath, MailboxACLRight right, MailboxSession session) throws MailboxException {
-            return false;
-        }
-
-        @Override
-        public MailboxACLRights myRights(MailboxPath mailboxPath, MailboxSession session) throws MailboxException {
-            return null;
-        }
-
-        @Override
-        public MailboxACLRights[] listRigths(MailboxPath mailboxPath, MailboxACLEntryKey identifier, MailboxSession session) throws MailboxException {
-            return null;
-        }
-
-        @Override
-        public void setRights(MailboxPath mailboxPath, MailboxACLCommand mailboxACLCommand, MailboxSession session) throws MailboxException {
-        }
-
-        @Override
-        public List<MailboxPath> list(MailboxSession session) throws MailboxException {
-            return null;
-        }
-
-        @Override
-        public EnumSet<MailboxCapabilities> getSupportedMailboxCapabilities() {
-            return null;
-        }
-        
-        @Override
-        public EnumSet<MessageCapabilities> getSupportedMessageCapabilities() {
-            return null;
-        }
-
-        @Override
-        public List<MailboxAnnotation> getAllAnnotations(MailboxPath mailboxPath, MailboxSession session) throws MailboxException {
-            return null;
-        }
-
-        @Override
-        public List<MailboxAnnotation> getAnnotationsByKeys(MailboxPath mailboxPath, MailboxSession session, Set<MailboxAnnotationKey> keys) throws MailboxException {
-            return null;
-        }
-
-        @Override
-        public void updateAnnotations(MailboxPath mailboxPath, MailboxSession session, List<MailboxAnnotation> mailboxAnnotations) throws MailboxException {
-            
-        }
-
-        @Override
-        public boolean hasCapability(MailboxCapabilities capability) {
-            return false;
-        }
-
-        @Override
-        public List<MessageId> search(MultimailboxesSearchQuery expression, MailboxSession session, long limit) throws MailboxException {
-            return null;
-        }
-
-        @Override
-        public List<MailboxAnnotation> getAnnotationsByKeysWithOneDepth(MailboxPath mailboxPath, MailboxSession session,
-                Set<MailboxAnnotationKey> keys) throws MailboxException {
-            return null;
-        }
-
-        @Override
-        public List<MailboxAnnotation> getAnnotationsByKeysWithAllDepth(MailboxPath mailboxPath, MailboxSession session,
-                Set<MailboxAnnotationKey> keys) throws MailboxException {
-            return null;
-        }
-
-        @Override
-        public boolean hasChildren(MailboxPath mailboxPath, MailboxSession session) throws MailboxException {
-            return false;
-        }
-    }
 }
 


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


[3/7] james-project git commit: JAMES-1925 Rely on cassandra profile for JMAP integration tests

Posted by ad...@apache.org.
JAMES-1925 Rely on cassandra profile for JMAP integration tests


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

Branch: refs/heads/master
Commit: c10cfae17db2cc950cb2f35dd75bd1e1786c4c1c
Parents: 844efe2
Author: Benoit Tellier <bt...@linagora.com>
Authored: Wed Feb 8 09:21:05 2017 +0700
Committer: Antoine Duprat <ad...@linagora.com>
Committed: Thu Feb 9 09:44:50 2017 +0100

----------------------------------------------------------------------
 server/protocols/jmap-integration-testing/pom.xml | 1 -
 1 file changed, 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/c10cfae1/server/protocols/jmap-integration-testing/pom.xml
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/pom.xml b/server/protocols/jmap-integration-testing/pom.xml
index 7a76231..a9df9da 100644
--- a/server/protocols/jmap-integration-testing/pom.xml
+++ b/server/protocols/jmap-integration-testing/pom.xml
@@ -33,7 +33,6 @@
     <packaging>pom</packaging>
 
     <modules>
-        <module>cassandra-jmap-integration-testing</module>
         <module>jmap-integration-testing-common</module>
     </modules>
 


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