accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ctubb...@apache.org
Subject [10/14] accumulo git commit: ACCUMULO-3920 Deprecate mock components
Date Thu, 30 Jul 2015 21:51:44 GMT
http://git-wip-us.apache.org/repos/asf/accumulo/blob/2556df3a/examples/simple/src/test/java/org/apache/accumulo/examples/simple/dirlist/CountTest.java
----------------------------------------------------------------------
diff --git a/examples/simple/src/test/java/org/apache/accumulo/examples/simple/dirlist/CountTest.java b/examples/simple/src/test/java/org/apache/accumulo/examples/simple/dirlist/CountTest.java
index f089d42..492f3e5 100644
--- a/examples/simple/src/test/java/org/apache/accumulo/examples/simple/dirlist/CountTest.java
+++ b/examples/simple/src/test/java/org/apache/accumulo/examples/simple/dirlist/CountTest.java
@@ -16,19 +16,20 @@
  */
 package org.apache.accumulo.examples.simple.dirlist;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+
 import java.util.ArrayList;
 import java.util.Map.Entry;
 
-import junit.framework.TestCase;
-
 import org.apache.accumulo.core.cli.BatchWriterOpts;
 import org.apache.accumulo.core.cli.ClientOpts.Password;
 import org.apache.accumulo.core.cli.ScannerOpts;
 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.mock.MockInstance;
 import org.apache.accumulo.core.client.security.tokens.PasswordToken;
 import org.apache.accumulo.core.data.Key;
 import org.apache.accumulo.core.data.Value;
@@ -37,37 +38,43 @@ import org.apache.accumulo.core.security.ColumnVisibility;
 import org.apache.accumulo.core.util.Pair;
 import org.apache.accumulo.examples.simple.dirlist.FileCount.Opts;
 import org.apache.hadoop.io.Text;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TestName;
 
