1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-12-22 20:47:57 +01:00

Conditionially set the IQ type in ThreadedDummyConnection

and do not set 'from'.
This commit is contained in:
Florian Schmaus 2017-04-04 11:16:15 +02:00
parent f48f0cab5b
commit 48b5dc5fe7
2 changed files with 10 additions and 3 deletions

View file

@ -57,9 +57,10 @@ public class ThreadedDummyConnection extends DummyConnection {
replyQ.add(replyPacket);
}
replyPacket.setStanzaId(packet.getStanzaId());
replyPacket.setFrom(packet.getTo());
replyPacket.setTo(packet.getFrom());
replyPacket.setType(Type.result);
if (replyPacket.getType() == null) {
replyPacket.setType(Type.result);
}
new ProcessQueue(replyQ).start();
}

View file

@ -26,7 +26,9 @@ import org.jivesoftware.smack.ThreadedDummyConnection;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.XMPPError;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smack.packet.XMPPError.Condition;
import org.jivesoftware.smackx.InitExtensions;
import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
import org.jivesoftware.smackx.disco.packet.DiscoverInfo.Identity;
import org.jivesoftware.smackx.pubsub.packet.PubSub;
@ -39,7 +41,7 @@ import org.junit.Test;
* @author Robin Collier
*
*/
public class ConfigureFormTest
public class ConfigureFormTest extends InitExtensions
{
@Test
public void checkChildrenAssocPolicy()
@ -55,6 +57,8 @@ public class ConfigureFormTest
ThreadedDummyConnection con = ThreadedDummyConnection.newInstance();
PubSubManager mgr = new PubSubManager(con, PubSubManagerTest.DUMMY_PUBSUB_SERVICE);
DiscoverInfo info = new DiscoverInfo();
info.setType(Type.result);
info.setFrom(PubSubManagerTest.DUMMY_PUBSUB_SERVICE);
Identity ident = new Identity("pubsub", null, "leaf");
info.addIdentity(ident);
con.addIQReply(info);
@ -62,6 +66,8 @@ public class ConfigureFormTest
Node node = mgr.getNode("princely_musings");
PubSub errorIq = new PubSub();
errorIq.setType(Type.error);
errorIq.setFrom(PubSubManagerTest.DUMMY_PUBSUB_SERVICE);
XMPPError.Builder error = XMPPError.getBuilder(Condition.forbidden);
errorIq.setError(error);
con.addIQReply(errorIq);