use of org.eclipse.che.api.core.ForbiddenException in project che by eclipse.
the class MemoryVirtualFileTest method failsDeleteLockedFileWhenLockTokenIsInvalid.
@Test
public void failsDeleteLockedFileWhenLockTokenIsInvalid() throws Exception {
VirtualFile root = getRoot();
VirtualFile folder = root.createFolder(generateFolderName());
VirtualFile file = folder.createFile(generateFileName(), DEFAULT_CONTENT);
file.setProperty("property1", "value1");
Path filePath = file.getPath();
String invalidLockToken = invalidateLockToken(file.lock(0));
try {
file.delete(invalidLockToken);
thrown.expect(ForbiddenException.class);
} catch (ForbiddenException e) {
assertEquals(file, getRoot().getChild(filePath));
assertTrue(file.isLocked());
}
}
use of org.eclipse.che.api.core.ForbiddenException in project che by eclipse.
the class MemoryVirtualFileTest method failsUpdateContentOfLockedFileByStreamWhenLockTokenIsInvalid.
@Test
public void failsUpdateContentOfLockedFileByStreamWhenLockTokenIsInvalid() throws Exception {
VirtualFile root = getRoot();
VirtualFile file = root.createFile(generateFileName(), DEFAULT_CONTENT);
String invalidLockToken = invalidateLockToken(file.lock(0));
try {
file.updateContent(new ByteArrayInputStream("updated content".getBytes()), invalidLockToken);
thrown.expect(ForbiddenException.class);
} catch (ForbiddenException expected) {
assertEquals(DEFAULT_CONTENT, file.getContentAsString());
}
}
use of org.eclipse.che.api.core.ForbiddenException in project che by eclipse.
the class MemoryVirtualFileTest method failsRenameLockedFileWhenLockTokenIsInvalid.
@Test
public void failsRenameLockedFileWhenLockTokenIsInvalid() throws Exception {
VirtualFile folder = getRoot().createFolder(generateFolderName());
VirtualFile file = folder.createFile(generateFileName(), DEFAULT_CONTENT);
file.setProperty("property1", "value1");
Path filePath = file.getPath();
Path newPath = folder.getPath().newPath("new name");
String invalidLockToken = invalidateLockToken(file.lock(0));
try {
file.rename("new name", invalidLockToken);
thrown.expect(ForbiddenException.class);
} catch (ForbiddenException e) {
assertNull(getRoot().getChild(newPath));
assertTrue(file.isLocked());
assertEquals(file, getRoot().getChild(filePath));
assertEquals(ImmutableMap.of("property1", "value1"), file.getProperties());
assertEquals(DEFAULT_CONTENT, file.getContentAsString());
}
}
Aggregations