Skip to content

Commit

Permalink
src: don't use guava's Files#asCharSink
Browse files Browse the repository at this point in the history
Guava's implementation of Files#asCharSink s marked @beta and can be replaced
with java native Files#writeString.

Result:
less dependency on guava's non stable API.

Acked-by: Paul Millar
Acked-by: Lea Morschel
Target: master
  • Loading branch information
kofemann committed May 5, 2021
1 parent de0a8d4 commit b1956be
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions core/src/test/java/org/dcache/nfs/ExportFileTest.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
package org.dcache.nfs;

import com.google.common.io.Files;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.Random;
import org.junit.Before;
import org.junit.Test;

import static org.mockito.Mockito.*;
import static org.mockito.BDDMockito.*;

import static java.nio.charset.StandardCharsets.UTF_8;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertFalse;

Expand All @@ -31,7 +30,7 @@ public void setUp() throws IOException {
export = File.createTempFile("exports", null);
export.deleteOnExit();

Files.asCharSink(export, UTF_8).write("/export_main 1.1.1.1(sec=sys)");
Files.writeString(export.toPath(), "/export_main 1.1.1.1(sec=sys)");

do {
// create new unique tmp-directory
Expand All @@ -43,16 +42,16 @@ public void setUp() throws IOException {
for (int i = 0; i < fileNumber; i++) {
File extraExport = File.createTempFile("extra", ".exports", exportDir);
extraExport.deleteOnExit();
Files.asCharSink(extraExport, UTF_8).write("/extra_export" + i + " 2.2.2." + i + "(sec=sys)");
Files.writeString(extraExport.toPath(), "/extra_export" + i + " 2.2.2." + i + "(sec=sys)");
}

File hiddenExport = File.createTempFile(".hidden", ".exports", exportDir);
hiddenExport.deleteOnExit();
Files.asCharSink(hiddenExport, UTF_8).write("/hidden_export *(sec=sys)");
Files.writeString(hiddenExport.toPath(), "/hidden_export *(sec=sys)");

File randomFile = File.createTempFile("random", null, exportDir);
randomFile.deleteOnExit();
Files.asCharSink(randomFile, UTF_8).write("/random_file_export *(sec=sys)");
Files.writeString(randomFile.toPath(), "/random_file_export *(sec=sys)");
}

@Test
Expand Down Expand Up @@ -118,7 +117,7 @@ public void testAddingNewFile() throws IOException {
assertExportNotExists("/added_export", ef);
File addedFile = File.createTempFile("new_export", ".exports", exportDir);
addedFile.deleteOnExit();
Files.asCharSink(addedFile, UTF_8).write("/added_export *(sec=sys)");
Files.writeString(addedFile.toPath(), "/added_export *(sec=sys)");

ef.rescan();
assertExportExists("/added_export", ef);
Expand Down

0 comments on commit b1956be

Please sign in to comment.