Search in sources :

Example 86 with XmlPullParser

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());
}
Also used : Base64BinaryChunk(org.jivesoftware.smackx.hoxt.packet.Base64BinaryChunk) XmlPullParser(org.xmlpull.v1.XmlPullParser) ExtensionElement(org.jivesoftware.smack.packet.ExtensionElement) Test(org.junit.Test)

Example 87 with XmlPullParser

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());
}
Also used : CarbonManagerProvider(org.jivesoftware.smackx.carbons.provider.CarbonManagerProvider) CarbonExtension(org.jivesoftware.smackx.carbons.packet.CarbonExtension) XmlPullParser(org.xmlpull.v1.XmlPullParser) ExperimentalInitializerTest(org.jivesoftware.smackx.ExperimentalInitializerTest) Test(org.junit.Test)

Example 88 with XmlPullParser

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());
}
Also used : Message(org.jivesoftware.smack.packet.Message) AcknowledgedProvider(org.jivesoftware.smackx.chat_markers.provider.AcknowledgedProvider) XmlPullParser(org.xmlpull.v1.XmlPullParser) AcknowledgedExtension(org.jivesoftware.smackx.chat_markers.element.ChatMarkersElements.AcknowledgedExtension) Test(org.junit.Test)

Example 89 with XmlPullParser

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);
}
Also used : XmlPullParser(org.xmlpull.v1.XmlPullParser) ForwardedProvider(org.jivesoftware.smackx.forward.provider.ForwardedProvider) Test(org.junit.Test)

Example 90 with XmlPullParser

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());
}
Also used : DelayInformation(org.jivesoftware.smackx.delay.packet.DelayInformation) XmlPullParser(org.xmlpull.v1.XmlPullParser) Forwarded(org.jivesoftware.smackx.forward.packet.Forwarded) ForwardedProvider(org.jivesoftware.smackx.forward.provider.ForwardedProvider) Test(org.junit.Test)

Aggregations

XmlPullParser (org.xmlpull.v1.XmlPullParser)673 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)623 IOException (java.io.IOException)377 FileInputStream (java.io.FileInputStream)185 FileNotFoundException (java.io.FileNotFoundException)185 File (java.io.File)107 ArrayList (java.util.ArrayList)77 StringReader (java.io.StringReader)65 AttributeSet (android.util.AttributeSet)61 Test (org.junit.Test)57 TypedArray (android.content.res.TypedArray)56 InputStream (java.io.InputStream)48 AtomicFile (android.util.AtomicFile)47 HashMap (java.util.HashMap)45 BridgeXmlBlockParser (com.android.layoutlib.bridge.android.BridgeXmlBlockParser)39 FileReader (java.io.FileReader)36 BufferedInputStream (java.io.BufferedInputStream)30 XmlPullParserFactory (org.xmlpull.v1.XmlPullParserFactory)30 RemoteException (android.os.RemoteException)28 ResourceValue (com.android.ide.common.rendering.api.ResourceValue)28