@Test
    public void testComplexGenerationExample() throws Exception {
        // formulate the result stanza
        final IQ iq = new IQ(IQ.Type.result);
        iq.setFrom("nurse@capulet.lit/chamber");
        iq.setTo("juliet@capulet.lit");
        iq.setID("simpleexample1");

        final Element query = iq.setChildElement("query",
                "http://jabber.org/protocol/disco#info");
        query.addAttribute("node",
                "http://psi-im.org#q07IKJEyjvHSyhy//CH0CxmKi8w=");

        // Two identities: "client/pc/Psi" and "client/pc/"
        final Element identityA = query.addElement("identity");
        identityA.addAttribute("category", "client");
        identityA.addAttribute("type", "pc");
        identityA.addAttribute("name", "Psi 0.11");
        identityA.addAttribute("xml:lang", "en");

        final Element identityB = query.addElement("identity");
        identityB.addAttribute("category", "client");
        identityB.addAttribute("type", "pc");
        identityB.addAttribute("name", "\u03a8 0.11");
        identityB.addAttribute("xml:lang", "el");

        // the features: "http://jabber.org/protocol/caps",
        // http://jabber.org/protocol/disco#info",
        // "http://jabber.org/protocol/disco#items",
        // "http://jabber.org/protocol/muc".
        query.addElement("feature").addAttribute("var",
                "http://jabber.org/protocol/disco#info");
        query.addElement("feature").addAttribute("var",
                "http://jabber.org/protocol/disco#items");
        query.addElement("feature").addAttribute("var",
                "http://jabber.org/protocol/muc");
        query.addElement("feature").addAttribute("var",
                "http://jabber.org/protocol/caps");

        // extended service discovery forms
        final Element ext = query.addElement(QName.get("x", "jabber:x:data"));
        ext.addAttribute("type", "result");

        final Element formField = ext.addElement("field");
        formField.addAttribute("var", "FORM_TYPE");
        formField.addAttribute("type", "hidden");
        formField.addElement("value")
                .setText("urn:xmpp:dataforms:softwareinfo");

        final Element ipField = ext.addElement("field");
        ipField.addAttribute("var", "ip_version");
        ipField.addElement("value").setText("ipv4");
        ipField.addElement("value").setText("ipv6");

        final Element osField = ext.addElement("field");
        osField.addAttribute("var", "os");
        osField.addElement("value").setText("Mac");

        final Element osvField = ext.addElement("field");
        osvField.addAttribute("var", "os_version");
        osvField.addElement("value").setText("10.5.1");

        final Element softwareField = ext.addElement("field");
        softwareField.addAttribute("var", "software");
        softwareField.addElement("value").setText("Psi");

        final Element softwarevField = ext.addElement("field");
        softwarevField.addAttribute("var", "software_version");
        softwarevField.addElement("value").setText("0.11");

        // Using the SHA-1 algorithm (...)
        final String verification = EntityCapabilitiesManager.generateVerHash(
                iq, "SHA-1");

        // the verification string result must be q07IKJEyjvHSyhy//CH0CxmKi8w=
        assertEquals("q07IKJEyjvHSyhy//CH0CxmKi8w=", verification);
    }
Tests the CAPS verification string generation based on the
"Complex Generation Example" provided in section 5.3 of XEP-0115 (version
1.4 and later).
xmppserver/src/test/java/org/jivesoftware/util/EntityCapabilitiesManagerTest.java