diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2018-09-26 16:18:08 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-26 16:18:08 +0200 |
commit | b4bd563a4c22652437a39d83161f14abbb540f6e (patch) | |
tree | a7d2fae084392dea90584aefb69dcf7ebb33bae8 /vespajlib/src/test/java/com/yahoo | |
parent | a246879bed135a7c5861eab5ad0da85e16e539d7 (diff) |
Revert "Revert "Balder/add native fadvise""
Diffstat (limited to 'vespajlib/src/test/java/com/yahoo')
-rw-r--r-- | vespajlib/src/test/java/com/yahoo/io/NativeIOTestCase.java | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/vespajlib/src/test/java/com/yahoo/io/NativeIOTestCase.java b/vespajlib/src/test/java/com/yahoo/io/NativeIOTestCase.java new file mode 100644 index 00000000000..ecd38056a19 --- /dev/null +++ b/vespajlib/src/test/java/com/yahoo/io/NativeIOTestCase.java @@ -0,0 +1,34 @@ +package com.yahoo.io; + +import com.sun.jna.Platform; +import org.junit.Test; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; + +public class NativeIOTestCase { + + @Test + public void requireThatDropFileFromCacheDoesNotThrow() throws IOException { + File testFile = new File("testfile"); + FileOutputStream output = new FileOutputStream(testFile); + output.write('t'); + output.flush(); + output.close(); + NativeIO nativeIO = new NativeIO(); + if (Platform.isLinux()) { + assertTrue(nativeIO.valid()); + } else { + assertFalse(nativeIO.valid()); + assertEquals("Platform is unsúpported. Only supported on linux.", nativeIO.getError().getMessage()); + } + nativeIO.dropFileFromCache(output.getFD()); + nativeIO.dropFileFromCache(testFile); + testFile.delete(); + } +} |