use of org.xmlpull.v1.XmlPullParser in project Smack by igniterealtime.
the class Base64BinaryChunkProviderTest method isNonLatsChunkParsedCorrectly.
@Test
public void isNonLatsChunkParsedCorrectly() throws Exception {
String base64Text = "iVBORw0KGgoAAAANSUhEUgAAASwAAAGQCAYAA";
String string = "<chunk xmlns='urn:xmpp:http' streamId='Stream0001' nr='0'>" + 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());
assertFalse(chunk.isLast());
assertEquals(base64Text, chunk.getText());
assertEquals(0, chunk.getNr());
}
use of org.xmlpull.v1.XmlPullParser in project Smack by igniterealtime.
the class CarbonTest method carbonReceivedTest.
@Test
public void carbonReceivedTest() throws Exception {
XmlPullParser parser;
String control;
CarbonExtension cc;
control = XMLBuilder.create("received").e("forwarded").a("xmlns", "urn:xmpp:forwarded:0").e("message").a("from", "romeo@montague.com").asString(outputProperties);
parser = PacketParserUtils.getParserFor(control);
cc = new CarbonManagerProvider().parse(parser);
assertEquals(CarbonExtension.Direction.received, cc.getDirection());
// check end of tag
assertEquals(XmlPullParser.END_TAG, parser.getEventType());
assertEquals("received", parser.getName());
}
use of org.xmlpull.v1.XmlPullParser in project Smack by igniterealtime.
the class AcknowledgedExtensionTest method checkDisplayedProvider.
@Test
public void checkDisplayedProvider() throws Exception {
XmlPullParser parser = PacketParserUtils.getParserFor(acknowledgedExtension);
AcknowledgedExtension acknowledgedExtension1 = new AcknowledgedProvider().parse(parser);
Assert.assertEquals("message-1", acknowledgedExtension1.getId());
Message message = (Message) PacketParserUtils.parseStanza(acknowledgedMessageStanza);
AcknowledgedExtension acknowledgedExtension2 = AcknowledgedExtension.from(message);
Assert.assertEquals("message-1", acknowledgedExtension2.getId());
}
use of org.xmlpull.v1.XmlPullParser in project Smack by igniterealtime.
the class ForwardedTest method forwardedEmptyTest.
@Test(expected = Exception.class)
public void forwardedEmptyTest() throws Exception {
XmlPullParser parser;
String control;
control = XMLBuilder.create("forwarded").a("xmlns", "urn:xmpp:forwarded:0").asString(outputProperties);
parser = PacketParserUtils.getParserFor(control);
new ForwardedProvider().parse(parser);
}
use of org.xmlpull.v1.XmlPullParser in project Smack by igniterealtime.
the class ForwardedTest method forwardedWithDelayTest.
@Test
public void forwardedWithDelayTest() throws Exception {
XmlPullParser parser;
String control;
Forwarded fwd;
// @formatter:off
control = XMLBuilder.create("forwarded").a("xmlns", "urn:xmpp:forwarded:0").e("message").a("from", "romeo@montague.com").up().e("delay").ns(DelayInformation.NAMESPACE).a("stamp", "2010-07-10T23:08:25Z").asString(outputProperties);
// @formatter:on
parser = PacketParserUtils.getParserFor(control);
fwd = new ForwardedProvider().parse(parser);
// assert there is delay information in packet
DelayInformation delay = fwd.getDelayInformation();
assertNotNull(delay);
// check message
assertThat("romeo@montague.com", equalsCharSequence(fwd.getForwardedStanza().getFrom()));
// check end of tag
assertEquals(XmlPullParser.END_TAG, parser.getEventType());
assertEquals("forwarded", parser.getName());
}
Aggregations