Java 类org.jivesoftware.smack.roster.rosterstore.RosterStore 实例源码

项目:Smack    文件:Roster.java   
/**
 * Set the roster store, may cause a roster reload
 *
 * @param rosterStore
 * @return true if the roster reload was initiated, false otherwise.
 * @since 4.1
 */
public boolean setRosterStore(RosterStore rosterStore) {
    this.rosterStore = rosterStore;
    try {
        reload();
    }
    catch (NotLoggedInException | NotConnectedException e) {
        LOGGER.log(Level.FINER, "Could not reload roster", e);
        return false;
    }
    return true;
}
项目:Smack    文件:RosterVersioningTest.java   
/**
 * Tests that a non-empty roster result empties the store.
 * @throws SmackException 
 * @throws XMPPException 
 */
@Test(timeout = 5000)
public void testOtherVersionStored() throws InterruptedException, XMPPException, SmackException {
    Item vaglafItem = vaglafItem();

    // We expect that the roster request is the only packet sent. This is not part of the specification,
    // but a shortcut in the test implementation.
    Stanza sentPacket = connection.getSentPacket();
    if (sentPacket instanceof RosterPacket) {
        RosterPacket sentRP = (RosterPacket)sentPacket;
        RosterPacket answer = new RosterPacket();
        answer.setStanzaId(sentRP.getStanzaId());
        answer.setType(Type.result);
        answer.setTo(sentRP.getFrom());

        answer.setVersion("newVersion");
        answer.addRosterItem(vaglafItem);

        rosterListener.reset();
        connection.processPacket(answer);
        rosterListener.waitUntilInvocationOrTimeout();
    } else {
        assertTrue("Expected to get a RosterPacket ", false);
    }

    Roster roster = Roster.getInstanceFor(connection);
    assertEquals("Size of roster", 1, roster.getEntries().size());
    RosterEntry entry = roster.getEntry(vaglafItem.getUser());
    assertNotNull("Roster contains vaglaf entry", entry);
    assertEquals("vaglaf entry in roster equals the sent entry", vaglafItem, RosterEntry.toRosterItem(entry));

    RosterStore store = roster.getRosterStore();
    assertEquals("Size of store", 1, store.getEntries().size());
    Item item = store.getEntry(vaglafItem.getUser());
    assertNotNull("Store contains vaglaf entry");
    assertEquals("vaglaf entry in store equals the sent entry", vaglafItem, item);
}
项目:Smack    文件:Roster.java   
RosterStore getRosterStore() {
    return rosterStore;
}