use of alluxio.client.file.options.CreateFileOptions in project alluxio by Alluxio.
the class FileInStreamIntegrationTest method seek.
/**
* Tests {@link FileInStream#seek(long)}.
*/
@Test
public void seek() throws Exception {
for (int k = MIN_LEN; k <= MAX_LEN; k += DELTA) {
for (CreateFileOptions op : getOptionSet()) {
String filename = sTestPath + "/file_" + k + "_" + op.hashCode();
AlluxioURI uri = new AlluxioURI(filename);
FileInStream is = sFileSystem.openFile(uri, FileSystemTestUtils.toOpenFileOptions(op));
is.seek(k / 3);
Assert.assertEquals(k / 3, is.read());
is.seek(k / 2);
Assert.assertEquals(k / 2, is.read());
is.seek(k / 4);
Assert.assertEquals(k / 4, is.read());
is.close();
}
}
}
use of alluxio.client.file.options.CreateFileOptions in project alluxio by Alluxio.
the class ReadOnlyMountIntegrationTest method createFile.
@Test
public void createFile() throws IOException, AlluxioException {
CreateFileOptions writeBoth = CreateFileOptions.defaults().setWriteType(WriteType.CACHE_THROUGH);
AlluxioURI uri = new AlluxioURI(FILE_PATH + "_create");
try {
mFileSystem.createFile(uri, writeBoth).close();
Assert.fail("createFile should not succeed under a readonly mount.");
} catch (AccessControlException e) {
Assert.assertEquals(e.getMessage(), ExceptionMessage.MOUNT_READONLY.getMessage(uri, MOUNT_PATH));
}
uri = new AlluxioURI(SUB_FILE_PATH + "_create");
try {
mFileSystem.createFile(uri, writeBoth).close();
Assert.fail("createFile should not succeed under a readonly mount.");
} catch (AccessControlException e) {
Assert.assertEquals(e.getMessage(), ExceptionMessage.MOUNT_READONLY.getMessage(uri, MOUNT_PATH));
}
}
use of alluxio.client.file.options.CreateFileOptions in project alluxio by Alluxio.
the class FileInStreamIntegrationTest method seekExceptionTest1.
/**
* Tests {@link FileInStream#seek(long)}. Validate the expected exception for seeking a negative
* position.
*/
@Test
public void seekExceptionTest1() throws Exception {
mThrown.expect(IllegalArgumentException.class);
for (int k = MIN_LEN; k <= MAX_LEN; k += DELTA) {
for (CreateFileOptions op : getOptionSet()) {
String filename = sTestPath + "/file_" + k + "_" + op.hashCode();
AlluxioURI uri = new AlluxioURI(filename);
try (FileInStream is = sFileSystem.openFile(uri, FileSystemTestUtils.toOpenFileOptions(op))) {
is.seek(-1);
}
}
}
}
use of alluxio.client.file.options.CreateFileOptions in project alluxio by Alluxio.
the class FileInStreamIntegrationTest method seekExceptionTest2.
/**
* Tests {@link FileInStream#seek(long)}. Validate the expected exception for seeking a position
* that is past EOF.
*/
@Test
public void seekExceptionTest2() throws Exception {
mThrown.expect(IllegalArgumentException.class);
for (int k = MIN_LEN; k <= MAX_LEN; k += DELTA) {
for (CreateFileOptions op : getOptionSet()) {
String filename = sTestPath + "/file_" + k + "_" + op.hashCode();
AlluxioURI uri = new AlluxioURI(filename);
try (FileInStream is = sFileSystem.openFile(uri, FileSystemTestUtils.toOpenFileOptions(op))) {
is.seek(k + 1);
}
}
}
}
use of alluxio.client.file.options.CreateFileOptions in project alluxio by Alluxio.
the class FileOutStreamIntegrationTest method writeByteArray.
/**
* Tests {@link FileOutStream#write(byte[])}.
*/
@Test
public void writeByteArray() throws Exception {
String uniqPath = PathUtils.uniqPath();
for (int len = MIN_LEN; len <= MAX_LEN; len += DELTA) {
CreateFileOptions op = CreateFileOptions.defaults().setWriteType(mWriteType);
AlluxioURI filePath = new AlluxioURI(PathUtils.concatPath(uniqPath, "file_" + len + "_" + mWriteType));
writeIncreasingByteArrayToFile(filePath, len, op);
if (mWriteType.getAlluxioStorageType().isStore()) {
checkFileInAlluxio(filePath, len);
}
if (mWriteType.getUnderStorageType().isSyncPersist()) {
checkFileInUnderStorage(filePath, len);
}
}
}
Aggregations