mina-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n..@apache.org
Subject svn commit: r821620 - in /mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src: main/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/ main/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/handler/ main/java/org/apache/vysper/x...
Date Sun, 04 Oct 2009 21:27:20 GMT
Author: ngn
Date: Sun Oct  4 21:27:20 2009
New Revision: 821620

URL: http://svn.apache.org/viewvc?rev=821620&view=rev
Log:
Implement room subject change (VYSPER-155, VYSPER-123)

Added:
    mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/test/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/handler/AbstractMUCMessageHandlerTestCase.java
    mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/test/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/handler/MUCSubjectMessageHandlerTestCase.java
Modified:
    mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/ServerMain.java
    mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/handler/MUCMessageHandler.java
    mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/model/Occupant.java
    mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/model/Room.java
    mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/model/RoomType.java
    mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/stanzas/History.java
    mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/test/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/handler/AbstractMUCHandlerTestCase.java
    mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/test/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/handler/MUCMessageHandlerTestCase.java
    mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/test/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/handler/MUCPresenceHandlerEnterRoomTestCase.java
    mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/test/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/model/DiscussionMessageTestCase.java

Modified: mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/ServerMain.java
URL: http://svn.apache.org/viewvc/mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/ServerMain.java?rev=821620&r1=821619&r2=821620&view=diff
==============================================================================
--- mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/ServerMain.java
(original)
+++ mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/ServerMain.java
Sun Oct  4 21:27:20 2009
@@ -62,6 +62,7 @@
         final AccountManagement accountManagement = (AccountManagement)providerRegistry.retrieve(AccountManagement.class);
 
         accountManagement.addUser("test@vysper.org", "password");
+        accountManagement.addUser("test2@vysper.org", "password");
 
         XMPPServer server = new XMPPServer("vysper.org");
         server.addEndpoint(new TCPEndpoint());

Modified: mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/handler/MUCMessageHandler.java
URL: http://svn.apache.org/viewvc/mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/handler/MUCMessageHandler.java?rev=821620&r1=821619&r2=821620&view=diff
==============================================================================
--- mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/handler/MUCMessageHandler.java
(original)
+++ mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/handler/MUCMessageHandler.java
Sun Oct  4 21:27:20 2009
@@ -32,7 +32,9 @@
 import org.apache.vysper.xmpp.modules.core.base.handler.DefaultMessageHandler;
 import org.apache.vysper.xmpp.modules.extension.xep0045_muc.model.Conference;
 import org.apache.vysper.xmpp.modules.extension.xep0045_muc.model.Occupant;
+import org.apache.vysper.xmpp.modules.extension.xep0045_muc.model.Role;
 import org.apache.vysper.xmpp.modules.extension.xep0045_muc.model.Room;
+import org.apache.vysper.xmpp.modules.extension.xep0045_muc.model.RoomType;
 import org.apache.vysper.xmpp.modules.extension.xep0045_muc.stanzas.X;
 import org.apache.vysper.xmpp.server.ServerRuntimeContext;
 import org.apache.vysper.xmpp.server.SessionContext;
@@ -43,6 +45,7 @@
 import org.apache.vysper.xmpp.stanza.StanzaErrorCondition;
 import org.apache.vysper.xmpp.stanza.StanzaErrorType;
 import org.apache.vysper.xmpp.xmlfragment.Attribute;
