labs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ber...@apache.org
Subject svn commit: r740410 - in /labs/vysper/src: main/java/org/apache/vysper/mina/codec/ main/java/org/apache/vysper/xmpp/modules/core/base/handler/ main/java/org/apache/vysper/xmpp/modules/core/im/handler/ main/java/org/apache/vysper/xmpp/modules/roster/han...
Date Tue, 03 Feb 2009 20:21:23 GMT
Author: berndf
Date: Tue Feb  3 20:21:22 2009
New Revision: 740410

URL: http://svn.apache.org/viewvc?rev=740410&view=rev
Log:
[vysper] doc and clean up ResourceRegistry, remove getFirstResourceForSession() with more
compliant behavior: determine 'from' for client-sent stanzas correctly and handle errors

Modified:
    labs/vysper/src/main/java/org/apache/vysper/mina/codec/StanzaWriterProtocolEncoder.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/core/base/handler/XMPPCoreStanzaHandler.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/core/im/handler/PresenceAvailabilityHandler.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/roster/handler/RosterIQHandler.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/state/resourcebinding/ResourceRegistry.java
    labs/vysper/src/test/java/org/apache/vysper/xmpp/modules/core/im/handler/PresenceAvailInitialOutHandlerTestCase.java
    labs/vysper/src/test/java/org/apache/vysper/xmpp/modules/core/im/handler/PresenceAvailUpdateOutHandlerTestCase.java
    labs/vysper/src/test/java/org/apache/vysper/xmpp/modules/roster/handler/RosterIQHandlerTestCase.java
    labs/vysper/src/test/java/org/apache/vysper/xmpp/state/resourcebinding/ResourceRegistryTestCase.java

