You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by ct...@apache.org on 2015/07/30 23:51:43 UTC

[09/14] accumulo git commit: ACCUMULO-3920 moved some test away from mock

ACCUMULO-3920 moved some test away from mock


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

Branch: refs/heads/master
Commit: 66c62e5f357a50044da0ab4a56fccb527ed6ac2c
Parents: 2556df3
Author: Keith Turner <ke...@deenlo.com>
Authored: Thu Jul 9 16:25:10 2015 -0400
Committer: Christopher Tubbs <ct...@apache.org>
Committed: Thu Jul 30 16:33:03 2015 -0400

----------------------------------------------------------------------
 .../accumulo/core/client/admin/FindMaxTest.java | 119 ------
 .../user/IntersectingIteratorTest.java          |  26 --
 .../core/iterators/user/RegExFilterTest.java    |  49 +--
 .../core/iterators/user/RowFilterTest.java      | 128 +++---
 .../user/TransformingIteratorTest.java          | 202 +++++-----
 .../accumulo/server/util/MetadataTableUtil.java |  29 +-
 .../master/balancer/TableLoadBalancerTest.java  |  39 +-
 .../server/security/SystemCredentialsTest.java  |   5 +-
 .../apache/accumulo/server/util/CloneTest.java  | 376 ------------------
 .../accumulo/shell/ShellSetInstanceTest.java    |   7 +-
 .../java/org/apache/accumulo/test/CloneIT.java  | 390 +++++++++++++++++++
 .../org/apache/accumulo/test/FindMaxIT.java     | 113 ++++++
 .../accumulo/test/iterator/RegExTest.java       |  76 ++--
 13 files changed, 748 insertions(+), 811 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/66c62e5f/core/src/test/java/org/apache/accumulo/core/client/admin/FindMaxTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/client/admin/FindMaxTest.java b/core/src/test/java/org/apache/accumulo/core/client/admin/FindMaxTest.java
deleted file mode 100644
index 78f7e75..0000000
--- a/core/src/test/java/org/apache/accumulo/core/client/admin/FindMaxTest.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.accumulo.core.client.admin;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-
-import java.util.ArrayList;
-import java.util.Map.Entry;
-
-import org.apache.accumulo.core.client.BatchWriter;
-import org.apache.accumulo.core.client.BatchWriterConfig;
-import org.apache.accumulo.core.client.Connector;
-import org.apache.accumulo.core.client.Instance;
-import org.apache.accumulo.core.client.Scanner;
-import org.apache.accumulo.core.client.security.tokens.PasswordToken;
-import org.apache.accumulo.core.data.Key;
-import org.apache.accumulo.core.data.Mutation;
-import org.apache.accumulo.core.data.Value;
-import org.apache.accumulo.core.security.Authorizations;
-import org.apache.hadoop.io.Text;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TestName;
-
-public class FindMaxTest {
-
-  private static Mutation nm(byte[] row) {
-    Mutation m = new Mutation(new Text(row));
-    m.put("cf", "cq", "v");
-    return m;
-  }
-
-  private static Mutation nm(String row) {
-    Mutation m = new Mutation(row);
-    m.put("cf", "cq", "v");
-    return m;
-  }
-
-  @Rule
-  public TestName test = new TestName();
-
-  @Test
-  public void test1() throws Exception {
-    Instance mi = new org.apache.accumulo.core.client.mock.MockInstance(test.getMethodName());
-
-    Connector conn = mi.getConnector("root", new PasswordToken(""));
-    conn.tableOperations().create("foo");
-
-    BatchWriter bw = conn.createBatchWriter("foo", new BatchWriterConfig());
-
-    bw.addMutation(nm(new byte[] {0}));
-    bw.addMutation(nm(new byte[] {0, 0}));
-    bw.addMutation(nm(new byte[] {0, 1}));
-    bw.addMutation(nm(new byte[] {0, 1, 0}));
-    bw.addMutation(nm(new byte[] {1, 0}));
-    bw.addMutation(nm(new byte[] {'a', 'b', 'c'}));
-    bw.addMutation(nm(new byte[] {(byte) 0xff}));
-    bw.addMutation(nm(new byte[] {(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff}));
-
-    for (int i = 0; i < 1000; i++) {
-      bw.addMutation(nm(String.format("r%05d", i)));
-    }
-
-    bw.close();
-
-    Scanner scanner = conn.createScanner("foo", Authorizations.EMPTY);
-
-    ArrayList<Text> rows = new ArrayList<Text>();
-
-    for (Entry<Key,Value> entry : scanner) {
-      rows.add(entry.getKey().getRow());
-    }
-
-    for (int i = rows.size() - 1; i > 0; i--) {
-      Text max = FindMax.findMax(conn.createScanner("foo", Authorizations.EMPTY), null, true, rows.get(i), false);
-      assertEquals(rows.get(i - 1), max);
-
-      max = FindMax.findMax(conn.createScanner("foo", Authorizations.EMPTY), rows.get(i - 1), true, rows.get(i), false);
-      assertEquals(rows.get(i - 1), max);
-
-      max = FindMax.findMax(conn.createScanner("foo", Authorizations.EMPTY), rows.get(i - 1), false, rows.get(i), false);
-      assertNull(max);
-
-      max = FindMax.findMax(conn.createScanner("foo", Authorizations.EMPTY), null, true, rows.get(i), true);
-      assertEquals(rows.get(i), max);
-
-      max = FindMax.findMax(conn.createScanner("foo", Authorizations.EMPTY), rows.get(i), true, rows.get(i), true);
-      assertEquals(rows.get(i), max);
-
-      max = FindMax.findMax(conn.createScanner("foo", Authorizations.EMPTY), rows.get(i - 1), false, rows.get(i), true);
-      assertEquals(rows.get(i), max);
-
-    }
-
-    Text max = FindMax.findMax(conn.createScanner("foo", Authorizations.EMPTY), null, true, null, true);
-    assertEquals(rows.get(rows.size() - 1), max);
-
-    max = FindMax.findMax(conn.createScanner("foo", Authorizations.EMPTY), null, true, new Text(new byte[] {0}), false);
-    assertNull(max);
-
-    max = FindMax.findMax(conn.createScanner("foo", Authorizations.EMPTY), null, true, new Text(new byte[] {0}), true);
-    assertEquals(rows.get(0), max);
-  }
-}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/66c62e5f/core/src/test/java/org/apache/accumulo/core/iterators/user/IntersectingIteratorTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/iterators/user/IntersectingIteratorTest.java b/core/src/test/java/org/apache/accumulo/core/iterators/user/IntersectingIteratorTest.java
index c3696d4..286b343 100644
--- a/core/src/test/java/org/apache/accumulo/core/iterators/user/IntersectingIteratorTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/iterators/user/IntersectingIteratorTest.java
@@ -295,30 +295,4 @@ public class IntersectingIteratorTest {
     assertTrue(hitCount == docs.size());
     cleanup();
   }
-
-  @Test
-  public void testWithBatchScanner() throws Exception {
-    Value empty = new Value(new byte[] {});
-    Instance inst = new org.apache.accumulo.core.client.mock.MockInstance(test.getMethodName());
-    Connector connector = inst.getConnector("user", new PasswordToken("pass"));
-    connector.tableOperations().create("index");
-    BatchWriter bw = connector.createBatchWriter("index", new BatchWriterConfig());
-    Mutation m = new Mutation("000012");
-    m.put("rvy", "5000000000000000", empty);
-    m.put("15qh", "5000000000000000", empty);
-    bw.addMutation(m);
-    bw.close();
-
-    BatchScanner bs = connector.createBatchScanner("index", Authorizations.EMPTY, 10);
-    IteratorSetting ii = new IteratorSetting(20, IntersectingIterator.class);
-    IntersectingIterator.setColumnFamilies(ii, new Text[] {new Text("rvy"), new Text("15qh")});
-    bs.addScanIterator(ii);
-    bs.setRanges(Collections.singleton(new Range()));
-    Iterator<Entry<Key,Value>> iterator = bs.iterator();
-    assertTrue(iterator.hasNext());
-    Entry<Key,Value> next = iterator.next();
-    Key key = next.getKey();
-    assertEquals(key.getColumnQualifier(), new Text("5000000000000000"));
-    assertFalse(iterator.hasNext());
-  }
 }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/66c62e5f/core/src/test/java/org/apache/accumulo/core/iterators/user/RegExFilterTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/iterators/user/RegExFilterTest.java b/core/src/test/java/org/apache/accumulo/core/iterators/user/RegExFilterTest.java
index 7a203c8..61acc09 100644
--- a/core/src/test/java/org/apache/accumulo/core/iterators/user/RegExFilterTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/iterators/user/RegExFilterTest.java
@@ -25,46 +25,20 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.TreeMap;
 
-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.BatchWriterConfig;
-import org.apache.accumulo.core.client.Connector;
-import org.apache.accumulo.core.client.Instance;
 import org.apache.accumulo.core.client.IteratorSetting;
-import org.apache.accumulo.core.client.Scanner;
-import org.apache.accumulo.core.client.TableExistsException;
-import org.apache.accumulo.core.client.TableNotFoundException;
-import org.apache.accumulo.core.client.security.tokens.PasswordToken;
 import org.apache.accumulo.core.data.ByteSequence;
 import org.apache.accumulo.core.data.Key;
-import org.apache.accumulo.core.data.Mutation;
 import org.apache.accumulo.core.data.Range;
 import org.apache.accumulo.core.data.Value;
 import org.apache.accumulo.core.iterators.DefaultIteratorEnvironment;
 import org.apache.accumulo.core.iterators.SortedMapIterator;
-import org.apache.accumulo.core.security.Authorizations;
 import org.apache.hadoop.io.Text;
