01: /*
02: * All content copyright (c) 2003-2007 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.tc.net.core;
05:
06: import junit.framework.TestCase;
07:
08: public class ConnectionAddressIteratorTest extends TestCase {
09:
10: public final void testEmpty() {
11: ConnectionAddressIterator i = new ConnectionAddressIterator(
12: new ConnectionInfo[0]);
13: assertFalse(i.hasNext());
14: assertNull(i.next());
15: }
16:
17: public final void testOne() {
18: final ConnectionInfo[] cis = new ConnectionInfo[] { new ConnectionInfo(
19: "1", 1) };
20: ConnectionAddressIterator i = new ConnectionAddressIterator(cis);
21: assertTrue(i.hasNext());
22: assertTrue(i.hasNext()); // multi calls to hasNext should not change state
23: assertSame(cis[0], i.next());
24: assertFalse(i.hasNext());
25: assertFalse(i.hasNext());
26: assertNull(i.next());
27: }
28:
29: public final void testMany() {
30: final ConnectionInfo[] cis = new ConnectionInfo[] {
31: new ConnectionInfo("1", 1), new ConnectionInfo("2", 2),
32: new ConnectionInfo("3", 3) };
33: ConnectionAddressIterator iter = new ConnectionAddressIterator(
34: cis);
35: for (int i = 0; i < cis.length; i++) {
36: assertTrue(iter.hasNext());
37: assertSame(cis[i], iter.next());
38: }
39: assertFalse(iter.hasNext());
40: assertNull(iter.next());
41: }
42: }
|