Package rocks.xmpp.core.session

Examples of rocks.xmpp.core.session.TestXmppSession


public class PingManagerTest extends ExtensionTest {

    @Test
    public void testPing() throws XmppException {
        MockServer mockServer = new MockServer();
        TestXmppSession connection1 = new TestXmppSession(ROMEO, mockServer);
        new TestXmppSession(JULIET, mockServer);
        PingManager pingManager = connection1.getExtensionManager(PingManager.class);
        pingManager.ping(JULIET);
    }
View Full Code Here


    }

    @Test(expectedExceptions = StanzaException.class)
    public void testPingIfDisabled() throws XmppException {
        MockServer mockServer = new MockServer();
        TestXmppSession connection1 = new TestXmppSession(ROMEO, mockServer);
        TestXmppSession connection2 = new TestXmppSession(JULIET, mockServer);
        connection2.getExtensionManager(PingManager.class).setEnabled(false);
        PingManager pingManager = connection1.getExtensionManager(PingManager.class);
        pingManager.ping(JULIET);
    }
View Full Code Here

        pingManager.ping(JULIET);
    }

    @Test
    public void testServiceDiscoveryEntry() {
        TestXmppSession connection1 = new TestXmppSession();
        PingManager pingManager = connection1.getExtensionManager(PingManager.class);
        // By default, the manager should be enabled.
        Assert.assertTrue(pingManager.isEnabled());
        ServiceDiscoveryManager serviceDiscoveryManager = connection1.getExtensionManager(ServiceDiscoveryManager.class);
        Feature feature = new Feature("urn:xmpp:ping");
        Assert.assertTrue(serviceDiscoveryManager.getFeatures().contains(feature));
        pingManager.setEnabled(false);
        Assert.assertFalse(pingManager.isEnabled());
        Assert.assertFalse(serviceDiscoveryManager.getFeatures().contains(feature));
View Full Code Here

public class BoshConnectionTest {

    @Test
    public void testInsertionOrder() {

        BoshConnection boshConnection = new BoshConnection(new TestXmppSession(), BoshConnectionConfiguration.getDefault());

        Body body1 = Body.builder().build();
        boshConnection.unacknowledgedRequests.put(1L, body1);

        Body body2 = Body.builder().build();
View Full Code Here

    protected Unmarshaller unmarshaller;

    protected TestXmppSession xmppSession;

    public BaseTest() {
        xmppSession = new TestXmppSession();
    }
View Full Code Here

    @Test
    public void testRosterListener() throws XMLStreamException, JAXBException {
        final int[] rosterPushCount = new int[1];

        RosterManager rosterManager = new RosterManager(new TestXmppSession());
        rosterManager.addRosterListener(new RosterListener() {
            @Override
            public void rosterChanged(RosterEvent e) {
                if (rosterPushCount[0] == 0) {
                    Assert.assertEquals(e.getAddedContacts().size(), 3);
View Full Code Here

        rosterManager.updateRoster(roster4, true);
    }

    @Test
    public void testRosterGroups() {
        RosterManager rosterManager = new RosterManager(new TestXmppSession());

        Roster roster1 = new Roster();
        roster1.getContacts().add(new Contact(Jid.valueOf("contact1@domain"), "contact1", "Group1"));
        roster1.getContacts().add(new Contact(Jid.valueOf("contact2@domain"), "contact2", "Group2"));
        roster1.getContacts().add(new Contact(Jid.valueOf("contact4@domain"), "contact4", "Group3"));
View Full Code Here

        Assert.assertEquals(iterator.next().getJid(), Jid.valueOf("contact5@domain"));
    }

    @Test
    public void testNestedRosterGroups() {
        RosterManager rosterManager = new RosterManager(new TestXmppSession());
        rosterManager.setGroupDelimiter("::");
        Roster roster1 = new Roster();
        roster1.getContacts().add(new Contact(Jid.valueOf("contact3@domain"), "contact3", "Group3::SubGroup"));
        roster1.getContacts().add(new Contact(Jid.valueOf("contact4@domain"), "contact4", "Group3::SubGroup::3rdLevel"));
        roster1.getContacts().add(new Contact(Jid.valueOf("contact5@domain"), "contact5", "Group3"));
View Full Code Here

    }

    @Test
    public void testRosterIntegrity() {

        RosterManager rosterManager = new RosterManager(new TestXmppSession());

        // Initial roster
        Roster roster1 = new Roster();
        roster1.getContacts().add(new Contact(Jid.valueOf("contact1@domain"), "contact1", "group1"));
        roster1.getContacts().add(new Contact(Jid.valueOf("contact2@domain"), "contact2", "group2"));
View Full Code Here

        Assert.assertEquals(DatatypeConverter.printBase64Binary(scramSaslClient.hi("test".getBytes(), "salt".getBytes(), 4096)), "suIjHg0e14CDoom6wmHKz3naWOc=");
    }

    @Test
    public void testSasl() throws SaslException {
        XmppSession xmppSession = new TestXmppSession();
        String[] preferredMechanisms = xmppSession.getAuthenticationManager().getPreferredMechanisms().toArray(new String[xmppSession.getAuthenticationManager().getPreferredMechanisms().size()]);
        SaslClient sc = Sasl.createSaslClient(preferredMechanisms, "authorizationId", "xmpp", "localhost", null, new CallbackHandler() {
            @Override
            public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
                for (Callback callback : callbacks) {
                    if (callback instanceof NameCallback) {
View Full Code Here

TOP

Related Classes of rocks.xmpp.core.session.TestXmppSession

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.