You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@labs.apache.org by be...@apache.org on 2008/11/29 10:07:12 UTC

svn commit: r721656 - in /labs/vysper/src: main/java/org/apache/vysper/xmpp/modules/core/im/handler/ main/java/org/apache/vysper/xmpp/state/resourcebinding/ test/java/org/apache/vysper/xmpp/modules/core/im/handler/ test/java/org/apache/vysper/xmpp/modu...

Author: berndf
Date: Sat Nov 29 01:07:11 2008
New Revision: 721656

URL: http://svn.apache.org/viewvc?rev=721656&view=rev
Log:
[vysper] enhance and refactor pres handler test harness, more tests

Modified:
    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/core/im/handler/PresenceSubscriptionHandler.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/state/resourcebinding/ResourceRegistry.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/state/resourcebinding/ResourceState.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/core/im/handler/PresenceHandlerBaseTestCase.java
    labs/vysper/src/test/java/org/apache/vysper/xmpp/modules/core/im/handler/PresenceSubRequestOutHandlerTestCase.java
    labs/vysper/src/test/java/org/apache/vysper/xmpp/modules/roster/handler/RosterIQHandlerTestCase.java

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=721656&r1=721655&r2=721656&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 Sat Nov 29 01:07:11 2008
@@ -241,9 +241,9 @@
 
         ResourceState resourceState = registry.getResourceState(registry.getFirstResourceForSession(sessionContext));
 
-        boolean isPresenceUpdate = resourceState != null && !ResourceState.isNotYetAvailable(resourceState);
+        boolean isPresenceUpdate = resourceState != null && ResourceState.isAvailable(resourceState);
 
-        // TODO in case of !isPresenceUpdate, should we check for resourceState != ResourceState.INTERESTED ?
+        // TODO in case of !isPresenceUpdate, should we check for resourceState != ResourceState.AVAILABLE_INTERESTED ?
         // RFC3921bis-04#4.2.2 Initial Presence
         // RFC3921bis-04#4.4.2 Initial Presence
 
@@ -259,7 +259,7 @@
 
             // set resource state
             ResourceState currentState = registry.getResourceState(user.getResource());
-            // set to AVAILABLE, but do not override INTERESTED
+            // set to AVAILABLE, but do not override AVAILABLE_INTERESTED
             registry.setResourceState(user.getResource(), ResourceState.makeAvailable(currentState));
         }
         updateResourcePriority(registry, sessionContext.getInitiatingEntity(), presenceStanza.getPrioritySafe());

Modified: labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/core/im/handler/PresenceSubscriptionHandler.java
URL: http://svn.apache.org/viewvc/labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/core/im/handler/PresenceSubscriptionHandler.java?rev=721656&r1=721655&r2=721656&view=diff
==============================================================================
--- labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/core/im/handler/PresenceSubscriptionHandler.java (original)
+++ labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/core/im/handler/PresenceSubscriptionHandler.java Sat Nov 29 01:07:11 2008
@@ -60,7 +60,7 @@
         if (!isSubscriptionType(presenceStanza.getPresenceType())) {
             throw new RuntimeException("case not handled in availability handler" + presenceStanza.getPresenceType().value());
         }
-        
+
         // TODO: either use the resource associated with the session
         // (initiatingEntity)
         // or in case of multiple resources, use the from attribute or return an
@@ -84,7 +84,7 @@
 			// request/approval/cancellation/unsubscription
 			// stamp it with the bare JID of the user
 			Entity user = initiatingEntity;
