public static void areEqual(Iterator expected, Iterator actual) { if (null == expected) { Assert.isNull(actual); return; } Assert.isNotNull(actual); while (expected.hasNext()) { Assert.isTrue(actual.hasNext()); Assert.areEqual(expected.next(), actual.next()); } Assert.isFalse(actual.hasNext()); }
public static void sameContent(Iterator expected, Iterator actual) { final Collection4 allExpected = new Collection4(); while (expected.hasNext()) { allExpected.add(expected.next()); } while (actual.hasNext()) { final Object current = actual.next(); final boolean removed = allExpected.remove(current); if (!removed) { unexpected(current); } } Assert.isTrue(allExpected.isEmpty(), allExpected.toString()); }