From 13d1c07741d8acadbb8e92c70195bafb002c086c Mon Sep 17 00:00:00 2001 From: Gaston Dombiak Date: Wed, 4 Aug 2004 19:54:17 +0000 Subject: [PATCH] Adds new test for discovering client's identity. SMACK-149 git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@2349 b35dd754-fafc-0310-a699-88a17e54d16e --- .../smackx/ServiceDiscoveryManagerTest.java | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/test/org/jivesoftware/smackx/ServiceDiscoveryManagerTest.java b/test/org/jivesoftware/smackx/ServiceDiscoveryManagerTest.java index 82376bf82..9130bb361 100644 --- a/test/org/jivesoftware/smackx/ServiceDiscoveryManagerTest.java +++ b/test/org/jivesoftware/smackx/ServiceDiscoveryManagerTest.java @@ -52,7 +52,11 @@ package org.jivesoftware.smackx; +import java.util.Iterator; + +import org.jivesoftware.smack.SmackConfiguration; import org.jivesoftware.smack.test.SmackTestCase; +import org.jivesoftware.smackx.packet.DiscoverInfo; import org.jivesoftware.smackx.packet.DiscoverItems; @@ -71,6 +75,33 @@ public class ServiceDiscoveryManagerTest extends SmackTestCase { super(arg0); } + /** + * Tests info discovery of a Smack client. + */ + public void testSmackInfo() { + + ServiceDiscoveryManager discoManager = ServiceDiscoveryManager + .getInstanceFor(getConnection(0)); + try { + // Discover the information of another Smack client + DiscoverInfo info = discoManager.discoverInfo(getFullJID(1)); + // Check the identity of the Smack client + Iterator identities = info.getIdentities(); + assertTrue("No identities were found", identities.hasNext()); + DiscoverInfo.Identity identity = (DiscoverInfo.Identity)identities.next(); + assertEquals("Name in identity is wrong", SmackConfiguration.getIdentityName(), + identity.getName()); + assertEquals("Category in identity is wrong", "client", identity.getCategory()); + assertEquals("Type in identity is wrong", SmackConfiguration.getIdentityType(), + identity.getType()); + assertFalse("More identities were found", identities.hasNext()); + } + catch (Exception e) { + e.printStackTrace(); + fail(e.getMessage()); + } + } + /** * Tests service discovery of XHTML support. */