+import org.apache.vysper.xmpp.xmlfragment.XMLSemanticError;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -108,6 +111,18 @@
                     if(sendingOccupant.hasVoice()) {
                         // relay message to all occupants in room
                         
+                        try {
+                            if(stanza.getSubjects() != null && !stanza.getSubjects().isEmpty())
{
+                                // subject message
+                                if(!room.isRoomType(RoomType.OpenSubject) && !sendingOccupant.isModerator())
{
+                                    // room only allows moderators to change the subject,
and sender is not a moderator
+                                    return createMessageErrorStanza(room.getJID(), from,
stanza.getID(), StanzaErrorType.AUTH, StanzaErrorCondition.FORBIDDEN, stanza);
+                                }
+                            }
+                        } catch (XMLSemanticError e) {
+                            // not a subject message, ignore exception
+                        }
+                        
                         logger.debug("Relaying message to all room occupants");
                         for(Occupant occupent : room.getOccupants()) {
                             logger.debug("Relaying message to  {}", occupent);

Modified: mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/model/Occupant.java
URL: http://svn.apache.org/viewvc/mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/model/Occupant.java?rev=821620&r1=821619&r2=821620&view=diff
==============================================================================
--- mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/model/Occupant.java
(original)
+++ mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/model/Occupant.java
Sun Oct  4 21:27:20 2009
@@ -83,4 +83,8 @@
         return jid.getFullQualifiedName();
     }
     
+    public boolean isModerator() {
+        return role == Role.Moderator;
+    }
+    
 }

Modified: mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/model/Room.java
URL: http://svn.apache.org/viewvc/mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/model/Room.java?rev=821620&r1=821619&r2=821620&view=diff
==============================================================================
--- mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/model/Room.java
(original)
+++ mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/model/Room.java
Sun Oct  4 21:27:20 2009
@@ -171,7 +171,9 @@
         infoElements.add(new Feature(NamespaceURIs.XEP0045_MUC));
         
         for(RoomType type : roomTypes) {
-            infoElements.add(new Feature(type.getDiscoName()));            
+            if(type.includeInDisco()) {
+                infoElements.add(new Feature(type.getDiscoName()));
+            }
         }
         
         return infoElements;

Modified: mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/model/RoomType.java
URL: http://svn.apache.org/viewvc/mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/model/RoomType.java?rev=821620&r1=821619&r2=821620&view=diff
==============================================================================
--- mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/model/RoomType.java
(original)
+++ mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/model/RoomType.java
Sun Oct  4 21:27:20 2009
@@ -95,7 +95,13 @@
     /**
      * A room that anyone is allowed to enter without first providing the correct password;
antonym: Password-Protected Room.
      */
-    Unsecured("muc_unsecured");
+    Unsecured("muc_unsecured"),
+    
+    // extra features, not covered by room types as defined in the XEP
+    /**
+     * Any visitor can change the room subject, not only a moderator
+     */
+    OpenSubject(null);
     
     private String discoName;
 
@@ -161,4 +167,9 @@
         }
     }
 
+
+    public boolean includeInDisco() {
+        return discoName != null;
+    }
+
 }

Modified: mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/stanzas/History.java
URL: http://svn.apache.org/viewvc/mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/stanzas/History.java?rev=821620&r1=821619&r2=821620&view=diff
==============================================================================
--- mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/stanzas/History.java
(original)
+++ mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/stanzas/History.java
Sun Oct  4 21:27:20 2009
@@ -21,7 +21,6 @@
 
 import java.util.ArrayList;
 import java.util.Calendar;
-import java.util.Date;
 import java.util.List;
 
 import org.apache.vysper.xmpp.datetime.DateTimeProfile;

