Search in sources :

Example 1 with HttpOverXmppResp

use of org.jivesoftware.smackx.hoxt.packet.HttpOverXmppResp in project Smack by igniterealtime.

the class AbstractHttpOverXmppProviderTest method areRespHeadersParsedCorrectly.

@Test
public void areRespHeadersParsedCorrectly() throws Exception {
    String string = "<resp xmlns='urn:xmpp:http' version='1.1' statusCode='200' statusMessage='OK'>" + "<headers xmlns='http://jabber.org/protocol/shim'>" + "<header name='Date'>Fri, 03 May 2013 13:52:10 GMT-4</header>" + "<header name='Allow'>OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE</header>" + "<header name='Content-Length'>0</header>" + "</headers>" + "</resp>";
    Map<String, String> expectedHeaders = new HashMap<String, String>();
    expectedHeaders.put("Date", "Fri, 03 May 2013 13:52:10 GMT-4");
    expectedHeaders.put("Allow", "OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE");
    expectedHeaders.put("Content-Length", "0");
    HttpOverXmppRespProvider provider = new HttpOverXmppRespProvider();
    XmlPullParser parser = PacketParserUtils.getParserFor(string);
    IQ iq = provider.parse(parser);
    assertTrue(iq instanceof HttpOverXmppResp);
    HttpOverXmppResp body = ((HttpOverXmppResp) iq);
    checkHeaders(body.getHeaders(), expectedHeaders);
}
Also used : HttpOverXmppResp(org.jivesoftware.smackx.hoxt.packet.HttpOverXmppResp) HashMap(java.util.HashMap) XmlPullParser(org.xmlpull.v1.XmlPullParser) IQ(org.jivesoftware.smack.packet.IQ) Test(org.junit.Test)

Example 2 with HttpOverXmppResp

use of org.jivesoftware.smackx.hoxt.packet.HttpOverXmppResp in project Smack by igniterealtime.

the class HttpOverXmppRespProviderTest method areRespAttributesWothoutMessageCorrectlyParsed.

@Test
public void areRespAttributesWothoutMessageCorrectlyParsed() throws Exception {
    String string = "<resp xmlns='urn:xmpp:http' version='1.1' statusCode='200'/>";
    HttpOverXmppRespProvider provider = new HttpOverXmppRespProvider();
    XmlPullParser parser = PacketParserUtils.getParserFor(string);
    IQ iq = provider.parse(parser);
    assertTrue(iq instanceof HttpOverXmppResp);
    HttpOverXmppResp resp = (HttpOverXmppResp) iq;
    assertEquals(resp.getVersion(), "1.1");
    assertEquals(resp.getStatusCode(), 200);
    assertNull(resp.getStatusMessage());
}
Also used : HttpOverXmppResp(org.jivesoftware.smackx.hoxt.packet.HttpOverXmppResp) XmlPullParser(org.xmlpull.v1.XmlPullParser) IQ(org.jivesoftware.smack.packet.IQ) Test(org.junit.Test)

Example 3 with HttpOverXmppResp

use of org.jivesoftware.smackx.hoxt.packet.HttpOverXmppResp in project Smack by igniterealtime.

the class HttpOverXmppRespProviderTest method areAllRespAttributesCorrectlyParsed.

@Test
public void areAllRespAttributesCorrectlyParsed() throws Exception {
    String string = "<resp xmlns='urn:xmpp:http' version='1.1' statusCode='200' statusMessage='OK'/>";
    HttpOverXmppRespProvider provider = new HttpOverXmppRespProvider();
    XmlPullParser parser = PacketParserUtils.getParserFor(string);
    IQ iq = provider.parse(parser);
    assertTrue(iq instanceof HttpOverXmppResp);
    HttpOverXmppResp resp = (HttpOverXmppResp) iq;
    assertEquals(resp.getVersion(), "1.1");
    assertEquals(resp.getStatusCode(), 200);
    assertEquals(resp.getStatusMessage(), "OK");
}
Also used : HttpOverXmppResp(org.jivesoftware.smackx.hoxt.packet.HttpOverXmppResp) XmlPullParser(org.xmlpull.v1.XmlPullParser) IQ(org.jivesoftware.smack.packet.IQ) Test(org.junit.Test)

Example 4 with HttpOverXmppResp

use of org.jivesoftware.smackx.hoxt.packet.HttpOverXmppResp in project Smack by igniterealtime.

the class AbstractHttpOverXmppProviderTest method parseAbstractBody.

// TODO The method name makes no sense after the HOXT re-design, change to parseHttpOverXmppResp()
private static HttpOverXmppResp parseAbstractBody(String string, String tag) throws Exception {
    HttpOverXmppRespProvider provider = new HttpOverXmppRespProvider();
    XmlPullParser parser = PacketParserUtils.getParserFor(string, tag);
    IQ iq = provider.parse(parser);
    assertTrue(iq instanceof HttpOverXmppResp);
    return (HttpOverXmppResp) iq;
}
Also used : HttpOverXmppResp(org.jivesoftware.smackx.hoxt.packet.HttpOverXmppResp) XmlPullParser(org.xmlpull.v1.XmlPullParser) IQ(org.jivesoftware.smack.packet.IQ)

Aggregations

IQ (org.jivesoftware.smack.packet.IQ)4 HttpOverXmppResp (org.jivesoftware.smackx.hoxt.packet.HttpOverXmppResp)4 XmlPullParser (org.xmlpull.v1.XmlPullParser)4 Test (org.junit.Test)3 HashMap (java.util.HashMap)1