-			PresenceStanza stampedStanza = buildPresenceStanza(user.getBareJID(), 
+			PresenceStanza stampedStanza = buildPresenceStanza(user.getBareJID(),
                     presenceStanza.getTo().getBareJID(), presenceStanza.getPresenceType(), null);
 
             switch (type) {
@@ -94,29 +94,29 @@
                     // user requests subsription to contact
                     handleOutboundSubscriptionRequest(stampedStanza, serverRuntimeContext, sessionContext, registry, rosterManager);
                     break;
-                
+
                 case SUBSCRIBED:
                     // RFC3921bis-04#3.1.5
                     // user approves subscription to requesting contact
                     handleOutboundSubscriptionApproval(stampedStanza, serverRuntimeContext, sessionContext, registry, rosterManager);
                     break;
-                
+
                 case UNSUBSCRIBE:
                     // RFC3921bis-04#3.3.2
                     // user removes subscription from contact
                     handleOutboundUnsubscription(stampedStanza, serverRuntimeContext, sessionContext, registry, rosterManager);
                     break;
-                
+
                 case UNSUBSCRIBED:
                     // RFC3921bis-04#3.2.2
-                    // user approves unsubscription of contact 
+                    // user approves unsubscription of contact
                     handleOutboundSubscriptionCancellation(stampedStanza, serverRuntimeContext, sessionContext, registry, rosterManager);
                     break;
-                
+
                 default:
                     throw new RuntimeException("unhandled case " + type.value());
             }
-            
+
         } else /* inbound */ {
 
             switch (type) {
@@ -177,7 +177,7 @@
                  subscription='none'/>
          </query>
        </iq>
-    
+
  */
     @SpecCompliant(spec = "RFC3921bis-04", section = "3.3.3")
 	protected void handleInboundUnsubscription(PresenceStanza stanza, ServerRuntimeContext serverRuntimeContext, SessionContext sessionContext, ResourceRegistry registry, RosterManager rosterManager) {
@@ -310,14 +310,14 @@
 
     /*
    FROM: http://www.xmpp.org/internet-drafts/draft-saintandre-rfc3921bis-05.txt
-   
+
    3.2.3.  Server Processing of Inbound Subscription Cancellation
-   
+
       When the user's server receives the inbound subscription
       cancellation, it MUST modify the subscription state and send a roster
       push to the user's interested resources, where the subscription state
       is now either "none" or "from" (see Appendix A).
-   
+
       US: <iq to='romeo@example.net/foo'
               type='set'
               id='h37h3u1bv400'>
@@ -326,7 +326,7 @@
                     subscription='none'/>
             </query>
           </iq>
-   
+
       US: <iq to='romeo@example.net/bar'
               type='set'
               id='h37h3u1bv401'>
@@ -336,8 +336,8 @@
               </item>
             </query>
           </iq>
-   
-   
+
+
     */
     @SpecCompliant(spec = "RFC3921bis-04", section = "3.2.3")
 	protected void handleInboundSubscriptionCancellation(PresenceStanza stanza,
@@ -847,13 +847,13 @@
 		StanzaRelay stanzaRelay = serverRuntimeContext.getStanzaRelay();
 
 		Entity user = stanza.getFrom();
-		Entity contact = stanza.getTo();
+		Entity contact = stanza.getTo().getBareJID();
 
         // TODO schedule a observer which can re-send the request
 
         RosterItem rosterItem = null;
         try {
-            rosterItem = getExistingOrNewRosterItem(rosterManager, user.getBareJID(), contact.getBareJID());
+            rosterItem = getExistingOrNewRosterItem(rosterManager, user.getBareJID(), contact);
         } catch (RosterException e) {
             e.printStackTrace();
             throw new RuntimeException(e);

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=721656&r1=721655&r2=721656&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 Sat Nov 29 01:07:11 2008
@@ -277,7 +277,7 @@
 	 * @return true if the resource is available, false otherwise.
 	 */
 	public boolean isResourceAvailable(String resourceId) {
-		return AVAILABLE.equals(getResourceState(resourceId));
+        return isAvailable(getResourceState(resourceId));
 	}
 
 	/**
@@ -292,7 +292,13 @@
 	}
 
 	public List<String> getInterestedResources(Entity entity) {
-		return filterResources(entity, INTERESTED);
+        List<String> resources = getResourceList(entity);
+        List<String> result = new ArrayList<String>();
+        for (String resource : resources) {
+            ResourceState resourceState = getResourceState(resource);
+            if (ResourceState.isInterested(resourceState)) result.add(resource);
+        }
+        return result;
 	}
 
     /**
@@ -300,31 +306,14 @@
      * @see org.apache.vysper.xmpp.state.resourcebinding.ResourceState
      */
 	public List<String> getAvailableResources(Entity entity) {
-		return filterResources(entity, AVAILABLE);
-	}
-
-	private List<String> filterResources(Entity entity, ResourceState state) {
-		if (state == null || entity == null) {
-			throw new IllegalArgumentException(
-					"entity or resourcestate must not be null");
-		}
-
-		List<String> resources = getResourceList(entity);
-		List<String> result = new ArrayList<String>();
-		for (String resource : resources) {
+        List<String> resources = getResourceList(entity);
+        List<String> result = new ArrayList<String>();
+        for (String resource : resources) {
             ResourceState resourceState = getResourceState(resource);
-            if (state == INTERESTED) {
-                // special handling to catch both interested-related states
-                if (ResourceState.isInterested(resourceState)) result.add(resource);
-            } else if (state == AVAILABLE) {
-                // special handling to handling inclusion ("INTERESTED" => available)
-                if (resourceState == AVAILABLE || resourceState == INTERESTED) {
-                    result.add(resource);
-                }
-            } else if (state.equals(resourceState)) {
+            if (resourceState == AVAILABLE || resourceState == AVAILABLE_INTERESTED) {
                 result.add(resource);
             }
         }
-		return result;
+        return result;
 	}
 }

Modified: labs/vysper/src/main/java/org/apache/vysper/xmpp/state/resourcebinding/ResourceState.java
URL: http://svn.apache.org/viewvc/labs/vysper/src/main/java/org/apache/vysper/xmpp/state/resourcebinding/ResourceState.java?rev=721656&r1=721655&r2=721656&view=diff
==============================================================================
--- labs/vysper/src/main/java/org/apache/vysper/xmpp/state/resourcebinding/ResourceState.java (original)
+++ labs/vysper/src/main/java/org/apache/vysper/xmpp/state/resourcebinding/ResourceState.java Sat Nov 29 01:07:11 2008
@@ -17,28 +17,28 @@
      * A conntected resource has requested the
      * entity's roster without sending initial presence first
      */
-    INTERESTED_NOT_YET_AVAILABLE,
+    CONNECTED_INTERESTED,
     /**
     * A connected resource is considered "available" after successfully sending
-      * its initial presence.
+      * its initial presence, it has not requested the roster yet
       */
     AVAILABLE,
     /**
      * An available resource is considered "interested" after requesting the
      * entity's roster.
      */
-    INTERESTED,
+    AVAILABLE_INTERESTED,
     /**
       * A resource is no longer "available" 
       */
     UNAVAILABLE;
 
     public static boolean isInterested(ResourceState resourceState) {
-        return resourceState == INTERESTED_NOT_YET_AVAILABLE || resourceState == INTERESTED;
+        return resourceState == CONNECTED_INTERESTED || resourceState == AVAILABLE_INTERESTED;
     }
     
-    public static boolean isNotYetAvailable(ResourceState resourceState) {
-        return resourceState != AVAILABLE && resourceState != INTERESTED;
+    public static boolean isAvailable(ResourceState resourceState) {
+        return resourceState == AVAILABLE || resourceState == AVAILABLE_INTERESTED;
     }
 
     /**
@@ -48,11 +48,11 @@
      */
     public static ResourceState makeAvailable(ResourceState inState) {
         if (inState == null || !isInterested(inState)) return AVAILABLE;
-        return INTERESTED;
+        return AVAILABLE_INTERESTED;
     }
 
     public static ResourceState makeInterested(ResourceState inState) {
-        if (inState == AVAILABLE) return INTERESTED;
-        return INTERESTED_NOT_YET_AVAILABLE;
+        if (inState == AVAILABLE) return AVAILABLE_INTERESTED;
+        return CONNECTED_INTERESTED;
     }
 }

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=721656&r1=721655&r2=721656&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 Sat Nov 29 01:07:11 2008
@@ -47,41 +47,41 @@
         // check presence broadcasts to resources of same session (self, interested & available)
         //
         
-        Stanza initiatorNotification = initiatorsQueue.getNext();
+        Stanza initiatorNotification = initiatingUser.getNextStanza();
         assertNotNull(initiatorNotification);
-        assertTrue(checkPresence(initiatorNotification, clientFullQualified, null));
-        assertTrue(initiatorNotification.getVerifier().toAttributeEquals(clientFullQualified.getFullQualifiedName()));
+        assertTrue(checkPresence(initiatorNotification, initiatingUser.getEntityFQ(), null));
+        assertTrue(initiatorNotification.getVerifier().toAttributeEquals(initiatingUser.getEntityFQ().getFullQualifiedName()));
         
-        Stanza availableResourceNotification = anotherAvailableResourceQueue.getNext();
+        Stanza availableResourceNotification = anotherAvailableUser.getNextStanza();
         assertNotNull(availableResourceNotification);
-        assertTrue(checkPresence(availableResourceNotification, clientFullQualified, null));
-        assertTrue(availableResourceNotification.getVerifier().toAttributeEquals(client.getFullQualifiedName() + "/" + anotherAvailableResourceId));
-        assertNull(anotherAvailableResourceQueue.getNext()); // no more stanzas
+        assertTrue(checkPresence(availableResourceNotification, initiatingUser.getEntityFQ(), null));
+        assertTrue(availableResourceNotification.getVerifier().toAttributeEquals(anotherAvailableUser.getEntityFQ().getFullQualifiedName()));
+        assertNull(anotherAvailableUser.getNextStanza()); // no more stanzas
         
-        Stanza interestedResourceNotification = anotherInterestedResourceQueue.getNext();
+        Stanza interestedResourceNotification = anotherInterestedUser.getNextStanza();
         assertNotNull(interestedResourceNotification);
-        assertTrue(checkPresence(interestedResourceNotification, clientFullQualified, null));
-        assertTrue(interestedResourceNotification.getVerifier().toAttributeEquals(client.getFullQualifiedName() + "/" + anotherInterestedResourceId));
-        assertNull(anotherInterestedResourceQueue.getNext()); // no more stanzas
+        assertTrue(checkPresence(interestedResourceNotification, initiatingUser.getEntityFQ(), null));
+        assertTrue(interestedResourceNotification.getVerifier().toAttributeEquals(initiatingUser.getEntity().getFullQualifiedName() + "/" + anotherInterestedUser.getBoundResourceId()));
+        assertNull(anotherInterestedUser.getNextStanza()); // no more stanzas
 
-        assertNull(anotherInterestedNotAvailResourceQueue.getNext()); // no stanza at all
+        assertNull(anotherInterestedNotAvailUser.getNextStanza()); // no stanza at all
 
         //
         // check other presences
         //        
         
-        assertNull(unrelatedQueue.getNext()); // does not sent pres to everybody arbitrarily
-        assertTrue(checkPresence(subscribed_FROM_Queue.getNext(), clientFullQualified, null)); // pres sent to FROM contacts
-        assertNull(subscribed_FROM_Queue.getNext()); // no second stanza sent to FROMs 
+        assertNull(unrelatedUser.getNextStanza()); // does not sent pres to everybody arbitrarily
+        assertTrue(checkPresence(subscribed_FROM.getNextStanza(), initiatingUser.getEntityFQ(), null)); // pres sent to FROM contacts
+        assertNull(subscribed_FROM.getNextStanza()); // no second stanza sent to FROMs
 
         // initial pres and pres probe might come in different order
-        assertTrue(checkPresence(subscribed_BOTH_Queue.getNext(), clientFullQualified, null)); // pres sent to BOTH contacts
-        assertTrue(checkPresence(subscribed_BOTH_Queue.getNext(), clientFullQualified, PROBE)); // probe sent to BOTH contacts
-        assertNull(subscribed_BOTH_Queue.getNext()); // no third stanza sent to BOTHs 
+        assertTrue(checkPresence(subscribed_BOTH.getNextStanza(), initiatingUser.getEntityFQ(), null)); // pres sent to BOTH contacts
+        assertTrue(checkPresence(subscribed_BOTH.getNextStanza(), initiatingUser.getEntityFQ(), PROBE)); // probe sent to BOTH contacts
+        assertNull(subscribed_BOTH.getNextStanza()); // no third stanza sent to BOTHs
 
-        assertTrue(checkPresence(subscribed_TO_Queue.getNext(), clientFullQualified, PROBE)); // probe sent to TO contacts
-        assertNull(subscribed_TO_Queue.getNext()); // pres NOT sent to TO contacts
+        assertTrue(checkPresence(subscribed_TO.getNextStanza(), initiatingUser.getEntityFQ(), PROBE)); // probe sent to TO contacts
+        assertNull(subscribed_TO.getNextStanza()); // pres NOT sent to TO contacts
     }
 
 
-}
\ No newline at end of file
+}

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=721656&r1=721655&r2=721656&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 Sat Nov 29 01:07:11 2008
@@ -38,13 +38,13 @@
         XMPPCoreStanza initialPresence = XMPPCoreStanza.getWrapper(StanzaBuilder.createPresenceStanza(null, null, null, null, null, null).getFinalStanza());
         handler.executeCore(initialPresence, sessionContext.getServerRuntimeContext(), true, sessionContext);
         assertTrue(0 < receiverRelay.getCountDelivered());
-        receiverRelay.resetAll(); // purge recorded 
+        resetRecordedStanzas(); // purge recorded 
         assertTrue(0 == receiverRelay.getCountDelivered());
         
         // send update now
         final String showValue = "chatty";
         
-        XMPPCoreStanza updatePresence = XMPPCoreStanza.getWrapper(StanzaBuilder.createPresenceStanza(clientFullQualified, null, null, null, showValue, null).getFinalStanza());
+        XMPPCoreStanza updatePresence = XMPPCoreStanza.getWrapper(StanzaBuilder.createPresenceStanza(initiatingUser.getEntityFQ(), null, null, null, showValue, null).getFinalStanza());
         handler.executeCore(updatePresence, sessionContext.getServerRuntimeContext(), true, sessionContext);
         // check resource state 
         assertEquals(ResourceState.AVAILABLE, getResourceState());
@@ -56,38 +56,38 @@
         // check presence broadcasts to resources of same session (self, interested & available)
         //
         
-        Stanza initiatorNotification = initiatorsQueue.getNext();
+        Stanza initiatorNotification = initiatingUser.getNextStanza();
         assertNotNull(initiatorNotification);
-        assertTrue(checkPresence(initiatorNotification, null, clientFullQualified, showValue));
-        assertTrue(initiatorNotification.getVerifier().toAttributeEquals(clientFullQualified.getFullQualifiedName()));
+        assertTrue(checkPresence(initiatorNotification, null, initiatingUser.getEntityFQ(), showValue));
+        assertTrue(initiatorNotification.getVerifier().toAttributeEquals(initiatingUser.getEntityFQ().getFullQualifiedName()));
         
-        Stanza availableResourceNotification = anotherAvailableResourceQueue.getNext();
+        Stanza availableResourceNotification = anotherAvailableUser.getNextStanza();
         assertNotNull(availableResourceNotification);
-        assertTrue(checkPresence(availableResourceNotification, null, clientFullQualified, showValue));
-        assertTrue(availableResourceNotification.getVerifier().toAttributeEquals(client.getFullQualifiedName() + "/" + anotherAvailableResourceId));
-        assertNull(anotherAvailableResourceQueue.getNext()); // no more stanzas
+        assertTrue(checkPresence(availableResourceNotification, null, initiatingUser.getEntityFQ(), showValue));
+        assertTrue(availableResourceNotification.getVerifier().toAttributeEquals(anotherAvailableUser.getEntityFQ().getFullQualifiedName()));
+        assertNull(anotherAvailableUser.getNextStanza()); // no more stanzas
         
-        Stanza interestedResourceNotification = anotherInterestedResourceQueue.getNext();
+        Stanza interestedResourceNotification = anotherInterestedUser.getNextStanza();
         assertNotNull(interestedResourceNotification);
-        assertTrue(checkPresence(interestedResourceNotification, null, clientFullQualified, showValue));
-        assertTrue(interestedResourceNotification.getVerifier().toAttributeEquals(client.getFullQualifiedName() + "/" + anotherInterestedResourceId));
-        assertNull(anotherInterestedResourceQueue.getNext()); // no more stanzas
+        assertTrue(checkPresence(interestedResourceNotification, null, initiatingUser.getEntityFQ(), showValue));
+        assertTrue(interestedResourceNotification.getVerifier().toAttributeEquals(initiatingUser.getEntity().getFullQualifiedName() + "/" + anotherInterestedUser.getBoundResourceId()));
+        assertNull(anotherInterestedUser.getNextStanza()); // no more stanzas
         
-        assertNull(anotherInterestedNotAvailResourceQueue.getNext()); // no stanza at all
+        assertNull(anotherInterestedNotAvailUser.getNextStanza()); // no stanza at all
 
         //
         // check other presences
         //        
         
-        assertNull(unrelatedQueue.getNext()); // does not sent pres to everybody arbitrarily
-        assertTrue(checkPresence(subscribed_FROM_Queue.getNext(), null, clientFullQualified, showValue)); // pres sent to FROM contacts
-        assertNull(subscribed_FROM_Queue.getNext()); // no second stanza sent to FROMs 
+        assertNull(unrelatedUser.getNextStanza()); // does not sent pres to everybody arbitrarily
+        assertTrue(checkPresence(subscribed_FROM.getNextStanza(), null, initiatingUser.getEntityFQ(), showValue)); // pres sent to FROM contacts
+        assertNull(subscribed_FROM.getNextStanza()); // no second stanza sent to FROMs
 
         // initial pres and pres probe might come in different order
-        assertTrue(checkPresence(subscribed_BOTH_Queue.getNext(), null, clientFullQualified, showValue)); // pres sent to BOTH contacts
-        assertNull(subscribed_BOTH_Queue.getNext()); // no second stanza (especially probe) sent to BOTHs
+        assertTrue(checkPresence(subscribed_BOTH.getNextStanza(), null, initiatingUser.getEntityFQ(), showValue)); // pres sent to BOTH contacts
+        assertNull(subscribed_BOTH.getNextStanza()); // no second stanza (especially probe) sent to BOTHs
 
-        assertNull(subscribed_TO_Queue.getNext()); // pres (especially probe)  NOT sent to TO contacts
+        assertNull(subscribed_TO.getNextStanza()); // pres (especially probe)  NOT sent to TO contacts
     }
 
 }

Modified: labs/vysper/src/test/java/org/apache/vysper/xmpp/modules/core/im/handler/PresenceHandlerBaseTestCase.java
URL: http://svn.apache.org/viewvc/labs/vysper/src/test/java/org/apache/vysper/xmpp/modules/core/im/handler/PresenceHandlerBaseTestCase.java?rev=721656&r1=721655&r2=721656&view=diff
==============================================================================
--- labs/vysper/src/test/java/org/apache/vysper/xmpp/modules/core/im/handler/PresenceHandlerBaseTestCase.java (original)
+++ labs/vysper/src/test/java/org/apache/vysper/xmpp/modules/core/im/handler/PresenceHandlerBaseTestCase.java Sat Nov 29 01:07:11 2008
@@ -19,15 +19,16 @@
 import junit.framework.TestCase;
 import org.apache.vysper.xmpp.server.TestSessionContext;
 import org.apache.vysper.xmpp.modules.roster.persistence.MemoryRosterManager;
-import org.apache.vysper.xmpp.modules.roster.RosterItem;
-import org.apache.vysper.xmpp.modules.roster.SubscriptionType;
-import org.apache.vysper.xmpp.modules.roster.AskSubscriptionType;
-import org.apache.vysper.xmpp.modules.roster.RosterException;
+import org.apache.vysper.xmpp.modules.roster.*;
 import org.apache.vysper.xmpp.addressing.EntityImpl;
 import org.apache.vysper.xmpp.addressing.Entity;
+import org.apache.vysper.xmpp.addressing.EntityFormatException;
 import org.apache.vysper.xmpp.state.resourcebinding.ResourceState;
+import org.apache.vysper.xmpp.state.resourcebinding.BindException;
 import org.apache.vysper.xmpp.stanza.Stanza;
 import org.apache.vysper.xmpp.stanza.PresenceStanzaType;
+import org.apache.vysper.xmpp.stanza.IQStanza;
+import org.apache.vysper.xmpp.stanza.XMPPCoreStanza;
 import org.apache.vysper.xmpp.xmlfragment.XMLElementVerifier;
 import org.apache.vysper.xmpp.xmlfragment.XMLSemanticError;
 import org.apache.vysper.xmpp.delivery.StanzaReceiverQueue;
@@ -38,23 +39,18 @@
  */
 abstract public class PresenceHandlerBaseTestCase extends TestCase {
 
+
     protected TestSessionContext sessionContext;
-    protected String boundResourceId;
-    protected EntityImpl client;
-    protected StanzaReceiverQueue initiatorsQueue;
-    protected EntityImpl clientFullQualified = null;
-    protected StanzaReceiverQueue anotherInterestedResourceQueue;
-    protected StanzaReceiverQueue anotherInterestedNotAvailResourceQueue;
-    protected StanzaReceiverQueue anotherAvailableResourceQueue;
-    protected StanzaReceiverQueue unrelatedQueue;
-    protected String anotherAvailableResourceId;
-    protected String anotherInterestedNotAvailResourceId;
-    protected String anotherInterestedResourceId;
     protected MemoryRosterManager rosterManager;
-    protected StanzaReceiverQueue subscribed_TO_Queue;
-    protected StanzaReceiverQueue subscribed_BOTH_Queue;
-    protected StanzaReceiverQueue subscribed_FROM_Queue;
-    protected EntityImpl unrelatedEntity;
+
+    protected TestUser initiatingUser;
+    protected TestUser anotherInterestedNotAvailUser;
+    protected TestUser anotherInterestedUser;
+    protected TestUser anotherAvailableUser;
+    protected TestUser unrelatedUser;
+    protected TestUser subscribed_TO;
+    protected TestUser subscribed_BOTH;
+    protected TestUser subscribed_FROM;
 
     @Override
     protected void setUp() throws Exception {
@@ -63,45 +59,30 @@
         rosterManager = new MemoryRosterManager();
         sessionContext.getServerRuntimeContext().registerServerRuntimeContextService(rosterManager);
 
-        client = EntityImpl.parse("tester@vysper.org");
+        Entity client = EntityImpl.parse("tester@vysper.org");
         sessionContext.setInitiatingEntity(client);
-        boundResourceId = sessionContext.bindResource();
-        initiatorsQueue = sessionContext.addReceiver(client, boundResourceId);
-        clientFullQualified = new EntityImpl(client, boundResourceId);
+        initiatingUser = TestUser.createForSession(sessionContext, client);
 
         // set up more resources for the same session
-        anotherInterestedNotAvailResourceId = sessionContext.bindResource();
-        anotherInterestedNotAvailResourceQueue = sessionContext.addReceiver(client, anotherInterestedNotAvailResourceId);
-        setResourceState(anotherInterestedNotAvailResourceId, ResourceState.INTERESTED_NOT_YET_AVAILABLE);
-
-        anotherInterestedResourceId = sessionContext.bindResource();
-        anotherInterestedResourceQueue = sessionContext.addReceiver(client, anotherInterestedResourceId);
-        setResourceState(anotherInterestedResourceId, ResourceState.INTERESTED);
-
-        anotherAvailableResourceId = sessionContext.bindResource();
-        anotherAvailableResourceQueue = sessionContext.addReceiver(client, anotherAvailableResourceId);
-        setResourceState(anotherAvailableResourceId, ResourceState.AVAILABLE);
+        anotherInterestedNotAvailUser = TestUser.createForSession(sessionContext, client);
+        setResourceState(anotherInterestedNotAvailUser.getBoundResourceId(), ResourceState.CONNECTED_INTERESTED);
+
+        anotherInterestedUser = TestUser.createForSession(sessionContext, client);
+        setResourceState(anotherInterestedUser.getBoundResourceId(), ResourceState.AVAILABLE_INTERESTED);
+
+        anotherAvailableUser = TestUser.createForSession(sessionContext, client);
+        setResourceState(anotherAvailableUser.getBoundResourceId(), ResourceState.AVAILABLE);
 
         // set up completely unrelated resource
-        unrelatedEntity = EntityImpl.parse("unrelated@vysper.org");
-        unrelatedQueue = sessionContext.addReceiver(unrelatedEntity, null);
+        unrelatedUser = TestUser.createQueueReceiver(sessionContext, "unrelated@vysper.org");
 
         // now we have:
         // 4 resources for the same entity: one initiating, one interested (not yet avail), one interested (implicitly avail), one available
         // and another unrelated resource
 
-        EntityImpl subscribed_TO = EntityImpl.parse("subscribed_to@vysper.org");
-        rosterManager.addContact(client, new RosterItem(subscribed_TO, SubscriptionType.TO));
-        subscribed_TO_Queue = sessionContext.addReceiver(subscribed_TO, null);
-
-        EntityImpl subscribed_BOTH = EntityImpl.parse("subscribed_both@vysper.org");
-        rosterManager.addContact(client, new RosterItem(subscribed_BOTH, SubscriptionType.BOTH));
-        subscribed_BOTH_Queue = sessionContext.addReceiver(subscribed_BOTH, null);
-
-        EntityImpl subscribed_FROM = EntityImpl.parse("subscribed_from@vysper.org");
-        rosterManager.addContact(client, new RosterItem(subscribed_FROM, SubscriptionType.FROM));
-        subscribed_FROM_Queue = sessionContext.addReceiver(subscribed_FROM, null);
-
+        subscribed_TO = TestUser.createContact(sessionContext, rosterManager, "subscribed_to@vysper.org", SubscriptionType.TO);
+        subscribed_BOTH = TestUser.createContact(sessionContext, rosterManager, "subscribed_both@vysper.org", SubscriptionType.BOTH);
+        subscribed_FROM = TestUser.createContact(sessionContext, rosterManager, "subscribed_from@vysper.org", SubscriptionType.FROM);
     }
 
     protected void setResourceState(String resourceId, ResourceState state) {
@@ -135,7 +116,7 @@
     }
 
     protected ResourceState getResourceState() {
-        return sessionContext.getServerRuntimeContext().getResourceRegistry().getResourceState(boundResourceId);
+        return sessionContext.getServerRuntimeContext().getResourceRegistry().getResourceState(initiatingUser.getBoundResourceId());
     }
 
     protected void assertStanzasRelayed(int expectedRelayed, int expectedDelivered) {
@@ -145,7 +126,7 @@
 
     protected boolean checkRosterItem(Entity contactEntity, SubscriptionType expectedSubscriptionType, AskSubscriptionType expectedAskSubscriptionType) {
         try {
-            RosterItem contact = rosterManager.getContact(client, contactEntity);
+            RosterItem contact = rosterManager.getContact(initiatingUser.getEntity(), contactEntity);
             assertNotNull(contact);
             assertEquals(expectedSubscriptionType, contact.getSubscriptionType());
             assertEquals(expectedAskSubscriptionType, contact.getAskSubscriptionType());
@@ -154,4 +135,84 @@
         }
         return true;
     }
+
+    protected boolean checkRosterPush(Stanza stanza, Entity entity, Entity contact, SubscriptionType subscriptionType, AskSubscriptionType askSubscriptionType) {
+        if (stanza == null) return false;
+        IQStanza rosterPush = (IQStanza) XMPPCoreStanza.getWrapper(stanza);
+        rosterPush.getInnerElementsNamed("query");
+
+        RosterItem rosterItem = null;
+        try {
+            rosterItem = RosterUtils.parseRosterItemForTesting(rosterPush);
+        } catch (Exception e) {
+            fail(e.toString());
+        }
+        assertEquals(rosterPush.getTo(), entity);
+        assertEquals(contact, rosterItem.getJid());
+        assertEquals(subscriptionType, rosterItem.getSubscriptionType());
+        assertEquals(subscriptionType, rosterItem.getSubscriptionType());
+        assertEquals(askSubscriptionType, rosterItem.getAskSubscriptionType());
+
+        return true;
+    }
+
+    protected void resetRecordedStanzas() {
+        StanzaReceiverRelay receiverRelay = (StanzaReceiverRelay) sessionContext.getServerRuntimeContext().getStanzaRelay();
+        receiverRelay.resetAll();
+    }
 }
+
+class TestUser {
+    protected String boundResourceId;
+    protected Entity entity;
+    protected StanzaReceiverQueue queue;
+    protected Entity fqEntity;
+
+    static TestUser createForSession(TestSessionContext sessionContext, Entity entity) throws BindException {
+        String boundResourceId = sessionContext.bindResource();
+        StanzaReceiverQueue queue = sessionContext.addReceiver(entity, boundResourceId);
+        return new TestUser(boundResourceId, entity, queue);
+    }
+
+    static TestUser createQueueReceiver(TestSessionContext parentSession, String entity) throws BindException, EntityFormatException {
+        return createQueueReceiver(parentSession, EntityImpl.parse(entity));
+    }
+
+    static TestUser createQueueReceiver(TestSessionContext parentSession, Entity entity) throws BindException {
+        StanzaReceiverQueue queue = parentSession.addReceiver(entity, null);
+        return new TestUser(null, entity, queue);
+    }
+
+    static TestUser createContact(TestSessionContext parentSession, MemoryRosterManager rosterManager, String entity, SubscriptionType subscriptionType) throws BindException, EntityFormatException, RosterException {
+        TestUser testUser = createQueueReceiver(parentSession, EntityImpl.parse(entity));
+        rosterManager.addContact(parentSession.getInitiatingEntity(), new RosterItem(testUser.getEntity(), subscriptionType));
+        return testUser;
+    }
+
+    TestUser(String boundResourceId, Entity entity, StanzaReceiverQueue queue) {
+        this.boundResourceId = boundResourceId;
+        this.entity = entity;
+        this.queue = queue;
+        this.fqEntity = new EntityImpl(entity, boundResourceId);
+    }
+
+    public String getBoundResourceId() {
+        return boundResourceId;
+    }
+
+    public Entity getEntity() {
+        return entity;
+    }
+
+    public StanzaReceiverQueue getQueue() {
+        return queue;
+    }
+
+    public Stanza getNextStanza() {
+        return queue.getNext();
+    }
+
+    public Entity getEntityFQ() {
+        return fqEntity;
+    }
+}
\ No newline at end of file

Modified: labs/vysper/src/test/java/org/apache/vysper/xmpp/modules/core/im/handler/PresenceSubRequestOutHandlerTestCase.java
URL: http://svn.apache.org/viewvc/labs/vysper/src/test/java/org/apache/vysper/xmpp/modules/core/im/handler/PresenceSubRequestOutHandlerTestCase.java?rev=721656&r1=721655&r2=721656&view=diff
==============================================================================
--- labs/vysper/src/test/java/org/apache/vysper/xmpp/modules/core/im/handler/PresenceSubRequestOutHandlerTestCase.java (original)
+++ labs/vysper/src/test/java/org/apache/vysper/xmpp/modules/core/im/handler/PresenceSubRequestOutHandlerTestCase.java Sat Nov 29 01:07:11 2008
@@ -17,16 +17,10 @@
 
 package org.apache.vysper.xmpp.modules.core.im.handler;
 
-import org.apache.vysper.xmpp.addressing.Entity;
 import org.apache.vysper.xmpp.addressing.EntityFormatException;
 import org.apache.vysper.xmpp.addressing.EntityImpl;
-import org.apache.vysper.xmpp.modules.roster.AskSubscriptionType;
-import static org.apache.vysper.xmpp.modules.roster.AskSubscriptionType.ASK_SUBSCRIBE;
-import org.apache.vysper.xmpp.modules.roster.RosterItem;
-import org.apache.vysper.xmpp.modules.roster.RosterUtils;
-import org.apache.vysper.xmpp.modules.roster.SubscriptionType;
-import static org.apache.vysper.xmpp.modules.roster.SubscriptionType.NONE;
-import org.apache.vysper.xmpp.stanza.IQStanza;
+import static org.apache.vysper.xmpp.modules.roster.AskSubscriptionType.*;
+import static org.apache.vysper.xmpp.modules.roster.SubscriptionType.*;
 import org.apache.vysper.xmpp.stanza.PresenceStanzaType;
 import org.apache.vysper.xmpp.stanza.Stanza;
 import org.apache.vysper.xmpp.stanza.StanzaBuilder;
@@ -40,63 +34,103 @@
 
     protected PresenceHandler handler = new PresenceHandler();
 
-    public void testOutgoingSubscriptionRequest() throws BindException, EntityFormatException {
+    public void testUnrelated_Approved() throws BindException, EntityFormatException {
 
-        setResourceState(boundResourceId, ResourceState.AVAILABLE);
+        requestSubscribeToUnrelated();
 
-        XMPPCoreStanza initialPresence = XMPPCoreStanza.getWrapper(StanzaBuilder.createPresenceStanza(clientFullQualified, unrelatedEntity, null, PresenceStanzaType.SUBSCRIBE, null, null).getFinalStanza());
+        // now entity 'unrelated' approves the subscription
+
+        XMPPCoreStanza requestApproval = XMPPCoreStanza.getWrapper(StanzaBuilder.createPresenceStanza(unrelatedUser.getEntityFQ(), initiatingUser.getEntity(), null, PresenceStanzaType.SUBSCRIBED, null, null).getFinalStanza());
+        handler.executeCore(requestApproval, sessionContext.getServerRuntimeContext(), false, sessionContext);
+
+        assertStanzasRelayed(1+3, 1+3);
+    }
+
+    private void requestSubscribeToUnrelated() {
+        setResourceState(initiatingUser.getBoundResourceId(), ResourceState.AVAILABLE_INTERESTED);
+
+        XMPPCoreStanza initialPresence = XMPPCoreStanza.getWrapper(StanzaBuilder.createPresenceStanza(initiatingUser.getEntityFQ(), unrelatedUser.getEntity(), null, PresenceStanzaType.SUBSCRIBE, null, null).getFinalStanza());
 
         handler.executeCore(initialPresence, sessionContext.getServerRuntimeContext(), true, sessionContext);
-        assertEquals(ResourceState.AVAILABLE, getResourceState());
+        assertEquals(ResourceState.AVAILABLE_INTERESTED, getResourceState());
+
+        // 1 to TO + 3 roster pushes
+        assertStanzasRelayed(1+3, 1+3);
+
+        // roster push for interested initiator
+        Stanza initiatorNotification = initiatingUser.getNextStanza();
+        assertTrue(checkRosterPush(initiatorNotification, initiatingUser.getEntityFQ(), unrelatedUser.getEntity(), NONE, ASK_SUBSCRIBE));
+        assertNull(initiatingUser.getNextStanza()); // no more stanzas
+
+        // no stanzas for not interested
+        assertNull(anotherAvailableUser.getNextStanza());
 
-        // 1 to TO + 2 roster pushes
-        assertStanzasRelayed(1+2, 1+2);
+        // roster push for interested
+        Stanza interestedResourceNotification = anotherInterestedUser.getNextStanza();
+        assertTrue(checkRosterPush(interestedResourceNotification, new EntityImpl(initiatingUser.getEntity(), anotherInterestedUser.getBoundResourceId()), unrelatedUser.getEntity(), NONE, ASK_SUBSCRIBE));
+        assertNull(anotherInterestedUser.getNextStanza()); // no more stanzas
 
-//        Stanza initiatorNotification = initiatorsQueue.getNext();
-//        assertNotNull(initiatorNotification);
-/*        assertTrue(checkPresence(initiatorNotification, PresenceStanzaType.SUBSCRIBE));
-        assertTrue(initiatorNotification.getVerifier().fromAttributeEquals(clientFullQualified.getFullQualifiedName()));
-        assertTrue(initiatorNotification.getVerifier().toAttributeEquals(clientFullQualified.getFullQualifiedName()));*/
-        
-//        Stanza availableResourceNotification = anotherAvailableResourceQueue.getNext();
-//        assertNotNull(availableResourceNotification);
-/*        assertTrue(checkPresence(availableResourceNotification, null));
-        assertTrue(availableResourceNotification.getVerifier().fromAttributeEquals(clientFullQualified.getFullQualifiedName()));
-        assertTrue(availableResourceNotification.getVerifier().toAttributeEquals(client.getFullQualifiedName() + "/" + anotherAvailableResourceId));*/
-        assertNull(anotherAvailableResourceQueue.getNext()); // no more stanzas
-        
-        Stanza interestedResourceNotification = anotherInterestedResourceQueue.getNext();
-        assertNotNull(interestedResourceNotification);
-        assertTrue(checkRosterPush(interestedResourceNotification, new EntityImpl(client, anotherInterestedResourceId), unrelatedEntity, NONE, ASK_SUBSCRIBE));
-        assertNull(anotherInterestedResourceQueue.getNext()); // no more stanzas
-
-//        assertNull(anotherInterestedNotAvailResourceQueue.getNext()); // no stanza at all
-
-        // sub request sent
-        assertTrue(checkPresence(unrelatedQueue.getNext(), PresenceStanzaType.SUBSCRIBE, client, null)); // pres sent to FROM contacts
-        assertNull(unrelatedQueue.getNext()); // no other stanza
+        // roster push for interested
+        Stanza interestedNotYetAvailResourceNotification = anotherInterestedNotAvailUser.getNextStanza();
+        assertTrue(checkRosterPush(interestedNotYetAvailResourceNotification, new EntityImpl(initiatingUser.getEntity(), anotherInterestedNotAvailUser.getBoundResourceId()), unrelatedUser.getEntity(), NONE, ASK_SUBSCRIBE));
+        assertNull(anotherInterestedNotAvailUser.getNextStanza()); // no more stanzas
 
-        assertTrue(checkRosterItem(unrelatedEntity, NONE, ASK_SUBSCRIBE));
+        // sub request sent to contact
+        assertTrue(checkPresence(unrelatedUser.getNextStanza(), PresenceStanzaType.SUBSCRIBE, initiatingUser.getEntity(), null));
+        assertNull(unrelatedUser.getNextStanza()); // no other stanza
+
+        assertTrue(checkRosterItem(unrelatedUser.getEntity(), NONE, ASK_SUBSCRIBE));
+
+        // unrelatedUser approves
+        resetRecordedStanzas();
     }
 
-    protected boolean checkRosterPush(Stanza stanza, Entity entity, Entity contact, SubscriptionType subscriptionType, AskSubscriptionType askSubscriptionType) {
-        if (stanza == null) return false;
-        IQStanza rosterPush = (IQStanza) XMPPCoreStanza.getWrapper(stanza);
-        rosterPush.getInnerElementsNamed("query");
-
-        RosterItem rosterItem = null;
-        try {
-            rosterItem = RosterUtils.parseRosterItemForTesting(rosterPush);
-        } catch (Exception e) {
-            fail(e.toString());
-        }
-        assertEquals(rosterPush.getTo(), entity);
-        assertEquals(contact, rosterItem.getJid());
-        assertEquals(subscriptionType, rosterItem.getSubscriptionType());
-        assertEquals(subscriptionType, rosterItem.getSubscriptionType());
-        assertEquals(askSubscriptionType, rosterItem.getAskSubscriptionType());
+    public void testWithFROM() throws BindException, EntityFormatException {
+
+        setResourceState(initiatingUser.getBoundResourceId(), ResourceState.AVAILABLE_INTERESTED);
+
+        XMPPCoreStanza initialPresence = XMPPCoreStanza.getWrapper(StanzaBuilder.createPresenceStanza(initiatingUser.getEntityFQ(), subscribed_FROM.getEntity(), null, PresenceStanzaType.SUBSCRIBE, null, null).getFinalStanza());
+
+        handler.executeCore(initialPresence, sessionContext.getServerRuntimeContext(), true, sessionContext);
+        assertEquals(ResourceState.AVAILABLE_INTERESTED, getResourceState());
+
+        // 1 to TO + 3 roster pushes
+        assertStanzasRelayed(1+3, 1+3);
+
+        // roster push for interested initiator
+        Stanza initiatorNotification = initiatingUser.getNextStanza();
+        assertTrue(checkRosterPush(initiatorNotification, initiatingUser.getEntityFQ(), subscribed_FROM.getEntity(), FROM, ASK_SUBSCRIBE));
+        assertNull(initiatingUser.getNextStanza()); // no more stanzas
+
+        // sub request sent to contact
+        assertTrue(checkPresence(subscribed_FROM.getNextStanza(), PresenceStanzaType.SUBSCRIBE, initiatingUser.getEntity(), null)); 
+        assertNull(subscribed_FROM.getNextStanza()); // no other stanza
+
+        assertTrue(checkRosterItem(subscribed_FROM.getEntity(), FROM, ASK_SUBSCRIBE));
+    }
+
+    public void testWithTO() throws BindException, EntityFormatException {
+
+        setResourceState(initiatingUser.getBoundResourceId(), ResourceState.AVAILABLE_INTERESTED);
+
+        XMPPCoreStanza initialPresence = XMPPCoreStanza.getWrapper(StanzaBuilder.createPresenceStanza(initiatingUser.getEntityFQ(), subscribed_TO.getEntity(), null, PresenceStanzaType.SUBSCRIBE, null, null).getFinalStanza());
+
+        handler.executeCore(initialPresence, sessionContext.getServerRuntimeContext(), true, sessionContext);
+        assertEquals(ResourceState.AVAILABLE_INTERESTED, getResourceState());
+
+        assertStanzasRelayed(0, 0); // TO subscription already exists
+    }
+
+    public void testWithBOTH() throws BindException, EntityFormatException {
+
+        setResourceState(initiatingUser.getBoundResourceId(), ResourceState.AVAILABLE_INTERESTED);
+
+        XMPPCoreStanza initialPresence = XMPPCoreStanza.getWrapper(StanzaBuilder.createPresenceStanza(initiatingUser.getEntityFQ(), subscribed_BOTH.getEntity(), null, PresenceStanzaType.SUBSCRIBE, null, null).getFinalStanza());
+
+        handler.executeCore(initialPresence, sessionContext.getServerRuntimeContext(), true, sessionContext);
+        assertEquals(ResourceState.AVAILABLE_INTERESTED, getResourceState());
 
-        return true;
+        assertStanzasRelayed(0, 0); // TO subscription already exists with subscribed_BOTH
     }
 
 }
\ No newline at end of file

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=721656&r1=721655&r2=721656&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 Sat Nov 29 01:07:11 2008
@@ -39,7 +39,7 @@
 
         assertEquals(ResourceState.CONNECTED, getResourceState());
         handler.execute(stanzaBuilder.getFinalStanza(), sessionContext.getServerRuntimeContext(), true, sessionContext, null);
-        assertEquals(ResourceState.INTERESTED_NOT_YET_AVAILABLE, getResourceState());
+        assertEquals(ResourceState.CONNECTED_INTERESTED, getResourceState());
         
 //        C: <iq from='juliet@example.com/balcony'
 //               type='get'
@@ -57,7 +57,7 @@
         sessionContext.getServerRuntimeContext().getResourceRegistry().setResourceState(boundResourceId, ResourceState.AVAILABLE);
         
         handler.execute(stanzaBuilder.getFinalStanza(), sessionContext.getServerRuntimeContext(), true, sessionContext, null);
-        assertEquals(ResourceState.INTERESTED, getResourceState());
+        assertEquals(ResourceState.AVAILABLE_INTERESTED, getResourceState());
     }
 
     private StanzaBuilder createRosterGet() {



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