Search in sources :

Example 1 with Header

use of org.jivesoftware.smackx.shim.packet.Header in project Smack by igniterealtime.

the class HeadersProviderTest method headersInMessageTest.

@Test
public void headersInMessageTest() throws Exception {
    // @formatter:off
    final String messageStanza = "<message from='romeo@shakespeare.lit/orchard' to='juliet@capulet.com' type='chat'>" + "<body>Wherefore are thou?!?</body>" + "<headers xmlns='http://jabber.org/protocol/shim'>" + "<header name='Urgency'>high</header>" + "</headers>" + "</message>";
    // @formatter:on
    XmlPullParser parser = TestUtils.getMessageParser(messageStanza);
    Message message = PacketParserUtils.parseMessage(parser);
    HeadersExtension headers = HeadersExtension.from(message);
    Header header = headers.getHeaders().get(0);
    assertEquals("Urgency", header.getName());
    assertEquals("high", header.getValue());
}
Also used : HeadersExtension(org.jivesoftware.smackx.shim.packet.HeadersExtension) Message(org.jivesoftware.smack.packet.Message) Header(org.jivesoftware.smackx.shim.packet.Header) XmlPullParser(org.xmlpull.v1.XmlPullParser) Test(org.junit.Test)

Example 2 with Header

use of org.jivesoftware.smackx.shim.packet.Header in project Smack by igniterealtime.

the class AbstractHttpOverXmppProviderTest method checkHeaders.

private static void checkHeaders(HeadersExtension headers, Map<String, String> expectedHeaders) {
    Collection<Header> collection = headers.getHeaders();
    assertEquals(collection.size(), expectedHeaders.size());
    for (Header header : collection) {
        assertTrue(expectedHeaders.containsKey(header.getName()));
        assertEquals(expectedHeaders.get(header.getName()), header.getValue());
    }
}
Also used : Header(org.jivesoftware.smackx.shim.packet.Header)

Example 3 with Header

use of org.jivesoftware.smackx.shim.packet.Header in project Smack by igniterealtime.

the class Node method getSubscriptionIds.

private static List<String> getSubscriptionIds(Stanza packet) {
    HeadersExtension headers = (HeadersExtension) packet.getExtension("headers", "http://jabber.org/protocol/shim");
    List<String> values = null;
    if (headers != null) {
        values = new ArrayList<String>(headers.getHeaders().size());
        for (Header header : headers.getHeaders()) {
            values.add(header.getValue());
        }
    }
    return values;
}
Also used : HeadersExtension(org.jivesoftware.smackx.shim.packet.HeadersExtension) Header(org.jivesoftware.smackx.shim.packet.Header)

Aggregations

Header (org.jivesoftware.smackx.shim.packet.Header)3 HeadersExtension (org.jivesoftware.smackx.shim.packet.HeadersExtension)2 Message (org.jivesoftware.smack.packet.Message)1 Test (org.junit.Test)1 XmlPullParser (org.xmlpull.v1.XmlPullParser)1