1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-12-24 03:27:59 +01:00

Update Message Archive Management (XEP-0313) support to urn:xmpp:mam:2

Fixes SMACK-890.
This commit is contained in:
Florian Schmaus 2020-05-24 12:26:36 +02:00
parent a51663448b
commit f045c0dd08
9 changed files with 25 additions and 25 deletions

View file

@ -1,6 +1,6 @@
/**
*
* Copyright © 2016 Florian Schmaus and Fernando Ramirez
* Copyright © 2016-2020 Florian Schmaus and Fernando Ramirez
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -38,7 +38,7 @@ import org.jxmpp.jid.Jid;
*/
public class MamElements {
public static final String NAMESPACE = "urn:xmpp:mam:1";
public static final String NAMESPACE = "urn:xmpp:mam:2";
/**
* MAM result extension class.

View file

@ -17,22 +17,22 @@
<!-- XEP-0313: Message Archive Management -->
<iqProvider>
<elementName>prefs</elementName>
<namespace>urn:xmpp:mam:1</namespace>
<namespace>urn:xmpp:mam:2</namespace>
<className>org.jivesoftware.smackx.mam.provider.MamPrefsIQProvider</className>
</iqProvider>
<iqProvider>
<elementName>query</elementName>
<namespace>urn:xmpp:mam:1</namespace>
<namespace>urn:xmpp:mam:2</namespace>
<className>org.jivesoftware.smackx.mam.provider.MamQueryIQProvider</className>
</iqProvider>
<iqProvider>
<elementName>fin</elementName>
<namespace>urn:xmpp:mam:1</namespace>
<namespace>urn:xmpp:mam:2</namespace>
<className>org.jivesoftware.smackx.mam.provider.MamFinIQProvider</className>
</iqProvider>
<extensionProvider>
<elementName>result</elementName>
<namespace>urn:xmpp:mam:1</namespace>
<namespace>urn:xmpp:mam:2</namespace>
<className>org.jivesoftware.smackx.mam.provider.MamResultProvider</className>
</extensionProvider>

View file

@ -34,7 +34,7 @@ import org.junit.jupiter.api.Test;
public class MamFinProviderTest extends MamTest {
static final String exmapleMamFinXml = "<fin xmlns='urn:xmpp:mam:1' stable='true'>"
static final String exmapleMamFinXml = "<fin xmlns='urn:xmpp:mam:2' stable='true'>"
+ "<set xmlns='http://jabber.org/protocol/rsm'>" + "<max>10</max>" + "<after>09af3-cc343-b409f</after>"
+ "</set>" + "</fin>";
@ -56,7 +56,7 @@ public class MamFinProviderTest extends MamTest {
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'>"
+ "<fin xmlns='urn:xmpp:mam:2' complete='true'>"
+ "<set xmlns='http://jabber.org/protocol/rsm'>"
+ "<first index='0'>23452-4534-1</first>"
+ "<last>390-2342-22</last>" + "<count>16</count>"

View file

@ -33,19 +33,19 @@ import org.jxmpp.jid.Jid;
public class MamPrefIQProviderTest extends MamTest {
private static final String exampleMamPrefsIQ1 = "<iq type='set' id='juliet3'>" + "<prefs xmlns='urn:xmpp:mam:1' default='roster'>"
private static final String exampleMamPrefsIQ1 = "<iq type='set' id='juliet3'>" + "<prefs xmlns='urn:xmpp:mam:2' default='roster'>"
+ "<always>" + "<jid>romeo@montague.lit</jid>" + "</always>" + "<never>"
+ "<jid>montague@montague.lit</jid>" + "</never>" + "</prefs>" + "</iq>";
private static final String exampleMamPrefsIQ2 = "<iq type='set' id='juliet3'>" + "<prefs xmlns='urn:xmpp:mam:1' default='roster'>"
private static final String exampleMamPrefsIQ2 = "<iq type='set' id='juliet3'>" + "<prefs xmlns='urn:xmpp:mam:2' default='roster'>"
+ "<always>" + "<jid>romeo@montague.lit</jid>" + "<jid>montague@montague.lit</jid>" + "</always>"
+ "<never>" + "</never>" + "</prefs>" + "</iq>";
private static final String exampleMamPrefsIQ3 = "<iq type='get' id='juliet3'>" + "<prefs xmlns='urn:xmpp:mam:1'>" + "</prefs>"
private static final String exampleMamPrefsIQ3 = "<iq type='get' id='juliet3'>" + "<prefs xmlns='urn:xmpp:mam:2'>" + "</prefs>"
+ "</iq>";
private static final String exampleMamPrefsResultIQ = "<iq type='result' id='juliet3'>"
+ "<prefs xmlns='urn:xmpp:mam:1' default='roster'>" + "<always>" + "<jid>romeo@montague.lit</jid>"
+ "<prefs xmlns='urn:xmpp:mam:2' default='roster'>" + "<always>" + "<jid>romeo@montague.lit</jid>"
+ "</always>" + "<never>" + "<jid>sarasa@montague.lit</jid>" + "<jid>montague@montague.lit</jid>"
+ "</never>" + "</prefs>" + "</iq>";

View file

@ -35,18 +35,18 @@ import org.junit.jupiter.api.Test;
public class MamQueryIQProviderTest {
private static final String exampleMamQueryIQ1 = "<iq type='set' id='query4'>" + "<query xmlns='urn:xmpp:mam:1' queryid='test'>"
private static final String exampleMamQueryIQ1 = "<iq type='set' id='query4'>" + "<query xmlns='urn:xmpp:mam:2' queryid='test'>"
+ "<x xmlns='jabber:x:data' type='submit'>" + "<field type='hidden' var='FORM_TYPE'>"
+ "<value>urn:xmpp:mam:1</value>" + "</field>"
+ "<value>urn:xmpp:mam:2</value>" + "</field>"
+ "<field type='text-single' var='urn:example:xmpp:free-text-search'>"
+ "<value>Where arth thou, my Juliet?</value>" + "</field>"
+ "<field type='text-single' var='urn:example:xmpp:stanza-content'>"
+ "<value>{http://jabber.org/protocol/mood}mood/lonely</value>" + "</field>" + "</x>" + "</query>"
+ "</iq>";
private static final String exampleMamQueryIQ2 = "<iq type='result' id='form1'>" + "<query xmlns='urn:xmpp:mam:1'>"
private static final String exampleMamQueryIQ2 = "<iq type='result' id='form1'>" + "<query xmlns='urn:xmpp:mam:2'>"
+ "<x xmlns='jabber:x:data' type='form'>" + "<field type='hidden' var='FORM_TYPE'>"
+ "<value>urn:xmpp:mam:1</value>" + "</field>" + "<field type='jid-single' var='with'/>"
+ "<value>urn:xmpp:mam:2</value>" + "</field>" + "<field type='jid-single' var='with'/>"
+ "<field type='text-single' var='start'/>" + "<field type='text-single' var='end'/>"
+ "<field type='text-single' var='urn:example:xmpp:free-text-search'/>"
+ "<field type='text-single' var='urn:example:xmpp:stanza-content'/>" + "</x>" + "</query>" + "</iq>";
@ -80,7 +80,7 @@ public class MamQueryIQProviderTest {
assertEquals(dataForm2.getType(), DataForm.Type.form);
List<FormField> fields2 = dataForm2.getFields();
assertEquals(fields2.get(0).getValues().get(0).toString(), "urn:xmpp:mam:1");
assertEquals(fields2.get(0).getValues().get(0).toString(), "urn:xmpp:mam:2");
assertTrue(fields2.get(0).getValues().size() == 1);
assertEquals(fields2.get(1).getType(), FormField.Type.jid_single);
assertEquals(fields2.get(2).getType(), FormField.Type.text_single);

View file

@ -34,7 +34,7 @@ import org.junit.jupiter.api.Test;
public class MamResultProviderTest {
private static final String exampleMamResultXml = "<result xmlns='urn:xmpp:mam:1' queryid='f27' id='28482-98726-73623'>"
private static final String exampleMamResultXml = "<result xmlns='urn:xmpp:mam:2' queryid='f27' id='28482-98726-73623'>"
+ "<forwarded xmlns='urn:xmpp:forward:0'>" + "<delay xmlns='urn:xmpp:delay' stamp='2010-07-10T23:08:25Z'/>"
+ "<message xmlns='jabber:client' to='juliet@capulet.lit/balcony' from='romeo@montague.lit/orchard' "
+ "type='chat'>"
@ -42,7 +42,7 @@ public class MamResultProviderTest {
+ "</message>" + "</forwarded>" + "</result>";
private static final String exampleResultMessage = "<message id='aeb213' to='juliet@capulet.lit/chamber'>"
+ "<result xmlns='urn:xmpp:mam:1' queryid='f27' id='28482-98726-73623'>"
+ "<result xmlns='urn:xmpp:mam:2' queryid='f27' id='28482-98726-73623'>"
+ "<forwarded xmlns='urn:xmpp:forward:0'>" + "<delay xmlns='urn:xmpp:delay' stamp='2010-07-10T23:08:25Z'/>"
+ "<message xmlns='jabber:client' from='witch@shakespeare.lit' to='macbeth@shakespeare.lit'>"
+ "<body>Hail to thee</body>" + "</message>" + "</forwarded>" + "</result>" + "</message>";

View file

@ -29,9 +29,9 @@ import org.junit.jupiter.api.Test;
public class PagingTest extends MamTest {
private static final String pagingStanza = "<iq id='sarasa' type='set'>" + "<query xmlns='urn:xmpp:mam:1' queryid='testid'>"
private static final String pagingStanza = "<iq id='sarasa' type='set'>" + "<query xmlns='urn:xmpp:mam:2' queryid='testid'>"
+ "<x xmlns='jabber:x:data' type='submit'>" + "<field var='FORM_TYPE'>"
+ "<value>urn:xmpp:mam:1</value>" + "</field>" + "</x>" + "<set xmlns='http://jabber.org/protocol/rsm'>"
+ "<value>urn:xmpp:mam:2</value>" + "</field>" + "</x>" + "<set xmlns='http://jabber.org/protocol/rsm'>"
+ "<max>10</max>" + "</set>" + "</query>" + "</iq>";
@Test
@ -46,7 +46,7 @@ public class PagingTest extends MamTest {
mamQueryIQ.addExtension(rsmSet);
assertEquals(mamQueryIQ.getDataForm(), dataForm);
assertEquals(mamQueryIQ.getDataForm().getFields().get(0).getValues().get(0).toString(), "urn:xmpp:mam:1");
assertEquals(mamQueryIQ.getDataForm().getFields().get(0).getValues().get(0).toString(), "urn:xmpp:mam:2");
assertEquals(pagingStanza, mamQueryIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
}

View file

@ -40,12 +40,12 @@ import org.jxmpp.jid.impl.JidCreate;
public class QueryArchiveTest extends MamTest {
private static final String mamSimpleQueryIQ = "<iq id='sarasa' type='set'>" + "<query xmlns='urn:xmpp:mam:1' queryid='testid'>"
private static final String mamSimpleQueryIQ = "<iq id='sarasa' type='set'>" + "<query xmlns='urn:xmpp:mam:2' queryid='testid'>"
+ "<x xmlns='jabber:x:data' type='submit'>" + "<field var='FORM_TYPE'>" + "<value>"
+ MamElements.NAMESPACE + "</value>" + "</field>" + "</x>" + "</query>" + "</iq>";
private static final String mamQueryResultExample = "<message to='hag66@shakespeare.lit/pda' from='coven@chat.shakespeare.lit' id='iasd207'>"
+ "<result xmlns='urn:xmpp:mam:1' queryid='g27' id='34482-21985-73620'>"
+ "<result xmlns='urn:xmpp:mam:2' queryid='g27' id='34482-21985-73620'>"
+ "<forwarded xmlns='urn:xmpp:forward:0'>"
+ "<delay xmlns='urn:xmpp:delay' stamp='2002-10-13T23:58:37.000+00:00'/>" + "<message "
+ "xmlns='jabber:client' from='coven@chat.shakespeare.lit/firstwitch' " + "id='162BEBB1-F6DB-4D9A-9BD8-CFDCC801A0B2' "

View file

@ -30,7 +30,7 @@ import org.junit.jupiter.api.Test;
public class ResultsLimitTest extends MamTest {
private static final String resultsLimitStanza = "<iq id='sarasa' type='set'>" + "<query xmlns='urn:xmpp:mam:1' queryid='testid'>"
private static final String resultsLimitStanza = "<iq id='sarasa' type='set'>" + "<query xmlns='urn:xmpp:mam:2' queryid='testid'>"
+ "<x xmlns='jabber:x:data' type='submit'>" + "<field var='FORM_TYPE'>" + "<value>"
+ MamElements.NAMESPACE + "</value>" + "</field>" + "</x>" + "<set xmlns='http://jabber.org/protocol/rsm'>"
+ "<max>10</max>" + "</set>" + "</query>" + "</iq>";