From 924c27d94c2e0bb212e8426b09c84d534b4f08ce Mon Sep 17 00:00:00 2001 From: Gaston Dombiak Date: Sun, 18 Jan 2004 14:13:43 +0000 Subject: [PATCH] *** empty log message *** git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@2211 b35dd754-fafc-0310-a699-88a17e54d16e --- test/org/jivesoftware/smack/RosterTest.java | 79 +++++++++++---------- 1 file changed, 42 insertions(+), 37 deletions(-) diff --git a/test/org/jivesoftware/smack/RosterTest.java b/test/org/jivesoftware/smack/RosterTest.java index 714802137..503745249 100644 --- a/test/org/jivesoftware/smack/RosterTest.java +++ b/test/org/jivesoftware/smack/RosterTest.java @@ -89,7 +89,10 @@ public class RosterTest extends TestCase { conn1.getRoster().createEntry("gato11@" + conn1.getHost(), "gato11", new String[] {"Friends", "Family"}); conn1.getRoster().createEntry("gato12@" + conn1.getHost(), "gato12", new String[] {"Family"}); - Thread.sleep(200); + // Wait until the server confirms the new entries + while (conn1.getRoster().getEntryCount() != 2) { + Thread.sleep(50); + } Iterator it = conn1.getRoster().getEntries(); while (it.hasNext()) { @@ -98,12 +101,9 @@ public class RosterTest extends TestCase { while (groups.hasNext()) { RosterGroup rosterGroup = (RosterGroup) groups.next(); rosterGroup.removeEntry(entry); - Thread.sleep(250); } } - - assertEquals("The number of entries in conn1 should be 2", 2, conn1.getRoster().getEntryCount()); - assertEquals("The number of groups in conn1 should be 0", 0, conn1.getRoster().getGroupCount()); + Thread.sleep(750); assertEquals("The number of entries in conn2 should be 1", 1, conn2.getRoster().getEntryCount()); assertEquals("The number of groups in conn2 should be 0", 0, conn2.getRoster().getGroupCount()); @@ -111,6 +111,9 @@ public class RosterTest extends TestCase { assertEquals("The number of entries in conn3 should be 1", 1, conn3.getRoster().getEntryCount()); assertEquals("The number of groups in conn3 should be 0", 0, conn3.getRoster().getGroupCount()); + assertEquals("The number of entries in conn1 should be 2", 2, conn1.getRoster().getEntryCount()); + assertEquals("The number of groups in conn1 should be 0", 0, conn1.getRoster().getGroupCount()); + cleanUpRoster(); } catch (Exception e) { @@ -217,6 +220,39 @@ public class RosterTest extends TestCase { } } + /** + * Test if renaming a roster group works fine. + * + */ + public void testRenameRosterGroup() { + try { + // Add a new roster entry + conn1.getRoster().createEntry("gato11@" + conn1.getHost(), "gato11", new String[] {"Friends"}); + conn1.getRoster().createEntry("gato12@" + conn1.getHost(), "gato12", new String[] {"Friends"}); + + Thread.sleep(200); + + conn1.getRoster().getGroup("Friends").setName("Amigos"); + Thread.sleep(200); + assertNull("The group Friends still exists", conn1.getRoster().getGroup("Friends")); + assertNotNull("The group Amigos does not exist", conn1.getRoster().getGroup("Amigos")); + assertEquals("Wrong number of entries in the group Amigos ", 2, conn1.getRoster().getGroup("Amigos").getEntryCount()); + + + conn1.getRoster().getGroup("Amigos").setName(""); + Thread.sleep(200); + assertNull("The group Amigos still exists", conn1.getRoster().getGroup("Amigos")); + assertNotNull("The group with no name does not exist", conn1.getRoster().getGroup("")); + assertEquals("Wrong number of entries in the group \"\" ", 2, conn1.getRoster().getGroup("").getEntryCount()); + + cleanUpRoster(); + Thread.sleep(200); + } + catch (Exception e) { + fail(e.getMessage()); + } + } + /** * Test presence management. */ @@ -269,6 +305,7 @@ public class RosterTest extends TestCase { } assertEquals("Wrong number of returned presences", count, 1); + Thread.sleep(200); cleanUpRoster(); } @@ -277,38 +314,6 @@ public class RosterTest extends TestCase { } } - /** - * Test if renaming a roster group works fine. - * - */ - public void testRenameRosterGroup() { - try { - // Add a new roster entry - conn1.getRoster().createEntry("gato11@" + conn1.getHost(), "gato11", new String[] {"Friends"}); - conn1.getRoster().createEntry("gato12@" + conn1.getHost(), "gato12", new String[] {"Friends"}); - - Thread.sleep(200); - - conn1.getRoster().getGroup("Friends").setName("Amigos"); - Thread.sleep(200); - assertNull("The group Friends still exists", conn1.getRoster().getGroup("Friends")); - assertNotNull("The group Amigos does not exist", conn1.getRoster().getGroup("Amigos")); - assertEquals("Wrong number of entries in the group Amigos ", 2, conn1.getRoster().getGroup("Amigos").getEntryCount()); - - - conn1.getRoster().getGroup("Amigos").setName(""); - Thread.sleep(200); - assertNull("The group Amigos still exists", conn1.getRoster().getGroup("Amigos")); - assertNotNull("The group with no name does not exist", conn1.getRoster().getGroup("")); - assertEquals("Wrong number of entries in the group \"\" ", 2, conn1.getRoster().getGroup("").getEntryCount()); - - cleanUpRoster(); - } - catch (Exception e) { - fail(e.getMessage()); - } - } - /** * Clean up all the entries in the roster */