accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r1190427 - in /incubator/accumulo/branches/1.3/src/core/src: main/java/org/apache/accumulo/core/client/mock/MockMultiTableBatchWriter.java test/java/org/apache/accumulo/core/client/mock/MockConnectorTest.java
Date Fri, 28 Oct 2011 16:25:11 GMT
Author: ecn
Date: Fri Oct 28 16:25:11 2011
New Revision: 1190427

URL: http://svn.apache.org/viewvc?rev=1190427&view=rev
Log:
ACCUMULO-95: add MockMultiTableBatchWriter

Added:
    incubator/accumulo/branches/1.3/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockMultiTableBatchWriter.java
Modified:
    incubator/accumulo/branches/1.3/src/core/src/test/java/org/apache/accumulo/core/client/mock/MockConnectorTest.java

Added: incubator/accumulo/branches/1.3/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockMultiTableBatchWriter.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/branches/1.3/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockMultiTableBatchWriter.java?rev=1190427&view=auto
==============================================================================
--- incubator/accumulo/branches/1.3/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockMultiTableBatchWriter.java
(added)
+++ incubator/accumulo/branches/1.3/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockMultiTableBatchWriter.java
Fri Oct 28 16:25:11 2011
@@ -0,0 +1,36 @@
+package org.apache.accumulo.core.client.mock;
+
+import org.apache.accumulo.core.client.AccumuloException;
+import org.apache.accumulo.core.client.AccumuloSecurityException;
+import org.apache.accumulo.core.client.BatchWriter;
+import org.apache.accumulo.core.client.MultiTableBatchWriter;
+import org.apache.accumulo.core.client.MutationsRejectedException;
+import org.apache.accumulo.core.client.TableNotFoundException;
+
+public class MockMultiTableBatchWriter implements MultiTableBatchWriter {
+  
+  final MockAccumulo ma;
+  
+  MockMultiTableBatchWriter(MockAccumulo ma) {
+    this.ma = ma;
+  }
+
+  @Override
+  public BatchWriter getBatchWriter(String table) throws AccumuloException, AccumuloSecurityException,
TableNotFoundException {
+    return new MockBatchWriter(ma, table);
+  }
+  
+  @Override
+  public void flush() throws MutationsRejectedException {
+  }
+  
+  @Override
+  public void close() throws MutationsRejectedException {
+  }
+  
+  @Override
+  public boolean isClosed() {
+    return false;
+  }
+  
+}

Modified: incubator/accumulo/branches/1.3/src/core/src/test/java/org/apache/accumulo/core/client/mock/MockConnectorTest.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/branches/1.3/src/core/src/test/java/org/apache/accumulo/core/client/mock/MockConnectorTest.java?rev=1190427&r1=1190426&r2=1190427&view=diff
==============================================================================
--- incubator/accumulo/branches/1.3/src/core/src/test/java/org/apache/accumulo/core/client/mock/MockConnectorTest.java
(original)
+++ incubator/accumulo/branches/1.3/src/core/src/test/java/org/apache/accumulo/core/client/mock/MockConnectorTest.java
Fri Oct 28 16:25:11 2011
@@ -31,9 +31,8 @@ import org.apache.accumulo.core.Constant
 import org.apache.accumulo.core.client.BatchScanner;
 import org.apache.accumulo.core.client.BatchWriter;
 import org.apache.accumulo.core.client.Connector;
+import org.apache.accumulo.core.client.MultiTableBatchWriter;
 import org.apache.accumulo.core.client.Scanner;
-import org.apache.accumulo.core.client.mock.MockConnector;
-import org.apache.accumulo.core.client.mock.MockInstance;
 import org.apache.accumulo.core.data.Key;
 import org.apache.accumulo.core.data.Mutation;
 import org.apache.accumulo.core.data.Range;
@@ -150,4 +149,34 @@ public class MockConnectorTest {
     assertEquals(value, next.getValue().toString());
   }
   
+  public void testMockMultiTableBatchWriter() throws Exception {
+    Connector c = new MockConnector("root");
+    c.tableOperations().create("a");
+    c.tableOperations().create("b");
+    MultiTableBatchWriter bw = c.createMultiTableBatchWriter(10000L, 1000L, 4);
+    Mutation m1 = new Mutation("r1");
+    m1.put("cf1", "cq1", 1, "v1");
+    BatchWriter b = bw.getBatchWriter("a");
+    b.addMutation(m1);
+    b.flush();
+    b = bw.getBatchWriter("b");
+    b.addMutation(m1);
+    b.flush();
+    
+    Scanner scanner = c.createScanner("a", Constants.NO_AUTHS);
+    int count = 0;
+    for (@SuppressWarnings("unused")
+    Entry<Key,Value> entry : scanner) {
+      count++;
+    }
+    assertEquals(1, count);
+    scanner = c.createScanner("b", Constants.NO_AUTHS);
+    for (@SuppressWarnings("unused")
+    Entry<Key,Value> entry : scanner) {
+      count++;
+    }
+    assertEquals(1, count);
+
+  }
+
 }



Mime
View raw message