-import org.junit.Before;
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.TestName;
 
 public class RegExFilterTest {
 
   private static final Collection<ByteSequence> EMPTY_COL_FAMS = new ArrayList<ByteSequence>();
 
-  private Connector conn;
-
-  @Rule
-  public TestName test = new TestName();
-
-  @Before
-  public void setupInstance() throws Exception {
-    Instance instance = new org.apache.accumulo.core.client.mock.MockInstance(test.getMethodName());
-    conn = instance.getConnector("root", new PasswordToken(""));
-  }
-
   private Key nkv(TreeMap<Key,Value> tm, String row, String cf, String cq, String val) {
     Key k = nk(row, cf, cq);
     tm.put(k, new Value(val.getBytes()));
@@ -267,8 +241,8 @@ public class RegExFilterTest {
   }
 
   @Test
-  public void testNullByteInKey() throws AccumuloException, AccumuloSecurityException, TableExistsException, TableNotFoundException {
-    String table = "nullRegexTest";
+  public void testNullByteInKey() throws IOException {
+    TreeMap<Key,Value> tm = new TreeMap<Key,Value>();
 
     String s1 = "first", s2 = "second";
     byte[] b1 = s1.getBytes(), b2 = s2.getBytes(), ball;
@@ -277,22 +251,17 @@ public class RegExFilterTest {
     ball[b1.length] = (byte) 0;
     System.arraycopy(b2, 0, ball, b1.length + 1, b2.length);
 
-    conn.tableOperations().create(table);
-    BatchWriter bw = conn.createBatchWriter(table, new BatchWriterConfig());
-    Mutation m = new Mutation(ball);
-    m.put(new byte[0], new byte[0], new byte[0]);
-    bw.addMutation(m);
-    bw.close();
+    Key key = new Key(ball, new byte[0], new byte[0], new byte[0], 90, false);
+    Value val = new Value(new byte[0]);
+    tm.put(key, val);
 
     IteratorSetting is = new IteratorSetting(5, RegExFilter.class);
     RegExFilter.setRegexs(is, s2, null, null, null, true, true);
 
-    Scanner scanner = conn.createScanner(table, new Authorizations());
-    scanner.addScanIterator(is);
-
-    assertTrue("Client side iterator couldn't find a match when it should have", scanner.iterator().hasNext());
+    RegExFilter filter = new RegExFilter();
+    filter.init(new SortedMapIterator(tm), is.getOptions(), null);
+    filter.seek(new Range(), EMPTY_COL_FAMS, false);
 
-    conn.tableOperations().attachIterator(table, is);
-    assertTrue("server side iterator couldn't find a match when it should have", conn.createScanner(table, new Authorizations()).iterator().hasNext());
+    assertTrue("iterator couldn't find a match when it should have", filter.hasTop());
   }
 }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/66c62e5f/core/src/test/java/org/apache/accumulo/core/iterators/user/RowFilterTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/iterators/user/RowFilterTest.java b/core/src/test/java/org/apache/accumulo/core/iterators/user/RowFilterTest.java
index 6026c14..f0892b2 100644
--- a/core/src/test/java/org/apache/accumulo/core/iterators/user/RowFilterTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/iterators/user/RowFilterTest.java
@@ -25,17 +25,10 @@ import java.util.Collections;
 import java.util.HashSet;
 import java.util.LinkedList;
 import java.util.List;
-import java.util.Map.Entry;
 import java.util.Set;
 import java.util.TreeMap;
 
-import org.apache.accumulo.core.client.BatchWriter;
-import org.apache.accumulo.core.client.BatchWriterConfig;
-import org.apache.accumulo.core.client.Connector;
-import org.apache.accumulo.core.client.Instance;
-import org.apache.accumulo.core.client.IteratorSetting;
-import org.apache.accumulo.core.client.Scanner;
-import org.apache.accumulo.core.client.security.tokens.PasswordToken;
+import org.apache.accumulo.core.data.ArrayByteSequence;
 import org.apache.accumulo.core.data.ByteSequence;
 import org.apache.accumulo.core.data.ColumnUpdate;
 import org.apache.accumulo.core.data.Key;
@@ -45,25 +38,13 @@ import org.apache.accumulo.core.data.Value;
 import org.apache.accumulo.core.iterators.DefaultIteratorEnvironment;
 import org.apache.accumulo.core.iterators.SortedKeyValueIterator;
 import org.apache.accumulo.core.iterators.SortedMapIterator;
-import org.apache.accumulo.core.security.Authorizations;
+import org.apache.accumulo.core.iterators.system.ColumnFamilySkippingIterator;
 import org.apache.hadoop.io.Text;
-import org.junit.Before;
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.TestName;
 
-public class RowFilterTest {
-
-  @Rule
-  public TestName test = new TestName();
+import com.google.common.collect.ImmutableSet;
 
-  private Connector conn;
-
-  @Before
-  public void setupInstance() throws Exception {
-    Instance instance = new org.apache.accumulo.core.client.mock.MockInstance(test.getMethodName());
-    conn = instance.getConnector("", new PasswordToken(""));
-  }
+public class RowFilterTest {
 
   public static class SummingRowFilter extends RowFilter {
 
@@ -84,7 +65,7 @@ public class RowFilterTest {
       }
 
       // ensure that seeks are confined to the row
-      rowIterator.seek(new Range(), new HashSet<ByteSequence>(), false);
+      rowIterator.seek(new Range(null, false, firstKey == null ? null : firstKey.getRow(), false), new HashSet<ByteSequence>(), false);
       while (rowIterator.hasTop()) {
         sum2 += Integer.parseInt(rowIterator.getTopValue().toString());
         rowIterator.next();
@@ -96,7 +77,7 @@ public class RowFilterTest {
         rowIterator.next();
       }
 
-      return sum == 2 && sum2 == 2;
+      return sum == 2 && sum2 == 0;
     }
 
   }
@@ -144,7 +125,7 @@ public class RowFilterTest {
 
     m = new Mutation("1");
     m.put("cf1", "cq1", "1");
-    m.put("cf1", "cq2", "2");
+    m.put("cf2", "cq2", "2");
     mutations.add(m);
 
     m = new Mutation("2");
@@ -154,7 +135,7 @@ public class RowFilterTest {
 
     m = new Mutation("3");
     m.put("cf1", "cq1", "0");
-    m.put("cf1", "cq2", "2");
+    m.put("cf2", "cq2", "2");
     mutations.add(m);
 
     m = new Mutation("4");
@@ -197,69 +178,63 @@ public class RowFilterTest {
 
   @Test
   public void test1() throws Exception {
-    conn.tableOperations().create("table1");
-    BatchWriter bw = conn.createBatchWriter("table1", new BatchWriterConfig());
+    ColumnFamilySkippingIterator source = new ColumnFamilySkippingIterator(new SortedMapIterator(createKeyValues()));
 
-    for (Mutation m : createMutations()) {
-      bw.addMutation(m);
-    }
-    IteratorSetting is = new IteratorSetting(40, SummingRowFilter.class);
-    conn.tableOperations().attachIterator("table1", is);
+    RowFilter filter = new SummingRowFilter();
+    filter.init(source, Collections.<String,String> emptyMap(), new DefaultIteratorEnvironment());
 
-    Scanner scanner = conn.createScanner("table1", Authorizations.EMPTY);
-    assertEquals(new HashSet<String>(Arrays.asList("2", "3")), getRows(scanner));
+    filter.seek(new Range(), Collections.<ByteSequence> emptySet(), false);
+
+    assertEquals(new HashSet<String>(Arrays.asList("2", "3")), getRows(filter));
 
-    scanner.fetchColumn(new Text("cf1"), new Text("cq2"));
-    assertEquals(new HashSet<String>(Arrays.asList("1", "3")), getRows(scanner));
+    ByteSequence cf = new ArrayByteSequence("cf2");
 
-    scanner.clearColumns();
-    scanner.fetchColumn(new Text("cf1"), new Text("cq1"));
-    assertEquals(new HashSet<String>(), getRows(scanner));
+    filter.seek(new Range(), ImmutableSet.of(cf), true);
+    assertEquals(new HashSet<String>(Arrays.asList("1", "3", "0", "4")), getRows(filter));
 
-    scanner.setRange(new Range("0", "4"));
-    scanner.clearColumns();
-    assertEquals(new HashSet<String>(Arrays.asList("2", "3")), getRows(scanner));
+    filter.seek(new Range("0", "4"), Collections.<ByteSequence> emptySet(), false);
+    assertEquals(new HashSet<String>(Arrays.asList("2", "3")), getRows(filter));
 
-    scanner.setRange(new Range("2"));
-    scanner.clearColumns();
-    assertEquals(new HashSet<String>(Arrays.asList("2")), getRows(scanner));
+    filter.seek(new Range("2"), Collections.<ByteSequence> emptySet(), false);
+    assertEquals(new HashSet<String>(Arrays.asList("2")), getRows(filter));
 
-    scanner.setRange(new Range("4"));
-    scanner.clearColumns();
-    assertEquals(new HashSet<String>(), getRows(scanner));
+    filter.seek(new Range("4"), Collections.<ByteSequence> emptySet(), false);
+    assertEquals(new HashSet<String>(), getRows(filter));
 
-    scanner.setRange(new Range("4"));
-    scanner.clearColumns();
-    scanner.fetchColumn(new Text("cf1"), new Text("cq2"));
-    scanner.fetchColumn(new Text("cf1"), new Text("cq4"));
-    assertEquals(new HashSet<String>(Arrays.asList("4")), getRows(scanner));
+    filter.seek(new Range("4"), ImmutableSet.of(cf), true);
+    assertEquals(new HashSet<String>(Arrays.asList("4")), getRows(filter));
 
   }
 
   @Test
   public void testChainedRowFilters() throws Exception {
-    conn.tableOperations().create("chained_row_filters");
-    BatchWriter bw = conn.createBatchWriter("chained_row_filters", new BatchWriterConfig());
-    for (Mutation m : createMutations()) {
-      bw.addMutation(m);
-    }
-    conn.tableOperations().attachIterator("chained_row_filters", new IteratorSetting(40, "trueFilter1", TrueFilter.class));
-    conn.tableOperations().attachIterator("chained_row_filters", new IteratorSetting(41, "trueFilter2", TrueFilter.class));
-    Scanner scanner = conn.createScanner("chained_row_filters", Authorizations.EMPTY);
-    assertEquals(new HashSet<String>(Arrays.asList("0", "1", "2", "3", "4")), getRows(scanner));
+    SortedMapIterator source = new SortedMapIterator(createKeyValues());
+
+    RowFilter filter0 = new TrueFilter();
+    filter0.init(source, Collections.<String,String> emptyMap(), new DefaultIteratorEnvironment());
+
+    RowFilter filter = new TrueFilter();
+    filter.init(filter0, Collections.<String,String> emptyMap(), new DefaultIteratorEnvironment());
+
+    filter.seek(new Range(), Collections.<ByteSequence> emptySet(), false);
+
+    assertEquals(new HashSet<String>(Arrays.asList("0", "1", "2", "3", "4")), getRows(filter));
   }
 
   @Test
   public void testFilterConjunction() throws Exception {
-    conn.tableOperations().create("filter_conjunction");
-    BatchWriter bw = conn.createBatchWriter("filter_conjunction", new BatchWriterConfig());
-    for (Mutation m : createMutations()) {
-      bw.addMutation(m);
-    }
-    conn.tableOperations().attachIterator("filter_conjunction", new IteratorSetting(40, "rowZeroOrOne", RowZeroOrOneFilter.class));
-    conn.tableOperations().attachIterator("filter_conjunction", new IteratorSetting(41, "rowOneOrTwo", RowOneOrTwoFilter.class));
-    Scanner scanner = conn.createScanner("filter_conjunction", Authorizations.EMPTY);
-    assertEquals(new HashSet<String>(Arrays.asList("1")), getRows(scanner));
+
+    SortedMapIterator source = new SortedMapIterator(createKeyValues());
+
+    RowFilter filter0 = new RowZeroOrOneFilter();
+    filter0.init(source, Collections.<String,String> emptyMap(), new DefaultIteratorEnvironment());
+
+    RowFilter filter = new RowOneOrTwoFilter();
+    filter.init(filter0, Collections.<String,String> emptyMap(), new DefaultIteratorEnvironment());
+
+    filter.seek(new Range(), Collections.<ByteSequence> emptySet(), false);
+
+    assertEquals(new HashSet<String>(Arrays.asList("1")), getRows(filter));
   }
 
   @Test
@@ -308,10 +283,11 @@ public class RowFilterTest {
     assertTrue("Expected next key read to be greater than the previous after deepCopy", lastKeyRead.compareTo(finalKeyRead) < 0);
   }
 
-  private HashSet<String> getRows(Scanner scanner) {
+  private HashSet<String> getRows(RowFilter filter) throws IOException {
     HashSet<String> rows = new HashSet<String>();
-    for (Entry<Key,Value> entry : scanner) {
-      rows.add(entry.getKey().getRow().toString());
+    while (filter.hasTop()) {
+      rows.add(filter.getTopKey().getRowData().toString());
+      filter.next();
     }
     return rows;
   }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/66c62e5f/core/src/test/java/org/apache/accumulo/core/iterators/user/TransformingIteratorTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/iterators/user/TransformingIteratorTest.java b/core/src/test/java/org/apache/accumulo/core/iterators/user/TransformingIteratorTest.java
index e98afd7..1f4d6e7 100644
--- a/core/src/test/java/org/apache/accumulo/core/iterators/user/TransformingIteratorTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/iterators/user/TransformingIteratorTest.java
@@ -24,83 +24,85 @@ import static org.junit.Assert.assertTrue;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
+import java.util.Set;
 import java.util.SortedMap;
 import java.util.TreeMap;
 
-import org.apache.accumulo.core.client.BatchScanner;
-import org.apache.accumulo.core.client.BatchWriter;
-import org.apache.accumulo.core.client.BatchWriterConfig;
-import org.apache.accumulo.core.client.Connector;
-import org.apache.accumulo.core.client.Instance;
 import org.apache.accumulo.core.client.IteratorSetting;
-import org.apache.accumulo.core.client.Scanner;
-import org.apache.accumulo.core.client.security.tokens.PasswordToken;
 import org.apache.accumulo.core.conf.AccumuloConfiguration;
 import org.apache.accumulo.core.data.ArrayByteSequence;
 import org.apache.accumulo.core.data.ByteSequence;
 import org.apache.accumulo.core.data.Key;
-import org.apache.accumulo.core.data.Mutation;
 import org.apache.accumulo.core.data.PartialKey;
 import org.apache.accumulo.core.data.Range;
 import org.apache.accumulo.core.data.Value;
 import org.apache.accumulo.core.iterators.IteratorEnvironment;
 import org.apache.accumulo.core.iterators.IteratorUtil.IteratorScope;
 import org.apache.accumulo.core.iterators.SortedKeyValueIterator;
+import org.apache.accumulo.core.iterators.SortedMapIterator;
 import org.apache.accumulo.core.iterators.WrappingIterator;
+import org.apache.accumulo.core.iterators.system.ColumnFamilySkippingIterator;
+import org.apache.accumulo.core.iterators.system.VisibilityFilter;
 import org.apache.accumulo.core.security.Authorizations;
 import org.apache.accumulo.core.security.ColumnVisibility;
 import org.apache.hadoop.io.Text;
+import org.easymock.EasyMock;
 import org.junit.Assert;
 import org.junit.Before;
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.TestName;
+
+import com.google.common.collect.ImmutableMap;
 
 public class TransformingIteratorTest {
-  private static final String TABLE_NAME = "test_table";
+
   private static Authorizations authorizations = new Authorizations("vis0", "vis1", "vis2", "vis3", "vis4");
-  private Connector connector;
-  private Scanner scanner;
+  private static final Map<String,String> EMPTY_OPTS = ImmutableMap.of();
+  private TransformingIterator titer;
 
-  @Rule
-  public TestName test = new TestName();
+  private TreeMap<Key,Value> data = new TreeMap<Key,Value>();
 
   @Before
-  public void setUpMockAccumulo() throws Exception {
-    Instance instance = new org.apache.accumulo.core.client.mock.MockInstance(test.getMethodName());
-    connector = instance.getConnector("user", new PasswordToken("password"));
-    connector.securityOperations().changeUserAuthorizations("user", authorizations);
-
-    if (connector.tableOperations().exists(TABLE_NAME))
-      connector.tableOperations().delete(TABLE_NAME);
-    connector.tableOperations().create(TABLE_NAME);
-    BatchWriterConfig bwCfg = new BatchWriterConfig();
-    bwCfg.setMaxWriteThreads(1);
+  public void createData() throws Exception {
+    data.clear();
+    generateRow(data, "row1");
+    generateRow(data, "row2");
+    generateRow(data, "row3");
+  }
 
-    BatchWriter bw = connector.createBatchWriter(TABLE_NAME, bwCfg);
-    bw.addMutation(createDefaultMutation("row1"));
-    bw.addMutation(createDefaultMutation("row2"));
-    bw.addMutation(createDefaultMutation("row3"));
+  private void setUpTransformIterator(Class<? extends TransformingIterator> clazz) throws IOException {
+    setUpTransformIterator(clazz, true);
+  }
 
-    bw.flush();
-    bw.close();
+  private void setUpTransformIterator(Class<? extends TransformingIterator> clazz, boolean setupAuths) throws IOException {
+    SortedMapIterator source = new SortedMapIterator(data);
+    ColumnFamilySkippingIterator cfsi = new ColumnFamilySkippingIterator(source);
+    VisibilityFilter visFilter = new VisibilityFilter(cfsi, authorizations, new byte[0]);
+    ReuseIterator reuserIter = new ReuseIterator();
+    reuserIter.init(visFilter, EMPTY_OPTS, null);
+    try {
+      titer = clazz.newInstance();
+    } catch (InstantiationException | IllegalAccessException e) {
+      throw new RuntimeException(e);
+    }
 
-    scanner = connector.createScanner(TABLE_NAME, authorizations);
-    scanner.addScanIterator(new IteratorSetting(20, ReuseIterator.class));
-  }
+    IteratorEnvironment iterEnv = EasyMock.createMock(IteratorEnvironment.class);
+    EasyMock.expect(iterEnv.getIteratorScope()).andReturn(IteratorScope.scan).anyTimes();
+    EasyMock.replay(iterEnv);
 
-  private void setUpTransformIterator(Class<? extends TransformingIterator> clazz) {
-    IteratorSetting cfg = new IteratorSetting(21, clazz);
-    cfg.setName("keyTransformIter");
-    TransformingIterator.setAuthorizations(cfg, new Authorizations("vis0", "vis1", "vis2", "vis3"));
-    scanner.addScanIterator(cfg);
+    Map<String,String> opts;
+    if (setupAuths) {
+      IteratorSetting cfg = new IteratorSetting(21, clazz);
+      TransformingIterator.setAuthorizations(cfg, new Authorizations("vis0", "vis1", "vis2", "vis3"));
+      opts = cfg.getOptions();
+    } else {
+      opts = ImmutableMap.of();
+    }
+    titer.init(reuserIter, opts, iterEnv);
   }
 
   @Test
@@ -134,7 +136,6 @@ public class TransformingIteratorTest {
 
     // Test transforming col fam, col qual, col vis
     for (Class<? extends ReversingKeyTransformingIterator> clazz : classes) {
-      scanner.removeScanIterator("keyTransformIter");
       setUpTransformIterator(clazz);
 
       // All rows with visibilities reversed
@@ -164,7 +165,6 @@ public class TransformingIteratorTest {
     // Source data has vis1, vis2, vis3 so vis0 is a new one that is introduced.
     // Make sure it shows up in the output with the default test auths which include
     // vis0.
-    scanner.removeScanIterator("keyTransformIter");
     setUpTransformIterator(ColVisReversingKeyTransformingIterator.class);
     TreeMap<Key,Value> expected = new TreeMap<Key,Value>();
     for (int row = 1; row <= 3; ++row) {
@@ -182,13 +182,10 @@ public class TransformingIteratorTest {
   @Test
   public void testCreatingIllegalVisbility() throws Exception {
     // illegal visibility created by transform should be filtered on scan, even if evaluation is done
-    IteratorSetting cfg = new IteratorSetting(21, IllegalVisKeyTransformingIterator.class);
-    cfg.setName("keyTransformIter");
-    scanner.addScanIterator(cfg);
+    setUpTransformIterator(IllegalVisKeyTransformingIterator.class, false);
     checkExpected(new TreeMap<Key,Value>());
 
     // ensure illegal vis is supressed when evaluations is done
-    scanner.removeScanIterator("keyTransformIter");
     setUpTransformIterator(IllegalVisKeyTransformingIterator.class);
     checkExpected(new TreeMap<Key,Value>());
   }
@@ -196,26 +193,24 @@ public class TransformingIteratorTest {
   @Test
   public void testRangeStart() throws Exception {
     setUpTransformIterator(ColVisReversingKeyTransformingIterator.class);
-    scanner.setRange(new Range(new Key("row1", "cf2", "cq2", "vis1"), true, new Key("row1", "cf2", "cq3"), false));
 
     TreeMap<Key,Value> expected = new TreeMap<Key,Value>();
     putExpected(expected, 1, 2, 2, 1, PartialKey.ROW_COLFAM_COLQUAL); // before the range start, but transforms in the range
     putExpected(expected, 1, 2, 2, 2, PartialKey.ROW_COLFAM_COLQUAL);
 
-    checkExpected(expected);
+    checkExpected(new Range(new Key("row1", "cf2", "cq2", "vis1"), true, new Key("row1", "cf2", "cq3"), false), expected);
   }
 
   @Test
   public void testRangeEnd() throws Exception {
     setUpTransformIterator(ColVisReversingKeyTransformingIterator.class);
-    scanner.setRange(new Range(new Key("row1", "cf2", "cq2"), true, new Key("row1", "cf2", "cq2", "vis2"), false));
 
     TreeMap<Key,Value> expected = new TreeMap<Key,Value>();
     // putExpected(expected, 1, 2, 2, 1, part); // transforms vis outside range end
     putExpected(expected, 1, 2, 2, 2, PartialKey.ROW_COLFAM_COLQUAL);
     putExpected(expected, 1, 2, 2, 3, PartialKey.ROW_COLFAM_COLQUAL);
 
-    checkExpected(expected);
+    checkExpected(new Range(new Key("row1", "cf2", "cq2"), true, new Key("row1", "cf2", "cq2", "vis2"), false), expected);
   }
 
   @Test
@@ -224,13 +219,12 @@ public class TransformingIteratorTest {
     // Set a range that is before all of the untransformed data. However,
     // the data with untransformed col fam cf3 will transform to cf0 and
     // be inside the range.
-    scanner.setRange(new Range(new Key("row1", "cf0"), true, new Key("row1", "cf1"), false));
 
     TreeMap<Key,Value> expected = new TreeMap<Key,Value>();
     for (int cq = 1; cq <= 3; ++cq)
       for (int cv = 1; cv <= 3; ++cv)
         putExpected(expected, 1, 3, cq, cv, PartialKey.ROW);
-    checkExpected(expected);
+    checkExpected(new Range(new Key("row1", "cf0"), true, new Key("row1", "cf1"), false), expected);
   }
 
   @Test
@@ -238,8 +232,7 @@ public class TransformingIteratorTest {
     // Set a range that's after all data and make sure we don't
     // somehow return something.
     setUpTransformIterator(ColFamReversingKeyTransformingIterator.class);
-    scanner.setRange(new Range(new Key("row4"), null));
-    checkExpected(new TreeMap<Key,Value>());
+    checkExpected(new Range(new Key("row4"), null), new TreeMap<Key,Value>());
   }
 
   @Test
@@ -272,53 +265,47 @@ public class TransformingIteratorTest {
     // put in the expectations.
     int expectedCF = 1;
     setUpTransformIterator(ColFamReversingKeyTransformingIterator.class);
-    scanner.fetchColumnFamily(new Text("cf2"));
 
     TreeMap<Key,Value> expected = new TreeMap<Key,Value>();
     for (int row = 1; row <= 3; ++row)
       for (int cq = 1; cq <= 3; ++cq)
         for (int cv = 1; cv <= 3; ++cv)
           putExpected(expected, row, expectedCF, cq, cv, PartialKey.ROW);
-    checkExpected(expected);
+    checkExpected(expected, "cf2");
   }
 
   @Test
   public void testDeepCopy() throws Exception {
-    connector.tableOperations().create("shard_table");
-
-    BatchWriter bw = connector.createBatchWriter("shard_table", new BatchWriterConfig());
-
     ColumnVisibility vis1 = new ColumnVisibility("vis1");
     ColumnVisibility vis3 = new ColumnVisibility("vis3");
 
-    Mutation m1 = new Mutation("shard001");
-    m1.put("foo", "doc02", vis1, "");
-    m1.put("dog", "doc02", vis3, "");
-    m1.put("cat", "doc02", vis3, "");
+    data.clear();
 
-    m1.put("bar", "doc03", vis1, "");
-    m1.put("dog", "doc03", vis3, "");
-    m1.put("cat", "doc03", vis3, "");
+    Value ev = new Value("".getBytes());
 
-    bw.addMutation(m1);
-    bw.close();
+    data.put(new Key("shard001", "foo", "doc02", vis1, 78), ev);
+    data.put(new Key("shard001", "dog", "doc02", vis3, 78), ev);
+    data.put(new Key("shard001", "cat", "doc02", vis3, 78), ev);
 
-    BatchScanner bs = connector.createBatchScanner("shard_table", authorizations, 1);
+    data.put(new Key("shard001", "bar", "doc03", vis1, 78), ev);
+    data.put(new Key("shard001", "dog", "doc03", vis3, 78), ev);
+    data.put(new Key("shard001", "cat", "doc03", vis3, 78), ev);
+
+    setUpTransformIterator(ColVisReversingKeyTransformingIterator.class);
 
-    bs.addScanIterator(new IteratorSetting(21, ColVisReversingKeyTransformingIterator.class));
+    IntersectingIterator iiIter = new IntersectingIterator();
     IteratorSetting iicfg = new IteratorSetting(22, IntersectingIterator.class);
     IntersectingIterator.setColumnFamilies(iicfg, new Text[] {new Text("foo"), new Text("dog"), new Text("cat")});
-    bs.addScanIterator(iicfg);
-    bs.setRanges(Collections.singleton(new Range()));
+    iiIter.init(titer, iicfg.getOptions(), null);
 
-    Iterator<Entry<Key,Value>> iter = bs.iterator();
-    assertTrue(iter.hasNext());
-    Key docKey = iter.next().getKey();
+    iiIter.seek(new Range(), new HashSet<ByteSequence>(), false);
+
+    assertTrue(iiIter.hasTop());
+    Key docKey = iiIter.getTopKey();
     assertEquals("shard001", docKey.getRowData().toString());
     assertEquals("doc02", docKey.getColumnQualifierData().toString());
-    assertFalse(iter.hasNext());
-
-    bs.close();
+    iiIter.next();
+    assertFalse(iiIter.hasTop());
   }
 
   @Test
@@ -329,14 +316,13 @@ public class TransformingIteratorTest {
     // put in the expectations.
     int expectedCF = 1;
     setUpTransformIterator(ColFamReversingCompactionKeyTransformingIterator.class);
-    scanner.fetchColumnFamily(new Text("cf2"));
 
     TreeMap<Key,Value> expected = new TreeMap<Key,Value>();
     for (int row = 1; row <= 3; ++row)
       for (int cq = 1; cq <= 3; ++cq)
         for (int cv = 1; cv <= 3; ++cv)
           putExpected(expected, row, expectedCF, cq, cv, PartialKey.ROW);
-    checkExpected(expected);
+    checkExpected(expected, "cf2");
   }
 
   @Test
@@ -381,9 +367,12 @@ public class TransformingIteratorTest {
   public void testDupes() throws Exception {
     setUpTransformIterator(DupeTransformingIterator.class);
 
+    titer.seek(new Range(), new HashSet<ByteSequence>(), false);
+
     int count = 0;
-    for (Entry<Key,Value> entry : scanner) {
-      Key key = entry.getKey();
+    while (titer.hasTop()) {
+      Key key = titer.getTopKey();
+      titer.next();
       assertEquals("cf1", key.getColumnFamily().toString());
       assertEquals("cq1", key.getColumnQualifier().toString());
       assertEquals("", key.getColumnVisibility().toString());
@@ -429,13 +418,31 @@ public class TransformingIteratorTest {
     return key;
   }
 
-  private void checkExpected(TreeMap<Key,Value> expectedEntries) {
-    for (Entry<Key,Value> entry : scanner) {
+  private void checkExpected(Range range, TreeMap<Key,Value> expectedEntries) throws IOException {
+    checkExpected(range, new HashSet<ByteSequence>(), expectedEntries);
+  }
+
+  private void checkExpected(TreeMap<Key,Value> expectedEntries, String... fa) throws IOException {
+
+    HashSet<ByteSequence> families = new HashSet<>();
+    for (String family : fa) {
+      families.add(new ArrayByteSequence(family));
+    }
+
+    checkExpected(new Range(), families, expectedEntries);
+  }
+
+  private void checkExpected(Range range, Set<ByteSequence> families, TreeMap<Key,Value> expectedEntries) throws IOException {
+
+    titer.seek(range, families, families.size() != 0);
+
+    while (titer.hasTop()) {
       Entry<Key,Value> expected = expectedEntries.pollFirstEntry();
-      Key actualKey = entry.getKey();
-      Value actualValue = entry.getValue();
+      Key actualKey = titer.getTopKey();
+      Value actualValue = titer.getTopValue();
+      titer.next();
 
-      assertNotNull("Ran out of expected entries on: " + entry, expected);
+      assertNotNull("Ran out of expected entries on: " + actualKey, expected);
       assertEquals("Key mismatch", expected.getKey(), actualKey);
       assertEquals("Value mismatch", expected.getValue(), actualValue);
     }
@@ -480,8 +487,8 @@ public class TransformingIteratorTest {
     return new Text(sb.toString());
   }
 
-  private static Mutation createDefaultMutation(String row) {
-    Mutation m = new Mutation(row);
+  private static void generateRow(TreeMap<Key,Value> data, String row) {
+
     for (int cfID = 1; cfID <= 3; ++cfID) {
       for (int cqID = 1; cqID <= 3; ++cqID) {
         for (int cvID = 1; cvID <= 3; ++cvID) {
@@ -491,11 +498,13 @@ public class TransformingIteratorTest {
           long ts = 100 * cfID + 10 * cqID + cvID;
           String val = "val" + ts;
 
-          m.put(cf, cq, new ColumnVisibility(cv), ts, val);
+          Key k = new Key(row, cf, cq, cv, ts);
+          Value v = new Value(val.getBytes());
+          data.put(k, v);
         }
       }
     }
-    return m;
+
   }
 
   private static Key reverseKeyPart(Key originalKey, PartialKey part) {
@@ -666,6 +675,13 @@ public class TransformingIteratorTest {
     private Value topValue = new Value();
 
     @Override
+    public SortedKeyValueIterator<Key,Value> deepCopy(IteratorEnvironment env) {
+      ReuseIterator rei = new ReuseIterator();
+      rei.setSource(getSource().deepCopy(env));
+      return rei;
+    }
+
+    @Override
     public void seek(Range range, Collection<ByteSequence> columnFamilies, boolean inclusive) throws IOException {
       super.seek(range, columnFamilies, inclusive);
       loadTop();

http://git-wip-us.apache.org/repos/asf/accumulo/blob/66c62e5f/server/base/src/main/java/org/apache/accumulo/server/util/MetadataTableUtil.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/server/util/MetadataTableUtil.java b/server/base/src/main/java/org/apache/accumulo/server/util/MetadataTableUtil.java
index bcfbbc8..d4ec4f8 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/util/MetadataTableUtil.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/util/MetadataTableUtil.java
@@ -94,6 +94,7 @@ import org.apache.zookeeper.KeeperException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Optional;
 import static com.google.common.util.concurrent.Uninterruptibles.sleepUninterruptibly;
 
@@ -706,10 +707,7 @@ public class MetadataTableUtil {
     return m;
   }
 
-  private static Scanner createCloneScanner(String tableId, Connector conn) throws TableNotFoundException {
-    String tableName = MetadataTable.NAME;
-    if (tableId.equals(MetadataTable.ID))
-      tableName = RootTable.NAME;
+  private static Scanner createCloneScanner(String tableName, String tableId, Connector conn) throws TableNotFoundException {
     Scanner mscanner = new IsolatedScanner(conn.createScanner(tableName, Authorizations.EMPTY));
     mscanner.setRange(new KeyExtent(new Text(tableId), null, null).toMetadataRange());
     mscanner.fetchColumnFamily(DataFileColumnFamily.NAME);
@@ -721,12 +719,14 @@ public class MetadataTableUtil {
     return mscanner;
   }
 
-  static void initializeClone(String srcTableId, String tableId, Connector conn, BatchWriter bw) throws TableNotFoundException, MutationsRejectedException {
+  @VisibleForTesting
+  public static void initializeClone(String tableName, String srcTableId, String tableId, Connector conn, BatchWriter bw) throws TableNotFoundException,
+      MutationsRejectedException {
     TabletIterator ti;
     if (srcTableId.equals(MetadataTable.ID))
-      ti = new TabletIterator(createCloneScanner(srcTableId, conn), new Range(), true, true);
+      ti = new TabletIterator(createCloneScanner(tableName, srcTableId, conn), new Range(), true, true);
     else
-      ti = new TabletIterator(createCloneScanner(srcTableId, conn), new KeyExtent(new Text(srcTableId), null, null).toMetadataRange(), true, true);
+      ti = new TabletIterator(createCloneScanner(tableName, srcTableId, conn), new KeyExtent(new Text(srcTableId), null, null).toMetadataRange(), true, true);
 
     if (!ti.hasNext())
       throw new RuntimeException(" table deleted during clone?  srcTableId = " + srcTableId);
@@ -741,10 +741,13 @@ public class MetadataTableUtil {
     return new KeyExtent(new Text("0"), endRow1, null).compareTo(new KeyExtent(new Text("0"), endRow2, null));
   }
 
-  static int checkClone(String srcTableId, String tableId, Connector conn, BatchWriter bw) throws TableNotFoundException, MutationsRejectedException {
-    TabletIterator srcIter = new TabletIterator(createCloneScanner(srcTableId, conn), new KeyExtent(new Text(srcTableId), null, null).toMetadataRange(), true,
-        true);
-    TabletIterator cloneIter = new TabletIterator(createCloneScanner(tableId, conn), new KeyExtent(new Text(tableId), null, null).toMetadataRange(), true, true);
+  @VisibleForTesting
+  public static int checkClone(String tableName, String srcTableId, String tableId, Connector conn, BatchWriter bw) throws TableNotFoundException,
+      MutationsRejectedException {
+    TabletIterator srcIter = new TabletIterator(createCloneScanner(tableName, srcTableId, conn),
+        new KeyExtent(new Text(srcTableId), null, null).toMetadataRange(), true, true);
+    TabletIterator cloneIter = new TabletIterator(createCloneScanner(tableName, tableId, conn), new KeyExtent(new Text(tableId), null, null).toMetadataRange(),
+        true, true);
 
     if (!cloneIter.hasNext() || !srcIter.hasNext())
       throw new RuntimeException(" table deleted during clone?  srcTableId = " + srcTableId + " tableId=" + tableId);
@@ -831,12 +834,12 @@ public class MetadataTableUtil {
     while (true) {
 
       try {
-        initializeClone(srcTableId, tableId, conn, bw);
+        initializeClone(MetadataTable.NAME, srcTableId, tableId, conn, bw);
 
         // the following loop looks changes in the file that occurred during the copy.. if files were dereferenced then they could have been GCed
 
         while (true) {
-          int rewrites = checkClone(srcTableId, tableId, conn, bw);
+          int rewrites = checkClone(MetadataTable.NAME, srcTableId, tableId, conn, bw);
 
           if (rewrites == 0)
             break;

http://git-wip-us.apache.org/repos/asf/accumulo/blob/66c62e5f/server/base/src/test/java/org/apache/accumulo/server/master/balancer/TableLoadBalancerTest.java
----------------------------------------------------------------------
diff --git a/server/base/src/test/java/org/apache/accumulo/server/master/balancer/TableLoadBalancerTest.java b/server/base/src/test/java/org/apache/accumulo/server/master/balancer/TableLoadBalancerTest.java
index 7bf5d2d..de853d5 100644
--- a/server/base/src/test/java/org/apache/accumulo/server/master/balancer/TableLoadBalancerTest.java
+++ b/server/base/src/test/java/org/apache/accumulo/server/master/balancer/TableLoadBalancerTest.java
@@ -24,12 +24,11 @@ import java.util.Map;
 import java.util.Set;
 import java.util.SortedMap;
 import java.util.TreeMap;
+import java.util.UUID;
 
-import org.apache.accumulo.core.client.Connector;
 import org.apache.accumulo.core.client.Instance;
 import org.apache.accumulo.core.client.admin.TableOperations;
 import org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException;
-import org.apache.accumulo.core.client.security.tokens.PasswordToken;
 import org.apache.accumulo.core.conf.DefaultConfiguration;
 import org.apache.accumulo.core.conf.Property;
 import org.apache.accumulo.core.data.impl.KeyExtent;
@@ -42,13 +41,17 @@ import org.apache.accumulo.server.master.state.TServerInstance;
 import org.apache.accumulo.server.master.state.TabletMigration;
 import org.apache.hadoop.io.Text;
 import org.apache.thrift.TException;
+import org.easymock.EasyMock;
 import org.junit.Assert;
 import org.junit.Test;
 
+import com.google.common.collect.ImmutableMap;
 import com.google.common.net.HostAndPort;
 
 public class TableLoadBalancerTest {
 
+  private static Map<String,String> TABLE_ID_MAP = ImmutableMap.of("t1", "a1", "t2", "b12", "t3", "c4");
+
   static private TServerInstance mkts(String address, String session) throws Exception {
     return new TServerInstance(HostAndPort.fromParts(address, 1234), session);
   }
@@ -71,8 +74,6 @@ public class TableLoadBalancerTest {
     return result;
   }
 
-  static Instance instance = new org.apache.accumulo.core.client.mock.MockInstance(TableLoadBalancerTest.class.getName());
-
   static SortedMap<TServerInstance,TabletServerStatus> state;
 
   static List<TabletStats> generateFakeTablets(TServerInstance tserver, String tableId) {
@@ -95,6 +96,9 @@ public class TableLoadBalancerTest {
     }
 
     @Override
+    public void init(ServerConfigurationFactory conf) {}
+
+    @Override
     public List<TabletStats> getOnlineTabletsForTable(TServerInstance tserver, String tableId) throws ThriftSecurityException, TException {
       return generateFakeTablets(tserver, tableId);
     }
@@ -107,6 +111,9 @@ public class TableLoadBalancerTest {
       super();
     }
 
+    @Override
+    public void init(ServerConfigurationFactory conf) {}
+
     // use our new classname to test class loading
     @Override
     protected String getLoadBalancerClassNameForTable(String table) {
@@ -118,15 +125,26 @@ public class TableLoadBalancerTest {
     public List<TabletStats> getOnlineTabletsForTable(TServerInstance tserver, String tableId) throws ThriftSecurityException, TException {
       return generateFakeTablets(tserver, tableId);
     }
+
+    @Override
+    protected TableOperations getTableOperations() {
+      TableOperations tops = EasyMock.createMock(TableOperations.class);
+      EasyMock.expect(tops.tableIdMap()).andReturn(TABLE_ID_MAP).anyTimes();
+      EasyMock.replay(tops);
+      return tops;
+    }
   }
 
   @Test
   public void test() throws Exception {
-    Connector c = instance.getConnector("user", new PasswordToken("pass"));
-    ServerConfigurationFactory confFactory = new ServerConfigurationFactory(instance) {
+    final Instance inst = EasyMock.createMock(Instance.class);
+    EasyMock.expect(inst.getInstanceID()).andReturn(UUID.nameUUIDFromBytes(new byte[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 0}).toString()).anyTimes();
+    EasyMock.replay(inst);
+
+    ServerConfigurationFactory confFactory = new ServerConfigurationFactory(inst) {
       @Override
       public TableConfiguration getTableConfiguration(String tableId) {
-        return new TableConfiguration(instance, tableId, null) {
+        return new TableConfiguration(inst, tableId, null) {
           @Override
           public String get(Property property) {
             // fake the get table configuration so the test doesn't try to look in zookeeper for per-table classpath stuff
@@ -135,11 +153,8 @@ public class TableLoadBalancerTest {
         };
       }
     };
-    TableOperations tops = c.tableOperations();
-    tops.create("t1");
-    tops.create("t2");
-    tops.create("t3");
-    String t1Id = tops.tableIdMap().get("t1"), t2Id = tops.tableIdMap().get("t2"), t3Id = tops.tableIdMap().get("t3");
+
+    String t1Id = TABLE_ID_MAP.get("t1"), t2Id = TABLE_ID_MAP.get("t2"), t3Id = TABLE_ID_MAP.get("t3");
     state = new TreeMap<TServerInstance,TabletServerStatus>();
     TServerInstance svr = mkts("10.0.0.1", "0x01020304");
     state.put(svr, status(t1Id, 10, t2Id, 10, t3Id, 10));

http://git-wip-us.apache.org/repos/asf/accumulo/blob/66c62e5f/server/base/src/test/java/org/apache/accumulo/server/security/SystemCredentialsTest.java
----------------------------------------------------------------------
diff --git a/server/base/src/test/java/org/apache/accumulo/server/security/SystemCredentialsTest.java b/server/base/src/test/java/org/apache/accumulo/server/security/SystemCredentialsTest.java
index 81a3892..57c68c4 100644
--- a/server/base/src/test/java/org/apache/accumulo/server/security/SystemCredentialsTest.java
+++ b/server/base/src/test/java/org/apache/accumulo/server/security/SystemCredentialsTest.java
@@ -28,6 +28,7 @@ import org.apache.accumulo.core.client.impl.ConnectorImpl;
 import org.apache.accumulo.core.client.impl.Credentials;
 import org.apache.accumulo.server.ServerConstants;
 import org.apache.accumulo.server.security.SystemCredentials.SystemToken;
+import org.easymock.EasyMock;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Rule;
@@ -59,7 +60,9 @@ public class SystemCredentialsTest {
 
   @Before
   public void setupInstance() {
-    inst = new org.apache.accumulo.core.client.mock.MockInstance(test.getMethodName());
+    inst = EasyMock.createMock(Instance.class);
+    EasyMock.expect(inst.getInstanceID()).andReturn(UUID.nameUUIDFromBytes(new byte[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 0}).toString()).anyTimes();
+    EasyMock.replay(inst);
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/accumulo/blob/66c62e5f/server/base/src/test/java/org/apache/accumulo/server/util/CloneTest.java
----------------------------------------------------------------------
diff --git a/server/base/src/test/java/org/apache/accumulo/server/util/CloneTest.java b/server/base/src/test/java/org/apache/accumulo/server/util/CloneTest.java
deleted file mode 100644
index aa7cad4..0000000
--- a/server/base/src/test/java/org/apache/accumulo/server/util/CloneTest.java
+++ /dev/null
@@ -1,376 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.accumulo.server.util;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.util.HashSet;
-import java.util.Map.Entry;
-
-import org.apache.accumulo.core.client.BatchWriter;
-import org.apache.accumulo.core.client.BatchWriterConfig;
-import org.apache.accumulo.core.client.Connector;
-import org.apache.accumulo.core.client.Instance;
-import org.apache.accumulo.core.client.Scanner;
-import org.apache.accumulo.core.client.security.tokens.PasswordToken;
-import org.apache.accumulo.core.data.Key;
-import org.apache.accumulo.core.data.Mutation;
-import org.apache.accumulo.core.data.Value;
-import org.apache.accumulo.core.data.impl.KeyExtent;
-import org.apache.accumulo.core.metadata.MetadataTable;
-import org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection;
-import org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection.DataFileColumnFamily;
-import org.apache.accumulo.core.security.Authorizations;
-import org.apache.hadoop.io.Text;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TestName;
-
-public class CloneTest {
-
-  private Connector conn;
-
-  @Rule
-  public TestName test = new TestName();
-
-  @Before
-  public void setupInstance() throws Exception {
-    Instance inst = new org.apache.accumulo.core.client.mock.MockInstance(test.getMethodName());
-    conn = inst.getConnector("", new PasswordToken(""));
-  }
-
-  @Test
-  public void testNoFiles() throws Exception {
-    KeyExtent ke = new KeyExtent(new Text("0"), null, null);
-    Mutation mut = ke.getPrevRowUpdateMutation();
-
-    TabletsSection.ServerColumnFamily.TIME_COLUMN.put(mut, new Value("M0".getBytes()));
-    TabletsSection.ServerColumnFamily.DIRECTORY_COLUMN.put(mut, new Value("/default_tablet".getBytes()));
-
-    BatchWriter bw1 = conn.createBatchWriter(MetadataTable.NAME, new BatchWriterConfig());
-
-    bw1.addMutation(mut);
-
-    bw1.close();
-
-    BatchWriter bw2 = conn.createBatchWriter(MetadataTable.NAME, new BatchWriterConfig());
-
-    MetadataTableUtil.initializeClone("0", "1", conn, bw2);
-
-    int rc = MetadataTableUtil.checkClone("0", "1", conn, bw2);
-
-    assertEquals(0, rc);
-
-    // scan tables metadata entries and confirm the same
-
-  }
-
-  @Test
-  public void testFilesChange() throws Exception {
-    KeyExtent ke = new KeyExtent(new Text("0"), null, null);
-    Mutation mut = ke.getPrevRowUpdateMutation();
-
-    TabletsSection.ServerColumnFamily.TIME_COLUMN.put(mut, new Value("M0".getBytes()));
-    TabletsSection.ServerColumnFamily.DIRECTORY_COLUMN.put(mut, new Value("/default_tablet".getBytes()));
-    mut.put(DataFileColumnFamily.NAME.toString(), "/default_tablet/0_0.rf", "1,200");
-
-    BatchWriter bw1 = conn.createBatchWriter(MetadataTable.NAME, new BatchWriterConfig());
-
-    bw1.addMutation(mut);
-
-    bw1.flush();
-
-    BatchWriter bw2 = conn.createBatchWriter(MetadataTable.NAME, new BatchWriterConfig());
-
-    MetadataTableUtil.initializeClone("0", "1", conn, bw2);
-
-    Mutation mut2 = new Mutation(ke.getMetadataEntry());
-    mut2.putDelete(DataFileColumnFamily.NAME.toString(), "/default_tablet/0_0.rf");
-    mut2.put(DataFileColumnFamily.NAME.toString(), "/default_tablet/1_0.rf", "2,300");
-
-    bw1.addMutation(mut2);
-    bw1.flush();
-
-    int rc = MetadataTableUtil.checkClone("0", "1", conn, bw2);
-
-    assertEquals(1, rc);
-
-    rc = MetadataTableUtil.checkClone("0", "1", conn, bw2);
-
-    assertEquals(0, rc);
-
-    Scanner scanner = conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY);
-    scanner.setRange(new KeyExtent(new Text("1"), null, null).toMetadataRange());
-
-    HashSet<String> files = new HashSet<String>();
-
-    for (Entry<Key,Value> entry : scanner) {
-      if (entry.getKey().getColumnFamily().equals(DataFileColumnFamily.NAME))
-        files.add(entry.getKey().getColumnQualifier().toString());
-    }
-
-    assertEquals(1, files.size());
-    assertTrue(files.contains("../0/default_tablet/1_0.rf"));
-
-  }
-
-  // test split where files of children are the same
-  @Test
-  public void testSplit1() throws Exception {
-    BatchWriter bw1 = conn.createBatchWriter(MetadataTable.NAME, new BatchWriterConfig());
-
-    bw1.addMutation(createTablet("0", null, null, "/default_tablet", "/default_tablet/0_0.rf"));
-
-    bw1.flush();
-
-    BatchWriter bw2 = conn.createBatchWriter(MetadataTable.NAME, new BatchWriterConfig());
-
-    MetadataTableUtil.initializeClone("0", "1", conn, bw2);
-
-    bw1.addMutation(createTablet("0", "m", null, "/default_tablet", "/default_tablet/0_0.rf"));
-    bw1.addMutation(createTablet("0", null, "m", "/t-1", "/default_tablet/0_0.rf"));
-
-    bw1.flush();
-
-    int rc = MetadataTableUtil.checkClone("0", "1", conn, bw2);
-
-    assertEquals(0, rc);
-
-    Scanner scanner = conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY);
-    scanner.setRange(new KeyExtent(new Text("1"), null, null).toMetadataRange());
-
-    HashSet<String> files = new HashSet<String>();
-
-    int count = 0;
-    for (Entry<Key,Value> entry : scanner) {
-      if (entry.getKey().getColumnFamily().equals(DataFileColumnFamily.NAME)) {
-        files.add(entry.getKey().getColumnQualifier().toString());
-        count++;
-      }
-    }
-
-    assertEquals(1, count);
-    assertEquals(1, files.size());
-    assertTrue(files.contains("../0/default_tablet/0_0.rf"));
-  }
-
-  // test split where files of children differ... like majc and split occurred
-  @Test
-  public void testSplit2() throws Exception {
-    BatchWriter bw1 = conn.createBatchWriter(MetadataTable.NAME, new BatchWriterConfig());
-
-    bw1.addMutation(createTablet("0", null, null, "/default_tablet", "/default_tablet/0_0.rf"));
-
-    bw1.flush();
-
-    BatchWriter bw2 = conn.createBatchWriter(MetadataTable.NAME, new BatchWriterConfig());
-
-    MetadataTableUtil.initializeClone("0", "1", conn, bw2);
-
-    bw1.addMutation(createTablet("0", "m", null, "/default_tablet", "/default_tablet/1_0.rf"));
-    Mutation mut3 = createTablet("0", null, "m", "/t-1", "/default_tablet/1_0.rf");
-    mut3.putDelete(DataFileColumnFamily.NAME.toString(), "/default_tablet/0_0.rf");
-    bw1.addMutation(mut3);
-
-    bw1.flush();
-
-    int rc = MetadataTableUtil.checkClone("0", "1", conn, bw2);
-
-    assertEquals(1, rc);
-
-    rc = MetadataTableUtil.checkClone("0", "1", conn, bw2);
-
-    assertEquals(0, rc);
-
-    Scanner scanner = conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY);
-    scanner.setRange(new KeyExtent(new Text("1"), null, null).toMetadataRange());
-
-    HashSet<String> files = new HashSet<String>();
-
-    int count = 0;
-
-    for (Entry<Key,Value> entry : scanner) {
-      if (entry.getKey().getColumnFamily().equals(DataFileColumnFamily.NAME)) {
-        files.add(entry.getKey().getColumnQualifier().toString());
-        count++;
-      }
-    }
-
-    assertEquals(1, files.size());
-    assertEquals(2, count);
-    assertTrue(files.contains("../0/default_tablet/1_0.rf"));
-  }
-
-  private static Mutation deleteTablet(String tid, String endRow, String prevRow, String dir, String file) throws Exception {
-    KeyExtent ke = new KeyExtent(new Text(tid), endRow == null ? null : new Text(endRow), prevRow == null ? null : new Text(prevRow));
-    Mutation mut = new Mutation(ke.getMetadataEntry());
-    TabletsSection.TabletColumnFamily.PREV_ROW_COLUMN.putDelete(mut);
-    TabletsSection.ServerColumnFamily.TIME_COLUMN.putDelete(mut);
-    TabletsSection.ServerColumnFamily.DIRECTORY_COLUMN.putDelete(mut);
-    mut.putDelete(DataFileColumnFamily.NAME.toString(), file);
-
-    return mut;
-  }
-
-  private static Mutation createTablet(String tid, String endRow, String prevRow, String dir, String file) throws Exception {
-    KeyExtent ke = new KeyExtent(new Text(tid), endRow == null ? null : new Text(endRow), prevRow == null ? null : new Text(prevRow));
-    Mutation mut = ke.getPrevRowUpdateMutation();
-
-    TabletsSection.ServerColumnFamily.TIME_COLUMN.put(mut, new Value("M0".getBytes()));
-    TabletsSection.ServerColumnFamily.DIRECTORY_COLUMN.put(mut, new Value(dir.getBytes()));
-    mut.put(DataFileColumnFamily.NAME.toString(), file, "10,200");
-
-    return mut;
-  }
-
-  // test two tablets splitting into four
-  @Test
-  public void testSplit3() throws Exception {
-    BatchWriter bw1 = conn.createBatchWriter(MetadataTable.NAME, new BatchWriterConfig());
-
-    bw1.addMutation(createTablet("0", "m", null, "/d1", "/d1/file1"));
-    bw1.addMutation(createTablet("0", null, "m", "/d2", "/d2/file2"));
-
-    bw1.flush();
-
-    BatchWriter bw2 = conn.createBatchWriter(MetadataTable.NAME, new BatchWriterConfig());
-
-    MetadataTableUtil.initializeClone("0", "1", conn, bw2);
-
-    bw1.addMutation(createTablet("0", "f", null, "/d1", "/d1/file3"));
-    bw1.addMutation(createTablet("0", "m", "f", "/d3", "/d1/file1"));
-    bw1.addMutation(createTablet("0", "s", "m", "/d2", "/d2/file2"));
-    bw1.addMutation(createTablet("0", null, "s", "/d4", "/d2/file2"));
-
-    bw1.flush();
-
-    int rc = MetadataTableUtil.checkClone("0", "1", conn, bw2);
-
-    assertEquals(0, rc);
-
-    Scanner scanner = conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY);
-    scanner.setRange(new KeyExtent(new Text("1"), null, null).toMetadataRange());
-
-    HashSet<String> files = new HashSet<String>();
-
-    int count = 0;
-    for (Entry<Key,Value> entry : scanner) {
-      if (entry.getKey().getColumnFamily().equals(DataFileColumnFamily.NAME)) {
-        files.add(entry.getKey().getColumnQualifier().toString());
-        count++;
-      }
-    }
-
-    assertEquals(2, count);
-    assertEquals(2, files.size());
-    assertTrue(files.contains("../0/d1/file1"));
-    assertTrue(files.contains("../0/d2/file2"));
-  }
-
-  // test cloned marker
-  @Test
-  public void testClonedMarker() throws Exception {
-    BatchWriter bw1 = conn.createBatchWriter(MetadataTable.NAME, new BatchWriterConfig());
-
-    bw1.addMutation(createTablet("0", "m", null, "/d1", "/d1/file1"));
-    bw1.addMutation(createTablet("0", null, "m", "/d2", "/d2/file2"));
-
-    bw1.flush();
-
-    BatchWriter bw2 = conn.createBatchWriter(MetadataTable.NAME, new BatchWriterConfig());
-
-    MetadataTableUtil.initializeClone("0", "1", conn, bw2);
-
-    bw1.addMutation(deleteTablet("0", "m", null, "/d1", "/d1/file1"));
-    bw1.addMutation(deleteTablet("0", null, "m", "/d2", "/d2/file2"));
-
-    bw1.flush();
-
-    bw1.addMutation(createTablet("0", "f", null, "/d1", "/d1/file3"));
-    bw1.addMutation(createTablet("0", "m", "f", "/d3", "/d1/file1"));
-    bw1.addMutation(createTablet("0", "s", "m", "/d2", "/d2/file3"));
-    bw1.addMutation(createTablet("0", null, "s", "/d4", "/d4/file3"));
-
-    bw1.flush();
-
-    int rc = MetadataTableUtil.checkClone("0", "1", conn, bw2);
-
-    assertEquals(1, rc);
-
-    bw1.addMutation(deleteTablet("0", "m", "f", "/d3", "/d1/file1"));
-
-    bw1.flush();
-
-    bw1.addMutation(createTablet("0", "m", "f", "/d3", "/d1/file3"));
-
-    bw1.flush();
-
-    rc = MetadataTableUtil.checkClone("0", "1", conn, bw2);
-
-    assertEquals(0, rc);
-
-    Scanner scanner = conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY);
-    scanner.setRange(new KeyExtent(new Text("1"), null, null).toMetadataRange());
-
-    HashSet<String> files = new HashSet<String>();
-
-    int count = 0;
-    for (Entry<Key,Value> entry : scanner) {
-      if (entry.getKey().getColumnFamily().equals(DataFileColumnFamily.NAME)) {
-        files.add(entry.getKey().getColumnQualifier().toString());
-        count++;
-      }
-    }
-
-    assertEquals(3, count);
-    assertEquals(3, files.size());
-    assertTrue(files.contains("../0/d1/file1"));
-    assertTrue(files.contains("../0/d2/file3"));
-    assertTrue(files.contains("../0/d4/file3"));
-  }
-
-  // test two tablets splitting into four
-  @Test
-  public void testMerge() throws Exception {
-    BatchWriter bw1 = conn.createBatchWriter(MetadataTable.NAME, new BatchWriterConfig());
-
-    bw1.addMutation(createTablet("0", "m", null, "/d1", "/d1/file1"));
-    bw1.addMutation(createTablet("0", null, "m", "/d2", "/d2/file2"));
-
-    bw1.flush();
-
-    BatchWriter bw2 = conn.createBatchWriter(MetadataTable.NAME, new BatchWriterConfig());
-
-    MetadataTableUtil.initializeClone("0", "1", conn, bw2);
-
-    bw1.addMutation(deleteTablet("0", "m", null, "/d1", "/d1/file1"));
-    Mutation mut = createTablet("0", null, null, "/d2", "/d2/file2");
-    mut.put(DataFileColumnFamily.NAME.toString(), "/d1/file1", "10,200");
-    bw1.addMutation(mut);
-
-    bw1.flush();
-
-    try {
-      MetadataTableUtil.checkClone("0", "1", conn, bw2);
-      assertTrue(false);
-    } catch (TabletIterator.TabletDeletedException tde) {}
-
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/66c62e5f/shell/src/test/java/org/apache/accumulo/shell/ShellSetInstanceTest.java
----------------------------------------------------------------------
diff --git a/shell/src/test/java/org/apache/accumulo/shell/ShellSetInstanceTest.java b/shell/src/test/java/org/apache/accumulo/shell/ShellSetInstanceTest.java
index 4d74f65..4d2645b 100644
--- a/shell/src/test/java/org/apache/accumulo/shell/ShellSetInstanceTest.java
+++ b/shell/src/test/java/org/apache/accumulo/shell/ShellSetInstanceTest.java
@@ -49,6 +49,7 @@ import org.apache.log4j.Level;
 import org.easymock.EasyMock;
 import org.junit.After;
 import org.junit.AfterClass;
+import org.junit.Assert;
 import org.junit.Assume;
 import org.junit.Before;
 import org.junit.BeforeClass;
@@ -118,17 +119,15 @@ public class ShellSetInstanceTest {
     SiteConfiguration.clearInstance();
   }
 
+  @Deprecated
   @Test
   public void testSetInstance_Fake() throws Exception {
     ShellOptionsJC opts = createMock(ShellOptionsJC.class);
     expect(opts.isFake()).andReturn(true);
     replay(opts);
-    org.apache.accumulo.core.client.mock.MockInstance theInstance = createMock(org.apache.accumulo.core.client.mock.MockInstance.class);
-    expectNew(org.apache.accumulo.core.client.mock.MockInstance.class, "fake").andReturn(theInstance);
-    replay(theInstance, org.apache.accumulo.core.client.mock.MockInstance.class);
 
     shell.setInstance(opts);
-    verify(theInstance, org.apache.accumulo.core.client.mock.MockInstance.class);
+    Assert.assertTrue(shell.getInstance() instanceof org.apache.accumulo.core.client.mock.MockInstance);
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/accumulo/blob/66c62e5f/test/src/main/java/org/apache/accumulo/test/CloneIT.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/CloneIT.java b/test/src/main/java/org/apache/accumulo/test/CloneIT.java
new file mode 100644
index 0000000..e292b75
--- /dev/null
+++ b/test/src/main/java/org/apache/accumulo/test/CloneIT.java
@@ -0,0 +1,390 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.accumulo.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.HashSet;
+import java.util.Map.Entry;
+
+import org.apache.accumulo.core.client.BatchWriter;
+import org.apache.accumulo.core.client.BatchWriterConfig;
+import org.apache.accumulo.core.client.Connector;
+import org.apache.accumulo.core.client.Scanner;
+import org.apache.accumulo.core.data.Key;
+import org.apache.accumulo.core.data.Mutation;
+import org.apache.accumulo.core.data.Value;
+import org.apache.accumulo.core.data.impl.KeyExtent;
+import org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection;
+import org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection.DataFileColumnFamily;
+import org.apache.accumulo.core.security.Authorizations;
+import org.apache.accumulo.harness.AccumuloClusterHarness;
+import org.apache.accumulo.server.util.MetadataTableUtil;
+import org.apache.accumulo.server.util.TabletIterator;
+import org.apache.hadoop.io.Text;
+import org.junit.Test;
+
+public class CloneIT extends AccumuloClusterHarness {
+
+  @Test
+  public void testNoFiles() throws Exception {
+    Connector conn = getConnector();
+    String tableName = getUniqueNames(1)[0];
+    conn.tableOperations().create(tableName);
+
+    KeyExtent ke = new KeyExtent(new Text("0"), null, null);
+    Mutation mut = ke.getPrevRowUpdateMutation();
+
+    TabletsSection.ServerColumnFamily.TIME_COLUMN.put(mut, new Value("M0".getBytes()));
+    TabletsSection.ServerColumnFamily.DIRECTORY_COLUMN.put(mut, new Value("/default_tablet".getBytes()));
+
+    BatchWriter bw1 = conn.createBatchWriter(tableName, new BatchWriterConfig());
+
+    bw1.addMutation(mut);
+
+    bw1.close();
+
+    BatchWriter bw2 = conn.createBatchWriter(tableName, new BatchWriterConfig());
+
+    MetadataTableUtil.initializeClone(tableName, "0", "1", conn, bw2);
+
+    int rc = MetadataTableUtil.checkClone(tableName, "0", "1", conn, bw2);
+
+    assertEquals(0, rc);
+
+    // scan tables metadata entries and confirm the same
+
+  }
+
+  @Test
+  public void testFilesChange() throws Exception {
+    Connector conn = getConnector();
+    String tableName = getUniqueNames(1)[0];
+    conn.tableOperations().create(tableName);
+
+    KeyExtent ke = new KeyExtent(new Text("0"), null, null);
+    Mutation mut = ke.getPrevRowUpdateMutation();
+
+    TabletsSection.ServerColumnFamily.TIME_COLUMN.put(mut, new Value("M0".getBytes()));
+    TabletsSection.ServerColumnFamily.DIRECTORY_COLUMN.put(mut, new Value("/default_tablet".getBytes()));
+    mut.put(DataFileColumnFamily.NAME.toString(), "/default_tablet/0_0.rf", "1,200");
+
+    BatchWriter bw1 = conn.createBatchWriter(tableName, new BatchWriterConfig());
+
+    bw1.addMutation(mut);
+
+    bw1.flush();
+
+    BatchWriter bw2 = conn.createBatchWriter(tableName, new BatchWriterConfig());
+
+    MetadataTableUtil.initializeClone(tableName, "0", "1", conn, bw2);
+
+    Mutation mut2 = new Mutation(ke.getMetadataEntry());
+    mut2.putDelete(DataFileColumnFamily.NAME.toString(), "/default_tablet/0_0.rf");
+    mut2.put(DataFileColumnFamily.NAME.toString(), "/default_tablet/1_0.rf", "2,300");
+
+    bw1.addMutation(mut2);
+    bw1.flush();
+
+    int rc = MetadataTableUtil.checkClone(tableName, "0", "1", conn, bw2);
+
+    assertEquals(1, rc);
+
+    rc = MetadataTableUtil.checkClone(tableName, "0", "1", conn, bw2);
+
+    assertEquals(0, rc);
+
+    Scanner scanner = conn.createScanner(tableName, Authorizations.EMPTY);
+    scanner.setRange(new KeyExtent(new Text("1"), null, null).toMetadataRange());
+
+    HashSet<String> files = new HashSet<String>();
+
+    for (Entry<Key,Value> entry : scanner) {
+      if (entry.getKey().getColumnFamily().equals(DataFileColumnFamily.NAME))
+        files.add(entry.getKey().getColumnQualifier().toString());
+    }
+
+    assertEquals(1, files.size());
+    assertTrue(files.contains("../0/default_tablet/1_0.rf"));
+
+  }
+
+  // test split where files of children are the same
+  @Test
+  public void testSplit1() throws Exception {
+    Connector conn = getConnector();
+    String tableName = getUniqueNames(1)[0];
+    conn.tableOperations().create(tableName);
+
+    BatchWriter bw1 = conn.createBatchWriter(tableName, new BatchWriterConfig());
+
+    bw1.addMutation(createTablet("0", null, null, "/default_tablet", "/default_tablet/0_0.rf"));
+
+    bw1.flush();
+
+    BatchWriter bw2 = conn.createBatchWriter(tableName, new BatchWriterConfig());
+
+    MetadataTableUtil.initializeClone(tableName, "0", "1", conn, bw2);
+
+    bw1.addMutation(createTablet("0", "m", null, "/default_tablet", "/default_tablet/0_0.rf"));
+    bw1.addMutation(createTablet("0", null, "m", "/t-1", "/default_tablet/0_0.rf"));
+
+    bw1.flush();
+
+    int rc = MetadataTableUtil.checkClone(tableName, "0", "1", conn, bw2);
+
+    assertEquals(0, rc);
+
+    Scanner scanner = conn.createScanner(tableName, Authorizations.EMPTY);
+    scanner.setRange(new KeyExtent(new Text("1"), null, null).toMetadataRange());
+
+    HashSet<String> files = new HashSet<String>();
+
+    int count = 0;
+    for (Entry<Key,Value> entry : scanner) {
+      if (entry.getKey().getColumnFamily().equals(DataFileColumnFamily.NAME)) {
+        files.add(entry.getKey().getColumnQualifier().toString());
+        count++;
+      }
+    }
+
+    assertEquals(1, count);
+    assertEquals(1, files.size());
+    assertTrue(files.contains("../0/default_tablet/0_0.rf"));
+  }
+
+  // test split where files of children differ... like majc and split occurred
+  @Test
+  public void testSplit2() throws Exception {
+    Connector conn = getConnector();
+    String tableName = getUniqueNames(1)[0];
+    conn.tableOperations().create(tableName);
+
+    BatchWriter bw1 = conn.createBatchWriter(tableName, new BatchWriterConfig());
+
+    bw1.addMutation(createTablet("0", null, null, "/default_tablet", "/default_tablet/0_0.rf"));
+
+    bw1.flush();
+
+    BatchWriter bw2 = conn.createBatchWriter(tableName, new BatchWriterConfig());
+
+    MetadataTableUtil.initializeClone(tableName, "0", "1", conn, bw2);
+
+    bw1.addMutation(createTablet("0", "m", null, "/default_tablet", "/default_tablet/1_0.rf"));
+    Mutation mut3 = createTablet("0", null, "m", "/t-1", "/default_tablet/1_0.rf");
+    mut3.putDelete(DataFileColumnFamily.NAME.toString(), "/default_tablet/0_0.rf");
+    bw1.addMutation(mut3);
+
+    bw1.flush();
+
+    int rc = MetadataTableUtil.checkClone(tableName, "0", "1", conn, bw2);
+
+    assertEquals(1, rc);
+
+    rc = MetadataTableUtil.checkClone(tableName, "0", "1", conn, bw2);
+
+    assertEquals(0, rc);
+
+    Scanner scanner = conn.createScanner(tableName, Authorizations.EMPTY);
+    scanner.setRange(new KeyExtent(new Text("1"), null, null).toMetadataRange());
+
+    HashSet<String> files = new HashSet<String>();
+
+    int count = 0;
+
+    for (Entry<Key,Value> entry : scanner) {
+      if (entry.getKey().getColumnFamily().equals(DataFileColumnFamily.NAME)) {
+        files.add(entry.getKey().getColumnQualifier().toString());
+        count++;
+      }
+    }
+
+    assertEquals(1, files.size());
+    assertEquals(2, count);
+    assertTrue(files.contains("../0/default_tablet/1_0.rf"));
+  }
+
+  private static Mutation deleteTablet(String tid, String endRow, String prevRow, String dir, String file) throws Exception {
+    KeyExtent ke = new KeyExtent(new Text(tid), endRow == null ? null : new Text(endRow), prevRow == null ? null : new Text(prevRow));
+    Mutation mut = new Mutation(ke.getMetadataEntry());
+    TabletsSection.TabletColumnFamily.PREV_ROW_COLUMN.putDelete(mut);
+    TabletsSection.ServerColumnFamily.TIME_COLUMN.putDelete(mut);
+    TabletsSection.ServerColumnFamily.DIRECTORY_COLUMN.putDelete(mut);
+    mut.putDelete(DataFileColumnFamily.NAME.toString(), file);
+
+    return mut;
+  }
+
+  private static Mutation createTablet(String tid, String endRow, String prevRow, String dir, String file) throws Exception {
+    KeyExtent ke = new KeyExtent(new Text(tid), endRow == null ? null : new Text(endRow), prevRow == null ? null : new Text(prevRow));
+    Mutation mut = ke.getPrevRowUpdateMutation();
+
+    TabletsSection.ServerColumnFamily.TIME_COLUMN.put(mut, new Value("M0".getBytes()));
+    TabletsSection.ServerColumnFamily.DIRECTORY_COLUMN.put(mut, new Value(dir.getBytes()));
+    mut.put(DataFileColumnFamily.NAME.toString(), file, "10,200");
+
+    return mut;
+  }
+
+  // test two tablets splitting into four
+  @Test
+  public void testSplit3() throws Exception {
+    Connector conn = getConnector();
+    String tableName = getUniqueNames(1)[0];
+    conn.tableOperations().create(tableName);
+
+    BatchWriter bw1 = conn.createBatchWriter(tableName, new BatchWriterConfig());
+
+    bw1.addMutation(createTablet("0", "m", null, "/d1", "/d1/file1"));
+    bw1.addMutation(createTablet("0", null, "m", "/d2", "/d2/file2"));
+
+    bw1.flush();
+
+    BatchWriter bw2 = conn.createBatchWriter(tableName, new BatchWriterConfig());
+
+    MetadataTableUtil.initializeClone(tableName, "0", "1", conn, bw2);
+
+    bw1.addMutation(createTablet("0", "f", null, "/d1", "/d1/file3"));
+    bw1.addMutation(createTablet("0", "m", "f", "/d3", "/d1/file1"));
+    bw1.addMutation(createTablet("0", "s", "m", "/d2", "/d2/file2"));
+    bw1.addMutation(createTablet("0", null, "s", "/d4", "/d2/file2"));
+
+    bw1.flush();
+
+    int rc = MetadataTableUtil.checkClone(tableName, "0", "1", conn, bw2);
+
+    assertEquals(0, rc);
+
+    Scanner scanner = conn.createScanner(tableName, Authorizations.EMPTY);
+    scanner.setRange(new KeyExtent(new Text("1"), null, null).toMetadataRange());
+
+    HashSet<String> files = new HashSet<String>();
+
+    int count = 0;
+    for (Entry<Key,Value> entry : scanner) {
+      if (entry.getKey().getColumnFamily().equals(DataFileColumnFamily.NAME)) {
+        files.add(entry.getKey().getColumnQualifier().toString());
+        count++;
+      }
+    }
+
+    assertEquals(2, count);
+    assertEquals(2, files.size());
+    assertTrue(files.contains("../0/d1/file1"));
+    assertTrue(files.contains("../0/d2/file2"));
+  }
+
+  // test cloned marker
+  @Test
+  public void testClonedMarker() throws Exception {
+    Connector conn = getConnector();
+    String tableName = getUniqueNames(1)[0];
+    conn.tableOperations().create(tableName);
+
+    BatchWriter bw1 = conn.createBatchWriter(tableName, new BatchWriterConfig());
+
+    bw1.addMutation(createTablet("0", "m", null, "/d1", "/d1/file1"));
+    bw1.addMutation(createTablet("0", null, "m", "/d2", "/d2/file2"));
+
+    bw1.flush();
+
+    BatchWriter bw2 = conn.createBatchWriter(tableName, new BatchWriterConfig());
+
+    MetadataTableUtil.initializeClone(tableName, "0", "1", conn, bw2);
+
+    bw1.addMutation(deleteTablet("0", "m", null, "/d1", "/d1/file1"));
+    bw1.addMutation(deleteTablet("0", null, "m", "/d2", "/d2/file2"));
+
+    bw1.flush();
+
+    bw1.addMutation(createTablet("0", "f", null, "/d1", "/d1/file3"));
+    bw1.addMutation(createTablet("0", "m", "f", "/d3", "/d1/file1"));
+    bw1.addMutation(createTablet("0", "s", "m", "/d2", "/d2/file3"));
+    bw1.addMutation(createTablet("0", null, "s", "/d4", "/d4/file3"));
+
+    bw1.flush();
+
+    int rc = MetadataTableUtil.checkClone(tableName, "0", "1", conn, bw2);
+
+    assertEquals(1, rc);
+
+    bw1.addMutation(deleteTablet("0", "m", "f", "/d3", "/d1/file1"));
+
+    bw1.flush();
+
+    bw1.addMutation(createTablet("0", "m", "f", "/d3", "/d1/file3"));
+
+    bw1.flush();
+
+    rc = MetadataTableUtil.checkClone(tableName, "0", "1", conn, bw2);
+
+    assertEquals(0, rc);
+
+    Scanner scanner = conn.createScanner(tableName, Authorizations.EMPTY);
+    scanner.setRange(new KeyExtent(new Text("1"), null, null).toMetadataRange());
+
+    HashSet<String> files = new HashSet<String>();
+
+    int count = 0;
+    for (Entry<Key,Value> entry : scanner) {
+      if (entry.getKey().getColumnFamily().equals(DataFileColumnFamily.NAME)) {
+        files.add(entry.getKey().getColumnQualifier().toString());
+        count++;
+      }
+    }
+
+    assertEquals(3, count);
+    assertEquals(3, files.size());
+    assertTrue(files.contains("../0/d1/file1"));
+    assertTrue(files.contains("../0/d2/file3"));
+    assertTrue(files.contains("../0/d4/file3"));
+  }
+
+  // test two tablets splitting into four
+  @Test
+  public void testMerge() throws Exception {
+    Connector conn = getConnector();
+    String tableName = getUniqueNames(1)[0];
+    conn.tableOperations().create(tableName);
+
+    BatchWriter bw1 = conn.createBatchWriter(tableName, new BatchWriterConfig());
+
+    bw1.addMutation(createTablet("0", "m", null, "/d1", "/d1/file1"));
+    bw1.addMutation(createTablet("0", null, "m", "/d2", "/d2/file2"));
+
+    bw1.flush();
+
+    BatchWriter bw2 = conn.createBatchWriter(tableName, new BatchWriterConfig());
+
+    MetadataTableUtil.initializeClone(tableName, "0", "1", conn, bw2);
+
+    bw1.addMutation(deleteTablet("0", "m", null, "/d1", "/d1/file1"));
+    Mutation mut = createTablet("0", null, null, "/d2", "/d2/file2");
+    mut.put(DataFileColumnFamily.NAME.toString(), "/d1/file1", "10,200");
+    bw1.addMutation(mut);
+
+    bw1.flush();
+
+    try {
+      MetadataTableUtil.checkClone(tableName, "0", "1", conn, bw2);
+      assertTrue(false);
+    } catch (TabletIterator.TabletDeletedException tde) {}
+
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/66c62e5f/test/src/main/java/org/apache/accumulo/test/FindMaxIT.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/FindMaxIT.java b/test/src/main/java/org/apache/accumulo/test/FindMaxIT.java
new file mode 100644
index 0000000..f6e68b3
--- /dev/null
+++ b/test/src/main/java/org/apache/accumulo/test/FindMaxIT.java
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.accumulo.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import java.util.ArrayList;
+import java.util.Map.Entry;
+
+import org.apache.accumulo.core.client.BatchWriter;
+import org.apache.accumulo.core.client.BatchWriterConfig;
+import org.apache.accumulo.core.client.Connector;
+import org.apache.accumulo.core.client.Scanner;
+import org.apache.accumulo.core.data.Key;
+import org.apache.accumulo.core.data.Mutation;
+import org.apache.accumulo.core.data.Value;
+import org.apache.accumulo.core.security.Authorizations;
+import org.apache.accumulo.harness.AccumuloClusterHarness;
+import org.apache.hadoop.io.Text;
+import org.junit.Test;
+
+public class FindMaxIT extends AccumuloClusterHarness {
+
+  private static Mutation nm(byte[] row) {
+    Mutation m = new Mutation(new Text(row));
+    m.put("cf", "cq", "v");
+    return m;
+  }
+
+  private static Mutation nm(String row) {
+    Mutation m = new Mutation(row);
+    m.put("cf", "cq", "v");
+    return m;
+  }
+
+  @Test
+  public void test1() throws Exception {
+    Connector conn = getConnector();
+    String tableName = getUniqueNames(1)[0];
+
+    conn.tableOperations().create(tableName);
+
+    BatchWriter bw = conn.createBatchWriter(tableName, new BatchWriterConfig());
+
+    bw.addMutation(nm(new byte[] {0}));
+    bw.addMutation(nm(new byte[] {0, 0}));
+    bw.addMutation(nm(new byte[] {0, 1}));
+    bw.addMutation(nm(new byte[] {0, 1, 0}));
+    bw.addMutation(nm(new byte[] {1, 0}));
+    bw.addMutation(nm(new byte[] {'a', 'b', 'c'}));
+    bw.addMutation(nm(new byte[] {(byte) 0xff}));
+    bw.addMutation(nm(new byte[] {(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff}));
+
+    for (int i = 0; i < 1000; i += 5) {
+      bw.addMutation(nm(String.format("r%05d", i)));
+    }
+
+    bw.close();
+
+    Scanner scanner = conn.createScanner(tableName, Authorizations.EMPTY);
+
+    ArrayList<Text> rows = new ArrayList<Text>();
+
+    for (Entry<Key,Value> entry : scanner) {
+      rows.add(entry.getKey().getRow());
+    }
+
+    for (int i = rows.size() - 1; i > 0; i--) {
+      Text max = conn.tableOperations().getMaxRow(tableName, Authorizations.EMPTY, null, true, rows.get(i), false);
+      assertEquals(rows.get(i - 1), max);
+
+      max = conn.tableOperations().getMaxRow(tableName, Authorizations.EMPTY, rows.get(i - 1), true, rows.get(i), false);
+      assertEquals(rows.get(i - 1), max);
+
+      max = conn.tableOperations().getMaxRow(tableName, Authorizations.EMPTY, rows.get(i - 1), false, rows.get(i), false);
+      assertNull(max);
+
+      max = conn.tableOperations().getMaxRow(tableName, Authorizations.EMPTY, null, true, rows.get(i), true);
+      assertEquals(rows.get(i), max);
+
+      max = conn.tableOperations().getMaxRow(tableName, Authorizations.EMPTY, rows.get(i), true, rows.get(i), true);
+      assertEquals(rows.get(i), max);
+
+      max = conn.tableOperations().getMaxRow(tableName, Authorizations.EMPTY, rows.get(i - 1), false, rows.get(i), true);
+      assertEquals(rows.get(i), max);
+
+    }
+
+    Text max = conn.tableOperations().getMaxRow(tableName, Authorizations.EMPTY, null, true, null, true);
+    assertEquals(rows.get(rows.size() - 1), max);
+
+    max = conn.tableOperations().getMaxRow(tableName, Authorizations.EMPTY, null, true, new Text(new byte[] {0}), false);
+    assertNull(max);
+
+    max = conn.tableOperations().getMaxRow(tableName, Authorizations.EMPTY, null, true, new Text(new byte[] {0}), true);
+    assertEquals(rows.get(0), max);
+  }
+}