/** * Removes the group created in the server stored contact list by the create group test, makes * sure that the corresponding event has been generated and verifies that the group is not in the * list any more. */ public void postTestRemoveGroup() { logger.trace("testing removal of server stored groups"); // first add a listener GroupChangeCollector groupChangeCollector = new GroupChangeCollector(); opSetPersPresence1.addServerStoredGroupChangeListener(groupChangeCollector); try { // remove the group opSetPersPresence1.removeServerStoredContactGroup( opSetPersPresence1.getServerStoredContactListRoot().getGroup(testGroupName2)); } catch (OperationFailedException ex) { logger.error("error removing group", ex); } groupChangeCollector.waitForEvent(10000); opSetPersPresence1.removeServerStoredGroupChangeListener(groupChangeCollector); // check whether we got group created event assertEquals("Collected Group Change event", 1, groupChangeCollector.collectedEvents.size()); assertEquals( "Group name.", testGroupName2, ((ServerStoredGroupEvent) groupChangeCollector.collectedEvents.get(0)) .getSourceGroup() .getGroupName()); // check whether the group is still on the contact list ContactGroup group = opSetPersPresence1.getServerStoredContactListRoot().getGroup(testGroupName2); assertNull("A freshly removed group was still on the contact list.", group); }
/** * Creates a group in the server stored contact list, makes sure that the corresponding event has * been generated and verifies that the group is in the list. * * @throws java.lang.Exception */ public void postTestCreateGroup() throws Exception { // first clear the list fixture.clearProvidersLists(); Object o = new Object(); synchronized (o) { o.wait(3000); } logger.trace("testing creation of server stored groups"); // first add a listener GroupChangeCollector groupChangeCollector = new GroupChangeCollector(); opSetPersPresence1.addServerStoredGroupChangeListener(groupChangeCollector); // create the group opSetPersPresence1.createServerStoredContactGroup( opSetPersPresence1.getServerStoredContactListRoot(), testGroupName); groupChangeCollector.waitForEvent(10000); opSetPersPresence1.removeServerStoredGroupChangeListener(groupChangeCollector); // check whether we got group created event assertEquals("Collected Group Change events: ", 1, groupChangeCollector.collectedEvents.size()); assertEquals( "Group name.", testGroupName, ((ServerStoredGroupEvent) groupChangeCollector.collectedEvents.get(0)) .getSourceGroup() .getGroupName()); // check whether the group is retrievable ContactGroup group = opSetPersPresence1.getServerStoredContactListRoot().getGroup(testGroupName); assertNotNull("A newly created group was not in the contact list.", group); assertEquals("New group name", testGroupName, group.getGroupName()); // when opearting with groups . the group must have entries // so changes to take effect. Otherwise group will be lost after loggingout try { opSetPersPresence1.subscribe(group, fixture.userID2); synchronized (o) { o.wait(1500); } } catch (Exception ex) { fail("error adding entry to group : " + group.getGroupName() + " " + ex.getMessage()); } }
/** * Renames our test group and checks whether corresponding events are triggered. Verifies whether * the group has really changed its name and whether it is findable by its new name. Also makes * sure that it does not exist under its previous name any more. */ public void postTestRenameGroup() { logger.trace("Testing renaming groups."); ContactGroup group = opSetPersPresence1.getServerStoredContactListRoot().getGroup(testGroupName); // first add a listener GroupChangeCollector groupChangeCollector = new GroupChangeCollector(); opSetPersPresence1.addServerStoredGroupChangeListener(groupChangeCollector); // change the name and wait for a confirmation event opSetPersPresence1.renameServerStoredContactGroup(group, testGroupName2); groupChangeCollector.waitForEvent(10000); opSetPersPresence1.removeServerStoredGroupChangeListener(groupChangeCollector); // examine the event assertEquals("Collected Group Change event", 1, groupChangeCollector.collectedEvents.size()); assertEquals( "Group name.", testGroupName2, ((ServerStoredGroupEvent) groupChangeCollector.collectedEvents.get(0)) .getSourceGroup() .getGroupName()); // check whether the group is still on the contact list ContactGroup oldGroup = opSetPersPresence1.getServerStoredContactListRoot().getGroup(testGroupName); assertNull("A group was still findable by its old name after renaming.", oldGroup); // make sure that we could find the group by its new name. ContactGroup newGroup = opSetPersPresence1.getServerStoredContactListRoot().getGroup(testGroupName2); assertNotNull("Could not find a renamed group by its new name.", newGroup); }