Search in sources :

Example 21 with DiscoverInfo

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());
}
Also used : DiscoverInfo(org.jivesoftware.smackx.disco.packet.DiscoverInfo) EntityCapsPersistentCache(org.jivesoftware.smackx.caps.cache.EntityCapsPersistentCache) SimpleDirectoryPersistentCache(org.jivesoftware.smackx.caps.cache.SimpleDirectoryPersistentCache)

Example 22 with DiscoverInfo

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());
}
Also used : DiscoverInfo(org.jivesoftware.smackx.disco.packet.DiscoverInfo) Test(org.junit.Test)

Example 23 with DiscoverInfo

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;
}
Also used : DiscoverInfo(org.jivesoftware.smackx.disco.packet.DiscoverInfo) DataForm(org.jivesoftware.smackx.xdata.packet.DataForm) FormField(org.jivesoftware.smackx.xdata.FormField) LinkedList(java.util.LinkedList)

Example 24 with DiscoverInfo

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());
}
Also used : DiscoverInfo(org.jivesoftware.smackx.disco.packet.DiscoverInfo) Test(org.junit.Test)

Example 25 with DiscoverInfo

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;
}
Also used : DiscoverInfo(org.jivesoftware.smackx.disco.packet.DiscoverInfo)

Aggregations

DiscoverInfo (org.jivesoftware.smackx.disco.packet.DiscoverInfo)53 Test (org.junit.Test)18 DiscoverItems (org.jivesoftware.smackx.disco.packet.DiscoverItems)12 XMPPErrorException (org.jivesoftware.smack.XMPPException.XMPPErrorException)11 Identity (org.jivesoftware.smackx.disco.packet.DiscoverInfo.Identity)11 IOException (java.io.IOException)8 SmackException (org.jivesoftware.smack.SmackException)8 XMPPException (org.jivesoftware.smack.XMPPException)8 Item (org.jivesoftware.smackx.disco.packet.DiscoverItems.Item)8 ConnectException (java.net.ConnectException)7 FeatureNotSupportedException (org.jivesoftware.smack.SmackException.FeatureNotSupportedException)7 ServiceDiscoveryManager (org.jivesoftware.smackx.disco.ServiceDiscoveryManager)7 DataForm (org.jivesoftware.smackx.xdata.packet.DataForm)7 XmppStringprepException (org.jxmpp.stringprep.XmppStringprepException)7 IQ (org.jivesoftware.smack.packet.IQ)6 Bytestream (org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream)6 FormField (org.jivesoftware.smackx.xdata.FormField)6 XMPPConnection (org.jivesoftware.smack.XMPPConnection)5 ArrayList (java.util.ArrayList)4 ThreadedDummyConnection (org.jivesoftware.smack.ThreadedDummyConnection)4