Esempio n. 1
0
  @Test
  public void checkProvider() throws Exception {
    // @formatter:off
    String control =
        "<iq from='capulet.lit' to='[email protected]/balcony' id='s2c1' type='get'>"
            + "<query xmlns='jabber:iq:version'/>"
            + "</iq>";
    // @formatter:on
    DummyConnection con = new DummyConnection();
    con.connect();

    // Enable version replys for this connection
    VersionManager.setAutoAppendSmackVersion(false);
    VersionManager.getInstanceFor(con).setVersion("Test", "0.23", "DummyOS");
    IQ versionRequest = (IQ) PacketParserUtils.parseStanza(control);

    assertTrue(versionRequest instanceof Version);

    con.processPacket(versionRequest);

    Stanza replyPacket = con.getSentPacket();
    assertTrue(replyPacket instanceof Version);

    Version reply = (Version) replyPacket;
    // getFrom check is pending for SMACK-547
    // assertEquals("[email protected]/balcony", reply.getFrom());
    assertEquals("capulet.lit", reply.getTo());
    assertEquals("s2c1", reply.getStanzaId());
    assertEquals(IQ.Type.result, reply.getType());
    assertEquals("Test", reply.getName());
    assertEquals("0.23", reply.getVersion());
    assertEquals("DummyOS", reply.getOs());
  }
  @Before
  public void setUp() throws Exception {
    // Uncomment this to enable debug output
    // XMPPConnection.DEBUG_ENABLED = true;

    connection = new DummyConnection();
    connection.connect();
    connection.login("me", "secret");
    ServiceDiscoveryManager.getInstanceFor(connection);
  }
 @Test
 public void verifyForm() throws Exception {
   FileTransferNegotiator fileNeg = FileTransferNegotiator.getInstanceFor(connection);
   try {
     fileNeg.negotiateOutgoingTransfer("me", "streamid", "file", 1024, null, 10);
   } catch (NoResponseException e) {
     // Ignore
   }
   Packet packet = connection.getSentPacket();
   String xml = packet.toXML().toString();
   assertTrue(xml.indexOf("var='stream-method' type='list-single'") != -1);
 }
 @After
 public void tearDown() throws Exception {
   if (connection != null) connection.disconnect();
 }