use of org.jivesoftware.smack.packet.IQ in project Smack by igniterealtime.
the class MamFinProviderTest method checkQueryLimitedResults.
@Test
public void checkQueryLimitedResults() throws Exception {
// @formatter:off
final String IQ_LIMITED_RESULTS_EXAMPLE = "<iq type='result' id='u29303'>" + "<fin xmlns='urn:xmpp:mam:1' complete='true'>" + "<set xmlns='http://jabber.org/protocol/rsm'>" + "<first index='0'>23452-4534-1</first>" + "<last>390-2342-22</last>" + "<count>16</count>" + "</set>" + "</fin>" + "</iq>";
// @formatter:on
IQ iq = (IQ) PacketParserUtils.parseStanza(IQ_LIMITED_RESULTS_EXAMPLE);
MamFinIQ mamFinIQ = (MamFinIQ) iq;
Assert.assertEquals(mamFinIQ.getType(), Type.result);
Assert.assertTrue(mamFinIQ.isComplete());
Assert.assertEquals(mamFinIQ.getRSMSet().getCount(), 16);
Assert.assertEquals(mamFinIQ.getRSMSet().getFirst(), "23452-4534-1");
Assert.assertEquals(mamFinIQ.getRSMSet().getFirstIndex(), 0);
Assert.assertEquals(mamFinIQ.getRSMSet().getLast(), "390-2342-22");
}
use of org.jivesoftware.smack.packet.IQ in project Smack by igniterealtime.
the class MamQueryIQProviderTest method checkMamQueryIQProvider.
@Test
public void checkMamQueryIQProvider() throws Exception {
// example 1
IQ iq1 = (IQ) PacketParserUtils.parseStanza(exampleMamQueryIQ1);
MamQueryIQ mamQueryIQ1 = (MamQueryIQ) iq1;
Assert.assertEquals(mamQueryIQ1.getType(), Type.set);
Assert.assertEquals(mamQueryIQ1.getQueryId(), "test");
DataForm dataForm1 = (DataForm) mamQueryIQ1.getExtension(DataForm.NAMESPACE);
Assert.assertEquals(dataForm1.getType(), DataForm.Type.submit);
List<FormField> fields1 = dataForm1.getFields();
Assert.assertEquals(fields1.get(0).getType(), FormField.Type.hidden);
Assert.assertEquals(fields1.get(1).getType(), FormField.Type.text_single);
Assert.assertEquals(fields1.get(1).getValues().get(0), "Where arth thou, my Juliet?");
Assert.assertEquals(fields1.get(2).getValues().get(0), "{http://jabber.org/protocol/mood}mood/lonely");
// example2
IQ iq2 = (IQ) PacketParserUtils.parseStanza(exampleMamQueryIQ2);
MamQueryIQ mamQueryIQ2 = (MamQueryIQ) iq2;
Assert.assertEquals(mamQueryIQ2.getType(), Type.result);
Assert.assertNull(mamQueryIQ2.getQueryId());
DataForm dataForm2 = (DataForm) mamQueryIQ2.getExtension(DataForm.NAMESPACE);
Assert.assertEquals(dataForm2.getType(), DataForm.Type.form);
List<FormField> fields2 = dataForm2.getFields();
Assert.assertEquals(fields2.get(0).getValues().get(0), "urn:xmpp:mam:1");
Assert.assertTrue(fields2.get(0).getValues().size() == 1);
Assert.assertEquals(fields2.get(1).getType(), FormField.Type.jid_single);
Assert.assertEquals(fields2.get(2).getType(), FormField.Type.text_single);
Assert.assertEquals(fields2.get(2).getValues(), new ArrayList<>());
Assert.assertEquals(fields2.get(4).getVariable(), "urn:example:xmpp:free-text-search");
}
use of org.jivesoftware.smack.packet.IQ in project Smack by igniterealtime.
the class HttpOverXmppRespProviderTest method areRespAttributesWothoutMessageCorrectlyParsed.
@Test
public void areRespAttributesWothoutMessageCorrectlyParsed() throws Exception {
String string = "<resp xmlns='urn:xmpp:http' version='1.1' statusCode='200'/>";
HttpOverXmppRespProvider provider = new HttpOverXmppRespProvider();
XmlPullParser parser = PacketParserUtils.getParserFor(string);
IQ iq = provider.parse(parser);
assertTrue(iq instanceof HttpOverXmppResp);
HttpOverXmppResp resp = (HttpOverXmppResp) iq;
assertEquals(resp.getVersion(), "1.1");
assertEquals(resp.getStatusCode(), 200);
assertNull(resp.getStatusMessage());
}
use of org.jivesoftware.smack.packet.IQ in project Smack by igniterealtime.
the class HttpOverXmppRespProviderTest method areAllRespAttributesCorrectlyParsed.
@Test
public void areAllRespAttributesCorrectlyParsed() throws Exception {
String string = "<resp xmlns='urn:xmpp:http' version='1.1' statusCode='200' statusMessage='OK'/>";
HttpOverXmppRespProvider provider = new HttpOverXmppRespProvider();
XmlPullParser parser = PacketParserUtils.getParserFor(string);
IQ iq = provider.parse(parser);
assertTrue(iq instanceof HttpOverXmppResp);
HttpOverXmppResp resp = (HttpOverXmppResp) iq;
assertEquals(resp.getVersion(), "1.1");
assertEquals(resp.getStatusCode(), 200);
assertEquals(resp.getStatusMessage(), "OK");
}
use of org.jivesoftware.smack.packet.IQ in project Smack by igniterealtime.
the class FileTooLargeErrorProviderTest method checkSlotErrorFileToLarge.
@Test
public void checkSlotErrorFileToLarge() throws Exception {
IQ fileTooLargeErrorIQ = PacketParserUtils.parseStanza(slotErrorFileToLarge);
Assert.assertEquals(IQ.Type.error, fileTooLargeErrorIQ.getType());
FileTooLargeError fileTooLargeError = FileTooLargeError.from(fileTooLargeErrorIQ);
Assert.assertEquals(20000, fileTooLargeError.getMaxFileSize());
}
Aggregations