This closes #695

This commit is contained in:
jbertram 2016-08-01 16:20:12 -05:00
commit 4cecc95751
2 changed files with 23 additions and 1 deletions

View File

@ -22,7 +22,7 @@ import java.nio.ByteBuffer;
/**
* This is an extension to use libaio.
*/
public final class LibaioFile<Callback extends SubmitInfo> {
public final class LibaioFile<Callback extends SubmitInfo> implements AutoCloseable {
protected boolean open;
/**

View File

@ -46,6 +46,28 @@ public class LibaioTest {
@BeforeClass
public static void testAIO() {
Assume.assumeTrue(LibaioContext.isLoaded());
File parent = new File("./target");
File file = new File(parent, "testFile");
try {
parent.mkdirs();
boolean failed = false;
try (LibaioContext control = new LibaioContext<>(1, true); LibaioFile fileDescriptor = control.openFile(file, true)) {
fileDescriptor.fallocate(4 * 1024);
}
catch (Exception e) {
e.printStackTrace();
failed = true;
}
Assume.assumeFalse("There is not enough support to libaio", failed);
}
finally {
file.delete();
}
}
/**