Search in sources :

Example 11 with DummyConnection

use of org.jivesoftware.smack.DummyConnection in project Smack by igniterealtime.

the class RosterTest method setUp.

@Before
public void setUp() throws Exception {
    connection = new DummyConnection();
    connection.connect();
    connection.login();
    rosterListener = new TestRosterListener();
    roster = Roster.getInstanceFor(connection);
    roster.addRosterListener(rosterListener);
    connection.setReplyTimeout(1000 * 60 * 5);
}
Also used : DummyConnection(org.jivesoftware.smack.DummyConnection) Before(org.junit.Before)

Example 12 with DummyConnection

use of org.jivesoftware.smack.DummyConnection in project Smack by igniterealtime.

the class RosterVersioningTest method setUp.

@Before
public void setUp() throws Exception {
    DirectoryRosterStore store = DirectoryRosterStore.init(tmpFolder.newFolder("store"));
    populateStore(store);
    Builder<?, ?> builder = DummyConnection.getDummyConfigurationBuilder();
    connection = new DummyConnection(builder.build());
    connection.connect();
    connection.login();
    rosterListener = new TestRosterListener();
    roster = Roster.getInstanceFor(connection);
    roster.setRosterStore(store);
    roster.addRosterListener(rosterListener);
    roster.reload();
}
Also used : DirectoryRosterStore(org.jivesoftware.smack.roster.rosterstore.DirectoryRosterStore) DummyConnection(org.jivesoftware.smack.DummyConnection) TestRosterListener(org.jivesoftware.smack.roster.RosterTest.TestRosterListener) Before(org.junit.Before)

Example 13 with DummyConnection

use of org.jivesoftware.smack.DummyConnection in project Smack by igniterealtime.

the class SubscriptionPreApprovalTest method setUp.

@Before
public void setUp() throws Exception {
    connection = new DummyConnection();
    connection.connect();
    connection.login();
    rosterListener = new TestRosterListener();
    roster = Roster.getInstanceFor(connection);
    roster.addRosterListener(rosterListener);
    connection.setReplyTimeout(1000 * 60 * 5);
}
Also used : DummyConnection(org.jivesoftware.smack.DummyConnection) TestRosterListener(org.jivesoftware.smack.roster.RosterTest.TestRosterListener) Before(org.junit.Before)

Example 14 with DummyConnection

use of org.jivesoftware.smack.DummyConnection in project Smack by igniterealtime.

the class DeliveryReceiptTest method receiptManagerAutoReplyTest.

@Test
public void receiptManagerAutoReplyTest() throws Exception {
    DummyConnection c = new DummyConnection();
    c.connect();
    DeliveryReceiptManager drm = DeliveryReceiptManager.getInstanceFor(c);
    drm.setAutoReceiptMode(AutoReceiptMode.always);
    assertEquals(AutoReceiptMode.always, drm.getAutoReceiptMode());
    // test auto-receipts
    Message m = new Message(JidCreate.from("julia@capulet.com"), Message.Type.normal);
    m.setFrom(JidCreate.from("romeo@montague.com"));
    m.setStanzaId("test-receipt-request");
    DeliveryReceiptRequest.addTo(m);
    // the DRM will send a reply-packet
    c.processStanza(m);
    Stanza reply = c.getSentPacket();
    DeliveryReceipt r = DeliveryReceipt.from((Message) reply);
    assertThat("romeo@montague.com", equalsCharSequence(reply.getTo()));
    assertEquals("test-receipt-request", r.getId());
}
Also used : Message(org.jivesoftware.smack.packet.Message) DummyConnection(org.jivesoftware.smack.DummyConnection) Stanza(org.jivesoftware.smack.packet.Stanza) Test(org.junit.Test)

Example 15 with DummyConnection

use of org.jivesoftware.smack.DummyConnection in project Smack by igniterealtime.

the class PingTest method getAuthenticatedDummyConnectionWithoutIqReplies.

/**
     * The returned connection won't send replies to IQs
     * 
     * @return
     * @throws XMPPException 
     * @throws IOException 
     * @throws SmackException 
     * @throws InterruptedException 
     */
private static DummyConnection getAuthenticatedDummyConnectionWithoutIqReplies() throws SmackException, IOException, XMPPException, InterruptedException {
    DummyConnection con = new DummyConnection();
    con.setReplyTimeout(500);
    con.connect();
    con.login();
    return con;
}
Also used : DummyConnection(org.jivesoftware.smack.DummyConnection) ThreadedDummyConnection(org.jivesoftware.smack.ThreadedDummyConnection)

Aggregations

DummyConnection (org.jivesoftware.smack.DummyConnection)20 Test (org.junit.Test)13 Before (org.junit.Before)6 ThreadedDummyConnection (org.jivesoftware.smack.ThreadedDummyConnection)5 Stanza (org.jivesoftware.smack.packet.Stanza)5 IQ (org.jivesoftware.smack.packet.IQ)3 Message (org.jivesoftware.smack.packet.Message)2 TestRosterListener (org.jivesoftware.smack.roster.RosterTest.TestRosterListener)2 Ping (org.jivesoftware.smackx.ping.packet.Ping)2 XMLBuilder (com.jamesmurty.utils.XMLBuilder)1 SmackException (org.jivesoftware.smack.SmackException)1 NoResponseException (org.jivesoftware.smack.SmackException.NoResponseException)1 DirectoryRosterStore (org.jivesoftware.smack.roster.rosterstore.DirectoryRosterStore)1 AuthMechanism (org.jivesoftware.smack.sasl.packet.SaslStreamElements.AuthMechanism)1 Response (org.jivesoftware.smack.sasl.packet.SaslStreamElements.Response)1 LastActivity (org.jivesoftware.smackx.iqlast.packet.LastActivity)1 Version (org.jivesoftware.smackx.iqversion.packet.Version)1