-public class CountTest extends TestCase {
+public class CountTest {
 
-  private static final Logger log = LoggerFactory.getLogger(CountTest.class);
+  @Rule
+  public TestName test = new TestName();
 
-  {
-    try {
-      Connector conn = new MockInstance("counttest").getConnector("root", new PasswordToken(""));
-      conn.tableOperations().create("dirlisttable");
-      BatchWriter bw = conn.createBatchWriter("dirlisttable", new BatchWriterConfig());
-      ColumnVisibility cv = new ColumnVisibility();
-      // / has 1 dir
-      // /local has 2 dirs 1 file
-      // /local/user1 has 2 files
-      bw.addMutation(Ingest.buildMutation(cv, "/local", true, false, true, 272, 12345, null));
-      bw.addMutation(Ingest.buildMutation(cv, "/local/user1", true, false, true, 272, 12345, null));
-      bw.addMutation(Ingest.buildMutation(cv, "/local/user2", true, false, true, 272, 12345, null));
-      bw.addMutation(Ingest.buildMutation(cv, "/local/file", false, false, false, 1024, 12345, null));
-      bw.addMutation(Ingest.buildMutation(cv, "/local/file", false, false, false, 1024, 23456, null));
-      bw.addMutation(Ingest.buildMutation(cv, "/local/user1/file1", false, false, false, 2024, 12345, null));
-      bw.addMutation(Ingest.buildMutation(cv, "/local/user1/file2", false, false, false, 1028, 23456, null));
-      bw.close();
-    } catch (Exception e) {
-      log.error("Could not add mutations in initializer.", e);
-    }
+  private Connector conn;
+  private String tableName;
+
+  @Before
+  public void setupInstance() throws Exception {
+    tableName = test.getMethodName();
+    Instance inst = new org.apache.accumulo.core.client.mock.MockInstance(test.getMethodName());
+    conn = inst.getConnector("root", new PasswordToken(""));
+    conn.tableOperations().create(tableName);
+    BatchWriter bw = conn.createBatchWriter(tableName, new BatchWriterConfig());
+    ColumnVisibility cv = new ColumnVisibility();
+    // / has 1 dir
+    // /local has 2 dirs 1 file
+    // /local/user1 has 2 files
+    bw.addMutation(Ingest.buildMutation(cv, "/local", true, false, true, 272, 12345, null));
+    bw.addMutation(Ingest.buildMutation(cv, "/local/user1", true, false, true, 272, 12345, null));
+    bw.addMutation(Ingest.buildMutation(cv, "/local/user2", true, false, true, 272, 12345, null));
+    bw.addMutation(Ingest.buildMutation(cv, "/local/file", false, false, false, 1024, 12345, null));
+    bw.addMutation(Ingest.buildMutation(cv, "/local/file", false, false, false, 1024, 23456, null));
+    bw.addMutation(Ingest.buildMutation(cv, "/local/user1/file1", false, false, false, 2024, 12345, null));
+    bw.addMutation(Ingest.buildMutation(cv, "/local/user1/file2", false, false, false, 1028, 23456, null));
+    bw.close();
   }
 
+  @Test
   public void test() throws Exception {
-    Scanner scanner = new MockInstance("counttest").getConnector("root", new PasswordToken("")).createScanner("dirlisttable", new Authorizations());
+    Scanner scanner = conn.createScanner(tableName, new Authorizations());
     scanner.fetchColumn(new Text("dir"), new Text("counts"));
     assertFalse(scanner.iterator().hasNext());
 
@@ -75,7 +82,7 @@ public class CountTest extends TestCase {
     ScannerOpts scanOpts = new ScannerOpts();
     BatchWriterOpts bwOpts = new BatchWriterOpts();
     opts.instance = "counttest";
-    opts.setTableName("dirlisttable");
+    opts.setTableName(tableName);
     opts.setPassword(new Password("secret"));
     opts.mock = true;
     opts.setPassword(new Opts.Password(""));

http://git-wip-us.apache.org/repos/asf/accumulo/blob/2556df3a/examples/simple/src/test/java/org/apache/accumulo/examples/simple/filedata/ChunkInputFormatTest.java
----------------------------------------------------------------------
diff --git a/examples/simple/src/test/java/org/apache/accumulo/examples/simple/filedata/ChunkInputFormatTest.java b/examples/simple/src/test/java/org/apache/accumulo/examples/simple/filedata/ChunkInputFormatTest.java
index b95c00c..997612f 100644
--- a/examples/simple/src/test/java/org/apache/accumulo/examples/simple/filedata/ChunkInputFormatTest.java
+++ b/examples/simple/src/test/java/org/apache/accumulo/examples/simple/filedata/ChunkInputFormatTest.java
@@ -33,7 +33,7 @@ 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.mock.MockInstance;
+import org.apache.accumulo.core.client.Instance;
 import org.apache.accumulo.core.client.security.tokens.PasswordToken;
 import org.apache.accumulo.core.data.Key;
 import org.apache.accumulo.core.data.Mutation;
@@ -47,8 +47,11 @@ import org.apache.hadoop.mapreduce.Mapper;
 import org.apache.hadoop.mapreduce.lib.output.NullOutputFormat;
 import org.apache.hadoop.util.Tool;
 import org.apache.hadoop.util.ToolRunner;
+import org.junit.Before;
 import org.junit.BeforeClass;
+import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.TestName;
 
 public class ChunkInputFormatTest {
 
@@ -62,6 +65,17 @@ public class ChunkInputFormatTest {
   private static List<Entry<Key,Value>> data;
   private static List<Entry<Key,Value>> baddata;
 
+  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(""));
+  }
+
   @BeforeClass
   public static void setupClass() {
     System.setProperty("hadoop.tmp.dir", System.getProperty("user.dir") + "/target/hadoop-tmp");
@@ -243,8 +257,6 @@ public class ChunkInputFormatTest {
 
   @Test
   public void test() throws Exception {
-    MockInstance instance = new MockInstance("instance1");
-    Connector conn = instance.getConnector("root", new PasswordToken(""));
     conn.tableOperations().create("test");
     BatchWriter bw = conn.createBatchWriter("test", new BatchWriterConfig());
 
@@ -256,15 +268,13 @@ public class ChunkInputFormatTest {
     }
     bw.close();
 
-    assertEquals(0, CIFTester.main("instance1", "root", "", "test", CIFTester.TestMapper.class.getName()));
+    assertEquals(0, CIFTester.main(conn.getInstance().getInstanceName(), "root", "", "test", CIFTester.TestMapper.class.getName()));
     assertNull(e1);
     assertNull(e2);
   }
 
   @Test
   public void testErrorOnNextWithoutClose() throws Exception {
-    MockInstance instance = new MockInstance("instance2");
-    Connector conn = instance.getConnector("root", new PasswordToken(""));
     conn.tableOperations().create("test");
     BatchWriter bw = conn.createBatchWriter("test", new BatchWriterConfig());
 
@@ -276,7 +286,7 @@ public class ChunkInputFormatTest {
     }
     bw.close();
 
-    assertEquals(1, CIFTester.main("instance2", "root", "", "test", CIFTester.TestNoClose.class.getName()));
+    assertEquals(1, CIFTester.main(conn.getInstance().getInstanceName(), "root", "", "test", CIFTester.TestNoClose.class.getName()));
     assertNull(e1);
     assertNull(e2);
     assertNotNull(e3);
@@ -284,8 +294,6 @@ public class ChunkInputFormatTest {
 
   @Test
   public void testInfoWithoutChunks() throws Exception {
-    MockInstance instance = new MockInstance("instance3");
-    Connector conn = instance.getConnector("root", new PasswordToken(""));
     conn.tableOperations().create("test");
     BatchWriter bw = conn.createBatchWriter("test", new BatchWriterConfig());
     for (Entry<Key,Value> e : baddata) {
@@ -296,7 +304,7 @@ public class ChunkInputFormatTest {
     }
     bw.close();
 
-    assertEquals(0, CIFTester.main("instance3", "root", "", "test", CIFTester.TestBadData.class.getName()));
+    assertEquals(0, CIFTester.main(conn.getInstance().getInstanceName(), "root", "", "test", CIFTester.TestBadData.class.getName()));
     assertNull(e0);
     assertNull(e1);
     assertNull(e2);

http://git-wip-us.apache.org/repos/asf/accumulo/blob/2556df3a/examples/simple/src/test/java/org/apache/accumulo/examples/simple/filedata/ChunkInputStreamTest.java
----------------------------------------------------------------------
diff --git a/examples/simple/src/test/java/org/apache/accumulo/examples/simple/filedata/ChunkInputStreamTest.java b/examples/simple/src/test/java/org/apache/accumulo/examples/simple/filedata/ChunkInputStreamTest.java
index 1976b21..614a480 100644
--- a/examples/simple/src/test/java/org/apache/accumulo/examples/simple/filedata/ChunkInputStreamTest.java
+++ b/examples/simple/src/test/java/org/apache/accumulo/examples/simple/filedata/ChunkInputStreamTest.java
@@ -16,22 +16,26 @@
  */
 package org.apache.accumulo.examples.simple.filedata;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.fail;
+
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map.Entry;
 
-import junit.framework.TestCase;
-
 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.Scanner;
 import org.apache.accumulo.core.client.TableExistsException;
 import org.apache.accumulo.core.client.TableNotFoundException;
-import org.apache.accumulo.core.client.mock.MockInstance;
 import org.apache.accumulo.core.client.security.tokens.PasswordToken;
 import org.apache.accumulo.core.data.Key;
 import org.apache.accumulo.core.data.KeyValue;
@@ -41,17 +45,21 @@ import org.apache.accumulo.core.security.Authorizations;
 import org.apache.accumulo.core.security.ColumnVisibility;
 import org.apache.accumulo.core.util.PeekingIterator;
 import org.apache.hadoop.io.Text;
+import org.junit.Before;
+import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.TestName;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class ChunkInputStreamTest extends TestCase {
+public class ChunkInputStreamTest {
   private static final Logger log = LoggerFactory.getLogger(ChunkInputStream.class);
   List<Entry<Key,Value>> data;
   List<Entry<Key,Value>> baddata;
   List<Entry<Key,Value>> multidata;
 
-  {
+  @Before
+  public void setupData() {
     data = new ArrayList<Entry<Key,Value>>();
     addData(data, "a", "refs", "id\0ext", "A&B", "ext");
     addData(data, "a", "refs", "id\0name", "A&B", "name");
@@ -227,9 +235,13 @@ public class ChunkInputStreamTest extends TestCase {
     assertFalse(pi.hasNext());
   }
 
+  @Rule
+  public TestName test = new TestName();
+
   @Test
   public void testWithAccumulo() throws AccumuloException, AccumuloSecurityException, TableExistsException, TableNotFoundException, IOException {
-    Connector conn = new MockInstance().getConnector("root", new PasswordToken(""));
+    Instance inst = new org.apache.accumulo.core.client.mock.MockInstance(test.getMethodName());
+    Connector conn = inst.getConnector("root", new PasswordToken(""));
     conn.tableOperations().create("test");
     BatchWriter bw = conn.createBatchWriter("test", new BatchWriterConfig());
 

http://git-wip-us.apache.org/repos/asf/accumulo/blob/2556df3a/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloCluster.java
----------------------------------------------------------------------
diff --git a/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloCluster.java b/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloCluster.java
index 87dfff8..ba52f80 100644
--- a/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloCluster.java
+++ b/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloCluster.java
@@ -31,7 +31,7 @@ import org.apache.accumulo.minicluster.impl.MiniAccumuloConfigImpl;
 
 /**
  * A utility class that will create Zookeeper and Accumulo processes that write all of their data to a single local directory. This class makes it easy to test
- * code against a real Accumulo instance. Its much more accurate for testing than {@link org.apache.accumulo.core.client.mock.MockAccumulo}, but much slower.
+ * code against a real Accumulo instance. The use of this utility will yield results which closely match a normal Accumulo instance.
  *
  * @since 1.5.0
  */

http://git-wip-us.apache.org/repos/asf/accumulo/blob/2556df3a/minicluster/src/main/java/org/apache/accumulo/minicluster/impl/MiniAccumuloClusterImpl.java
----------------------------------------------------------------------
diff --git a/minicluster/src/main/java/org/apache/accumulo/minicluster/impl/MiniAccumuloClusterImpl.java b/minicluster/src/main/java/org/apache/accumulo/minicluster/impl/MiniAccumuloClusterImpl.java
index 0cb14c7..772ba69 100644
--- a/minicluster/src/main/java/org/apache/accumulo/minicluster/impl/MiniAccumuloClusterImpl.java
+++ b/minicluster/src/main/java/org/apache/accumulo/minicluster/impl/MiniAccumuloClusterImpl.java
@@ -78,6 +78,7 @@ import org.apache.accumulo.core.util.Pair;
 import org.apache.accumulo.core.zookeeper.ZooUtil;
 import org.apache.accumulo.fate.zookeeper.IZooReaderWriter;
 import org.apache.accumulo.master.state.SetGoalState;
+import org.apache.accumulo.minicluster.MiniAccumuloCluster;
 import org.apache.accumulo.minicluster.ServerType;
 import org.apache.accumulo.server.Accumulo;
 import org.apache.accumulo.server.fs.VolumeManager;
@@ -113,8 +114,8 @@ import com.google.common.collect.Maps;
 import static com.google.common.util.concurrent.Uninterruptibles.sleepUninterruptibly;
 
 /**
- * A utility class that will create Zookeeper and Accumulo processes that write all of their data to a single local directory. This class makes it easy to test
- * code against a real Accumulo instance. Its much more accurate for testing than {@link org.apache.accumulo.core.client.mock.MockAccumulo}, but much slower.
+ * This class provides the backing implementation for {@link MiniAccumuloCluster}, and may contain features for internal testing which have not yet been
+ * promoted to the public API. It's best to use {@link MiniAccumuloCluster} whenever possible. Use of this class risks API breakage between versions.
  *
  * @since 1.6.0
  */

http://git-wip-us.apache.org/repos/asf/accumulo/blob/2556df3a/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java
----------------------------------------------------------------------
diff --git a/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java b/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java
index 88dad8d..cda04a8 100644
--- a/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java
+++ b/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java
@@ -62,7 +62,6 @@ import org.apache.accumulo.core.client.admin.TimeType;
 import org.apache.accumulo.core.client.impl.Credentials;
 import org.apache.accumulo.core.client.impl.thrift.TableOperationExceptionType;
 import org.apache.accumulo.core.client.impl.thrift.ThriftTableOperationException;
-import org.apache.accumulo.core.client.mock.MockInstance;
 import org.apache.accumulo.core.client.security.SecurityErrorCode;
 import org.apache.accumulo.core.client.security.tokens.AuthenticationToken;
 import org.apache.accumulo.core.client.security.tokens.PasswordToken;
@@ -80,6 +79,7 @@ import org.apache.accumulo.core.security.ColumnVisibility;
 import org.apache.accumulo.core.security.SystemPermission;
 import org.apache.accumulo.core.security.TablePermission;
 import org.apache.accumulo.core.util.ByteBufferUtil;
+import org.apache.accumulo.core.util.DeprecationUtil;
 import org.apache.accumulo.core.util.TextUtil;
 import org.apache.accumulo.proxy.thrift.AccumuloProxy;
 import org.apache.accumulo.proxy.thrift.BatchScanOptions;
@@ -186,7 +186,7 @@ public class ProxyServer implements AccumuloProxy.Iface {
 
     String useMock = props.getProperty("useMockInstance");
     if (useMock != null && Boolean.parseBoolean(useMock))
-      instance = new MockInstance();
+      instance = DeprecationUtil.makeMockInstance(this.getClass().getName());
     else {
       ClientConfiguration clientConf;
       if (props.containsKey("clientConfigurationFile")) {

http://git-wip-us.apache.org/repos/asf/accumulo/blob/2556df3a/server/base/src/main/java/org/apache/accumulo/server/AccumuloServerContext.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/server/AccumuloServerContext.java b/server/base/src/main/java/org/apache/accumulo/server/AccumuloServerContext.java
index a35f39c..9198b19 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/AccumuloServerContext.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/AccumuloServerContext.java
@@ -26,11 +26,11 @@ import org.apache.accumulo.core.client.ZooKeeperInstance;
 import org.apache.accumulo.core.client.impl.ClientContext;
 import org.apache.accumulo.core.client.impl.ConnectorImpl;
 import org.apache.accumulo.core.client.impl.Credentials;
-import org.apache.accumulo.core.client.mock.MockInstance;
 import org.apache.accumulo.core.client.security.tokens.PasswordToken;
 import org.apache.accumulo.core.conf.AccumuloConfiguration;
 import org.apache.accumulo.core.conf.Property;
 import org.apache.accumulo.core.rpc.SslConnectionParams;
+import org.apache.accumulo.core.util.DeprecationUtil;
 import org.apache.accumulo.server.client.HdfsZooInstance;
 import org.apache.accumulo.server.conf.ServerConfigurationFactory;
 import org.apache.accumulo.server.rpc.SaslServerConnectionParams;
@@ -95,7 +95,7 @@ public class AccumuloServerContext extends ClientContext {
    * Get the credentials to use for this instance so it can be passed to the superclass during construction.
    */
   private static Credentials getCredentials(Instance instance) {
-    if (instance instanceof MockInstance) {
+    if (DeprecationUtil.isMockInstance(instance)) {
       return new Credentials("mockSystemUser", new PasswordToken("mockSystemPassword"));
     }
     return SystemCredentials.get(instance);

http://git-wip-us.apache.org/repos/asf/accumulo/blob/2556df3a/server/base/src/main/java/org/apache/accumulo/server/cli/ClientOnDefaultTable.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/server/cli/ClientOnDefaultTable.java b/server/base/src/main/java/org/apache/accumulo/server/cli/ClientOnDefaultTable.java
index 10cab49..a058660 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/cli/ClientOnDefaultTable.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/cli/ClientOnDefaultTable.java
@@ -18,7 +18,7 @@ package org.apache.accumulo.server.cli;
 
 import org.apache.accumulo.core.client.Instance;
 import org.apache.accumulo.core.client.ZooKeeperInstance;
-import org.apache.accumulo.core.client.mock.MockInstance;
+import org.apache.accumulo.core.util.DeprecationUtil;
 import org.apache.accumulo.server.client.HdfsZooInstance;
 
 public class ClientOnDefaultTable extends org.apache.accumulo.core.cli.ClientOnDefaultTable {
@@ -32,7 +32,7 @@ public class ClientOnDefaultTable extends org.apache.accumulo.core.cli.ClientOnD
       return cachedInstance;
 
     if (mock)
-      return cachedInstance = new MockInstance(instance);
+      return cachedInstance = DeprecationUtil.makeMockInstance(instance);
     if (instance == null) {
       return cachedInstance = HdfsZooInstance.getInstance();
     }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/2556df3a/server/base/src/main/java/org/apache/accumulo/server/cli/ClientOnRequiredTable.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/server/cli/ClientOnRequiredTable.java b/server/base/src/main/java/org/apache/accumulo/server/cli/ClientOnRequiredTable.java
index e134235..e02dd93 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/cli/ClientOnRequiredTable.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/cli/ClientOnRequiredTable.java
@@ -18,7 +18,7 @@ package org.apache.accumulo.server.cli;
 
 import org.apache.accumulo.core.client.Instance;
 import org.apache.accumulo.core.client.ZooKeeperInstance;
-import org.apache.accumulo.core.client.mock.MockInstance;
+import org.apache.accumulo.core.util.DeprecationUtil;
 import org.apache.accumulo.server.client.HdfsZooInstance;
 
 public class ClientOnRequiredTable extends org.apache.accumulo.core.cli.ClientOnRequiredTable {
@@ -32,7 +32,7 @@ public class ClientOnRequiredTable extends org.apache.accumulo.core.cli.ClientOn
       return cachedInstance;
 
     if (mock)
-      return cachedInstance = new MockInstance(instance);
+      return cachedInstance = DeprecationUtil.makeMockInstance(instance);
     if (instance == null) {
       return cachedInstance = HdfsZooInstance.getInstance();
     }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/2556df3a/server/base/src/main/java/org/apache/accumulo/server/cli/ClientOpts.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/server/cli/ClientOpts.java b/server/base/src/main/java/org/apache/accumulo/server/cli/ClientOpts.java
index c50d95d..c91471e 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/cli/ClientOpts.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/cli/ClientOpts.java
@@ -18,7 +18,7 @@ package org.apache.accumulo.server.cli;
 
 import org.apache.accumulo.core.client.Instance;
 import org.apache.accumulo.core.client.ZooKeeperInstance;
-import org.apache.accumulo.core.client.mock.MockInstance;
+import org.apache.accumulo.core.util.DeprecationUtil;
 import org.apache.accumulo.server.client.HdfsZooInstance;
 
 public class ClientOpts extends org.apache.accumulo.core.cli.ClientOpts {
@@ -30,7 +30,7 @@ public class ClientOpts extends org.apache.accumulo.core.cli.ClientOpts {
   @Override
   public Instance getInstance() {
     if (mock)
-      return new MockInstance(instance);
+      return DeprecationUtil.makeMockInstance(instance);
     if (instance == null) {
       return HdfsZooInstance.getInstance();
     }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/2556df3a/server/base/src/test/java/org/apache/accumulo/server/AccumuloServerContextTest.java
----------------------------------------------------------------------
diff --git a/server/base/src/test/java/org/apache/accumulo/server/AccumuloServerContextTest.java b/server/base/src/test/java/org/apache/accumulo/server/AccumuloServerContextTest.java
index a596d9f..521fd7b 100644
--- a/server/base/src/test/java/org/apache/accumulo/server/AccumuloServerContextTest.java
+++ b/server/base/src/test/java/org/apache/accumulo/server/AccumuloServerContextTest.java
@@ -26,9 +26,9 @@ import java.util.Map.Entry;
 
 import org.apache.accumulo.core.client.ClientConfiguration;
 import org.apache.accumulo.core.client.ClientConfiguration.ClientProperty;
+import org.apache.accumulo.core.client.Instance;
 import org.apache.accumulo.core.client.impl.ClientContext;
 import org.apache.accumulo.core.client.impl.Credentials;
-import org.apache.accumulo.core.client.mock.MockInstance;
 import org.apache.accumulo.core.client.security.tokens.PasswordToken;
 import org.apache.accumulo.core.conf.AccumuloConfiguration;
 import org.apache.accumulo.core.conf.Property;
@@ -68,7 +68,7 @@ public class AccumuloServerContextTest {
     testUser.doAs(new PrivilegedExceptionAction<Void>() {
       @Override
       public Void run() throws Exception {
-        MockInstance instance = new MockInstance();
+        Instance instance = EasyMock.createMock(Instance.class);
 
         ClientConfiguration clientConf = ClientConfiguration.loadDefault();
         clientConf.setProperty(ClientProperty.INSTANCE_RPC_SASL_ENABLED, "true");

http://git-wip-us.apache.org/repos/asf/accumulo/blob/2556df3a/server/base/src/test/java/org/apache/accumulo/server/client/BulkImporterTest.java
----------------------------------------------------------------------
diff --git a/server/base/src/test/java/org/apache/accumulo/server/client/BulkImporterTest.java b/server/base/src/test/java/org/apache/accumulo/server/client/BulkImporterTest.java
index 8d649d2..fe4aff2 100644
--- a/server/base/src/test/java/org/apache/accumulo/server/client/BulkImporterTest.java
+++ b/server/base/src/test/java/org/apache/accumulo/server/client/BulkImporterTest.java
@@ -25,15 +25,12 @@ import java.util.TreeSet;
 
 import org.apache.accumulo.core.client.AccumuloException;
 import org.apache.accumulo.core.client.AccumuloSecurityException;
-import org.apache.accumulo.core.client.ClientConfiguration;
 import org.apache.accumulo.core.client.Instance;
 import org.apache.accumulo.core.client.TableNotFoundException;
 import org.apache.accumulo.core.client.impl.ClientContext;
-import org.apache.accumulo.core.client.impl.Credentials;
 import org.apache.accumulo.core.client.impl.TabletLocator;
 import org.apache.accumulo.core.client.impl.TabletLocator.TabletLocation;
-import org.apache.accumulo.core.client.mock.MockInstance;
-import org.apache.accumulo.core.client.security.tokens.PasswordToken;
+import org.apache.accumulo.core.conf.DefaultConfiguration;
 import org.apache.accumulo.core.data.Key;
 import org.apache.accumulo.core.data.Mutation;
 import org.apache.accumulo.core.data.Range;
@@ -48,6 +45,7 @@ import org.apache.commons.lang.NotImplementedException;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.io.Text;
+import org.easymock.EasyMock;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -109,7 +107,9 @@ public class BulkImporterTest {
   public void testFindOverlappingTablets() throws Exception {
     MockTabletLocator locator = new MockTabletLocator();
     FileSystem fs = FileSystem.getLocal(CachedConfiguration.getInstance());
-    ClientContext context = new ClientContext(new MockInstance(), new Credentials("root", new PasswordToken("")), new ClientConfiguration());
+    ClientContext context = EasyMock.createMock(ClientContext.class);
+    EasyMock.expect(context.getConfiguration()).andReturn(DefaultConfiguration.getInstance()).anyTimes();
+    EasyMock.replay(context);
     String file = "target/testFile.rf";
     fs.delete(new Path(file), true);
     FileSKVWriter writer = FileOperations.getInstance().openWriter(file, fs, fs.getConf(), context.getConfiguration());

http://git-wip-us.apache.org/repos/asf/accumulo/blob/2556df3a/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 c957009..7bf5d2d 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
@@ -26,9 +26,9 @@ import java.util.SortedMap;
 import java.util.TreeMap;
 
 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.mock.MockInstance;
 import org.apache.accumulo.core.client.security.tokens.PasswordToken;
 import org.apache.accumulo.core.conf.DefaultConfiguration;
 import org.apache.accumulo.core.conf.Property;
@@ -71,7 +71,7 @@ public class TableLoadBalancerTest {
     return result;
   }
 
-  static MockInstance instance = new MockInstance("mockamatic");
+  static Instance instance = new org.apache.accumulo.core.client.mock.MockInstance(TableLoadBalancerTest.class.getName());
 
   static SortedMap<TServerInstance,TabletServerStatus> state;
 

http://git-wip-us.apache.org/repos/asf/accumulo/blob/2556df3a/server/base/src/test/java/org/apache/accumulo/server/problems/ProblemReportingIteratorTest.java
----------------------------------------------------------------------
diff --git a/server/base/src/test/java/org/apache/accumulo/server/problems/ProblemReportingIteratorTest.java b/server/base/src/test/java/org/apache/accumulo/server/problems/ProblemReportingIteratorTest.java
index 2e0ad0c..76d0171 100644
--- a/server/base/src/test/java/org/apache/accumulo/server/problems/ProblemReportingIteratorTest.java
+++ b/server/base/src/test/java/org/apache/accumulo/server/problems/ProblemReportingIteratorTest.java
@@ -16,7 +16,6 @@
  */
 package org.apache.accumulo.server.problems;
 
-import static org.easymock.EasyMock.createMock;
 import static org.easymock.EasyMock.expect;
 import static org.easymock.EasyMock.replay;
 import static org.easymock.EasyMock.verify;
@@ -28,14 +27,12 @@ import static org.junit.Assert.assertTrue;
 import java.util.Collection;
 import java.util.concurrent.atomic.AtomicBoolean;
 
-import org.apache.accumulo.core.client.mock.MockInstance;
 import org.apache.accumulo.core.data.ByteSequence;
 import org.apache.accumulo.core.data.Key;
 import org.apache.accumulo.core.data.Range;
 import org.apache.accumulo.core.data.Value;
 import org.apache.accumulo.core.iterators.system.InterruptibleIterator;
-import org.apache.accumulo.server.AccumuloServerContext;
-import org.apache.accumulo.server.conf.ServerConfigurationFactory;
+import org.easymock.EasyMock;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -48,16 +45,15 @@ public class ProblemReportingIteratorTest {
 
   @Before
   public void setUp() throws Exception {
-    ii = createMock(InterruptibleIterator.class);
-    AccumuloServerContext context = new AccumuloServerContext(new ServerConfigurationFactory(new MockInstance()));
-    pri = new ProblemReportingIterator(context, TABLE, RESOURCE, false, ii);
+    ii = EasyMock.createMock(InterruptibleIterator.class);
+    pri = new ProblemReportingIterator(null, TABLE, RESOURCE, false, ii);
   }
 
   @Test
   public void testBasicGetters() {
-    Key key = createMock(Key.class);
+    Key key = EasyMock.createMock(Key.class);
     expect(ii.getTopKey()).andReturn(key);
-    Value value = createMock(Value.class);
+    Value value = EasyMock.createMock(Value.class);
     expect(ii.getTopValue()).andReturn(value);
     expect(ii.hasTop()).andReturn(true);
     replay(ii);
@@ -84,7 +80,7 @@ public class ProblemReportingIteratorTest {
 
   @Test
   public void testSeek() throws Exception {
-    Range r = createMock(Range.class);
+    Range r = EasyMock.createMock(Range.class);
     Collection<ByteSequence> f = new java.util.HashSet<ByteSequence>();
     ii.seek(r, f, true);
     replay(ii);

http://git-wip-us.apache.org/repos/asf/accumulo/blob/2556df3a/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 1af908b..81a3892 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
@@ -23,24 +23,26 @@ import java.io.File;
 import java.io.IOException;
 import java.util.UUID;
 
+import org.apache.accumulo.core.client.Instance;
 import org.apache.accumulo.core.client.impl.ConnectorImpl;
 import org.apache.accumulo.core.client.impl.Credentials;
-import org.apache.accumulo.core.client.mock.MockInstance;
 import org.apache.accumulo.server.ServerConstants;
 import org.apache.accumulo.server.security.SystemCredentials.SystemToken;
+import org.junit.Before;
 import org.junit.BeforeClass;
+import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.TestName;
 
-/**
- *
- */
 public class SystemCredentialsTest {
 
-  private static MockInstance inst;
+  @Rule
+  public TestName test = new TestName();
+
+  private Instance inst;
 
   @BeforeClass
   public static void setUp() throws IOException {
-    inst = new MockInstance();
     File testInstanceId = new File(new File(new File(new File("target"), "instanceTest"), ServerConstants.INSTANCE_ID_DIR), UUID.fromString(
         "00000000-0000-0000-0000-000000000000").toString());
     if (!testInstanceId.exists()) {
@@ -55,6 +57,11 @@ public class SystemCredentialsTest {
     }
   }
 
+  @Before
+  public void setupInstance() {
+    inst = new org.apache.accumulo.core.client.mock.MockInstance(test.getMethodName());
+  }
+
   /**
    * This is a test to ensure the string literal in {@link ConnectorImpl#ConnectorImpl(org.apache.accumulo.core.client.impl.ClientContext)} is kept up-to-date
    * if we move the {@link SystemToken}<br/>

http://git-wip-us.apache.org/repos/asf/accumulo/blob/2556df3a/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
index 0c696a1..aa7cad4 100644
--- 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
@@ -16,16 +16,17 @@
  */
 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 junit.framework.TestCase;
-
 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.mock.MockInstance;
 import org.apache.accumulo.core.client.security.tokens.PasswordToken;
 import org.apache.accumulo.core.data.Key;
 import org.apache.accumulo.core.data.Mutation;
@@ -36,13 +37,26 @@ 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 extends TestCase {
+public class CloneTest {
 
-  public void testNoFiles() throws Exception {
-    MockInstance mi = new MockInstance();
-    Connector conn = mi.getConnector("", new PasswordToken(""));
+  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();
 
@@ -67,10 +81,8 @@ public class CloneTest extends TestCase {
 
   }
 
+  @Test
   public void testFilesChange() throws Exception {
-    MockInstance mi = new MockInstance();
-    Connector conn = mi.getConnector("", new PasswordToken(""));
-
     KeyExtent ke = new KeyExtent(new Text("0"), null, null);
     Mutation mut = ke.getPrevRowUpdateMutation();
 
@@ -119,10 +131,8 @@ public class CloneTest extends TestCase {
   }
 
   // test split where files of children are the same
+  @Test
   public void testSplit1() throws Exception {
-    MockInstance mi = new MockInstance();
-    Connector conn = mi.getConnector("", new PasswordToken(""));
-
     BatchWriter bw1 = conn.createBatchWriter(MetadataTable.NAME, new BatchWriterConfig());
 
     bw1.addMutation(createTablet("0", null, null, "/default_tablet", "/default_tablet/0_0.rf"));
@@ -161,10 +171,8 @@ public class CloneTest extends TestCase {
   }
 
   // test split where files of children differ... like majc and split occurred
+  @Test
   public void testSplit2() throws Exception {
-    MockInstance mi = new MockInstance();
-    Connector conn = mi.getConnector("", new PasswordToken(""));
-
     BatchWriter bw1 = conn.createBatchWriter(MetadataTable.NAME, new BatchWriterConfig());
 
     bw1.addMutation(createTablet("0", null, null, "/default_tablet", "/default_tablet/0_0.rf"));
@@ -232,10 +240,8 @@ public class CloneTest extends TestCase {
   }
 
   // test two tablets splitting into four
+  @Test
   public void testSplit3() throws Exception {
-    MockInstance mi = new MockInstance();
-    Connector conn = mi.getConnector("", new PasswordToken(""));
-
     BatchWriter bw1 = conn.createBatchWriter(MetadataTable.NAME, new BatchWriterConfig());
 
     bw1.addMutation(createTablet("0", "m", null, "/d1", "/d1/file1"));
@@ -278,11 +284,8 @@ public class CloneTest extends TestCase {
   }
 
   // test cloned marker
+  @Test
   public void testClonedMarker() throws Exception {
-
-    MockInstance mi = new MockInstance();
-    Connector conn = mi.getConnector("", new PasswordToken(""));
-
     BatchWriter bw1 = conn.createBatchWriter(MetadataTable.NAME, new BatchWriterConfig());
 
     bw1.addMutation(createTablet("0", "m", null, "/d1", "/d1/file1"));
@@ -343,10 +346,8 @@ public class CloneTest extends TestCase {
   }
 
   // test two tablets splitting into four
+  @Test
   public void testMerge() throws Exception {
-    MockInstance mi = new MockInstance();
-    Connector conn = mi.getConnector("", new PasswordToken(""));
-
     BatchWriter bw1 = conn.createBatchWriter(MetadataTable.NAME, new BatchWriterConfig());
 
     bw1.addMutation(createTablet("0", "m", null, "/d1", "/d1/file1"));

http://git-wip-us.apache.org/repos/asf/accumulo/blob/2556df3a/server/base/src/test/java/org/apache/accumulo/server/util/ReplicationTableUtilTest.java
----------------------------------------------------------------------
diff --git a/server/base/src/test/java/org/apache/accumulo/server/util/ReplicationTableUtilTest.java b/server/base/src/test/java/org/apache/accumulo/server/util/ReplicationTableUtilTest.java
index 04a83d3..59720e9 100644
--- a/server/base/src/test/java/org/apache/accumulo/server/util/ReplicationTableUtilTest.java
+++ b/server/base/src/test/java/org/apache/accumulo/server/util/ReplicationTableUtilTest.java
@@ -31,7 +31,6 @@ import java.util.Map;
 import java.util.Map.Entry;
 import java.util.UUID;
 
-import org.apache.accumulo.core.client.ClientConfiguration;
 import org.apache.accumulo.core.client.Connector;
 import org.apache.accumulo.core.client.IteratorSetting;
 import org.apache.accumulo.core.client.IteratorSetting.Column;
@@ -39,7 +38,6 @@ import org.apache.accumulo.core.client.admin.TableOperations;
 import org.apache.accumulo.core.client.impl.ClientContext;
 import org.apache.accumulo.core.client.impl.Credentials;
 import org.apache.accumulo.core.client.impl.Writer;
-import org.apache.accumulo.core.client.mock.MockInstance;
 import org.apache.accumulo.core.client.security.tokens.PasswordToken;
 import org.apache.accumulo.core.conf.Property;
 import org.apache.accumulo.core.data.ColumnUpdate;
@@ -81,7 +79,9 @@ public class ReplicationTableUtilTest {
     EasyMock.replay(writer);
 
     Credentials creds = new Credentials("root", new PasswordToken(""));
-    ClientContext context = new ClientContext(new MockInstance(), creds, new ClientConfiguration());
+    ClientContext context = EasyMock.createMock(ClientContext.class);
+    EasyMock.expect(context.getCredentials()).andReturn(creds).anyTimes();
+    EasyMock.replay(context);
 
     // Magic hook to create a Writer
     ReplicationTableUtil.addWriter(creds, writer);

http://git-wip-us.apache.org/repos/asf/accumulo/blob/2556df3a/server/base/src/test/java/org/apache/accumulo/server/util/TabletIteratorTest.java
----------------------------------------------------------------------
diff --git a/server/base/src/test/java/org/apache/accumulo/server/util/TabletIteratorTest.java b/server/base/src/test/java/org/apache/accumulo/server/util/TabletIteratorTest.java
index 9c6cee1..19bf13a 100644
--- a/server/base/src/test/java/org/apache/accumulo/server/util/TabletIteratorTest.java
+++ b/server/base/src/test/java/org/apache/accumulo/server/util/TabletIteratorTest.java
@@ -18,13 +18,11 @@ package org.apache.accumulo.server.util;
 
 import java.util.Map.Entry;
 
-import junit.framework.TestCase;
-
 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.mock.MockInstance;
 import org.apache.accumulo.core.client.security.tokens.PasswordToken;
 import org.apache.accumulo.core.data.Key;
 import org.apache.accumulo.core.data.Mutation;
@@ -37,8 +35,18 @@ import org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection;
 import org.apache.accumulo.core.security.Authorizations;
 import org.apache.accumulo.server.util.TabletIterator.TabletDeletedException;
 import org.apache.hadoop.io.Text;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.junit.rules.TestName;
+
+public class TabletIteratorTest {
+
+  @Rule
+  public TestName test = new TestName();
 
-public class TabletIteratorTest extends TestCase {
+  @Rule
+  public ExpectedException exception = ExpectedException.none();
 
   class TestTabletIterator extends TabletIterator {
 
@@ -78,8 +86,9 @@ public class TabletIteratorTest extends TestCase {
   }
 
   // simulate a merge happening while iterating over tablets
+  @Test
   public void testMerge() throws Exception {
-    MockInstance mi = new MockInstance();
+    Instance mi = new org.apache.accumulo.core.client.mock.MockInstance(test.getMethodName());
     Connector conn = mi.getConnector("", new PasswordToken(""));
 
     KeyExtent ke1 = new KeyExtent(new Text("0"), new Text("m"), null);
@@ -97,11 +106,9 @@ public class TabletIteratorTest extends TestCase {
 
     TestTabletIterator tabIter = new TestTabletIterator(conn);
 
-    try {
-      while (tabIter.hasNext()) {
-        tabIter.next();
-      }
-      assertTrue(false);
-    } catch (TabletDeletedException tde) {}
+    exception.expect(TabletDeletedException.class);
+    while (tabIter.hasNext()) {
+      tabIter.next();
+    }
   }
 }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/2556df3a/server/gc/src/test/java/org/apache/accumulo/gc/replication/CloseWriteAheadLogReferencesTest.java
----------------------------------------------------------------------
diff --git a/server/gc/src/test/java/org/apache/accumulo/gc/replication/CloseWriteAheadLogReferencesTest.java b/server/gc/src/test/java/org/apache/accumulo/gc/replication/CloseWriteAheadLogReferencesTest.java
index 7460b66..92a72fb 100644
--- a/server/gc/src/test/java/org/apache/accumulo/gc/replication/CloseWriteAheadLogReferencesTest.java
+++ b/server/gc/src/test/java/org/apache/accumulo/gc/replication/CloseWriteAheadLogReferencesTest.java
@@ -31,7 +31,6 @@ 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.mock.MockInstance;
 import org.apache.accumulo.core.client.security.tokens.PasswordToken;
 import org.apache.accumulo.core.conf.AccumuloConfiguration;
 import org.apache.accumulo.core.conf.ConfigurationCopy;
@@ -64,22 +63,28 @@ import com.google.common.collect.Iterables;
 public class CloseWriteAheadLogReferencesTest {
 
   private CloseWriteAheadLogReferences refs;
-  private Instance inst;
+  private Connector conn;
 
   @Rule
   public TestName testName = new TestName();
 
   @Before
+  public void setupInstance() throws Exception {
+    Instance inst = new org.apache.accumulo.core.client.mock.MockInstance(testName.getMethodName());
+    conn = inst.getConnector("root", new PasswordToken(""));
+  }
+
+  @Before
   public void setup() {
-    inst = createMock(Instance.class);
+    Instance mockInst = createMock(Instance.class);
     SiteConfiguration siteConfig = EasyMock.createMock(SiteConfiguration.class);
-    expect(inst.getInstanceID()).andReturn(testName.getMethodName()).anyTimes();
-    expect(inst.getZooKeepers()).andReturn("localhost").anyTimes();
-    expect(inst.getZooKeepersSessionTimeOut()).andReturn(30000).anyTimes();
+    expect(mockInst.getInstanceID()).andReturn(testName.getMethodName()).anyTimes();
+    expect(mockInst.getZooKeepers()).andReturn("localhost").anyTimes();
+    expect(mockInst.getZooKeepersSessionTimeOut()).andReturn(30000).anyTimes();
     final AccumuloConfiguration systemConf = new ConfigurationCopy(new HashMap<String,String>());
     ServerConfigurationFactory factory = createMock(ServerConfigurationFactory.class);
     expect(factory.getConfiguration()).andReturn(systemConf).anyTimes();
-    expect(factory.getInstance()).andReturn(inst).anyTimes();
+    expect(factory.getInstance()).andReturn(mockInst).anyTimes();
     expect(factory.getSiteConfiguration()).andReturn(siteConfig).anyTimes();
 
     // Just make the SiteConfiguration delegate to our AccumuloConfiguration
@@ -106,16 +111,13 @@ public class CloseWriteAheadLogReferencesTest {
       }
     }).anyTimes();
 
-    replay(inst, factory, siteConfig);
+    replay(mockInst, factory, siteConfig);
     refs = new CloseWriteAheadLogReferences(new AccumuloServerContext(factory));
   }
 
   @Test
   public void unclosedWalsLeaveStatusOpen() throws Exception {
     Set<String> wals = Collections.emptySet();
-    Instance inst = new MockInstance(testName.getMethodName());
-    Connector conn = inst.getConnector("root", new PasswordToken(""));
-
     BatchWriter bw = conn.createBatchWriter(MetadataTable.NAME, new BatchWriterConfig());
     Mutation m = new Mutation(ReplicationSection.getRowPrefix() + "file:/accumulo/wal/tserver+port/12345");
     m.put(ReplicationSection.COLF, new Text("1"), StatusUtil.fileCreatedValue(System.currentTimeMillis()));
@@ -134,9 +136,6 @@ public class CloseWriteAheadLogReferencesTest {
   public void closedWalsUpdateStatus() throws Exception {
     String file = "file:/accumulo/wal/tserver+port/12345";
     Set<String> wals = Collections.singleton(file);
-    Instance inst = new MockInstance(testName.getMethodName());
-    Connector conn = inst.getConnector("root", new PasswordToken(""));
-
     BatchWriter bw = conn.createBatchWriter(MetadataTable.NAME, new BatchWriterConfig());
     Mutation m = new Mutation(ReplicationSection.getRowPrefix() + file);
     m.put(ReplicationSection.COLF, new Text("1"), StatusUtil.fileCreatedValue(System.currentTimeMillis()));
@@ -155,9 +154,6 @@ public class CloseWriteAheadLogReferencesTest {
   public void partiallyReplicatedReferencedWalsAreNotClosed() throws Exception {
     String file = "file:/accumulo/wal/tserver+port/12345";
     Set<String> wals = Collections.singleton(file);
-    Instance inst = new MockInstance(testName.getMethodName());
-    Connector conn = inst.getConnector("root", new PasswordToken(""));
-
     BatchWriter bw = ReplicationTable.getBatchWriter(conn);
     Mutation m = new Mutation(file);
     StatusSection.add(m, new Text("1"), ProtobufUtil.toValue(StatusUtil.ingestedUntil(1000)));

http://git-wip-us.apache.org/repos/asf/accumulo/blob/2556df3a/server/master/src/test/java/org/apache/accumulo/master/ReplicationOperationsImplTest.java
----------------------------------------------------------------------
diff --git a/server/master/src/test/java/org/apache/accumulo/master/ReplicationOperationsImplTest.java b/server/master/src/test/java/org/apache/accumulo/master/ReplicationOperationsImplTest.java
index 3c3bc37..a18e5e9 100644
--- a/server/master/src/test/java/org/apache/accumulo/master/ReplicationOperationsImplTest.java
+++ b/server/master/src/test/java/org/apache/accumulo/master/ReplicationOperationsImplTest.java
@@ -33,7 +33,6 @@ import org.apache.accumulo.core.client.impl.ClientContext;
 import org.apache.accumulo.core.client.impl.Credentials;
 import org.apache.accumulo.core.client.impl.ReplicationOperationsImpl;
 import org.apache.accumulo.core.client.impl.thrift.ThriftTableOperationException;
-import org.apache.accumulo.core.client.mock.MockInstance;
 import org.apache.accumulo.core.client.security.tokens.PasswordToken;
 import org.apache.accumulo.core.data.Key;
 import org.apache.accumulo.core.data.Mutation;
@@ -63,14 +62,14 @@ import org.slf4j.LoggerFactory;
 public class ReplicationOperationsImplTest {
   private static final Logger log = LoggerFactory.getLogger(ReplicationOperationsImplTest.class);
 
-  private MockInstance inst;
+  private Instance inst;
 
   @Rule
   public TestName test = new TestName();
 
   @Before
   public void setup() {
-    inst = new MockInstance(test.getMethodName());
+    inst = new org.apache.accumulo.core.client.mock.MockInstance(test.getMethodName());
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/accumulo/blob/2556df3a/server/master/src/test/java/org/apache/accumulo/master/TestMergeState.java
----------------------------------------------------------------------
diff --git a/server/master/src/test/java/org/apache/accumulo/master/TestMergeState.java b/server/master/src/test/java/org/apache/accumulo/master/TestMergeState.java
index 8cbea68..a8fe771 100644
--- a/server/master/src/test/java/org/apache/accumulo/master/TestMergeState.java
+++ b/server/master/src/test/java/org/apache/accumulo/master/TestMergeState.java
@@ -27,7 +27,6 @@ import org.apache.accumulo.core.client.Connector;
 import org.apache.accumulo.core.client.Instance;
 import org.apache.accumulo.core.client.MutationsRejectedException;
 import org.apache.accumulo.core.client.TableNotFoundException;
-import org.apache.accumulo.core.client.mock.MockInstance;
 import org.apache.accumulo.core.data.Mutation;
 import org.apache.accumulo.core.data.Range;
 import org.apache.accumulo.core.data.Value;
@@ -49,13 +48,12 @@ import org.apache.accumulo.server.master.state.TServerInstance;
 import org.apache.accumulo.server.master.state.TabletLocationState;
 import org.apache.hadoop.io.Text;
 import org.junit.Assert;
+import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.TestName;
 
 import com.google.common.net.HostAndPort;
 
-/**
- *
- */
 public class TestMergeState {
 
   class MockCurrentState implements CurrentState {
@@ -104,9 +102,12 @@ public class TestMergeState {
     bw.close();
   }
 
+  @Rule
+  public TestName test = new TestName();
+
   @Test
   public void test() throws Exception {
-    Instance instance = new MockInstance();
+    Instance instance = new org.apache.accumulo.core.client.mock.MockInstance(test.getMethodName());
     AccumuloServerContext context = new AccumuloServerContext(new ServerConfigurationFactory(instance));
     Connector connector = context.getConnector();
     BatchWriter bw = connector.createBatchWriter(MetadataTable.NAME, new BatchWriterConfig());

http://git-wip-us.apache.org/repos/asf/accumulo/blob/2556df3a/server/master/src/test/java/org/apache/accumulo/master/replication/FinishedWorkUpdaterTest.java
----------------------------------------------------------------------
diff --git a/server/master/src/test/java/org/apache/accumulo/master/replication/FinishedWorkUpdaterTest.java b/server/master/src/test/java/org/apache/accumulo/master/replication/FinishedWorkUpdaterTest.java
index 4f1e159..864a79d 100644
--- a/server/master/src/test/java/org/apache/accumulo/master/replication/FinishedWorkUpdaterTest.java
+++ b/server/master/src/test/java/org/apache/accumulo/master/replication/FinishedWorkUpdaterTest.java
@@ -21,8 +21,8 @@ import java.util.UUID;
 
 import org.apache.accumulo.core.client.BatchWriter;
 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.mock.MockInstance;
 import org.apache.accumulo.core.client.security.tokens.PasswordToken;
 import org.apache.accumulo.core.data.Key;
 import org.apache.accumulo.core.data.Mutation;
@@ -52,7 +52,7 @@ public class FinishedWorkUpdaterTest {
 
   @Before
   public void setup() throws Exception {
-    MockInstance inst = new MockInstance(test.getMethodName());
+    Instance inst = new org.apache.accumulo.core.client.mock.MockInstance(test.getMethodName());
     conn = inst.getConnector("root", new PasswordToken(""));
     updater = new FinishedWorkUpdater(conn);
   }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/2556df3a/server/master/src/test/java/org/apache/accumulo/master/replication/RemoveCompleteReplicationRecordsTest.java
----------------------------------------------------------------------
diff --git a/server/master/src/test/java/org/apache/accumulo/master/replication/RemoveCompleteReplicationRecordsTest.java b/server/master/src/test/java/org/apache/accumulo/master/replication/RemoveCompleteReplicationRecordsTest.java
index 952fb2c..2555077 100644
--- a/server/master/src/test/java/org/apache/accumulo/master/replication/RemoveCompleteReplicationRecordsTest.java
+++ b/server/master/src/test/java/org/apache/accumulo/master/replication/RemoveCompleteReplicationRecordsTest.java
@@ -25,8 +25,8 @@ import java.util.UUID;
 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.Instance;
 import org.apache.accumulo.core.client.IteratorSetting;
-import org.apache.accumulo.core.client.mock.MockInstance;
 import org.apache.accumulo.core.client.security.tokens.PasswordToken;
 import org.apache.accumulo.core.data.Key;
 import org.apache.accumulo.core.data.Mutation;
@@ -54,7 +54,7 @@ import com.google.common.collect.Iterables;
 public class RemoveCompleteReplicationRecordsTest {
 
   private RemoveCompleteReplicationRecords rcrr;
-  private MockInstance inst;
+  private Instance inst;
   private Connector conn;
 
   @Rule
@@ -62,7 +62,7 @@ public class RemoveCompleteReplicationRecordsTest {
 
   @Before
   public void initialize() throws Exception {
-    inst = new MockInstance(test.getMethodName());
+    inst = new org.apache.accumulo.core.client.mock.MockInstance(test.getMethodName());
     conn = inst.getConnector("root", new PasswordToken(""));
     rcrr = new RemoveCompleteReplicationRecords(conn);
   }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/2556df3a/server/master/src/test/java/org/apache/accumulo/master/replication/SequentialWorkAssignerTest.java
----------------------------------------------------------------------
diff --git a/server/master/src/test/java/org/apache/accumulo/master/replication/SequentialWorkAssignerTest.java b/server/master/src/test/java/org/apache/accumulo/master/replication/SequentialWorkAssignerTest.java
index e05a17e..d4675db 100644
--- a/server/master/src/test/java/org/apache/accumulo/master/replication/SequentialWorkAssignerTest.java
+++ b/server/master/src/test/java/org/apache/accumulo/master/replication/SequentialWorkAssignerTest.java
@@ -29,8 +29,6 @@ import java.util.TreeMap;
 import org.apache.accumulo.core.client.BatchWriter;
 import org.apache.accumulo.core.client.Connector;
 import org.apache.accumulo.core.client.Instance;
-import org.apache.accumulo.core.client.impl.Credentials;
-import org.apache.accumulo.core.client.mock.MockInstance;
 import org.apache.accumulo.core.client.security.tokens.PasswordToken;
 import org.apache.accumulo.core.conf.AccumuloConfiguration;
 import org.apache.accumulo.core.data.Mutation;
@@ -60,13 +58,21 @@ public class SequentialWorkAssignerTest {
 
   private AccumuloConfiguration conf;
   private Connector conn;
+  private Connector mockConn;
   private SequentialWorkAssigner assigner;
 
   @Before
-  public void init() {
+  public void init() throws Exception {
     conf = createMock(AccumuloConfiguration.class);
     conn = createMock(Connector.class);
     assigner = new SequentialWorkAssigner(conf, conn);
+
+    Instance inst = new org.apache.accumulo.core.client.mock.MockInstance(test.getMethodName());
+    mockConn = inst.getConnector("root", new PasswordToken(""));
+    // Set the connector
+    assigner.setConnector(mockConn);
+    // grant ourselves write to the replication table
+    mockConn.securityOperations().grantTablePermission("root", ReplicationTable.NAME, TablePermission.WRITE);
   }
 
   @Test
@@ -74,18 +80,8 @@ public class SequentialWorkAssignerTest {
     ReplicationTarget target = new ReplicationTarget("cluster1", "table1", "1");
     Text serializedTarget = target.toText();
 
-    MockInstance inst = new MockInstance(test.getMethodName());
-    Credentials creds = new Credentials("root", new PasswordToken(""));
-    Connector conn = inst.getConnector(creds.getPrincipal(), creds.getToken());
-
-    // Set the connector
-    assigner.setConnector(conn);
-
-    // grant ourselves write to the replication table
-    conn.securityOperations().grantTablePermission("root", ReplicationTable.NAME, TablePermission.WRITE);
-
     // Create two mutations, both of which need replication work done
-    BatchWriter bw = ReplicationTable.getBatchWriter(conn);
+    BatchWriter bw = ReplicationTable.getBatchWriter(mockConn);
     // We want the name of file2 to sort before file1
     String filename1 = "z_file1", filename2 = "a_file1";
     String file1 = "/accumulo/wal/tserver+port/" + filename1, file2 = "/accumulo/wal/tserver+port/" + filename2;
@@ -146,18 +142,8 @@ public class SequentialWorkAssignerTest {
     ReplicationTarget target2 = new ReplicationTarget("cluster1", "table2", "2");
     Text serializedTarget2 = target2.toText();
 
-    MockInstance inst = new MockInstance(test.getMethodName());
-    Credentials creds = new Credentials("root", new PasswordToken(""));
-    Connector conn = inst.getConnector(creds.getPrincipal(), creds.getToken());
-
-    // Set the connector
-    assigner.setConnector(conn);
-
-    // grant ourselves write to the replication table
-    conn.securityOperations().grantTablePermission("root", ReplicationTable.NAME, TablePermission.WRITE);
-
     // Create two mutations, both of which need replication work done
-    BatchWriter bw = ReplicationTable.getBatchWriter(conn);
+    BatchWriter bw = ReplicationTable.getBatchWriter(mockConn);
     // We want the name of file2 to sort before file1
     String filename1 = "z_file1", filename2 = "a_file1";
     String file1 = "/accumulo/wal/tserver+port/" + filename1, file2 = "/accumulo/wal/tserver+port/" + filename2;
@@ -225,18 +211,8 @@ public class SequentialWorkAssignerTest {
     ReplicationTarget target2 = new ReplicationTarget("cluster2", "table1", "1");
     Text serializedTarget2 = target2.toText();
 
-    MockInstance inst = new MockInstance(test.getMethodName());
-    Credentials creds = new Credentials("root", new PasswordToken(""));
-    Connector conn = inst.getConnector(creds.getPrincipal(), creds.getToken());
-
-    // Set the connector
-    assigner.setConnector(conn);
-
-    // grant ourselves write to the replication table
-    conn.securityOperations().grantTablePermission("root", ReplicationTable.NAME, TablePermission.WRITE);
-
     // Create two mutations, both of which need replication work done
-    BatchWriter bw = ReplicationTable.getBatchWriter(conn);
+    BatchWriter bw = ReplicationTable.getBatchWriter(mockConn);
     // We want the name of file2 to sort before file1
     String filename1 = "z_file1", filename2 = "a_file1";
     String file1 = "/accumulo/wal/tserver+port/" + filename1, file2 = "/accumulo/wal/tserver+port/" + filename2;
@@ -345,18 +321,8 @@ public class SequentialWorkAssignerTest {
     ReplicationTarget target = new ReplicationTarget("cluster1", "table1", "1");
     Text serializedTarget = target.toText();
 
-    MockInstance inst = new MockInstance(test.getMethodName());
-    Credentials creds = new Credentials("root", new PasswordToken(""));
-    Connector conn = inst.getConnector(creds.getPrincipal(), creds.getToken());
-
-    // Set the connector
-    assigner.setConnector(conn);
-
-    // grant ourselves write to the replication table
-    conn.securityOperations().grantTablePermission("root", ReplicationTable.NAME, TablePermission.WRITE);
-
     // Create two mutations, both of which need replication work done
-    BatchWriter bw = ReplicationTable.getBatchWriter(conn);
+    BatchWriter bw = ReplicationTable.getBatchWriter(mockConn);
     // We want the name of file2 to sort before file1
     String filename1 = "z_file1", filename2 = "a_file1";
     String file1 = "/accumulo/wal/tserver+port/" + filename1, file2 = "/accumulo/wal/tserver+port/" + filename2;

http://git-wip-us.apache.org/repos/asf/accumulo/blob/2556df3a/server/master/src/test/java/org/apache/accumulo/master/replication/StatusMakerTest.java
----------------------------------------------------------------------
diff --git a/server/master/src/test/java/org/apache/accumulo/master/replication/StatusMakerTest.java b/server/master/src/test/java/org/apache/accumulo/master/replication/StatusMakerTest.java
index b57fd89..11be4fb 100644
--- a/server/master/src/test/java/org/apache/accumulo/master/replication/StatusMakerTest.java
+++ b/server/master/src/test/java/org/apache/accumulo/master/replication/StatusMakerTest.java
@@ -28,9 +28,9 @@ import java.util.UUID;
 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.impl.Credentials;
-import org.apache.accumulo.core.client.mock.MockInstance;
 import org.apache.accumulo.core.client.security.tokens.PasswordToken;
 import org.apache.accumulo.core.data.Key;
 import org.apache.accumulo.core.data.Mutation;
@@ -46,6 +46,7 @@ import org.apache.accumulo.server.replication.proto.Replication.Status;
 import org.apache.accumulo.server.util.ReplicationTableUtil;
 import org.apache.hadoop.io.Text;
 import org.junit.Assert;
+import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TestName;
@@ -58,12 +59,17 @@ public class StatusMakerTest {
   @Rule
   public TestName test = new TestName();
 
-  @Test
-  public void statusRecordsCreated() throws Exception {
-    MockInstance inst = new MockInstance(test.getMethodName());
+  private Connector conn;
+
+  @Before
+  public void setupInstance() throws Exception {
+    Instance inst = new org.apache.accumulo.core.client.mock.MockInstance(test.getMethodName());
     Credentials creds = new Credentials("root", new PasswordToken(""));
-    Connector conn = inst.getConnector(creds.getPrincipal(), creds.getToken());
+    conn = inst.getConnector(creds.getPrincipal(), creds.getToken());
+  }
 
+  @Test
+  public void statusRecordsCreated() throws Exception {
     String sourceTable = "source";
     conn.tableOperations().create(sourceTable);
     ReplicationTableUtil.configureMetadataTable(conn, sourceTable);
@@ -111,10 +117,6 @@ public class StatusMakerTest {
 
   @Test
   public void openMessagesAreNotDeleted() throws Exception {
-    MockInstance inst = new MockInstance(test.getMethodName());
-    Credentials creds = new Credentials("root", new PasswordToken(""));
-    Connector conn = inst.getConnector(creds.getPrincipal(), creds.getToken());
-
     String sourceTable = "source";
     conn.tableOperations().create(sourceTable);
     ReplicationTableUtil.configureMetadataTable(conn, sourceTable);
@@ -151,10 +153,6 @@ public class StatusMakerTest {
 
   @Test
   public void closedMessagesAreDeleted() throws Exception {
-    MockInstance inst = new MockInstance(test.getMethodName());
-    Credentials creds = new Credentials("root", new PasswordToken(""));
-    Connector conn = inst.getConnector(creds.getPrincipal(), creds.getToken());
-
     String sourceTable = "source";
     conn.tableOperations().create(sourceTable);
     ReplicationTableUtil.configureMetadataTable(conn, sourceTable);
@@ -198,10 +196,6 @@ public class StatusMakerTest {
 
   @Test
   public void closedMessagesCreateOrderRecords() throws Exception {
-    MockInstance inst = new MockInstance(test.getMethodName());
-    Credentials creds = new Credentials("root", new PasswordToken(""));
-    Connector conn = inst.getConnector(creds.getPrincipal(), creds.getToken());
-
     String sourceTable = "source";
     conn.tableOperations().create(sourceTable);
     ReplicationTableUtil.configureMetadataTable(conn, sourceTable);

http://git-wip-us.apache.org/repos/asf/accumulo/blob/2556df3a/server/master/src/test/java/org/apache/accumulo/master/replication/UnorderedWorkAssignerTest.java
----------------------------------------------------------------------
diff --git a/server/master/src/test/java/org/apache/accumulo/master/replication/UnorderedWorkAssignerTest.java b/server/master/src/test/java/org/apache/accumulo/master/replication/UnorderedWorkAssignerTest.java
index 35df344..f4c53f0 100644
--- a/server/master/src/test/java/org/apache/accumulo/master/replication/UnorderedWorkAssignerTest.java
+++ b/server/master/src/test/java/org/apache/accumulo/master/replication/UnorderedWorkAssignerTest.java
@@ -33,8 +33,6 @@ import org.apache.accumulo.core.Constants;
 import org.apache.accumulo.core.client.BatchWriter;
 import org.apache.accumulo.core.client.Connector;
 import org.apache.accumulo.core.client.Instance;
-import org.apache.accumulo.core.client.impl.Credentials;
-import org.apache.accumulo.core.client.mock.MockInstance;
 import org.apache.accumulo.core.client.security.tokens.PasswordToken;
 import org.apache.accumulo.core.conf.AccumuloConfiguration;
 import org.apache.accumulo.core.data.Mutation;
@@ -65,13 +63,17 @@ public class UnorderedWorkAssignerTest {
 
   private AccumuloConfiguration conf;
   private Connector conn;
+  private Connector mockConn;
   private UnorderedWorkAssigner assigner;
 
   @Before
-  public void init() {
+  public void init() throws Exception {
     conf = createMock(AccumuloConfiguration.class);
     conn = createMock(Connector.class);
     assigner = new UnorderedWorkAssigner(conf, conn);
+
+    Instance inst = new org.apache.accumulo.core.client.mock.MockInstance(test.getMethodName());
+    mockConn = inst.getConnector("root", new PasswordToken(""));
   }
 
   @Test
@@ -128,15 +130,11 @@ public class UnorderedWorkAssignerTest {
         + DistributedWorkQueueWorkAssignerHelper.KEY_SEPARATOR + target2.getRemoteIdentifier() + DistributedWorkQueueWorkAssignerHelper.KEY_SEPARATOR
         + target2.getSourceTableId();
 
-    MockInstance inst = new MockInstance(test.getMethodName());
-    Credentials creds = new Credentials("root", new PasswordToken(""));
-    Connector conn = inst.getConnector(creds.getPrincipal(), creds.getToken());
-
     // Set the connector
-    assigner.setConnector(conn);
+    assigner.setConnector(mockConn);
 
     // grant ourselves write to the replication table
-    conn.securityOperations().grantTablePermission("root", ReplicationTable.NAME, TablePermission.WRITE);
+    mockConn.securityOperations().grantTablePermission("root", ReplicationTable.NAME, TablePermission.WRITE);
 
     Status.Builder builder = Status.newBuilder().setBegin(0).setEnd(0).setInfiniteEnd(true).setClosed(false).setCreatedTime(5l);
     Status status1 = builder.build();
@@ -144,7 +142,7 @@ public class UnorderedWorkAssignerTest {
     Status status2 = builder.build();
 
     // Create two mutations, both of which need replication work done
-    BatchWriter bw = ReplicationTable.getBatchWriter(conn);
+    BatchWriter bw = ReplicationTable.getBatchWriter(mockConn);
     String filename1 = UUID.randomUUID().toString(), filename2 = UUID.randomUUID().toString();
     String file1 = "/accumulo/wal/tserver+port/" + filename1, file2 = "/accumulo/wal/tserver+port/" + filename2;
     Mutation m = new Mutation(file1);
@@ -190,18 +188,14 @@ public class UnorderedWorkAssignerTest {
     ReplicationTarget target1 = new ReplicationTarget("cluster1", "table1", "1"), target2 = new ReplicationTarget("cluster1", "table2", "2");
     Text serializedTarget1 = target1.toText(), serializedTarget2 = target2.toText();
 
-    MockInstance inst = new MockInstance(test.getMethodName());
-    Credentials creds = new Credentials("root", new PasswordToken(""));
-    Connector conn = inst.getConnector(creds.getPrincipal(), creds.getToken());
-
     // Set the connector
-    assigner.setConnector(conn);
+    assigner.setConnector(mockConn);
 
     // grant ourselves write to the replication table
-    conn.securityOperations().grantTablePermission("root", ReplicationTable.NAME, TablePermission.WRITE);
+    mockConn.securityOperations().grantTablePermission("root", ReplicationTable.NAME, TablePermission.WRITE);
 
     // Create two mutations, both of which need replication work done
-    BatchWriter bw = ReplicationTable.getBatchWriter(conn);
+    BatchWriter bw = ReplicationTable.getBatchWriter(mockConn);
     String filename1 = UUID.randomUUID().toString(), filename2 = UUID.randomUUID().toString();
     String file1 = "/accumulo/wal/tserver+port/" + filename1, file2 = "/accumulo/wal/tserver+port/" + filename2;
 
@@ -261,18 +255,14 @@ public class UnorderedWorkAssignerTest {
 
     queuedWork.add("wal1|" + serializedTarget.toString());
 
-    MockInstance inst = new MockInstance(test.getMethodName());
-    Credentials creds = new Credentials("root", new PasswordToken(""));
-    Connector conn = inst.getConnector(creds.getPrincipal(), creds.getToken());
-
     // Set the connector
-    assigner.setConnector(conn);
+    assigner.setConnector(mockConn);
 
     // grant ourselves write to the replication table
-    conn.securityOperations().grantTablePermission("root", ReplicationTable.NAME, TablePermission.WRITE);
+    mockConn.securityOperations().grantTablePermission("root", ReplicationTable.NAME, TablePermission.WRITE);
 
     // Create two mutations, both of which need replication work done
-    BatchWriter bw = ReplicationTable.getBatchWriter(conn);
+    BatchWriter bw = ReplicationTable.getBatchWriter(mockConn);
     String file1 = "/accumulo/wal/tserver+port/wal1";
     Mutation m = new Mutation(file1);
     WorkSection.add(m, target.toText(), StatusUtil.openWithUnknownLengthValue());

http://git-wip-us.apache.org/repos/asf/accumulo/blob/2556df3a/server/master/src/test/java/org/apache/accumulo/master/replication/WorkMakerTest.java
----------------------------------------------------------------------
diff --git a/server/master/src/test/java/org/apache/accumulo/master/replication/WorkMakerTest.java b/server/master/src/test/java/org/apache/accumulo/master/replication/WorkMakerTest.java
index 6373def..d6d0b9a 100644
--- a/server/master/src/test/java/org/apache/accumulo/master/replication/WorkMakerTest.java
+++ b/server/master/src/test/java/org/apache/accumulo/master/replication/WorkMakerTest.java
@@ -23,8 +23,8 @@ import java.util.Set;
 
 import org.apache.accumulo.core.client.BatchWriter;
 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.mock.MockInstance;
 import org.apache.accumulo.core.conf.Property;
 import org.apache.accumulo.core.data.Key;
 import org.apache.accumulo.core.data.Mutation;
@@ -51,7 +51,7 @@ import com.google.common.collect.Iterables;
 
 public class WorkMakerTest {
 
-  private MockInstance instance;
+  private Instance instance;
   private Connector conn;
 
   @Rule
@@ -60,7 +60,7 @@ public class WorkMakerTest {
 
   @Before
   public void createMockAccumulo() throws Exception {
-    instance = new MockInstance();
+    instance = new org.apache.accumulo.core.client.mock.MockInstance(name.getMethodName());
     context = new AccumuloServerContext(new ServerConfigurationFactory(instance));
     conn = context.getConnector();
     conn.securityOperations().grantTablePermission("root", ReplicationTable.NAME, TablePermission.WRITE);

http://git-wip-us.apache.org/repos/asf/accumulo/blob/2556df3a/server/tserver/src/test/java/org/apache/accumulo/tserver/LargestFirstMemoryManagerTest.java
----------------------------------------------------------------------
diff --git a/server/tserver/src/test/java/org/apache/accumulo/tserver/LargestFirstMemoryManagerTest.java b/server/tserver/src/test/java/org/apache/accumulo/tserver/LargestFirstMemoryManagerTest.java
index f3bd220..e0dc0c0 100644
--- a/server/tserver/src/test/java/org/apache/accumulo/tserver/LargestFirstMemoryManagerTest.java
+++ b/server/tserver/src/test/java/org/apache/accumulo/tserver/LargestFirstMemoryManagerTest.java
@@ -22,7 +22,6 @@ import java.util.Arrays;
 import java.util.List;
 
 import org.apache.accumulo.core.client.Instance;
-import org.apache.accumulo.core.client.mock.MockInstance;
 import org.apache.accumulo.core.conf.AccumuloConfiguration;
 import org.apache.accumulo.core.conf.DefaultConfiguration;
 import org.apache.accumulo.core.data.impl.KeyExtent;
@@ -34,6 +33,8 @@ import org.apache.accumulo.server.tabletserver.LargestFirstMemoryManager;
 import org.apache.accumulo.server.tabletserver.MemoryManagementActions;
 import org.apache.accumulo.server.tabletserver.TabletState;
 import org.apache.hadoop.io.Text;
+import org.easymock.EasyMock;
+import org.junit.Before;
 import org.junit.Test;
 
 import com.google.common.base.Function;
@@ -47,11 +48,18 @@ public class LargestFirstMemoryManagerTest {
   private static final long QGIG = ONE_GIG / 4;
   private static final long ONE_MINUTE = 60 * 1000;
 
+  private Instance inst;
+
+  @Before
+  public void mockInstance() {
+    inst = EasyMock.createMock(Instance.class);
+  }
+
   @Test
   public void test() throws Exception {
     LargestFirstMemoryManagerUnderTest mgr = new LargestFirstMemoryManagerUnderTest();
     ServerConfiguration config = new ServerConfiguration() {
-      ServerConfigurationFactory delegate = new ServerConfigurationFactory(new MockInstance());
+      ServerConfigurationFactory delegate = new ServerConfigurationFactory(inst);
 
       @Override
       public AccumuloConfiguration getConfiguration() {
@@ -176,7 +184,7 @@ public class LargestFirstMemoryManagerTest {
     };
     LargestFirstMemoryManagerWithExistenceCheck mgr = new LargestFirstMemoryManagerWithExistenceCheck(existenceCheck);
     ServerConfiguration config = new ServerConfiguration() {
-      ServerConfigurationFactory delegate = new ServerConfigurationFactory(new MockInstance());
+      ServerConfigurationFactory delegate = new ServerConfigurationFactory(inst);
 
       @Override
       public AccumuloConfiguration getConfiguration() {

http://git-wip-us.apache.org/repos/asf/accumulo/blob/2556df3a/shell/src/main/java/org/apache/accumulo/shell/Shell.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/accumulo/shell/Shell.java b/shell/src/main/java/org/apache/accumulo/shell/Shell.java
index 4734cb1..b140fe7 100644
--- a/shell/src/main/java/org/apache/accumulo/shell/Shell.java
+++ b/shell/src/main/java/org/apache/accumulo/shell/Shell.java
@@ -59,7 +59,6 @@ import org.apache.accumulo.core.client.TableNotFoundException;
 import org.apache.accumulo.core.client.ZooKeeperInstance;
 import org.apache.accumulo.core.client.impl.ClientContext;
 import org.apache.accumulo.core.client.impl.Tables;
-import org.apache.accumulo.core.client.mock.MockInstance;
 import org.apache.accumulo.core.client.security.tokens.AuthenticationToken;
 import org.apache.accumulo.core.client.security.tokens.PasswordToken;
 import org.apache.accumulo.core.conf.AccumuloConfiguration;
@@ -71,6 +70,7 @@ import org.apache.accumulo.core.data.thrift.TConstraintViolationSummary;
 import org.apache.accumulo.core.tabletserver.thrift.ConstraintViolationException;
 import org.apache.accumulo.core.trace.DistributedTrace;
 import org.apache.accumulo.core.util.BadArgumentException;
+import org.apache.accumulo.core.util.DeprecationUtil;
 import org.apache.accumulo.core.util.format.BinaryFormatter;
 import org.apache.accumulo.core.util.format.DefaultFormatter;
 import org.apache.accumulo.core.util.format.Formatter;
@@ -315,7 +315,7 @@ public class Shell extends ShellOptions implements KeywordExecutable {
 
     tabCompletion = !options.isTabCompletionDisabled();
 
-    // Use a fake (Mock), ZK, or HdfsZK Accumulo instance
+    // Use a ZK, or HdfsZK Accumulo instance
     setInstance(options);
 
     // AuthenticationToken options
@@ -448,7 +448,7 @@ public class Shell extends ShellOptions implements KeywordExecutable {
     // should only be one set of instance options set
     instance = null;
     if (options.isFake()) {
-      instance = new MockInstance("fake");
+      instance = DeprecationUtil.makeMockInstance("fake");
     } else {
       String instanceName, hosts;
       if (options.isHdfsZooInstance()) {

http://git-wip-us.apache.org/repos/asf/accumulo/blob/2556df3a/shell/src/main/java/org/apache/accumulo/shell/mock/MockShell.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/accumulo/shell/mock/MockShell.java b/shell/src/main/java/org/apache/accumulo/shell/mock/MockShell.java
index 609f23f..f2bd075 100644
--- a/shell/src/main/java/org/apache/accumulo/shell/mock/MockShell.java
+++ b/shell/src/main/java/org/apache/accumulo/shell/mock/MockShell.java
@@ -28,7 +28,6 @@ import jline.console.ConsoleReader;
 import org.apache.accumulo.core.client.AccumuloException;
 import org.apache.accumulo.core.client.AccumuloSecurityException;
 import org.apache.accumulo.core.client.TableNotFoundException;
-import org.apache.accumulo.core.client.mock.MockInstance;
 import org.apache.accumulo.shell.Shell;
 import org.apache.accumulo.shell.ShellOptionsJC;
 import org.apache.commons.cli.CommandLine;
@@ -36,7 +35,10 @@ import org.apache.commons.vfs2.FileSystemException;
 
 /**
  * An Accumulo Shell implementation that allows a developer to attach an InputStream and Writer to the Shell for testing purposes.
+ *
+ * @deprecated since 1.8.0; use MiniAccumuloCluster or a standard mock framework instead.
  */
+@Deprecated
 public class MockShell extends Shell {
   private static final String NEWLINE = "\n";
 
@@ -76,7 +78,7 @@ public class MockShell extends Shell {
   @Override
   protected void setInstance(ShellOptionsJC options) {
     // We always want a MockInstance for this test
-    instance = new MockInstance();
+    instance = new org.apache.accumulo.core.client.mock.MockInstance();
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/accumulo/blob/2556df3a/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 e592abb..4d74f65 100644
--- a/shell/src/test/java/org/apache/accumulo/shell/ShellSetInstanceTest.java
+++ b/shell/src/test/java/org/apache/accumulo/shell/ShellSetInstanceTest.java
@@ -39,7 +39,6 @@ import jline.console.ConsoleReader;
 import org.apache.accumulo.core.client.ClientConfiguration;
 import org.apache.accumulo.core.client.ClientConfiguration.ClientProperty;
 import org.apache.accumulo.core.client.ZooKeeperInstance;
-import org.apache.accumulo.core.client.mock.MockInstance;
 import org.apache.accumulo.core.conf.AccumuloConfiguration;
 import org.apache.accumulo.core.conf.ConfigSanityCheck;
 import org.apache.accumulo.core.conf.Property;
@@ -124,12 +123,12 @@ public class ShellSetInstanceTest {
     ShellOptionsJC opts = createMock(ShellOptionsJC.class);
     expect(opts.isFake()).andReturn(true);
     replay(opts);
-    MockInstance theInstance = createMock(MockInstance.class);
-    expectNew(MockInstance.class, "fake").andReturn(theInstance);
-    replay(theInstance, MockInstance.class);
+    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, MockInstance.class);
+    verify(theInstance, org.apache.accumulo.core.client.mock.MockInstance.class);
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/accumulo/blob/2556df3a/shell/src/test/java/org/apache/accumulo/shell/commands/FormatterCommandTest.java
----------------------------------------------------------------------
diff --git a/shell/src/test/java/org/apache/accumulo/shell/commands/FormatterCommandTest.java b/shell/src/test/java/org/apache/accumulo/shell/commands/FormatterCommandTest.java
index 704d0c3..02a9ee2 100644
--- a/shell/src/test/java/org/apache/accumulo/shell/commands/FormatterCommandTest.java
+++ b/shell/src/test/java/org/apache/accumulo/shell/commands/FormatterCommandTest.java
@@ -33,14 +33,13 @@ import org.apache.accumulo.core.data.Key;
 import org.apache.accumulo.core.data.Value;
 import org.apache.accumulo.core.util.format.Formatter;
 import org.apache.accumulo.shell.Shell;
-import org.apache.accumulo.shell.mock.MockShell;
 import org.apache.log4j.Level;
 import org.apache.log4j.Logger;
 import org.junit.Assert;
 import org.junit.Test;
 
 /**
- * Uses the MockShell to test the shell output with Formatters
+ * Tests the shell output with Formatters
  */
 public class FormatterCommandTest {
   ByteArrayOutputStream out = null;
@@ -57,10 +56,10 @@ public class FormatterCommandTest {
 
     final String[] commands = createCommands();
 
-    in = MockShell.makeCommands(commands);
+    in = org.apache.accumulo.shell.mock.MockShell.makeCommands(commands);
     out = new ByteArrayOutputStream();
 
-    final MockShell shell = new MockShell(in, out);
+    final Shell shell = new org.apache.accumulo.shell.mock.MockShell(in, out);
     assertTrue("Failed to configure shell without error", shell.config(args));
 
     // Can't call createtable in the shell with MockAccumulo

http://git-wip-us.apache.org/repos/asf/accumulo/blob/2556df3a/test/src/test/java/org/apache/accumulo/test/iterator/RegExTest.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/iterator/RegExTest.java b/test/src/test/java/org/apache/accumulo/test/iterator/RegExTest.java
index 82c89be..271822d 100644
--- a/test/src/test/java/org/apache/accumulo/test/iterator/RegExTest.java
+++ b/test/src/test/java/org/apache/accumulo/test/iterator/RegExTest.java
@@ -28,7 +28,6 @@ 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.ScannerBase;
-import org.apache.accumulo.core.client.mock.MockInstance;
 import org.apache.accumulo.core.client.security.tokens.PasswordToken;
 import org.apache.accumulo.core.data.Key;
 import org.apache.accumulo.core.data.Mutation;
@@ -37,15 +36,16 @@ import org.apache.accumulo.core.data.Value;
 import org.apache.accumulo.core.iterators.user.RegExFilter;
 import org.apache.accumulo.core.security.Authorizations;
 import org.apache.hadoop.io.Text;
+import org.junit.BeforeClass;
 import org.junit.Test;
 
 public class RegExTest {
 
-  Instance inst = new MockInstance();
-  Connector conn;
+  private static Connector conn;
 
-  @Test
-  public void runTest() throws Exception {
+  @BeforeClass
+  public static void setupTests() throws Exception {
+    Instance inst = new org.apache.accumulo.core.client.mock.MockInstance(RegExTest.class.getName());
     conn = inst.getConnector("user", new PasswordToken("pass"));
     conn.tableOperations().create("ret");
     BatchWriter bw = conn.createBatchWriter("ret", new BatchWriterConfig());
@@ -71,12 +71,6 @@ public class RegExTest {
     }
 
     bw.close();
-
-    runTest1();
-    runTest2();
-    runTest3();
-    runTest4();
-    runTest5();
   }
 
   private void check(String regex, String val) throws Exception {
@@ -92,31 +86,36 @@ public class RegExTest {
     check(regex, val.toString());
   }
 
-  private void runTest1() throws Exception {
+  @Test
+  public void runTest1() throws Exception {
     // try setting all regex
     Range range = new Range(new Text("rf"), true, new Text("rl"), true);
     runTest(range, "r[g-k]", "cf[1-5]", "cq[x-z]", "v[g-k][1-5][t-y]", 5 * 5 * (3 - 1));
   }
 
-  private void runTest2() throws Exception {
+  @Test
+  public void runTest2() throws Exception {
     // try setting only a row regex
     Range range = new Range(new Text("rf"), true, new Text("rl"), true);
     runTest(range, "r[g-k]", null, null, null, 5 * 36 * 36);
   }
 
-  private void runTest3() throws Exception {
+  @Test
+  public void runTest3() throws Exception {
     // try setting only a col fam regex
     Range range = new Range((Key) null, (Key) null);
     runTest(range, null, "cf[a-f]", null, null, 36 * 6 * 36);
   }
 
-  private void runTest4() throws Exception {
+  @Test
+  public void runTest4() throws Exception {
     // try setting only a col qual regex
     Range range = new Range((Key) null, (Key) null);
     runTest(range, null, null, "cq[1-7]", null, 36 * 36 * 7);
   }
 
-  private void runTest5() throws Exception {
+  @Test
+  public void runTest5() throws Exception {
     // try setting only a value regex
     Range range = new Range((Key) null, (Key) null);
     runTest(range, null, null, null, "v[a-c][d-f][g-i]", 3 * 3 * 3);


Mime
View raw message