Some more cleanup.

--
MOS_MIGRATED_REVID=87942730
diff --git a/src/test/java/com/google/devtools/build/lib/actions/ActionExecutionStatusReporterTest.java b/src/test/java/com/google/devtools/build/lib/actions/ActionExecutionStatusReporterTest.java
index 8af46e4..cbcac8d 100644
--- a/src/test/java/com/google/devtools/build/lib/actions/ActionExecutionStatusReporterTest.java
+++ b/src/test/java/com/google/devtools/build/lib/actions/ActionExecutionStatusReporterTest.java
@@ -102,7 +102,7 @@
   private void verifyOutput(String... lines) throws Exception {
     collector.clear();
     statusReporter.showCurrentlyExecutingActions("");
-    assertThat(Splitter.on("\n").omitEmptyStrings().trimResults().split(
+    assertThat(Splitter.on('\n').omitEmptyStrings().trimResults().split(
         Iterables.getOnlyElement(collector).getMessage().replaceAll(" +", " ")))
         .containsExactlyElementsIn(Arrays.asList(lines)).inOrder();
   }
@@ -110,7 +110,7 @@
   private void verifyWarningOutput(String... lines) throws Exception {
     collector.clear();
     statusReporter.warnAboutCurrentlyExecutingActions();
-    assertThat(Splitter.on("\n").omitEmptyStrings().trimResults().split(
+    assertThat(Splitter.on('\n').omitEmptyStrings().trimResults().split(
         Iterables.getOnlyElement(collector).getMessage().replaceAll(" +", " ")))
         .containsExactlyElementsIn(Arrays.asList(lines)).inOrder();
   }
diff --git a/src/test/java/com/google/devtools/build/lib/actions/ArtifactTest.java b/src/test/java/com/google/devtools/build/lib/actions/ArtifactTest.java
index d493e42..0ba34cb 100644
--- a/src/test/java/com/google/devtools/build/lib/actions/ArtifactTest.java
+++ b/src/test/java/com/google/devtools/build/lib/actions/ArtifactTest.java
@@ -281,8 +281,8 @@
           new PathFragment("c"));
       fail();
     } catch (IllegalArgumentException e) {
-      assertEquals("c: illegal execPath doesn't end with b/c at /a/b/c with root /a[derived]",
-          e.getMessage());
+      assertThat(e).hasMessage(
+          "c: illegal execPath doesn't end with b/c at /a/b/c with root /a[derived]");
     }
   }
 
diff --git a/src/test/java/com/google/devtools/build/lib/actions/ConcurrentMultimapWithHeadElementTest.java b/src/test/java/com/google/devtools/build/lib/actions/ConcurrentMultimapWithHeadElementTest.java
index 28f185c..4a95baa 100644
--- a/src/test/java/com/google/devtools/build/lib/actions/ConcurrentMultimapWithHeadElementTest.java
+++ b/src/test/java/com/google/devtools/build/lib/actions/ConcurrentMultimapWithHeadElementTest.java
@@ -15,6 +15,7 @@
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
 import com.google.common.testing.GcFinalization;
@@ -39,7 +40,7 @@
   @Test
   public void testSmoke() throws Exception {
     ConcurrentMultimapWithHeadElement<String, String> multimap =
-        new ConcurrentMultimapWithHeadElement<String, String>();
+        new ConcurrentMultimapWithHeadElement<>();
     assertEquals("val", multimap.putAndGet("key", "val"));
     assertEquals("val", multimap.get("key"));
     assertEquals("val", multimap.putAndGet("key", "val2"));
@@ -53,29 +54,29 @@
   @Test
   public void testDuplicate() throws Exception {
     ConcurrentMultimapWithHeadElement<String, String> multimap =
-        new ConcurrentMultimapWithHeadElement<String, String>();
+        new ConcurrentMultimapWithHeadElement<>();
     assertEquals("val", multimap.putAndGet("key", "val"));
     assertEquals("val", multimap.get("key"));
     assertEquals("val", multimap.putAndGet("key", "val"));
     multimap.remove("key", "val");
-    assertEquals(null, multimap.get("key"));
+    assertNull(multimap.get("key"));
   }
 
   @Test
   public void testDuplicateWithEqualsObject() throws Exception {
     ConcurrentMultimapWithHeadElement<String, String> multimap =
         new ConcurrentMultimapWithHeadElement<>();
-    assertEquals(new String("val"), multimap.putAndGet("key", new String("val")));
-    assertEquals(new String("val"), multimap.get("key"));
-    assertEquals(new String("val"), multimap.putAndGet("key", new String("val")));
-    multimap.remove("key", new String("val"));
-    assertEquals(null, multimap.get("key"));
+    assertEquals("val", multimap.putAndGet("key", "val"));
+    assertEquals("val", multimap.get("key"));
+    assertEquals("val", multimap.putAndGet("key", "val"));
+    multimap.remove("key", "val");
+    assertNull(multimap.get("key"));
   }
 
   @Test
   public void testFailedRemoval() throws Exception {
     ConcurrentMultimapWithHeadElement<String, String> multimap =
-        new ConcurrentMultimapWithHeadElement<String, String>();
+        new ConcurrentMultimapWithHeadElement<>();
     assertEquals("val", multimap.putAndGet("key", "val"));
     multimap.remove("key", "val2");
     assertEquals("val", multimap.get("key"));
@@ -84,7 +85,7 @@
   @Test
   public void testNotEmpty() throws Exception {
     ConcurrentMultimapWithHeadElement<String, String> multimap =
-        new ConcurrentMultimapWithHeadElement<String, String>();
+        new ConcurrentMultimapWithHeadElement<>();
     assertEquals("val", multimap.putAndGet("key", "val"));
     multimap.remove("key", "val2");
     assertEquals("val", multimap.get("key"));
@@ -94,9 +95,9 @@
   public void testKeyRemoved() throws Exception {
     String key = new String("key");
     ConcurrentMultimapWithHeadElement<String, String> multimap =
-        new ConcurrentMultimapWithHeadElement<String, String>();
+        new ConcurrentMultimapWithHeadElement<>();
     assertEquals("val", multimap.putAndGet(key, "val"));
-    WeakReference<String> weakKey = new WeakReference<String>(key);
+    WeakReference<String> weakKey = new WeakReference<>(key);
     multimap.remove(key, "val");
     key = null;
     GcFinalization.awaitClear(weakKey);
@@ -105,7 +106,7 @@
   @Test
   public void testKeyRemovedAndAddedConcurrently() throws Exception {
     final ConcurrentMultimapWithHeadElement<String, String> multimap =
-        new ConcurrentMultimapWithHeadElement<String, String>();
+        new ConcurrentMultimapWithHeadElement<>();
     // Because we have two threads racing, run the test many times. Before fixed, there was a 90%
     // chance of failure in 10,000 runs.
     for (int i = 0; i < 10000; i++) {
@@ -129,7 +130,7 @@
 
   private class StressTester extends AbstractQueueVisitor {
     private final ConcurrentMultimapWithHeadElement<Boolean, Integer> multimap =
-        new ConcurrentMultimapWithHeadElement<Boolean, Integer>();
+        new ConcurrentMultimapWithHeadElement<>();
     private final AtomicInteger actionCount = new AtomicInteger(0);
 
     private StressTester() {
diff --git a/src/test/java/com/google/devtools/build/lib/actions/ExecutableSymlinkActionTest.java b/src/test/java/com/google/devtools/build/lib/actions/ExecutableSymlinkActionTest.java
index 50d0f25..788ee82 100644
--- a/src/test/java/com/google/devtools/build/lib/actions/ExecutableSymlinkActionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/actions/ExecutableSymlinkActionTest.java
@@ -14,6 +14,7 @@
 package com.google.devtools.build.lib.actions;
 
 
+import static com.google.common.truth.Truth.assertThat;
 import static com.google.devtools.build.lib.actions.util.ActionsTestUtil.NULL_ACTION_OWNER;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
@@ -81,7 +82,7 @@
       action.execute(createContext());
       fail();
     } catch (ActionExecutionException e) {
-      assertTrue(e.getMessage().contains("'some-dir' is not a file"));
+      assertThat(e.getMessage()).contains("'some-dir' is not a file");
     }
   }
 
diff --git a/src/test/java/com/google/devtools/build/lib/actions/FailActionTest.java b/src/test/java/com/google/devtools/build/lib/actions/FailActionTest.java
index 7838fca..4afc7bd 100644
--- a/src/test/java/com/google/devtools/build/lib/actions/FailActionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/actions/FailActionTest.java
@@ -14,9 +14,9 @@
 package com.google.devtools.build.lib.actions;
 
 
+import static com.google.common.truth.Truth.assertThat;
 import static com.google.devtools.build.lib.actions.util.ActionsTestUtil.NULL_ACTION_OWNER;
 import static com.google.devtools.build.lib.testutil.MoreAsserts.assertSameContents;
-import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertSame;
 import static org.junit.Assert.fail;
 
@@ -60,7 +60,7 @@
       failAction.execute(null);
       fail();
     } catch (ActionExecutionException e) {
-      assertEquals(errorMessage, e.getMessage());
+      assertThat(e).hasMessage(errorMessage);
     }
   }
 
diff --git a/src/test/java/com/google/devtools/build/lib/actions/RootTest.java b/src/test/java/com/google/devtools/build/lib/actions/RootTest.java
index c8fc14b..a88a3ef 100644
--- a/src/test/java/com/google/devtools/build/lib/actions/RootTest.java
+++ b/src/test/java/com/google/devtools/build/lib/actions/RootTest.java
@@ -19,6 +19,7 @@
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
+import com.google.common.testing.EqualsTester;
 import com.google.devtools.build.lib.testutil.Scratch;
 import com.google.devtools.build.lib.vfs.Path;
 import com.google.devtools.build.lib.vfs.PathFragment;
@@ -122,8 +123,7 @@
 
   public void assertEqualsAndHashCode(boolean expected, Object a, Object b) {
     if (expected) {
-      assertTrue(a.equals(b));
-      assertTrue(a.hashCode() == b.hashCode());
+      new EqualsTester().addEqualityGroup(b, a).testEquals();
     } else {
       assertFalse(a.equals(b));
       assertFalse(a.hashCode() == b.hashCode());
diff --git a/src/test/java/com/google/devtools/build/lib/actions/cache/CompactPersistentActionCacheTest.java b/src/test/java/com/google/devtools/build/lib/actions/cache/CompactPersistentActionCacheTest.java
index 5fc1f4f..05b26fb 100644
--- a/src/test/java/com/google/devtools/build/lib/actions/cache/CompactPersistentActionCacheTest.java
+++ b/src/test/java/com/google/devtools/build/lib/actions/cache/CompactPersistentActionCacheTest.java
@@ -77,7 +77,7 @@
     String key = "key";
     putKey(key);
     ActionCache.Entry readentry = cache.get(key);
-    assertTrue(readentry != null);
+    assertNotNull(readentry);
     assertEquals(cache.get(key).toString(), readentry.toString());
     assertFalse(mapFile.exists());
   }
@@ -102,7 +102,7 @@
     CompactPersistentActionCache newcache =
       new CompactPersistentActionCache(dataRoot, clock);
     ActionCache.Entry readentry = newcache.get(key);
-    assertTrue(readentry != null);
+    assertNotNull(readentry);
     assertEquals(cache.get(key).toString(), readentry.toString());
   }
 
diff --git a/src/test/java/com/google/devtools/build/lib/actions/cache/PersistentStringIndexerTest.java b/src/test/java/com/google/devtools/build/lib/actions/cache/PersistentStringIndexerTest.java
index 7fc0cb1..f18607c 100644
--- a/src/test/java/com/google/devtools/build/lib/actions/cache/PersistentStringIndexerTest.java
+++ b/src/test/java/com/google/devtools/build/lib/actions/cache/PersistentStringIndexerTest.java
@@ -91,7 +91,7 @@
   private void assertContent() {
     for (int i = 0; i < psi.size(); i++) {
       if(mappings.get(i) != null) {
-        assertEquals(mappings.get(i), psi.getStringForIndex(i));
+        assertThat(mappings).containsEntry(i, psi.getStringForIndex(i));
       }
     }
   }
@@ -295,7 +295,7 @@
     }
 
     // Corrupt the journal with a negative size value.
-    byte[] journalCopy = Arrays.copyOf(journalContent, journalContent.length);
+    byte[] journalCopy = journalContent.clone();
     // Flip this bit to make the key size negative.
     journalCopy[95] = -2;
     FileSystemUtils.writeContent(journalPath,  journalCopy);
diff --git a/src/test/java/com/google/devtools/build/lib/actions/util/TestAction.java b/src/test/java/com/google/devtools/build/lib/actions/util/TestAction.java
index 42780a6..340d176 100644
--- a/src/test/java/com/google/devtools/build/lib/actions/util/TestAction.java
+++ b/src/test/java/com/google/devtools/build/lib/actions/util/TestAction.java
@@ -152,15 +152,10 @@
 
   /** No-op action that has exactly one output, and can be a middleman action. */
   public static class DummyAction extends TestAction {
-    private static final Runnable NOOP = new Runnable() {
-      @Override
-      public void run() {}
-    };
-
     private final MiddlemanType type;
 
     public DummyAction(Collection<Artifact> inputs, Artifact output, MiddlemanType type) {
-      super(NOOP, inputs, ImmutableList.of(output));
+      super(NO_EFFECT, inputs, ImmutableList.of(output));
       this.type = type;
     }
 
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/actions/SpawnActionTest.java b/src/test/java/com/google/devtools/build/lib/analysis/actions/SpawnActionTest.java
index 4e63393..ba119a7 100644
--- a/src/test/java/com/google/devtools/build/lib/analysis/actions/SpawnActionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/analysis/actions/SpawnActionTest.java
@@ -31,9 +31,9 @@
 import com.google.devtools.build.lib.actions.extra.SpawnInfo;
 import com.google.devtools.build.lib.actions.util.ActionsTestUtil;
 import com.google.devtools.build.lib.analysis.util.ActionTester;
-import com.google.devtools.build.lib.analysis.util.BuildViewTestCase;
 import com.google.devtools.build.lib.analysis.util.ActionTester.ActionCombinationFactory;
 import com.google.devtools.build.lib.analysis.util.AnalysisTestUtil;
+import com.google.devtools.build.lib.analysis.util.BuildViewTestCase;
 import com.google.devtools.build.lib.vfs.PathFragment;
 
 import java.util.Arrays;
@@ -162,9 +162,10 @@
     assertEquals(asList("/bin/java", "-Xverify:none", "-jvmarg", "-cp",
         "pkg/exe.jar", "MyMainClass", "@" + paramFile.getExecPathString()),
         action.getArguments());
-    assertEquals(ImmutableList.of("-X"),
+    assertThat(
         ImmutableList.copyOf(
-            ((ParameterFileWriteAction) getGeneratingAction(paramFile)).getContents()));
+            ((ParameterFileWriteAction) getGeneratingAction(paramFile)).getContents()))
+        .containsExactly("-X");
     assertContainsSublist(actionInputsToPaths(action.getSpawn().getInputFiles()),
         "pkg/exe.jar");
   }
@@ -297,7 +298,7 @@
     assertEquals(environment.size(), spawnInfo.getVariableCount());
 
     for (EnvironmentVariable variable : spawnInfo.getVariableList()) {
-      assertEquals(variable.getValue(), environment.get(variable.getName()));
+      assertThat(environment).containsEntry(variable.getName(), variable.getValue());
     }
   }
 
@@ -313,7 +314,7 @@
     collectingAnalysisEnvironment.registerAction(actions);
     SpawnAction action = (SpawnAction) actions[0];
     List<String> inputFiles = actionInputsToPaths(action.getSpawn().getInputFiles());
-    assertTrue(inputFiles.isEmpty());
+    assertThat(inputFiles).isEmpty();
   }
 
   public void testComputeKey() throws Exception {
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/actions/TemplateExpansionActionTest.java b/src/test/java/com/google/devtools/build/lib/analysis/actions/TemplateExpansionActionTest.java
index 65df114..0dd7fff 100644
--- a/src/test/java/com/google/devtools/build/lib/analysis/actions/TemplateExpansionActionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/analysis/actions/TemplateExpansionActionTest.java
@@ -13,12 +13,12 @@
 // limitations under the License.
 package com.google.devtools.build.lib.analysis.actions;
 
+import static com.google.common.truth.Truth.assertThat;
 import static com.google.devtools.build.lib.actions.util.ActionsTestUtil.NULL_ACTION_OWNER;
 
 import com.google.common.base.Joiner;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Iterables;
 import com.google.common.collect.Lists;
 import com.google.devtools.build.lib.actions.ActionExecutionContext;
 import com.google.devtools.build.lib.actions.Artifact;
@@ -77,7 +77,7 @@
   }
 
   public void testInputsIsEmpty() {
-    assertTrue(Iterables.isEmpty(create().getInputs()));
+    assertThat(create().getInputs()).isEmpty();
   }
 
   public void testDestinationArtifactIsOutput() {
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/util/AnalysisTestUtil.java b/src/test/java/com/google/devtools/build/lib/analysis/util/AnalysisTestUtil.java
index 41793bf..54768e8 100644
--- a/src/test/java/com/google/devtools/build/lib/analysis/util/AnalysisTestUtil.java
+++ b/src/test/java/com/google/devtools/build/lib/analysis/util/AnalysisTestUtil.java
@@ -57,6 +57,7 @@
 
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.LinkedHashSet;
 import java.util.List;
@@ -91,9 +92,7 @@
 
     @Override
     public void registerAction(Action... actions) {
-      for (Action action : actions) {
-        this.actions.add(action);
-      }
+      Collections.addAll(this.actions, actions);
       original.registerAction(actions);
     }
 
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java b/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java
index ee6904d..9982c73 100644
--- a/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java
+++ b/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java
@@ -1379,7 +1379,7 @@
     ImmutableList.Builder<String> basenames = ImmutableList.builder();
     for (String line : new String(bytes.toByteArray(), StandardCharsets.UTF_8).split("\n")) {
       if (line.startsWith("SF:")) {
-        String basename = line.substring(line.lastIndexOf("/") + 1);
+        String basename = line.substring(line.lastIndexOf('/') + 1);
         basenames.add(basename);
       }
     }
diff --git a/src/test/java/com/google/devtools/build/lib/collect/CollectionUtilsTest.java b/src/test/java/com/google/devtools/build/lib/collect/CollectionUtilsTest.java
index 2505501..6840df2 100644
--- a/src/test/java/com/google/devtools/build/lib/collect/CollectionUtilsTest.java
+++ b/src/test/java/com/google/devtools/build/lib/collect/CollectionUtilsTest.java
@@ -13,6 +13,7 @@
 // limitations under the License.
 package com.google.devtools.build.lib.collect;
 
+import static com.google.common.truth.Truth.assertThat;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotSame;
@@ -142,7 +143,7 @@
       allSets.add(set);
     }
 
-    assertEquals(maxBits, allSets.size());  // Assert that every decoded value is different
+    assertThat(allSets).hasSize(maxBits); // Assert that every decoded value is different
   }
 
   @Test
