You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by kt...@apache.org on 2013/07/31 17:13:59 UTC

[22/50] [abbrv] git commit: ACCUMULO-1505 - Applying Ryan Leary's patch

ACCUMULO-1505 - Applying Ryan Leary's patch



git-svn-id: https://svn.apache.org/repos/asf/accumulo/branches/1.4@1491900 13f79535-47bb-0310-9956-ffa450edef68


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/225d7286
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/225d7286
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/225d7286

Branch: refs/heads/master
Commit: 225d7286d2d5f382c7caef83ea7e6f22c044291a
Parents: 8fd1c3b
Author: John Vines <vi...@apache.org>
Authored: Tue Jun 11 18:50:30 2013 +0000
Committer: John Vines <vi...@apache.org>
Committed: Tue Jun 11 18:50:30 2013 +0000

----------------------------------------------------------------------
 .../core/client/mock/MockBatchWriter.java       |  3 ++
 .../accumulo/core/client/mock/MockTable.java    |  2 +
 .../core/client/mock/MockConnectorTest.java     | 39 ++++++++++++++++++++
 3 files changed, 44 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/225d7286/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockBatchWriter.java
----------------------------------------------------------------------
diff --git a/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockBatchWriter.java b/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockBatchWriter.java
index b33ebcb..d89a263 100644
--- a/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockBatchWriter.java
+++ b/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockBatchWriter.java
@@ -19,6 +19,7 @@ package org.apache.accumulo.core.client.mock;
 import org.apache.accumulo.core.client.BatchWriter;
 import org.apache.accumulo.core.client.MutationsRejectedException;
 import org.apache.accumulo.core.data.Mutation;
+import org.apache.accumulo.core.util.ArgumentChecker;
 
 public class MockBatchWriter implements BatchWriter {
   
@@ -32,11 +33,13 @@ public class MockBatchWriter implements BatchWriter {
   
   @Override
   public void addMutation(Mutation m) throws MutationsRejectedException {
+    ArgumentChecker.notNull(m);
     acu.addMutation(tablename, m);
   }
   
   @Override
   public void addMutations(Iterable<Mutation> iterable) throws MutationsRejectedException {
+    ArgumentChecker.notNull(iterable);
     for (Mutation m : iterable) {
       acu.addMutation(tablename, m);
     }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/225d7286/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockTable.java
----------------------------------------------------------------------
diff --git a/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockTable.java b/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockTable.java
index 0722ba1..999c9b2 100644
--- a/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockTable.java
+++ b/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockTable.java
@@ -97,6 +97,8 @@ public class MockTable {
   }
   
   synchronized void addMutation(Mutation m) {
+    if (m.size() == 0)
+      throw new IllegalArgumentException("Can not add empty mutations");
     long now = System.currentTimeMillis();
     mutationCount++;
     for (ColumnUpdate u : m.getUpdates()) {

http://git-wip-us.apache.org/repos/asf/accumulo/blob/225d7286/src/core/src/test/java/org/apache/accumulo/core/client/mock/MockConnectorTest.java
----------------------------------------------------------------------
diff --git a/src/core/src/test/java/org/apache/accumulo/core/client/mock/MockConnectorTest.java b/src/core/src/test/java/org/apache/accumulo/core/client/mock/MockConnectorTest.java
index ab1ffb5..6fa9dff 100644
--- a/src/core/src/test/java/org/apache/accumulo/core/client/mock/MockConnectorTest.java
+++ b/src/core/src/test/java/org/apache/accumulo/core/client/mock/MockConnectorTest.java
@@ -20,8 +20,10 @@ import static junit.framework.Assert.assertEquals;
 import static junit.framework.Assert.assertFalse;
 import static junit.framework.Assert.assertTrue;
 
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Map.Entry;
 import java.util.Random;
 
@@ -92,6 +94,43 @@ public class MockConnectorTest {
   }
   
   @Test
+  public void testBadMutations() throws Exception {
+    Connector c = new MockConnector("root", new MockInstance());
+    c.tableOperations().create("test");
+    BatchWriter bw = c.createBatchWriter("test", 10000L, 1000L, 4);
+
+    try {
+      bw.addMutation(null);
+      Assert.fail("addMutation should throw IAE for null mutation");
+    } catch (IllegalArgumentException iae) {}
+    try {
+      bw.addMutations(null);
+      Assert.fail("addMutations should throw IAE for null iterable");
+    } catch (IllegalArgumentException iae) {}
+
+    bw.addMutations(Collections.EMPTY_LIST);
+
+    Mutation bad = new Mutation("bad");
+    try {
+      bw.addMutation(bad);
+      Assert.fail("addMutation should throw IAE for empty mutation");
+    } catch (IllegalArgumentException iae) {}
+
+
+    Mutation good = new Mutation("good");
+    good.put(asText(random.nextInt()), asText(random.nextInt()), new Value("good".getBytes()));
+    List<Mutation> mutations = new ArrayList<Mutation>();
+    mutations.add(good);
+    mutations.add(bad);
+    try {
+      bw.addMutations(mutations);
+      Assert.fail("addMutations should throw IAE if it contains empty mutation");
+    } catch (IllegalArgumentException iae) {}
+
+    bw.close();
+  }
+
+  @Test
   public void testAggregation() throws Exception {
     MockInstance mockInstance = new MockInstance();
     Connector c = mockInstance.getConnector("root", new byte[] {});