You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kafka.apache.org by da...@apache.org on 2017/06/23 10:32:53 UTC
kafka git commit: KAFKA-4656;
Improve test coverage of CompositeReadOnlyKeyValueStore
Repository: kafka
Updated Branches:
refs/heads/trunk 2420491f4 -> 26eea1d71
KAFKA-4656; Improve test coverage of CompositeReadOnlyKeyValueStore
Author: Jeyhun Karimov <je...@gmail.com>
Reviewers: Matthias J. Sax <ma...@confluent.io>, Eno Thereska <en...@gmail.com>, Damian Guy <da...@gmail.com>
Closes #3292 from jeyhunkarimov/KAFKA-4656
Project: http://git-wip-us.apache.org/repos/asf/kafka/repo
Commit: http://git-wip-us.apache.org/repos/asf/kafka/commit/26eea1d7
Tree: http://git-wip-us.apache.org/repos/asf/kafka/tree/26eea1d7
Diff: http://git-wip-us.apache.org/repos/asf/kafka/diff/26eea1d7
Branch: refs/heads/trunk
Commit: 26eea1d71e57348284ea00182045c8d943336f4e
Parents: 2420491
Author: Jeyhun Karimov <je...@gmail.com>
Authored: Fri Jun 23 11:32:47 2017 +0100
Committer: Damian Guy <da...@gmail.com>
Committed: Fri Jun 23 11:32:47 2017 +0100
----------------------------------------------------------------------
.../CompositeReadOnlyKeyValueStoreTest.java | 50 ++++++++++++++++++++
1 file changed, 50 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/kafka/blob/26eea1d7/streams/src/test/java/org/apache/kafka/streams/state/internals/CompositeReadOnlyKeyValueStoreTest.java
----------------------------------------------------------------------
diff --git a/streams/src/test/java/org/apache/kafka/streams/state/internals/CompositeReadOnlyKeyValueStoreTest.java b/streams/src/test/java/org/apache/kafka/streams/state/internals/CompositeReadOnlyKeyValueStoreTest.java
index a8ac65f..4054990 100644
--- a/streams/src/test/java/org/apache/kafka/streams/state/internals/CompositeReadOnlyKeyValueStoreTest.java
+++ b/streams/src/test/java/org/apache/kafka/streams/state/internals/CompositeReadOnlyKeyValueStoreTest.java
@@ -18,6 +18,7 @@ package org.apache.kafka.streams.state.internals;
import org.apache.kafka.streams.KeyValue;
import org.apache.kafka.streams.errors.InvalidStateStoreException;
+import org.apache.kafka.streams.state.KeyValueIterator;
import org.apache.kafka.streams.state.KeyValueStore;
import org.apache.kafka.streams.state.QueryableStoreTypes;
import org.apache.kafka.test.NoOpReadOnlyStore;
@@ -28,11 +29,13 @@ import org.junit.Test;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
+import java.util.NoSuchElementException;
import static org.apache.kafka.test.StreamsTestUtils.toList;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
public class CompositeReadOnlyKeyValueStoreTest {
@@ -96,6 +99,49 @@ public class CompositeReadOnlyKeyValueStoreTest {
assertNull(theStore.get("otherKey"));
}
+ @Test
+ public void shouldThrowNoSuchElementExceptionWhileNext() {
+ stubOneUnderlying.put("a", "1");
+ KeyValueIterator<String, String> keyValueIterator = theStore.range("a", "b");
+ keyValueIterator.next();
+ try {
+ keyValueIterator.next();
+ fail("Should have thrown NoSuchElementException with next()");
+ } catch (NoSuchElementException e) { }
+ }
+
+ @Test
+ public void shouldThrowNoSuchElementExceptionWhilePeekNext() {
+ stubOneUnderlying.put("a", "1");
+ KeyValueIterator<String, String> keyValueIterator = theStore.range("a", "b");
+ keyValueIterator.next();
+ try {
+ keyValueIterator.peekNextKey();
+ fail("Should have thrown NoSuchElementException with peekNextKey()");
+ } catch (NoSuchElementException e) { }
+ }
+
+ @Test
+ public void shouldThrowUnsupportedOperationExceptionWhileRemove() {
+ KeyValueIterator<String, String> keyValueIterator = theStore.all();
+ try {
+ keyValueIterator.remove();
+ fail("Should have thrown UnsupportedOperationException");
+ } catch (UnsupportedOperationException e) { }
+ }
+
+ @Test
+ public void shouldThrowUnsupportedOperationExceptionWhileRange() {
+ stubOneUnderlying.put("a", "1");
+ stubOneUnderlying.put("b", "1");
+ KeyValueIterator<String, String> keyValueIterator = theStore.range("a", "b");
+ try {
+ keyValueIterator.remove();
+ fail("Should have thrown UnsupportedOperationException");
+ } catch (UnsupportedOperationException e) { }
+ }
+
+
@SuppressWarnings("unchecked")
@Test
public void shouldFindValueForKeyWhenMultiStores() throws Exception {
@@ -171,6 +217,10 @@ public class CompositeReadOnlyKeyValueStoreTest {
rebalancing().get("anything");
}
+ @Test(expected = InvalidStateStoreException.class)
+ public void shouldThrowInvalidStoreExceptionOnApproximateNumEntriesDuringRebalance() throws Exception {
+ rebalancing().approximateNumEntries();
+ }
@Test(expected = InvalidStateStoreException.class)
public void shouldThrowInvalidStoreExceptionOnRangeDuringRebalance() throws Exception {