1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-16 12:12:06 +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); replyQ.add(replyPacket);
} }
replyPacket.setStanzaId(packet.getStanzaId()); replyPacket.setStanzaId(packet.getStanzaId());
replyPacket.setFrom(packet.getTo());
replyPacket.setTo(packet.getFrom()); replyPacket.setTo(packet.getFrom());
replyPacket.setType(Type.result); if (replyPacket.getType() == null) {
replyPacket.setType(Type.result);
}
new ProcessQueue(replyQ).start(); 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;
import org.jivesoftware.smack.XMPPException.XMPPErrorException; import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.XMPPError; import org.jivesoftware.smack.packet.XMPPError;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smack.packet.XMPPError.Condition; 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;
import org.jivesoftware.smackx.disco.packet.DiscoverInfo.Identity; import org.jivesoftware.smackx.disco.packet.DiscoverInfo.Identity;
import org.jivesoftware.smackx.pubsub.packet.PubSub; import org.jivesoftware.smackx.pubsub.packet.PubSub;
@ -39,7 +41,7 @@ import org.junit.Test;
* @author Robin Collier * @author Robin Collier
* *
*/ */
public class ConfigureFormTest public class ConfigureFormTest extends InitExtensions
{ {
@Test @Test
public void checkChildrenAssocPolicy() public void checkChildrenAssocPolicy()
@ -55,6 +57,8 @@ public class ConfigureFormTest
ThreadedDummyConnection con = ThreadedDummyConnection.newInstance(); ThreadedDummyConnection con = ThreadedDummyConnection.newInstance();
PubSubManager mgr = new PubSubManager(con, PubSubManagerTest.DUMMY_PUBSUB_SERVICE); PubSubManager mgr = new PubSubManager(con, PubSubManagerTest.DUMMY_PUBSUB_SERVICE);
DiscoverInfo info = new DiscoverInfo(); DiscoverInfo info = new DiscoverInfo();
info.setType(Type.result);
info.setFrom(PubSubManagerTest.DUMMY_PUBSUB_SERVICE);
Identity ident = new Identity("pubsub", null, "leaf"); Identity ident = new Identity("pubsub", null, "leaf");
info.addIdentity(ident); info.addIdentity(ident);
con.addIQReply(info); con.addIQReply(info);
@ -62,6 +66,8 @@ public class ConfigureFormTest
Node node = mgr.getNode("princely_musings"); Node node = mgr.getNode("princely_musings");
PubSub errorIq = new PubSub(); PubSub errorIq = new PubSub();
errorIq.setType(Type.error);
errorIq.setFrom(PubSubManagerTest.DUMMY_PUBSUB_SERVICE);
XMPPError.Builder error = XMPPError.getBuilder(Condition.forbidden); XMPPError.Builder error = XMPPError.getBuilder(Condition.forbidden);
errorIq.setError(error); errorIq.setError(error);
con.addIQReply(errorIq); con.addIQReply(errorIq);