use of org.jivesoftware.smackx.mam.MamManager.MamQueryArgs in project Smack by igniterealtime.
the class FiltersTest method checkStartDateFilter.
@Test
public void checkStartDateFilter() throws Exception {
Date date = new Date();
MamQueryArgs mamQueryArgs = MamQueryArgs.builder().limitResultsSince(date).build();
DataForm dataForm = mamQueryArgs.getDataForm(MamVersion.MAM2);
List<String> fields = new ArrayList<>();
fields.add("start");
List<String> values = new ArrayList<>();
values.add(XmppDateTime.formatXEP0082Date(date));
assertEquals(getMamXMemberWith(fields, values), dataForm.toXML().toString());
}
use of org.jivesoftware.smackx.mam.MamManager.MamQueryArgs in project Smack by igniterealtime.
the class MamIntegrationTest method mamTest.
@SmackIntegrationTest
public void mamTest() throws TimeoutException, Exception {
EntityBareJid userOne = conOne.getUser().asEntityBareJid();
EntityBareJid userTwo = conTwo.getUser().asEntityBareJid();
final String messageBody = "Test MAM message (" + testRunId + ')';
Message message = conTwo.getStanzaFactory().buildMessageStanza().to(userTwo).setBody(messageBody).build();
final String messageId = message.getStanzaId();
final SimpleResultSyncPoint messageReceived = new SimpleResultSyncPoint();
final StanzaListener stanzaListener = new StanzaListener() {
@Override
public void processStanza(Stanza stanza) {
Message message = (Message) stanza;
if (message.getBody().equals(messageBody)) {
messageReceived.signal();
}
}
};
conTwo.addAsyncStanzaListener(stanzaListener, MessageWithBodiesFilter.INSTANCE);
try {
conOne.sendStanza(message);
messageReceived.waitForResult(timeout);
} finally {
conTwo.removeAsyncStanzaListener(stanzaListener);
}
MamQueryArgs mamQueryArgs = MamQueryArgs.builder().setResultPageSizeTo(1).limitResultsToJid(userOne).queryLastPage().build();
MamQuery mamQuery = mamManagerConTwo.queryArchive(mamQueryArgs);
assertEquals(1, mamQuery.getMessages().size());
Message mamMessage = mamQuery.getMessages().get(0);
assertEquals(messageId, mamMessage.getStanzaId());
assertEquals(messageBody, mamMessage.getBody());
assertEquals(conOne.getUser(), mamMessage.getFrom());
assertEquals(userTwo, mamMessage.getTo());
}
Aggregations