diff --git a/src/test/java/com/google/devtools/build/lib/collect/ImmutableSortedKeyMapTest.java b/src/test/java/com/google/devtools/build/lib/collect/ImmutableSortedKeyMapTest.java
index c712695..f1bc6d3 100644
--- a/src/test/java/com/google/devtools/build/lib/collect/ImmutableSortedKeyMapTest.java
+++ b/src/test/java/com/google/devtools/build/lib/collect/ImmutableSortedKeyMapTest.java
@@ -13,10 +13,9 @@
 // limitations under the License.
 package com.google.devtools.build.lib.collect;
 
+import static com.google.common.truth.Truth.assertThat;
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
 import com.google.common.collect.Maps;
@@ -44,7 +43,7 @@
   public void emptyBuilder() {
     ImmutableSortedKeyMap<String, Integer> map
         = ImmutableSortedKeyMap.<String, Integer>builder().build();
-    assertEquals(Collections.<String, Integer>emptyMap(), map);
+    assertThat(map).isEmpty();
   }
 
   @Test
@@ -73,7 +72,7 @@
     ImmutableSortedKeyMap<String, Integer> map = ImmutableSortedKeyMap.<String, Integer>builder()
         .putAll(Collections.<String, Integer>emptyMap())
         .build();
-    assertEquals(Collections.<String, Integer>emptyMap(), map);
+    assertThat(map).isEmpty();
   }
 
   @Test
@@ -195,7 +194,7 @@
   public void copyOfEmptyMap() {
     ImmutableSortedKeyMap<String, Integer> copy
         = ImmutableSortedKeyMap.copyOf(Collections.<String, Integer>emptyMap());
-    assertEquals(Collections.<String, Integer>emptyMap(), copy);
+    assertThat(copy).isEmpty();
     assertSame(copy, ImmutableSortedKeyMap.copyOf(copy));
   }
 
@@ -222,7 +221,7 @@
   @Test
   public void nullGet() {
     ImmutableSortedKeyMap<String, Integer> map = ImmutableSortedKeyMap.of("one", 1);
-    assertNull(map.get(null));
+    assertThat(map).doesNotContainKey(null);
   }
 
   @Test
@@ -271,8 +270,7 @@
     IntHolder holderB = new IntHolder(2);
     Map<String, IntHolder> map = ImmutableSortedKeyMap.of("a", holderA, "b", holderB);
     holderA.value = 3;
-    assertTrue(map.entrySet().contains(
-        Maps.immutableEntry("a", new IntHolder(3))));
+    assertThat(map.entrySet()).contains(Maps.immutableEntry("a", new IntHolder(3)));
     Map<String, Integer> intMap = ImmutableSortedKeyMap.of("a", 3, "b", 2);
     assertEquals(intMap.hashCode(), map.entrySet().hashCode());
     assertEquals(intMap.hashCode(), map.hashCode());
diff --git a/src/test/java/com/google/devtools/build/lib/collect/nestedset/ExpanderTestBase.java b/src/test/java/com/google/devtools/build/lib/collect/nestedset/ExpanderTestBase.java
index 25448c6..0cf65db 100644
--- a/src/test/java/com/google/devtools/build/lib/collect/nestedset/ExpanderTestBase.java
+++ b/src/test/java/com/google/devtools/build/lib/collect/nestedset/ExpanderTestBase.java
@@ -13,6 +13,7 @@
 // limitations under the License.
 package com.google.devtools.build.lib.collect.nestedset;
 
+import static junit.framework.TestCase.assertFalse;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
@@ -205,7 +206,7 @@
   @Test
   public void getOrdering() {
     NestedSet<String> s = prepareBuilder("a", "b").build();
-    assertTrue(!s.isEmpty());
+    assertFalse(s.isEmpty());
     assertEquals(expanderOrder(), s.getOrder());
   }
 
diff --git a/src/test/java/com/google/devtools/build/lib/collect/nestedset/NestedSetImplTest.java b/src/test/java/com/google/devtools/build/lib/collect/nestedset/NestedSetImplTest.java
index e5cfae3..04690c9 100644
--- a/src/test/java/com/google/devtools/build/lib/collect/nestedset/NestedSetImplTest.java
+++ b/src/test/java/com/google/devtools/build/lib/collect/nestedset/NestedSetImplTest.java
@@ -13,6 +13,7 @@
 // limitations under the License.
 package com.google.devtools.build.lib.collect.nestedset;
 
+import static com.google.common.truth.Truth.assertThat;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
@@ -47,8 +48,8 @@
     NestedSet<String> set = nestedSetBuilder("a").build();
 
     assertTrue(Arrays.equals(new String[]{"a"}, set.directMembers()));
-    assertEquals(0, set.transitiveSets().length);
-    assertEquals(false, set.isEmpty());
+    assertThat(set.transitiveSets()).isEmpty();
+    assertFalse(set.isEmpty());
   }
 
   @Test
@@ -173,7 +174,7 @@
     for (SetWrapper<Integer> wrap : nested) {
       builder.addTransitive(wrap.set);
     }
-    return new SetWrapper<Integer>(builder.build());
+    return new SetWrapper<>(builder.build());
   }
 
   @Test
diff --git a/src/test/java/com/google/devtools/build/lib/concurrent/AbstractQueueVisitorTest.java b/src/test/java/com/google/devtools/build/lib/concurrent/AbstractQueueVisitorTest.java
index 8a6485c..1ac6792 100644
--- a/src/test/java/com/google/devtools/build/lib/concurrent/AbstractQueueVisitorTest.java
+++ b/src/test/java/com/google/devtools/build/lib/concurrent/AbstractQueueVisitorTest.java
@@ -13,6 +13,7 @@
 // limitations under the License.
 package com.google.devtools.build.lib.concurrent;
 
+import static com.google.common.truth.Truth.assertThat;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertSame;
@@ -127,7 +128,7 @@
       counter.work(false);
       fail();
     } catch (Error expected) {
-      assertEquals("Could not create thread (fakeout)", expected.getMessage());
+      assertThat(expected).hasMessage("Could not create thread (fakeout)");
     }
     assertSame(5, counter.getCount());
 
@@ -317,14 +318,13 @@
       fail();
     } catch (Exception e) {
       if (interrupt) {
-        assertTrue(e instanceof InterruptedException);
+        assertThat(e).isInstanceOf(InterruptedException.class);
       } else {
         assertSame(THROWABLE, e);
       }
     }
-    assertTrue(
-        "got: " + visitedList + "\nwant: " + Arrays.toString(expectedVisited),
-        Sets.newHashSet(visitedList).equals(Sets.newHashSet(expectedVisited)));
+    assertEquals("got: " + visitedList + "\nwant: " + Arrays.toString(expectedVisited),
+        Sets.newHashSet(expectedVisited), Sets.newHashSet(visitedList));
 
     if (executor != null) {
       assertFalse(executor.isShutdown());
diff --git a/src/test/java/com/google/devtools/build/lib/concurrent/MoreFuturesTest.java b/src/test/java/com/google/devtools/build/lib/concurrent/MoreFuturesTest.java
index 60f29ac..52bb7f2 100644
--- a/src/test/java/com/google/devtools/build/lib/concurrent/MoreFuturesTest.java
+++ b/src/test/java/com/google/devtools/build/lib/concurrent/MoreFuturesTest.java
@@ -13,7 +13,7 @@
 // limitations under the License.
 package com.google.devtools.build.lib.concurrent;
 
-import static org.junit.Assert.assertEquals;
+import static com.google.common.truth.Truth.assertThat;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
@@ -69,12 +69,12 @@
     }
     ListenableFuture<List<Object>> list = MoreFutures.allAsListOrCancelAll(futureList);
     List<Object> result = list.get();
-    assertEquals(futureList.size(), result.size());
+    assertThat(result).hasSize(futureList.size());
     for (DelayedFuture delayedFuture : futureList) {
       assertFalse(delayedFuture.wasCanceled);
       assertFalse(delayedFuture.wasInterrupted);
       assertNotNull(delayedFuture.get());
-      assertTrue(result.contains(delayedFuture.get()));
+      assertThat(result).contains(delayedFuture.get());
     }
   }
 
diff --git a/src/test/java/com/google/devtools/build/lib/events/PrintingEventHandlerTest.java b/src/test/java/com/google/devtools/build/lib/events/PrintingEventHandlerTest.java
index 4cdfcb4..2585596 100644
--- a/src/test/java/com/google/devtools/build/lib/events/PrintingEventHandlerTest.java
+++ b/src/test/java/com/google/devtools/build/lib/events/PrintingEventHandlerTest.java
@@ -13,7 +13,7 @@
 // limitations under the License.
 package com.google.devtools.build.lib.events;
 
-import static org.junit.Assert.assertEquals;
+import static com.google.common.truth.Truth.assertThat;
 
 import com.google.devtools.build.lib.testutil.MoreAsserts;
 import com.google.devtools.build.lib.util.io.RecordingOutErr;
@@ -37,7 +37,7 @@
     MoreAsserts.assertEqualsUnifyingLineEnds("WARNING: /my/sample/path.txt:3:4: "
                  + "This is not an error message.\n",
                  recordingOutErr.errAsLatin1());
-    assertEquals("", recordingOutErr.outAsLatin1());
+    assertThat(recordingOutErr.outAsLatin1()).isEmpty();
   }
 
 }
diff --git a/src/test/java/com/google/devtools/build/lib/events/ReporterStreamTest.java b/src/test/java/com/google/devtools/build/lib/events/ReporterStreamTest.java
index 092d940..27a67fb 100644
--- a/src/test/java/com/google/devtools/build/lib/events/ReporterStreamTest.java
+++ b/src/test/java/com/google/devtools/build/lib/events/ReporterStreamTest.java
@@ -13,7 +13,7 @@
 // limitations under the License.
 package com.google.devtools.build.lib.events;
 
-import static org.junit.Assert.assertEquals;
+import static com.google.common.truth.Truth.assertThat;
 
 import com.google.devtools.build.lib.testutil.MoreAsserts;
 
@@ -45,16 +45,16 @@
 
   @Test
   public void reporterStream() throws Exception {
-    assertEquals("", out.toString());
+    assertThat(out.toString()).isEmpty();
     reporter.addHandler(outAppender);
-    PrintWriter infoWriter = new PrintWriter(new ReporterStream(reporter, EventKind.INFO), true);
-    PrintWriter warnWriter = new PrintWriter(new ReporterStream(reporter, EventKind.WARNING), true);
-    try {
+    try (
+      PrintWriter warnWriter =
+        new PrintWriter(new ReporterStream(reporter, EventKind.WARNING), true);
+      PrintWriter infoWriter =
+          new PrintWriter(new ReporterStream(reporter, EventKind.INFO), true)
+    ) {
       infoWriter.println("some info");
       warnWriter.println("a warning");
-    } finally {
-      infoWriter.close();
-      warnWriter.close();
     }
     reporter.getOutErr().printOutLn("some output");
     reporter.getOutErr().printErrLn("an error");
diff --git a/src/test/java/com/google/devtools/build/lib/events/ReporterTest.java b/src/test/java/com/google/devtools/build/lib/events/ReporterTest.java
index f51451a..0a248c6 100644
--- a/src/test/java/com/google/devtools/build/lib/events/ReporterTest.java
+++ b/src/test/java/com/google/devtools/build/lib/events/ReporterTest.java
@@ -13,6 +13,7 @@
 // limitations under the License.
 package com.google.devtools.build.lib.events;
 
+import static com.google.common.truth.Truth.assertThat;
 import static org.junit.Assert.assertEquals;
 
 import com.google.common.collect.ImmutableList;
@@ -55,7 +56,7 @@
     reporter.handle(interesting);
     reporter.handle(new Event(EventKind.WARNING, null, "ignore-me", "good"));
 
-    assertEquals(ImmutableList.copyOf(collector.iterator()), ImmutableList.of(interesting));
+    assertEquals(ImmutableList.copyOf(collector), ImmutableList.of(interesting));
   }
 
   @Test
@@ -66,7 +67,7 @@
     for (Event e : want) {
       reporter.handle(e);
     }
-    ImmutableList<Event> got = ImmutableList.copyOf(collector.iterator());
+    ImmutableList<Event> got = ImmutableList.copyOf(collector);
     assertEquals(got, want);
   }
 
@@ -87,14 +88,14 @@
 
   @Test
   public void removeHandlerUndoesAddHandler() {
-    assertEquals("", out.toString());
+    assertThat(out.toString()).isEmpty();
     reporter.addHandler(outAppender);
     reporter.handle(Event.error(location, "Event gets registered."));
     assertEquals("Event gets registered.", out.toString());
     out = new StringBuilder();
     reporter.removeHandler(outAppender);
     reporter.handle(Event.error(location, "Event gets ignored."));
-    assertEquals("", out.toString());
+    assertThat(out.toString()).isEmpty();
   }
 
 }
diff --git a/src/test/java/com/google/devtools/build/lib/events/StoredErrorEventHandlerTest.java b/src/test/java/com/google/devtools/build/lib/events/StoredErrorEventHandlerTest.java
index d47cf86..16eaf1e 100644
--- a/src/test/java/com/google/devtools/build/lib/events/StoredErrorEventHandlerTest.java
+++ b/src/test/java/com/google/devtools/build/lib/events/StoredErrorEventHandlerTest.java
@@ -67,9 +67,6 @@
     }
 
     eventHandler.replayOn(sink);
-    assertEquals(events.size(), sink.getEvents().size());
-    for (int i = 0; i < events.size(); i++) {
-      assertEquals(events.get(i), sink.getEvents().get(i));
-    }
+    assertEquals(events, sink.getEvents());
   }
 }
diff --git a/src/test/java/com/google/devtools/build/lib/shell/CommandLargeInputsTest.java b/src/test/java/com/google/devtools/build/lib/shell/CommandLargeInputsTest.java
index 06d4f9a..8ffacd1 100644
--- a/src/test/java/com/google/devtools/build/lib/shell/CommandLargeInputsTest.java
+++ b/src/test/java/com/google/devtools/build/lib/shell/CommandLargeInputsTest.java
@@ -121,11 +121,11 @@
     ByteArrayOutputStream out = new ByteArrayOutputStream();
     ByteArrayOutputStream err = new ByteArrayOutputStream();
     command.execute(Command.NO_INPUT, Command.NO_OBSERVER, out, err);
-    StringBuffer expectedOut = new StringBuffer();
-    StringBuffer expectedErr = new StringBuffer();
+    StringBuilder expectedOut = new StringBuilder();
+    StringBuilder expectedErr = new StringBuilder();
     for (int i = 0; i < 1000; i++) {
-      expectedOut.append("OUT").append(Integer.toString(i)).append("\n");
-      expectedErr.append("ERR").append(Integer.toString(i)).append("\n");
+      expectedOut.append("OUT").append(i).append("\n");
+      expectedErr.append("ERR").append(i).append("\n");
     }
     assertEquals(expectedOut.toString(), out.toString("UTF-8"));
     assertEquals(expectedErr.toString(), err.toString("UTF-8"));
diff --git a/src/test/java/com/google/devtools/build/lib/shell/CommandTest.java b/src/test/java/com/google/devtools/build/lib/shell/CommandTest.java
index 694972e..ef45a63 100644
--- a/src/test/java/com/google/devtools/build/lib/shell/CommandTest.java
+++ b/src/test/java/com/google/devtools/build/lib/shell/CommandTest.java
@@ -13,6 +13,7 @@
 // limitations under the License.
 package com.google.devtools.build.lib.shell;
 
+import static com.google.common.truth.Truth.assertThat;
 import static com.google.devtools.build.lib.shell.TestUtil.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
@@ -100,7 +101,7 @@
     final Command command = new Command(commandArgs, env, workingDir);
     assertArrayEquals(commandArgs, command.getCommandLineElements());
     for (final String key : env.keySet()) {
-      assertEquals(env.get(key), command.getEnvironmentVariables().get(key));
+      assertThat(command.getEnvironmentVariables()).containsEntry(key, env.get(key));
     }
     assertEquals(workingDir, command.getWorkingDirectory());
   }
@@ -112,8 +113,8 @@
     final Command command = new Command(new String[] {"ls"});
     final CommandResult result = command.execute();
     assertTrue(result.getTerminationStatus().success());
-    assertTrue(result.getStderr().length == 0);
-    assertTrue(result.getStdout().length > 0);
+    assertEquals(0, result.getStderr().length);
+    assertThat(result.getStdout().length).isGreaterThan(0);
   }
 
   @Test
