aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDanny van Heumen <danny@dannyvanheumen.nl>2014-08-12 19:42:50 +0200
committerDanny van Heumen <danny@dannyvanheumen.nl>2014-08-12 19:42:50 +0200
commit7a1ef1a22810a69cf60f53ecedcb4e70a68a7481 (patch)
tree083221cdd13a3d1d2bf624f28208191184e2c81e /test
parenteb8fe613fce57f7728dd2d8e030e2a786371b539 (diff)
downloadjitsi-7a1ef1a22810a69cf60f53ecedcb4e70a68a7481.zip
jitsi-7a1ef1a22810a69cf60f53ecedcb4e70a68a7481.tar.gz
jitsi-7a1ef1a22810a69cf60f53ecedcb4e70a68a7481.tar.bz2
Added tests for IrcAccountID and fine tuned equals implementation.
Diffstat (limited to 'test')
-rw-r--r--test/net/java/sip/communicator/impl/protocol/irc/IrcAccountIDTest.java126
1 files changed, 126 insertions, 0 deletions
diff --git a/test/net/java/sip/communicator/impl/protocol/irc/IrcAccountIDTest.java b/test/net/java/sip/communicator/impl/protocol/irc/IrcAccountIDTest.java
new file mode 100644
index 0000000..5849ace
--- /dev/null
+++ b/test/net/java/sip/communicator/impl/protocol/irc/IrcAccountIDTest.java
@@ -0,0 +1,126 @@
+package net.java.sip.communicator.impl.protocol.irc;
+
+import java.util.*;
+
+import junit.framework.*;
+import net.java.sip.communicator.service.protocol.*;
+
+public class IrcAccountIDTest
+ extends TestCase
+{
+
+ //@Test(expected = IllegalArgumentException.class)
+ public void testConstructNullHost()
+ {
+ HashMap<String, String> properties = new HashMap<String, String>();
+ properties.put(ProtocolProviderFactory.PROTOCOL, ProtocolNames.IRC);
+ try
+ {
+ IrcAccountID account =
+ new IrcAccountID("user", null, "6667", properties);
+ Assert.fail("Should have failed with IAE.");
+ }
+ catch (IllegalArgumentException e)
+ {
+ // this works as expected
+ }
+ }
+
+ //@Test(expected = IllegalArgumentException.class)
+ public void testConstructNullPort()
+ {
+ HashMap<String, String> properties = new HashMap<String, String>();
+ properties.put(ProtocolProviderFactory.PROTOCOL, ProtocolNames.IRC);
+ try
+ {
+ IrcAccountID account =
+ new IrcAccountID("user", "host", null, properties);
+ Assert.fail("Should have failed with IAE.");
+ }
+ catch (IllegalArgumentException e)
+ {
+ // this works as expected
+ }
+ }
+
+ public void testCorrectConstruction()
+ {
+ HashMap<String, String> properties = new HashMap<String, String>();
+ properties.put(ProtocolProviderFactory.PROTOCOL, ProtocolNames.IRC);
+ IrcAccountID account =
+ new IrcAccountID("user", "host", "6667", properties);
+ Assert.assertEquals("user", account.getUserID());
+ Assert.assertEquals("host", account.getHost());
+ Assert.assertEquals(6667, account.getPort());
+ }
+
+ public void testEqualsSame()
+ {
+ HashMap<String, String> properties = new HashMap<String, String>();
+ properties.put(ProtocolProviderFactory.PROTOCOL, ProtocolNames.IRC);
+ IrcAccountID account =
+ new IrcAccountID("user", "host", "6667", properties);
+ Assert.assertTrue(account.equals(account));
+ }
+
+ public void testEqualsNull()
+ {
+ HashMap<String, String> properties = new HashMap<String, String>();
+ properties.put(ProtocolProviderFactory.PROTOCOL, ProtocolNames.IRC);
+ IrcAccountID account =
+ new IrcAccountID("user", "host", "6667", properties);
+ Assert.assertFalse(account.equals(null));
+ }
+
+ public void testEqualsOtherClassInstance()
+ {
+ HashMap<String, String> properties = new HashMap<String, String>();
+ properties.put(ProtocolProviderFactory.PROTOCOL, ProtocolNames.IRC);
+ IrcAccountID account =
+ new IrcAccountID("user", "host", "6667", properties);
+ Assert.assertFalse(account.equals(new Object()));
+ }
+
+ public void testEqualsOtherUser()
+ {
+ HashMap<String, String> properties = new HashMap<String, String>();
+ properties.put(ProtocolProviderFactory.PROTOCOL, ProtocolNames.IRC);
+ IrcAccountID account =
+ new IrcAccountID("user", "host", "6667", properties);
+ IrcAccountID account2 =
+ new IrcAccountID("other-user", "host", "6667", properties);
+ Assert.assertFalse(account.equals(account2));
+ }
+
+ public void testEqualsOtherHost()
+ {
+ HashMap<String, String> properties = new HashMap<String, String>();
+ properties.put(ProtocolProviderFactory.PROTOCOL, ProtocolNames.IRC);
+ IrcAccountID account =
+ new IrcAccountID("user", "host", "6667", properties);
+ IrcAccountID account2 =
+ new IrcAccountID("user", "other-host", "6667", properties);
+ Assert.assertFalse(account.equals(account2));
+ }
+
+ public void testEqualsOtherPort()
+ {
+ HashMap<String, String> properties = new HashMap<String, String>();
+ properties.put(ProtocolProviderFactory.PROTOCOL, ProtocolNames.IRC);
+ IrcAccountID account =
+ new IrcAccountID("user", "host", "6667", properties);
+ IrcAccountID account2 =
+ new IrcAccountID("user", "host", "6697", properties);
+ Assert.assertFalse(account.equals(account2));
+ }
+
+ public void testHashCodeExecutes()
+ {
+ HashMap<String, String> properties = new HashMap<String, String>();
+ properties.put(ProtocolProviderFactory.PROTOCOL, ProtocolNames.IRC);
+ IrcAccountID account =
+ new IrcAccountID("user", "host", "6667", properties);
+ // only test that it does not throw an exception
+ account.hashCode();
+ }
+}