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);
}
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());
}
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");
}
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;
}
Aggregations