Search in sources :

Example 1 with JingleIBBTransport

use of org.jivesoftware.smackx.jingle.transports.jingle_ibb.element.JingleIBBTransport in project Smack by igniterealtime.

the class JingleIBBTransportTest method parserTest.

@Test
public void parserTest() throws Exception {
    String sid = StringUtils.randomString(24);
    short size = 8192;
    String xml = "<transport xmlns='urn:xmpp:jingle:transports:ibb:1' block-size='8192' sid='" + sid + "'/>";
    JingleIBBTransport transport = new JingleIBBTransport(size, sid);
    assertEquals(xml, transport.toXML().toString());
    assertEquals(size, transport.getBlockSize());
    assertEquals(sid, transport.getSessionId());
    JingleIBBTransport parsed = new JingleIBBTransportProvider().parse(TestUtils.getParser(xml));
    assertEquals(transport, parsed);
    assertTrue(transport.equals(parsed));
    assertEquals(xml, parsed.toXML().toString());
    JingleIBBTransport transport1 = new JingleIBBTransport((short) 1024);
    assertEquals((short) 1024, transport1.getBlockSize());
    assertNotSame(transport, transport1);
    assertNotSame(transport.getSessionId(), transport1.getSessionId());
    assertFalse(transport.equals(null));
    JingleIBBTransport transport2 = new JingleIBBTransport();
    assertEquals(JingleIBBTransport.DEFAULT_BLOCK_SIZE, transport2.getBlockSize());
    assertFalse(transport1.equals(transport2));
    JingleIBBTransport transport3 = new JingleIBBTransport((short) -1024);
    assertEquals(JingleIBBTransport.DEFAULT_BLOCK_SIZE, transport3.getBlockSize());
    assertEquals(transport3.getNamespace(), JingleIBBTransport.NAMESPACE_V1);
    assertEquals(transport3.getElementName(), "transport");
    JingleIBBTransport transport4 = new JingleIBBTransport("session-id");
    assertEquals(JingleIBBTransport.DEFAULT_BLOCK_SIZE, transport4.getBlockSize());
}
Also used : JingleIBBTransport(org.jivesoftware.smackx.jingle.transports.jingle_ibb.element.JingleIBBTransport) JingleIBBTransportProvider(org.jivesoftware.smackx.jingle.transports.jingle_ibb.provider.JingleIBBTransportProvider) Test(org.junit.jupiter.api.Test)

Aggregations

JingleIBBTransport (org.jivesoftware.smackx.jingle.transports.jingle_ibb.element.JingleIBBTransport)1 JingleIBBTransportProvider (org.jivesoftware.smackx.jingle.transports.jingle_ibb.provider.JingleIBBTransportProvider)1 Test (org.junit.jupiter.api.Test)1