From 61881318325393a5ea78277f059533b9254b2292 Mon Sep 17 00:00:00 2001 From: Danny van Heumen Date: Sat, 25 Oct 2014 21:11:29 +0200 Subject: Added support for ISUPPORT CHANLIMIT server parameter. --- .../impl/protocol/irc/ISupportTest.java | 98 ++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 test/net/java/sip/communicator/impl/protocol/irc/ISupportTest.java (limited to 'test') 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 dest = new HashMap(); + ISupport.parseChanLimit(dest, null); + Assert.assertEquals(0, dest.size()); + } + + public void testParseEmptyValue() + { + Map destination = new HashMap(); + ISupport.parseChanLimit(destination, ""); + Assert.assertEquals(0, destination.size()); + } + + public void testParseSingleSimpleValidValue() + { + Map destination = new HashMap(); + ISupport.parseChanLimit(destination, "#:10"); + Assert.assertEquals(1, destination.size()); + Assert.assertEquals(10, destination.get('#').intValue()); + } + + public void testParseSingleCombinedValidValue() + { + Map destination = new HashMap(); + 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 destination = new HashMap(); + 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 destination = new HashMap(); + 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 destination = new HashMap(); + 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 destination = new HashMap(); + ISupport.parseChanLimit(destination, "bla"); + Assert.assertEquals(0, destination.size()); + } +} -- cgit v1.1