@@ -149,8 +150,8 @@
                                                        "print 'a'x100000" });
     final CommandResult result = command.execute();
     assertTrue(result.getTerminationStatus().success());
-    assertTrue(result.getStderr().length == 0);
-    assertTrue(result.getStdout().length > 0);
+    assertEquals(0, result.getStderr().length);
+    assertThat(result.getStdout().length).isGreaterThan(0);
   }
 
   @Test
@@ -199,8 +200,8 @@
     CommandResult result = command.execute(emptyInput,
                                            Command.NO_OBSERVER, out, err);
     assertTrue(result.getTerminationStatus().success());
-    assertEquals("", out.toString("UTF-8"));
-    assertEquals("", err.toString("UTF-8"));
+    assertThat(out.toString("UTF-8")).isEmpty();
+    assertThat(err.toString("UTF-8")).isEmpty();
   }
 
   @Test
@@ -208,8 +209,8 @@
     final Command command = new Command(new String[]{"/bin/cat"});
     CommandResult result = command.execute();
     assertTrue(result.getTerminationStatus().success());
-    assertEquals("", new String(result.getStdout(), "UTF-8"));
-    assertEquals("", new String(result.getStderr(), "UTF-8"));
+    assertThat(new String(result.getStdout(), "UTF-8")).isEmpty();
+    assertThat(new String(result.getStderr(), "UTF-8")).isEmpty();
   }
 
   @Test
@@ -355,7 +356,7 @@
         new Command(args).execute();
         fail("Should have exited with status " + exit);
       } catch (BadExitStatusException e) {
-        assertEquals("Process exited with status " + exit, e.getMessage());
+        assertThat(e).hasMessage("Process exited with status " + exit);
         checkCommandElements(e, "/bin/sh", "-c", "exit " + exit);
         TerminationStatus status = e.getResult().getTerminationStatus();
         assertFalse(status.success());
@@ -373,7 +374,7 @@
         new Command(args).execute();
         fail("Should have exited with status " + expected);
       } catch (BadExitStatusException e) {
-        assertEquals("Process exited with status " + expected, e.getMessage());
+        assertThat(e).hasMessage("Process exited with status " + expected);
         checkCommandElements(e, "/bin/sh", "-c", "exit " + exit);
         TerminationStatus status = e.getResult().getTerminationStatus();
         assertFalse(status.success());
@@ -398,7 +399,7 @@
         new Command(args).execute();
         fail("Expected signal " + signal);
       } catch (AbnormalTerminationException e) {
-        assertEquals("Process terminated by signal " + signal, e.getMessage());
+        assertThat(e).hasMessage("Process terminated by signal " + signal);
         checkCommandElements(e, killmyself, "" + signal);
         TerminationStatus status = e.getResult().getTerminationStatus();
         assertFalse(status.success());
@@ -535,8 +536,8 @@
 
     final CommandResult result = resultContainer[0];
     assertTrue(result.getTerminationStatus().success());
-    assertTrue(result.getStderr().length == 0);
-    assertTrue(result.getStdout().length == 0);
+    assertEquals(0, result.getStderr().length);
+    assertEquals(0, result.getStdout().length);
   }
 
   @Test
@@ -554,7 +555,7 @@
     } catch (AbnormalTerminationException e) {
       // Good.
       checkCommandElements(e, "/bin/echo", "foo");
-      assertEquals("java.io.IOException", e.getMessage());
+      assertThat(e).hasMessage("java.io.IOException");
     }
   }
 
@@ -681,7 +682,7 @@
   private static void checkSuccess(final CommandResult result,
                                    final String expectedOutput) {
     assertTrue(result.getTerminationStatus().success());
-    assertTrue(result.getStderr().length == 0);
+    assertEquals(0, result.getStderr().length);
     assertEquals(expectedOutput, new String(result.getStdout()));
   }
 }
diff --git a/src/test/java/com/google/devtools/build/lib/shell/ConsumersTest.java b/src/test/java/com/google/devtools/build/lib/shell/ConsumersTest.java
index d03012d..e521949 100644
--- a/src/test/java/com/google/devtools/build/lib/shell/ConsumersTest.java
+++ b/src/test/java/com/google/devtools/build/lib/shell/ConsumersTest.java
@@ -13,7 +13,7 @@
 // limitations under the License.
 package com.google.devtools.build.lib.shell;
 
-import static org.junit.Assert.assertEquals;
+import static com.google.common.truth.Truth.assertThat;
 import static org.junit.Assert.assertSame;
 import static org.junit.Assert.fail;
 
@@ -65,7 +65,7 @@
       outErr.waitForCompletion();
       fail();
     } catch (IOException e) {
-      assertEquals(SECRET_MESSAGE, e.getMessage());
+      assertThat(e).hasMessage(SECRET_MESSAGE);
     }
   }
 
@@ -118,7 +118,7 @@
     } catch (IOException e) {
       fail();
     } catch (Error e) {
-      assertEquals(SECRET_MESSAGE, e.getMessage());
+      assertThat(e).hasMessage(SECRET_MESSAGE);
     }
   }
 
@@ -143,7 +143,7 @@
       outErr.waitForCompletion();
       fail();
     } catch (RuntimeException e) {
-      assertEquals(SECRET_MESSAGE, e.getMessage());
+      assertThat(e).hasMessage(SECRET_MESSAGE);
     }
   }
 
diff --git a/src/test/java/com/google/devtools/build/lib/shell/LoadTest.java b/src/test/java/com/google/devtools/build/lib/shell/LoadTest.java
index b49ddd9..545120e 100644
--- a/src/test/java/com/google/devtools/build/lib/shell/LoadTest.java
+++ b/src/test/java/com/google/devtools/build/lib/shell/LoadTest.java
@@ -52,12 +52,12 @@
     tempFile.deleteOnExit();
 
     // write some random numbers to the file
-    final PrintWriter out = new PrintWriter(new FileWriter(tempFile));
-    final Random r = new Random();
-    for (int i = 0; i < 100; i++) {
-      out.println(String.valueOf(r.nextDouble()));
+    try (final PrintWriter out = new PrintWriter(new FileWriter(tempFile))) {
+      final Random r = new Random();
+      for (int i = 0; i < 100; i++) {
+        out.println(String.valueOf(r.nextDouble()));
+      }
     }
-    out.close();
   }
 
   @After
diff --git a/src/test/java/com/google/devtools/build/lib/shell/ShellUtilsTest.java b/src/test/java/com/google/devtools/build/lib/shell/ShellUtilsTest.java
index 1034561..cfda807 100644
--- a/src/test/java/com/google/devtools/build/lib/shell/ShellUtilsTest.java
+++ b/src/test/java/com/google/devtools/build/lib/shell/ShellUtilsTest.java
@@ -13,6 +13,7 @@
 // limitations under the License.
 package com.google.devtools.build.lib.shell;
 
+import static com.google.common.truth.Truth.assertThat;
 import static com.google.devtools.build.lib.shell.ShellUtils.prettyPrintArgv;
 import static com.google.devtools.build.lib.shell.ShellUtils.shellEscape;
 import static com.google.devtools.build.lib.shell.ShellUtils.tokenize;
@@ -55,7 +56,7 @@
 
   private void assertTokenize(String copts, String... expectedTokens)
       throws Exception {
-    List<String> actualTokens = new ArrayList<String>();
+    List<String> actualTokens = new ArrayList<>();
     tokenize(actualTokens, copts);
     assertEquals(Arrays.asList(expectedTokens), actualTokens);
   }
@@ -126,7 +127,7 @@
       tokenize(new ArrayList<String>(), copts);
       fail();
     } catch (ShellUtils.TokenizationException e) {
-      assertEquals(expectedError, e.getMessage());
+      assertThat(e).hasMessage(expectedError);
     }
   }
 
@@ -163,14 +164,14 @@
     // because String.split() ignores trailing empty strings.
     ArrayList<String> words = Lists.newArrayList();
     int index;
-    while ((index = stdout.indexOf("\n")) >= 0) {
+    while ((index = stdout.indexOf('\n')) >= 0) {
       words.add(stdout.substring(0, index));
       stdout = stdout.substring(index + 1);
     }
     assertEquals(in, words);
 
     // Assert that tokenize is dual to pretty-print:
-    List<String> out = new ArrayList<String>();
+    List<String> out = new ArrayList<>();
     try {
       tokenize(out, shellCommand);
     } finally {
diff --git a/src/test/java/com/google/devtools/build/lib/shell/ToTruncatedStringTest.java b/src/test/java/com/google/devtools/build/lib/shell/ToTruncatedStringTest.java
index 90a4234..3a7b7d6 100644
--- a/src/test/java/com/google/devtools/build/lib/shell/ToTruncatedStringTest.java
+++ b/src/test/java/com/google/devtools/build/lib/shell/ToTruncatedStringTest.java
@@ -13,6 +13,7 @@
 // limitations under the License.
 package com.google.devtools.build.lib.shell;
 
+import static com.google.common.truth.Truth.assertThat;
 import static org.junit.Assert.assertEquals;
 
 import org.junit.Before;
@@ -44,12 +45,12 @@
 
   @Test
   public void testTruncatingNullYieldsEmptyString() {
-    assertEquals("", LogUtil.toTruncatedString(null));
+    assertThat(LogUtil.toTruncatedString(null)).isEmpty();
   }
 
   @Test
   public void testTruncatingEmptyArrayYieldsEmptyString() {
-    assertEquals("", LogUtil.toTruncatedString(new byte[0]));
+    assertThat(LogUtil.toTruncatedString(new byte[0])).isEmpty();
   }
 
   @Test
diff --git a/src/test/java/com/google/devtools/build/lib/syntax/EnvironmentTest.java b/src/test/java/com/google/devtools/build/lib/syntax/EnvironmentTest.java
index 9dc5dd3..36a50c1 100644
--- a/src/test/java/com/google/devtools/build/lib/syntax/EnvironmentTest.java
+++ b/src/test/java/com/google/devtools/build/lib/syntax/EnvironmentTest.java
@@ -14,6 +14,7 @@
 
 package com.google.devtools.build.lib.syntax;
 
+import static com.google.common.truth.Truth.assertThat;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.fail;
 
@@ -38,7 +39,7 @@
       env.lookup("foo");
       fail();
     } catch (Environment.NoSuchVariableException e) {
-       assertEquals("no such variable: foo", e.getMessage());
+      assertThat(e).hasMessage("no such variable: foo");
     }
 
     env.update("foo", "bar");
@@ -72,7 +73,7 @@
       env.lookup("foo");
       fail();
     } catch (Environment.NoSuchVariableException e) {
-      assertEquals("no such variable: foo", e.getMessage());
+      assertThat(e).hasMessage("no such variable: foo");
     }
 
     exec(parseStmt("foo = 'bar'"), env);
@@ -89,7 +90,7 @@
       eval(parseExpr("foo"), env);
       fail();
     } catch (EvalException e) {
-      assertEquals("name 'foo' is not defined", e.getMessage());
+      assertThat(e).hasMessage("name 'foo' is not defined");
     }
 
     env.update("foo", "bar");
@@ -106,7 +107,7 @@
       eval(parseExpr("foo"), env);
       fail();
     } catch (EvalException e) {
-      assertEquals("name 'foo' is not defined", e.getMessage());
+      assertThat(e).hasMessage("name 'foo' is not defined");
     }
 
     exec(parseStmt("foo = 'bar'"), env);
@@ -144,7 +145,7 @@
       new Environment().update("some_name", null);
       fail();
     } catch (NullPointerException e) {
-      assertEquals("update(value == null)", e.getMessage());
+      assertThat(e).hasMessage("update(value == null)");
     }
   }
 }
diff --git a/src/test/java/com/google/devtools/build/lib/syntax/EvalUtilsTest.java b/src/test/java/com/google/devtools/build/lib/syntax/EvalUtilsTest.java
index ed4c930..9e4ed16 100644
--- a/src/test/java/com/google/devtools/build/lib/syntax/EvalUtilsTest.java
+++ b/src/test/java/com/google/devtools/build/lib/syntax/EvalUtilsTest.java
@@ -128,7 +128,7 @@
       EvalUtils.formatString(format, tuple);
       fail();
     } catch (IllegalFormatException e) {
-      assertEquals(errorMessage, e.getMessage());
+      assertThat(e).hasMessage(errorMessage);
     }
   }
 
diff --git a/src/test/java/com/google/devtools/build/lib/syntax/EvaluationTest.java b/src/test/java/com/google/devtools/build/lib/syntax/EvaluationTest.java
index 932ea3b..342f34e 100644
--- a/src/test/java/com/google/devtools/build/lib/syntax/EvaluationTest.java
+++ b/src/test/java/com/google/devtools/build/lib/syntax/EvaluationTest.java
@@ -19,6 +19,7 @@
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
+import com.google.common.base.Functions;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.Iterables;
@@ -258,10 +259,7 @@
           if ((Integer) args.get(0) == 0) {
             return keys;
           } else {
-            return Lists.transform(keys, new com.google.common.base.Function<String, Object> () {
-                  @Override public Object apply (String s) {
-                    return kwargs.get(s);
-                  }});
+            return Lists.transform(keys, Functions.forMap(kwargs, null));
           }
         }
       };
@@ -530,7 +528,7 @@
       eval(input, env);
       fail();
     } catch (EvalException e) {
-      assertEquals(msg, e.getMessage());
+      assertThat(e).hasMessage(msg);
     }
   }
 
@@ -544,7 +542,7 @@
       exec(input, env);
       fail();
     } catch (EvalException e) {
-      assertEquals(msg, e.getMessage());
+      assertThat(e).hasMessage(msg);
     }
   }
 }
diff --git a/src/test/java/com/google/devtools/build/lib/syntax/FunctionTest.java b/src/test/java/com/google/devtools/build/lib/syntax/FunctionTest.java
index eaefb69..4ce41cb 100644
--- a/src/test/java/com/google/devtools/build/lib/syntax/FunctionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/syntax/FunctionTest.java
@@ -459,7 +459,7 @@
       exec(input, env);
       fail();
     } catch (EvalException e) {
-      assertEquals(msg, e.getMessage());
+      assertThat(e).hasMessage(msg);
     }
   }
 }
diff --git a/src/test/java/com/google/devtools/build/lib/syntax/GlobCriteriaTest.java b/src/test/java/com/google/devtools/build/lib/syntax/GlobCriteriaTest.java
index e0a18f4..4620269 100644
--- a/src/test/java/com/google/devtools/build/lib/syntax/GlobCriteriaTest.java
+++ b/src/test/java/com/google/devtools/build/lib/syntax/GlobCriteriaTest.java
@@ -13,12 +13,12 @@
 // limitations under the License.
 package com.google.devtools.build.lib.syntax;
 
+import static com.google.common.truth.Truth.assertThat;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
-import com.google.common.collect.ImmutableList;
 import com.google.devtools.build.lib.testutil.Suite;
 import com.google.devtools.build.lib.testutil.TestSpec;
 
@@ -37,72 +37,72 @@
   public void testParse_EmptyList() throws Exception {
     GlobCriteria gc = GlobCriteria.parse("[]");
     assertFalse(gc.isGlob());
-    assertTrue(gc.getIncludePatterns().isEmpty());
-    assertTrue(gc.getExcludePatterns().isEmpty());
+    assertThat(gc.getIncludePatterns()).isEmpty();
+    assertThat(gc.getExcludePatterns()).isEmpty();
   }
 
   @Test
   public void testParse_SingleList() throws Exception {
     GlobCriteria gc = GlobCriteria.parse("['abc']");
     assertFalse(gc.isGlob());
-    assertEquals(ImmutableList.of("abc"), gc.getIncludePatterns());
-    assertTrue(gc.getExcludePatterns().isEmpty());
+    assertThat(gc.getIncludePatterns()).containsExactly("abc");
+    assertThat(gc.getExcludePatterns()).isEmpty();
   }
 
   @Test
   public void testParse_MultipleList() throws Exception {
     GlobCriteria gc = GlobCriteria.parse("['abc', 'def', 'ghi']");
     assertFalse(gc.isGlob());
-    assertEquals(ImmutableList.of("abc", "def", "ghi"), gc.getIncludePatterns());
-    assertTrue(gc.getExcludePatterns().isEmpty());
+    assertThat(gc.getIncludePatterns()).containsExactly("abc", "def", "ghi").inOrder();
+    assertThat(gc.getExcludePatterns()).isEmpty();
   }
 
   @Test
   public void testParse_EmptyGlob() throws Exception {
     GlobCriteria gc = GlobCriteria.parse("glob([])");
     assertTrue(gc.isGlob());
-    assertTrue(gc.getIncludePatterns().isEmpty());
-    assertTrue(gc.getExcludePatterns().isEmpty());
+    assertThat(gc.getIncludePatterns()).isEmpty();
+    assertThat(gc.getExcludePatterns()).isEmpty();
   }
 
   @Test
   public void testParse_SingleGlob() throws Exception {
     GlobCriteria gc = GlobCriteria.parse("glob(['abc'])");
     assertTrue(gc.isGlob());
-    assertEquals(ImmutableList.of("abc"), gc.getIncludePatterns());
-    assertTrue(gc.getExcludePatterns().isEmpty());
+    assertThat(gc.getIncludePatterns()).containsExactly("abc");
+    assertThat(gc.getExcludePatterns()).isEmpty();
   }
 
   @Test
   public void testParse_MultipleGlob() throws Exception {
     GlobCriteria gc = GlobCriteria.parse("glob(['abc', 'def', 'ghi'])");
     assertTrue(gc.isGlob());
-    assertEquals(ImmutableList.of("abc", "def", "ghi"), gc.getIncludePatterns());
-    assertTrue(gc.getExcludePatterns().isEmpty());
+    assertThat(gc.getIncludePatterns()).containsExactly("abc", "def", "ghi").inOrder();
+    assertThat(gc.getExcludePatterns()).isEmpty();
   }
 
   @Test
   public void testParse_EmptyGlobWithExclude() throws Exception {
     GlobCriteria gc = GlobCriteria.parse("glob([], exclude=['xyz'])");
     assertTrue(gc.isGlob());
-    assertTrue(gc.getIncludePatterns().isEmpty());
-    assertEquals(ImmutableList.of("xyz"), gc.getExcludePatterns());
+    assertThat(gc.getIncludePatterns()).isEmpty();
+    assertThat(gc.getExcludePatterns()).containsExactly("xyz");
   }
 
   @Test
   public void testParse_SingleGlobWithExclude() throws Exception {
     GlobCriteria gc = GlobCriteria.parse("glob(['abc'], exclude=['xyz'])");
     assertTrue(gc.isGlob());
-    assertEquals(ImmutableList.of("abc"), gc.getIncludePatterns());
-    assertEquals(ImmutableList.of("xyz"), gc.getExcludePatterns());
+    assertThat(gc.getIncludePatterns()).containsExactly("abc");
+    assertThat(gc.getExcludePatterns()).containsExactly("xyz");
   }
 
   @Test
   public void testParse_MultipleGlobWithExclude() throws Exception {
     GlobCriteria gc = GlobCriteria.parse("glob(['abc', 'def', 'ghi'], exclude=['xyz'])");
     assertTrue(gc.isGlob());
-    assertEquals(ImmutableList.of("abc", "def", "ghi"), gc.getIncludePatterns());
-    assertEquals(ImmutableList.of("xyz"), gc.getExcludePatterns());
+    assertThat(gc.getIncludePatterns()).containsExactly("abc", "def", "ghi").inOrder();
+    assertThat(gc.getExcludePatterns()).containsExactly("xyz");
   }
 
   @Test
