1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-09-10 17:49:38 +02:00

Make sendPacket throw NotConnectedException

also use XMPPConnection.sendPacket() instead of
PacketWriter.sendPacket() in XMPPTCPConnection.
This commit is contained in:
Florian Schmaus 2014-05-03 10:23:57 +02:00
parent 7041e90522
commit 42f2eae8fb
5 changed files with 40 additions and 31 deletions

View file

@ -21,6 +21,7 @@ import java.io.Writer;
import java.util.concurrent.BrokenBarrierException;
import java.util.concurrent.CyclicBarrier;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.packet.Message;
import org.junit.Test;
@ -41,7 +42,7 @@ public class PacketWriterTest {
*/
@SuppressWarnings("javadoc")
@Test
public void shouldBlockAndUnblockTest() throws InterruptedException, BrokenBarrierException {
public void shouldBlockAndUnblockTest() throws InterruptedException, BrokenBarrierException, NotConnectedException {
XMPPTCPConnection connection = new XMPPTCPConnection("foobar.com");
final PacketWriter pw = new PacketWriter(connection);
pw.setWriter(new BlockingStringWriter());
@ -59,13 +60,13 @@ public class PacketWriterTest {
public void run() {
try {
barrier.await();
pw.sendPacket(new Message());
// should only return after the pw was interrupted
if (!shutdown) {
prematureUnblocked = true;
}
}
catch (InterruptedException | BrokenBarrierException e1) {
}
pw.sendPacket(new Message());
// should only return after the pw was shutdown
if (!shutdown) {
prematureUnblocked = true;
catch (Exception e) {
}
try {
barrier.await();