use of org.jivesoftware.smack.xml.XmlPullParser in project Smack by igniterealtime.
the class Base64BinaryChunkProviderTest method isLatsChunkParsedCorrectly.
@Test
public void isLatsChunkParsedCorrectly() throws Exception {
String base64Text = "2uPzi9u+tVWJd+e+y1AAAAABJRU5ErkJggg==";
String string = "<chunk xmlns='urn:xmpp:http' streamId='Stream0001' nr='1' last='true'>" + base64Text + "</chunk>";
Base64BinaryChunkProvider provider = new Base64BinaryChunkProvider();
XmlPullParser parser = PacketParserUtils.getParserFor(string);
ExtensionElement extension = provider.parse(parser);
assertTrue(extension instanceof Base64BinaryChunk);
Base64BinaryChunk chunk = (Base64BinaryChunk) extension;
assertEquals("Stream0001", chunk.getStreamId());
assertTrue(chunk.isLast());
assertEquals(base64Text, chunk.getText());
assertEquals(1, chunk.getNr());
}
use of org.jivesoftware.smack.xml.XmlPullParser in project Smack by igniterealtime.
the class AbstractHttpOverXmppProviderTest method areReqHeadersParsedCorrectly.
@Test
public void areReqHeadersParsedCorrectly() throws Exception {
String string = "<req xmlns='urn:xmpp:http' method='GET' resource='/rdf/xep' version='1.1'>" + "<headers xmlns='http://jabber.org/protocol/shim'>" + "<header name='Host'>clayster.com</header>" + "</headers>" + "</req>";
Map<String, String> expectedHeaders = new HashMap<String, String>();
expectedHeaders.put("Host", "clayster.com");
HttpOverXmppReqProvider provider = new HttpOverXmppReqProvider();
XmlPullParser parser = PacketParserUtils.getParserFor(string);
IQ iq = provider.parse(parser);
assertTrue(iq instanceof HttpOverXmppReq);
HttpOverXmppReq body = (HttpOverXmppReq) iq;
checkHeaders(body.getHeaders(), expectedHeaders);
}
use of org.jivesoftware.smack.xml.XmlPullParser 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.smack.xml.XmlPullParser 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.smack.xml.XmlPullParser in project Smack by igniterealtime.
the class MarkableExtensionTest method checkMarkableProvider.
@Test
public void checkMarkableProvider() throws Exception {
XmlPullParser parser = PacketParserUtils.getParserFor(markableExtension);
MarkableExtension markableExtension1 = new MarkableProvider().parse(parser);
assertEquals(markableExtension, markableExtension1.toXML().toString());
Message message = PacketParserUtils.parseStanza(markableMessageStanza);
MarkableExtension markableExtension2 = MarkableExtension.from(message);
assertEquals(markableExtension, markableExtension2.toXML().toString());
}
Aggregations