@@ -110,24 +110,24 @@
     GlobCriteria gc = GlobCriteria.parse(
         "glob(['abc', 'def', 'ghi'], exclude=['rst', 'uvw', 'xyz'])");
     assertTrue(gc.isGlob());
-    assertEquals(ImmutableList.of("abc", "def", "ghi"), gc.getIncludePatterns());
-    assertEquals(ImmutableList.of("rst", "uvw", "xyz"), gc.getExcludePatterns());
+    assertThat(gc.getIncludePatterns()).containsExactly("abc", "def", "ghi").inOrder();
+    assertThat(gc.getExcludePatterns()).containsExactly("rst", "uvw", "xyz").inOrder();
   }
 
   @Test
   public void testParse_GlobWithSlashesAndWildcards() throws Exception {
     GlobCriteria gc = GlobCriteria.parse("glob(['java/src/net/jsunit/*.java'])");
     assertTrue(gc.isGlob());
-    assertEquals(ImmutableList.of("java/src/net/jsunit/*.java"), gc.getIncludePatterns());
-    assertTrue(gc.getExcludePatterns().isEmpty());
+    assertThat(gc.getIncludePatterns()).containsExactly("java/src/net/jsunit/*.java");
+    assertThat(gc.getExcludePatterns()).isEmpty();
   }
 
   @Test
   public void testParse_ExcludeWithInvalidLabel() throws Exception {
     GlobCriteria gc = GlobCriteria.parse("glob(['abc', 'def', 'ghi'], exclude=['xyz~'])");
     assertTrue(gc.isGlob());
-    assertEquals(ImmutableList.of("abc", "def", "ghi"), gc.getIncludePatterns());
-    assertEquals(ImmutableList.of("xyz~"), gc.getExcludePatterns());
+    assertThat(gc.getIncludePatterns()).containsExactly("abc", "def", "ghi").inOrder();
+    assertThat(gc.getExcludePatterns()).containsExactly("xyz~");
   }
 
   @Test
diff --git a/src/test/java/com/google/devtools/build/lib/syntax/GlobListTest.java b/src/test/java/com/google/devtools/build/lib/syntax/GlobListTest.java
index 95535ed..75c8b06 100644
--- a/src/test/java/com/google/devtools/build/lib/syntax/GlobListTest.java
+++ b/src/test/java/com/google/devtools/build/lib/syntax/GlobListTest.java
@@ -13,6 +13,7 @@
 // limitations under the License.
 package com.google.devtools.build.lib.syntax;
 
+import static com.google.common.truth.Truth.assertThat;
 import static org.junit.Assert.assertEquals;
 
 import com.google.common.collect.ImmutableList;
@@ -96,7 +97,7 @@
     GlobList<String> glob = GlobList.captureResults(include, exclude, matches);
     assertEquals(matches, glob);
     ImmutableList<GlobCriteria> criteria = glob.getCriteria();
-    assertEquals(1, criteria.size());
+    assertThat(criteria).hasSize(1);
     assertEquals(include, criteria.get(0).getIncludePatterns());
     assertEquals(exclude, criteria.get(0).getExcludePatterns());
   }
diff --git a/src/test/java/com/google/devtools/build/lib/syntax/LabelTest.java b/src/test/java/com/google/devtools/build/lib/syntax/LabelTest.java
index a0daf20..4aac0de 100644
--- a/src/test/java/com/google/devtools/build/lib/syntax/LabelTest.java
+++ b/src/test/java/com/google/devtools/build/lib/syntax/LabelTest.java
@@ -13,10 +13,10 @@
 // limitations under the License.
 package com.google.devtools.build.lib.syntax;
 
+import static com.google.common.truth.Truth.assertThat;
 import static com.google.devtools.build.lib.testutil.MoreAsserts.assertContainsRegex;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
 import com.google.devtools.build.lib.syntax.Label.SyntaxException;
@@ -144,10 +144,10 @@
     Label l2 = Label.parseAbsolute("//foo/bar:baz");
     Label l3 = Label.parseAbsolute("//foo/bar:quux");
 
-    assertTrue(l1.equals(l1));
-    assertTrue(l2.equals(l1));
-    assertTrue(l1.equals(l2));
-    assertTrue(l2.equals(l1));
+    assertEquals(l1, l1);
+    assertEquals(l1, l2);
+    assertEquals(l2, l1);
+    assertEquals(l1, l2);
 
     assertFalse(l3.equals(l1));
     assertFalse(l1.equals(l3));
@@ -357,8 +357,7 @@
       Label.parseRepositoryLabel("foo//bar/baz:bat/boo");
       fail();
     } catch (SyntaxException e) {
-      assertEquals("invalid repository name 'foo': workspace name must start with '@'",
-          e.getMessage());
+      assertThat(e).hasMessage("invalid repository name 'foo': workspace name must start with '@'");
     }
   }
 }
diff --git a/src/test/java/com/google/devtools/build/lib/syntax/MixedModeFunctionTest.java b/src/test/java/com/google/devtools/build/lib/syntax/MixedModeFunctionTest.java
index ceeae38..6b7355b 100644
--- a/src/test/java/com/google/devtools/build/lib/syntax/MixedModeFunctionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/syntax/MixedModeFunctionTest.java
@@ -13,6 +13,7 @@
 // limitations under the License.
 package com.google.devtools.build.lib.syntax;
 
+import static com.google.common.truth.Truth.assertThat;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.fail;
 
@@ -65,7 +66,7 @@
         eval(callExpression, env);
         fail();
       } catch (EvalException e) {
-        assertEquals(expectedOutput, e.getMessage());
+        assertThat(e).hasMessage(expectedOutput);
       }
     }
   }
diff --git a/src/test/java/com/google/devtools/build/lib/syntax/ParserInputSourceTest.java b/src/test/java/com/google/devtools/build/lib/syntax/ParserInputSourceTest.java
index f174cd7..895e7fb 100644
--- a/src/test/java/com/google/devtools/build/lib/syntax/ParserInputSourceTest.java
+++ b/src/test/java/com/google/devtools/build/lib/syntax/ParserInputSourceTest.java
@@ -13,6 +13,7 @@
 // limitations under the License.
 package com.google.devtools.build.lib.syntax;
 
+import static com.google.common.truth.Truth.assertThat;
 import static com.google.devtools.build.lib.util.StringUtilities.joinLines;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.fail;
@@ -86,7 +87,7 @@
       fail();
     } catch (IOException e) {
       String expected = "/does/not/exist (No such file or directory)";
-      assertEquals(expected, e.getMessage());
+      assertThat(e).hasMessage(expected);
     }
   }
 
@@ -121,7 +122,7 @@
       ParserInputSource.create(in, path);
       fail();
     } catch (IOException e) {
-      assertEquals("Fault injected.", e.getMessage());
+      assertThat(e).hasMessage("Fault injected.");
     }
     assertEquals("Stream closed.", log.toString());
   }
diff --git a/src/test/java/com/google/devtools/build/lib/syntax/SkylarkListTest.java b/src/test/java/com/google/devtools/build/lib/syntax/SkylarkListTest.java
index aea87b7..a5fd942 100644
--- a/src/test/java/com/google/devtools/build/lib/syntax/SkylarkListTest.java
+++ b/src/test/java/com/google/devtools/build/lib/syntax/SkylarkListTest.java
@@ -153,7 +153,7 @@
       exec(input);
       fail();
     } catch (Exception e) {
-      assertEquals(msg, e.getMessage());
+      assertThat(e).hasMessage(msg);
     }
   }
 }
diff --git a/src/test/java/com/google/devtools/build/lib/syntax/SkylarkNestedSetTest.java b/src/test/java/com/google/devtools/build/lib/syntax/SkylarkNestedSetTest.java
index 48a5672..f54583a 100644
--- a/src/test/java/com/google/devtools/build/lib/syntax/SkylarkNestedSetTest.java
+++ b/src/test/java/com/google/devtools/build/lib/syntax/SkylarkNestedSetTest.java
@@ -13,8 +13,8 @@
 // limitations under the License.
 package com.google.devtools.build.lib.syntax;
 
+import static com.google.common.truth.Truth.assertThat;
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
 import com.google.common.base.Joiner;
@@ -46,7 +46,7 @@
   @Test
   public void testNsetBuilder() throws Exception {
     exec("n = set(order='stable')");
-    assertTrue(env.lookup("n") instanceof SkylarkNestedSet);
+    assertThat(env.lookup("n")).isInstanceOf(SkylarkNestedSet.class);
   }
 
   @Test
@@ -189,7 +189,7 @@
       exec(input);
       fail();
     } catch (Exception e) {
-      assertEquals(msg, e.getMessage());
+      assertThat(e).hasMessage(msg);
     }
   }
 }
diff --git a/src/test/java/com/google/devtools/build/lib/testutil/BlazeTestUtils.java b/src/test/java/com/google/devtools/build/lib/testutil/BlazeTestUtils.java
index 8588a08..ac41beb 100644
--- a/src/test/java/com/google/devtools/build/lib/testutil/BlazeTestUtils.java
+++ b/src/test/java/com/google/devtools/build/lib/testutil/BlazeTestUtils.java
@@ -44,7 +44,7 @@
     Path runfiles = directories.getFileSystem().getPath(BlazeTestUtils.runfilesDir());
     // Copy over everything in embedded_scripts.
     Path embeddedScripts = runfiles.getRelative(TestConstants.EMBEDDED_SCRIPTS_PATH);
-    Collection<Path> files = new ArrayList<Path>();
+    Collection<Path> files = new ArrayList<>();
     if (embeddedScripts.exists()) {
       files.addAll(embeddedScripts.getDirectoryEntries());
     } else {
diff --git a/src/test/java/com/google/devtools/build/lib/testutil/BuildRuleBuilder.java b/src/test/java/com/google/devtools/build/lib/testutil/BuildRuleBuilder.java
index cd8a202..0eaa1bf 100644
--- a/src/test/java/com/google/devtools/build/lib/testutil/BuildRuleBuilder.java
+++ b/src/test/java/com/google/devtools/build/lib/testutil/BuildRuleBuilder.java
@@ -82,8 +82,8 @@
    * Sets the value of a single valued attribute
    */
   public BuildRuleBuilder setSingleValueAttribute(String attrName, Object value) {
-    Preconditions.checkState(!singleValueAttributes.containsKey(attrName),
-        "attribute '" + attrName + "' already set");
+    Preconditions.checkState(
+        !singleValueAttributes.containsKey(attrName), "attribute '%s' already set", attrName);
     singleValueAttributes.put(attrName, value);
     return this;
   }
diff --git a/src/test/java/com/google/devtools/build/lib/testutil/BuildRuleWithDefaultsBuilder.java b/src/test/java/com/google/devtools/build/lib/testutil/BuildRuleWithDefaultsBuilder.java
index 042ebe3..b422772 100644
--- a/src/test/java/com/google/devtools/build/lib/testutil/BuildRuleWithDefaultsBuilder.java
+++ b/src/test/java/com/google/devtools/build/lib/testutil/BuildRuleWithDefaultsBuilder.java
@@ -99,7 +99,7 @@
       } else {
         FileTypeSet fileTypes = attribute.getAllowedFileTypesPredicate();
         // This argument should always hold, if not that means a Blaze design/implementation error
-        Preconditions.checkArgument(fileTypes.getExtensions().size() > 0);
+        Preconditions.checkArgument(!fileTypes.getExtensions().isEmpty());
         extension = fileTypes.getExtensions().get(0);
       }
       label = getDummyFileLabel(rulePkg, filePkg, extension, attrType);
diff --git a/src/test/java/com/google/devtools/build/lib/testutil/MoreAsserts.java b/src/test/java/com/google/devtools/build/lib/testutil/MoreAsserts.java
index 8c01655..3b7a6b1 100644
--- a/src/test/java/com/google/devtools/build/lib/testutil/MoreAsserts.java
+++ b/src/test/java/com/google/devtools/build/lib/testutil/MoreAsserts.java
@@ -21,13 +21,14 @@
 
 import com.google.common.base.Joiner;
 import com.google.common.base.Predicate;
+import com.google.common.base.Predicates;
 import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
 
 import java.lang.ref.Reference;
 import java.lang.reflect.Field;
+import java.util.ArrayDeque;
 import java.util.Comparator;
 import java.util.Map;
 import java.util.Queue;
@@ -147,8 +148,8 @@
       }
     };
     if (isRetained(p, start)) {
-      assert_().fail("Found an instance of " + clazz.getCanonicalName() +
-          " reachable from " + start.toString());
+      assert_().fail(
+          "Found an instance of " + clazz.getCanonicalName() + " reachable from " + start);
     }
   }
 
@@ -157,24 +158,17 @@
   static {
     try {
       NON_STRONG_REF = Reference.class.getDeclaredField("referent");
-    } catch (SecurityException e) {
-      throw new RuntimeException(e);
-    } catch (NoSuchFieldException e) {
+    } catch (SecurityException | NoSuchFieldException e) {
       throw new RuntimeException(e);
     }
   }
 
-  static final Predicate<Field> ALL_STRONG_REFS = new Predicate<Field>() {
-    @Override
-    public boolean apply(Field field) {
-      return NON_STRONG_REF.equals(field);
-    }
-  };
+  static final Predicate<Field> ALL_STRONG_REFS = Predicates.equalTo(NON_STRONG_REF);
 
   private static boolean isRetained(Predicate<Object> predicate, Object start) {
     Map<Object, Object> visited = Maps.newIdentityHashMap();
     visited.put(start, start);
-    Queue<Object> toScan = Lists.newLinkedList();
+    Queue<Object> toScan = new ArrayDeque<>();
     toScan.add(start);
 
     while (!toScan.isEmpty()) {
@@ -214,9 +208,7 @@
                   toScan.add(ref);
                 }
               }
-            } catch (IllegalArgumentException e) {
-              throw new IllegalStateException("Error when scanning the heap", e);
-            } catch (IllegalAccessException e) {
+            } catch (IllegalArgumentException | IllegalAccessException e) {
               throw new IllegalStateException("Error when scanning the heap", e);
             }
           }
@@ -308,7 +300,7 @@
   public static Set<String> asStringSet(Iterable<?> collection) {
     Set<String> set = Sets.newTreeSet();
     for (Object o : collection) {
-      set.add("\"" + String.valueOf(o) + "\"");
+      set.add("\"" + o + "\"");
     }
     return set;
   }
@@ -316,8 +308,7 @@
   public static <T> void
   assertSameContents(Iterable<? extends T> expected, Iterable<? extends T> actual) {
     if (!Sets.newHashSet(expected).equals(Sets.newHashSet(actual))) {
-      fail("got string set: " + asStringSet(actual).toString()
-          + "\nwant: " + asStringSet(expected).toString());
+      fail("got string set: " + asStringSet(actual) + "\nwant: " + asStringSet(expected));
     }
   }
 }
