From ab2d2219d1bff13a4200fbfb8122a89219abda46 Mon Sep 17 00:00:00 2001 From: Zhangmei Li Date: Sun, 29 Dec 2019 23:42:41 +0800 Subject: [PATCH] fix ExtendableIteratorTest.testCloseAfterNext() Change-Id: I1add942c011cfc1b6faf998d94901fc2d8723169 --- .../unit/iterator/ExtendableIteratorTest.java | 29 +++++++++++++++++-- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/src/test/java/com/baidu/hugegraph/unit/iterator/ExtendableIteratorTest.java b/src/test/java/com/baidu/hugegraph/unit/iterator/ExtendableIteratorTest.java index 1a9a635b5..4c7ba31b8 100644 --- a/src/test/java/com/baidu/hugegraph/unit/iterator/ExtendableIteratorTest.java +++ b/src/test/java/com/baidu/hugegraph/unit/iterator/ExtendableIteratorTest.java @@ -175,7 +175,30 @@ public void testClose() throws Exception { } @Test - public void testCloseAfterNext() throws Exception { + public void testCloseAfterNext1() throws Exception { + CloseableItor c1 = new CloseableItor<>(DATA1.iterator()); + CloseableItor c2 = new CloseableItor<>(DATA2.iterator()); + CloseableItor c3 = new CloseableItor<>(DATA3.iterator()); + + ExtendableIterator results = new ExtendableIterator<>(); + results.extend(c1).extend(c2).extend(c3); + + results.next(); + results.hasNext(); + + Assert.assertTrue(c1.closed()); // close after iterated + Assert.assertFalse(c2.closed()); + Assert.assertFalse(c3.closed()); + + results.close(); + + Assert.assertTrue(c1.closed()); + Assert.assertTrue(c2.closed()); + Assert.assertTrue(c3.closed()); + } + + @Test + public void testCloseAfterNext3() throws Exception { CloseableItor c1 = new CloseableItor<>(DATA1.iterator()); CloseableItor c2 = new CloseableItor<>(DATA2.iterator()); CloseableItor c3 = new CloseableItor<>(DATA3.iterator()); @@ -191,8 +214,8 @@ public void testCloseAfterNext() throws Exception { results.next(); } - Assert.assertFalse(c1.closed()); - Assert.assertFalse(c2.closed()); + Assert.assertTrue(c1.closed()); + Assert.assertTrue(c2.closed()); Assert.assertFalse(c3.closed()); results.close();