aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDanny van Heumen <danny@dannyvanheumen.nl>2014-10-25 21:11:29 +0200
committerDanny van Heumen <danny@dannyvanheumen.nl>2014-10-28 22:33:33 +0100
commit61881318325393a5ea78277f059533b9254b2292 (patch)
tree1a840a5ced304c8cd36c67db191583bf8d7289da /test
parent9cf6e262e0ecbd2bb83736e140153cf386efab81 (diff)
downloadjitsi-61881318325393a5ea78277f059533b9254b2292.zip
jitsi-61881318325393a5ea78277f059533b9254b2292.tar.gz
jitsi-61881318325393a5ea78277f059533b9254b2292.tar.bz2
Added support for ISUPPORT CHANLIMIT server parameter.
Diffstat (limited to 'test')
-rw-r--r--test/net/java/sip/communicator/impl/protocol/irc/ISupportTest.java98
1 files changed, 98 insertions, 0 deletions
diff --git a/test/net/java/sip/communicator/impl/protocol/irc/ISupportTest.java b/test/net/java/sip/communicator/impl/protocol/irc/ISupportTest.java
new file mode 100644
index 0000000..14e3359
--- /dev/null
+++ b/test/net/java/sip/communicator/impl/protocol/irc/ISupportTest.java
@@ -0,0 +1,98 @@
+/*
+ * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package net.java.sip.communicator.impl.protocol.irc;
+
+import java.util.*;
+
+import junit.framework.*;
+
+/**
+ * @author Danny van Heumen
+ */
+public class ISupportTest
+ extends TestCase
+{
+ public void testParseNullDestination()
+ {
+ try
+ {
+ ISupport.parseChanLimit(null, "");
+ Assert.fail("Should not reach this, since it should fail on null destination.");
+ }
+ catch (IllegalArgumentException e)
+ {
+ }
+ }
+
+ public void testParseNullValue()
+ {
+ HashMap<Character, Integer> dest = new HashMap<Character, Integer>();
+ ISupport.parseChanLimit(dest, null);
+ Assert.assertEquals(0, dest.size());
+ }
+
+ public void testParseEmptyValue()
+ {
+ Map<Character, Integer> destination = new HashMap<Character, Integer>();
+ ISupport.parseChanLimit(destination, "");
+ Assert.assertEquals(0, destination.size());
+ }
+
+ public void testParseSingleSimpleValidValue()
+ {
+ Map<Character, Integer> destination = new HashMap<Character, Integer>();
+ ISupport.parseChanLimit(destination, "#:10");
+ Assert.assertEquals(1, destination.size());
+ Assert.assertEquals(10, destination.get('#').intValue());
+ }
+
+ public void testParseSingleCombinedValidValue()
+ {
+ Map<Character, Integer> destination = new HashMap<Character, Integer>();
+ ISupport.parseChanLimit(destination, "#&+:25");
+ Assert.assertEquals(3, destination.size());
+ Assert.assertEquals(25, destination.get('#').intValue());
+ Assert.assertEquals(25, destination.get('&').intValue());
+ Assert.assertEquals(25, destination.get('+').intValue());
+ }
+
+ public void testParseMultipleSimpleValidValues()
+ {
+ Map<Character, Integer> destination = new HashMap<Character, Integer>();
+ ISupport.parseChanLimit(destination, "#:10,&:20,+:30");
+ Assert.assertEquals(3, destination.size());
+ Assert.assertEquals(10, destination.get('#').intValue());
+ Assert.assertEquals(20, destination.get('&').intValue());
+ Assert.assertEquals(30, destination.get('+').intValue());
+ }
+
+ public void testParseMultipleSimpleValidValuesWithInvalidStuff()
+ {
+ Map<Character, Integer> destination = new HashMap<Character, Integer>();
+ ISupport.parseChanLimit(destination, "#:10,^:20,jadie:abc,+:30,#:abc");
+ Assert.assertEquals(2, destination.size());
+ Assert.assertEquals(10, destination.get('#').intValue());
+ Assert.assertEquals(30, destination.get('+').intValue());
+ }
+
+ public void testParseMultipleCombinedValidValues()
+ {
+ Map<Character, Integer> destination = new HashMap<Character, Integer>();
+ ISupport.parseChanLimit(destination, "#&:100,+:30");
+ Assert.assertEquals(3, destination.size());
+ Assert.assertEquals(100, destination.get('#').intValue());
+ Assert.assertEquals(100, destination.get('&').intValue());
+ Assert.assertEquals(30, destination.get('+').intValue());
+ }
+
+ public void testParseSimpleInvalidValue()
+ {
+ Map<Character, Integer> destination = new HashMap<Character, Integer>();
+ ISupport.parseChanLimit(destination, "bla");
+ Assert.assertEquals(0, destination.size());
+ }
+}