diff --git a/src/test/java/com/google/devtools/build/lib/testutil/TestFileOutErr.java b/src/test/java/com/google/devtools/build/lib/testutil/TestFileOutErr.java
index 6f0494f..ed652ec 100644
--- a/src/test/java/com/google/devtools/build/lib/testutil/TestFileOutErr.java
+++ b/src/test/java/com/google/devtools/build/lib/testutil/TestFileOutErr.java
@@ -102,7 +102,7 @@
   @Override
   public void dumpOutAsLatin1(OutputStream out) {
     try {
-      out.write(recorder.getOutputStream().toByteArray());
+      recorder.getOutputStream().writeTo(out);
     } catch (IOException e) {
       throw new RuntimeException(e);
     }
@@ -111,7 +111,7 @@
   @Override
   public void dumpErrAsLatin1(OutputStream out) {
     try {
-      out.write(recorder.getErrorStream().toByteArray());
+      recorder.getErrorStream().writeTo(out);
     } catch (IOException e) {
       throw new RuntimeException(e);
     }
diff --git a/src/test/java/com/google/devtools/build/lib/testutil/TestSuiteBuilder.java b/src/test/java/com/google/devtools/build/lib/testutil/TestSuiteBuilder.java
index af90c52..82ebbe4 100644
--- a/src/test/java/com/google/devtools/build/lib/testutil/TestSuiteBuilder.java
+++ b/src/test/java/com/google/devtools/build/lib/testutil/TestSuiteBuilder.java
@@ -104,7 +104,7 @@
   }
 
   private static boolean isJunit4Test(Class<?> container) {
-    return container.getAnnotation(RunWith.class) != null;
+    return container.isAnnotationPresent(RunWith.class);
   }
 
   private static boolean isJunit3Test(Class<?> container) {
diff --git a/src/test/java/com/google/devtools/build/lib/testutil/TestThread.java b/src/test/java/com/google/devtools/build/lib/testutil/TestThread.java
index e043025..e1b4972 100644
--- a/src/test/java/com/google/devtools/build/lib/testutil/TestThread.java
+++ b/src/test/java/com/google/devtools/build/lib/testutil/TestThread.java
@@ -36,9 +36,7 @@
     try {
       runTest();
       isSucceeded = true;
-    } catch (Exception e) {
-      testException = e;
-    } catch (AssertionError e) {
+    } catch (Exception | AssertionError e) {
       testException = e;
     }
   }
diff --git a/src/test/java/com/google/devtools/build/lib/unix/FilesystemUtilsTest.java b/src/test/java/com/google/devtools/build/lib/unix/FilesystemUtilsTest.java
index 48a67c1..c2f5929 100644
--- a/src/test/java/com/google/devtools/build/lib/unix/FilesystemUtilsTest.java
+++ b/src/test/java/com/google/devtools/build/lib/unix/FilesystemUtilsTest.java
@@ -13,7 +13,7 @@
 // limitations under the License.
 package com.google.devtools.build.lib.unix;
 
-import static org.junit.Assert.assertEquals;
+import static com.google.common.truth.Truth.assertThat;
 
 import com.google.common.hash.HashCode;
 import com.google.devtools.build.lib.testutil.TestUtils;
@@ -55,7 +55,7 @@
    */
   @Test
   public void testValidateMd5Sum() throws Exception {
-    HashMap<String, String> testVectors = new HashMap<String, String>();
+    HashMap<String, String> testVectors = new HashMap<>();
     testVectors.put("", "d41d8cd98f00b204e9800998ecf8427e");
     testVectors.put("a", "0cc175b9c0f1b6a831c399e269772661");
     testVectors.put("abc", "900150983cd24fb0d6963f7d28e17f72");
@@ -70,7 +70,7 @@
     for (String testInput : testVectors.keySet()) {
       FileSystemUtils.writeContentAsLatin1(testFile, testInput);
       HashCode result = FilesystemUtils.md5sum(testFile.getPathString());
-      assertEquals(result.toString(), testVectors.get(testInput));
+      assertThat(testVectors).containsEntry(testInput, result.toString());
     }
   }
 }
diff --git a/src/test/java/com/google/devtools/build/lib/util/CommandBuilderTest.java b/src/test/java/com/google/devtools/build/lib/util/CommandBuilderTest.java
index 566da25..e104c82 100644
--- a/src/test/java/com/google/devtools/build/lib/util/CommandBuilderTest.java
+++ b/src/test/java/com/google/devtools/build/lib/util/CommandBuilderTest.java
@@ -14,7 +14,6 @@
 package com.google.devtools.build.lib.util;
 
 import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.fail;
 
 import com.google.common.collect.ImmutableList;
@@ -53,7 +52,7 @@
       builder.build();
       fail("Expected exception");
     } catch (Exception e) {
-      assertEquals(expected, e.getMessage());
+      assertThat(e).hasMessage(expected);
     }
   }
 
diff --git a/src/test/java/com/google/devtools/build/lib/util/FileTypeTest.java b/src/test/java/com/google/devtools/build/lib/util/FileTypeTest.java
index 301875c..6d32eaa 100644
--- a/src/test/java/com/google/devtools/build/lib/util/FileTypeTest.java
+++ b/src/test/java/com/google/devtools/build/lib/util/FileTypeTest.java
@@ -106,7 +106,7 @@
     FileTypeSet allowedTypes = FileTypeSet.of(TEXT, HTML);
 
     assertTrue(allowedTypes.matches("readme.txt"));
-    assertTrue(!allowedTypes.matches("style.css"));
+    assertFalse(allowedTypes.matches("style.css"));
   }
 
   private List<HasFilename> getArtifacts() {
diff --git a/src/test/java/com/google/devtools/build/lib/util/GroupedListTest.java b/src/test/java/com/google/devtools/build/lib/util/GroupedListTest.java
index 87cd8c9..7a2eacc 100644
--- a/src/test/java/com/google/devtools/build/lib/util/GroupedListTest.java
+++ b/src/test/java/com/google/devtools/build/lib/util/GroupedListTest.java
@@ -13,7 +13,7 @@
 // limitations under the License.
 package com.google.devtools.build.lib.util;
 
-import static com.google.common.truth.Truth.assert_;
+import static com.google.common.truth.Truth.assertThat;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
@@ -125,8 +125,8 @@
     assertFalse(groupedList.isEmpty());
     Object compressed = groupedList.compress();
     assertElementsEqual(compressed, allElts);
-    assert_().that(GroupedList.create(compressed)).containsExactlyElementsIn(elements).inOrder();
-    assert_().that(groupedList).containsExactlyElementsIn(elements).inOrder();
+    assertThat(GroupedList.create(compressed)).containsExactlyElementsIn(elements).inOrder();
+    assertThat(groupedList).containsExactlyElementsIn(elements).inOrder();
   }
 
   @Test
@@ -157,8 +157,8 @@
     assertElementsEqual(compressed, allElts);
     // Get rid of empty list -- it was not stored in groupedList.
     elements.remove(1);
-    assert_().that(GroupedList.create(compressed)).containsExactlyElementsIn(elements).inOrder();
-    assert_().that(groupedList).containsExactlyElementsIn(elements).inOrder();
+    assertThat(GroupedList.create(compressed)).containsExactlyElementsIn(elements).inOrder();
+    assertThat(groupedList).containsExactlyElementsIn(elements).inOrder();
   }
 
   @Test
@@ -194,8 +194,8 @@
     elements.remove(ImmutableList.of("3"));
     elements.remove(ImmutableList.of());
     elements.remove(ImmutableList.of("removedGroup1", "removedGroup2"));
-    assert_().that(GroupedList.create(compressed)).containsExactlyElementsIn(elements).inOrder();
-    assert_().that(groupedList).containsExactlyElementsIn(elements).inOrder();
+    assertThat(GroupedList.create(compressed)).containsExactlyElementsIn(elements).inOrder();
+    assertThat(groupedList).containsExactlyElementsIn(elements).inOrder();
   }
 
   @Test
@@ -220,8 +220,8 @@
     allElts.removeAll(removed);
     assertElementsEqual(compressed, allElts);
     elements.get(0).removeAll(removed);
-    assert_().that(GroupedList.create(compressed)).containsExactlyElementsIn(elements).inOrder();
-    assert_().that(groupedList).containsExactlyElementsIn(elements).inOrder();
+    assertThat(GroupedList.create(compressed)).containsExactlyElementsIn(elements).inOrder();
+    assertThat(groupedList).containsExactlyElementsIn(elements).inOrder();
   }
 
   private static Object createAndCompress(Collection<String> list) {
@@ -239,8 +239,7 @@
   }
 
   private static void assertElementsEqual(Object compressed, Iterable<String> expected) {
-    assert_()
-        .that(GroupedList.<String>create(compressed).toSet())
+    assertThat(GroupedList.<String>create(compressed).toSet())
         .containsExactlyElementsIn(expected)
         .inOrder();
   }
diff --git a/src/test/java/com/google/devtools/build/lib/util/PairTest.java b/src/test/java/com/google/devtools/build/lib/util/PairTest.java
index f82e12f..7093c76 100644
--- a/src/test/java/com/google/devtools/build/lib/util/PairTest.java
+++ b/src/test/java/com/google/devtools/build/lib/util/PairTest.java
@@ -16,7 +16,6 @@
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
 
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -47,6 +46,6 @@
     assertNull(p.first);
     assertNull(p.second);
     p.hashCode(); // Should not throw.
-    assertTrue(p.equals(p));
+    assertEquals(p, p);
   }
 }
diff --git a/src/test/java/com/google/devtools/build/lib/util/PersistentMapTest.java b/src/test/java/com/google/devtools/build/lib/util/PersistentMapTest.java
index 44aa538..2e246c8 100644
--- a/src/test/java/com/google/devtools/build/lib/util/PersistentMapTest.java
+++ b/src/test/java/com/google/devtools/build/lib/util/PersistentMapTest.java
@@ -13,6 +13,7 @@
 // limitations under the License.
 package com.google.devtools.build.lib.util;
 
+import static com.google.common.truth.Truth.assertThat;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
@@ -97,19 +98,19 @@
     createMap();
     map.put("foo", "bar");
     map.put("baz", "bang");
-    assertEquals("bar", map.get("foo"));
-    assertEquals("bang", map.get("baz"));
-    assertEquals(2, map.size());
+    assertThat(map).containsEntry("foo", "bar");
+    assertThat(map).containsEntry("baz", "bang");
+    assertThat(map).hasSize(2);
     long size = map.save();
     assertEquals(mapFile.getFileSize(), size);
-    assertEquals("bar", map.get("foo"));
-    assertEquals("bang", map.get("baz"));
-    assertEquals(2, map.size());
+    assertThat(map).containsEntry("foo", "bar");
+    assertThat(map).containsEntry("baz", "bang");
+    assertThat(map).hasSize(2);
 
     createMap(); // create a new map
-    assertEquals("bar", map.get("foo"));
-    assertEquals("bang", map.get("baz"));
-    assertEquals(2, map.size());
+    assertThat(map).containsEntry("foo", "bar");
+    assertThat(map).containsEntry("baz", "bang");
+    assertThat(map).hasSize(2);
   }
 
   @Test
@@ -121,10 +122,10 @@
     assertEquals(mapFile.getFileSize(), size);
     assertFalse(journalFile.exists());
     map.remove("foo");
-    assertEquals(1, map.size());
+    assertThat(map).hasSize(1);
     assertTrue(journalFile.exists());
     createMap(); // create a new map
-    assertEquals(1, map.size());
+    assertThat(map).hasSize(1);
   }
 
   @Test
@@ -136,11 +137,11 @@
     assertTrue(mapFile.exists());
     assertFalse(journalFile.exists());
     map.clear();
-    assertEquals(0, map.size());
+    assertThat(map).isEmpty();
     assertTrue(mapFile.exists());
     assertFalse(journalFile.exists());
     createMap(); // create a new map
-    assertEquals(0, map.size());
+    assertThat(map).isEmpty();
   }
 
   @Test
@@ -154,12 +155,12 @@
     map.updateJournal = false;
     // remove an entry
     map.remove("foo");
-    assertEquals(1, map.size());
+    assertThat(map).hasSize(1);
     // no journal file written
     assertFalse(journalFile.exists());
     createMap(); // create a new map
     // both entries are still in the map on disk
-    assertEquals(2, map.size());
+    assertThat(map).hasSize(2);
   }
 
   @Test
@@ -176,26 +177,26 @@
 
     // remove an entry
     map.remove("foo");
-    assertEquals(1, map.size());
+    assertThat(map).hasSize(1);
     // no journal file written
     assertFalse(journalFile.exists());
 
     long size = map.save();
-    assertEquals(1, map.size());
+    assertThat(map).hasSize(1);
     // The journal must be serialzed on save(), even if !updateJournal.
     assertTrue(journalFile.exists());
     assertEquals(journalFile.getFileSize() + mapFile.getFileSize(), size);
 
     map.load();
-    assertEquals(1, map.size());
+    assertThat(map).hasSize(1);
     assertTrue(journalFile.exists());
 
     createMap(); // create a new map
-    assertEquals(1, map.size());
+    assertThat(map).hasSize(1);
 
     map.keepJournal = false;
     map.save();
-    assertEquals(1, map.size());
+    assertThat(map).hasSize(1);
     assertFalse(journalFile.exists());
   }
 
@@ -207,19 +208,19 @@
     assertFalse(journalFile.exists());
     // add an entry
     map.put("baz", "bang");
-    assertEquals(2, map.size());
+    assertThat(map).hasSize(2);
     // journal file written
     assertTrue(journalFile.exists());
     createMap(); // create a new map
     // both entries are still in the map on disk
-    assertEquals(2, map.size());
+    assertThat(map).hasSize(2);
     // add another entry
     map.put("baz2", "bang2");
-    assertEquals(3, map.size());
+    assertThat(map).hasSize(3);
     // journal file written
     assertTrue(journalFile.exists());
     createMap(); // create a new map
     // all three entries are still in the map on disk
-    assertEquals(3, map.size());
+    assertThat(map).hasSize(3);
   }
 }
diff --git a/src/test/java/com/google/devtools/build/lib/util/ResourceFileLoaderTest.java b/src/test/java/com/google/devtools/build/lib/util/ResourceFileLoaderTest.java
index e821ca1..6067101 100644
--- a/src/test/java/com/google/devtools/build/lib/util/ResourceFileLoaderTest.java
+++ b/src/test/java/com/google/devtools/build/lib/util/ResourceFileLoaderTest.java
@@ -13,6 +13,7 @@
 // limitations under the License.
 package com.google.devtools.build.lib.util;
 
+import static com.google.common.truth.Truth.assertThat;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.fail;
 
@@ -42,7 +43,7 @@
           "does_not_exist.txt");
       fail();
     } catch (IOException e) {
-      assertEquals("does_not_exist.txt not found.", e.getMessage());
+      assertThat(e).hasMessage("does_not_exist.txt not found.");
     }
   }
 
diff --git a/src/test/java/com/google/devtools/build/lib/util/StringIndexerTest.java b/src/test/java/com/google/devtools/build/lib/util/StringIndexerTest.java
index 693e11a..b1dee1b 100644
--- a/src/test/java/com/google/devtools/build/lib/util/StringIndexerTest.java
+++ b/src/test/java/com/google/devtools/build/lib/util/StringIndexerTest.java
@@ -78,7 +78,7 @@
   protected void assertContent() {
     for (int i = 0; i < indexer.size(); i++) {
       assertNotNull(mappings.get(i));
-      assertEquals(mappings.get(i), indexer.getStringForIndex(i));
+      assertThat(mappings).containsEntry(i, indexer.getStringForIndex(i));
     }
   }
 
diff --git a/src/test/java/com/google/devtools/build/lib/util/StringUtilTest.java b/src/test/java/com/google/devtools/build/lib/util/StringUtilTest.java
index 96d9a53..3239d73 100644
--- a/src/test/java/com/google/devtools/build/lib/util/StringUtilTest.java
+++ b/src/test/java/com/google/devtools/build/lib/util/StringUtilTest.java
@@ -13,12 +13,14 @@
 // limitations under the License.
 package com.google.devtools.build.lib.util;
 
+import static com.google.common.truth.Truth.assertThat;
 import static com.google.devtools.build.lib.util.StringUtil.capitalize;
 import static com.google.devtools.build.lib.util.StringUtil.indent;
 import static com.google.devtools.build.lib.util.StringUtil.joinEnglishList;
 import static com.google.devtools.build.lib.util.StringUtil.splitAndInternString;
 import static com.google.devtools.build.lib.util.StringUtil.stripSuffix;
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertSame;
 
 import com.google.common.collect.ImmutableList;
