From ed8806f1d7fcf0dd0a4b3586e3db35d4b1175d8d Mon Sep 17 00:00:00 2001 From: Michael Axiak Date: Mon, 9 Sep 2013 20:57:38 -0400 Subject: [PATCH] Allow setStopRow() to work with an empty test table. --- .../scala/org/kiji/testing/fakehtable/FakeHTable.scala | 2 +- .../org/kiji/testing/fakehtable/TestFakeHTable.scala | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/scala/org/kiji/testing/fakehtable/FakeHTable.scala b/src/main/scala/org/kiji/testing/fakehtable/FakeHTable.scala index 4be7bcf..2df8837 100644 --- a/src/main/scala/org/kiji/testing/fakehtable/FakeHTable.scala +++ b/src/main/scala/org/kiji/testing/fakehtable/FakeHTable.scala @@ -845,7 +845,7 @@ class FakeHTable( } } if (!scan.getStopRow.isEmpty - && (BytesComparator.compare(key, scan.getStopRow) >= 0)) { + && (key == null || BytesComparator.compare(key, scan.getStopRow) >= 0)) { key = null } diff --git a/src/test/scala/org/kiji/testing/fakehtable/TestFakeHTable.scala b/src/test/scala/org/kiji/testing/fakehtable/TestFakeHTable.scala index 651abe6..ff1642e 100644 --- a/src/test/scala/org/kiji/testing/fakehtable/TestFakeHTable.scala +++ b/src/test/scala/org/kiji/testing/fakehtable/TestFakeHTable.scala @@ -288,6 +288,14 @@ class TestFakeHTable extends FunSuite { expect(null)(iterator.next()) } + test("ResultScanner with stop key on empty table ") { + val table = new FakeHTable(name = "table", desc = null) + val scanner = table.getScanner(new Scan().setStopRow("stop")) + val iterator = scanner.iterator() + expect(false)(iterator.hasNext()) + expect(null)(iterator.next()) + } + test("ResultScanner.hasNext") { val table = new FakeHTable(name = "table", desc = null) table.put(new Put("key")