summaryrefslogtreecommitdiffstats
path: root/node-admin/src/test/java/com/yahoo
diff options
context:
space:
mode:
authorMartin Polden <mpolden@mpolden.no>2019-10-16 12:16:02 +0200
committerMartin Polden <mpolden@mpolden.no>2019-10-16 12:20:12 +0200
commit48d7efe8bf25b597a0313443a1217c90116a7436 (patch)
treeb9cf2d50b4d50dc21c9d49ce8417afde406f1624 /node-admin/src/test/java/com/yahoo
parent38299f5fc89504356b9237d36e6dc55877d5ef1a (diff)
Add readBytesIfExists to UnixPath
Diffstat (limited to 'node-admin/src/test/java/com/yahoo')
-rw-r--r--node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/task/util/file/UnixPathTest.java11
1 files changed, 11 insertions, 0 deletions
diff --git a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/task/util/file/UnixPathTest.java b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/task/util/file/UnixPathTest.java
index 6dfbc258474..802ca43ef56 100644
--- a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/task/util/file/UnixPathTest.java
+++ b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/task/util/file/UnixPathTest.java
@@ -9,6 +9,7 @@ import java.nio.file.FileSystem;
import java.nio.file.Files;
import java.nio.file.Path;
+import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@@ -17,6 +18,7 @@ import static org.junit.Assert.assertTrue;
* @author hakonhall
*/
public class UnixPathTest {
+
private final FileSystem fs = TestFileSystem.create();
@Test
@@ -87,4 +89,13 @@ public class UnixPathTest {
UnixPath link = path.createSymbolicLink(fs.getPath("link-to-example.txt"));
assertEquals(original, link.readUtf8File());
}
+
+ @Test
+ public void readBytesIfExists() {
+ UnixPath path = new UnixPath(fs.getPath("example.txt"));
+ assertFalse(path.readBytesIfExists().isPresent());
+ path.writeBytes(new byte[]{42});
+ assertArrayEquals(new byte[]{42}, path.readBytesIfExists().get());
+ }
+
}