Modified: labs/vysper/src/main/java/org/apache/vysper/mina/codec/StanzaWriterProtocolEncoder.java
URL: http://svn.apache.org/viewvc/labs/vysper/src/main/java/org/apache/vysper/mina/codec/StanzaWriterProtocolEncoder.java?rev=740410&r1=740409&r2=740410&view=diff
==============================================================================
--- labs/vysper/src/main/java/org/apache/vysper/mina/codec/StanzaWriterProtocolEncoder.java
(original)
+++ labs/vysper/src/main/java/org/apache/vysper/mina/codec/StanzaWriterProtocolEncoder.java
Tue Feb  3 20:21:22 2009
@@ -35,8 +35,8 @@
  */
 public class StanzaWriterProtocolEncoder implements ProtocolEncoder {
 
-    final Logger logger = LoggerFactory.getLogger(StanzaWriterProtocolEncoder.class);
-    final Logger serverStanzaLogger = LoggerFactory.getLogger("stanza.server");
+    private final Logger logger = LoggerFactory.getLogger(StanzaWriterProtocolEncoder.class);
+    private final Logger serverStanzaLogger = LoggerFactory.getLogger("stanza.server");
 
     public void encode(IoSession ioSession, Object o, ProtocolEncoderOutput protocolEncoderOutput)
throws Exception {
         if (!(o instanceof StanzaWriteInfo)) {

Modified: labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/core/base/handler/XMPPCoreStanzaHandler.java
URL: http://svn.apache.org/viewvc/labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/core/base/handler/XMPPCoreStanzaHandler.java?rev=740410&r1=740409&r2=740410&view=diff
==============================================================================
--- labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/core/base/handler/XMPPCoreStanzaHandler.java
(original)
+++ labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/core/base/handler/XMPPCoreStanzaHandler.java
Tue Feb  3 20:21:22 2009
@@ -18,6 +18,7 @@
 package org.apache.vysper.xmpp.modules.core.base.handler;
 
 import org.apache.vysper.xmpp.addressing.Entity;
+import org.apache.vysper.xmpp.addressing.EntityImpl;
 import org.apache.vysper.xmpp.protocol.ResponseStanzaContainer;
 import org.apache.vysper.xmpp.protocol.ResponseStanzaContainerImpl;
 import org.apache.vysper.xmpp.protocol.SessionStateHolder;
@@ -30,12 +31,16 @@
 import org.apache.vysper.xmpp.stanza.Stanza;
 import org.apache.vysper.xmpp.stanza.XMPPCoreStanza;
 import org.apache.vysper.xmpp.xmlfragment.Attribute;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * foundation for the three core protocol stanzas: iq, message, presence
  */
 public abstract class XMPPCoreStanzaHandler implements StanzaHandler {
 
+    final static Logger logger = LoggerFactory.getLogger(XMPPCoreStanzaHandler.class);
+
     public boolean verify(Stanza stanza) {
         boolean typeVerified = verifyType(stanza);
         boolean namespaceVerified = verifyNamespace(stanza);
@@ -108,4 +113,29 @@
     }
 
     protected abstract Stanza executeCore(XMPPCoreStanza stanza, ServerRuntimeContext serverRuntimeContext,
boolean isOutboundStanza, SessionContext sessionContext);
+
+    /**
+     * a client might send a stanza without a 'from' attribute, if the sending (bare or full)
entity can be determined
+     * from the context. such a missing from is determined here, if possible.
+     * for a formal discussion, see RFC3921bis/Resource Binding/Binding multiple resources/From
Addresses
+     * @param stanza
+     * @param sessionContext
+     * @return
+     */
+    public static Entity determineFrom(XMPPCoreStanza stanza, SessionContext sessionContext)
{
+        Entity from = stanza.getFrom();
+        if (from != null) return from;
+
+        // try to build something together from initiating entity and a bound resource
+        Entity initiatingEntity = sessionContext.getInitiatingEntity();
+        if (initiatingEntity == null) throw new RuntimeException("no 'from' attribute, and
initiating entity not set: cannot determine sender of roster IQ");
+
+        String resourceId = sessionContext.getServerRuntimeContext().getResourceRegistry().getUniqueResourceForSession(sessionContext);
+        if (resourceId == null) {
+            logger.warn("no 'from' attribute, and cannot uniquely determine sending resource
for initiating entity {} in session {}", initiatingEntity.getFullQualifiedName(), sessionContext.getSessionId());
+            return null;
+        }
+        from = new EntityImpl(initiatingEntity, resourceId);
+        return from;
+    }
 }

Modified: labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/core/im/handler/PresenceAvailabilityHandler.java
URL: http://svn.apache.org/viewvc/labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/core/im/handler/PresenceAvailabilityHandler.java?rev=740410&r1=740409&r2=740410&view=diff
==============================================================================
--- labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/core/im/handler/PresenceAvailabilityHandler.java
(original)
+++ labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/core/im/handler/PresenceAvailabilityHandler.java
Tue Feb  3 20:21:22 2009
@@ -25,15 +25,12 @@
 import org.apache.vysper.xmpp.modules.roster.RosterUtils;
 import org.apache.vysper.xmpp.modules.roster.SubscriptionType;
 import org.apache.vysper.xmpp.modules.roster.persistence.RosterManager;
+import org.apache.vysper.xmpp.modules.core.base.handler.XMPPCoreStanzaHandler;
 import org.apache.vysper.xmpp.server.ServerRuntimeContext;
 import org.apache.vysper.xmpp.server.SessionContext;
-import org.apache.vysper.xmpp.stanza.PresenceStanza;
-import org.apache.vysper.xmpp.stanza.PresenceStanzaType;
+import org.apache.vysper.xmpp.server.response.ServerErrorResponses;
 import static org.apache.vysper.xmpp.stanza.PresenceStanzaType.*;
-import org.apache.vysper.xmpp.stanza.Stanza;
-import org.apache.vysper.xmpp.stanza.StanzaBuilder;
-import org.apache.vysper.xmpp.stanza.XMPPCoreStanza;
-import org.apache.vysper.xmpp.stanza.XMPPCoreStanzaVerifier;
+import org.apache.vysper.xmpp.stanza.*;
 import org.apache.vysper.xmpp.state.resourcebinding.ResourceRegistry;
 import org.apache.vysper.xmpp.state.resourcebinding.ResourceState;
 import org.apache.vysper.xmpp.xmlfragment.Attribute;
@@ -83,10 +80,15 @@
         boolean available = PresenceStanzaType.isAvailable(type);
 
         if (isOutboundStanza) {
+            Entity user = XMPPCoreStanzaHandler.determineFrom(presenceStanza, sessionContext);
+            if (user == null) {
+                return ServerErrorResponses.getInstance().getStanzaError(StanzaErrorCondition.UNKNOWN_SENDER,
presenceStanza, StanzaErrorType.MODIFY, "sender info insufficient: " + ((user == null) ? "no
from" : user.getFullQualifiedName()), null, null);
+            }
+
             if (available) {
-                return handleOutboundAvailable(presenceStanza, serverRuntimeContext, sessionContext,
rosterManager, initiatingEntity, registry);
+                return handleOutboundAvailable(presenceStanza, serverRuntimeContext, sessionContext,
rosterManager, user, registry);
             } else if (type == UNAVAILABLE) {
-                return handleOutboundUnavailable(presenceStanza, serverRuntimeContext, sessionContext,
rosterManager, initiatingEntity, registry);
+                return handleOutboundUnavailable(presenceStanza, serverRuntimeContext, sessionContext,
rosterManager, user, registry);
             } else if (type == PROBE) {
                 return handleOutboundPresenceProbe(presenceStanza, serverRuntimeContext,
sessionContext, registry);
             } else if (type == ERROR) {
@@ -181,15 +183,10 @@
               presence session).
 
      */
-    private Stanza handleOutboundUnavailable(PresenceStanza presenceStanza, ServerRuntimeContext
serverRuntimeContext, SessionContext sessionContext, RosterManager rosterManager, Entity initiatingEntity,
ResourceRegistry registry) {
-
-        String resourceID = registry.getFirstResourceForSession(sessionContext);
-        Entity user = (resourceID != null) ? new EntityImpl(initiatingEntity, resourceID)
: presenceStanza.getFrom();
-        if (user == null) {
-            // return error stanza
-        }
+    private Stanza handleOutboundUnavailable(PresenceStanza presenceStanza, ServerRuntimeContext
serverRuntimeContext, SessionContext sessionContext, RosterManager rosterManager, Entity user,
ResourceRegistry registry) {
 
-        registry.setResourceState(resourceID, ResourceState.UNAVAILABLE);
+        if (!user.isResourceSet()) throw new RuntimeException("resource id not available");
+        registry.setResourceState(user.getResource(), ResourceState.UNAVAILABLE);
 
         sessionContext.getServerRuntimeContext().getPresenceCache().remove(user);
 
@@ -235,11 +232,12 @@
         throw new IllegalStateException("clients might not send presence probes");
     }
 
-    private PresenceStanza handleOutboundAvailable(PresenceStanza presenceStanza, ServerRuntimeContext
serverRuntimeContext, SessionContext sessionContext, RosterManager rosterManager, Entity initiatingEntity,
ResourceRegistry registry) {
+    private PresenceStanza handleOutboundAvailable(PresenceStanza presenceStanza, ServerRuntimeContext
serverRuntimeContext, SessionContext sessionContext, RosterManager rosterManager, Entity user,
ResourceRegistry registry) {
         boolean hasTo = presenceStanza.getCoreVerifier().attributePresent("to");
         if (hasTo) throw new RuntimeException("unhandled presence available case");
 
-        ResourceState resourceState = registry.getResourceState(registry.getFirstResourceForSession(sessionContext));
+        if (!user.isResourceSet()) throw new RuntimeException("resource id not available");
+        ResourceState resourceState = registry.getResourceState(user.getResource());
 
         boolean isPresenceUpdate = resourceState != null && ResourceState.isAvailable(resourceState);
 
@@ -247,12 +245,6 @@
         // RFC3921bis-04#4.2.2 Initial Presence
         // RFC3921bis-04#4.4.2 Initial Presence
 
-        String resourceID = registry.getFirstResourceForSession(sessionContext);
-        Entity user = (resourceID != null) ? new EntityImpl(initiatingEntity, resourceID)
: presenceStanza.getFrom();
-        if (user == null) {
-            // return error stanza
-        }
-
         updateLatestPresence(sessionContext, user, presenceStanza);
         if (!isPresenceUpdate) {
             // things to be done for initial presence

Modified: labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/roster/handler/RosterIQHandler.java
URL: http://svn.apache.org/viewvc/labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/roster/handler/RosterIQHandler.java?rev=740410&r1=740409&r2=740410&view=diff
==============================================================================
--- labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/roster/handler/RosterIQHandler.java
(original)
+++ labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/roster/handler/RosterIQHandler.java
Tue Feb  3 20:21:22 2009
@@ -25,12 +25,7 @@
 import org.apache.vysper.xmpp.server.ServerRuntimeContext;
 import org.apache.vysper.xmpp.server.SessionContext;
 import org.apache.vysper.xmpp.server.response.ServerErrorResponses;
-import org.apache.vysper.xmpp.stanza.IQStanza;
-import org.apache.vysper.xmpp.stanza.IQStanzaType;
-import org.apache.vysper.xmpp.stanza.Stanza;
-import org.apache.vysper.xmpp.stanza.StanzaBuilder;
-import org.apache.vysper.xmpp.stanza.StanzaErrorCondition;
-import org.apache.vysper.xmpp.stanza.StanzaErrorType;
+import org.apache.vysper.xmpp.stanza.*;
 import org.apache.vysper.xmpp.state.resourcebinding.ResourceRegistry;
 import org.apache.vysper.xmpp.state.resourcebinding.ResourceState;
 import org.slf4j.Logger;
@@ -63,14 +58,17 @@
             return handleCannotRetrieveRoster(stanza, sessionContext);
         }
 
-        String resourceId = registry.getFirstResourceForSession(sessionContext);
+        Entity from = determineFrom(stanza, sessionContext);
+        if (from == null || !from.isResourceSet()) {
+            return ServerErrorResponses.getInstance().getStanzaError(StanzaErrorCondition.UNKNOWN_SENDER,
stanza, StanzaErrorType.MODIFY, "sender info insufficient: " + ((from == null) ? "no from"
: from.getFullQualifiedName()), null, null);
+        }
+        String resourceId = from.getResource();
+
         ResourceState currentState = registry.getResourceState(resourceId);
         if (currentState != null) {
             registry.setResourceState(resourceId, ResourceState.makeInterested(currentState));
         }
 
-        Entity from = determineFrom(stanza, sessionContext);
-
         Roster roster = null;
         try {
             roster = rosterManager.retrieve(from.getBareJID());
@@ -84,15 +82,6 @@
         return stanzaBuilder.getFinalStanza();
     }
 
-    private Entity determineFrom(IQStanza stanza, SessionContext sessionContext) {
-        Entity from = stanza.getFrom();
-        if (from == null) {
-            if (sessionContext.getInitiatingEntity() == null) throw new RuntimeException("handle
this case");
-            else from = sessionContext.getInitiatingEntity();
-        }
-        return from;
-    }
-
     /*
         2.1.3. Roster Set
         
@@ -123,7 +112,6 @@
     */
     @Override
     protected Stanza handleSet(IQStanza stanza, ServerRuntimeContext serverRuntimeContext,
SessionContext sessionContext) {
-        ResourceRegistry registry = serverRuntimeContext.getResourceRegistry();
         RosterManager rosterManager = (RosterManager)serverRuntimeContext.getServerRuntimeContextService(RosterManager.SERVER_SERVICE_ROSTERMANAGER);
 
         if (rosterManager == null) {
@@ -131,6 +119,9 @@
         }
 
         Entity user = determineFrom(stanza, sessionContext);
+        if (user == null || !user.isResourceSet()) {
+            return ServerErrorResponses.getInstance().getStanzaError(StanzaErrorCondition.UNKNOWN_SENDER,
stanza, StanzaErrorType.MODIFY, "sender info insufficient: " + ((user == null) ? "no from"
: user.getFullQualifiedName()), null, null);
+        }
 
         RosterItem setRosterItem;
         try {

Modified: labs/vysper/src/main/java/org/apache/vysper/xmpp/state/resourcebinding/ResourceRegistry.java
URL: http://svn.apache.org/viewvc/labs/vysper/src/main/java/org/apache/vysper/xmpp/state/resourcebinding/ResourceRegistry.java?rev=740410&r1=740409&r2=740410&view=diff
==============================================================================
--- labs/vysper/src/main/java/org/apache/vysper/xmpp/state/resourcebinding/ResourceRegistry.java
(original)
+++ labs/vysper/src/main/java/org/apache/vysper/xmpp/state/resourcebinding/ResourceRegistry.java
Tue Feb  3 20:21:22 2009
@@ -20,12 +20,10 @@
 import org.apache.vysper.xmpp.uuid.JVMBuiltinUUIDGenerator;
 import org.apache.vysper.xmpp.uuid.UUIDGenerator;
 import org.apache.vysper.xmpp.addressing.Entity;
-import org.apache.vysper.xmpp.addressing.EntityImpl;
 import static org.apache.vysper.xmpp.state.resourcebinding.ResourceState.*;
 
 import java.util.List;
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.Collections;
 import java.util.Map;
 import java.util.HashMap;
@@ -34,6 +32,7 @@
  * assigns and holds resource ids and their related session
  */
 public class ResourceRegistry {
+
     private static class SessionData {
 
         private final SessionContext context;
@@ -52,12 +51,28 @@
 
     private UUIDGenerator resourceIdGenerator = new JVMBuiltinUUIDGenerator();
 
+    /**
+     * maps resource id to session. note: two resources may point to the same session, but
often this
+     * is a 1:1 relationship
+     */
     protected final Map<String, SessionData> boundResources = new HashMap<String,
SessionData>();
 
+    /**
+     * maps bare JID to all its bound resources. the list of resource ids might not be emtpy,
and if there
+     * is more than one id, the list usually spans more than 1 session 
+     */
     protected final Map<Entity, List<String>> entityResources = new HashMap<Entity,
List<String>>();
 
+    /**
+     * maps a session to all the resource ids bound to it. this is a subset of
+     */
     protected final Map<SessionContext, List<String>> sessionResources = new
HashMap<SessionContext, List<String>>();
 
+    /**
+     * allocates new resource ID for the given session and binds it to the session
+     * @param sessionContext
+     * @return newly allocated resource id
+     */
     public String bindSession(SessionContext sessionContext) {
 		if (sessionContext == null) {
 			throw new IllegalArgumentException("session context cannot be NULL");
@@ -71,6 +86,7 @@
 		synchronized (boundResources) {
 			synchronized (entityResources) {
                 synchronized (sessionResources) {
+                    // record session for the resource id
                     boundResources.put(resourceId, new SessionData(sessionContext,
                             CONNECTED, 0));
     
@@ -96,28 +112,36 @@
 		return resourceId;
 	}
 
-    public Iterator<String> boundResources() {
-		return Collections.unmodifiableSet(boundResources.keySet()).iterator();
-	}
-
+    /**
+     * not as commonly used as #unbindSession, this method unbinds only one of multiple resource
ids for the _same_
+     * session. In XMPP, this is done by sending a stanza like
+     * <iq id='unbind_1' type='set'><unbind xmlns='urn:ietf:params:xml:ns:xmpp-bind'>
+     * <resource>resourceId</resource>
+     * </unbind></iq>
+     * @param resourceId
+     */
     public void unbindResource(String resourceId) {
 		synchronized (boundResources) {
 			synchronized (entityResources) {
     			synchronized (sessionResources) {
                     SessionContext sessionContext = getSessionContext(resourceId);
-                    List<String> resourceListForSession = getResourceList(sessionContext
-                            .getInitiatingEntity());
+                    List<String> resourceListForSession = getResourceList(sessionContext.getInitiatingEntity());
                     resourceListForSession.remove(resourceId);
                     sessionResources.get(sessionContext).remove(resourceId);
+                    // TODO end session if last resource got unbound
                     boundResources.remove(resourceId);
     			}
 			}
 		}
 	}
 
+    /**
+     * unbinds a complete session, together with all its bound resources. this is typically
done when a XMPP session
+     * end because the client sends a </stream:stream> or the connection is cut.
+     * @param unbindingSessionContext sessionContext to be unbound
+     */
     public void unbindSession(SessionContext unbindingSessionContext) {
-		if (unbindingSessionContext == null)
-			return;
+		if (unbindingSessionContext == null) return;
 
 		synchronized (boundResources) {
 			synchronized (entityResources) {
@@ -144,9 +168,14 @@
 		}
 	}
 
-    public String getFirstResourceForSession(SessionContext sessionContext) {
+    /**
+     * retrieves the one and only bound resource for a given session.
+     * @param sessionContext
+     * @return null, if a unique resource cannot be determined (there is more or less than
1), the resource id otherwise 
+     */
+    public String getUniqueResourceForSession(SessionContext sessionContext) {
         List<String> list = getResourcesForSessionInternal(sessionContext);
-        if (list != null && list.size() > 0) return list.get(0);
+        if (list != null && list.size() == 1) return list.get(0);
         return null;
     }
 
@@ -162,17 +191,14 @@
         return resourceList;
     }
 
-    public SessionContext getSessionContext(String resourceId) {
+    protected SessionContext getSessionContext(String resourceId) {
 		SessionData data = boundResources.get(resourceId);
 		if (data == null) return null;
 		return data.context;
 	}
 
     private Entity getBareEntity(Entity entity) {
-        if (entity == null) return null;
-        if (!entity.isResourceSet())
-			return entity; // bare already
-		return new EntityImpl(entity.getNode(), entity.getDomain(), null);
+        return entity == null ? null : entity.getBareJID();
 	}
 
     /**
@@ -187,7 +213,7 @@
     /**
 	 * retrieve IDs of all bound resources for this entity
 	 */
-	public List<String> getBoundResources(Entity entity) {
+	protected List<String> getBoundResources(Entity entity) {
 		return getBoundResources(entity, true);
 	}
 
@@ -223,7 +249,7 @@
 
     /**
 	 * Sets the {@link ResourceState} for the given resource.
-	 * 
+	 *
 	 * @param resourceId
 	 *            the resource identifier
 	 * @param state
@@ -239,7 +265,7 @@
 
     /**
 	 * Gets the {@link ResourceState} of the given resource.
-	 * 
+	 *
 	 * @param resourceId
 	 *            the resource identifier
 	 * @return the {@link ResourceState}

Modified: labs/vysper/src/test/java/org/apache/vysper/xmpp/modules/core/im/handler/PresenceAvailInitialOutHandlerTestCase.java
URL: http://svn.apache.org/viewvc/labs/vysper/src/test/java/org/apache/vysper/xmpp/modules/core/im/handler/PresenceAvailInitialOutHandlerTestCase.java?rev=740410&r1=740409&r2=740410&view=diff
==============================================================================
--- labs/vysper/src/test/java/org/apache/vysper/xmpp/modules/core/im/handler/PresenceAvailInitialOutHandlerTestCase.java
(original)
+++ labs/vysper/src/test/java/org/apache/vysper/xmpp/modules/core/im/handler/PresenceAvailInitialOutHandlerTestCase.java
Tue Feb  3 20:21:22 2009
@@ -18,6 +18,7 @@
 package org.apache.vysper.xmpp.modules.core.im.handler;
 
 import org.apache.vysper.xmpp.addressing.EntityFormatException;
+import org.apache.vysper.xmpp.addressing.EntityImpl;
 import org.apache.vysper.xmpp.delivery.StanzaReceiverRelay;
 import static org.apache.vysper.xmpp.stanza.PresenceStanzaType.PROBE;
 import org.apache.vysper.xmpp.stanza.Stanza;
@@ -33,7 +34,7 @@
     protected PresenceHandler handler = new PresenceHandler();
 
     public void testInitialPresence() throws BindException, EntityFormatException {
-        XMPPCoreStanza initialPresence = XMPPCoreStanza.getWrapper(StanzaBuilder.createPresenceStanza(null,
null, null, null, null, null).getFinalStanza());
+        XMPPCoreStanza initialPresence = XMPPCoreStanza.getWrapper(StanzaBuilder.createPresenceStanza(initiatingUser.getEntityFQ(),
null, null, null, null, null).getFinalStanza());
 
         assertEquals(ResourceState.CONNECTED, getResourceState());
         handler.executeCore(initialPresence, sessionContext.getServerRuntimeContext(), true,
sessionContext);

Modified: labs/vysper/src/test/java/org/apache/vysper/xmpp/modules/core/im/handler/PresenceAvailUpdateOutHandlerTestCase.java
URL: http://svn.apache.org/viewvc/labs/vysper/src/test/java/org/apache/vysper/xmpp/modules/core/im/handler/PresenceAvailUpdateOutHandlerTestCase.java?rev=740410&r1=740409&r2=740410&view=diff
==============================================================================
--- labs/vysper/src/test/java/org/apache/vysper/xmpp/modules/core/im/handler/PresenceAvailUpdateOutHandlerTestCase.java
(original)
+++ labs/vysper/src/test/java/org/apache/vysper/xmpp/modules/core/im/handler/PresenceAvailUpdateOutHandlerTestCase.java
Tue Feb  3 20:21:22 2009
@@ -35,7 +35,7 @@
         StanzaReceiverRelay receiverRelay = (StanzaReceiverRelay) sessionContext.getServerRuntimeContext().getStanzaRelay();
 
         // at first, initial presence
-        XMPPCoreStanza initialPresence = XMPPCoreStanza.getWrapper(StanzaBuilder.createPresenceStanza(null,
null, null, null, null, null).getFinalStanza());
+        XMPPCoreStanza initialPresence = XMPPCoreStanza.getWrapper(StanzaBuilder.createPresenceStanza(initiatingUser.getEntityFQ(),
null, null, null, null, null).getFinalStanza());
         handler.executeCore(initialPresence, sessionContext.getServerRuntimeContext(), true,
sessionContext);
         assertTrue(0 < receiverRelay.getCountDelivered());
         resetRecordedStanzas(); // purge recorded 

Modified: labs/vysper/src/test/java/org/apache/vysper/xmpp/modules/roster/handler/RosterIQHandlerTestCase.java
URL: http://svn.apache.org/viewvc/labs/vysper/src/test/java/org/apache/vysper/xmpp/modules/roster/handler/RosterIQHandlerTestCase.java?rev=740410&r1=740409&r2=740410&view=diff
==============================================================================
--- labs/vysper/src/test/java/org/apache/vysper/xmpp/modules/roster/handler/RosterIQHandlerTestCase.java
(original)
+++ labs/vysper/src/test/java/org/apache/vysper/xmpp/modules/roster/handler/RosterIQHandlerTestCase.java
Tue Feb  3 20:21:22 2009
@@ -61,8 +61,7 @@
     }
 
     private StanzaBuilder createRosterGet() {
-        StanzaBuilder stanzaBuilder = StanzaBuilder.createIQStanza(null, null, IQStanzaType.GET,
"id1");
-        stanzaBuilder.addAttribute("from", client.getFullQualifiedName());
+        StanzaBuilder stanzaBuilder = StanzaBuilder.createIQStanza(new EntityImpl(client,
boundResourceId), null, IQStanzaType.GET, "id1");
         stanzaBuilder.startInnerElement("query").addNamespaceAttribute(NamespaceURIs.JABBER_IQ_ROSTER).endInnerElement();
         return stanzaBuilder;
     }

Modified: labs/vysper/src/test/java/org/apache/vysper/xmpp/state/resourcebinding/ResourceRegistryTestCase.java
URL: http://svn.apache.org/viewvc/labs/vysper/src/test/java/org/apache/vysper/xmpp/state/resourcebinding/ResourceRegistryTestCase.java?rev=740410&r1=740409&r2=740410&view=diff
==============================================================================
--- labs/vysper/src/test/java/org/apache/vysper/xmpp/state/resourcebinding/ResourceRegistryTestCase.java
(original)
+++ labs/vysper/src/test/java/org/apache/vysper/xmpp/state/resourcebinding/ResourceRegistryTestCase.java
Tue Feb  3 20:21:22 2009
@@ -152,16 +152,16 @@
         assertEquals(0, resourceRegistry.getBoundResources(entity).size());
     }
 
-    public void testFirstResourceIsConsistent() throws EntityFormatException {
+    public void testUniqueResourceIsConsistent() throws EntityFormatException {
         EntityImpl entity = EntityImpl.parse("me@test");
         TestSessionContext sessionContext = TestSessionContext.createSessionContext(entity);
         String resourceId1 = resourceRegistry.bindSession(sessionContext);
 
-        String first1 = resourceRegistry.getFirstResourceForSession(sessionContext);
+        String first1 = resourceRegistry.getUniqueResourceForSession(sessionContext);
         assertEquals(resourceId1, first1);
         
         String resourceId2 = resourceRegistry.bindSession(sessionContext);
         assertFalse("resource ids actually differ", resourceId1.equals(resourceId2));
-        assertEquals("still the first resource", first1, resourceRegistry.getFirstResourceForSession(sessionContext));
+        assertNull("resource id no longer unique", resourceRegistry.getUniqueResourceForSession(sessionContext));
     } 
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@labs.apache.org
For additional commands, e-mail: commits-help@labs.apache.org


Mime
View raw message