@@ -57,13 +59,13 @@
 
   @Test
   public void splitAndIntern() throws Exception {
-    assertEquals(ImmutableList.of(), splitAndInternString("       "));
-    assertEquals(ImmutableList.of(), splitAndInternString(null));
+    assertThat(splitAndInternString("       ")).isEmpty();
+    assertThat(splitAndInternString(null)).isEmpty();
     List<String> list1 = splitAndInternString("    x y    z    z");
     List<String> list2 = splitAndInternString("a z    c z");
 
-    assertEquals(ImmutableList.of("x", "y", "z", "z"), list1);
-    assertEquals(ImmutableList.of("a", "z", "c", "z"), list2);
+    assertThat(list1).containsExactly("x", "y", "z", "z").inOrder();
+    assertThat(list2).containsExactly("a", "z", "c", "z").inOrder();
     assertSame(list1.get(2), list1.get(3));
     assertSame(list1.get(2), list2.get(1));
     assertSame(list2.get(1), list2.get(3));
@@ -81,8 +83,8 @@
 
   @Test
   public void testIndent() throws Exception {
-    assertEquals("", indent("", 0));
-    assertEquals("", indent("", 1));
+    assertThat(indent("", 0)).isEmpty();
+    assertThat(indent("", 1)).isEmpty();
     assertEquals("a", indent("a", 1));
     assertEquals("\n  a", indent("\na", 2));
     assertEquals("a\n  b", indent("a\nb", 2));
@@ -92,16 +94,16 @@
 
   @Test
   public void testStripSuffix() throws Exception {
-    assertEquals("", stripSuffix("", ""));
-    assertEquals(null, stripSuffix("", "a"));
+    assertThat(stripSuffix("", "")).isEmpty();
+    assertNull(stripSuffix("", "a"));
     assertEquals("a", stripSuffix("a", ""));
     assertEquals("a", stripSuffix("aa", "a"));
-    assertEquals(null, stripSuffix("ab", "c"));
+    assertNull(stripSuffix("ab", "c"));
   }
 
   @Test
   public void testCapitalize() throws Exception {
-    assertEquals("", capitalize(""));
+    assertThat(capitalize("")).isEmpty();
     assertEquals("Joe", capitalize("joe"));
     assertEquals("Joe", capitalize("Joe"));
     assertEquals("O", capitalize("o"));
diff --git a/src/test/java/com/google/devtools/build/lib/util/StringUtilitiesTest.java b/src/test/java/com/google/devtools/build/lib/util/StringUtilitiesTest.java
index c8ed641..548d10f 100644
--- a/src/test/java/com/google/devtools/build/lib/util/StringUtilitiesTest.java
+++ b/src/test/java/com/google/devtools/build/lib/util/StringUtilitiesTest.java
@@ -13,6 +13,7 @@
 // limitations under the License.
 package com.google.devtools.build.lib.util;
 
+import static com.google.common.truth.Truth.assertThat;
 import static com.google.devtools.build.lib.util.StringUtilities.combineKeys;
 import static com.google.devtools.build.lib.util.StringUtilities.joinLines;
 import static com.google.devtools.build.lib.util.StringUtilities.layoutTable;
@@ -42,7 +43,7 @@
 
   @Test
   public void emptyLinesYieldsEmptyString() {
-    assertEquals("", joinLines());
+    assertThat(joinLines()).isEmpty();
   }
 
   @Test
@@ -88,11 +89,11 @@
       String combined_key = combineKeys(keys_copy);
       String[] prev_keys = map.put(combined_key, keys_copy);
       if (prev_keys != null) {
-        fail("combineKeys collision:\n" +
-              "key sequence 1: " + Arrays.deepToString(prev_keys) + "\n" +
-              "key sequence 2: " + Arrays.deepToString(keys_copy) + "\n" +
-              "combined key sequence 1: " + combineKeys(prev_keys) + "\n" +
-              "combined key sequence 2: " + combineKeys(keys_copy) + "\n");
+        fail("combineKeys collision:\n"
+            + "key sequence 1: " + Arrays.toString(prev_keys) + "\n"
+            + "key sequence 2: " + Arrays.toString(keys_copy) + "\n"
+            + "combined key sequence 1: " + combineKeys(prev_keys) + "\n"
+            + "combined key sequence 2: " + combineKeys(keys_copy) + "\n");
       }
     } else {
       for (String key : test_keys) {
@@ -119,8 +120,7 @@
   public void replaceAllLiteral() throws Exception {
     assertEquals("ababab",
                  StringUtilities.replaceAllLiteral("bababa", "ba", "ab"));
-    assertEquals("",
-        StringUtilities.replaceAllLiteral("bababa", "ba", ""));
+    assertThat(StringUtilities.replaceAllLiteral("bababa", "ba", "")).isEmpty();
     assertEquals("bababa",
         StringUtilities.replaceAllLiteral("bababa", "", "ab"));
   }
diff --git a/src/test/java/com/google/devtools/build/lib/util/TargetUtilsTest.java b/src/test/java/com/google/devtools/build/lib/util/TargetUtilsTest.java
index 33b0fe3..338f3a7 100644
--- a/src/test/java/com/google/devtools/build/lib/util/TargetUtilsTest.java
+++ b/src/test/java/com/google/devtools/build/lib/util/TargetUtilsTest.java
@@ -13,6 +13,7 @@
 // limitations under the License.
 package com.google.devtools.build.lib.util;
 
+import static com.google.common.truth.Truth.assertThat;
 import static org.junit.Assert.assertEquals;
 
 import com.google.devtools.build.lib.packages.TargetUtils;
@@ -31,6 +32,6 @@
   public void getRuleLanguage() {
     assertEquals("java", TargetUtils.getRuleLanguage("java_binary"));
     assertEquals("foobar", TargetUtils.getRuleLanguage("foobar"));
-    assertEquals("", TargetUtils.getRuleLanguage(""));
+    assertThat(TargetUtils.getRuleLanguage("")).isEmpty();
   }
 }
diff --git a/src/test/java/com/google/devtools/build/lib/util/io/AnsiTerminalPrinterTest.java b/src/test/java/com/google/devtools/build/lib/util/io/AnsiTerminalPrinterTest.java
index d75208f..b9d8dd3 100644
--- a/src/test/java/com/google/devtools/build/lib/util/io/AnsiTerminalPrinterTest.java
+++ b/src/test/java/com/google/devtools/build/lib/util/io/AnsiTerminalPrinterTest.java
@@ -13,10 +13,10 @@
 // limitations under the License.
 package com.google.devtools.build.lib.util.io;
 
+import static com.google.common.truth.Truth.assertThat;
 import static com.google.devtools.build.lib.util.io.AnsiTerminalPrinter.Mode;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
 
 import com.google.devtools.build.lib.testutil.MoreAsserts;
 
@@ -79,9 +79,9 @@
     printer.print(Mode.INFO + "XXX" + Mode.ERROR + "XXX" + Mode.WARNING +"XXX" + Mode.DEFAULT
         + "XXX" + Mode.INFO + "XXX" + Mode.ERROR + "XXX" + Mode.WARNING +"XXX" + Mode.DEFAULT);
     String[] codes = stream.toString().split("XXX");
-    assertEquals(8, codes.length);
+    assertThat(codes).hasLength(8);
     for (int i = 0; i < 4; i++) {
-      assertTrue(codes[i].length() > 0);
+      assertThat(codes[i]).isNotEmpty();
       assertEquals(codes[i], codes[i+4]);
     }
     assertFalse(codes[0].equals(codes[1]));
diff --git a/src/test/java/com/google/devtools/build/lib/util/io/LinePrefixingOutputStreamTest.java b/src/test/java/com/google/devtools/build/lib/util/io/LinePrefixingOutputStreamTest.java
index b060beb..921b669 100644
--- a/src/test/java/com/google/devtools/build/lib/util/io/LinePrefixingOutputStreamTest.java
+++ b/src/test/java/com/google/devtools/build/lib/util/io/LinePrefixingOutputStreamTest.java
@@ -13,6 +13,7 @@
 // limitations under the License.
 package com.google.devtools.build.lib.util.io;
 
+import static com.google.common.truth.Truth.assertThat;
 import static java.nio.charset.StandardCharsets.UTF_8;
 import static org.junit.Assert.assertEquals;
 
@@ -44,7 +45,7 @@
   @Test
   public void testNoOutputUntilNewline() throws IOException {
     prefixOut.write(bytes("We won't be seeing any output."));
-    assertEquals("", string(out.toByteArray()));
+    assertThat(string(out.toByteArray())).isEmpty();
   }
 
   @Test
diff --git a/src/test/java/com/google/devtools/build/lib/util/io/StreamDemultiplexerTest.java b/src/test/java/com/google/devtools/build/lib/util/io/StreamDemultiplexerTest.java
index 59277df5..d19c15f 100644
--- a/src/test/java/com/google/devtools/build/lib/util/io/StreamDemultiplexerTest.java
+++ b/src/test/java/com/google/devtools/build/lib/util/io/StreamDemultiplexerTest.java
@@ -64,12 +64,8 @@
   @Test
   public void testHelloWorldOnStandardOut() throws Exception {
     byte[] multiplexed = lines("@1@", "Hello, world.");
-    StreamDemultiplexer demux = new StreamDemultiplexer((byte) '1', out);
-    try {
+    try (final StreamDemultiplexer demux = new StreamDemultiplexer((byte) '1', out)) {
       demux.write(multiplexed);
-      demux.flush();
-    } finally {
-      demux.close();
     }
     assertEquals("Hello, world.", out.toString("ISO-8859-1"));
   }
@@ -77,12 +73,8 @@
   @Test
   public void testOutErrCtl() throws Exception {
     byte[] multiplexed = lines("@1@", "out", "@2@", "err", "@3@", "ctl", "");
-    StreamDemultiplexer demux = new StreamDemultiplexer((byte) '1', out, err, ctl);
-    try {
+    try (final StreamDemultiplexer demux = new StreamDemultiplexer((byte) '1', out, err, ctl)) {
       demux.write(multiplexed);
-      demux.flush();
-    } finally {
-      demux.close();
     }
     assertEquals("out", toAnsi(out));
     assertEquals("err", toAnsi(err));
@@ -92,12 +84,8 @@
   @Test
   public void testWithoutLineBreaks() throws Exception {
     byte[] multiplexed = lines("@1@", "just ", "@1@", "one ", "@1@", "line", "");
-    StreamDemultiplexer demux = new StreamDemultiplexer((byte) '1', out);
-    try {
+    try (final StreamDemultiplexer demux = new StreamDemultiplexer((byte) '1', out)) {
       demux.write(multiplexed);
-      demux.flush();
-    } finally {
-      demux.close();
     }
     assertEquals("just one line", out.toString("ISO-8859-1"));
   }
@@ -105,13 +93,10 @@
   @Test
   public void testLineBreaks() throws Exception {
     byte[] multiplexed = lines("@1", "two", "@1", "lines", "");
-    StreamDemultiplexer demux = new StreamDemultiplexer((byte) '1', out);
-    try {
+    try (StreamDemultiplexer demux = new StreamDemultiplexer((byte) '1', out)) {
       demux.write(multiplexed);
       demux.flush();
       assertEquals("two\nlines\n", out.toString("ISO-8859-1"));
-    } finally {
-      demux.close();
     }
   }
 
diff --git a/src/test/java/com/google/devtools/build/lib/vfs/FileSystemTest.java b/src/test/java/com/google/devtools/build/lib/vfs/FileSystemTest.java
index b6e88d8..9481b22 100644
--- a/src/test/java/com/google/devtools/build/lib/vfs/FileSystemTest.java
+++ b/src/test/java/com/google/devtools/build/lib/vfs/FileSystemTest.java
@@ -473,7 +473,7 @@
   public void testCreateDirectoryIsOnlyChildInParent() throws Exception {
     Path newPath = xEmptyDirectory.getChild("new-dir");
     newPath.createDirectory();
-    assertEquals(1, newPath.getParentDirectory().getDirectoryEntries().size());
+    assertThat(newPath.getParentDirectory().getDirectoryEntries()).hasSize(1);
     assertThat(newPath.getParentDirectory().getDirectoryEntries()).containsExactly(newPath);
   }
 
@@ -515,7 +515,7 @@
   public void testCreateDirectoriesIsOnlyChildInParent() throws Exception {
     Path newPath = absolutize("new-dir/sub/directory");
     FileSystemUtils.createDirectoryAndParents(newPath);
-    assertEquals(1, newPath.getParentDirectory().getDirectoryEntries().size());
+    assertThat(newPath.getParentDirectory().getDirectoryEntries()).hasSize(1);
     assertThat(newPath.getParentDirectory().getDirectoryEntries()).containsExactly(newPath);
   }
 
@@ -531,7 +531,7 @@
   public void testCreateFileIsOnlyChildInParent() throws Exception {
     Path newPath = xEmptyDirectory.getChild("new-file");
     FileSystemUtils.createEmptyFile(newPath);
-    assertEquals(1, newPath.getParentDirectory().getDirectoryEntries().size());
+    assertThat(newPath.getParentDirectory().getDirectoryEntries()).hasSize(1);
     assertThat(newPath.getParentDirectory().getDirectoryEntries()).containsExactly(newPath);
   }
 
@@ -548,7 +548,7 @@
       xFile.createDirectory();
       fail();
     } catch (IOException e) {
-      assertEquals(xFile + " (File exists)", e.getMessage());
+      assertThat(e).hasMessage(xFile + " (File exists)");
     }
   }
 
@@ -571,7 +571,7 @@
       xChildOfReadonlyDir.createDirectory();
       fail();
     } catch (IOException e) {
-      assertEquals(xChildOfReadonlyDir + " (Permission denied)", e.getMessage());
+      assertThat(e).hasMessage(xChildOfReadonlyDir + " (Permission denied)");
     }
   }
 
@@ -594,7 +594,7 @@
       FileSystemUtils.createEmptyFile(xChildOfReadonlyDir);
       fail();
     } catch (IOException e) {
-      assertEquals(xChildOfReadonlyDir + " (Permission denied)", e.getMessage());
+      assertThat(e).hasMessage(xChildOfReadonlyDir + " (Permission denied)");
     }
   }
 
@@ -649,7 +649,7 @@
       if (ex instanceof FileNotFoundException) {
         fail("The method should throw an object of class IOException.");
       }
-      assertEquals(xFile + " (Not a directory)", ex.getMessage());
+      assertThat(ex).hasMessage(xFile + " (Not a directory)");
     }
   }
 
@@ -660,7 +660,7 @@
       somePath.getDirectoryEntries();
       fail("FileNotFoundException not thrown.");
     } catch (Exception x) {
-      assertEquals(somePath + " (No such file or directory)", x.getMessage());
+      assertThat(x).hasMessage(somePath + " (No such file or directory)");
     }
   }
 
@@ -734,7 +734,7 @@
       xNonEmptyDirectory.delete();
       fail();
     } catch (IOException e) {
-      assertEquals(xNonEmptyDirectory + " (Directory not empty)", e.getMessage());
+      assertThat(e).hasMessage(xNonEmptyDirectory + " (Directory not empty)");
     }
   }
 
@@ -835,7 +835,7 @@
       newPath.getLastModifiedTime();
       fail("FileNotFoundException not thrown!");
     } catch (FileNotFoundException x) {
-      assertEquals(newPath + " (No such file or directory)", x.getMessage());
+      assertThat(x).hasMessage(newPath + " (No such file or directory)");
     }
   }
 
@@ -847,7 +847,7 @@
       newPath.getFileSize();
       fail("FileNotFoundException not thrown.");
     } catch (FileNotFoundException e) {
-      assertEquals(newPath + " (No such file or directory)", e.getMessage());
+      assertThat(e).hasMessage(newPath + " (No such file or directory)");
     }
   }
 
@@ -872,75 +872,75 @@
 
   @Test
   public void testInputAndOutputStreamEOF() throws Exception {
-    OutputStream outStream = xFile.getOutputStream();
-    outStream.write(1);
-    outStream.close();
+    try (OutputStream outStream = xFile.getOutputStream()) {
+      outStream.write(1);
+    }
 
-    InputStream inStream = xFile.getInputStream();
-    inStream.read();
+    try (InputStream inStream = xFile.getInputStream()) {
+      inStream.read();
     assertEquals(-1, inStream.read());
-    inStream.close();
+    }
   }
 
   @Test
   public void testInputAndOutputStream() throws Exception {
-    OutputStream outStream = xFile.getOutputStream();
-    for (int i = 33; i < 126; i++) {
-      outStream.write(i);
+    try (OutputStream outStream = xFile.getOutputStream()) {
+      for (int i = 33; i < 126; i++) {
+        outStream.write(i);
+      }
     }
-    outStream.close();
 
-    InputStream inStream = xFile.getInputStream();
-    for (int i = 33; i < 126; i++) {
-      int readValue = inStream.read();
-      assertEquals(i,readValue);
+    try (InputStream inStream = xFile.getInputStream()) {
+      for (int i = 33; i < 126; i++) {
+        int readValue = inStream.read();
+        assertEquals(i, readValue);
+      }
     }
-    inStream.close();
   }
 
   @Test
   public void testInputAndOutputStreamAppend() throws Exception {
-    OutputStream outStream = xFile.getOutputStream();
-    for (int i = 33; i < 126; i++) {
-      outStream.write(i);
+    try (OutputStream outStream = xFile.getOutputStream()) {
+      for (int i = 33; i < 126; i++) {
+        outStream.write(i);
+      }
     }
-    outStream.close();
 
-    OutputStream appendOut = xFile.getOutputStream(true);
-    for (int i = 126; i < 155; i++) {
-      appendOut.write(i);
+    try (OutputStream appendOut = xFile.getOutputStream(true)) {
+      for (int i = 126; i < 155; i++) {
+        appendOut.write(i);
+      }
     }
-    appendOut.close();
 
-    InputStream inStream = xFile.getInputStream();
-    for (int i = 33; i < 155; i++) {
-      int readValue = inStream.read();
-      assertEquals(i,readValue);
+    try (InputStream inStream = xFile.getInputStream()) {
+      for (int i = 33; i < 155; i++) {
+        int readValue = inStream.read();
+        assertEquals(i, readValue);
+      }
     }
-    inStream.close();
   }
 
   @Test
   public void testInputAndOutputStreamNoAppend() throws Exception {
-    OutputStream outStream = xFile.getOutputStream();
-    outStream.write(1);
-    outStream.close();
+    try (OutputStream outStream = xFile.getOutputStream()) {
+      outStream.write(1);
+    }
 
-    OutputStream noAppendOut = xFile.getOutputStream(false);
-    noAppendOut.close();
+    try (OutputStream noAppendOut = xFile.getOutputStream(false)) {
+    }
 
-    InputStream inStream = xFile.getInputStream();
-    assertEquals(-1, inStream.read());
-    inStream.close();
+    try (InputStream inStream = xFile.getInputStream()) {
+      assertEquals(-1, inStream.read());
+    }
   }
 
   @Test
   public void testGetOutputStreamCreatesFile() throws Exception {
     Path newFile = absolutize("does_not_exist_yet.txt");
 
-    OutputStream out = newFile.getOutputStream();
-    out.write(42);
-    out.close();
+    try (OutputStream out = newFile.getOutputStream()) {
+      out.write(42);
+    }
 
     assertTrue(newFile.isFile());
   }
@@ -951,7 +951,7 @@
       xEmptyDirectory.getOutputStream();
       fail("The Exception was not thrown!");
     } catch (IOException ex) {
-      assertEquals(xEmptyDirectory + " (Is a directory)", ex.getMessage());
+      assertThat(ex).hasMessage(xEmptyDirectory + " (Is a directory)");
     }
   }
 
@@ -961,7 +961,7 @@
       xEmptyDirectory.getInputStream();
       fail("The Exception was not thrown!");
     } catch (IOException ex) {
-      assertEquals(xEmptyDirectory + " (Is a directory)", ex.getMessage());
+      assertThat(ex).hasMessage(xEmptyDirectory + " (Is a directory)");
     }
   }
 
@@ -987,7 +987,7 @@
     xNonEmptyDirectory.renameTo(xEmptyDirectory); // succeeds
     assertFalse(xNonEmptyDirectory.exists());
     assertTrue(xEmptyDirectory.isDirectory());
-    assertFalse(xEmptyDirectory.getDirectoryEntries().isEmpty());
+    assertThat(xEmptyDirectory.getDirectoryEntries()).isNotEmpty();
   }
 
   @Test
