Package rocks.xmpp.core.session

Examples of rocks.xmpp.core.session.TestXmppSession


        xmppSession1.send(message);
    }

    @Test
    public void testEnablingManager() {
        TestXmppSession connection1 = new TestXmppSession();
        MessageDeliveryReceiptsManager messageDeliveryReceiptsManager = connection1.getExtensionManager(MessageDeliveryReceiptsManager.class);
        Assert.assertFalse(messageDeliveryReceiptsManager.isEnabled());
    }
View Full Code Here


public class HeadersManagerTest extends ExtensionTest {

    @Test
    public void testServiceDiscoveryIfHeadersAreDisabled() throws XmppException {
        MockServer mockServer = new MockServer();
        TestXmppSession connection1 = new TestXmppSession(JULIET, mockServer);
        TestXmppSession connection2 = new TestXmppSession(ROMEO, mockServer);

        // JULIET supports the following headers:
        HeaderManager headerManager = connection1.getExtensionManager(HeaderManager.class);
        headerManager.getSupportedHeaders().add("In-Reply-To");
        headerManager.getSupportedHeaders().add("Keywords");

        ServiceDiscoveryManager serviceDiscoveryManager = connection2.getExtensionManager(ServiceDiscoveryManager.class);
        InfoNode infoNode = null;
        try {
            infoNode = serviceDiscoveryManager.discoverInformation(JULIET);
        } catch (StanzaException e) {
            Assert.fail();
View Full Code Here

public class SoftwareVersionManagerTest extends ExtensionTest {

    @Test
    public void testSoftwareVersionManager() throws XmppException {
        MockServer mockServer = new MockServer();
        TestXmppSession connection1 = new TestXmppSession(ROMEO, mockServer);
        new TestXmppSession(JULIET, mockServer);
        TestXmppSession connection2 = new TestXmppSession(JULIET, mockServer);
        connection2.getExtensionManager(SoftwareVersionManager.class).setSoftwareVersion(new SoftwareVersion("Name", "Version"));
        SoftwareVersionManager softwareVersionManager = connection1.getExtensionManager(SoftwareVersionManager.class);
        SoftwareVersion softwareVersion = softwareVersionManager.getSoftwareVersion(JULIET);
        Assert.assertNotNull(softwareVersion);
        Assert.assertEquals(softwareVersion.getName(), "Name");
        Assert.assertEquals(softwareVersion.getVersion(), "Version");
View Full Code Here

    }

    @Test
    public void testServiceDiscoveryIfHeadersAreEnabled() throws XmppException {
        MockServer mockServer = new MockServer();
        TestXmppSession connection1 = new TestXmppSession(JULIET, mockServer);
        TestXmppSession connection2 = new TestXmppSession(ROMEO, mockServer);

        // JULIET supports the following headers:
        HeaderManager headerManager = connection1.getExtensionManager(HeaderManager.class);
        headerManager.getSupportedHeaders().add("In-Reply-To");
        headerManager.getSupportedHeaders().add("Keywords");
        headerManager.setEnabled(true);

        ServiceDiscoveryManager serviceDiscoveryManager = connection2.getExtensionManager(ServiceDiscoveryManager.class);
        InfoNode infoNode = null;
        try {
            infoNode = serviceDiscoveryManager.discoverInformation(JULIET);
        } catch (StanzaException e) {
            Assert.fail();
View Full Code Here

        Assert.assertFalse(messageDeliveryReceiptsManager.isEnabled());
    }

    @Test
    public void testListeners() throws IOException {
        TestXmppSession connection1 = new TestXmppSession();

        MessageDeliveryReceiptsManager messageDeliveryReceiptsManager = connection1.getExtensionManager(MessageDeliveryReceiptsManager.class);

        MessageDeliveredListener messageDeliveredListener = new MessageDeliveredListener() {
            @Override
            public void messageDelivered(MessageDeliveredEvent e) {

            }
        };
        messageDeliveryReceiptsManager.addMessageDeliveredListener(messageDeliveredListener);
        Assert.assertEquals(messageDeliveryReceiptsManager.messageDeliveredListeners.size(), 1);
        messageDeliveryReceiptsManager.removeMessageDeliveredListener(messageDeliveredListener);
        Assert.assertEquals(messageDeliveryReceiptsManager.messageDeliveredListeners.size(), 0);
        messageDeliveryReceiptsManager.addMessageDeliveredListener(new MessageDeliveredListener() {
            @Override
            public void messageDelivered(MessageDeliveredEvent e) {

            }
        });

        connection1.close();
        // Listeners should be cleared now.
        Assert.assertEquals(messageDeliveryReceiptsManager.messageDeliveredListeners.size(), 0);
    }
View Full Code Here

    }

    @Test
    public void testDiscoverSupportedHeaders() throws XmppException {
        MockServer mockServer = new MockServer();
        TestXmppSession connection1 = new TestXmppSession(JULIET, mockServer);
        TestXmppSession connection2 = new TestXmppSession(ROMEO, mockServer);

        // JULIET supports the following headers:
        HeaderManager headerManager = connection1.getExtensionManager(HeaderManager.class);
        headerManager.getSupportedHeaders().add("In-Reply-To");
        headerManager.getSupportedHeaders().add("Keywords");
        headerManager.setEnabled(true);

        HeaderManager headerManager2 = connection2.getExtensionManager(HeaderManager.class);
        List<String> headers = headerManager2.discoverSupportedHeaders(JULIET);

        Assert.assertEquals(headers.size(), 2);
        Assert.assertTrue(headers.contains("In-Reply-To"));
        Assert.assertTrue(headers.contains("Keywords"));
View Full Code Here

    }

    @Test
    public void testSoftwareVersionManagerIfDisabled() throws XmppException {
        MockServer mockServer = new MockServer();
        TestXmppSession connection1 = new TestXmppSession(ROMEO, mockServer);
        TestXmppSession connection2 = new TestXmppSession(JULIET, mockServer);
        connection2.getExtensionManager(SoftwareVersionManager.class).setEnabled(false);
        SoftwareVersionManager softwareVersionManager = connection1.getExtensionManager(SoftwareVersionManager.class);
        try {
            softwareVersionManager.getSoftwareVersion(JULIET);
        } catch (StanzaException e) {
            return;
View Full Code Here

        Assert.assertEquals(messageDeliveryReceiptsManager.messageDeliveredListeners.size(), 0);
    }

    @Test
    public void testServiceDiscoveryEntry() {
        TestXmppSession connection1 = new TestXmppSession();
        MessageDeliveryReceiptsManager messageDeliveryReceiptsManager = connection1.getExtensionManager(MessageDeliveryReceiptsManager.class);
        Assert.assertFalse(messageDeliveryReceiptsManager.isEnabled());
        ServiceDiscoveryManager serviceDiscoveryManager = connection1.getExtensionManager(ServiceDiscoveryManager.class);
        Feature feature = new Feature("urn:xmpp:receipts");
        Assert.assertFalse(serviceDiscoveryManager.getFeatures().contains(feature));
        messageDeliveryReceiptsManager.setEnabled(true);
        Assert.assertTrue(messageDeliveryReceiptsManager.isEnabled());
        Assert.assertTrue(serviceDiscoveryManager.getFeatures().contains(feature));
View Full Code Here

        Assert.fail();
    }

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

*/
public class MessageCorrectionManagerTest extends ExtensionTest {

    @Test
    public void testServiceDiscoveryEntry() {
        TestXmppSession connection1 = new TestXmppSession();
        MessageCorrectionManager manager = connection1.getExtensionManager(MessageCorrectionManager.class);
        // By default, the manager should NOT be enabled.
        Assert.assertFalse(manager.isEnabled());
        ServiceDiscoveryManager serviceDiscoveryManager = connection1.getExtensionManager(ServiceDiscoveryManager.class);
        Feature feature = new Feature("urn:xmpp:message-correct:0");
        Assert.assertFalse(serviceDiscoveryManager.getFeatures().contains(feature));
        manager.setEnabled(true);
        Assert.assertTrue(manager.isEnabled());
        Assert.assertTrue(serviceDiscoveryManager.getFeatures().contains(feature));
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.