diff options
author | Damian Minkov <damencho@jitsi.org> | 2014-02-18 13:14:24 +0200 |
---|---|---|
committer | Damian Minkov <damencho@jitsi.org> | 2014-02-18 13:15:06 +0200 |
commit | 8ef362f0811123acbc8f8404a1eee5fb6862c534 (patch) | |
tree | 056ce08676d9bca7ce7dcea8b9c283d2cdc5653c /test | |
parent | 7959e538273688f36f2ec884025596653cc587e0 (diff) | |
download | jitsi-8ef362f0811123acbc8f8404a1eee5fb6862c534.zip jitsi-8ef362f0811123acbc8f8404a1eee5fb6862c534.tar.gz jitsi-8ef362f0811123acbc8f8404a1eee5fb6862c534.tar.bz2 |
Fixes history corrupting records when they contain utf chars < 0x20, reported on the maiinglist by Danny van Heumen. Adds tests to reproduce this case.
Diffstat (limited to 'test')
-rw-r--r-- | test/net/java/sip/communicator/slick/msghistory/TestMsgHistoryService.java | 48 | ||||
-rw-r--r-- | test/net/java/sip/communicator/slick/msghistory/msghistory.slick.manifest.mf | 2 |
2 files changed, 49 insertions, 1 deletions
diff --git a/test/net/java/sip/communicator/slick/msghistory/TestMsgHistoryService.java b/test/net/java/sip/communicator/slick/msghistory/TestMsgHistoryService.java index 7e8ba1a..6377a68 100644 --- a/test/net/java/sip/communicator/slick/msghistory/TestMsgHistoryService.java +++ b/test/net/java/sip/communicator/slick/msghistory/TestMsgHistoryService.java @@ -11,6 +11,7 @@ import java.util.*; import junit.framework.*; import net.java.sip.communicator.impl.protocol.mock.*; import net.java.sip.communicator.service.contactlist.*; +import net.java.sip.communicator.service.history.*; import net.java.sip.communicator.service.msghistory.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.event.*; @@ -18,6 +19,8 @@ import net.java.sip.communicator.util.*; import org.osgi.framework.*; +import com.google.common.xml.*; + /** * Tests message history. * First installs the MoxkProtocolProvider to be able to send some messages @@ -53,6 +56,8 @@ public class TestMsgHistoryService private static ServiceReference msgHistoryServiceRef = null; public static MessageHistoryService msgHistoryService = null; + public static HistoryService historyService = null; + private static MockContact testContact = null; private static ServiceReference metaCLref = null; @@ -138,6 +143,14 @@ public class TestMsgHistoryService (MessageHistoryService)MsgHistoryServiceLick.bc. getService(msgHistoryServiceRef); + ServiceReference historyServiceRef = + MsgHistoryServiceLick.bc. + getServiceReference(HistoryService.class.getName()); + + historyService = + (HistoryService)MsgHistoryServiceLick.bc. + getService(historyServiceRef); + // fill in a contact to comunicate with MockContactGroup root = (MockContactGroup)mockPresOpSet.getServerStoredContactListRoot(); @@ -180,7 +193,8 @@ public class TestMsgHistoryService mockBImOpSet.createMessage("test message word2" + Math.random()), mockBImOpSet.createMessage("test message word3" + Math.random()), mockBImOpSet.createMessage("test message word4" + Math.random()), - mockBImOpSet.createMessage("test message word5" + Math.random()) + mockBImOpSet.createMessage("test message word5" + Math.random()), + mockBImOpSet.createMessage("Hello \u0002World\u0002!") }; } @@ -380,6 +394,38 @@ public class TestMsgHistoryService msgs.contains(messagesToSend[2].getContent())); } + /** + * Tests some special chars insert and read. + */ + public void specialChars() + { + mockBImOpSet.deliverMessage(TEST_CONTACT_NAME_1, messagesToSend[5]); + + waitWrite(500); + + historyService.purgeLocallyCachedHistories(); + + /** + * Must return exactly the last 3 messages + */ + Collection<EventObject> rs + = msgHistoryService.findLast(testMetaContact, 3); + + assertTrue("Nothing found 8", !rs.isEmpty()); + List<String> msgs = getMessages(rs); + assertEquals("Messages must be 3", 3, msgs.size()); + assertTrue("Message no found", + msgs.contains(messagesToSend[3].getContent())); + assertTrue("Message no found", + msgs.contains(messagesToSend[4].getContent())); + + // For now we are stripping in history the special content chars + // in order to avoid breaking the history records in the xml + assertTrue("Message no found", + msgs.contains(XmlEscapers.xmlContentEscaper().escape( + messagesToSend[5].getContent()))); + } + private static void waitWrite(long timeout) { synchronized (lock) diff --git a/test/net/java/sip/communicator/slick/msghistory/msghistory.slick.manifest.mf b/test/net/java/sip/communicator/slick/msghistory/msghistory.slick.manifest.mf index 4cf11fc..f571a5e 100644 --- a/test/net/java/sip/communicator/slick/msghistory/msghistory.slick.manifest.mf +++ b/test/net/java/sip/communicator/slick/msghistory/msghistory.slick.manifest.mf @@ -13,6 +13,8 @@ Import-Package: junit.framework, net.java.sip.communicator.impl.protocol.mock, net.java.sip.communicator.service.protocol, net.java.sip.communicator.service.protocol.event,org.jitsi.service.protocol.event, + com.google.common.xml, + com.google.common.escape, org.osgi.framework, org.w3c.dom, javax.xml.parsers, |