storm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ptgo...@apache.org
Subject [11/50] [abbrv] git commit: added OFFSET_METADATA_TOO_LARGE error
Date Mon, 21 Apr 2014 19:44:10 GMT
added OFFSET_METADATA_TOO_LARGE error


Project: http://git-wip-us.apache.org/repos/asf/incubator-storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-storm/commit/80005ba3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-storm/tree/80005ba3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-storm/diff/80005ba3

Branch: refs/heads/master
Commit: 80005ba3916e2a05c82649dd67f11b0f813c41b6
Parents: 95c60db
Author: wurstmeister <wurstmeister@users.noreply.github.com>
Authored: Sun Jan 12 18:21:56 2014 +0000
Committer: wurstmeister <wurstmeister@users.noreply.github.com>
Committed: Sun Jan 12 18:24:37 2014 +0000

----------------------------------------------------------------------
 src/jvm/storm/kafka/KafkaError.java      |  5 ++--
 src/test/storm/kafka/KafkaErrorTest.java | 39 +++++++++++++++++++++++++++
 2 files changed, 42 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-storm/blob/80005ba3/src/jvm/storm/kafka/KafkaError.java
----------------------------------------------------------------------
diff --git a/src/jvm/storm/kafka/KafkaError.java b/src/jvm/storm/kafka/KafkaError.java
index 260ab91..a67335c 100644
--- a/src/jvm/storm/kafka/KafkaError.java
+++ b/src/jvm/storm/kafka/KafkaError.java
@@ -17,10 +17,11 @@ public enum KafkaError {
     REPLICA_NOT_AVAILABLE,
     MESSAGE_SIZE_TOO_LARGE,
     STALE_CONTROLLER_EPOCH,
+    OFFSET_METADATA_TOO_LARGE,
     UNKNOWN;
 
-    public static KafkaError getError(short errorCode) {
-        if (errorCode < 0) {
+    public static KafkaError getError(int errorCode) {
+        if (errorCode < 0 || errorCode >= UNKNOWN.ordinal()) {
             return UNKNOWN;
         } else {
             return values()[errorCode];

http://git-wip-us.apache.org/repos/asf/incubator-storm/blob/80005ba3/src/test/storm/kafka/KafkaErrorTest.java
----------------------------------------------------------------------
diff --git a/src/test/storm/kafka/KafkaErrorTest.java b/src/test/storm/kafka/KafkaErrorTest.java
new file mode 100644
index 0000000..e5f9db2
--- /dev/null
+++ b/src/test/storm/kafka/KafkaErrorTest.java
@@ -0,0 +1,39 @@
+package storm.kafka;
+
+import org.junit.Test;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Date: 12/01/2014
+ * Time: 18:09
+ */
+public class KafkaErrorTest {
+
+    @Test
+    public void getError() {
+        assertThat(KafkaError.getError(0), is(equalTo(KafkaError.NO_ERROR)));
+    }
+
+    @Test
+    public void offsetMetaDataTooLarge() {
+        assertThat(KafkaError.getError(12), is(equalTo(KafkaError.OFFSET_METADATA_TOO_LARGE)));
+    }
+
+    @Test
+    public void unknownNegative() {
+        assertThat(KafkaError.getError(-1), is(equalTo(KafkaError.UNKNOWN)));
+    }
+
+    @Test
+    public void unknownPositive() {
+        assertThat(KafkaError.getError(75), is(equalTo(KafkaError.UNKNOWN)));
+    }
+
+    @Test
+    public void unknown() {
+        assertThat(KafkaError.getError(13), is(equalTo(KafkaError.UNKNOWN)));
+    }
+}


Mime
View raw message