aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDanny van Heumen <danny@dannyvanheumen.nl>2014-08-01 20:42:17 +0200
committerDanny van Heumen <danny@dannyvanheumen.nl>2014-08-01 20:53:17 +0200
commited7b6454e4c33c7b82c8d02c839727a16c2386fe (patch)
treec1f135eceae57dc6c72f970af01769ef76364ae0 /test
parentcc7072ab414864fd90e98c51016783b58da587b1 (diff)
downloadjitsi-ed7b6454e4c33c7b82c8d02c839727a16c2386fe.zip
jitsi-ed7b6454e4c33c7b82c8d02c839727a16c2386fe.tar.gz
jitsi-ed7b6454e4c33c7b82c8d02c839727a16c2386fe.tar.bz2
Escape html entities while parsing the IRC message.
Now escapes html entities during the parsing of the message received from IRC and added a unit test for this requirement. Renamed format* methods to styleAs*, since this is more appropriate.
Diffstat (limited to 'test')
-rw-r--r--test/net/java/sip/communicator/impl/protocol/irc/UtilsTest.java29
1 files changed, 13 insertions, 16 deletions
diff --git a/test/net/java/sip/communicator/impl/protocol/irc/UtilsTest.java b/test/net/java/sip/communicator/impl/protocol/irc/UtilsTest.java
index b38454e..92b6ed8 100644
--- a/test/net/java/sip/communicator/impl/protocol/irc/UtilsTest.java
+++ b/test/net/java/sip/communicator/impl/protocol/irc/UtilsTest.java
@@ -14,16 +14,6 @@ public class UtilsTest
extends TestCase
{
- protected void setUp() throws Exception
- {
- super.setUp();
- }
-
- protected void tearDown() throws Exception
- {
- super.tearDown();
- }
-
public void testNullText()
{
Assert.assertEquals(null, Utils.parseIrcMessage(null));
@@ -183,26 +173,33 @@ public class UtilsTest
final String htmlMessage = "<font color=\"Navy\">With color</font> and without color.";
Assert.assertEquals(htmlMessage, Utils.parseIrcMessage(ircMessage));
}
+
+ public void testMessageContainingHtmlEntities()
+ {
+ final String ircMessage = "\u0002This<b> is very</b> bad &&& text!!!<!-- \u0002<i>";
+ final String parsedMessage = "<b>This&lt;b&gt; is very&lt;/b&gt; bad &amp;&amp;&amp; text!!!&lt;!-- </b>&lt;i&gt;";
+ Assert.assertEquals(parsedMessage, Utils.parseIrcMessage(ircMessage));
+ }
- public void testFormatMessage()
+ public void testStyleAsMessage()
{
String message = "hello world";
- Assert.assertEquals(message, Utils.formatMessage(message));
+ Assert.assertEquals(message, Utils.styleAsMessage(message));
}
- public void testFormatNotice()
+ public void testStyleAsNotice()
{
String message = "hello world";
String nick = "MrNiceGuy";
Assert.assertEquals("<i>MrNiceGuy</i>: hello world",
- Utils.formatNotice(message, nick));
+ Utils.styleAsNotice(message, nick));
}
- public void testFormatAction()
+ public void testStyleAsAction()
{
String message = "is absolutely crazy!";
String nick = "AbsoluteLunatic";
Assert.assertEquals("<b>*AbsoluteLunatic</b> is absolutely crazy!",
- Utils.formatAction(message, nick));
+ Utils.styleAsAction(message, nick));
}
}