Examples of TestXmppSession


Examples of rocks.xmpp.core.session.TestXmppSession

*/
public class RpcManagerTest extends ExtensionTest {

    @Test
    public void testServiceDiscoveryEntry() {
        TestXmppSession connection1 = new TestXmppSession();
        RpcManager rpcManager = connection1.getExtensionManager(RpcManager.class);
        Assert.assertFalse(rpcManager.isEnabled());
        ServiceDiscoveryManager serviceDiscoveryManager = connection1.getExtensionManager(ServiceDiscoveryManager.class);
        Feature feature = new Feature("jabber:iq:rpc");
        Assert.assertFalse(serviceDiscoveryManager.getFeatures().contains(feature));
        rpcManager.setEnabled(true);
        Assert.assertTrue(rpcManager.isEnabled());
        Assert.assertTrue(serviceDiscoveryManager.getFeatures().contains(feature));
View Full Code Here

Examples of rocks.xmpp.core.session.TestXmppSession

    @Test
    public void testCall() throws XmppException, RpcException {
        MockServer mockServer = new MockServer();

        XmppSession xmppSession1 = new TestXmppSession(ROMEO, mockServer);
        XmppSession xmppSession2 = new TestXmppSession(JULIET, mockServer);

        RpcManager rpcManager = xmppSession1.getExtensionManager(RpcManager.class);
        rpcManager.executorService = new SameThreadExecutorService();
        rpcManager.setEnabled(true);
        rpcManager.setRpcHandler(new RpcHandler() {
            @Override
            public Value process(Jid requester, String methodName, List<Value> parameters) throws RpcException {
                if (methodName.equals("square")) {
                    return new Value(parameters.get(0).getAsInteger() * parameters.get(0).getAsInteger());
                }
                return null;
            }
        });

        Value result = xmppSession2.getExtensionManager(RpcManager.class).call(ROMEO, "square", new Value(2));
        Assert.assertEquals(result.getAsInteger().intValue(), 4);
    }
View Full Code Here

Examples of rocks.xmpp.core.session.TestXmppSession

    @Test
    public void testRpcException() throws XmppException {
        MockServer mockServer = new MockServer();

        XmppSession xmppSession1 = new TestXmppSession(ROMEO, mockServer);
        XmppSession xmppSession2 = new TestXmppSession(JULIET, mockServer);

        RpcManager rpcManager = xmppSession1.getExtensionManager(RpcManager.class);
        rpcManager.setEnabled(true);

        rpcManager.executorService = new SameThreadExecutorService();

        rpcManager.setRpcHandler(new RpcHandler() {
            @Override
            public Value process(Jid requester, String methodName, List<Value> parameters) throws RpcException {
                if (methodName.equals("fault")) {
                    throw new RpcException(2, "faulty");
                }
                return null;
            }
        });

        try {
            xmppSession2.getExtensionManager(RpcManager.class).call(ROMEO, "fault", new Value(2));
        } catch (RpcException e) {
            Assert.assertEquals(e.getFaultCode(), 2);
            Assert.assertEquals(e.getFaultString(), "faulty");
            return;
        }
View Full Code Here

Examples of rocks.xmpp.core.session.TestXmppSession

*/
public class IbbTest extends ExtensionTest {

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

Examples of rocks.xmpp.core.session.TestXmppSession

    }

    @Test
    public void testIbbSessionRejection() {
        MockServer mockServer = new MockServer();
        final XmppSession xmppSession1 = new TestXmppSession(ROMEO, mockServer);
        final XmppSession xmppSession2 = new TestXmppSession(JULIET, mockServer);
        InBandByteStreamManager inBandBytestreamManager2 = xmppSession2.getExtensionManager(InBandByteStreamManager.class);
        inBandBytestreamManager2.addByteStreamListener(new ByteStreamListener() {
            @Override
            public void byteStreamRequested(final ByteStreamEvent e) {
                e.reject();
            }
View Full Code Here

Examples of rocks.xmpp.core.session.TestXmppSession

    //@Test
    public void testInBandBytestreamManager() throws IOException {
        MockServer mockServer = new MockServer();
        final Lock lock = new ReentrantLock();
        final XmppSession xmppSession1 = new TestXmppSession(ROMEO, mockServer);
        final XmppSession xmppSession2 = new TestXmppSession(JULIET, mockServer);
        final Condition condition = lock.newCondition();
        final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();

        new Thread() {
            @Override
            public void run() {
                InBandByteStreamManager inBandBytestreamManager2 = xmppSession2.getExtensionManager(InBandByteStreamManager.class);
                inBandBytestreamManager2.addByteStreamListener(new ByteStreamListener() {
                    @Override
                    public void byteStreamRequested(final ByteStreamEvent e) {
                        final ByteStreamSession ibbSession;
View Full Code Here

Examples of rocks.xmpp.core.session.TestXmppSession

*/
public class PubSubEntityUseCasesTest extends ExtensionTest {

    @Test
    public void testFeatures() {
        TestXmppSession xmppSession = new TestXmppSession();
        InfoDiscovery infoDiscovery = new InfoDiscovery();
        infoDiscovery.getFeatures().add(new Feature("http://jabber.org/protocol/pubsub#collections"));
        infoDiscovery.getFeatures().add(new Feature("http://jabber.org/protocol/pubsub#config-node"));
        infoDiscovery.getFeatures().add(new Feature("http://jabber.org/protocol/disco#info"));
        PubSubManager pubSubManager = xmppSession.getExtensionManager(PubSubManager.class);
        Collection<PubSubFeature> pubSubFeatures = pubSubManager.createPubSubService(null).getFeatures(infoDiscovery);

        Assert.assertEquals(pubSubFeatures.size(), 2);
        Assert.assertTrue(pubSubFeatures.contains(PubSubFeature.COLLECTIONS));
        Assert.assertTrue(pubSubFeatures.contains(PubSubFeature.CONFIG_NODE));
View Full Code Here

Examples of rocks.xmpp.core.session.TestXmppSession

*/
public class LastActivityManagerTest extends ExtensionTest {

    @Test
    public void testLastActivityManagerIsCleared() throws IOException {
        TestXmppSession xmppSession1 = new TestXmppSession();
        LastActivityManager lastActivityManager = xmppSession1.getExtensionManager(LastActivityManager.class);
        lastActivityManager.setLastActivityStrategy(new LastActivityStrategy() {
            @Override
            public Date getLastActivity() {
                return new Date();
            }
        });
        xmppSession1.close();
        Assert.assertNull(lastActivityManager.getLastActivityStrategy());
    }
View Full Code Here

Examples of rocks.xmpp.core.session.TestXmppSession

    }

    @Test
    public void testGetLastActivity() throws XmppException {
        MockServer mockServer = new MockServer();
        TestXmppSession xmppSession1 = new TestXmppSession(ROMEO, mockServer);
        new TestXmppSession(JULIET, mockServer);
        LastActivityManager lastActivityManager = xmppSession1.getExtensionManager(LastActivityManager.class);
        LastActivity lastActivity = lastActivityManager.getLastActivity(JULIET);
        Assert.assertNotNull(lastActivity);
    }
View Full Code Here

Examples of rocks.xmpp.core.session.TestXmppSession

    }

    @Test
    public void testGetLastActivityIfDisabled() throws XmppException {
        MockServer mockServer = new MockServer();
        TestXmppSession xmppSession1 = new TestXmppSession(ROMEO, mockServer);
        TestXmppSession xmppSession2 = new TestXmppSession(JULIET, mockServer);
        xmppSession2.getExtensionManager(LastActivityManager.class).setEnabled(false);
        LastActivityManager lastActivityManager = xmppSession1.getExtensionManager(LastActivityManager.class);
        try {
            lastActivityManager.getLastActivity(JULIET);
        } catch (StanzaException e) {
            return;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.