mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2025-12-07 13:41:08 +01:00
Apply builder pattern to DiscoverInfo
This is the first transformation of an IQ type to the builder type.
This commit is contained in:
parent
36072fb25a
commit
6e32305987
30 changed files with 749 additions and 233 deletions
|
|
@ -49,6 +49,7 @@ import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream.StreamHost;
|
|||
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
||||
import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
|
||||
import org.jivesoftware.smackx.disco.packet.DiscoverInfo.Identity;
|
||||
import org.jivesoftware.smackx.disco.packet.DiscoverInfoBuilder;
|
||||
import org.jivesoftware.smackx.disco.packet.DiscoverItems;
|
||||
import org.jivesoftware.smackx.disco.packet.DiscoverItems.Item;
|
||||
|
||||
|
|
@ -145,7 +146,7 @@ public class Socks5ByteStreamManagerTest {
|
|||
|
||||
FeatureNotSupportedException e = assertThrows(FeatureNotSupportedException.class, () -> {
|
||||
// build empty discover info as reply if targets features are queried
|
||||
DiscoverInfo discoverInfo = new DiscoverInfo();
|
||||
DiscoverInfo discoverInfo = DiscoverInfo.builder("disco-1").build();
|
||||
protocol.addResponse(discoverInfo);
|
||||
|
||||
// start SOCKS5 Bytestream
|
||||
|
|
@ -181,11 +182,11 @@ public class Socks5ByteStreamManagerTest {
|
|||
*/
|
||||
|
||||
// build discover info that supports the SOCKS5 feature
|
||||
DiscoverInfo discoverInfo = Socks5PacketUtils.createDiscoverInfo(targetJID, initiatorJID);
|
||||
DiscoverInfoBuilder discoverInfo = Socks5PacketUtils.createDiscoverInfo(targetJID, initiatorJID);
|
||||
discoverInfo.addFeature(Bytestream.NAMESPACE);
|
||||
|
||||
// return that SOCKS5 is supported if target is queried
|
||||
protocol.addResponse(discoverInfo, Verification.correspondingSenderReceiver,
|
||||
protocol.addResponse(discoverInfo.build(), Verification.correspondingSenderReceiver,
|
||||
Verification.requestTypeGET);
|
||||
|
||||
// build discover items with no proxy items
|
||||
|
|
@ -233,11 +234,11 @@ public class Socks5ByteStreamManagerTest {
|
|||
*/
|
||||
|
||||
// build discover info that supports the SOCKS5 feature
|
||||
DiscoverInfo discoverInfo = Socks5PacketUtils.createDiscoverInfo(targetJID, initiatorJID);
|
||||
DiscoverInfoBuilder discoverInfo = Socks5PacketUtils.createDiscoverInfo(targetJID, initiatorJID);
|
||||
discoverInfo.addFeature(Bytestream.NAMESPACE);
|
||||
|
||||
// return that SOCKS5 is supported if target is queried
|
||||
protocol.addResponse(discoverInfo, Verification.correspondingSenderReceiver,
|
||||
protocol.addResponse(discoverInfo.build(), Verification.correspondingSenderReceiver,
|
||||
Verification.requestTypeGET);
|
||||
|
||||
// build discover items containing a proxy item
|
||||
|
|
@ -252,12 +253,12 @@ public class Socks5ByteStreamManagerTest {
|
|||
|
||||
// build discover info for proxy containing information about NOT being a Socks5
|
||||
// proxy
|
||||
DiscoverInfo proxyInfo = Socks5PacketUtils.createDiscoverInfo(proxyJID, initiatorJID);
|
||||
DiscoverInfoBuilder proxyInfo = Socks5PacketUtils.createDiscoverInfo(proxyJID, initiatorJID);
|
||||
Identity identity = new Identity("noproxy", proxyJID.toString(), "bytestreams");
|
||||
proxyInfo.addIdentity(identity);
|
||||
|
||||
// return the proxy identity if proxy is queried
|
||||
protocol.addResponse(proxyInfo, Verification.correspondingSenderReceiver,
|
||||
protocol.addResponse(proxyInfo.build(), Verification.correspondingSenderReceiver,
|
||||
Verification.requestTypeGET);
|
||||
|
||||
SmackException e = assertThrows(SmackException.class, () -> {
|
||||
|
|
@ -294,9 +295,10 @@ public class Socks5ByteStreamManagerTest {
|
|||
*/
|
||||
|
||||
// build discover info that supports the SOCKS5 feature
|
||||
DiscoverInfo discoverInfo = Socks5PacketUtils.createDiscoverInfo(targetJID, initiatorJID);
|
||||
discoverInfo.addFeature(Bytestream.NAMESPACE);
|
||||
DiscoverInfoBuilder discoverInfoBuilder = Socks5PacketUtils.createDiscoverInfo(targetJID, initiatorJID);
|
||||
discoverInfoBuilder.addFeature(Bytestream.NAMESPACE);
|
||||
|
||||
DiscoverInfo discoverInfo = discoverInfoBuilder.build();
|
||||
// return that SOCKS5 is supported if target is queried
|
||||
protocol.addResponse(discoverInfo, Verification.correspondingSenderReceiver,
|
||||
Verification.requestTypeGET);
|
||||
|
|
@ -313,12 +315,12 @@ public class Socks5ByteStreamManagerTest {
|
|||
|
||||
// build discover info for proxy containing information about NOT being a Socks5
|
||||
// proxy
|
||||
DiscoverInfo proxyInfo = Socks5PacketUtils.createDiscoverInfo(proxyJID, initiatorJID);
|
||||
DiscoverInfoBuilder proxyInfo = Socks5PacketUtils.createDiscoverInfo(proxyJID, initiatorJID);
|
||||
Identity identity = new Identity("noproxy", proxyJID.toString(), "bytestreams");
|
||||
proxyInfo.addIdentity(identity);
|
||||
|
||||
// return the proxy identity if proxy is queried
|
||||
protocol.addResponse(proxyInfo, Verification.correspondingSenderReceiver,
|
||||
protocol.addResponse(proxyInfo.build(), Verification.correspondingSenderReceiver,
|
||||
Verification.requestTypeGET);
|
||||
|
||||
SmackException e = assertThrows(SmackException.class, () -> {
|
||||
|
|
@ -376,11 +378,11 @@ public class Socks5ByteStreamManagerTest {
|
|||
*/
|
||||
|
||||
// build discover info that supports the SOCKS5 feature
|
||||
DiscoverInfo discoverInfo = Socks5PacketUtils.createDiscoverInfo(targetJID, initiatorJID);
|
||||
DiscoverInfoBuilder discoverInfo = Socks5PacketUtils.createDiscoverInfo(targetJID, initiatorJID);
|
||||
discoverInfo.addFeature(Bytestream.NAMESPACE);
|
||||
|
||||
// return that SOCKS5 is supported if target is queried
|
||||
protocol.addResponse(discoverInfo, Verification.correspondingSenderReceiver,
|
||||
protocol.addResponse(discoverInfo.build(), Verification.correspondingSenderReceiver,
|
||||
Verification.requestTypeGET);
|
||||
|
||||
// build discover items containing a proxy item
|
||||
|
|
@ -394,12 +396,12 @@ public class Socks5ByteStreamManagerTest {
|
|||
Verification.requestTypeGET);
|
||||
|
||||
// build discover info for proxy containing information about being a SOCKS5 proxy
|
||||
DiscoverInfo proxyInfo = Socks5PacketUtils.createDiscoverInfo(proxyJID, initiatorJID);
|
||||
DiscoverInfoBuilder proxyInfo = Socks5PacketUtils.createDiscoverInfo(proxyJID, initiatorJID);
|
||||
Identity identity = new Identity("proxy", proxyJID.toString(), "bytestreams");
|
||||
proxyInfo.addIdentity(identity);
|
||||
|
||||
// return the socks5 bytestream proxy identity if proxy is queried
|
||||
protocol.addResponse(proxyInfo, Verification.correspondingSenderReceiver,
|
||||
protocol.addResponse(proxyInfo.build(), Verification.correspondingSenderReceiver,
|
||||
Verification.requestTypeGET);
|
||||
|
||||
// build a socks5 stream host info containing the address and the port of the
|
||||
|
|
@ -458,11 +460,11 @@ public class Socks5ByteStreamManagerTest {
|
|||
*/
|
||||
|
||||
// build discover info that supports the SOCKS5 feature
|
||||
DiscoverInfo discoverInfo = Socks5PacketUtils.createDiscoverInfo(targetJID, initiatorJID);
|
||||
DiscoverInfoBuilder discoverInfo = Socks5PacketUtils.createDiscoverInfo(targetJID, initiatorJID);
|
||||
discoverInfo.addFeature(Bytestream.NAMESPACE);
|
||||
|
||||
// return that SOCKS5 is supported if target is queried
|
||||
protocol.addResponse(discoverInfo, Verification.correspondingSenderReceiver,
|
||||
protocol.addResponse(discoverInfo.build(), Verification.correspondingSenderReceiver,
|
||||
Verification.requestTypeGET);
|
||||
|
||||
// build discover items containing a proxy item
|
||||
|
|
@ -476,12 +478,12 @@ public class Socks5ByteStreamManagerTest {
|
|||
Verification.requestTypeGET);
|
||||
|
||||
// build discover info for proxy containing information about being a SOCKS5 proxy
|
||||
DiscoverInfo proxyInfo = Socks5PacketUtils.createDiscoverInfo(proxyJID, initiatorJID);
|
||||
DiscoverInfoBuilder proxyInfo = Socks5PacketUtils.createDiscoverInfo(proxyJID, initiatorJID);
|
||||
Identity identity = new Identity("proxy", proxyJID.toString(), "bytestreams");
|
||||
proxyInfo.addIdentity(identity);
|
||||
|
||||
// return the socks5 bytestream proxy identity if proxy is queried
|
||||
protocol.addResponse(proxyInfo, Verification.correspondingSenderReceiver,
|
||||
protocol.addResponse(proxyInfo.build(), Verification.correspondingSenderReceiver,
|
||||
Verification.requestTypeGET);
|
||||
|
||||
// build a socks5 stream host info containing the address and the port of the
|
||||
|
|
@ -545,11 +547,11 @@ public class Socks5ByteStreamManagerTest {
|
|||
*/
|
||||
|
||||
// build discover info that supports the SOCKS5 feature
|
||||
DiscoverInfo discoverInfo = Socks5PacketUtils.createDiscoverInfo(targetJID, initiatorJID);
|
||||
discoverInfo.addFeature(Bytestream.NAMESPACE);
|
||||
DiscoverInfoBuilder discoverInfoBuilder = Socks5PacketUtils.createDiscoverInfo(targetJID, initiatorJID);
|
||||
discoverInfoBuilder.addFeature(Bytestream.NAMESPACE);
|
||||
|
||||
// return that SOCKS5 is supported if target is queried
|
||||
protocol.addResponse(discoverInfo, Verification.correspondingSenderReceiver,
|
||||
protocol.addResponse(discoverInfoBuilder.build(), Verification.correspondingSenderReceiver,
|
||||
Verification.requestTypeGET);
|
||||
|
||||
// build discover items containing a proxy item
|
||||
|
|
@ -563,12 +565,12 @@ public class Socks5ByteStreamManagerTest {
|
|||
Verification.requestTypeGET);
|
||||
|
||||
// build discover info for proxy containing information about being a SOCKS5 proxy
|
||||
DiscoverInfo proxyInfo = Socks5PacketUtils.createDiscoverInfo(proxyJID, initiatorJID);
|
||||
DiscoverInfoBuilder proxyInfo = Socks5PacketUtils.createDiscoverInfo(proxyJID, initiatorJID);
|
||||
Identity identity = new Identity("proxy", proxyJID.toString(), "bytestreams");
|
||||
proxyInfo.addIdentity(identity);
|
||||
|
||||
// return the socks5 bytestream proxy identity if proxy is queried
|
||||
protocol.addResponse(proxyInfo, Verification.correspondingSenderReceiver,
|
||||
protocol.addResponse(proxyInfo.build(), Verification.correspondingSenderReceiver,
|
||||
Verification.requestTypeGET);
|
||||
|
||||
// build a socks5 stream host info containing the address and the port of the
|
||||
|
|
@ -639,11 +641,11 @@ public class Socks5ByteStreamManagerTest {
|
|||
*/
|
||||
|
||||
// build discover info that supports the SOCKS5 feature
|
||||
DiscoverInfo discoverInfo = Socks5PacketUtils.createDiscoverInfo(targetJID, initiatorJID);
|
||||
DiscoverInfoBuilder discoverInfo = Socks5PacketUtils.createDiscoverInfo(targetJID, initiatorJID);
|
||||
discoverInfo.addFeature(Bytestream.NAMESPACE);
|
||||
|
||||
// return that SOCKS5 is supported if target is queried
|
||||
protocol.addResponse(discoverInfo, Verification.correspondingSenderReceiver,
|
||||
protocol.addResponse(discoverInfo.build(), Verification.correspondingSenderReceiver,
|
||||
Verification.requestTypeGET);
|
||||
|
||||
// build discover items containing a proxy item
|
||||
|
|
@ -657,12 +659,12 @@ public class Socks5ByteStreamManagerTest {
|
|||
Verification.requestTypeGET);
|
||||
|
||||
// build discover info for proxy containing information about being a SOCKS5 proxy
|
||||
DiscoverInfo proxyInfo = Socks5PacketUtils.createDiscoverInfo(proxyJID, initiatorJID);
|
||||
DiscoverInfoBuilder proxyInfo = Socks5PacketUtils.createDiscoverInfo(proxyJID, initiatorJID);
|
||||
Identity identity = new Identity("proxy", proxyJID.toString(), "bytestreams");
|
||||
proxyInfo.addIdentity(identity);
|
||||
|
||||
// return the socks5 bytestream proxy identity if proxy is queried
|
||||
protocol.addResponse(proxyInfo, Verification.correspondingSenderReceiver,
|
||||
protocol.addResponse(proxyInfo.build(), Verification.correspondingSenderReceiver,
|
||||
Verification.requestTypeGET);
|
||||
|
||||
// build a socks5 stream host info containing the address and the port of the
|
||||
|
|
@ -765,11 +767,11 @@ public class Socks5ByteStreamManagerTest {
|
|||
*/
|
||||
|
||||
// build discover info that supports the SOCKS5 feature
|
||||
DiscoverInfo discoverInfo = Socks5PacketUtils.createDiscoverInfo(targetJID, initiatorJID);
|
||||
DiscoverInfoBuilder discoverInfo = Socks5PacketUtils.createDiscoverInfo(targetJID, initiatorJID);
|
||||
discoverInfo.addFeature(Bytestream.NAMESPACE);
|
||||
|
||||
// return that SOCKS5 is supported if target is queried
|
||||
protocol.addResponse(discoverInfo, Verification.correspondingSenderReceiver,
|
||||
protocol.addResponse(discoverInfo.build(), Verification.correspondingSenderReceiver,
|
||||
Verification.requestTypeGET);
|
||||
|
||||
// build discover items containing no proxy item
|
||||
|
|
@ -1009,11 +1011,11 @@ public class Socks5ByteStreamManagerTest {
|
|||
Verification<Bytestream, Bytestream> streamHostUsedVerification, Socks5TestProxy socks5TestProxy)
|
||||
throws XmppStringprepException {
|
||||
// build discover info that supports the SOCKS5 feature
|
||||
DiscoverInfo discoverInfo = Socks5PacketUtils.createDiscoverInfo(targetJID, initiatorJID);
|
||||
DiscoverInfoBuilder discoverInfo = Socks5PacketUtils.createDiscoverInfo(targetJID, initiatorJID);
|
||||
discoverInfo.addFeature(Bytestream.NAMESPACE);
|
||||
|
||||
// return that SOCKS5 is supported if target is queried
|
||||
protocol.addResponse(discoverInfo, Verification.correspondingSenderReceiver,
|
||||
protocol.addResponse(discoverInfo.build(), Verification.correspondingSenderReceiver,
|
||||
Verification.requestTypeGET);
|
||||
|
||||
// build discover items containing a proxy item
|
||||
|
|
@ -1030,22 +1032,22 @@ public class Socks5ByteStreamManagerTest {
|
|||
* build discover info for proxy "proxy2.xmpp-server" containing information about being a
|
||||
* SOCKS5 proxy
|
||||
*/
|
||||
DiscoverInfo proxyInfo1 = Socks5PacketUtils.createDiscoverInfo(JidCreate.from("proxy2.xmpp-server"),
|
||||
DiscoverInfoBuilder proxyInfo1 = Socks5PacketUtils.createDiscoverInfo(JidCreate.from("proxy2.xmpp-server"),
|
||||
initiatorJID);
|
||||
Identity identity1 = new Identity("proxy", "proxy2.xmpp-server", "bytestreams");
|
||||
proxyInfo1.addIdentity(identity1);
|
||||
|
||||
// return the SOCKS5 bytestream proxy identity if proxy is queried
|
||||
protocol.addResponse(proxyInfo1, Verification.correspondingSenderReceiver,
|
||||
protocol.addResponse(proxyInfo1.build(), Verification.correspondingSenderReceiver,
|
||||
Verification.requestTypeGET);
|
||||
|
||||
// build discover info for proxy containing information about being a SOCKS5 proxy
|
||||
DiscoverInfo proxyInfo2 = Socks5PacketUtils.createDiscoverInfo(proxyJID, initiatorJID);
|
||||
DiscoverInfoBuilder proxyInfo2 = Socks5PacketUtils.createDiscoverInfo(proxyJID, initiatorJID);
|
||||
Identity identity2 = new Identity("proxy", proxyJID.toString(), "bytestreams");
|
||||
proxyInfo2.addIdentity(identity2);
|
||||
|
||||
// return the SOCKS5 bytestream proxy identity if proxy is queried
|
||||
protocol.addResponse(proxyInfo2, Verification.correspondingSenderReceiver,
|
||||
protocol.addResponse(proxyInfo2.build(), Verification.correspondingSenderReceiver,
|
||||
Verification.requestTypeGET);
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import org.jivesoftware.smack.packet.IQ;
|
|||
|
||||
import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream;
|
||||
import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
|
||||
import org.jivesoftware.smackx.disco.packet.DiscoverInfoBuilder;
|
||||
import org.jivesoftware.smackx.disco.packet.DiscoverItems;
|
||||
|
||||
import org.jxmpp.jid.Jid;
|
||||
|
|
@ -88,11 +89,12 @@ public class Socks5PacketUtils {
|
|||
* @param to the initiator
|
||||
* @return response to an info discovery request
|
||||
*/
|
||||
public static DiscoverInfo createDiscoverInfo(Jid from, Jid to) {
|
||||
DiscoverInfo discoverInfo = new DiscoverInfo();
|
||||
discoverInfo.setFrom(from);
|
||||
discoverInfo.setTo(to);
|
||||
discoverInfo.setType(IQ.Type.result);
|
||||
public static DiscoverInfoBuilder createDiscoverInfo(Jid from, Jid to) {
|
||||
DiscoverInfoBuilder discoverInfo = DiscoverInfo.builder("disco-1")
|
||||
.from(from)
|
||||
.to(to)
|
||||
.ofType(IQ.Type.result)
|
||||
;
|
||||
return discoverInfo;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ import org.jivesoftware.smackx.InitExtensions;
|
|||
import org.jivesoftware.smackx.caps.cache.EntityCapsPersistentCache;
|
||||
import org.jivesoftware.smackx.caps.cache.SimpleDirectoryPersistentCache;
|
||||
import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
|
||||
import org.jivesoftware.smackx.disco.packet.DiscoverInfoBuilder;
|
||||
import org.jivesoftware.smackx.xdata.FormField;
|
||||
import org.jivesoftware.smackx.xdata.packet.DataForm;
|
||||
|
||||
|
|
@ -97,11 +98,10 @@ public class EntityCapsManagerTest extends InitExtensions {
|
|||
}
|
||||
|
||||
private static DiscoverInfo createComplexSamplePacket() throws XmppStringprepException {
|
||||
DiscoverInfo di = new DiscoverInfo();
|
||||
di.setFrom(JidCreate.from("benvolio@capulet.lit/230193"));
|
||||
di.setStanzaId("disco1");
|
||||
di.setTo(JidCreate.from("juliet@capulet.lit/chamber"));
|
||||
di.setType(IQ.Type.result);
|
||||
DiscoverInfoBuilder di = DiscoverInfo.builder("disco1");
|
||||
di.from(JidCreate.from("benvolio@capulet.lit/230193"));
|
||||
di.to(JidCreate.from("juliet@capulet.lit/chamber"));
|
||||
di.ofType(IQ.Type.result);
|
||||
|
||||
Collection<DiscoverInfo.Identity> identities = new LinkedList<DiscoverInfo.Identity>();
|
||||
DiscoverInfo.Identity i = new DiscoverInfo.Identity("client", "pc", "Psi 0.11", "en");
|
||||
|
|
@ -144,15 +144,14 @@ public class EntityCapsManagerTest extends InitExtensions {
|
|||
df.addField(ff.build());
|
||||
|
||||
di.addExtension(df);
|
||||
return di;
|
||||
return di.build();
|
||||
}
|
||||
|
||||
private static DiscoverInfo createMalformedDiscoverInfo() throws XmppStringprepException {
|
||||
DiscoverInfo di = new DiscoverInfo();
|
||||
di.setFrom(JidCreate.from("benvolio@capulet.lit/230193"));
|
||||
di.setStanzaId("disco1");
|
||||
di.setTo(JidCreate.from(")juliet@capulet.lit/chamber"));
|
||||
di.setType(IQ.Type.result);
|
||||
DiscoverInfoBuilder di = DiscoverInfo.builder("disco1");
|
||||
di.from("benvolio@capulet.lit/230193");
|
||||
di.to(")juliet@capulet.lit/chamber");
|
||||
di.ofType(IQ.Type.result);
|
||||
|
||||
Collection<DiscoverInfo.Identity> identities = new LinkedList<DiscoverInfo.Identity>();
|
||||
DiscoverInfo.Identity i = new DiscoverInfo.Identity("client", "pc", "Psi 0.11", "en");
|
||||
|
|
@ -217,7 +216,8 @@ public class EntityCapsManagerTest extends InitExtensions {
|
|||
|
||||
di.addExtension(df);
|
||||
|
||||
return di;
|
||||
DiscoverInfo discoverInfo = di.buildWithoutValidiation();
|
||||
return discoverInfo;
|
||||
}
|
||||
|
||||
public static File createTempDirectory() throws IOException {
|
||||
|
|
|
|||
|
|
@ -30,8 +30,9 @@ public class RoomInfoTest {
|
|||
public void validateRoomWithEmptyForm() {
|
||||
DataForm dataForm = new DataForm(DataForm.Type.result);
|
||||
|
||||
DiscoverInfo discoInfo = new DiscoverInfo();
|
||||
discoInfo.addExtension(dataForm);
|
||||
DiscoverInfo discoInfo = DiscoverInfo.builder("disco1")
|
||||
.addExtension(dataForm)
|
||||
.build();
|
||||
RoomInfo roomInfo = new RoomInfo(discoInfo);
|
||||
assertTrue(roomInfo.getDescription().isEmpty());
|
||||
assertTrue(roomInfo.getSubject().isEmpty());
|
||||
|
|
@ -54,8 +55,9 @@ public class RoomInfoTest {
|
|||
occupants.addValue("3");
|
||||
dataForm.addField(occupants.build());
|
||||
|
||||
DiscoverInfo discoInfo = new DiscoverInfo();
|
||||
discoInfo.addExtension(dataForm);
|
||||
DiscoverInfo discoInfo = DiscoverInfo.builder("disco1")
|
||||
.addExtension(dataForm)
|
||||
.build();
|
||||
RoomInfo roomInfo = new RoomInfo(discoInfo);
|
||||
assertEquals("The place for all good witches!", roomInfo.getDescription());
|
||||
assertEquals("Spells", roomInfo.getSubject());
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import org.jivesoftware.smack.SmackException;
|
|||
import org.jivesoftware.smack.ThreadedDummyConnection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.IQ.Type;
|
||||
import org.jivesoftware.smack.packet.StanzaError;
|
||||
import org.jivesoftware.smack.packet.StanzaError.Condition;
|
||||
|
|
@ -33,6 +34,7 @@ import org.jivesoftware.smack.packet.StanzaError.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.disco.packet.DiscoverInfoBuilder;
|
||||
import org.jivesoftware.smackx.pubsub.packet.PubSub;
|
||||
import org.jivesoftware.smackx.xdata.packet.DataForm;
|
||||
|
||||
|
|
@ -55,12 +57,14 @@ public class ConfigureFormTest extends InitExtensions {
|
|||
public void getConfigFormWithInsufficientPrivileges() throws XMPPException, SmackException, IOException, InterruptedException {
|
||||
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);
|
||||
DiscoverInfoBuilder info = DiscoverInfo.builder("disco-result")
|
||||
.ofType(IQ.Type.result)
|
||||
.from(PubSubManagerTest.DUMMY_PUBSUB_SERVICE);
|
||||
Identity ident = new Identity("pubsub", null, "leaf");
|
||||
info.addIdentity(ident);
|
||||
con.addIQReply(info);
|
||||
|
||||
DiscoverInfo discoverInfo = info.build();
|
||||
con.addIQReply(discoverInfo);
|
||||
|
||||
Node node = mgr.getNode("princely_musings");
|
||||
|
||||
|
|
@ -84,10 +88,12 @@ public class ConfigureFormTest extends InitExtensions {
|
|||
public void getConfigFormWithTimeout() throws XMPPException, SmackException, InterruptedException {
|
||||
ThreadedDummyConnection con = new ThreadedDummyConnection();
|
||||
PubSubManager mgr = new PubSubManager(con, PubSubManagerTest.DUMMY_PUBSUB_SERVICE);
|
||||
DiscoverInfo info = new DiscoverInfo();
|
||||
DiscoverInfoBuilder info = DiscoverInfo.builder("disco-result");
|
||||
Identity ident = new Identity("pubsub", null, "leaf");
|
||||
info.addIdentity(ident);
|
||||
con.addIQReply(info);
|
||||
|
||||
DiscoverInfo discoverInfo = info.build();
|
||||
con.addIQReply(discoverInfo);
|
||||
|
||||
Node node = mgr.getNode("princely_musings");
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue