01: /*
02: * All content copyright (c) 2003-2007 Terracotta, Inc., except as may otherwise be noted in a separate copyright
03: * notice. All rights reserved.
04: */
05: package com.tc.net.groups;
06:
07: import junit.framework.TestCase;
08:
09: public class NodeTest extends TestCase {
10:
11: public void testCtor() {
12: try {
13: new Node(null, 1);
14: fail("expected exception");
15: } catch (IllegalArgumentException e) {
16: // ignore
17: }
18: try {
19: new Node(" ", 1);
20: fail("expected exception");
21: } catch (IllegalArgumentException e) {
22: // ignore
23: }
24: try {
25: new Node("host", -1);
26: fail("expected exception");
27: } catch (IllegalArgumentException e) {
28: // ignore
29: }
30:
31: final String host = "host";
32: final int port = 123;
33: final Node n = new Node(host, port);
34: assertEquals(host, n.getHost());
35: assertEquals(port, n.getPort());
36: }
37:
38: public void testEqualsAndHashCode() {
39: final String host = "host";
40: final int port = 123;
41: final Node n1 = new Node(host, port);
42: final Node n2 = new Node(host, port);
43: assertEquals(n1, n2);
44: assertEquals(n1, new Node(" " + host + " ", port));
45:
46: assertFalse(n1.equals(new Node(host + "1", port)));
47: assertFalse(n1.equals(new Node(host, port + 1)));
48: }
49: }
|