Migrated remaining tests in devtools/build/lib to JUnit 4.

--
MOS_MIGRATED_REVID=109287267
diff --git a/src/test/java/com/google/devtools/build/lib/actions/BaseSpawnTest.java b/src/test/java/com/google/devtools/build/lib/actions/BaseSpawnTest.java
index 875c449..72fc7e9 100644
--- a/src/test/java/com/google/devtools/build/lib/actions/BaseSpawnTest.java
+++ b/src/test/java/com/google/devtools/build/lib/actions/BaseSpawnTest.java
@@ -38,7 +38,7 @@
   private Root rootDir;
 
   @Before
-  public void setup() throws IOException {
+  public final void setup() throws IOException {
     Scratch scratch = new Scratch();
     rootDir = Root.asDerivedRoot(scratch.dir("/fake/root/dont/matter"));
   }
diff --git a/src/test/java/com/google/devtools/build/lib/bazel/repository/StripPrefixedPathTest.java b/src/test/java/com/google/devtools/build/lib/bazel/repository/StripPrefixedPathTest.java
index 0735a05..2998460 100644
--- a/src/test/java/com/google/devtools/build/lib/bazel/repository/StripPrefixedPathTest.java
+++ b/src/test/java/com/google/devtools/build/lib/bazel/repository/StripPrefixedPathTest.java
@@ -14,14 +14,23 @@
 
 package com.google.devtools.build.lib.bazel.repository;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
 import com.google.common.base.Optional;
 import com.google.devtools.build.lib.vfs.PathFragment;
-import junit.framework.TestCase;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
 
 /**
  * Tests {@link StripPrefixedPath}.
  */
-public class StripPrefixedPathTest extends TestCase {
+@RunWith(JUnit4.class)
+public class StripPrefixedPathTest {
+  @Test
   public void testStrip() {
     StripPrefixedPath result = StripPrefixedPath.maybeDeprefix("foo/bar", Optional.of("foo"));
     assertEquals(result.getPathFragment(), new PathFragment("bar"));
diff --git a/src/test/java/com/google/devtools/build/lib/graph/DigraphTest.java b/src/test/java/com/google/devtools/build/lib/graph/DigraphTest.java
index aaf9d4c..1e8c604 100644
--- a/src/test/java/com/google/devtools/build/lib/graph/DigraphTest.java
+++ b/src/test/java/com/google/devtools/build/lib/graph/DigraphTest.java
@@ -28,7 +28,9 @@
 import com.google.devtools.build.lib.packages.RuleVisibility;
 import com.google.devtools.build.lib.packages.Target;
 
-import junit.framework.TestCase;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
 
 import java.util.Comparator;
 import java.util.List;
@@ -37,7 +39,8 @@
 /**
  * Test for {@link Digraph}.
  */
-public class DigraphTest extends TestCase {
+@RunWith(JUnit4.class)
+public class DigraphTest {
 
   class FakeTarget implements Target {
 
@@ -98,6 +101,7 @@
     }
   }
 
+  @Test
   public void testStableOrdering() throws Exception {
     Digraph<Target> digraph = new Digraph<>();
     FakeTarget a = new FakeTarget(Label.create("pkg", "a"));
diff --git a/src/test/java/com/google/devtools/build/lib/sandbox/LinuxSandboxedStrategyTestCase.java b/src/test/java/com/google/devtools/build/lib/sandbox/LinuxSandboxedStrategyTestCase.java
index b2f5c55..8f7b9a7 100644
--- a/src/test/java/com/google/devtools/build/lib/sandbox/LinuxSandboxedStrategyTestCase.java
+++ b/src/test/java/com/google/devtools/build/lib/sandbox/LinuxSandboxedStrategyTestCase.java
@@ -66,7 +66,7 @@
   }
 
   @Before
-  public void setUp() throws Exception {
+  public final void createDirectoriesAndExecutor() throws Exception  {
     Path testRoot = createTestRoot();
 
     workspaceDir = testRoot.getRelative("workspace");
diff --git a/src/test/java/com/google/devtools/build/lib/standalone/StandaloneSpawnStrategyTest.java b/src/test/java/com/google/devtools/build/lib/standalone/StandaloneSpawnStrategyTest.java
index 715b792..6e4bfd2 100644
--- a/src/test/java/com/google/devtools/build/lib/standalone/StandaloneSpawnStrategyTest.java
+++ b/src/test/java/com/google/devtools/build/lib/standalone/StandaloneSpawnStrategyTest.java
@@ -14,6 +14,9 @@
 package com.google.devtools.build.lib.standalone;
 
 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.collect.ImmutableList;
 import com.google.common.collect.ImmutableMap;
@@ -46,7 +49,10 @@
 import com.google.devtools.build.lib.vfs.util.FileSystems;
 import com.google.devtools.common.options.OptionsParser;
 
-import junit.framework.TestCase;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
 
 import java.io.IOException;
 import java.util.Arrays;
@@ -54,7 +60,8 @@
 /**
  * Test StandaloneSpawnStrategy.
  */
-public class StandaloneSpawnStrategyTest extends TestCase {
+@RunWith(JUnit4.class)
+public class StandaloneSpawnStrategyTest {
 
   private Reporter reporter = new Reporter(PrintingEventHandler.ERRORS_AND_WARNINGS_TO_STDERR);
   private BlazeExecutor executor;
@@ -72,9 +79,8 @@
     return testRoot;
   }
 
-  @Override
-  protected void setUp() throws Exception {
-    super.setUp();
+  @Before
+  public final void setUp() throws Exception {
     Path testRoot = createTestRoot();
     Path workspaceDir = testRoot.getRelative(TestConstants.WORKSPACE_NAME);
     workspaceDir.createDirectory();
@@ -120,6 +126,7 @@
     return outErr.errAsLatin1();
   }
 
+  @Test
   public void testBinTrueExecutesFine() throws Exception {
     Spawn spawn = createSpawn(getTrueCommand());
     executor.getSpawnActionContext(spawn.getMnemonic()).exec(spawn, createContext());
@@ -141,6 +148,7 @@
         null);
   }
 
+  @Test
   public void testBinFalseYieldsException() throws Exception {
     try {
       run(createSpawn(getFalseCommand()));
@@ -159,7 +167,7 @@
     return OS.getCurrent() == OS.DARWIN ? "/usr/bin/true" : "/bin/true";
   }
 
-
+  @Test
   public void testBinEchoPrintsArguments() throws Exception {
     Spawn spawn = createSpawn("/bin/echo", "Hello,", "world.");
     run(spawn);
@@ -167,12 +175,14 @@
     assertThat(err()).isEmpty();
   }
 
+  @Test
   public void testCommandRunsInWorkingDir() throws Exception {
     Spawn spawn = createSpawn("/bin/pwd");
     run(spawn);
     assertEquals(executor.getExecRoot() + "\n", out());
   }
 
+  @Test
   public void testCommandHonorsEnvironment() throws Exception {
     Spawn spawn = new BaseSpawn.Local(Arrays.asList("/usr/bin/env"),
         ImmutableMap.of("foo", "bar", "baz", "boo"),
@@ -181,6 +191,7 @@
     assertEquals(Sets.newHashSet("foo=bar", "baz=boo"), Sets.newHashSet(out().split("\n")));
   }
 
+  @Test
   public void testStandardError() throws Exception {
     Spawn spawn = createSpawn("/bin/sh", "-c", "echo Oops! >&2");
     run(spawn);
@@ -191,6 +202,7 @@
   // Test an action with environment variables set indicating an action running on a darwin host 
   // system. Such actions should fail given the fact that these tests run on a non darwin
   // architecture.
+  @Test
   public void testIOSEnvironmentOnNonDarwin() throws Exception {
     if (OS.getCurrent() == OS.DARWIN) {
       return;
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 f915304..dafcb1c 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
@@ -42,7 +42,7 @@
   private Path testFile;
 
   @Before
-  public void setUp() throws Exception {
+  public final void createFileSystem() throws Exception  {
     testFS = new UnixFileSystem();
     workingDir = testFS.getPath(new File(TestUtils.tmpDir()).getCanonicalPath());
     testFile = workingDir.getRelative("test");