Package org.jivesoftware.smack.packet.RosterPacket

Examples of org.jivesoftware.smack.packet.RosterPacket.Item


                    if (packet instanceof RosterPacket && ((IQ) packet).getType() == Type.SET) {
                        final RosterPacket rosterRequest = (RosterPacket) packet;

                        // Prepare and process the roster push
                        final RosterPacket rosterPush = new RosterPacket();
                        final Item item = rosterRequest.getRosterItems().iterator().next();
                        if (item.getItemType() != ItemType.remove) {
                            item.setItemType(ItemType.none);
                        }
                        rosterPush.setType(Type.SET);
                        rosterPush.setTo(connection.getUser());
                        rosterPush.addRosterItem(item);
                        connection.processPacket(rosterPush);
View Full Code Here


        rosterListener.reset();

        // Adding the new roster item
        final RosterUpdateResponder serverSimulator = new RosterUpdateResponder() {
            void verifyUpdateRequest(final RosterPacket updateRequest) {
                final Item item = updateRequest.getRosterItems().iterator().next();
                assertSame("The provided JID doesn't match the requested!",
                        contactJID,
                        item.getUser());
                assertSame("The provided name doesn't match the requested!",
                        contactName,
                        item.getName());
                assertSame("The provided group number doesn't match the requested!",
                        contactGroup.length,
                        item.getGroupNames().size());
                assertSame("The provided group doesn't match the requested!",
                        contactGroup[0],
                        item.getGroupNames().iterator().next());
            }
        };
        serverSimulator.start();
        roster.createEntry(contactJID, contactName, contactGroup);
        serverSimulator.join();
View Full Code Here

        rosterListener.reset();

        // Updating the roster item
        final RosterUpdateResponder serverSimulator = new RosterUpdateResponder() {
            void verifyUpdateRequest(final RosterPacket updateRequest) {
                final Item item = updateRequest.getRosterItems().iterator().next();
                assertSame("The provided JID doesn't match the requested!",
                        contactJID,
                        item.getUser());
                assertSame("The provided name doesn't match the requested!",
                        contactName,
                        item.getName());
                assertTrue("The updated contact doesn't belong to the requested groups ("
                        + contactGroups[0] +")!",
                        item.getGroupNames().contains(contactGroups[0]));
                assertTrue("The updated contact doesn't belong to the requested groups ("
                        + contactGroups[1] +")!",
                        item.getGroupNames().contains(contactGroups[1]));
                assertSame("The provided group number doesn't match the requested!",
                        contactGroups.length,
                        item.getGroupNames().size());
            }
        };
        serverSimulator.start();
        roster.createGroup(contactGroups[1]).addEntry(roster.getEntry(contactJID));
        serverSimulator.join();
View Full Code Here

        rosterListener.reset();

        // Delete a roster item
        final RosterUpdateResponder serverSimulator = new RosterUpdateResponder() {
            void verifyUpdateRequest(final RosterPacket updateRequest) {
                final Item item = updateRequest.getRosterItems().iterator().next();
                assertSame("The provided JID doesn't match the requested!",
                        contactJID,
                        item.getUser());
            }
        };
        serverSimulator.start();
        roster.removeEntry(roster.getEntry(contactJID));
        serverSimulator.join();
View Full Code Here

        rosterListener.reset();

        // Adding the new roster item
        final RosterUpdateResponder serverSimulator = new RosterUpdateResponder() {
            void verifyUpdateRequest(final RosterPacket updateRequest) {
                final Item item = updateRequest.getRosterItems().iterator().next();
                assertSame("The provided JID doesn't match the requested!",
                        contactJID,
                        item.getUser());
                assertSame("The provided name doesn't match the requested!",
                        contactName,
                        item.getName());
                assertSame("Shouldn't provide an empty group element!",
                        0,
                        item.getGroupNames().size());
               
            }
        };
        serverSimulator.start();
        roster.createEntry(contactJID, contactName, contactGroup);
View Full Code Here

                rosterResult.setTo(connection.getUser());
                rosterResult.setType(Type.RESULT);
                rosterResult.setPacketID(rosterRequest.getPacketID());

                // prepare romeo's roster entry
                final Item romeo = new Item("romeo@example.net", "Romeo");
                romeo.addGroupName("Friends");
                romeo.setItemType(ItemType.both);
                rosterResult.addRosterItem(romeo);

                // prepare mercutio's roster entry
                final Item mercutio = new Item("mercutio@example.com", "Mercutio");
                mercutio.setItemType(ItemType.from);
                rosterResult.addRosterItem(mercutio);

                // prepare benvolio's roster entry
                final Item benvolio = new Item("benvolio@example.net", "Benvolio");
                benvolio.setItemType(ItemType.both);
                rosterResult.addRosterItem(benvolio);

                // simulate receiving the roster result and exit the loop
                connection.processPacket(rosterResult);
                break;
View Full Code Here

TOP

Related Classes of org.jivesoftware.smack.packet.RosterPacket.Item

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.