You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by vi...@apache.org on 2013/06/11 20:50:31 UTC
svn commit: r1491900 - in /accumulo/branches/1.4/src/core/src:
main/java/org/apache/accumulo/core/client/mock/
test/java/org/apache/accumulo/core/client/mock/
Author: vines
Date: Tue Jun 11 18:50:30 2013
New Revision: 1491900
URL: http://svn.apache.org/r1491900
Log:
ACCUMULO-1505 - Applying Ryan Leary's patch
Modified:
accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockBatchWriter.java
accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockTable.java
accumulo/branches/1.4/src/core/src/test/java/org/apache/accumulo/core/client/mock/MockConnectorTest.java
Modified: accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockBatchWriter.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockBatchWriter.java?rev=1491900&r1=1491899&r2=1491900&view=diff
==============================================================================
--- accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockBatchWriter.java (original)
+++ accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockBatchWriter.java Tue Jun 11 18:50:30 2013
@@ -19,6 +19,7 @@ package org.apache.accumulo.core.client.
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
@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);
}
Modified: accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockTable.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockTable.java?rev=1491900&r1=1491899&r2=1491900&view=diff
==============================================================================
--- accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockTable.java (original)
+++ accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockTable.java Tue Jun 11 18:50:30 2013
@@ -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()) {
Modified: accumulo/branches/1.4/src/core/src/test/java/org/apache/accumulo/core/client/mock/MockConnectorTest.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.4/src/core/src/test/java/org/apache/accumulo/core/client/mock/MockConnectorTest.java?rev=1491900&r1=1491899&r2=1491900&view=diff
==============================================================================
--- accumulo/branches/1.4/src/core/src/test/java/org/apache/accumulo/core/client/mock/MockConnectorTest.java (original)
+++ accumulo/branches/1.4/src/core/src/test/java/org/apache/accumulo/core/client/mock/MockConnectorTest.java Tue Jun 11 18:50:30 2013
@@ -20,8 +20,10 @@ import static junit.framework.Assert.ass
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[] {});