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 2020/12/15 19:34:05 UTC

[accumulo] branch 1.10 updated: Backport JUnit upgrade from #1562 to 1.10.1

This is an automated email from the ASF dual-hosted git repository.

ctubbsii pushed a commit to branch 1.10
in repository https://gitbox.apache.org/repos/asf/accumulo.git


The following commit(s) were added to refs/heads/1.10 by this push:
     new d4fd27f  Backport JUnit upgrade from #1562 to 1.10.1
d4fd27f is described below

commit d4fd27f32dc2611a23f67b1d3e8dafd8ee05a1cb
Author: Christopher Tubbs <ct...@apache.org>
AuthorDate: Tue Dec 15 13:25:08 2020 -0500

    Backport JUnit upgrade from #1562 to 1.10.1
    
    Update JUnit dependency, and use assertThrows instead of
    ExpectedException Rule and hamcrest library, to avoid deprecation
    warnings and an unnecessary test dependency.
---
 .../core/conf/AccumuloConfigurationTest.java       |  9 +--
 .../apache/accumulo/core/data/KeyExtentTest.java   | 26 ++++-----
 .../accumulo/core/security/crypto/CryptoTest.java  | 17 ++----
 .../accumulo/core/util/PreAllocatedArrayTest.java  | 21 ++-----
 .../core/util/UnsynchronizedBufferTest.java        | 14 ++---
 .../org/apache/accumulo/fate/util/RetryTest.java   | 39 +++++--------
 pom.xml                                            |  2 +-
 .../accumulo/server/util/TabletIteratorTest.java   | 41 ++++++-------
 .../apache/accumulo/tserver/InMemoryMapTest.java   | 18 +++---
 .../tserver/compaction/CompactionPlanTest.java     | 16 ++----
 .../tserver/log/SortedLogRecoveryTest.java         | 18 +++---
 .../accumulo/test/functional/ClassLoaderIT.java    |  3 +-
 .../accumulo/test/functional/KerberosProxyIT.java  | 67 ++++++----------------
 .../apache/accumulo/test/functional/MergeIT.java   | 15 ++---
 .../accumulo/test/functional/ScannerContextIT.java |  3 +-
 .../apache/accumulo/test/functional/TableIT.java   |  3 +-
 16 files changed, 110 insertions(+), 202 deletions(-)

