/** * Returns the text of the XHTMLText. * * @return the text of the XHTMLText */ @Override public String toString() { return text.toString(); }
@Override public boolean equals(Object other) { if (!(other instanceof CharSequence)) { return false; } CharSequence otherCharSequenceBuilder = (CharSequence) other; return toString().equals(otherCharSequenceBuilder.toString()); }
@Override public String toString() { return toXML().toString(); } }
@Override public int hashCode() { return this.toXML(null).toString().hashCode(); } }
@Test public void checkUpdatePrefsStanza() throws Exception { List<Jid> alwaysJids = new ArrayList<>(); alwaysJids.add(JidCreate.from("romeo@montague.lit")); alwaysJids.add(JidCreate.from("other@montague.lit")); List<Jid> neverJids = new ArrayList<>(); neverJids.add(JidCreate.from("montague@montague.lit")); MamPrefsIQ mamPrefIQ = new MamPrefsIQ(alwaysJids, neverJids, DefaultBehavior.roster); mamPrefIQ.setStanzaId("sarasa"); Assert.assertEquals(mamPrefIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString(), updatePrefsStanzaExample); }
@Test public void checkBlockContactIQStanza() throws Exception { List<Jid> jids = new ArrayList<>(); jids.add(JidCreate.from("romeo@montague.net")); jids.add(JidCreate.from("pepe@montague.net")); BlockContactsIQ blockContactIQ = new BlockContactsIQ(jids); blockContactIQ.setStanzaId("block1"); Assert.assertEquals(blockContactIQExample, blockContactIQ.toXML(null).toString()); }
@Test public void tieBreakTest() throws Exception { String xml = "<tie-break xmlns='urn:xmpp:jingle:errors:1'/>"; JingleError error = new JingleErrorProvider().parse(TestUtils.getParser(xml)); assertEquals(xml, error.toXML(null).toString()); }
@Test public void checkStanzas() throws Exception { Message initialMessage = PacketParserUtils.parseStanza(initialMessageXml); MessageCorrectExtension messageCorrectExtension = new MessageCorrectExtension(idInitialMessage); Assert.assertEquals(messageCorrectExtension.toXML(null).toString(), messageCorrectionXml.toString()); initialMessage.addExtension(messageCorrectExtension); Assert.assertEquals(initialMessage.toXML(null), expectedXml.toString()); }
@Test public void checkBlockRoomsIQ() throws Exception { HashMap<Jid, Boolean> rooms = new HashMap<>(); rooms.put(JidCreate.from("coven@muclight.shakespeare.lit"), false); rooms.put(JidCreate.from("chapel@shakespeare.lit"), false); MUCLightBlockingIQ mucLightBlockingIQ = new MUCLightBlockingIQ(rooms, null); mucLightBlockingIQ.setType(Type.set); mucLightBlockingIQ.setTo(JidCreate.from("muclight.shakespeare.lit")); mucLightBlockingIQ.setStanzaId("block1"); Assert.assertEquals(blockingRoomsIQExample, mucLightBlockingIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString()); }
@Test public void checkUnblockAllIQStanza() throws Exception { UnblockContactsIQ unblockAllIQ = new UnblockContactsIQ(null); unblockAllIQ.setStanzaId("unblock2"); Assert.assertEquals(unblockAllIQExample, unblockAllIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString()); }
@Test public void checkRetrieveFormFieldsStanza() throws Exception { MamQueryIQ mamQueryIQ = new MamQueryIQ(queryId); mamQueryIQ.setStanzaId("sarasa"); assertEquals(retrieveFormFieldStanza, mamQueryIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString()); }
@Test public void providerTest() throws Exception { String expected = "<openpgp xmlns='urn:xmpp:openpgp:0'>" + "BASE64_OPENPGP_MESSAGE" + "</openpgp>"; OpenPgpElement element = new OpenPgpElement("BASE64_OPENPGP_MESSAGE"); assertXMLEqual(expected, element.toXML(null).toString()); XmlPullParser parser = TestUtils.getParser(expected); OpenPgpElement parsed = OpenPgpElementProvider.TEST_INSTANCE.parse(parser); assertEquals(element.getEncryptedBase64MessageContent(), parsed.getEncryptedBase64MessageContent()); }
@Test public void checkGetBlockingListIQStanza() throws Exception { BlockListIQ getBlockListIQ = new BlockListIQ(null); getBlockListIQ.setType(Type.get); getBlockListIQ.setStanzaId("blocklist1"); Assert.assertEquals(getBlockingListIQExample, getBlockListIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString()); }
@Test public void checkGetConfigsIQ() throws Exception { MUCLightGetConfigsIQ mucLightGetConfigsIQ = new MUCLightGetConfigsIQ( JidCreate.from("coven@muclight.shakespeare.lit"), "abcdefg"); mucLightGetConfigsIQ.setStanzaId("config0"); Assert.assertEquals(getConfigsIQExample, mucLightGetConfigsIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString()); }
@Test public void checkGetAffiliationsIQ() throws Exception { MUCLightGetAffiliationsIQ mucLightGetAffiliationsIQ = new MUCLightGetAffiliationsIQ( JidCreate.from("coven@muclight.shakespeare.lit"), "abcdefg"); mucLightGetAffiliationsIQ.setStanzaId("getmembers"); Assert.assertEquals(getAffiliationsIQExample, mucLightGetAffiliationsIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString()); }
@Test public void checkDestroyMUCLightStanza() throws Exception { MUCLightDestroyIQ mucLightDestroyIQ = new MUCLightDestroyIQ(JidCreate.from("coven@muclight.shakespeare.lit")); mucLightDestroyIQ.setStanzaId("destroy1"); Assert.assertEquals(mucLightDestroyIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString(), stanza); }
@Test public void validatePresenceProbe() throws Exception { // CHECKSTYLE:OFF String stanza = "<presence from='mercutio@example.com' id='xv291f38' to='juliet@example.com' type='unsubscribed'/>"; Presence presence = PacketParserUtils.parsePresence(PacketParserUtils.getParserFor(stanza)); assertXMLEqual(stanza, presence.toXML(StreamOpen.CLIENT_NAMESPACE).toString()); assertEquals(Presence.Type.unsubscribed, presence.getType()); // CHECKSTYLE:ON }
@Test public void checkReceivedExtension() throws Exception { Message message = new Message(JidCreate.from("northumberland@shakespeare.lit/westminster")); message.setStanzaId("message-2"); message.addExtension(new ChatMarkersElements.ReceivedExtension("message-1")); Assert.assertEquals(receivedMessageStanza, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString()); }
@Test public void checkSlotRequestCreation() throws SAXException, IOException { SlotRequest slotRequest = new SlotRequest(JidTestUtil.DOMAIN_BARE_JID_1, "my_juliet.png", 23456, "image/jpeg"); Assert.assertEquals("my_juliet.png", slotRequest.getFilename()); Assert.assertEquals(23456, slotRequest.getSize()); Assert.assertEquals("image/jpeg", slotRequest.getContentType()); assertXMLEqual(testRequest, slotRequest.getChildElementXML().toString()); }
@Test public void checkResultsLimit() throws Exception { DataForm dataForm = getNewMamForm(); MamQueryIQ mamQueryIQ = new MamQueryIQ(queryId, dataForm); mamQueryIQ.setType(IQ.Type.set); mamQueryIQ.setStanzaId("sarasa"); MamQueryArgs mamQueryArgs = MamQueryArgs.builder().setResultPageSize(10).build(); mamQueryArgs.maybeAddRsmSet(mamQueryIQ); Assert.assertEquals(mamQueryIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString(), resultsLimitStanza); }