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

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


        Assert.assertEquals(xml, "<message from=\"from@domain\" id=\"id\" to=\"to@domain\" type=\"chat\"><body xml:lang=\"de\">body</body><body xml:lang=\"fr\">body2</body></message>");
    }

    @Test
    public void marshalMessageSubject() throws JAXBException, XMLStreamException {
        Message message = new Message(new Jid("to", "domain"), Message.Type.CHAT);
        message.setId("id");
        message.setFrom(new Jid("from", "domain"));
        message.getSubjects().add(new AbstractMessage.Subject("subject1", "de"));
        AbstractMessage.Subject subject2 = new AbstractMessage.Subject("subject2");
        subject2.setLanguage("fr");
        message.getSubjects().add(subject2);
        String xml = marshal(message);
        Assert.assertEquals(xml, "<message from=\"from@domain\" id=\"id\" to=\"to@domain\" type=\"chat\"><subject xml:lang=\"de\">subject1</subject><subject xml:lang=\"fr\">subject2</subject></message>");
    }
View Full Code Here


            public void handle(PresenceEvent e) {
                xmppSession1.removePresenceListener(this);
                Assert.assertTrue(e.getPresence().getExtension(LastActivity.class) != null);
            }
        });
        xmppSession1.send(new Message(JULIET));
        xmppSession1.send(new Presence(Presence.Show.AWAY));
    }
View Full Code Here

            @Override
            public void handle(PresenceEvent e) {
                Assert.assertTrue(e.getPresence().getExtension(LastActivity.class) != null);
            }
        });
        xmppSession1.send(new Message(JULIET));
        xmppSession1.send(new Presence(Presence.Show.AWAY));
    }
View Full Code Here

                "    <e n='3' p='8'/>\n" +
                "    <t p='5'> there,</t>\n" +
                "  </rtt>\n" +
                "</message>";

        Message message = unmarshal(xml, Message.class);
        RealTimeText realTimeText = message.getExtension(RealTimeText.class);

        Assert.assertNotNull(realTimeText);
        Assert.assertEquals(realTimeText.getEvent(), RealTimeText.Event.NEW);
        Assert.assertEquals(realTimeText.getSequence(), (Long) 123001L);
        Assert.assertEquals(realTimeText.getActions().size(), 7);
View Full Code Here

        soapBodyElem1.addTextNode("New York");

        SOAPElement soapBodyElem2 = soapBody.addChildElement("arriving", "p");
        soapBodyElem2.addTextNode("Los Angeles");

        Message message = new Message(Jid.valueOf("juliet@example.net"));
        message.getExtensions().add(envelope);
        String xml = marshal(message);

        Assert.assertEquals(xml, "<message to=\"juliet@example.net\"><env:Envelope xmlns:p=\"http://travelcompany.example.org/reservation/travel\" xmlns:env=\"http://www.w3.org/2003/05/soap-envelope\"><env:Header></env:Header><env:Body><p:departing>New York</p:departing><p:arriving>Los Angeles</p:arriving></env:Body></env:Envelope></message>");
    }
View Full Code Here

                "  <x xmlns='jabber:x:oob'>\n" +
                "    <url>http://www.jabber.org/images/psa-license.jpg</url>\n" +
                "    <desc>A license to Jabber!</desc>\n" +
                "  </x>\n" +
                "</message>\n";
        Message message = unmarshal(xml, Message.class);
        OobX oobX = message.getExtension(OobX.class);
        Assert.assertNotNull(oobX);
        Assert.assertEquals(oobX.getUrl(), new URL("http://www.jabber.org/images/psa-license.jpg"));
        Assert.assertEquals(oobX.getDescription(), "A license to Jabber!");
    }
View Full Code Here

                "     <error by='example.net'\n" +
                "            type='cancel'>\n" +
                "       <gone xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'>xmpp:romeo@afterlife.example.net</gone>\n" +
                "     </error>\n" +
                "   </message>";
        Message message = unmarshal(xml, Message.class);
        Assert.assertEquals(message.getType(), Message.Type.ERROR);
        Assert.assertNotNull(message.getError());
        Assert.assertEquals(message.getError().getType(), StanzaError.Type.CANCEL);
        Assert.assertTrue(message.getError().getCondition() instanceof Gone);
        Assert.assertEquals(((Gone) message.getError().getCondition()).getNewAddress(), "xmpp:romeo@afterlife.example.net");
    }
View Full Code Here

                "  <delay xmlns='urn:xmpp:delay'\n" +
                "     from='capulet.com'\n" +
                "     stamp='2002-09-10T23:08:25Z'>Offline Storage</delay>\n" +
                "</message>\n";

        Message message = unmarshal(xml, Message.class);
        Assert.assertEquals(message.getExtensions().size(), 1);
        DelayedDelivery delay = message.getExtension(DelayedDelivery.class);
        Assert.assertNotNull(delay);
        Assert.assertEquals(delay.getFrom(), new Jid("capulet.com"));
        Assert.assertEquals(delay.getTimeStamp(), DatatypeConverter.parseDate("2002-09-10T23:08:25Z").getTime());
        Assert.assertEquals(delay.getReason(), "Offline Storage");
    }
View Full Code Here

                "     <error type='modify'>\n" +
                "       <not-acceptable\n" +
                "           xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>\n" +
                "     </error>\n" +
                "   </message>";
        Message message = unmarshal(xml, Message.class);
        Assert.assertNotNull(message.getError());
        Assert.assertEquals(message.getError().getType(), StanzaError.Type.MODIFY);
        Assert.assertTrue(message.getError().getCondition() instanceof NotAcceptable);
    }
View Full Code Here

                "     <error by='example.net' type='modify'>\n" +
                "       <policy-violation\n" +
                "           xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>\n" +
                "     </error>\n" +
                "   </message>";
        Message message = unmarshal(xml, Message.class);
        Assert.assertNotNull(message.getError());
        Assert.assertEquals(message.getError().getType(), StanzaError.Type.MODIFY);
        Assert.assertTrue(message.getError().getCondition() instanceof PolicyViolation);
    }
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.