use of org.eclipse.core.filebuffers.ITextFileBufferManager in project eclipse.platform.text by eclipse.
the class FileBufferCreation method test3_2_new.
/*
* Tests the creation of a file buffer for a file in a linked folder.
*/
@Test
public void test3_2_new() throws Exception {
IPath path = createLinkedFolder("linkedFolder", "testResources/linkedFolderTarget");
assertNotNull(path);
path = path.append("FileInLinkedFolder");
ITextFileBufferManager manager = FileBuffers.getTextFileBufferManager();
manager.connect(path, LocationKind.IFILE, null);
ITextFileBuffer buffer = manager.getTextFileBuffer(path, LocationKind.IFILE);
Assert.assertNotNull(buffer);
IDocument document = buffer.getDocument();
Assert.assertNotNull(document);
Assert.assertTrue(CONTENT4.equals(document.get()));
assertSame(buffer, manager.getTextFileBuffer(document));
manager.disconnect(path, LocationKind.IFILE, null);
assertNull(manager.getTextFileBuffer(path, LocationKind.IFILE));
}
use of org.eclipse.core.filebuffers.ITextFileBufferManager in project eclipse.platform.text by eclipse.
the class FileBufferCreation method test3_1_IFILE.
/*
* Tests the creation of a file buffer for a linked file.
*/
@Test
public void test3_1_IFILE() throws Exception {
IPath path = createLinkedFile("file", "testResources/LinkedFileTarget");
assertNotNull(path);
ITextFileBufferManager manager = FileBuffers.getTextFileBufferManager();
manager.connect(path, LocationKind.IFILE, null);
ITextFileBuffer buffer = manager.getTextFileBuffer(path, LocationKind.IFILE);
Assert.assertNotNull(buffer);
IDocument document = buffer.getDocument();
Assert.assertNotNull(document);
Assert.assertTrue(CONTENT2.equals(document.get()));
assertSame(buffer, manager.getTextFileBuffer(document));
manager.disconnect(path, LocationKind.IFILE, null);
assertNull(manager.getTextFileBuffer(path, LocationKind.IFILE));
}
use of org.eclipse.core.filebuffers.ITextFileBufferManager in project eclipse.platform.text by eclipse.
the class FileBufferCreation method test5.
/*
* Tests the creation of a file buffer for an external file.
*/
@Test
public void test5() throws Exception {
File externalFile = FileTool.getFileInPlugin(FileBuffersTestPlugin.getDefault(), new Path("testResources/ExternalFile"));
assertNotNull(externalFile);
IPath path = new Path(externalFile.getAbsolutePath());
ITextFileBufferManager manager = FileBuffers.getTextFileBufferManager();
manager.connect(path, LocationKind.NORMALIZE, null);
ITextFileBuffer buffer = manager.getTextFileBuffer(path, LocationKind.NORMALIZE);
assertNotNull(buffer);
IDocument document = buffer.getDocument();
assertNotNull(document);
assertTrue(CONTENT3.equals(document.get()));
assertSame(buffer, manager.getTextFileBuffer(document));
manager.disconnect(path, LocationKind.NORMALIZE, null);
assertNull(manager.getTextFileBuffer(path, LocationKind.NORMALIZE));
}
use of org.eclipse.core.filebuffers.ITextFileBufferManager in project eclipse.platform.text by eclipse.
the class FileBufferCreation method test7_IFileStore.
/*
* Tests the creation of a file buffer for a non-existing file.
*/
@Test
public void test7_IFileStore() throws Exception {
IPath path = FileBuffersTestPlugin.getDefault().getStateLocation();
path = path.append("NonExistingFile");
IFileStore fileStore = EFS.getLocalFileSystem().getStore(path);
ITextFileBufferManager manager = FileBuffers.getTextFileBufferManager();
manager.connectFileStore(fileStore, null);
ITextFileBuffer buffer = manager.getFileStoreTextFileBuffer(fileStore);
Assert.assertNotNull(buffer);
IDocument document = buffer.getDocument();
Assert.assertNotNull(document);
Assert.assertTrue("".equals(document.get()));
assertSame(buffer, manager.getTextFileBuffer(document));
manager.disconnectFileStore(fileStore, null);
assertNull(manager.getFileStoreTextFileBuffer(fileStore));
}
use of org.eclipse.core.filebuffers.ITextFileBufferManager in project eclipse.platform.text by eclipse.
the class FileBufferCreation method test3_2.
/*
* Tests the creation of a file buffer for a file in a linked folder.
*/
@Test
public void test3_2() throws Exception {
IPath path = createLinkedFolder("linkedFolder", "testResources/linkedFolderTarget");
assertNotNull(path);
path = path.append("FileInLinkedFolder");
ITextFileBufferManager manager = FileBuffers.getTextFileBufferManager();
manager.connect(path, LocationKind.NORMALIZE, null);
ITextFileBuffer buffer = manager.getTextFileBuffer(path, LocationKind.NORMALIZE);
Assert.assertNotNull(buffer);
IDocument document = buffer.getDocument();
Assert.assertNotNull(document);
Assert.assertTrue(CONTENT4.equals(document.get()));
assertSame(buffer, manager.getTextFileBuffer(document));
manager.disconnect(path, LocationKind.NORMALIZE, null);
assertNull(manager.getTextFileBuffer(path, LocationKind.NORMALIZE));
}
Aggregations