当前位置: 首页>>代码示例>>Java>>正文


Java PacketParserUtils.getParserFor方法代码示例

本文整理汇总了Java中org.jivesoftware.smack.util.PacketParserUtils.getParserFor方法的典型用法代码示例。如果您正苦于以下问题:Java PacketParserUtils.getParserFor方法的具体用法?Java PacketParserUtils.getParserFor怎么用?Java PacketParserUtils.getParserFor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jivesoftware.smack.util.PacketParserUtils的用法示例。


在下文中一共展示了PacketParserUtils.getParserFor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isNonLatsChunkParsedCorrectly

import org.jivesoftware.smack.util.PacketParserUtils; //导入方法依赖的package包/类
@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());
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:18,代码来源:Base64BinaryChunkProviderTest.java

示例2: isLatsChunkParsedCorrectly

import org.jivesoftware.smack.util.PacketParserUtils; //导入方法依赖的package包/类
@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());
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:18,代码来源:Base64BinaryChunkProviderTest.java

示例3: areRespHeadersParsedCorrectly

import org.jivesoftware.smack.util.PacketParserUtils; //导入方法依赖的package包/类
@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);
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:24,代码来源:AbstractHttpOverXmppProviderTest.java

示例4: testParsingOfSimpleStreamError

import org.jivesoftware.smack.util.PacketParserUtils; //导入方法依赖的package包/类
@Test
public void testParsingOfSimpleStreamError() {
    StreamError error = null;
    final String xml =
            // Usually the stream:stream element has more attributes (to, version, ...)
            // We omit those, since they are not relevant for testing
            "<stream:stream from='im.example.com' id='++TR84Sm6A3hnt3Q065SnAbbk3Y=' xmlns:stream='http://etherx.jabber.org/streams'>" +
            "<stream:error>" +
            "<conflict xmlns='urn:ietf:params:xml:ns:xmpp-streams' /> +" +
            "</stream:error>" +
            "</stream:stream>";
    try {
        XmlPullParser parser = PacketParserUtils.getParserFor(xml, "error");
        error = PacketParserUtils.parseStreamError(parser);
    } catch (Exception e) {
        fail(e.getMessage());
    }
    assertNotNull(error);
    assertEquals(Condition.conflict, error.getCondition());
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:21,代码来源:StreamErrorTest.java

示例5: testParsingOfStreamErrorWithText

import org.jivesoftware.smack.util.PacketParserUtils; //导入方法依赖的package包/类
@Test
public void testParsingOfStreamErrorWithText() {
    StreamError error = null;
    final String xml =
            // Usually the stream:stream element has more attributes (to, version, ...)
            // We omit those, since they are not relevant for testing
            "<stream:stream from='im.example.com' id='++TR84Sm6A3hnt3Q065SnAbbk3Y=' xmlns:stream='http://etherx.jabber.org/streams'>" +
            "<stream:error>" +
            "<conflict xmlns='urn:ietf:params:xml:ns:xmpp-streams' />" +
            "<text xml:lang='' xmlns='urn:ietf:params:xml:ns:xmpp-streams'>" +
                "Replaced by new connection" +
            "</text>" +
            "</stream:error>" +
            "</stream:stream>";
    try {
        XmlPullParser parser = PacketParserUtils.getParserFor(xml, "error");
        error = PacketParserUtils.parseStreamError(parser);
    } catch (Exception e) {
        fail(e.getMessage());
    }
    assertNotNull(error);
    assertEquals(Condition.conflict, error.getCondition());
    assertEquals("Replaced by new connection", error.getDescriptiveText());
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:25,代码来源:StreamErrorTest.java

示例6: testLayout

import org.jivesoftware.smack.util.PacketParserUtils; //导入方法依赖的package包/类
@Test
public void testLayout() throws XmlPullParserException, IOException, SmackException {
    DataLayout layout = new DataLayout("Label");
    Fieldref reffield = new Fieldref("testField1");
    layout.getPageLayout().add(reffield);
    Section section = new Section("section Label");
    section.getSectionLayout().add(new Text("SectionText"));
    layout.getPageLayout().add(section);
    layout.getPageLayout().add(new Text( "PageText"));
    
    assertNotNull( layout.toXML());
    String output = layout.toXML().toString();
    assertEquals(TEST_OUTPUT_2, output);
    
    XmlPullParser parser = PacketParserUtils.getParserFor(output);
    
    layout = DataLayoutProvider.parse(parser);
    
    assertEquals(3 , layout.getPageLayout().size());
    assertEquals("Label", layout.getLabel());

    assertNotNull( layout.toXML());
    output = layout.toXML().toString();
    assertEquals(TEST_OUTPUT_2, output);
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:26,代码来源:DataLayoutTest.java

示例7: test

import org.jivesoftware.smack.util.PacketParserUtils; //导入方法依赖的package包/类
@Test
public void test() throws XmlPullParserException, IOException, SmackException {
    //Build a Form
    DataForm df = new DataForm(DataForm.Type.submit);
    String instruction = "InstructionTest1";
    df.addInstruction(instruction);
    FormField field = new FormField("testField1");
    df.addField(field);
    
    assertNotNull( df.toXML());
    String output = df.toXML().toString();
    assertEquals(TEST_OUTPUT_1, output);
    
    XmlPullParser parser = PacketParserUtils.getParserFor(output);
    
    df = pr.parse(parser);
    
    assertNotNull(df);
    assertNotNull(df.getFields());
    assertEquals(1 , df.getFields().size() );
    assertEquals(1 , df.getInstructions().size());

    assertNotNull( df.toXML());
    output = df.toXML().toString();
    assertEquals(TEST_OUTPUT_1, output);
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:27,代码来源:DataFormTest.java

示例8: receiptTest

import org.jivesoftware.smack.util.PacketParserUtils; //导入方法依赖的package包/类
@Test
public void receiptTest() throws Exception {
    XmlPullParser parser;
    String control;
    
    control = XMLBuilder.create("message")
        .a("from", "[email protected]")
        .e("request")
            .a("xmlns", "urn:xmpp:receipts")
        .asString(outputProperties);
    
    parser = PacketParserUtils.getParserFor(control);
    Message p = PacketParserUtils.parseMessage(parser);

    DeliveryReceiptRequest drr = (DeliveryReceiptRequest)p.getExtension(
                    DeliveryReceiptRequest.ELEMENT, DeliveryReceipt.NAMESPACE);
    assertNotNull(drr);

    assertTrue(DeliveryReceiptManager.hasDeliveryReceiptRequest(p));

    Message m = new Message("[email protected]", Message.Type.normal);
    assertFalse(DeliveryReceiptManager.hasDeliveryReceiptRequest(m));
    DeliveryReceiptRequest.addTo(m);
    assertTrue(DeliveryReceiptManager.hasDeliveryReceiptRequest(m));
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:26,代码来源:DeliveryReceiptTest.java

示例9: testParseEnabledInvariant

import org.jivesoftware.smack.util.PacketParserUtils; //导入方法依赖的package包/类
@Test
public void testParseEnabledInvariant() throws XmlPullParserException, IOException {
    String enabledString = (new StreamManagement.Enabled("stream-id", false)).toXML().toString();
    XmlPullParser parser = PacketParserUtils.getParserFor(enabledString);
    StreamManagement.Enabled enabled = ParseStreamManagement.enabled(parser);

    assertEquals(enabledString, enabled.toXML().toString());
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:9,代码来源:ParseStreamManagementTest.java

示例10: carbonEmptyTest

import org.jivesoftware.smack.util.PacketParserUtils; //导入方法依赖的package包/类
@Test(expected=Exception.class)
public void carbonEmptyTest() throws Exception {
    XmlPullParser parser;
    String control;
    
    control = XMLBuilder.create("sent")
        .a("xmlns", "urn:xmpp:forwarded:0")
        .asString(outputProperties);
    
    parser = PacketParserUtils.getParserFor(control);
    new CarbonManagerProvider().parse(parser);
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:13,代码来源:CarbonTest.java

示例11: parseReq

import org.jivesoftware.smack.util.PacketParserUtils; //导入方法依赖的package包/类
private HttpOverXmppReq parseReq(String string) throws Exception {
    HttpOverXmppReqProvider provider = new HttpOverXmppReqProvider();
    XmlPullParser parser = PacketParserUtils.getParserFor(string);
    IQ iq = provider.parse(parser);
    assertTrue(iq instanceof HttpOverXmppReq);
    HttpOverXmppReq castedIq = (HttpOverXmppReq) iq;
    return castedIq;
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:9,代码来源:HttpOverXmppReqProviderTest.java

示例12: areAllRespAttributesCorrectlyParsed

import org.jivesoftware.smack.util.PacketParserUtils; //导入方法依赖的package包/类
@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");
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:15,代码来源:HttpOverXmppRespProviderTest.java

示例13: areRespAttributesWothoutMessageCorrectlyParsed

import org.jivesoftware.smack.util.PacketParserUtils; //导入方法依赖的package包/类
@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());
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:15,代码来源:HttpOverXmppRespProviderTest.java

示例14: forwardedEmptyTest

import org.jivesoftware.smack.util.PacketParserUtils; //导入方法依赖的package包/类
@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);
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:13,代码来源:ForwardedTest.java

示例15: parseAbstractBody

import org.jivesoftware.smack.util.PacketParserUtils; //导入方法依赖的package包/类
private 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;
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:9,代码来源:AbstractHttpOverXmppProviderTest.java


注:本文中的org.jivesoftware.smack.util.PacketParserUtils.getParserFor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。