Package rocks.xmpp.core.stanza.model.client

Examples of rocks.xmpp.core.stanza.model.client.Message


                "    <items node='princely_musings'>\n" +
                "      <retract id='ae890ac52d0df67ed7cfdf51b644e901'/>\n" +
                "    </items>\n" +
                "  </event>\n" +
                "</message>\n";
        Message message = unmarshal(xml, Message.class);
        Assert.assertNotNull(message);
        Event event = message.getExtension(Event.class);
        Assert.assertNotNull(event);
        Assert.assertNotNull(event.getItems());
        //Assert.assertNotNull(event.getItems().getRetract());
        //Assert.assertEquals(event.getItems().getRetract().getId(), "ae890ac52d0df67ed7cfdf51b644e901");
    }
View Full Code Here


        String xml = "<message from='pubsub.shakespeare.lit' to='francisco@denmark.lit' id='foo'>\n" +
                "  <event xmlns='http://jabber.org/protocol/pubsub#event'>\n" +
                "    <configuration node='princely_musings'/>\n" +
                "  </event>\n" +
                "</message>";
        Message message = unmarshal(xml, Message.class);
        Assert.assertNotNull(message);
        Event event = message.getExtension(Event.class);
        Assert.assertNotNull(event);
        Assert.assertTrue(event.isConfiguration());
        Assert.assertEquals(event.getNode(), "princely_musings");
    }
View Full Code Here

                "        </field>\n" +
                "      </x>\n" +
                "    </configuration>\n" +
                "  </event>\n" +
                "</message>";
        Message message = unmarshal(xml, Message.class);
        Assert.assertNotNull(message);
        Event event = message.getExtension(Event.class);
        Assert.assertNotNull(event);
        Assert.assertTrue(event.isConfiguration());
        Assert.assertEquals(event.getNode(), "princely_musings");
        Assert.assertNotNull(event.getConfigurationForm());
    }
View Full Code Here

                "    <delete node='princely_musings'>\n" +
                "      <redirect uri='xmpp:hamlet@denmark.lit?;node=blog'/>\n" +
                "    </delete>\n" +
                "  </event>\n" +
                "</message>";
        Message message = unmarshal(xml, Message.class);
        Assert.assertNotNull(message);
        Event event = message.getExtension(Event.class);
        Assert.assertNotNull(event);
        Assert.assertTrue(event.isDelete());
        Assert.assertEquals(event.getNode(), "princely_musings");
        Assert.assertNotNull(event.getRedirectUri());
        Assert.assertEquals(event.getRedirectUri(), URI.create("xmpp:hamlet@denmark.lit?;node=blog"));
View Full Code Here

        String xml = "<message from='pubsub.shakespeare.lit' to='francisco@denmark.lit' id='foo'>\n" +
                "  <event xmlns='http://jabber.org/protocol/pubsub#event'>\n" +
                "    <purge node='princely_musings'/>\n" +
                "  </event>\n" +
                "</message>";
        Message message = unmarshal(xml, Message.class);
        Assert.assertNotNull(message);
        Event event = message.getExtension(Event.class);
        Assert.assertNotNull(event);
        Assert.assertNotNull(event.isPurge());
        Assert.assertEquals(event.getNode(), "princely_musings");
    }
View Full Code Here

                "        node='princely_musings'\n" +
                "        subid='ba49252aaa4f5d320c24d3766f0bdcade78c78d3'\n" +
                "        subscription='subscribed'/>\n" +
                "  </event>\n" +
                "</message>\n";
        Message message = unmarshal(xml, Message.class);
        Assert.assertNotNull(message);
        Event event = message.getExtension(Event.class);
        Assert.assertNotNull(event);
        Assert.assertNotNull(event.getSubscription());
        Assert.assertNotNull(event.getSubscription().getExpiry());
        Assert.assertEquals(event.getSubscription().getNode(), "princely_musings");
        Assert.assertEquals(event.getSubscription().getJid(), Jid.valueOf("francisco@denmark.lit"));
View Full Code Here

                "    to='romeo@example.net'\n" +
                "    type='chat'\n" +
                "    xml:lang='en'>\n" +
                "  <body>Wherefore art thou, Romeo?</body>\n" +
                "</message>";
        Message message = unmarshal(xml, Message.class);
        Assert.assertEquals(message.getFrom().toString(), "juliet@example.com/balcony");
        Assert.assertEquals(message.getTo().toString(), "romeo@example.net");
        Assert.assertEquals(message.getType(), Message.Type.CHAT);
        Assert.assertEquals(message.getId(), "b4vs9km4");
        Assert.assertEquals(message.getLanguage(), "en");
        Assert.assertEquals(message.getBody(), "Wherefore art thou, Romeo?");
    }
View Full Code Here

                "    type='chat'\n" +
                "    xml:lang='en'>\n" +
                "  <body>Wherefore art thou, Romeo?</body>\n" +
                "  <body xml:lang='de'>Wo bist du, Romeo?</body>\n" +
                "</message>";
        Message message = unmarshal(xml, Message.class);
        Assert.assertEquals(message.getFrom().toString(), "juliet@example.com/balcony");
        Assert.assertEquals(message.getTo().toString(), "romeo@example.net");
        Assert.assertEquals(message.getType(), Message.Type.CHAT);
        Assert.assertEquals(message.getId(), "z94nb37h");
        Assert.assertEquals(message.getLanguage(), "en");
        Assert.assertEquals(message.getBody(), "Wherefore art thou, Romeo?");
        Assert.assertEquals(message.getBodies().get(1).getText(), "Wo bist du, Romeo?");
    }
View Full Code Here

                "    type='chat'\n" +
                "    xml:lang='en'>\n" +
                "  <subject>I implore you!</subject>\n" +
                "  <body>Wherefore art thou, Romeo?</body>\n" +
                "</message>";
        Message message = unmarshal(xml, Message.class);
        Assert.assertEquals(message.getFrom().toString(), "juliet@example.com/balcony");
        Assert.assertEquals(message.getTo().toString(), "romeo@example.net");
        Assert.assertEquals(message.getType(), Message.Type.CHAT);
        Assert.assertEquals(message.getId(), "c8xg3nf8");
        Assert.assertEquals(message.getLanguage(), "en");
        Assert.assertEquals(message.getSubject(), "I implore you!");
        Assert.assertEquals(message.getBody(), "Wherefore art thou, Romeo?");
    }
View Full Code Here

        final Condition resultReceived = lock.newCondition();

        final MessageListener listener = new MessageListener() {
            @Override
            public void handle(MessageEvent e) {
                Message message = e.getMessage();
                if (e.isIncoming() && filter.accept(message)) {
                    lock.lock();
                    try {
                        result[0] = message;
                    } finally {
                        resultReceived.signal();
                        lock.unlock();
                    }
                }
            }
        };

        lock.lock();
        try {
            addMessageListener(listener);
            send(stanza);
            // Wait for the stanza to arrive.
            if (!resultReceived.await(configuration.getDefaultResponseTimeout(), TimeUnit.MILLISECONDS)) {
                throw new NoResponseException("Timeout reached, while waiting on a response.");
            }
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
        } finally {
            lock.unlock();
            removeMessageListener(listener);
        }
        Message response = result[0];
        if (response.getType() == Message.Type.ERROR) {
            throw new StanzaException(response);
        }
        return response;
    }
View Full Code Here

TOP

Related Classes of rocks.xmpp.core.stanza.model.client.Message

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.