Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKai Maetzel2004-10-07 15:59:20 +0000
committerKai Maetzel2004-10-07 15:59:20 +0000
commit194ac92deeb027152a9e1a9cbd87a2d579235d75 (patch)
tree056d50231d7e3b72e78de61fd785f2d32727416a /org.eclipse.core.filebuffers.tests/src
parent40bcde25532be3b6663df2540b25bc3b5970001b (diff)
downloadeclipse.platform.text-194ac92deeb027152a9e1a9cbd87a2d579235d75.tar.gz
eclipse.platform.text-194ac92deeb027152a9e1a9cbd87a2d579235d75.tar.xz
eclipse.platform.text-194ac92deeb027152a9e1a9cbd87a2d579235d75.zip
new tests
Diffstat (limited to 'org.eclipse.core.filebuffers.tests/src')
-rw-r--r--org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBufferFunctions.java685
-rw-r--r--org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBuffersForExternalFiles.java21
-rw-r--r--org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBuffersForLinkedFiles.java33
-rw-r--r--org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBuffersForNonExistingExternalFiles.java21
-rw-r--r--org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBuffersForNonExistingWorkspaceFiles.java21
-rw-r--r--org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBuffersForWorkspaceFiles.java40
6 files changed, 786 insertions, 35 deletions
diff --git a/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBufferFunctions.java b/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBufferFunctions.java
index e4d5da688..1fffd5c99 100644
--- a/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBufferFunctions.java
+++ b/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBufferFunctions.java
@@ -39,6 +39,12 @@ public abstract class FileBufferFunctions extends TestCase {
protected abstract void markReadOnly() throws Exception;
+ protected abstract boolean modifyUnderlyingFile() throws Exception;
+
+ protected abstract boolean deleteUnderlyingFile() throws Exception;
+
+ protected abstract IPath moveUnderlyingFile() throws Exception;
+
protected abstract boolean isStateValidationSupported();
@@ -311,10 +317,10 @@ public abstract class FileBufferFunctions extends TestCase {
Listener listener= new Listener();
fManager.addFileBufferListener(listener);
-
- fManager.connect(fPath, null);
try {
+ fManager.connect(fPath, null);
+
assertTrue(listener.count == 1);
assertNotNull(listener.buffer);
IFileBuffer fileBuffer= fManager.getFileBuffer(fPath);
@@ -325,7 +331,11 @@ public abstract class FileBufferFunctions extends TestCase {
assertTrue(listener.buffer == fileBuffer);
} finally {
- fManager.disconnect(fPath, null);
+ try {
+ fManager.disconnect(fPath, null);
+ } finally {
+ fManager.removeFileBufferListener(listener);
+ }
}
}
@@ -348,29 +358,34 @@ public abstract class FileBufferFunctions extends TestCase {
Listener listener= new Listener();
fManager.addFileBufferListener(listener);
-
- ITextFileBuffer fileBuffer= fManager.getTextFileBuffer(fPath);
- assertTrue(listener.count == 0 && listener.buffer == null);
-
- fManager.connect(fPath, null);
try {
- fileBuffer= fManager.getTextFileBuffer(fPath);
- IDocument document= fileBuffer.getDocument();
- document.replace(0, 0, "prefix");
-
- assertTrue(listener.count == 1);
- assertTrue(listener.buffer == fileBuffer);
- assertTrue(listener.isDirty);
-
- fileBuffer.commit(null, true);
+ ITextFileBuffer fileBuffer= fManager.getTextFileBuffer(fPath);
+ assertTrue(listener.count == 0 && listener.buffer == null);
- assertTrue(listener.count == 2);
- assertTrue(listener.buffer == fileBuffer);
- assertFalse(listener.isDirty);
+ fManager.connect(fPath, null);
+ try {
+
+ fileBuffer= fManager.getTextFileBuffer(fPath);
+ IDocument document= fileBuffer.getDocument();
+ document.replace(0, 0, "prefix");
+
+ assertTrue(listener.count == 1);
+ assertTrue(listener.buffer == fileBuffer);
+ assertTrue(listener.isDirty);
+
+ fileBuffer.commit(null, true);
+
+ assertTrue(listener.count == 2);
+ assertTrue(listener.buffer == fileBuffer);
+ assertFalse(listener.isDirty);
+
+ } finally {
+ fManager.disconnect(fPath, null);
+ }
} finally {
- fManager.disconnect(fPath, null);
+ fManager.removeFileBufferListener(listener);
}
}
@@ -393,29 +408,629 @@ public abstract class FileBufferFunctions extends TestCase {
Listener listener= new Listener();
fManager.addFileBufferListener(listener);
+ try {
+ ITextFileBuffer fileBuffer= fManager.getTextFileBuffer(fPath);
+ assertTrue(listener.count == 0 && listener.buffer == null);
+
+ fManager.connect(fPath, null);
+ try {
+
+ fileBuffer= fManager.getTextFileBuffer(fPath);
+ IDocument document= fileBuffer.getDocument();
+ document.replace(0, 0, "prefix");
+
+ assertTrue(listener.count == 1);
+ assertTrue(listener.buffer == fileBuffer);
+ assertTrue(listener.isDirty);
+
+ fileBuffer.revert(null);
+
+ assertTrue(listener.count == 2);
+ assertTrue(listener.buffer == fileBuffer);
+ assertFalse(listener.isDirty);
+
+ } finally {
+ fManager.disconnect(fPath, null);
+ }
+
+ } finally {
+ fManager.removeFileBufferListener(listener);
+ }
+ }
+
+ /*
+ * Test IFileBufferListener#bufferContentAboutToBeReplaced/replaced
+ */
+ public void test12_1() throws Exception {
+ class Listener extends FileBufferListener {
+
+ public IFileBuffer preBuffer, postBuffer;
+ public int preCount, postCount;
+
+ public void bufferContentAboutToBeReplaced(IFileBuffer buffer) {
+ ++preCount;
+ preBuffer= buffer;
+ }
+
+ public void bufferContentReplaced(IFileBuffer buffer) {
+ ++postCount;
+ postBuffer= buffer;
+ }
+ }
- ITextFileBuffer fileBuffer= fManager.getTextFileBuffer(fPath);
- assertTrue(listener.count == 0 && listener.buffer == null);
+ Listener listener= new Listener();
+ fManager.addFileBufferListener(listener);
+ try {
+ ITextFileBuffer fileBuffer= fManager.getTextFileBuffer(fPath);
+ assertTrue(listener.preCount == 0 && listener.postCount == 0 && listener.preBuffer == null && listener.postBuffer == null);
+
+ fManager.connect(fPath, null);
+ try {
+
+ fileBuffer= fManager.getTextFileBuffer(fPath);
+ IDocument document= fileBuffer.getDocument();
+ document.replace(0, 0, "prefix");
+
+ fileBuffer.revert(null);
+
+ assertTrue(listener.preCount == 1);
+ assertTrue(listener.preBuffer == fileBuffer);
+ assertTrue(listener.postCount == 1);
+ assertTrue(listener.postBuffer == fileBuffer);
+
+ } finally {
+ fManager.disconnect(fPath, null);
+ }
+
+ } finally {
+ fManager.removeFileBufferListener(listener);
+ }
+ }
+
+ /*
+ * Test IFileBufferListener#bufferContentAboutToBeReplaced/replaced
+ */
+ public void test12_2() throws Exception {
+ class Listener extends FileBufferListener {
+
+ public IFileBuffer preBuffer, postBuffer;
+ public int preCount, postCount;
+
+ public void bufferContentAboutToBeReplaced(IFileBuffer buffer) {
+ ++preCount;
+ preBuffer= buffer;
+ }
+
+ public void bufferContentReplaced(IFileBuffer buffer) {
+ ++postCount;
+ postBuffer= buffer;
+ }
+ }
- fManager.connect(fPath, null);
+ Listener listener= new Listener();
+ fManager.addFileBufferListener(listener);
try {
+ ITextFileBuffer fileBuffer= fManager.getTextFileBuffer(fPath);
+ assertTrue(listener.preCount == 0 && listener.postCount == 0 && listener.preBuffer == null && listener.postBuffer == null);
- fileBuffer= fManager.getTextFileBuffer(fPath);
- IDocument document= fileBuffer.getDocument();
- document.replace(0, 0, "prefix");
+ fManager.connect(fPath, null);
+ try {
+
+ fileBuffer= fManager.getTextFileBuffer(fPath);
+
+ if (modifyUnderlyingFile()) {
+ assertTrue(listener.preCount == 1);
+ assertTrue(listener.preBuffer == fileBuffer);
+ assertTrue(listener.postCount == 1);
+ assertTrue(listener.postBuffer == fileBuffer);
+ }
+
+ } finally {
+ fManager.disconnect(fPath, null);
+ }
- assertTrue(listener.count == 1);
- assertTrue(listener.buffer == fileBuffer);
- assertTrue(listener.isDirty);
+ } finally {
+ fManager.removeFileBufferListener(listener);
+ }
+ }
+
+ /*
+ * Test IFileBufferListener#stateValidationChanged
+ */
+ public void test13_1() throws Exception {
+ class Listener extends FileBufferListener {
- fileBuffer.revert(null);
+ public IFileBuffer buffer;
+ public int count;
+ public boolean isStateValidated;
- assertTrue(listener.count == 2);
- assertTrue(listener.buffer == fileBuffer);
- assertFalse(listener.isDirty);
+ public void stateValidationChanged(IFileBuffer buffer, boolean isStateValidated) {
+ ++count;
+ this.buffer= buffer;
+ this.isStateValidated= isStateValidated;
+ }
+ }
+
+ Listener listener= new Listener();
+ fManager.addFileBufferListener(listener);
+ try {
+ ITextFileBuffer fileBuffer= fManager.getTextFileBuffer(fPath);
+ assertTrue(listener.count == 0 && listener.buffer == null);
+
+ fManager.connect(fPath, null);
+ try {
+
+ fileBuffer= fManager.getTextFileBuffer(fPath);
+ fileBuffer.validateState(null, null);
+
+ if (isStateValidationSupported()) {
+ assertTrue(listener.count == 1);
+ assertTrue(listener.buffer == fileBuffer);
+ assertTrue(listener.isStateValidated);
+ }
+
+ } finally {
+ fManager.disconnect(fPath, null);
+ }
} finally {
- fManager.disconnect(fPath, null);
+ fManager.removeFileBufferListener(listener);
+ }
+ }
+
+ /*
+ * Test IFileBufferListener#stateValidationChanged
+ */
+ public void test13_2() throws Exception {
+ class Listener extends FileBufferListener {
+
+ public IFileBuffer buffer;
+ public int count;
+ public boolean isStateValidated;
+
+ public void stateValidationChanged(IFileBuffer buffer, boolean isStateValidated) {
+ ++count;
+ this.buffer= buffer;
+ this.isStateValidated= isStateValidated;
+ }
+ }
+
+ Listener listener= new Listener();
+ fManager.addFileBufferListener(listener);
+ try {
+ ITextFileBuffer fileBuffer= fManager.getTextFileBuffer(fPath);
+ assertTrue(listener.count == 0 && listener.buffer == null);
+
+ fManager.connect(fPath, null);
+ try {
+
+ markReadOnly();
+ fileBuffer= fManager.getTextFileBuffer(fPath);
+ fileBuffer.validateState(null, null);
+
+ if (isStateValidationSupported()) {
+ assertTrue(listener.count == 1);
+ assertTrue(listener.buffer == fileBuffer);
+ assertTrue(listener.isStateValidated);
+ }
+
+ } finally {
+ fManager.disconnect(fPath, null);
+ }
+
+ } finally {
+ fManager.removeFileBufferListener(listener);
+ }
+ }
+ /*
+ * Test IFileBufferListener#stateValidationChanged
+ */
+ public void test13_3() throws Exception {
+ class Listener extends FileBufferListener {
+
+ public IFileBuffer buffer;
+ public int count;
+ public boolean isStateValidated;
+
+ public void stateValidationChanged(IFileBuffer buffer, boolean isStateValidated) {
+ ++count;
+ this.buffer= buffer;
+ this.isStateValidated= isStateValidated;
+ }
+ }
+
+ Listener listener= new Listener();
+ fManager.addFileBufferListener(listener);
+ try {
+ ITextFileBuffer fileBuffer= fManager.getTextFileBuffer(fPath);
+ assertTrue(listener.count == 0 && listener.buffer == null);
+
+ fManager.connect(fPath, null);
+ try {
+
+ fileBuffer= fManager.getTextFileBuffer(fPath);
+ fileBuffer.validateState(null, null);
+ fileBuffer.resetStateValidation();
+
+ if (isStateValidationSupported()) {
+ assertTrue(listener.count == 2);
+ assertTrue(listener.buffer == fileBuffer);
+ assertFalse(listener.isStateValidated);
+ }
+
+ } finally {
+ fManager.disconnect(fPath, null);
+ }
+
+ } finally {
+ fManager.removeFileBufferListener(listener);
+ }
+ }
+
+ /*
+ * Test IFileBufferListener#stateValidationChanged
+ */
+ public void test13_4() throws Exception {
+ class Listener extends FileBufferListener {
+
+ public IFileBuffer buffer;
+ public int count;
+ public boolean isStateValidated;
+
+ public void stateValidationChanged(IFileBuffer buffer, boolean isStateValidated) {
+ ++count;
+ this.buffer= buffer;
+ this.isStateValidated= isStateValidated;
+ }
+ }
+
+ Listener listener= new Listener();
+ fManager.addFileBufferListener(listener);
+ try {
+ ITextFileBuffer fileBuffer= fManager.getTextFileBuffer(fPath);
+ assertTrue(listener.count == 0 && listener.buffer == null);
+
+ fManager.connect(fPath, null);
+ try {
+
+ markReadOnly();
+ fileBuffer= fManager.getTextFileBuffer(fPath);
+ fileBuffer.validateState(null, null);
+ fileBuffer.resetStateValidation();
+
+ if (isStateValidationSupported()) {
+ assertTrue(listener.count == 2);
+ assertTrue(listener.buffer == fileBuffer);
+ assertFalse(listener.isStateValidated);
+ }
+
+ } finally {
+ fManager.disconnect(fPath, null);
+ }
+
+ } finally {
+ fManager.removeFileBufferListener(listener);
+ }
+ }
+
+ /*
+ * Test IFileBufferListener#underlyingFileDeleted
+ */
+ public void test14() throws Exception {
+ class Listener extends FileBufferListener {
+
+ public IFileBuffer buffer;
+ public int count;
+
+ public void underlyingFileDeleted(IFileBuffer buffer) {
+ ++count;
+ this.buffer= buffer;
+ }
+ }
+
+ Listener listener= new Listener();
+ fManager.addFileBufferListener(listener);
+ try {
+ ITextFileBuffer fileBuffer= fManager.getTextFileBuffer(fPath);
+ assertTrue(listener.count == 0 && listener.buffer == null);
+
+ fManager.connect(fPath, null);
+ try {
+
+ fileBuffer= fManager.getTextFileBuffer(fPath);
+ if (deleteUnderlyingFile()) {
+ assertTrue(listener.count == 1);
+ assertTrue(listener.buffer == fileBuffer);
+ }
+
+ } finally {
+ fManager.disconnect(fPath, null);
+ }
+
+ } finally {
+ fManager.removeFileBufferListener(listener);
+ }
+ }
+
+ /*
+ * Test IFileBufferListener#underlyingFileMoved
+ */
+ public void test15() throws Exception {
+ class Listener extends FileBufferListener {
+
+ public IFileBuffer buffer;
+ public int count;
+ public IPath newLocation;
+
+ public void underlyingFileMoved(IFileBuffer buffer, IPath newLocation) {
+ ++count;
+ this.buffer= buffer;
+ this.newLocation= newLocation;
+ }
+ }
+
+ Listener listener= new Listener();
+ fManager.addFileBufferListener(listener);
+ try {
+ ITextFileBuffer fileBuffer= fManager.getTextFileBuffer(fPath);
+ assertTrue(listener.count == 0 && listener.buffer == null);
+
+ fManager.connect(fPath, null);
+ try {
+
+ fileBuffer= fManager.getTextFileBuffer(fPath);
+ IPath newLocation= moveUnderlyingFile();
+ if (newLocation != null) {
+ assertTrue(listener.count == 1);
+ assertTrue(listener.buffer == fileBuffer);
+ assertEquals(listener.newLocation, newLocation);
+ }
+
+ } finally {
+ fManager.disconnect(fPath, null);
+ }
+
+ } finally {
+ fManager.removeFileBufferListener(listener);
+ }
+ }
+
+ /*
+ * Test IFileBufferListener#stateChanging for external changes
+ */
+ public void test16_1() throws Exception {
+ class Listener extends FileBufferListener {
+
+ public IFileBuffer buffer;
+ public int count;
+
+ public void stateChanging(IFileBuffer buffer) {
+ ++count;
+ this.buffer= buffer;
+ }
+ }
+
+ Listener listener= new Listener();
+ fManager.addFileBufferListener(listener);
+ try {
+ ITextFileBuffer fileBuffer= fManager.getTextFileBuffer(fPath);
+ assertTrue(listener.count == 0 && listener.buffer == null);
+
+ fManager.connect(fPath, null);
+ try {
+
+ fileBuffer= fManager.getTextFileBuffer(fPath);
+ if (modifyUnderlyingFile()) {
+ assertTrue(listener.count == 1);
+ assertTrue(listener.buffer == fileBuffer);
+ }
+
+ } finally {
+ fManager.disconnect(fPath, null);
+ }
+
+ } finally {
+ fManager.removeFileBufferListener(listener);
+ }
+ }
+
+ /*
+ * Test IFileBufferListener#stateChanging for external changes
+ */
+ public void test16_2() throws Exception {
+ class Listener extends FileBufferListener {
+
+ public IFileBuffer buffer;
+ public int count;
+
+ public void stateChanging(IFileBuffer buffer) {
+ ++count;
+ this.buffer= buffer;
+ }
+ }
+
+ Listener listener= new Listener();
+ fManager.addFileBufferListener(listener);
+ try {
+ ITextFileBuffer fileBuffer= fManager.getTextFileBuffer(fPath);
+ assertTrue(listener.count == 0 && listener.buffer == null);
+
+ fManager.connect(fPath, null);
+ try {
+
+ fileBuffer= fManager.getTextFileBuffer(fPath);
+ if (deleteUnderlyingFile()) {
+ assertTrue(listener.count == 1);
+ assertTrue(listener.buffer == fileBuffer);
+ }
+
+ } finally {
+ fManager.disconnect(fPath, null);
+ }
+
+ } finally {
+ fManager.removeFileBufferListener(listener);
+ }
+ }
+
+ /*
+ * Test IFileBufferListener#stateChanging for external changes
+ */
+ public void test16_3() throws Exception {
+ class Listener extends FileBufferListener {
+
+ public IFileBuffer buffer;
+ public int count;
+
+ public void stateChanging(IFileBuffer buffer) {
+ ++count;
+ this.buffer= buffer;
+ }
+ }
+
+ Listener listener= new Listener();
+ fManager.addFileBufferListener(listener);
+ try {
+ ITextFileBuffer fileBuffer= fManager.getTextFileBuffer(fPath);
+ assertTrue(listener.count == 0 && listener.buffer == null);
+
+ fManager.connect(fPath, null);
+ try {
+
+ fileBuffer= fManager.getTextFileBuffer(fPath);
+ if (moveUnderlyingFile() != null) {
+ assertTrue(listener.count == 1);
+ assertTrue(listener.buffer == fileBuffer);
+ }
+
+ } finally {
+ fManager.disconnect(fPath, null);
+ }
+
+ } finally {
+ fManager.removeFileBufferListener(listener);
+ }
+ }
+
+ /*
+ * Test IFileBufferListener#stateChanging for internal changes
+ */
+ public void test17_1() throws Exception {
+ class Listener extends FileBufferListener {
+
+ public IFileBuffer buffer;
+ public int count;
+
+ public void stateChanging(IFileBuffer buffer) {
+ ++count;
+ this.buffer= buffer;
+ }
+ }
+
+ Listener listener= new Listener();
+ fManager.addFileBufferListener(listener);
+ try {
+ ITextFileBuffer fileBuffer= fManager.getTextFileBuffer(fPath);
+ assertTrue(listener.count == 0 && listener.buffer == null);
+
+ fManager.connect(fPath, null);
+ try {
+
+ fileBuffer= fManager.getTextFileBuffer(fPath);
+ fileBuffer.validateState(null, null);
+
+ if (isStateValidationSupported()) {
+ assertTrue(listener.count == 1);
+ assertTrue(listener.buffer == fileBuffer);
+ }
+
+ } finally {
+ fManager.disconnect(fPath, null);
+ }
+
+ } finally {
+ fManager.removeFileBufferListener(listener);
+ }
+ }
+ /*
+ * Test IFileBufferListener#stateChanging for internal changes
+ */
+ public void test17_2() throws Exception {
+ class Listener extends FileBufferListener {
+
+ public IFileBuffer buffer;
+ public int count;
+
+ public void stateChanging(IFileBuffer buffer) {
+ ++count;
+ this.buffer= buffer;
+ }
+ }
+
+ Listener listener= new Listener();
+ fManager.addFileBufferListener(listener);
+ try {
+ ITextFileBuffer fileBuffer= fManager.getTextFileBuffer(fPath);
+ assertTrue(listener.count == 0 && listener.buffer == null);
+
+ fManager.connect(fPath, null);
+ try {
+
+ fileBuffer= fManager.getTextFileBuffer(fPath);
+ IDocument document= fileBuffer.getDocument();
+ document.replace(0, 0, "prefix");
+ fileBuffer.revert(null);
+
+ assertTrue(listener.count == 1);
+ assertTrue(listener.buffer == fileBuffer);
+
+ } finally {
+ fManager.disconnect(fPath, null);
+ }
+
+ } finally {
+ fManager.removeFileBufferListener(listener);
+ }
+ }
+
+ /*
+ * Test IFileBufferListener#stateChanging for internal changes
+ */
+ public void test17_3() throws Exception {
+ class Listener extends FileBufferListener {
+
+ public IFileBuffer buffer;
+ public int count;
+
+ public void stateChanging(IFileBuffer buffer) {
+ ++count;
+ this.buffer= buffer;
+ }
+ }
+
+ Listener listener= new Listener();
+ fManager.addFileBufferListener(listener);
+ try {
+ ITextFileBuffer fileBuffer= fManager.getTextFileBuffer(fPath);
+ assertTrue(listener.count == 0 && listener.buffer == null);
+
+ fManager.connect(fPath, null);
+ try {
+
+ fileBuffer= fManager.getTextFileBuffer(fPath);
+ IDocument document= fileBuffer.getDocument();
+ document.replace(0, 0, "prefix");
+ fileBuffer.commit(null, true);
+
+ assertTrue(listener.count == 1);
+ assertTrue(listener.buffer == fileBuffer);
+
+ } finally {
+ fManager.disconnect(fPath, null);
+ }
+
+ } finally {
+ fManager.removeFileBufferListener(listener);
}
}
}
diff --git a/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBuffersForExternalFiles.java b/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBuffersForExternalFiles.java
index bd826d9e6..65d0d6ecb 100644
--- a/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBuffersForExternalFiles.java
+++ b/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBuffersForExternalFiles.java
@@ -56,4 +56,25 @@ public class FileBuffersForExternalFiles extends FileBufferFunctions {
protected boolean isStateValidationSupported() {
return false;
}
+
+ /*
+ * @see org.eclipse.core.filebuffers.tests.FileBufferFunctions#deleteUnderlyingFile()
+ */
+ protected boolean deleteUnderlyingFile() throws Exception {
+ return false;
+ }
+
+ /*
+ * @see org.eclipse.core.filebuffers.tests.FileBufferFunctions#moveUnderlyingFile()
+ */
+ protected IPath moveUnderlyingFile() throws Exception {
+ return null;
+ }
+
+ /*
+ * @see org.eclipse.core.filebuffers.tests.FileBufferFunctions#modifyUnderlyingFile()
+ */
+ protected boolean modifyUnderlyingFile() throws Exception {
+ return false;
+ }
}
diff --git a/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBuffersForLinkedFiles.java b/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBuffersForLinkedFiles.java
index 32f07b168..98387221b 100644
--- a/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBuffersForLinkedFiles.java
+++ b/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBuffersForLinkedFiles.java
@@ -60,4 +60,37 @@ public class FileBuffersForLinkedFiles extends FileBufferFunctions {
protected boolean isStateValidationSupported() {
return true;
}
+
+ /*
+ * @see org.eclipse.core.filebuffers.tests.FileBufferFunctions#deleteUnderlyingFile()
+ */
+ protected boolean deleteUnderlyingFile() throws Exception {
+ IFile file= FileBuffers.getWorkspaceFileAtLocation(getPath());
+ file.delete(true, false, null);
+ return file.exists();
+ }
+
+ /*
+ * @see org.eclipse.core.filebuffers.tests.FileBufferFunctions#moveUnderlyingFile()
+ */
+ protected IPath moveUnderlyingFile() throws Exception {
+ IFile file= FileBuffers.getWorkspaceFileAtLocation(getPath());
+ ResourceHelper.createFolder("project/folderA");
+ IPath path= new Path("/project/folderA/MovedLinkedFile");
+ file.move(path, true, false, null);
+
+ file= FileBuffers.getWorkspaceFileAtLocation(path);
+ if (file != null && file.exists())
+ return path;
+
+ return null;
+ }
+
+ /*
+ * @see org.eclipse.core.filebuffers.tests.FileBufferFunctions#modifyUnderlyingFile()
+ */
+ protected boolean modifyUnderlyingFile() throws Exception {
+ // TODO Auto-generated method stub
+ return false;
+ }
}
diff --git a/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBuffersForNonExistingExternalFiles.java b/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBuffersForNonExistingExternalFiles.java
index 9b61d90dd..a984446b5 100644
--- a/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBuffersForNonExistingExternalFiles.java
+++ b/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBuffersForNonExistingExternalFiles.java
@@ -52,4 +52,25 @@ public class FileBuffersForNonExistingExternalFiles extends FileBufferFunctions
protected boolean isStateValidationSupported() {
return false;
}
+
+ /*
+ * @see org.eclipse.core.filebuffers.tests.FileBufferFunctions#deleteUnderlyingFile()
+ */
+ protected boolean deleteUnderlyingFile() throws Exception {
+ return false;
+ }
+
+ /*
+ * @see org.eclipse.core.filebuffers.tests.FileBufferFunctions#moveUnderlyingFile()
+ */
+ protected IPath moveUnderlyingFile() throws Exception {
+ return null;
+ }
+
+ /*
+ * @see org.eclipse.core.filebuffers.tests.FileBufferFunctions#modifyUnderlyingFile()
+ */
+ protected boolean modifyUnderlyingFile() throws Exception {
+ return false;
+ }
}
diff --git a/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBuffersForNonExistingWorkspaceFiles.java b/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBuffersForNonExistingWorkspaceFiles.java
index 23e11add5..22f745d43 100644
--- a/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBuffersForNonExistingWorkspaceFiles.java
+++ b/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBuffersForNonExistingWorkspaceFiles.java
@@ -55,4 +55,25 @@ public class FileBuffersForNonExistingWorkspaceFiles extends FileBufferFunctions
protected boolean isStateValidationSupported() {
return false;
}
+
+ /*
+ * @see org.eclipse.core.filebuffers.tests.FileBufferFunctions#deleteUnderlyingFile()
+ */
+ protected boolean deleteUnderlyingFile() throws Exception {
+ return false;
+ }
+
+ /*
+ * @see org.eclipse.core.filebuffers.tests.FileBufferFunctions#moveUnderlyingFile()
+ */
+ protected IPath moveUnderlyingFile() throws Exception {
+ return null;
+ }
+
+ /*
+ * @see org.eclipse.core.filebuffers.tests.FileBufferFunctions#modifyUnderlyingFile()
+ */
+ protected boolean modifyUnderlyingFile() throws Exception {
+ return false;
+ }
}
diff --git a/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBuffersForWorkspaceFiles.java b/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBuffersForWorkspaceFiles.java
index eeb8cf767..e2879f55e 100644
--- a/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBuffersForWorkspaceFiles.java
+++ b/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBuffersForWorkspaceFiles.java
@@ -10,10 +10,14 @@
*******************************************************************************/
package org.eclipse.core.filebuffers.tests;
+import java.io.File;
+
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
import org.eclipse.core.filebuffers.FileBuffers;
@@ -42,4 +46,40 @@ public class FileBuffersForWorkspaceFiles extends FileBufferFunctions {
protected boolean isStateValidationSupported() {
return true;
}
+
+ /*
+ * @see org.eclipse.core.filebuffers.tests.FileBufferFunctions#deleteUnderlyingFile()
+ */
+ protected boolean deleteUnderlyingFile() throws Exception {
+ IFile file= FileBuffers.getWorkspaceFileAtLocation(getPath());
+ file.delete(true, false, null);
+ return file.exists();
+ }
+
+ /*
+ * @see org.eclipse.core.filebuffers.tests.FileBufferFunctions#moveUnderlyingFile()
+ */
+ protected IPath moveUnderlyingFile() throws Exception {
+ IFile file= FileBuffers.getWorkspaceFileAtLocation(getPath());
+ ResourceHelper.createFolder("project/folderA/folderB/folderC");
+ IPath path= new Path("/project/folderA/folderB/folderC/MovedWorkspaceFile");
+ file.move(path, true, false, null);
+
+ file= FileBuffers.getWorkspaceFileAtLocation(path);
+ if (file != null && file.exists())
+ return path;
+
+ return null;
+ }
+
+ /*
+ * @see org.eclipse.core.filebuffers.tests.FileBufferFunctions#modifyUnderlyingFile()
+ */
+ protected boolean modifyUnderlyingFile() throws Exception {
+ File file= FileBuffers.getSystemFileAtLocation(getPath());
+ FileTool.write(file.getAbsolutePath(), new StringBuffer("Changed content of workspace file"));
+ IFile iFile= FileBuffers.getWorkspaceFileAtLocation(getPath());
+ iFile.refreshLocal(IResource.DEPTH_INFINITE, null);
+ return true;
+ }
}

Back to the top