diff --git a/core/src/test/java/org/apache/accumulo/core/conf/AccumuloConfigurationTest.java b/core/src/test/java/org/apache/accumulo/core/conf/AccumuloConfigurationTest.java
index 7a0f349..df78ade 100644
--- a/core/src/test/java/org/apache/accumulo/core/conf/AccumuloConfigurationTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/conf/AccumuloConfigurationTest.java
@@ -19,24 +19,20 @@ package org.apache.accumulo.core.conf;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotSame;
 import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertThrows;
 import static org.junit.Assert.assertTrue;
 
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Map.Entry;
 
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import com.google.common.base.Predicate;
 import com.google.common.collect.ImmutableMap;
 
 public class AccumuloConfigurationTest {
 
-  @Rule
-  public ExpectedException thrown = ExpectedException.none();
-
   @Test
   public void testGetMemoryInBytes() throws Exception {
     assertEquals(42l, AccumuloConfiguration.getMemoryInBytes("42"));
@@ -205,8 +201,7 @@ public class AccumuloConfigurationTest {
     expected1.put(Property.TABLE_ARBITRARY_PROP_PREFIX.getKey() + "a2", "asg34");
     assertEquals(expected1, pm1);
 
-    thrown.expect(UnsupportedOperationException.class);
-    pm1.put("k9", "v3");
+    assertThrows(UnsupportedOperationException.class, () -> pm1.put("k9", "v3"));
   }
 
   @Test
diff --git a/core/src/test/java/org/apache/accumulo/core/data/KeyExtentTest.java b/core/src/test/java/org/apache/accumulo/core/data/KeyExtentTest.java
index e7abea9..71371ff 100644
--- a/core/src/test/java/org/apache/accumulo/core/data/KeyExtentTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/data/KeyExtentTest.java
@@ -16,13 +16,9 @@
  */
 package org.apache.accumulo.core.data;
 
-import static org.hamcrest.CoreMatchers.hasItem;
-import static org.hamcrest.CoreMatchers.hasItems;
-import static org.hamcrest.CoreMatchers.is;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
 
 import java.io.ByteArrayInputStream;
@@ -323,24 +319,26 @@ public class KeyExtentTest {
     Collection<KeyExtent> results;
 
     results = KeyExtent.getKeyExtentsForRange(null, null, set0);
-    assertThat("infinite range should return full set", results.size(), is(5));
-    assertThat("infinite range should return full set", results, hasItems(b, e, h, m, z));
+    assertEquals("infinite range should return full set", 5, results.size());
+    assertTrue("infinite range should return full set",
+        results.containsAll(Arrays.asList(b, e, h, m, z)));
 
     results = KeyExtent.getKeyExtentsForRange(new Text("a"), new Text("z"), set0);
-    assertThat("full overlap should return full set", results.size(), is(5));
-    assertThat("full overlap should return full set", results, hasItems(b, e, h, m, z));
+    assertEquals("full overlap should return full set", 5, results.size(), 5);
+    assertTrue("full overlap should return full set",
+        results.containsAll(Arrays.asList(b, e, h, m, z)));
 
     results = KeyExtent.getKeyExtentsForRange(null, new Text("f"), set0);
-    assertThat("end row should return head set", results.size(), is(3));
-    assertThat("end row should return head set", results, hasItems(b, e, h));
+    assertEquals("end row should return head set", 3, results.size());
+    assertTrue("end row should return head set", results.containsAll(Arrays.asList(b, e, h)));
 
     results = KeyExtent.getKeyExtentsForRange(new Text("f"), null, set0);
-    assertThat("start row should return tail set", results.size(), is(3));
-    assertThat("start row should return tail set", results, hasItems(h, m, z));
+    assertEquals("start row should return tail set", 3, results.size());
+    assertTrue("start row should return tail set", results.containsAll(Arrays.asList(h, m, z)));
 
     results = KeyExtent.getKeyExtentsForRange(new Text("f"), new Text("g"), set0);
-    assertThat("slice should return correct subset", results.size(), is(1));
-    assertThat("slice should return correct subset", results, hasItem(h));
+    assertEquals("slice should return correct subset", 1, results.size());
+    assertTrue("slice should return correct subset", results.contains(h));
   }
 
   @Test
diff --git a/core/src/test/java/org/apache/accumulo/core/security/crypto/CryptoTest.java b/core/src/test/java/org/apache/accumulo/core/security/crypto/CryptoTest.java
index 1705fcc..bae418f 100644
--- a/core/src/test/java/org/apache/accumulo/core/security/crypto/CryptoTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/security/crypto/CryptoTest.java
@@ -20,6 +20,7 @@ package org.apache.accumulo.core.security.crypto;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertThrows;
 import static org.junit.Assert.assertTrue;
 
 import java.io.ByteArrayInputStream;
@@ -46,9 +47,7 @@ import org.apache.accumulo.core.conf.AccumuloConfiguration;
 import org.apache.accumulo.core.conf.ConfigurationCopy;
 import org.apache.accumulo.core.conf.Property;
 import org.apache.hadoop.conf.Configuration;
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import com.google.common.primitives.Bytes;
 
@@ -62,9 +61,6 @@ public class CryptoTest {
   public static final String CRYPTO_ON_KEK_OFF_CONF =
       "crypto-on-no-key-encryption-accumulo-site.xml";
 
-  @Rule
-  public ExpectedException exception = ExpectedException.none();
-
   @Test
   public void testNoCryptoStream() throws IOException {
     AccumuloConfiguration conf = setAndGetAccumuloConfig(CRYPTO_OFF_CONF);
@@ -143,8 +139,7 @@ public class CryptoTest {
 
     assertTrue(cryptoModule instanceof DefaultCryptoModule);
 
-    exception.expect(RuntimeException.class);
-    cryptoModule.getEncryptingOutputStream(params);
+    assertThrows(RuntimeException.class, () -> cryptoModule.getEncryptingOutputStream(params));
   }
 
   @Test
@@ -157,8 +152,7 @@ public class CryptoTest {
 
     assertTrue(cryptoModule instanceof DefaultCryptoModule);
 
-    exception.expect(RuntimeException.class);
-    cryptoModule.getDecryptingInputStream(params);
+    assertThrows(RuntimeException.class, () -> cryptoModule.getDecryptingInputStream(params));
   }
 
   private String getStringifiedBytes(String s) throws IOException {
@@ -273,10 +267,7 @@ public class CryptoTest {
 
     assertNotNull(params.getPlaintextInputStream());
     DataInputStream dataIn = new DataInputStream(params.getPlaintextInputStream());
-    // We expect the following operation to fail and throw an exception
-    exception.expect(IOException.class);
-    @SuppressWarnings("unused")
-    String markerString = dataIn.readUTF();
+    assertThrows(IOException.class, () -> dataIn.readUTF());
   }
 
   @Test
diff --git a/core/src/test/java/org/apache/accumulo/core/util/PreAllocatedArrayTest.java b/core/src/test/java/org/apache/accumulo/core/util/PreAllocatedArrayTest.java
index 14d28a1..2c096e4 100644
--- a/core/src/test/java/org/apache/accumulo/core/util/PreAllocatedArrayTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/util/PreAllocatedArrayTest.java
@@ -19,18 +19,14 @@ package org.apache.accumulo.core.util;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertThrows;
 
 import java.util.Iterator;
 
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 public class PreAllocatedArrayTest {
 
-  @Rule
-  public ExpectedException exception = ExpectedException.none();
-
   /**
    * Test method for {@link org.apache.accumulo.core.util.PreAllocatedArray#PreAllocatedArray(int)}.
    */
@@ -48,8 +44,7 @@ public class PreAllocatedArrayTest {
 
   @Test
   public void testPreAllocatedArray_Fail() {
-    exception.expect(IllegalArgumentException.class);
-    new PreAllocatedArray<String>(-5);
+    assertThrows(IllegalArgumentException.class, () -> new PreAllocatedArray<String>(-5));
   }
 
   /**
@@ -87,31 +82,27 @@ public class PreAllocatedArrayTest {
   public void testSetIndexHigh() {
     PreAllocatedArray<String> strings = new PreAllocatedArray<>(3);
     strings.set(2, "in bounds");
-    exception.expect(IndexOutOfBoundsException.class);
-    strings.set(3, "out of bounds");
+    assertThrows(IndexOutOfBoundsException.class, () -> strings.set(3, "out of bounds"));
   }
 
   @Test
   public void testSetIndexNegative() {
     PreAllocatedArray<String> strings = new PreAllocatedArray<>(3);
     strings.set(0, "in bounds");
-    exception.expect(IndexOutOfBoundsException.class);
-    strings.set(-3, "out of bounds");
+    assertThrows(IndexOutOfBoundsException.class, () -> strings.set(-3, "out of bounds"));
   }
 
   @Test
   public void testGetIndexHigh() {
     PreAllocatedArray<String> strings = new PreAllocatedArray<>(3);
     strings.get(2);
-    exception.expect(IndexOutOfBoundsException.class);
-    strings.get(3);
+    assertThrows(IndexOutOfBoundsException.class, () -> strings.get(3));
   }
 
   @Test
   public void testGetIndexNegative() {
     PreAllocatedArray<String> strings = new PreAllocatedArray<>(3);
     strings.get(0);
-    exception.expect(IndexOutOfBoundsException.class);
-    strings.get(-3);
+    assertThrows(IndexOutOfBoundsException.class, () -> strings.get(-3));
   }
 }
diff --git a/core/src/test/java/org/apache/accumulo/core/util/UnsynchronizedBufferTest.java b/core/src/test/java/org/apache/accumulo/core/util/UnsynchronizedBufferTest.java
index bc68ba2..b842f3c 100644
--- a/core/src/test/java/org/apache/accumulo/core/util/UnsynchronizedBufferTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/util/UnsynchronizedBufferTest.java
@@ -18,6 +18,7 @@ package org.apache.accumulo.core.util;
 
 import static java.nio.charset.StandardCharsets.UTF_8;
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThrows;
 import static org.junit.Assert.assertTrue;
 
 import java.io.ByteArrayOutputStream;
@@ -26,15 +27,10 @@ import java.nio.ByteBuffer;
 import java.util.Arrays;
 
 import org.apache.hadoop.io.WritableUtils;
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 public class UnsynchronizedBufferTest {
 
-  @Rule
-  public ExpectedException thrown = ExpectedException.none();
-
   @Test
   public void testByteBufferConstructor() {
     byte[] test = "0123456789".getBytes(UTF_8);
@@ -54,9 +50,11 @@ public class UnsynchronizedBufferTest {
     assertEquals("34567", new String(buf, UTF_8));
 
     buf = new byte[6];
-    // the byte buffer has the extra byte, but should not be able to read it...
-    thrown.expect(ArrayIndexOutOfBoundsException.class);
-    ub.readBytes(buf);
+
+    final UnsynchronizedBuffer.Reader finalUb = ub;
+    final byte[] finalBuf = buf;
+    assertThrows("the byte buffer has the extra byte, but should not be able to read it",
+        ArrayIndexOutOfBoundsException.class, () -> finalUb.readBytes(finalBuf));
   }
 
   @Test
diff --git a/fate/src/test/java/org/apache/accumulo/fate/util/RetryTest.java b/fate/src/test/java/org/apache/accumulo/fate/util/RetryTest.java
index 17518fd..c03da4f 100644
--- a/fate/src/test/java/org/apache/accumulo/fate/util/RetryTest.java
+++ b/fate/src/test/java/org/apache/accumulo/fate/util/RetryTest.java
@@ -23,8 +23,8 @@ import static java.util.concurrent.TimeUnit.MINUTES;
 import static java.util.concurrent.TimeUnit.NANOSECONDS;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertThrows;
 import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
 
 import java.util.concurrent.TimeUnit;
 
@@ -36,9 +36,7 @@ import org.apache.accumulo.fate.util.Retry.NeedsTimeIncrement;
 import org.apache.accumulo.fate.util.Retry.RetryFactory;
 import org.easymock.EasyMock;
 import org.junit.Before;
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 import org.slf4j.Logger;
 
 public class RetryTest {
@@ -51,9 +49,6 @@ public class RetryTest {
   private Retry unlimitedRetry;
   private static final TimeUnit MS = MILLISECONDS;
 
-  @Rule
-  public ExpectedException exception = ExpectedException.none();
-
   @Before
   public void setup() {
     retry = Retry.builder().maxRetries(MAX_RETRIES).retryAfter(INITIAL_WAIT, MS)
@@ -98,11 +93,8 @@ public class RetryTest {
       retry.useRetry();
     }
     assertFalse(retry.canRetry());
-
-    // Calling useRetry when canRetry returns false throws an exception
-    exception.expect(IllegalStateException.class);
-    retry.useRetry();
-    fail("previous command should have thrown IllegalStateException");
+    assertThrows("Calling useRetry when canRetry returns false throws an exception",
+        IllegalStateException.class, () -> retry.useRetry());
   }
 
   @Test
@@ -207,9 +199,8 @@ public class RetryTest {
     NeedsRetries builder = Retry.builder();
     builder.maxRetries(10);
     builder.maxRetries(0);
-    exception.expect(IllegalArgumentException.class);
-    builder.maxRetries(-1);
-    fail("Should not allow negative retries");
+    assertThrows("Should not allow negative retries", IllegalArgumentException.class,
+        () -> builder.maxRetries(-1));
   }
 
   @Test
@@ -222,9 +213,8 @@ public class RetryTest {
     builder.retryAfter(0, MILLISECONDS);
     builder.retryAfter(0, DAYS);
 
-    exception.expect(IllegalArgumentException.class);
-    builder.retryAfter(-1, NANOSECONDS);
-    fail("Should not allow negative wait times");
+    assertThrows("Should not allow negative wait times", IllegalArgumentException.class,
+        () -> builder.retryAfter(-1, NANOSECONDS));
   }
 
   @Test
@@ -237,9 +227,8 @@ public class RetryTest {
     builder.incrementBy(0, HOURS);
     builder.incrementBy(0, NANOSECONDS);
 
-    exception.expect(IllegalArgumentException.class);
-    builder.incrementBy(-1, NANOSECONDS);
-    fail("Should not allow negative increments");
+    assertThrows("Should not allow negative increments", IllegalArgumentException.class,
+        () -> builder.incrementBy(-1, NANOSECONDS));
   }
 
   @Test
@@ -249,9 +238,8 @@ public class RetryTest {
     builder.maxWait(15, MILLISECONDS);
     builder.maxWait(16, MILLISECONDS);
 
-    exception.expect(IllegalArgumentException.class);
-    builder.maxWait(14, MILLISECONDS);
-    fail("Max wait time should be greater than or equal to initial wait time");
+    assertThrows("Max wait time should be greater than or equal to initial wait time",
+        IllegalArgumentException.class, () -> builder.maxWait(14, MILLISECONDS));
   }
 
   @Test
@@ -265,9 +253,8 @@ public class RetryTest {
     builder.logInterval(0, HOURS);
     builder.logInterval(0, NANOSECONDS);
 
-    exception.expect(IllegalArgumentException.class);
-    builder.logInterval(-1, NANOSECONDS);
-    fail("Log interval must not be negative");
+    assertThrows("Log interval must not be negative", IllegalArgumentException.class,
+        () -> builder.logInterval(-1, NANOSECONDS));
   }
 
   @Test
diff --git a/pom.xml b/pom.xml
index 6606c0f..55beb66 100644
--- a/pom.xml
+++ b/pom.xml
@@ -238,7 +238,7 @@
       <dependency>
         <groupId>junit</groupId>
         <artifactId>junit</artifactId>
-        <version>4.12</version>
+        <version>4.13.1</version>
       </dependency>
       <dependency>
         <groupId>log4j</groupId>
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 4171b3c..43888af 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
@@ -24,6 +24,7 @@ import static org.easymock.EasyMock.expectLastCall;
 import static org.easymock.EasyMock.replay;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertThrows;
 
 import java.util.Arrays;
 import java.util.Iterator;
@@ -45,26 +46,21 @@ import org.apache.accumulo.server.util.TabletIterator.TabletDeletedException;
 import org.apache.hadoop.io.Text;
 import org.easymock.Capture;
 import org.easymock.IAnswer;
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import com.google.common.collect.Iterators;
 
 public class TabletIteratorTest {
 
-  @Rule
-  public ExpectedException thrown = ExpectedException.none();
-
   @Test
   public void testSplits() {
-    TreeMap<Key,Value> data1 = new TreeMap<Key,Value>();
+    TreeMap<Key,Value> data1 = new TreeMap<>();
 
     createTabletData(data1, "4", "j", null);
     createTabletData(data1, "4", "m", "j");
     createTabletData(data1, "4", null, "x");
 
-    TreeMap<Key,Value> data2 = new TreeMap<Key,Value>(data1);
+    TreeMap<Key,Value> data2 = new TreeMap<>(data1);
 
     createTabletData(data2, "4", "s", "m");
     createTabletData(data2, "4", "x", "s");
@@ -74,14 +70,14 @@ public class TabletIteratorTest {
 
   @Test
   public void testTableTransition1() {
-    TreeMap<Key,Value> data1 = new TreeMap<Key,Value>();
+    TreeMap<Key,Value> data1 = new TreeMap<>();
 
     createTabletData(data1, "3", "c", null);
     createTabletData(data1, "3", "n", "c");
     createTabletData(data1, "4", "f", null);
     createTabletData(data1, "4", null, "f");
 
-    TreeMap<Key,Value> data2 = new TreeMap<Key,Value>(data1);
+    TreeMap<Key,Value> data2 = new TreeMap<>(data1);
 
     createTabletData(data2, "3", null, "n");
 
@@ -90,14 +86,14 @@ public class TabletIteratorTest {
 
   @Test
   public void testTableTransition2() {
-    TreeMap<Key,Value> data1 = new TreeMap<Key,Value>();
+    TreeMap<Key,Value> data1 = new TreeMap<>();
 
     createTabletData(data1, "3", "c", null);
     createTabletData(data1, "3", "n", "c");
     createTabletData(data1, "3", null, "n");
     createTabletData(data1, "4", null, "f");
 
-    TreeMap<Key,Value> data2 = new TreeMap<Key,Value>(data1);
+    TreeMap<Key,Value> data2 = new TreeMap<>(data1);
 
     createTabletData(data2, "4", "f", null);
 
@@ -106,12 +102,12 @@ public class TabletIteratorTest {
 
   @Test
   public void testMissingFirstTablet() {
-    TreeMap<Key,Value> data1 = new TreeMap<Key,Value>();
+    TreeMap<Key,Value> data1 = new TreeMap<>();
 
     createTabletData(data1, "3", "n", "c");
     createTabletData(data1, "3", null, "n");
 
-    TreeMap<Key,Value> data2 = new TreeMap<Key,Value>(data1);
+    TreeMap<Key,Value> data2 = new TreeMap<>(data1);
 
     createTabletData(data2, "3", "c", null);
 
@@ -120,34 +116,34 @@ public class TabletIteratorTest {
 
   @Test
   public void testMissingLastTablet() {
-    TreeMap<Key,Value> data1 = new TreeMap<Key,Value>();
+    TreeMap<Key,Value> data1 = new TreeMap<>();
 
     createTabletData(data1, "3", "c", null);
     createTabletData(data1, "3", "n", "c");
 
-    TreeMap<Key,Value> data2 = new TreeMap<Key,Value>(data1);
+    TreeMap<Key,Value> data2 = new TreeMap<>(data1);
 
     createTabletData(data2, "3", null, "n");
 
-    thrown.expect(IllegalStateException.class);
-    runTest(Arrays.asList(data1, data2), Arrays.asList("3;c", "3;n", "3<"));
+    assertThrows(IllegalStateException.class,
+        () -> runTest(Arrays.asList(data1, data2), Arrays.asList("3;c", "3;n", "3<")));
   }
 
   @Test
   public void testDeletedTable() {
-    TreeMap<Key,Value> data1 = new TreeMap<Key,Value>();
+    TreeMap<Key,Value> data1 = new TreeMap<>();
 
     createTabletData(data1, "3", "c", null);
     createTabletData(data1, "3", "n", "c");
     createTabletData(data1, "4", null, "f");
     createTabletData(data1, "4", "f", null);
 
-    TreeMap<Key,Value> data2 = new TreeMap<Key,Value>();
+    TreeMap<Key,Value> data2 = new TreeMap<>();
     createTabletData(data1, "4", null, "f");
     createTabletData(data1, "4", "f", null);
 
-    thrown.expect(TabletDeletedException.class);
-    runTest(Arrays.asList(data1, data2), Arrays.asList("3;c", "3;n"));
+    assertThrows(TabletDeletedException.class,
+        () -> runTest(Arrays.asList(data1, data2), Arrays.asList("3;c", "3;n")));
   }
 
   private static class ScannerState {
@@ -219,11 +215,12 @@ public class TabletIteratorTest {
   public void runTest(List<TreeMap<Key,Value>> dataSets, List<String> expectedEndRows) {
     final Iterator<TreeMap<Key,Value>> dataSetIter = dataSets.iterator();
 
-    final TreeMap<Key,Value> data = new TreeMap<Key,Value>(dataSetIter.next());
+    final TreeMap<Key,Value> data = new TreeMap<>(dataSetIter.next());
 
     Scanner scanner = createMockScanner(data);
 
     TabletIterator tabIter = new TabletIterator(scanner, TabletsSection.getRange(), true, false) {
+      @Override
       protected void resetScanner() {
         data.clear();
         data.putAll(dataSetIter.next());
diff --git a/server/tserver/src/test/java/org/apache/accumulo/tserver/InMemoryMapTest.java b/server/tserver/src/test/java/org/apache/accumulo/tserver/InMemoryMapTest.java
index 16e68b1..212e516 100644
--- a/server/tserver/src/test/java/org/apache/accumulo/tserver/InMemoryMapTest.java
+++ b/server/tserver/src/test/java/org/apache/accumulo/tserver/InMemoryMapTest.java
@@ -18,6 +18,7 @@ package org.apache.accumulo.tserver;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertThrows;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
@@ -67,7 +68,6 @@ import org.junit.BeforeClass;
 import org.junit.Ignore;
 import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 import org.junit.rules.TemporaryFolder;
 
 import com.google.common.collect.ImmutableMap;
@@ -97,9 +97,6 @@ public class InMemoryMapTest {
     }
   }
 
-  @Rule
-  public ExpectedException thrown = ExpectedException.none();
-
   @BeforeClass
   public static void setUp() throws Exception {
     // suppress log messages having to do with not having an instance
@@ -494,8 +491,8 @@ public class InMemoryMapTest {
 
   static long sum(long[] counts) {
     long result = 0;
-    for (int i = 0; i < counts.length; i++)
-      result += counts[i];
+    for (long count : counts)
+      result += count;
     return result;
   }
 
@@ -535,8 +532,8 @@ public class InMemoryMapTest {
           String.format("%.1f mutations per second with %d threads", mutationsPerSecond, threads));
     }
     // verify that more threads doesn't go a lot faster, or a lot slower than one thread
-    for (int i = 0; i < timings.size(); i++) {
-      double ratioFirst = timings.get(0) / timings.get(i);
+    for (Double timing : timings) {
+      double ratioFirst = timings.get(0) / timing;
       assertTrue(ratioFirst < 3);
       assertTrue(ratioFirst > 0.3);
     }
@@ -835,8 +832,9 @@ public class InMemoryMapTest {
     assertEquals(expectedAll, readAll(iter));
 
     iter = imm.skvIterator(sampleConfig1);
-    thrown.expect(SampleNotPresentException.class);
-    iter.seek(new Range(), LocalityGroupUtil.EMPTY_CF_SET, false);
+    final MemoryIterator finalIter = iter;
+    assertThrows(SampleNotPresentException.class,
+        () -> finalIter.seek(new Range(), LocalityGroupUtil.EMPTY_CF_SET, false));
   }
 
   private TreeMap<Key,Value> readAll(SortedKeyValueIterator<Key,Value> iter) throws IOException {
diff --git a/server/tserver/src/test/java/org/apache/accumulo/tserver/compaction/CompactionPlanTest.java b/server/tserver/src/test/java/org/apache/accumulo/tserver/compaction/CompactionPlanTest.java
index 1b7d00d..d2c96b7 100644
--- a/server/tserver/src/test/java/org/apache/accumulo/tserver/compaction/CompactionPlanTest.java
+++ b/server/tserver/src/test/java/org/apache/accumulo/tserver/compaction/CompactionPlanTest.java
@@ -17,20 +17,17 @@
 
 package org.apache.accumulo.tserver.compaction;
 
+import static org.junit.Assert.assertThrows;
+
 import java.util.Set;
 
 import org.apache.accumulo.server.fs.FileRef;
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import com.google.common.collect.ImmutableSet;
 
 public class CompactionPlanTest {
 
-  @Rule
-  public ExpectedException exception = ExpectedException.none();
-
   @Test
   public void testOverlappingInputAndDelete() {
     CompactionPlan cp1 = new CompactionPlan();
@@ -45,8 +42,7 @@ public class CompactionPlanTest {
 
     Set<FileRef> allFiles = ImmutableSet.of(fr1, fr2);
 
-    exception.expect(IllegalStateException.class);
-    cp1.validate(allFiles);
+    assertThrows(IllegalStateException.class, () -> cp1.validate(allFiles));
   }
 
   @Test
@@ -63,8 +59,7 @@ public class CompactionPlanTest {
 
     Set<FileRef> allFiles = ImmutableSet.of(fr1, fr2);
 
-    exception.expect(IllegalStateException.class);
-    cp1.validate(allFiles);
+    assertThrows(IllegalStateException.class, () -> cp1.validate(allFiles));
   }
 
   @Test
@@ -81,8 +76,7 @@ public class CompactionPlanTest {
 
     Set<FileRef> allFiles = ImmutableSet.of(fr1, fr2);
 
-    exception.expect(IllegalStateException.class);
-    cp1.validate(allFiles);
+    assertThrows(IllegalStateException.class, () -> cp1.validate(allFiles));
   }
 
 }
diff --git a/server/tserver/src/test/java/org/apache/accumulo/tserver/log/SortedLogRecoveryTest.java b/server/tserver/src/test/java/org/apache/accumulo/tserver/log/SortedLogRecoveryTest.java
index a247c99..5bea3a8 100644
--- a/server/tserver/src/test/java/org/apache/accumulo/tserver/log/SortedLogRecoveryTest.java
+++ b/server/tserver/src/test/java/org/apache/accumulo/tserver/log/SortedLogRecoveryTest.java
@@ -22,6 +22,7 @@ import static org.apache.accumulo.tserver.logger.LogEvents.DEFINE_TABLET;
 import static org.apache.accumulo.tserver.logger.LogEvents.MUTATION;
 import static org.apache.accumulo.tserver.logger.LogEvents.OPEN;
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThrows;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
@@ -53,9 +54,7 @@ import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.io.MapFile;
 import org.apache.hadoop.io.MapFile.Writer;
 import org.apache.hadoop.io.Text;
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 import org.junit.rules.TemporaryFolder;
 
 public class SortedLogRecoveryTest {
@@ -65,9 +64,6 @@ public class SortedLogRecoveryTest {
   static final Text cq = new Text("cq");
   static final Value value = new Value("value".getBytes());
 
-  @Rule
-  public ExpectedException thrown = ExpectedException.none();
-
   static class KeyValue implements Comparable<KeyValue> {
     public final LogFileKey key;
     public final LogFileValue value;
@@ -864,9 +860,9 @@ public class SortedLogRecoveryTest {
     Map<String,KeyValue[]> logs = new TreeMap<>();
     logs.put("entries1", entries1);
 
-    thrown.expect(IllegalStateException.class);
-    thrown.expectMessage("consecutive " + LogEvents.COMPACTION_FINISH.name());
-    recover(logs, extent);
+    IllegalStateException e =
+        assertThrows(IllegalStateException.class, () -> recover(logs, extent));
+    assertTrue(e.getMessage().contains("consecutive " + LogEvents.COMPACTION_FINISH.name()));
   }
 
   @Test
@@ -986,8 +982,8 @@ public class SortedLogRecoveryTest {
     Map<String,KeyValue[]> logs = new TreeMap<>();
     logs.put("entries1", entries1);
 
-    thrown.expect(IllegalStateException.class);
-    thrown.expectMessage("not " + LogEvents.OPEN);
-    recover(logs, extent);
+    IllegalStateException e =
+        assertThrows(IllegalStateException.class, () -> recover(logs, extent));
+    assertTrue(e.getMessage().contains("not " + LogEvents.OPEN));
   }
 }
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/ClassLoaderIT.java b/test/src/main/java/org/apache/accumulo/test/functional/ClassLoaderIT.java
index 390065c..ddeab28 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/ClassLoaderIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/ClassLoaderIT.java
@@ -46,7 +46,6 @@ import org.apache.accumulo.test.categories.MiniClusterOnlyTests;
 import org.apache.hadoop.fs.FSDataOutputStream;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
-import org.hamcrest.CoreMatchers;
 import org.junit.Assume;
 import org.junit.Before;
 import org.junit.Test;
@@ -66,7 +65,7 @@ public class ClassLoaderIT extends AccumuloClusterHarness {
 
   @Before
   public void checkCluster() {
-    Assume.assumeThat(getClusterType(), CoreMatchers.is(ClusterType.MINI));
+    Assume.assumeTrue(getClusterType() == ClusterType.MINI);
     MiniAccumuloClusterImpl mac = (MiniAccumuloClusterImpl) getCluster();
     rootPath = mac.getConfig().getDir().getAbsolutePath();
   }
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/KerberosProxyIT.java b/test/src/main/java/org/apache/accumulo/test/functional/KerberosProxyIT.java
index fdc6866..4ea76d1 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/KerberosProxyIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/KerberosProxyIT.java
@@ -19,6 +19,7 @@ package org.apache.accumulo.test.functional;
 import static java.nio.charset.StandardCharsets.UTF_8;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertThrows;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
@@ -72,16 +73,12 @@ import org.apache.thrift.protocol.TCompactProtocol;
 import org.apache.thrift.transport.TSaslClientTransport;
 import org.apache.thrift.transport.TSocket;
 import org.apache.thrift.transport.TTransportException;
-import org.hamcrest.Description;
-import org.hamcrest.TypeSafeMatcher;
 import org.junit.After;
 import org.junit.AfterClass;
 import org.junit.Before;
 import org.junit.BeforeClass;
-import org.junit.Rule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
-import org.junit.rules.ExpectedException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -99,9 +96,6 @@ public class KerberosProxyIT extends AccumuloITBase {
   private static final String PROXIED_USER1 = "proxied_user1", PROXIED_USER2 = "proxied_user2",
       PROXIED_USER3 = "proxied_user3";
 
-  @Rule
-  public ExpectedException thrown = ExpectedException.none();
-
   private static TestingKdc kdc;
   private static String krbEnabledForITs = null;
   private static File proxyKeytab;
@@ -414,19 +408,6 @@ public class KerberosProxyIT extends AccumuloITBase {
 
     log.info("Logged in as " + ugi);
 
-    // Expect an AccumuloSecurityException
-    thrown.expect(AccumuloSecurityException.class);
-    // Error msg would look like:
-    //
-    // org.apache.accumulo.core.client.AccumuloSecurityException: Error BAD_CREDENTIALS for user
-    // Principal in credentials object should match kerberos
-    // principal.
-    // Expected 'proxy/hw10447.local@EXAMPLE.COM' but was
-    // 'testDisallowedClientForImpersonation@EXAMPLE.COM' - Username or Password is Invalid)
-    thrown.expect(new ThriftExceptionMatchesPattern(".*Error BAD_CREDENTIALS.*"));
-    thrown.expect(new ThriftExceptionMatchesPattern(
-        ".*Expected '" + proxyPrincipal + "' but was '" + kdc.qualifyUser(user) + "'.*"));
-
     TSocket socket = new TSocket(hostname, proxyPort);
     log.info(
         "Connecting to proxy with server primary '" + proxyPrimary + "' running on " + hostname);
@@ -446,7 +427,18 @@ public class KerberosProxyIT extends AccumuloITBase {
 
     // Will fail because the proxy can't impersonate this user (per the site configuration)
     try {
-      client.login(kdc.qualifyUser(user), Collections.<String,String>emptyMap());
+      // Error msg would look like:
+      //
+      // org.apache.accumulo.core.client.AccumuloSecurityException: Error BAD_CREDENTIALS for user
+      // Principal in credentials object should match kerberos
+      // principal.
+      // Expected 'proxy/hw10447.local@EXAMPLE.COM' but was
+      // 'testDisallowedClientForImpersonation@EXAMPLE.COM' - Username or Password is Invalid)
+      AccumuloSecurityException e = assertThrows(AccumuloSecurityException.class,
+          () -> client.login(kdc.qualifyUser(user), Collections.<String,String>emptyMap()));
+      assertTrue(thriftExceptionMatchesPattern(e, ".*Error BAD_CREDENTIALS.*"));
+      assertTrue(thriftExceptionMatchesPattern(e,
+          ".*Expected '" + proxyPrincipal + "' but was '" + kdc.qualifyUser(user) + "'.*"));
     } finally {
       if (null != ugiTransport) {
         ugiTransport.close();
@@ -457,10 +449,6 @@ public class KerberosProxyIT extends AccumuloITBase {
   @Test
   public void testMismatchPrincipals() throws Exception {
     ClusterUser rootUser = kdc.getRootUser();
-    // Should get an AccumuloSecurityException and the given message
-    thrown.expect(AccumuloSecurityException.class);
-    thrown
-        .expect(new ThriftExceptionMatchesPattern(ProxyServer.RPC_ACCUMULO_PRINCIPAL_MISMATCH_MSG));
 
     // Make a new user
     String user = testName.getMethodName();
@@ -495,7 +483,9 @@ public class KerberosProxyIT extends AccumuloITBase {
     // Accumulo should let this through -- we need to rely on the proxy to dump me before talking to
     // accumulo
     try {
-      client.login(rootUser.getPrincipal(), Collections.<String,String>emptyMap());
+      AccumuloSecurityException e = assertThrows(AccumuloSecurityException.class,
+          () -> client.login(rootUser.getPrincipal(), Collections.<String,String>emptyMap()));
+      assertTrue(thriftExceptionMatchesPattern(e, ProxyServer.RPC_ACCUMULO_PRINCIPAL_MISMATCH_MSG));
     } finally {
       if (null != ugiTransport) {
         ugiTransport.close();
@@ -607,28 +597,7 @@ public class KerberosProxyIT extends AccumuloITBase {
     });
   }
 
-  private static class ThriftExceptionMatchesPattern
-      extends TypeSafeMatcher<AccumuloSecurityException> {
-    private String pattern;
-
-    public ThriftExceptionMatchesPattern(String pattern) {
-      this.pattern = pattern;
-    }
-
-    @Override
-    protected boolean matchesSafely(AccumuloSecurityException item) {
-      return item.isSetMsg() && item.msg.matches(pattern);
-    }
-
-    @Override
-    public void describeTo(Description description) {
-      description.appendText("matches pattern ").appendValue(pattern);
-    }
-
-    @Override
-    protected void describeMismatchSafely(AccumuloSecurityException item,
-        Description mismatchDescription) {
-      mismatchDescription.appendText("does not match");
-    }
+  private boolean thriftExceptionMatchesPattern(AccumuloSecurityException e, String pattern) {
+    return e.isSetMsg() && e.msg.matches(pattern);
   }
 }
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/MergeIT.java b/test/src/main/java/org/apache/accumulo/test/functional/MergeIT.java
index f0d8270..abc8629 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/MergeIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/MergeIT.java
@@ -18,6 +18,7 @@ package org.apache.accumulo.test.functional;
 
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThrows;
 
 import java.util.Arrays;
 import java.util.Collection;
@@ -45,9 +46,7 @@ import org.apache.accumulo.harness.AccumuloClusterHarness;
 import org.apache.accumulo.server.util.TabletIterator;
 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;
 
 public class MergeIT extends AccumuloClusterHarness {
 
@@ -217,9 +216,6 @@ public class MergeIT extends AccumuloClusterHarness {
 
   }
 
-  @Rule
-  public ExpectedException exception = ExpectedException.none();
-
   private static class TestTabletIterator extends TabletIterator {
 
     private final Connector conn;
@@ -282,9 +278,10 @@ public class MergeIT extends AccumuloClusterHarness {
 
     TestTabletIterator tabIter = new TestTabletIterator(getConnector(), metadataTableName);
 
-    exception.expect(TabletDeletedException.class);
-    while (tabIter.hasNext()) {
-      tabIter.next();
-    }
+    assertThrows(TabletDeletedException.class, () -> {
+      while (tabIter.hasNext()) {
+        tabIter.next();
+      }
+    });
   }
 }
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/ScannerContextIT.java b/test/src/main/java/org/apache/accumulo/test/functional/ScannerContextIT.java
index 12eadc8..b691d44 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/ScannerContextIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/ScannerContextIT.java
@@ -44,7 +44,6 @@ import org.apache.accumulo.harness.AccumuloClusterHarness;
 import org.apache.accumulo.minicluster.impl.MiniAccumuloClusterImpl;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
-import org.hamcrest.CoreMatchers;
 import org.junit.Assume;
 import org.junit.Before;
 import org.junit.Test;
@@ -67,7 +66,7 @@ public class ScannerContextIT extends AccumuloClusterHarness {
 
   @Before
   public void checkCluster() throws Exception {
-    Assume.assumeThat(getClusterType(), CoreMatchers.is(ClusterType.MINI));
+    Assume.assumeTrue(getClusterType() == ClusterType.MINI);
     MiniAccumuloClusterImpl.class.cast(getCluster());
     fs = FileSystem.get(CachedConfiguration.getInstance());
   }
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/TableIT.java b/test/src/main/java/org/apache/accumulo/test/functional/TableIT.java
index db49c8a..d1900ad 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/TableIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/TableIT.java
@@ -40,7 +40,6 @@ import org.apache.accumulo.test.VerifyIngest;
 import org.apache.accumulo.test.categories.MiniClusterOnlyTests;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
-import org.hamcrest.CoreMatchers;
 import org.junit.Assume;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
@@ -57,7 +56,7 @@ public class TableIT extends AccumuloClusterHarness {
 
   @Test
   public void test() throws Exception {
-    Assume.assumeThat(getClusterType(), CoreMatchers.is(ClusterType.MINI));
+    Assume.assumeTrue(getClusterType() == ClusterType.MINI);
 
     AccumuloCluster cluster = getCluster();
     MiniAccumuloClusterImpl mac = (MiniAccumuloClusterImpl) cluster;