use of com.yahoo.athenz.common.server.util.FilesHelper in project athenz by yahoo.
the class ZMSFileChangeLogStoreCommonTest method testSetFilePermissionsException.
@Test
public void testSetFilePermissionsException() throws IOException {
ZMSFileChangeLogStoreCommon fstore = new ZMSFileChangeLogStoreCommon(FSTORE_PATH);
FilesHelper helper = Mockito.mock(FilesHelper.class);
Mockito.when(helper.setPosixFilePermissions(any(), any())).thenThrow(new IOException("io exception"));
fstore.filesHelper = helper;
try {
File file = new File(FSTORE_PATH, "domain");
Set<PosixFilePermission> perms = EnumSet.of(PosixFilePermission.OWNER_READ, PosixFilePermission.OWNER_WRITE, PosixFilePermission.OWNER_EXECUTE);
fstore.setupFilePermissions(file, perms);
fail();
} catch (Exception ex) {
assertTrue(true);
}
}
use of com.yahoo.athenz.common.server.util.FilesHelper in project athenz by yahoo.
the class ZMSFileChangeLogStoreCommonTest method testPutException.
@Test
public void testPutException() throws IOException {
ZMSFileChangeLogStoreCommon fstore = new ZMSFileChangeLogStoreCommon(FSTORE_PATH);
FilesHelper helper = Mockito.mock(FilesHelper.class);
Mockito.when(helper.write(any(), any())).thenThrow(new IOException("io exception"));
fstore.filesHelper = helper;
Struct data = new Struct();
data.put("key", "val1");
try {
fstore.put("test1", JSON.bytes(data));
fail();
} catch (Exception ex) {
assertTrue(true);
}
}
use of com.yahoo.athenz.common.server.util.FilesHelper in project athenz by yahoo.
the class ZMSFileChangeLogStoreCommonTest method testSetupDomainFileException.
@Test
public void testSetupDomainFileException() throws IOException {
ZMSFileChangeLogStoreCommon fstore = new ZMSFileChangeLogStoreCommon(FSTORE_PATH);
FilesHelper helper = Mockito.mock(FilesHelper.class);
Mockito.doThrow(new IOException("io exception")).when(helper).createEmptyFile(any());
fstore.filesHelper = helper;
try {
File file = new File(FSTORE_PATH, "domain");
fstore.setupDomainFile(file);
fail();
} catch (Exception ex) {
assertTrue(true);
}
}
use of com.yahoo.athenz.common.server.util.FilesHelper in project athenz by yahoo.
the class ZMSFileChangeLogStoreCommonTest method testDeleteException.
@Test
public void testDeleteException() throws IOException {
ZMSFileChangeLogStoreCommon fstore = new ZMSFileChangeLogStoreCommon(FSTORE_PATH);
// create the file
Struct data = new Struct();
data.put("key", "val1");
fstore.put("test1", JSON.bytes(data));
// update the helper to be our mock
FilesHelper helper = Mockito.mock(FilesHelper.class);
Mockito.doThrow(new IOException("io exception")).when(helper).delete(any());
fstore.filesHelper = helper;
try {
fstore.delete("test1");
fail();
} catch (Exception ex) {
assertTrue(true);
}
}
Aggregations