Modified: mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/test/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/handler/AbstractMUCHandlerTestCase.java
URL: http://svn.apache.org/viewvc/mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/test/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/handler/AbstractMUCHandlerTestCase.java?rev=821620&r1=821619&r2=821620&view=diff
==============================================================================
--- mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/test/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/handler/AbstractMUCHandlerTestCase.java
(original)
+++ mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/test/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/handler/AbstractMUCHandlerTestCase.java
Sun Oct  4 21:27:20 2009
@@ -61,7 +61,7 @@
     
     
     protected void assertErrorStanza(Stanza response, String stanzaName, Entity from, Entity
to, 
-            String type, String errorName, List<XMLElement> expectedInnerElements)
{
+            String type, String errorName, XMLElement... expectedInnerElements) {
         assertNotNull(response);
         assertEquals(stanzaName, response.getName());
         assertEquals(to, response.getTo());

Added: mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/test/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/handler/AbstractMUCMessageHandlerTestCase.java
URL: http://svn.apache.org/viewvc/mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/test/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/handler/AbstractMUCMessageHandlerTestCase.java?rev=821620&view=auto
==============================================================================
--- mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/test/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/handler/AbstractMUCMessageHandlerTestCase.java
(added)
+++ mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/test/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/handler/AbstractMUCMessageHandlerTestCase.java
Sun Oct  4 21:27:20 2009
@@ -0,0 +1,109 @@
+package org.apache.vysper.xmpp.modules.extension.xep0045_muc.handler;
+
+import static org.apache.vysper.xmpp.stanza.MessageStanzaType.GROUPCHAT;
+
+import org.apache.vysper.xmpp.addressing.Entity;
+import org.apache.vysper.xmpp.modules.extension.xep0045_muc.model.Room;
+import org.apache.vysper.xmpp.modules.extension.xep0045_muc.stanzas.X;
+import org.apache.vysper.xmpp.protocol.ProtocolException;
+import org.apache.vysper.xmpp.protocol.ResponseStanzaContainer;
+import org.apache.vysper.xmpp.protocol.StanzaHandler;
+import org.apache.vysper.xmpp.stanza.MessageStanza;
+import org.apache.vysper.xmpp.stanza.MessageStanzaType;
+import org.apache.vysper.xmpp.stanza.Stanza;
+import org.apache.vysper.xmpp.stanza.StanzaBuilder;
+import org.apache.vysper.xmpp.xmlfragment.Attribute;
+import org.apache.vysper.xmpp.xmlfragment.XMLElement;
+import org.apache.vysper.xmpp.xmlfragment.XMLFragment;
+import org.apache.vysper.xmpp.xmlfragment.XMLSemanticError;
+import org.apache.vysper.xmpp.xmlfragment.XMLText;
+
+/**
+ */
+public class AbstractMUCMessageHandlerTestCase extends AbstractMUCHandlerTestCase {
+
+    protected static final String BODY = "Body";
+
+    protected Stanza sendMessage(Entity from, Entity to, MessageStanzaType type,
+            String body) throws ProtocolException {
+        return sendMessage(from, to, type, body, null, null);
+    }
+    
+    protected Stanza sendMessage(Entity from, Entity to, MessageStanzaType type,
+            String body, X x, String subject) throws ProtocolException {
+        StanzaBuilder stanzaBuilder = StanzaBuilder.createMessageStanza(from,
+                to, type, null, body);
+        if(subject != null) {
+            stanzaBuilder.startInnerElement("subject").addText(subject).endInnerElement();
+        }
+        if(x != null) {
+            stanzaBuilder.addPreparedElement(x);
+        }
+
+        Stanza messageStanza = stanzaBuilder.getFinalStanza();
+        ResponseStanzaContainer container = handler.execute(messageStanza,
+                sessionContext.getServerRuntimeContext(), true, sessionContext,
+                null);
+        if (container != null) {
+            return container.getResponseStanza();
+        } else {
+            return null;
+        }
+    }
+
+    protected void assertMessageErrorStanza(Stanza response, Entity from,
+            Entity to, String type, String errorName,
+            XMLElement... expectedInnerElements) {
+        assertErrorStanza(response, "message", from, to, type, errorName,
+                expectedInnerElements);
+    }
+
+    protected void testNotAllowedMessage(Room room, String expectedErrorName)
+            throws Exception {
+        String body = "Message body";
+
+        // now, let user 2 exit room
+        Stanza errorStanza = sendMessage(OCCUPANT1_JID, ROOM1_JID,
+                GROUPCHAT, body);
+
+        XMLText text = new XMLText(body);
+        XMLElement expectedBody = new XMLElement("body", null,
+                (Attribute[]) null, new XMLFragment[] { text });
+        assertMessageErrorStanza(errorStanza, ROOM1_JID, OCCUPANT1_JID, "modify",
+                expectedErrorName,expectedBody);
+
+        // no message should be relayed
+        assertNull(occupant1Queue.getNext());
+        assertNull(occupant2Queue.getNext());
+    }
+
+    protected void assertMessageStanza(Entity from, Entity to, String type,
+            String body, Stanza stanza) throws XMLSemanticError {
+        assertMessageStanza(from, to, type, body, null, null, stanza);
+    }
+    
+    protected void assertMessageStanza(Entity from, Entity to, String type,
+            String expectedBody, String expectedSubject, X expectedX, Stanza stanza) throws
XMLSemanticError {
+        assertNotNull(stanza);
+        MessageStanza msgStanza = (MessageStanza) MessageStanza.getWrapper(stanza);
+        
+        assertEquals(from, stanza.getFrom());
+        assertEquals(to, stanza.getTo());
+        if (type != null) {
+            assertEquals(type, stanza.getAttributeValue("type"));
+        }
+
+        assertEquals(expectedBody, msgStanza.getBody(null));
+        assertEquals(expectedSubject, msgStanza.getSubject(null));
+
+        if(expectedX != null) {
+            X actualX = X.fromStanza(stanza);
+            assertEquals(expectedX, actualX);
+        }
+    }
+
+    @Override
+    protected StanzaHandler createHandler() {
+        return new MUCMessageHandler(conference, MODULE_JID);
+    }
+}

Modified: mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/test/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/handler/MUCMessageHandlerTestCase.java
URL: http://svn.apache.org/viewvc/mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/test/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/handler/MUCMessageHandlerTestCase.java?rev=821620&r1=821619&r2=821620&view=diff
==============================================================================
--- mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/test/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/handler/MUCMessageHandlerTestCase.java
(original)
+++ mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/test/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/handler/MUCMessageHandlerTestCase.java
Sun Oct  4 21:27:20 2009
@@ -3,9 +3,7 @@
 import static org.apache.vysper.xmpp.stanza.MessageStanzaType.GROUPCHAT;
 
 import java.util.Arrays;
-import java.util.List;
 
-import org.apache.vysper.xmpp.addressing.Entity;
 import org.apache.vysper.xmpp.addressing.EntityImpl;
 import org.apache.vysper.xmpp.modules.extension.xep0045_muc.model.Occupant;
 import org.apache.vysper.xmpp.modules.extension.xep0045_muc.model.Role;
@@ -14,54 +12,16 @@
 import org.apache.vysper.xmpp.modules.extension.xep0045_muc.stanzas.Invite;
 import org.apache.vysper.xmpp.modules.extension.xep0045_muc.stanzas.Password;
 import org.apache.vysper.xmpp.modules.extension.xep0045_muc.stanzas.X;
-import org.apache.vysper.xmpp.protocol.ProtocolException;
-import org.apache.vysper.xmpp.protocol.ResponseStanzaContainer;
-import org.apache.vysper.xmpp.protocol.StanzaHandler;
 import org.apache.vysper.xmpp.stanza.MessageStanzaType;
 import org.apache.vysper.xmpp.stanza.Stanza;
-import org.apache.vysper.xmpp.stanza.StanzaBuilder;
 import org.apache.vysper.xmpp.xmlfragment.Attribute;
 import org.apache.vysper.xmpp.xmlfragment.XMLElement;
 import org.apache.vysper.xmpp.xmlfragment.XMLFragment;
-import org.apache.vysper.xmpp.xmlfragment.XMLSemanticError;
 import org.apache.vysper.xmpp.xmlfragment.XMLText;
 
 /**
  */
-public class MUCMessageHandlerTestCase extends AbstractMUCHandlerTestCase {
-
-    private static final String BODY = "Body";
-
-    private Stanza sendMessage(Entity from, Entity to, MessageStanzaType type,
-            String body) throws ProtocolException {
-        return sendMessage(from, to, type, body, null);
-    }
-    
-    private Stanza sendMessage(Entity from, Entity to, MessageStanzaType type,
-            String body, X x) throws ProtocolException {
-        StanzaBuilder stanzaBuilder = StanzaBuilder.createMessageStanza(from,
-                to, type, null, body);
-        if(x != null) {
-            stanzaBuilder.addPreparedElement(x);
-        }
-
-        Stanza messageStanza = stanzaBuilder.getFinalStanza();
-        ResponseStanzaContainer container = handler.execute(messageStanza,
-                sessionContext.getServerRuntimeContext(), true, sessionContext,
-                null);
-        if (container != null) {
-            return container.getResponseStanza();
-        } else {
-            return null;
-        }
-    }
-
-    private void assertMessageErrorStanza(Stanza response, Entity from,
-            Entity to, String type, String errorName,
-            List<XMLElement> expectedInnerElements) {
-        assertErrorStanza(response, "message", from, to, type, errorName,
-                expectedInnerElements);
-    }
+public class MUCMessageHandlerTestCase extends AbstractMUCMessageHandlerTestCase {
 
     public void testMessageWithNoVoice() throws Exception {
         Room room = conference.findOrCreateRoom(ROOM1_JID, "Room 1");
@@ -79,25 +39,6 @@
         testNotAllowedMessage(room, "not-acceptable");
     }
 
-    private void testNotAllowedMessage(Room room, String expectedErrorName)
-            throws Exception {
-        String body = "Message body";
-
-        // now, let user 2 exit room
-        Stanza errorStanza = sendMessage(OCCUPANT1_JID, ROOM1_JID,
-                GROUPCHAT, body);
-
-        XMLText text = new XMLText(body);
-        XMLElement expectedBody = new XMLElement("body", null,
-                (Attribute[]) null, new XMLFragment[] { text });
-        assertMessageErrorStanza(errorStanza, ROOM1_JID, OCCUPANT1_JID, "modify",
-                expectedErrorName, Arrays.asList(expectedBody));
-
-        // no message should be relayed
-        assertNull(occupant1Queue.getNext());
-        assertNull(occupant2Queue.getNext());
-    }
-
     public void testMessageToRoomWithRelays() throws Exception {
         String body = "Message body";
 
@@ -133,6 +74,7 @@
         assertNull(occupant1Queue.getNext());
     }
 
+    
     public void testGroupChatMessageToOccupant() throws Exception {
         // add occupants to the room
         Room room = conference.findOrCreateRoom(ROOM1_JID, "Room 1");
@@ -146,7 +88,7 @@
         XMLElement expectedBody = new XMLElement("body", null,
                 (Attribute[]) null, new XMLFragment[] { text });
         assertMessageErrorStanza(errorStanza, ROOM1_JID, OCCUPANT1_JID, "modify",
-                "bad-request", Arrays.asList(expectedBody));
+                "bad-request", expectedBody);
 
         // no message should be relayed
         assertNull(occupant1Queue.getNext());
@@ -164,11 +106,11 @@
 
         Invite invite = new Invite(null, OCCUPANT2_JID, reason);
         // send message to occupant 1
-        assertNull(sendMessage(OCCUPANT1_JID, ROOM1_JID, null, null, new X(invite)));
+        assertNull(sendMessage(OCCUPANT1_JID, ROOM1_JID, null, null, new X(invite), null));
 
         X expectedX = new X(new Invite(OCCUPANT1_JID, null, reason), new Password("secret"));
         // verify stanzas to existing occupants on the exiting user
-        assertMessageStanza(ROOM1_JID, OCCUPANT2_JID, null, null, expectedX,
+        assertMessageStanza(ROOM1_JID, OCCUPANT2_JID, null, null, null, expectedX,
                 occupant2Queue.getNext());
         assertNull(occupant1Queue.getNext());
     }
@@ -182,44 +124,13 @@
 
         Decline decline = new Decline(null, OCCUPANT2_JID, reason);
         // send message to occupant 1
-        Stanza error = sendMessage(OCCUPANT1_JID, ROOM1_JID, null, null, new X(decline));
+        Stanza error = sendMessage(OCCUPANT1_JID, ROOM1_JID, null, null, new X(decline),
null);
         assertNull(error);
 
         X expectedX = new X(new Decline(OCCUPANT1_JID, null, reason));
         // verify stanzas to existing occupants on the exiting user
-        assertMessageStanza(ROOM1_JID, OCCUPANT2_JID, null, null, expectedX,
+        assertMessageStanza(ROOM1_JID, OCCUPANT2_JID, null, null, null, expectedX,
                 occupant2Queue.getNext());
         assertNull(occupant1Queue.getNext());
     }
-
-    
-    private void assertMessageStanza(Entity from, Entity to, String type,
-            String body, Stanza stanza) throws XMLSemanticError {
-        assertMessageStanza(from, to, type, body, null, stanza);
-    }
-    
-    private void assertMessageStanza(Entity from, Entity to, String type,
-            String expectedBody, X expectedX, Stanza stanza) throws XMLSemanticError {
-        assertNotNull(stanza);
-        assertEquals(from, stanza.getFrom());
-        assertEquals(to, stanza.getTo());
-        if (type != null) {
-            assertEquals(type, stanza.getAttributeValue("type"));
-        }
-
-        if(expectedBody != null) {
-            XMLElement bodyElement = stanza.getSingleInnerElementsNamed("body");
-            assertEquals(expectedBody, bodyElement.getInnerText().getText());
-        }
-        
-        if(expectedX != null) {
-            X actualX = X.fromStanza(stanza);
-            assertEquals(expectedX, actualX);
-        }
-    }
-
-    @Override
-    protected StanzaHandler createHandler() {
-        return new MUCMessageHandler(conference, MODULE_JID);
-    }
 }

Modified: mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/test/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/handler/MUCPresenceHandlerEnterRoomTestCase.java
URL: http://svn.apache.org/viewvc/mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/test/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/handler/MUCPresenceHandlerEnterRoomTestCase.java?rev=821620&r1=821619&r2=821620&view=diff
==============================================================================
--- mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/test/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/handler/MUCPresenceHandlerEnterRoomTestCase.java
(original)
+++ mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/test/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/handler/MUCPresenceHandlerEnterRoomTestCase.java
Sun Oct  4 21:27:20 2009
@@ -186,7 +186,7 @@
             String type, String errorName) {
         Attribute xmlns = new NamespaceAttribute(NamespaceURIs.XEP0045_MUC);
         XMLElement xElement = new XMLElement("x", null, Arrays.asList(xmlns), (XMLFragment[])null);
-        assertErrorStanza(response, "presence", from, to, type, errorName, Arrays.asList(xElement));
+        assertErrorStanza(response, "presence", from, to, type, errorName, xElement);
     }
 
     

Added: mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/test/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/handler/MUCSubjectMessageHandlerTestCase.java
URL: http://svn.apache.org/viewvc/mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/test/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/handler/MUCSubjectMessageHandlerTestCase.java?rev=821620&view=auto
==============================================================================
--- mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/test/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/handler/MUCSubjectMessageHandlerTestCase.java
(added)
+++ mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/test/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/handler/MUCSubjectMessageHandlerTestCase.java
Sun Oct  4 21:27:20 2009
@@ -0,0 +1,67 @@
+package org.apache.vysper.xmpp.modules.extension.xep0045_muc.handler;
+
+import static org.apache.vysper.xmpp.stanza.MessageStanzaType.GROUPCHAT;
+
+import org.apache.vysper.xmpp.modules.extension.xep0045_muc.model.Role;
+import org.apache.vysper.xmpp.modules.extension.xep0045_muc.model.Room;
+import org.apache.vysper.xmpp.modules.extension.xep0045_muc.model.RoomType;
+import org.apache.vysper.xmpp.stanza.Stanza;
+import org.apache.vysper.xmpp.xmlfragment.Attribute;
+import org.apache.vysper.xmpp.xmlfragment.XMLElement;
+import org.apache.vysper.xmpp.xmlfragment.XMLFragment;
+import org.apache.vysper.xmpp.xmlfragment.XMLText;
+
+
+/**
+ */
+public class MUCSubjectMessageHandlerTestCase extends AbstractMUCMessageHandlerTestCase {
+
+    private static final String SUBJECT = "Subject";
+
+    public void testChangeSubjectNonModeratorAllowed() throws Exception {
+        Room room = conference.findOrCreateRoom(ROOM2_JID, "Room 2", RoomType.OpenSubject);
+        room.addOccupant(OCCUPANT1_JID, "nick");
+        room.addOccupant(OCCUPANT2_JID, "Nick 2");
+
+        // send message to room
+        assertNull(sendMessage(OCCUPANT1_JID, ROOM2_JID, GROUPCHAT, null, null, SUBJECT));
+
+        // verify stanzas to existing occupants on the exiting user
+        assertMessageStanza(ROOM2_JID_WITH_NICK, OCCUPANT1_JID, "groupchat", null, SUBJECT,
null,
+                occupant1Queue.getNext());
+        assertMessageStanza(ROOM2_JID_WITH_NICK, OCCUPANT2_JID, "groupchat", null, SUBJECT,
null,
+                occupant2Queue.getNext());
+    }
+
+    public void testChangeSubject() throws Exception {
+        Room room = conference.findOrCreateRoom(ROOM2_JID, "Room 2");
+        room.addOccupant(OCCUPANT1_JID, "nick").setRole(Role.Moderator);
+        room.addOccupant(OCCUPANT2_JID, "Nick 2");
+
+        // send message to room
+        assertNull(sendMessage(OCCUPANT1_JID, ROOM2_JID, GROUPCHAT, null, null, SUBJECT));
+
+        // verify stanzas to existing occupants on the exiting user
+        assertMessageStanza(ROOM2_JID_WITH_NICK, OCCUPANT1_JID, "groupchat", null, SUBJECT,
null,
+                occupant1Queue.getNext());
+        assertMessageStanza(ROOM2_JID_WITH_NICK, OCCUPANT2_JID, "groupchat", null, SUBJECT,
null,
+                occupant2Queue.getNext());
+    }
+
+    public void testChangeSubjectNonModerator() throws Exception {
+        Room room = conference.findOrCreateRoom(ROOM2_JID, "Room 2");
+        room.addOccupant(OCCUPANT1_JID, "nick");
+        room.addOccupant(OCCUPANT2_JID, "Nick 2");
+
+        // send message to room
+        Stanza error = sendMessage(OCCUPANT1_JID, ROOM2_JID, GROUPCHAT, null, null, SUBJECT);
+
+        assertMessageErrorStanza(error, ROOM2_JID, OCCUPANT1_JID, "auth", "forbidden", 
+                new XMLElement("subject", null, (Attribute[])null, new XMLFragment[]{new
XMLText(SUBJECT)}));
+        
+        assertNull(occupant1Queue.getNext());
+        assertNull(occupant2Queue.getNext());
+    }
+
+
+}

Modified: mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/test/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/model/DiscussionMessageTestCase.java
URL: http://svn.apache.org/viewvc/mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/test/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/model/DiscussionMessageTestCase.java?rev=821620&r1=821619&r2=821620&view=diff
==============================================================================
--- mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/test/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/model/DiscussionMessageTestCase.java
(original)
+++ mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/test/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/model/DiscussionMessageTestCase.java
Sun Oct  4 21:27:20 2009
@@ -20,7 +20,6 @@
 package org.apache.vysper.xmpp.modules.extension.xep0045_muc.model;
 
 import java.util.Calendar;
-import java.util.Date;
 import java.util.TimeZone;
 
 import junit.framework.TestCase;



Mime
View raw message