use of org.eclipse.core.filebuffers.ITextFileBuffer in project eclipse.platform.text by eclipse.
the class FileBufferFunctions method setUp.
@Before
public void setUp() throws Exception {
fManager = FileBuffers.getTextFileBufferManager();
fProject = ResourceHelper.createProject("project");
fPath = createPath(fProject);
ITextFileBuffer buffer = fManager.getTextFileBuffer(fPath, LocationKind.NORMALIZE);
assertTrue(buffer == null);
}
use of org.eclipse.core.filebuffers.ITextFileBuffer in project eclipse.platform.text by eclipse.
the class FileBufferFunctions method test7.
/*
* Test commit.
*/
@Test
public void test7() throws Exception {
fManager.connect(fPath, LocationKind.NORMALIZE, null);
try {
ITextFileBuffer fileBuffer = fManager.getTextFileBuffer(fPath, LocationKind.NORMALIZE);
// set dirty bit
IDocument document = fileBuffer.getDocument();
document.replace(document.getLength(), 0, "appendix");
String originalContent = document.get();
// commit
fileBuffer.commit(null, true);
// check assertions
assertEquals(originalContent, document.get());
assertFalse(fileBuffer.isDirty());
assertTrue(fileBuffer.isSynchronized());
// revert to see effect is persistent
fileBuffer.revert(null);
// check assertions
assertEquals(originalContent, document.get());
assertFalse(fileBuffer.isDirty());
assertTrue(fileBuffer.isSynchronized());
// disconnect
fManager.disconnect(fPath, LocationKind.NORMALIZE, null);
// reconnect
fManager.connect(fPath, LocationKind.NORMALIZE, null);
try {
fileBuffer = fManager.getTextFileBuffer(fPath, LocationKind.NORMALIZE);
document = fileBuffer.getDocument();
// check assertions
assertEquals(originalContent, document.get());
assertFalse(fileBuffer.isDirty());
assertTrue(fileBuffer.isSynchronized());
} finally {
fManager.disconnect(fPath, LocationKind.NORMALIZE, null);
}
} finally {
fManager.disconnect(fPath, LocationKind.NORMALIZE, null);
}
}
use of org.eclipse.core.filebuffers.ITextFileBuffer in project eclipse.platform.text by eclipse.
the class FileBufferFunctions method test8_1.
/*
* Test validateState.
*/
@Test
public void test8_1() throws Exception {
fManager.connect(fPath, LocationKind.NORMALIZE, null);
try {
ITextFileBuffer fileBuffer = fManager.getTextFileBuffer(fPath, LocationKind.NORMALIZE);
fileBuffer.validateState(null, null);
assertTrue(fileBuffer.isStateValidated());
} finally {
fManager.disconnect(fPath, LocationKind.NORMALIZE, null);
}
}
use of org.eclipse.core.filebuffers.ITextFileBuffer in project eclipse.platform.text by eclipse.
the class FileBufferFunctions method test4.
/*
* Tests isShared.
*/
@Test
public void test4() throws Exception {
fManager.connect(fPath, LocationKind.NORMALIZE, null);
try {
ITextFileBuffer fileBuffer1 = fManager.getTextFileBuffer(fPath, LocationKind.NORMALIZE);
assertFalse(fileBuffer1.isShared());
fManager.connect(fPath, LocationKind.NORMALIZE, null);
try {
ITextFileBuffer fileBuffer2 = fManager.getTextFileBuffer(fPath, LocationKind.NORMALIZE);
assertTrue(fileBuffer1.isShared());
assertTrue(fileBuffer2.isShared());
} finally {
fManager.disconnect(fPath, LocationKind.NORMALIZE, null);
}
assertFalse(fileBuffer1.isShared());
} finally {
fManager.disconnect(fPath, LocationKind.NORMALIZE, null);
}
}
use of org.eclipse.core.filebuffers.ITextFileBuffer in project eclipse.platform.text by eclipse.
the class FileBufferFunctions method testGetFileStoreAnnotationModel.
/*
* Tests isSynchronized.
*/
@Test
public void testGetFileStoreAnnotationModel() throws Exception {
IFileStore fileStore = EFS.getNullFileSystem().getStore(new Path("/dev/null"));
assertNotNull(fileStore);
fManager.connectFileStore(fileStore, null);
try {
ITextFileBuffer fileBuffer = fManager.getFileStoreTextFileBuffer(fileStore);
IAnnotationModel model = fileBuffer.getAnnotationModel();
Class<IAnnotationModel> clazz = getAnnotationModelClass();
if (clazz != null)
assertTrue(clazz.isInstance(model));
else
assertNotNull(model);
} finally {
fManager.disconnectFileStore(fileStore, null);
}
}
Aggregations