Automatically create folders in createSymlink in BuildIntegrationTestCase.

The helper to create symlinks does not handle creating folders on the path to
the new symlink if they don't exist. That is an inconsistent behavior to write
which does that for files. Add logic to handle adding folders as needed.

Also, apply error-prone fixes.

PiperOrigin-RevId: 269602789
diff --git a/src/test/java/com/google/devtools/build/lib/buildtool/util/BuildIntegrationTestCase.java b/src/test/java/com/google/devtools/build/lib/buildtool/util/BuildIntegrationTestCase.java
index 6f1749e..e39bbd5 100644
--- a/src/test/java/com/google/devtools/build/lib/buildtool/util/BuildIntegrationTestCase.java
+++ b/src/test/java/com/google/devtools/build/lib/buildtool/util/BuildIntegrationTestCase.java
@@ -104,6 +104,7 @@
 import com.google.devtools.common.options.OptionsBase;
 import com.google.devtools.common.options.OptionsParser;
 import java.io.IOException;
+import java.nio.charset.StandardCharsets;
 import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
@@ -320,7 +321,7 @@
     return TestRuleModule.getModule();
   }
 
-  private BlazeModule getNoResolvedFileModule() {
+  private static BlazeModule getNoResolvedFileModule() {
     return new BlazeModule() {
       @Override
       public ImmutableList<Injected> getPrecomputedValues() {
@@ -644,9 +645,14 @@
     return path;
   }
 
-  /** Equivalent to {@code ln -s <target> <relativeLinkPath>}. */
+  /**
+   * Creates folders on the path to {@code relativeLinkPath} and a symlink to {@code target} at
+   * {@code relativeLinkPath} (equivalent to {@code ln -s <target> <relativeLinkPath>}).
+   */
   protected void createSymlink(String target, String relativeLinkPath) throws IOException {
-    getWorkspace().getRelative(relativeLinkPath).createSymbolicLink(PathFragment.create(target));
+    Path path = getWorkspace().getRelative(relativeLinkPath);
+    path.getParentDirectory().createDirectoryAndParents();
+    path.createSymbolicLink(PathFragment.create(target));
   }
 
   /**
@@ -664,7 +670,7 @@
    * Fork/exec/wait the specified command.  A utility method for subclasses.
    */
   protected String exec(String... argv) throws CommandException {
-    return new String(new Command(argv).execute().getStdout());
+    return new String(new Command(argv).execute().getStdout(), StandardCharsets.UTF_8);
   }
 
   /**