mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-26 05:52:06 +01:00
Fix StreamManagementTest in smack-integration
Since 6c637d5784
connect() does not longer
automatically perform a login.
Also verify the message bodies in the test.
This commit is contained in:
parent
0efdc4018f
commit
00a7556bfe
1 changed files with 34 additions and 7 deletions
|
@ -16,6 +16,9 @@
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smack;
|
package org.jivesoftware.smack;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.security.KeyManagementException;
|
import java.security.KeyManagementException;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
@ -25,6 +28,9 @@ import org.igniterealtime.smack.inttest.Configuration;
|
||||||
import org.igniterealtime.smack.inttest.SmackIntegrationTest;
|
import org.igniterealtime.smack.inttest.SmackIntegrationTest;
|
||||||
import org.igniterealtime.smack.inttest.TestNotPossibleException;
|
import org.igniterealtime.smack.inttest.TestNotPossibleException;
|
||||||
import org.jivesoftware.smack.SmackException.NotConnectedException;
|
import org.jivesoftware.smack.SmackException.NotConnectedException;
|
||||||
|
import org.jivesoftware.smack.filter.AndFilter;
|
||||||
|
import org.jivesoftware.smack.filter.FromMatchesFilter;
|
||||||
|
import org.jivesoftware.smack.filter.MessageWithBodiesFilter;
|
||||||
import org.jivesoftware.smack.packet.Message;
|
import org.jivesoftware.smack.packet.Message;
|
||||||
import org.jivesoftware.smack.tcp.XMPPTCPConnection;
|
import org.jivesoftware.smack.tcp.XMPPTCPConnection;
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
|
@ -60,17 +66,32 @@ public class StreamManagementTest extends AbstractSmackLowLevelIntegrationTest {
|
||||||
public void testStreamManagement(XMPPTCPConnection conOne, XMPPTCPConnection conTwo) throws InterruptedException, KeyManagementException,
|
public void testStreamManagement(XMPPTCPConnection conOne, XMPPTCPConnection conTwo) throws InterruptedException, KeyManagementException,
|
||||||
NoSuchAlgorithmException, SmackException, IOException, XMPPException,
|
NoSuchAlgorithmException, SmackException, IOException, XMPPException,
|
||||||
TestNotPossibleException {
|
TestNotPossibleException {
|
||||||
send("Hi, what's up?", conOne, conTwo);
|
final String body1 = "Hi, what's up? " + testRunId;
|
||||||
|
final String body2 = "Hi, what's up? I've been just instantly shutdown" + testRunId;
|
||||||
|
final String body3 = "Hi, what's up? I've been just resumed" + testRunId;
|
||||||
|
|
||||||
|
final PacketCollector collector = conTwo.createPacketCollector(new AndFilter(
|
||||||
|
MessageWithBodiesFilter.INSTANCE,
|
||||||
|
FromMatchesFilter.createFull(conOne.getUser())));
|
||||||
|
|
||||||
|
try {
|
||||||
|
send(body1, conOne, conTwo);
|
||||||
|
assertMessageWithBodyReceived(body1, collector);
|
||||||
|
|
||||||
conOne.instantShutdown();
|
conOne.instantShutdown();
|
||||||
|
|
||||||
send("Hi, what's up? I've been just instantly shutdown", conOne, conTwo);
|
send(body2, conOne, conTwo);
|
||||||
|
|
||||||
// Reconnect with xep198
|
// Reconnect with xep198
|
||||||
conOne.connect();
|
conOne.connect().login();
|
||||||
|
assertMessageWithBodyReceived(body2, collector);
|
||||||
|
|
||||||
send("Hi, what's up? I've been just resumed", conOne, conTwo);
|
send(body3, conOne, conTwo);
|
||||||
// TODO check that all messages where received
|
assertMessageWithBodyReceived(body3, collector);
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
collector.cancel();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void send(String messageString, XMPPConnection from, XMPPConnection to)
|
private static void send(String messageString, XMPPConnection from, XMPPConnection to)
|
||||||
|
@ -79,4 +100,10 @@ public class StreamManagementTest extends AbstractSmackLowLevelIntegrationTest {
|
||||||
message.setBody(messageString);
|
message.setBody(messageString);
|
||||||
from.sendStanza(message);
|
from.sendStanza(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void assertMessageWithBodyReceived(String body, PacketCollector collector) throws InterruptedException {
|
||||||
|
Message message = collector.nextResult();
|
||||||
|
assertNotNull(message);
|
||||||
|
assertEquals(body, message.getBody());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue