james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nor...@apache.org
Subject svn commit: r962439 - /james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/NamespaceProcessorTest.java
Date Fri, 09 Jul 2010 08:08:07 GMT
Author: norman
Date: Fri Jul  9 08:08:07 2010
New Revision: 962439

URL: http://svn.apache.org/viewvc?rev=962439&view=rev
Log:
Fix Test which got broken by the namespace string patch.. Sorry for that

Modified:
    james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/NamespaceProcessorTest.java

Modified: james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/NamespaceProcessorTest.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/NamespaceProcessorTest.java?rev=962439&r1=962438&r2=962439&view=diff
==============================================================================
--- james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/NamespaceProcessorTest.java
(original)
+++ james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/NamespaceProcessorTest.java
Fri Jul  9 08:08:07 2010
@@ -21,6 +21,7 @@ package org.apache.james.imap.processor;
 import static org.junit.Assert.*;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.List;
 
@@ -34,6 +35,7 @@ import org.apache.james.imap.api.message
 import org.apache.james.imap.api.process.ImapProcessor;
 import org.apache.james.imap.api.process.ImapSession;
 import org.apache.james.imap.api.process.ImapProcessor.Responder;
+import org.apache.james.imap.mailbox.MailboxConstants;
 import org.apache.james.imap.mailbox.MailboxManager;
 import org.apache.james.imap.mailbox.MailboxSession;
 import org.apache.james.imap.message.request.NamespaceRequest;
@@ -50,12 +52,9 @@ import org.junit.runner.RunWith;
 @RunWith(JMock.class)
 public class NamespaceProcessorTest {
 
-    private static final char SHARED_SPACE_DELIMINATOR = '&';
     private static final String SHARED_PREFIX = "SharedPrefix";
     private static final String USERS_PREFIX = "UsersPrefix";
     private static final String PERSONAL_PREFIX = "PersonalPrefix";
-    private static final char USERS_DELIMINATOR = '%';
-    private static final char PERSONAL_DELIMINATOR = '$';
     
     
     NamespaceProcessor subject;
@@ -67,25 +66,29 @@ public class NamespaceProcessorTest {
     String sharedSpaceStub;
     NamespaceRequest namespaceRequest;
     Collection<String> sharedSpaces;
-    
+    MailboxManager mailboxManagerStub;
     Mockery mockery = new JUnit4Mockery();
     
     @Before
     public void setUp() throws Exception {
         sharedSpaces = new ArrayList<String>();
         statusResponseStub = mockery.mock(StatusResponseFactory.class);
-        final MailboxManager mailboxManagerStub = mockery.mock(MailboxManager.class);
+        mailboxManagerStub = mockery.mock(MailboxManager.class);
         subject = new NamespaceProcessor(mockery.mock(ImapProcessor.class), mailboxManagerStub,
statusResponseStub);
         imapSessionStub = mockery.mock(ImapSession.class);
         mailboxSessionStub = mockery.mock(MailboxSession.class);
      
         namespaceRequest = new NamespaceRequest(ImapCommand.anyStateCommand("Name"), "TAG");
-        
+       
+    }
+    
+    @Test
+    public void testShouldAcceptNamespaceRequests() throws Exception {
         mockery.checking (new Expectations() {{
             allowing(imapSessionStub).getAttribute(ImapSessionUtils.MAILBOX_SESSION_ATTRIBUTE_SESSION_KEY);
will(returnValue(mailboxSessionStub));
-            allowing(mailboxSessionStub).getPersonalSpace(); will(returnValue("PersonalNamespace"));
-            allowing(mailboxSessionStub).getOtherUsersSpace(); will(returnValue("UsersNamespace"));
-            allowing(mailboxSessionStub).getSharedSpaces();will(returnValue("SharedNamespace"));
+            allowing(mailboxSessionStub).getPersonalSpace(); will(returnValue(PERSONAL_PREFIX));
+            allowing(mailboxSessionStub).getOtherUsersSpace(); will(returnValue(USERS_PREFIX));
+            allowing(mailboxSessionStub).getSharedSpaces();will(returnValue(Arrays.asList(SHARED_PREFIX)));
             allowing(imapSessionStub).getState();will(returnValue(ImapSessionState.AUTHENTICATED));
             allowing(statusResponseStub).taggedOk(
                     with(any(String.class)), with(any(ImapCommand.class)), 
@@ -95,16 +98,27 @@ public class NamespaceProcessorTest {
             ignoring(mailboxManagerStub);
             ignoring(statusResponseStub);
         }});
-    }
-    
-    @Test
-    public void testShouldAcceptNamespaceRequests() throws Exception {
         assertFalse(subject.isAcceptable(mockery.mock(ImapMessage.class)));
         assertTrue(subject.isAcceptable(namespaceRequest));
     }
     
     @Test
     public void testNamespaceResponseShouldContainPersonalAndUserSpaces() throws Exception
{
+        mockery.checking (new Expectations() {{
+            allowing(imapSessionStub).getAttribute(ImapSessionUtils.MAILBOX_SESSION_ATTRIBUTE_SESSION_KEY);
will(returnValue(mailboxSessionStub));
+            allowing(mailboxSessionStub).getPersonalSpace(); will(returnValue(PERSONAL_PREFIX));
+            allowing(mailboxSessionStub).getOtherUsersSpace(); will(returnValue(USERS_PREFIX));
+            allowing(mailboxSessionStub).getSharedSpaces();will(returnValue(new ArrayList<String>()));
+            allowing(imapSessionStub).getState();will(returnValue(ImapSessionState.AUTHENTICATED));
+            allowing(statusResponseStub).taggedOk(
+                    with(any(String.class)), with(any(ImapCommand.class)), 
+                    with(any(HumanReadableText.class)), with(any(ResponseCode.class))); will(returnValue(mockery.mock(StatusResponse.class)));
+            ignoring(imapSessionStub);
+            ignoring(mailboxSessionStub);
+            ignoring(mailboxManagerStub);
+            ignoring(statusResponseStub);
+        }});
+        
         final NamespaceResponse response = buildResponse(null);
         
         final Responder responderMock = expectResponse(response);
@@ -114,11 +128,25 @@ public class NamespaceProcessorTest {
     
     @Test
     public void testNamespaceResponseShouldContainSharedSpaces() throws Exception {
+        mockery.checking (new Expectations() {{
+            allowing(imapSessionStub).getAttribute(ImapSessionUtils.MAILBOX_SESSION_ATTRIBUTE_SESSION_KEY);
will(returnValue(mailboxSessionStub));
+            allowing(mailboxSessionStub).getPersonalSpace(); will(returnValue(PERSONAL_PREFIX));
+            allowing(mailboxSessionStub).getOtherUsersSpace(); will(returnValue(USERS_PREFIX));
+            allowing(mailboxSessionStub).getSharedSpaces();will(returnValue(Arrays.asList(SHARED_PREFIX)));
+            allowing(imapSessionStub).getState();will(returnValue(ImapSessionState.AUTHENTICATED));
+            allowing(statusResponseStub).taggedOk(
+                    with(any(String.class)), with(any(ImapCommand.class)), 
+                    with(any(HumanReadableText.class)), with(any(ResponseCode.class))); will(returnValue(mockery.mock(StatusResponse.class)));
+            ignoring(imapSessionStub);
+            ignoring(mailboxSessionStub);
+            ignoring(mailboxManagerStub);
+            ignoring(statusResponseStub);
+        }});
         this.sharedSpaces.add(sharedSpaceStub);
         
         
         final List<NamespaceResponse.Namespace> sharedSpaces = new ArrayList<NamespaceResponse.Namespace>();
-        sharedSpaces.add(new NamespaceResponse.Namespace(SHARED_PREFIX, SHARED_SPACE_DELIMINATOR));
+        sharedSpaces.add(new NamespaceResponse.Namespace(SHARED_PREFIX, MailboxConstants.DEFAULT_DELIMITER));
         final NamespaceResponse response = buildResponse(sharedSpaces);
         
         final Responder responderMock = expectResponse(response);
@@ -127,10 +155,11 @@ public class NamespaceProcessorTest {
     }
 
     private NamespaceResponse buildResponse(final List<NamespaceResponse.Namespace>
sharedSpaces) {
+       
         final List<NamespaceResponse.Namespace> personalSpaces = new ArrayList<NamespaceResponse.Namespace>();
-        personalSpaces.add(new NamespaceResponse.Namespace(PERSONAL_PREFIX, PERSONAL_DELIMINATOR));
+        personalSpaces.add(new NamespaceResponse.Namespace(PERSONAL_PREFIX, MailboxConstants.DEFAULT_DELIMITER));
         final List<NamespaceResponse.Namespace> otherUsersSpaces = new ArrayList<NamespaceResponse.Namespace>();
-        otherUsersSpaces.add(new NamespaceResponse.Namespace(USERS_PREFIX, USERS_DELIMINATOR));

+        otherUsersSpaces.add(new NamespaceResponse.Namespace(USERS_PREFIX, MailboxConstants.DEFAULT_DELIMITER));

         
         final NamespaceResponse response = new NamespaceResponse(personalSpaces, otherUsersSpaces,
sharedSpaces);
         return response;



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


Mime
View raw message