@@ -1011,8 +1011,8 @@
 
     assertTrue(xNonEmptyDirectory.isDirectory());
     assertTrue(xEmptyDirectory.isDirectory());
-    assertTrue(xEmptyDirectory.getDirectoryEntries().isEmpty());
-    assertFalse(xNonEmptyDirectory.getDirectoryEntries().isEmpty());
+    assertThat(xEmptyDirectory.getDirectoryEntries()).isEmpty();
+    assertThat(xNonEmptyDirectory.getDirectoryEntries()).isNotEmpty();
   }
 
   @Test
@@ -1021,7 +1021,7 @@
       xEmptyDirectory.renameTo(xFile);
       fail();
     } catch (IOException e) {
-      assertEquals(xEmptyDirectory + " -> " + xFile + " (Not a directory)", e.getMessage());
+      assertThat(e).hasMessage(xEmptyDirectory + " -> " + xFile + " (Not a directory)");
     }
   }
 
@@ -1044,8 +1044,7 @@
       xFile.renameTo(xEmptyDirectory);
       fail();
     } catch (IOException e) {
-      assertEquals(xFile + " -> " + xEmptyDirectory + " (Is a directory)",
-                   e.getMessage());
+      assertThat(e).hasMessage(xFile + " -> " + xEmptyDirectory + " (Is a directory)");
     }
   }
 
@@ -1081,7 +1080,7 @@
       testFS.getPath("not-absolute");
       fail("The expected Exception was not thrown.");
     } catch (IllegalArgumentException ex) {
-      assertEquals("not-absolute (not an absolute path)", ex.getMessage());
+      assertThat(ex).hasMessage("not-absolute (not an absolute path)");
     }
   }
 
@@ -1091,7 +1090,7 @@
       testFS.getPath(new PathFragment("not-absolute"));
       fail("The expected Exception was not thrown.");
     } catch (IllegalArgumentException ex) {
-      assertEquals("not-absolute (not an absolute path)", ex.getMessage());
+      assertThat(ex).hasMessage("not-absolute (not an absolute path)");
     }
   }
 
@@ -1127,7 +1126,7 @@
       xNothing.isExecutable();
       fail("No exception thrown.");
     } catch (FileNotFoundException ex) {
-      assertEquals(xNothing + " (No such file or directory)", ex.getMessage());
+      assertThat(ex).hasMessage(xNothing + " (No such file or directory)");
     }
   }
 
@@ -1137,7 +1136,7 @@
       xNothing.setExecutable(true);
       fail("No exception thrown.");
     } catch (FileNotFoundException ex) {
-      assertEquals(xNothing + " (No such file or directory)", ex.getMessage());
+      assertThat(ex).hasMessage(xNothing + " (No such file or directory)");
     }
   }
 
@@ -1147,7 +1146,7 @@
       xNothing.isWritable();
       fail("No exception thrown.");
     } catch (FileNotFoundException ex) {
-      assertEquals(xNothing + " (No such file or directory)", ex.getMessage());
+      assertThat(ex).hasMessage(xNothing + " (No such file or directory)");
     }
   }
 
@@ -1157,7 +1156,7 @@
       xNothing.setWritable(false);
       fail("No exception thrown.");
     } catch (FileNotFoundException ex) {
-      assertEquals(xNothing + " (No such file or directory)", ex.getMessage());
+      assertThat(ex).hasMessage(xNothing + " (No such file or directory)");
     }
   }
 
@@ -1205,7 +1204,7 @@
       FileSystemUtils.writeContent(xFile, "hello, world!".getBytes());
       fail("No exception thrown.");
     } catch (IOException e) {
-      assertEquals(xFile + " (Permission denied)", e.getMessage());
+      assertThat(e).hasMessage(xFile + " (Permission denied)");
     }
   }
 
@@ -1217,7 +1216,7 @@
       FileSystemUtils.readContent(xFile);
       fail("No exception thrown.");
     } catch (IOException e) {
-      assertEquals(xFile + " (Permission denied)", e.getMessage());
+      assertThat(e).hasMessage(xFile + " (Permission denied)");
     }
   }
 
@@ -1230,7 +1229,7 @@
       FileSystemUtils.createEmptyFile(xNonEmptyDirectoryBar);
       fail("No exception thrown.");
     } catch (IOException e) {
-      assertEquals(xNonEmptyDirectoryBar + " (Permission denied)", e.getMessage());
+      assertThat(e).hasMessage(xNonEmptyDirectoryBar + " (Permission denied)");
     }
   }
 
@@ -1243,7 +1242,7 @@
       xNonEmptyDirectoryBar.createDirectory();
       fail("No exception thrown.");
     } catch (IOException e) {
-      assertEquals(xNonEmptyDirectoryBar + " (Permission denied)", e.getMessage());
+      assertThat(e).hasMessage(xNonEmptyDirectoryBar + " (Permission denied)");
     }
   }
 
@@ -1280,7 +1279,7 @@
       xNonEmptyDirectoryFoo.delete();
       fail("No exception thrown.");
     } catch (IOException e) {
-      assertEquals(xNonEmptyDirectoryFoo + " (Permission denied)", e.getMessage());
+      assertThat(e).hasMessage(xNonEmptyDirectoryFoo + " (Permission denied)");
     }
   }
 
@@ -1294,7 +1293,7 @@
         createSymbolicLink(xNonEmptyDirectoryBar, xNonEmptyDirectoryFoo);
         fail("No exception thrown.");
       } catch (IOException e) {
-        assertEquals(xNonEmptyDirectoryBar + " (Permission denied)", e.getMessage());
+        assertThat(e).hasMessage(xNonEmptyDirectoryBar + " (Permission denied)");
       }
     }
   }
@@ -1348,7 +1347,7 @@
   @Test
   public void testResolveNonSymlinks() throws Exception {
     if (supportsSymlinks) {
-      assertEquals(null, testFS.resolveOneLink(xFile));
+      assertNull(testFS.resolveOneLink(xFile));
       assertEquals(xFile, xFile.resolveSymbolicLinks());
     }
   }
diff --git a/src/test/java/com/google/devtools/build/lib/vfs/FileSystemUtilsTest.java b/src/test/java/com/google/devtools/build/lib/vfs/FileSystemUtilsTest.java
index 21ca39b..11c90c5 100644
--- a/src/test/java/com/google/devtools/build/lib/vfs/FileSystemUtilsTest.java
+++ b/src/test/java/com/google/devtools/build/lib/vfs/FileSystemUtilsTest.java
@@ -131,7 +131,7 @@
     assertTrue(copiedADir.exists());
     assertTrue(copiedADir.isDirectory());
     Collection<Path> aDirEntries = copiedADir.getDirectoryEntries();
-    assertEquals(2, aDirEntries.size());
+    assertThat(aDirEntries).hasSize(2);
 
     Path copiedFile3 = copiedADir.getChild("file-3");
     assertTrue(copiedFile3.exists());
@@ -243,7 +243,7 @@
     assertPath("/foo.baz", FileSystemUtils.replaceExtension(fileSystem.getPath("/foo"), ".baz"));
     assertPath("/foo.baz", FileSystemUtils.replaceExtension(fileSystem.getPath("/foo.cc"), ".baz"));
     assertPath("/.baz", FileSystemUtils.replaceExtension(fileSystem.getPath("/.cc"), ".baz"));
-    assertEquals(null, FileSystemUtils.replaceExtension(fileSystem.getPath("/"), ".baz"));
+    assertNull(FileSystemUtils.replaceExtension(fileSystem.getPath("/"), ".baz"));
   }
 
   @Test
@@ -267,14 +267,14 @@
     assertPath("/foo.baz",
                FileSystemUtils.replaceExtension(new PathFragment("/foo.cc"), ".baz"));
     assertPath(".baz", FileSystemUtils.replaceExtension(new PathFragment(".cc"), ".baz"));
-    assertEquals(null, FileSystemUtils.replaceExtension(new PathFragment("/"), ".baz"));
-    assertEquals(null, FileSystemUtils.replaceExtension(new PathFragment(""), ".baz"));
+    assertNull(FileSystemUtils.replaceExtension(new PathFragment("/"), ".baz"));
+    assertNull(FileSystemUtils.replaceExtension(new PathFragment(""), ".baz"));
     assertPath("foo/bar.baz",
         FileSystemUtils.replaceExtension(new PathFragment("foo/bar.pony"), ".baz", ".pony"));
     assertPath("foo/bar.baz",
         FileSystemUtils.replaceExtension(new PathFragment("foo/bar"), ".baz", ""));
-    assertEquals(null, FileSystemUtils.replaceExtension(new PathFragment(""), ".baz", ".pony"));
-    assertEquals(null,
+    assertNull(FileSystemUtils.replaceExtension(new PathFragment(""), ".baz", ".pony"));
+    assertNull(
         FileSystemUtils.replaceExtension(new PathFragment("foo/bar.pony"), ".baz", ".unicorn"));
   }
 
@@ -294,8 +294,8 @@
         appendWithoutExtension(new PathFragment("libfoo.jar/"), "-src"));
     assertPath("libfoo.src.jar",
         appendWithoutExtension(new PathFragment("libfoo.jar"), ".src"));
-    assertEquals(null, appendWithoutExtension(new PathFragment("/"), "-src"));
-    assertEquals(null, appendWithoutExtension(new PathFragment(""), "-src"));
+    assertNull(appendWithoutExtension(new PathFragment("/"), "-src"));
+    assertNull(appendWithoutExtension(new PathFragment(""), "-src"));
   }
 
   @Test
@@ -357,7 +357,7 @@
     testFile.setLastModifiedTime(42);
     touchFile(testFile);
 
-    assertTrue(testFile.getLastModifiedTime() >= oldTime);
+    assertThat(testFile.getLastModifiedTime()).isAtLeast(oldTime);
   }
 
   @Test
@@ -439,9 +439,8 @@
       copyFile(originalFile, aDir);
       fail();
     } catch (IOException ex) {
-      assertEquals("error copying file: couldn't delete destination: "
-                   + aDir + " (Directory not empty)",
-                   ex.getMessage());
+      assertThat(ex).hasMessage(
+          "error copying file: couldn't delete destination: " + aDir + " (Directory not empty)");
     }
   }
 
@@ -488,7 +487,7 @@
       FileSystemUtils.copyTreesBelow(topDir, aDir);
       fail("Should not be able to copy a directory to a subdir");
     } catch (IllegalArgumentException expected) {
-      assertEquals("/top-dir/a-dir is a subdirectory of /top-dir", expected.getMessage());
+      assertThat(expected).hasMessage("/top-dir/a-dir is a subdirectory of /top-dir");
     }
   }
 
@@ -499,7 +498,7 @@
       FileSystemUtils.copyTreesBelow(file1, aDir);
       fail("Should not be able to copy a file with copyDirectory method");
     } catch (IOException expected) {
-      assertEquals("/top-dir/file-1 (Not a directory)", expected.getMessage());
+      assertThat(expected).hasMessage("/top-dir/file-1 (Not a directory)");
     }
   }
 
@@ -513,7 +512,7 @@
       FileSystemUtils.copyTreesBelow(copyDir, file4);
       fail("Should not be able to copy a directory to a file");
     } catch (IOException expected) {
-      assertEquals("/file-4 (Not a directory)", expected.getMessage());
+      assertThat(expected).hasMessage("/file-4 (Not a directory)");
     }
   }
 
@@ -526,7 +525,7 @@
       FileSystemUtils.copyTreesBelow(unexistingDir, aDir);
       fail("Should not be able to copy from an unexisting path");
     } catch (FileNotFoundException expected) {
-      assertEquals("/unexisting-dir (No such file or directory)", expected.getMessage());
+      assertThat(expected).hasMessage("/unexisting-dir (No such file or directory)");
     }
   }
 
@@ -661,7 +660,7 @@
       createDirectoryAndParents(theHierarchy);
       fail();
     } catch (IOException e) {
-      assertEquals("/somewhere/deep/in (Not a directory)", e.getMessage());
+      assertThat(e).hasMessage("/somewhere/deep/in (Not a directory)");
     }
   }
 
@@ -873,6 +872,6 @@
     clock.advanceMillis(1000);
     FileSystemUtils.ensureSymbolicLink(file, target);
     long timestamp = file.getLastModifiedTime(Symlinks.NOFOLLOW);
-    assertTrue(timestamp == prevTimeMillis);
+    assertEquals(prevTimeMillis, timestamp);
   }
 }
diff --git a/src/test/java/com/google/devtools/build/lib/vfs/GlobTest.java b/src/test/java/com/google/devtools/build/lib/vfs/GlobTest.java
index 37b7dc4..a751e1b 100644
--- a/src/test/java/com/google/devtools/build/lib/vfs/GlobTest.java
+++ b/src/test/java/com/google/devtools/build/lib/vfs/GlobTest.java
@@ -14,7 +14,6 @@
 package com.google.devtools.build.lib.vfs;
 
 import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
@@ -138,7 +137,7 @@
     Collection<Path> globResult = UnixGlob.forPath(fs.getPath("/does/not/exist"))
         .addPattern("*.txt")
         .globInterruptible();
-    assertEquals(0, globResult.size());
+    assertThat(globResult).isEmpty();
   }
 
   @Test
diff --git a/src/test/java/com/google/devtools/build/lib/vfs/PathFragmentTest.java b/src/test/java/com/google/devtools/build/lib/vfs/PathFragmentTest.java
index 9ab9bfa..53dd7a2 100644
--- a/src/test/java/com/google/devtools/build/lib/vfs/PathFragmentTest.java
+++ b/src/test/java/com/google/devtools/build/lib/vfs/PathFragmentTest.java
@@ -13,6 +13,7 @@
 // limitations under the License.
 package com.google.devtools.build.lib.vfs;
 
+import static com.google.common.truth.Truth.assertThat;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNull;
@@ -260,8 +261,8 @@
     assertEquals("foo", new PathFragment("/foo/").getBaseName());
     assertEquals("foo", new PathFragment("foo").getBaseName());
     assertEquals("foo", new PathFragment("/foo").getBaseName());
-    assertEquals("", new PathFragment("/").getBaseName());
-    assertEquals("", new PathFragment("").getBaseName());
+    assertThat(new PathFragment("/").getBaseName()).isEmpty();
+    assertThat(new PathFragment("").getBaseName()).isEmpty();
   }
 
   private static void assertPath(String expected, PathFragment actual) {
@@ -277,10 +278,10 @@
     assertPath("/baz", new PathFragment("/foo/").replaceName("baz"));
     assertPath("baz", new PathFragment("foo").replaceName("baz"));
     assertPath("/baz", new PathFragment("/foo").replaceName("baz"));
-    assertEquals(null, new PathFragment("/").replaceName("baz"));
-    assertEquals(null, new PathFragment("/").replaceName(""));
-    assertEquals(null, new PathFragment("").replaceName("baz"));
-    assertEquals(null, new PathFragment("").replaceName(""));
+    assertNull(new PathFragment("/").replaceName("baz"));
+    assertNull(new PathFragment("/").replaceName(""));
+    assertNull(new PathFragment("").replaceName("baz"));
+    assertNull(new PathFragment("").replaceName(""));
 
     assertPath("foo/bar/baz", new PathFragment("foo/bar").replaceName("bar/baz"));
     assertPath("foo/bar/baz", new PathFragment("foo/bar").replaceName("bar/baz/"));
diff --git a/src/test/java/com/google/devtools/build/lib/vfs/PathFragmentWindowsTest.java b/src/test/java/com/google/devtools/build/lib/vfs/PathFragmentWindowsTest.java
index 43c94d4..1e8ceaf 100644
--- a/src/test/java/com/google/devtools/build/lib/vfs/PathFragmentWindowsTest.java
+++ b/src/test/java/com/google/devtools/build/lib/vfs/PathFragmentWindowsTest.java
@@ -13,6 +13,7 @@
 // limitations under the License.
 package com.google.devtools.build.lib.vfs;
 
+import static com.google.common.truth.Truth.assertThat;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNull;
@@ -167,7 +168,7 @@
     assertEquals("bar", new PathFragment("C:/foo/bar").getBaseName());
     assertEquals("foo", new PathFragment("C:/foo").getBaseName());
     // Never return the drive name as a basename.
-    assertEquals("", new PathFragment("C:/").getBaseName());
+    assertThat(new PathFragment("C:/").getBaseName()).isEmpty();
   }
 
   private static void assertPath(String expected, PathFragment actual) {
@@ -177,7 +178,7 @@
   @Test
   public void testReplaceNameWindows() throws Exception {
     assertPath("C:/foo/baz", new PathFragment("C:/foo/bar").replaceName("baz"));
-    assertEquals(null, new PathFragment("C:/").replaceName("baz"));
+    assertNull(new PathFragment("C:/").replaceName("baz"));
   }
 
   @Test
diff --git a/src/test/java/com/google/devtools/build/lib/vfs/RecursiveGlobTest.java b/src/test/java/com/google/devtools/build/lib/vfs/RecursiveGlobTest.java
index 5e0012a..19b2210 100644
--- a/src/test/java/com/google/devtools/build/lib/vfs/RecursiveGlobTest.java
+++ b/src/test/java/com/google/devtools/build/lib/vfs/RecursiveGlobTest.java
@@ -15,7 +15,6 @@
 
 import static com.google.common.truth.Truth.assertThat;
 import static com.google.devtools.build.lib.testutil.MoreAsserts.assertSameContents;
-import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.fail;
 
 import com.google.common.collect.ImmutableList;
@@ -117,7 +116,7 @@
     Collection<Path> globResult = UnixGlob.forPath(fileSystem.getPath("/does/not/exist"))
         .addPattern("**")
         .globInterruptible();
-    assertEquals(0, globResult.size());
+    assertThat(globResult).isEmpty();
   }
 
   @Test
