use of org.jivesoftware.smackx.disco.packet.DiscoverInfo in project Smack by igniterealtime.
the class EntityCapsManagerTest method testSimpleDirectoryCache.
private static void testSimpleDirectoryCache(StringEncoder stringEncoder) throws IOException {
EntityCapsPersistentCache cache = new SimpleDirectoryPersistentCache(createTempDirectory());
EntityCapsManager.setPersistentCache(cache);
DiscoverInfo di = createComplexSamplePacket();
CapsVersionAndHash versionAndHash = EntityCapsManager.generateVerificationString(di, StringUtils.SHA1);
String nodeVer = di.getNode() + "#" + versionAndHash.version;
// Save the data in EntityCapsManager
EntityCapsManager.addDiscoverInfoByNode(nodeVer, di);
// Lose all the data
EntityCapsManager.clearMemoryCache();
DiscoverInfo restored_di = EntityCapsManager.getDiscoveryInfoByNodeVer(nodeVer);
assertNotNull(restored_di);
assertEquals(di.toXML().toString(), restored_di.toXML().toString());
}
use of org.jivesoftware.smackx.disco.packet.DiscoverInfo in project Smack by igniterealtime.
the class EntityCapsManagerTest method testVerificationDuplicateIdentities.
@Test
public void testVerificationDuplicateIdentities() throws XmppStringprepException {
DiscoverInfo di = createMalformedDiscoverInfo();
assertTrue(di.containsDuplicateIdentities());
}
use of org.jivesoftware.smackx.disco.packet.DiscoverInfo in project Smack by igniterealtime.
the class EntityCapsManagerTest method createComplexSamplePacket.
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);
Collection<DiscoverInfo.Identity> identities = new LinkedList<DiscoverInfo.Identity>();
DiscoverInfo.Identity i = new DiscoverInfo.Identity("client", "pc", "Psi 0.11", "en");
identities.add(i);
i = new DiscoverInfo.Identity("client", "pc", "Ψ 0.11", "el");
identities.add(i);
di.addIdentities(identities);
di.addFeature("http://jabber.org/protocol/disco#items");
di.addFeature(EntityCapsManager.NAMESPACE);
di.addFeature("http://jabber.org/protocol/muc");
di.addFeature("http://jabber.org/protocol/disco#info");
DataForm df = new DataForm(DataForm.Type.result);
FormField ff = new FormField("os");
ff.addValue("Mac");
df.addField(ff);
ff = new FormField("FORM_TYPE");
ff.setType(FormField.Type.hidden);
ff.addValue("urn:xmpp:dataforms:softwareinfo");
df.addField(ff);
ff = new FormField("ip_version");
ff.addValue("ipv4");
ff.addValue("ipv6");
df.addField(ff);
ff = new FormField("os_version");
ff.addValue("10.5.1");
df.addField(ff);
ff = new FormField("software");
ff.addValue("Psi");
df.addField(ff);
ff = new FormField("software_version");
ff.addValue("0.11");
df.addField(ff);
di.addExtension(df);
return di;
}
use of org.jivesoftware.smackx.disco.packet.DiscoverInfo in project Smack by igniterealtime.
the class EntityCapsManagerTest method testVerificationDuplicateFeatures.
@Test
public void testVerificationDuplicateFeatures() throws XmppStringprepException {
DiscoverInfo di = createMalformedDiscoverInfo();
assertTrue(di.containsDuplicateFeatures());
}
use of org.jivesoftware.smackx.disco.packet.DiscoverInfo in project Smack by igniterealtime.
the class Socks5PacketUtils method createDiscoverInfo.
/**
* Returns a response to an info discovery request. The stanza(/packet) doesn't contain any infos.
*
* @param from the target
* @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);
return discoverInfo;
}
Aggregations