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 jo...@apache.org on 2006/11/21 16:51:08 UTC

svn commit: r477708 - in /james/server/trunk/src: java/org/apache/james/imapserver/commands/UnsubscribeCommand.java test/org/apache/james/imapserver/handler/commands/UnsubscribeCommandTest.java

Author: joachim
Date: Tue Nov 21 07:51:07 2006
New Revision: 477708

URL: http://svn.apache.org/viewvc?view=rev&rev=477708
Log:
unsubscribe has to call buildFullName (fix + test)

Added:
    james/server/trunk/src/test/org/apache/james/imapserver/handler/commands/UnsubscribeCommandTest.java
Modified:
    james/server/trunk/src/java/org/apache/james/imapserver/commands/UnsubscribeCommand.java

Modified: james/server/trunk/src/java/org/apache/james/imapserver/commands/UnsubscribeCommand.java
URL: http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/imapserver/commands/UnsubscribeCommand.java?view=diff&rev=477708&r1=477707&r2=477708
==============================================================================
--- james/server/trunk/src/java/org/apache/james/imapserver/commands/UnsubscribeCommand.java (original)
+++ james/server/trunk/src/java/org/apache/james/imapserver/commands/UnsubscribeCommand.java Tue Nov 21 07:51:07 2006
@@ -40,12 +40,12 @@
     protected void doProcess( ImapRequestLineReader request,
                               ImapResponse response,
                               ImapSession session )
-            throws ProtocolException, MailboxException
-    {
+            throws ProtocolException, MailboxException  {
         String mailboxName = parser.mailbox( request );
         parser.endLine( request );
 
         try {
+            mailboxName=session.buildFullName(mailboxName);
             session.getMailboxManager().setSubscription(mailboxName,false);
         } catch (MailboxManagerException e) {
             throw new MailboxException(e);
@@ -55,14 +55,12 @@
     }
 
     /** @see ImapCommand#getName */
-    public String getName()
-    {
+    public String getName() {
         return NAME;
     }
 
     /** @see CommandTemplate#getArgSyntax */
-    public String getArgSyntax()
-    {
+    public String getArgSyntax() {
         return ARGS;
     }
 }

Added: james/server/trunk/src/test/org/apache/james/imapserver/handler/commands/UnsubscribeCommandTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/src/test/org/apache/james/imapserver/handler/commands/UnsubscribeCommandTest.java?view=auto&rev=477708
==============================================================================
--- james/server/trunk/src/test/org/apache/james/imapserver/handler/commands/UnsubscribeCommandTest.java (added)
+++ james/server/trunk/src/test/org/apache/james/imapserver/handler/commands/UnsubscribeCommandTest.java Tue Nov 21 07:51:07 2006
@@ -0,0 +1,47 @@
+/****************************************************************
+ * 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.imapserver.handler.commands;
+
+import org.apache.james.imapserver.ImapSessionState;
+import org.apache.james.imapserver.ProtocolException;
+import org.jmock.core.Constraint;
+
+public class UnsubscribeCommandTest extends AbstractCommandTest {
+
+    public void testSubscribeNonFq() throws ProtocolException {
+        final String fqMailboxName = "#mock.user.Test";
+
+        setSessionState(ImapSessionState.AUTHENTICATED);
+        setUpMailboxManager();
+
+        mockSession.expects(once()).method("buildFullName").with(eq("Test"))
+                .will(returnValue(fqMailboxName));
+        mockSession.expects(once()).method("unsolicitedResponses")
+                .withAnyArguments();
+
+        mockMailboxManager.expects(once()).method("setSubscription").with(
+                new Constraint[] {eq(fqMailboxName),eq(false)});
+
+        String response = handleRequest("1 UNSUBSCRIBE Test\n");
+
+        assertEquals("1 OK UNSUBSCRIBE completed.\r\n", response);
+    }
+
+}



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