diff --git a/src/test/java/com/google/devtools/build/lib/vfs/ScopeEscapableFileSystemTest.java b/src/test/java/com/google/devtools/build/lib/vfs/ScopeEscapableFileSystemTest.java
index 6c8071f..d959fc1 100644
--- a/src/test/java/com/google/devtools/build/lib/vfs/ScopeEscapableFileSystemTest.java
+++ b/src/test/java/com/google/devtools/build/lib/vfs/ScopeEscapableFileSystemTest.java
@@ -13,6 +13,7 @@
 // limitations under the License.
 package com.google.devtools.build.lib.vfs;
 
+import static com.google.common.truth.Truth.assertThat;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotSame;
@@ -124,8 +125,8 @@
   public void setUp() throws Exception {
     super.setUp();
 
-    Preconditions.checkState(testFS instanceof ScopeEscapableFileSystem,
-        "Not ScopeEscapable: " + testFS);
+    Preconditions.checkState(
+        testFS instanceof ScopeEscapableFileSystem, "Not ScopeEscapable: %s", testFS);
     ((ScopeEscapableFileSystem) testFS).enableScopeChecking(false);
     for (int i = 1; i <= SCOPE_ROOT.segmentCount(); i++) {
       testFS.getPath(SCOPE_ROOT.subFragment(0, i)).createDirectory();
@@ -154,7 +155,7 @@
 
   // Checks that the semi-resolved path passed to the delegator matches the expected value.
   private void checkPath(TestDelegator delegator, PathFragment expectedDelegatedPath) {
-    assertTrue(expectedDelegatedPath.equals(delegator.lastPath()));
+    assertEquals(delegator.lastPath(), expectedDelegatedPath);
   }
 
   // Asserts that the condition is false and checks that the expected path was delegated.
@@ -300,7 +301,7 @@
     // We shouldn't follow final-segment links, so they should never invoke the delegator.
     delegator.setState(false);
     assertTrue(fileLink.isSymbolicLink());
-    assertTrue(delegator.lastPath() == null);
+    assertNull(delegator.lastPath());
 
     assertFalseWithPathCheck(dirLink.getRelative("a").isSymbolicLink(), delegator,
         dirLinkTarget.getRelative("a"));
@@ -379,7 +380,7 @@
 
     delegator.setState(false);
     assertTrue(fileLink.delete());
-    assertTrue(delegator.lastPath() == null);  // Deleting a link shouldn't require delegation.
+    assertNull(delegator.lastPath()); // Deleting a link shouldn't require delegation.
     assertFalseWithPathCheck(dirLink.getRelative("a").delete(), delegator,
         dirLinkTarget.getRelative("a"));
 
@@ -560,8 +561,8 @@
     // Renaming a link should work fine.
     delegator.setState(null);
     fileLink.renameTo(testFS.getPath(SCOPE_ROOT).getRelative("newname"));
-    assertEquals(null, delegator.lastPath());  // Renaming a link shouldn't require delegation.
-    assertEquals(null, delegator.objectState());
+    assertNull(delegator.lastPath()); // Renaming a link shouldn't require delegation.
+    assertNull(delegator.objectState());
 
     // Renaming an out-of-scope path to an in-scope path should fail due to filesystem mismatch
     // errors.
@@ -611,7 +612,7 @@
     // Since we're not following the link, this shouldn't invoke delegation.
     delegator.setState(new PathFragment("whatever"));
     PathFragment p = fileLink.readSymbolicLink();
-    assertEquals(null, delegator.lastPath());
+    assertNull(delegator.lastPath());
     assertNotSame(delegator.objectState(), p);
 
     // This should.
@@ -677,7 +678,7 @@
     delegator.setState(testFS.getPath("/anything"));
     Collection<Path> entries = dirLink.getDirectoryEntries();
     assertEquals(dirLinkTarget, delegator.lastPath());
-    assertEquals(1, entries.size());
+    assertThat(entries).hasSize(1);
     assertSame(delegator.objectState(), entries.iterator().next());
   }
 
diff --git a/src/test/java/com/google/devtools/build/lib/vfs/SymlinkAwareFileSystemTest.java b/src/test/java/com/google/devtools/build/lib/vfs/SymlinkAwareFileSystemTest.java
index a728c88..e48a5dd 100644
--- a/src/test/java/com/google/devtools/build/lib/vfs/SymlinkAwareFileSystemTest.java
+++ b/src/test/java/com/google/devtools/build/lib/vfs/SymlinkAwareFileSystemTest.java
@@ -92,8 +92,7 @@
       assertEquals(newPath.toString().length(), linkPath.getFileSize(Symlinks.NOFOLLOW));
       assertEquals(newPath.getFileSize(Symlinks.NOFOLLOW), linkPath.getFileSize());
     }
-    assertEquals(2,
-                 linkPath.getParentDirectory().getDirectoryEntries().size());
+    assertThat(linkPath.getParentDirectory().getDirectoryEntries()).hasSize(2);
     assertThat(linkPath.getParentDirectory().getDirectoryEntries()).containsExactly(newPath,
         linkPath);
   }
@@ -110,8 +109,7 @@
     assertTrue(linkPath.isSymbolicLink());
     assertFalse(linkPath.isFile());
     assertTrue(linkPath.isDirectory());
-    assertEquals(2,
-                 linkPath.getParentDirectory().getDirectoryEntries().size());
+    assertThat(linkPath.getParentDirectory().getDirectoryEntries()).hasSize(2);
     assertThat(linkPath.getParentDirectory().
       getDirectoryEntries()).containsExactly(newPath, linkPath);
   }
@@ -168,7 +166,7 @@
       xDanglingLink.createDirectory();
       fail();
     } catch (IOException e) {
-      assertEquals(xDanglingLink + " (File exists)", e.getMessage());
+      assertThat(e).hasMessage(xDanglingLink + " (File exists)");
     }
     assertTrue(xDanglingLink.isSymbolicLink()); // still a symbolic link
     assertFalse(xDanglingLink.isDirectory(Symlinks.FOLLOW)); // link still dangles
@@ -180,7 +178,7 @@
       xLinkToDirectory.createDirectory();
       fail();
     } catch (IOException e) {
-      assertEquals(xLinkToDirectory + " (File exists)", e.getMessage());
+      assertThat(e).hasMessage(xLinkToDirectory + " (File exists)");
     }
     assertTrue(xLinkToDirectory.isSymbolicLink()); // still a symbolic link
     assertTrue(xLinkToDirectory.isDirectory(Symlinks.FOLLOW)); // link still points to dir
@@ -262,8 +260,7 @@
         link.resolveSymbolicLinks();
         fail();
       } catch (IOException e) {
-        assertEquals(link + " (Too many levels of symbolic links)",
-                     e.getMessage());
+        assertThat(e).hasMessage(link + " (Too many levels of symbolic links)");
       }
     }
   }
@@ -280,7 +277,7 @@
         link1.resolveSymbolicLinks();
         fail();
       } catch (IOException e) {
-        assertEquals(link1 + " (Too many levels of symbolic links)", e.getMessage());
+        assertThat(e).hasMessage(link1 + " (Too many levels of symbolic links)");
       }
     }
   }
@@ -292,7 +289,7 @@
         xDanglingLink.resolveSymbolicLinks();
         fail();
       } catch (IOException e) {
-        assertEquals(xNothing + " (No such file or directory)", e.getMessage());
+        assertThat(e).hasMessage(xNothing + " (No such file or directory)");
       }
     }
   }
@@ -349,14 +346,14 @@
       xFile.readSymbolicLink(); // not a link
       fail();
     } catch (NotASymlinkException e) {
-      assertEquals(xFile.toString(), e.getMessage());
+      assertThat(e).hasMessage(xFile.toString());
     }
 
     try {
       xNothing.readSymbolicLink(); // nothing there
       fail();
     } catch (IOException e) {
-      assertEquals(xNothing + " (No such file or directory)", e.getMessage());
+      assertThat(e).hasMessage(xNothing + " (No such file or directory)");
     }
   }
 
@@ -370,7 +367,7 @@
         xChildOfReadonlyDir.createSymbolicLink(xNothing);
         fail();
       } catch (IOException e) {
-        assertEquals(xChildOfReadonlyDir + " (Permission denied)", e.getMessage());
+        assertThat(e).hasMessage(xChildOfReadonlyDir + " (Permission denied)");
       }
     }
   }
@@ -391,8 +388,7 @@
       try {
         someLink.resolveSymbolicLinks();
       } catch (FileNotFoundException e) {
-        assertEquals(newPath.getParentDirectory()
-                     + " (No such file or directory)", e.getMessage());
+        assertThat(e).hasMessage(newPath.getParentDirectory() + " (No such file or directory)");
       }
     }
   }
@@ -422,7 +418,7 @@
       createSymbolicLink(xEmptyDirectory, xFile);
       fail();
     } catch (IOException e) { // => couldn't be created
-      assertEquals(xEmptyDirectory + " (File exists)", e.getMessage());
+      assertThat(e).hasMessage(xEmptyDirectory + " (File exists)");
     }
     assertTrue(xEmptyDirectory.isDirectory(Symlinks.NOFOLLOW));
   }
@@ -433,7 +429,7 @@
       createSymbolicLink(xFile, xEmptyDirectory);
       fail();
     } catch (IOException e) { // => couldn't be created
-      assertEquals(xFile + " (File exists)", e.getMessage());
+      assertThat(e).hasMessage(xFile + " (File exists)");
     }
     assertTrue(xFile.isFile(Symlinks.NOFOLLOW));
   }
@@ -444,7 +440,7 @@
       createSymbolicLink(xDanglingLink, xFile);
       fail();
     } catch (IOException e) {
-      assertEquals(xDanglingLink + " (File exists)", e.getMessage());
+      assertThat(e).hasMessage(xDanglingLink + " (File exists)");
     }
     assertTrue(xDanglingLink.isSymbolicLink()); // still a symbolic link
     assertFalse(xDanglingLink.isDirectory()); // link still dangles
@@ -456,7 +452,7 @@
       createSymbolicLink(xLinkToDirectory, xNothing);
       fail();
     } catch (IOException e) {
-      assertEquals(xLinkToDirectory + " (File exists)", e.getMessage());
+      assertThat(e).hasMessage(xLinkToDirectory + " (File exists)");
     }
     assertTrue(xLinkToDirectory.isSymbolicLink()); // still a symbolic link
     assertTrue(xLinkToDirectory.isDirectory()); // link still points to dir
diff --git a/src/test/java/com/google/devtools/build/lib/vfs/UnixPathEqualityTest.java b/src/test/java/com/google/devtools/build/lib/vfs/UnixPathEqualityTest.java
index f5f58e2..a613dc9 100644
--- a/src/test/java/com/google/devtools/build/lib/vfs/UnixPathEqualityTest.java
+++ b/src/test/java/com/google/devtools/build/lib/vfs/UnixPathEqualityTest.java
@@ -19,6 +19,8 @@
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
+import com.google.common.testing.EqualsTester;
+
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -42,9 +44,8 @@
   }
 
   private void assertTwoWayEquals(Object obj1, Object obj2) {
-    assertTrue(obj1.equals(obj2));
-    assertTrue(obj2.equals(obj1));
-    assertEquals(obj1.hashCode(), obj2.hashCode());
+    assertEquals(obj2, obj1);
+    new EqualsTester().addEqualityGroup(obj1, obj2).testEquals();
   }
 
   private void assertTwoWayNotEquals(Object obj1, Object obj2) {
diff --git a/src/test/java/com/google/devtools/build/lib/vfs/UnixPathGetParentTest.java b/src/test/java/com/google/devtools/build/lib/vfs/UnixPathGetParentTest.java
index 0f679c3..dccc6e6 100644
--- a/src/test/java/com/google/devtools/build/lib/vfs/UnixPathGetParentTest.java
+++ b/src/test/java/com/google/devtools/build/lib/vfs/UnixPathGetParentTest.java
@@ -14,6 +14,7 @@
 package com.google.devtools.build.lib.vfs;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
 
 import com.google.devtools.build.lib.testutil.TestUtils;
 import com.google.devtools.build.lib.vfs.util.FileSystems;
@@ -53,7 +54,7 @@
 
   @Test
   public void testAbsoluteRootHasNoParent() {
-    assertEquals(null, getParent("/"));
+    assertNull(getParent("/"));
   }
 
   @Test
diff --git a/src/test/java/com/google/devtools/build/lib/vfs/UnixPathTest.java b/src/test/java/com/google/devtools/build/lib/vfs/UnixPathTest.java
index b593367..9e4bce3 100644
--- a/src/test/java/com/google/devtools/build/lib/vfs/UnixPathTest.java
+++ b/src/test/java/com/google/devtools/build/lib/vfs/UnixPathTest.java
@@ -21,6 +21,7 @@
 import static org.junit.Assert.fail;
 
 import com.google.common.collect.Lists;
+import com.google.common.testing.EqualsTester;
 import com.google.devtools.build.lib.testutil.TestUtils;
 import com.google.devtools.build.lib.vfs.util.FileSystems;
 
@@ -156,7 +157,7 @@
     Collection<Path> textFiles = UnixGlob.forPath(unixFs.getPath(tmpDir.getPath()))
         .addPattern("*/*.txt")
         .globInterruptible();
-    assertEquals(1, textFiles.size());
+    assertThat(textFiles).hasSize(1);
     Path onlyFile = textFiles.iterator().next();
     assertEquals(unixFs.getPath(anotherFile.getPath()), onlyFile);
 
@@ -189,8 +190,7 @@
     Path differentPath = unixFs.getPath("/foo/bar/baz");
     Object differentType = new Object();
 
-    assertEquals(path.hashCode(), equalPath.hashCode());
-    assertEquals(path, equalPath);
+    new EqualsTester().addEqualityGroup(path, equalPath).testEquals();
     assertFalse(path.equals(differentPath));
     assertFalse(path.equals(differentType));
   }
diff --git a/src/test/java/com/google/devtools/build/lib/vfs/ZipFileSystemTest.java b/src/test/java/com/google/devtools/build/lib/vfs/ZipFileSystemTest.java
index 9dc1276..3e15524 100644
--- a/src/test/java/com/google/devtools/build/lib/vfs/ZipFileSystemTest.java
+++ b/src/test/java/com/google/devtools/build/lib/vfs/ZipFileSystemTest.java
@@ -13,6 +13,7 @@
 // limitations under the License.
 package com.google.devtools.build.lib.vfs;
 
+import static com.google.common.truth.Truth.assertThat;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
@@ -175,7 +176,7 @@
       throws Exception {
     InputStream is = fs.getPath(name).getInputStream();
     List<String> lines = CharStreams.readLines(new InputStreamReader(is, "ISO-8859-1"));
-    assertEquals(expectedSize, lines.size());
+    assertThat(lines).hasSize(expectedSize);
     for (int i = 0; i < expectedSize; i++) {
       assertEquals("body", lines.get(i));
     }
diff --git a/src/test/java/com/google/devtools/build/lib/vfs/inmemoryfs/InMemoryFileSystemTest.java b/src/test/java/com/google/devtools/build/lib/vfs/inmemoryfs/InMemoryFileSystemTest.java
index 65ea6f6..c4b5ccc 100644
--- a/src/test/java/com/google/devtools/build/lib/vfs/inmemoryfs/InMemoryFileSystemTest.java
+++ b/src/test/java/com/google/devtools/build/lib/vfs/inmemoryfs/InMemoryFileSystemTest.java
@@ -13,8 +13,10 @@
 // limitations under the License.
 package com.google.devtools.build.lib.vfs.inmemoryfs;
 
+import static com.google.common.truth.Truth.assertThat;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
 import com.google.common.collect.Lists;
@@ -162,7 +164,7 @@
           BufferedReader reader = new BufferedReader(
               new InputStreamReader(file.getInputStream(), Charset.defaultCharset()));
           assertEquals(TEST_FILE_DATA, reader.readLine());
-          assertEquals(null, reader.readLine());
+          assertNull(reader.readLine());
 
           Path symlink = base.getRelative("symlink" + i);
           assertTrue(symlink.exists());
@@ -246,7 +248,7 @@
             BufferedReader reader = new BufferedReader(
                 new InputStreamReader(file.getInputStream(), Charset.defaultCharset()));
             assertEquals(TEST_FILE_DATA, reader.readLine());
-            assertEquals(null, reader.readLine());
+            assertNull(reader.readLine());
           }
 
           Path symlink = base.getRelative("symlink_" + threadId + "_" + i);
@@ -397,7 +399,7 @@
     try {
       a.stat();
     } catch (IOException e) {
-      assertEquals("/a (Too many levels of symbolic links)", e.getMessage());
+      assertThat(e).hasMessage("/a (Too many levels of symbolic links)");
     }
   }
 
@@ -408,7 +410,7 @@
     try {
       a.stat();
     } catch (IOException e) {
-      assertEquals("/a (Too many levels of symbolic links)", e.getMessage());
+      assertThat(e).hasMessage("/a (Too many levels of symbolic links)");
     }
   }
 }