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

Add support for XEP-0198: Stream Management

- De-duplicate code by moving it into AbstractXMPPConnection
- Introduce TopLevelStreamElement as superclass for all XMPP stream elements.
- Add SynchronizationPoint, ParserUtils
- Add ParserUtils

Fixes SMACK-333 and SMACK-521
This commit is contained in:
Florian Schmaus 2014-09-11 09:49:16 +02:00
parent 07c10a7444
commit fc51f3df48
69 changed files with 3277 additions and 1083 deletions

View file

@ -23,9 +23,10 @@ import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.packet.Element;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.PlainStreamElement;
/**
* A dummy implementation of {@link XMPPConnection}, intended to be used during
@ -53,7 +54,7 @@ public class DummyConnection extends AbstractXMPPConnection {
private String connectionID;
private Roster roster;
private final BlockingQueue<Packet> queue = new LinkedBlockingQueue<Packet>();
private final BlockingQueue<Element> queue = new LinkedBlockingQueue<Element>();
public DummyConnection() {
this(new ConnectionConfiguration("example.com"));
@ -178,6 +179,14 @@ public class DummyConnection extends AbstractXMPPConnection {
authenticated = true;
}
@Override
public void send(PlainStreamElement element) {
if (SmackConfiguration.DEBUG_ENABLED) {
System.out.println("[SEND]: " + element.toXML());
}
queue.add(element);
}
@Override
protected void sendPacketInternal(Packet packet) {
if (SmackConfiguration.DEBUG_ENABLED) {
@ -204,7 +213,7 @@ public class DummyConnection extends AbstractXMPPConnection {
* @throws InterruptedException
*/
public Packet getSentPacket() throws InterruptedException {
return queue.poll();
return (Packet) queue.poll();
}
/**
@ -217,7 +226,7 @@ public class DummyConnection extends AbstractXMPPConnection {
* @throws InterruptedException
*/
public Packet getSentPacket(int wait) throws InterruptedException {
return queue.poll(wait, TimeUnit.SECONDS);
return (Packet) queue.poll(wait, TimeUnit.SECONDS);
}
/**

View file

@ -69,8 +69,6 @@ public class RosterVersioningTest {
connection = new DummyConnection(conf);
connection.connect();
connection.setRosterVersioningSupported();
connection.login("rostertest", "secret");
}

View file

@ -47,8 +47,7 @@ final public class TestUtils {
public static XmlPullParser getParser(Reader reader, String startTag) {
XmlPullParser parser;
try {
parser = PacketParserUtils.newXmppParser();
parser.setInput(reader);
parser = PacketParserUtils.newXmppParser(reader);
if (startTag == null) {
return parser;
}