Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDani Megert2005-02-21 10:49:03 +0000
committerDani Megert2005-02-21 10:49:03 +0000
commit1d7c05637aadbce6dba6e6e8c5c61521156ab2fd (patch)
tree8a7194d0183da0d108dcf2d740c5565ab6ef9852 /org.eclipse.core.filebuffers.tests
parentdad1c82ecb139d616fb831e6da77bed6d5b89652 (diff)
downloadeclipse.platform.text-1d7c05637aadbce6dba6e6e8c5c61521156ab2fd.tar.gz
eclipse.platform.text-1d7c05637aadbce6dba6e6e8c5c61521156ab2fd.tar.xz
eclipse.platform.text-1d7c05637aadbce6dba6e6e8c5c61521156ab2fd.zip
Notify via ISafeRunnable
Diffstat (limited to 'org.eclipse.core.filebuffers.tests')
-rw-r--r--org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBufferFunctions.java57
1 files changed, 56 insertions, 1 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 41ecd74a5..2c7174e75 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
@@ -14,9 +14,10 @@ import java.io.File;
import junit.framework.TestCase;
+import org.eclipse.core.runtime.IPath;
+
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IPath;
import org.eclipse.core.filebuffers.FileBuffers;
import org.eclipse.core.filebuffers.IFileBuffer;
@@ -1057,4 +1058,58 @@ public abstract class FileBufferFunctions extends TestCase {
fManager.disconnect(fPath, null);
}
}
+
+ /*
+ * Test notification in case of failing listener.
+ */
+ public void test19() throws Exception {
+
+ class NotifiedListener extends FileBufferListener {
+
+ int notifyCount= 0;
+
+ public void bufferCreated(IFileBuffer buffer) {
+ notifyCount++;
+ }
+ public void bufferDisposed(IFileBuffer buffer) {
+ notifyCount++;
+ }
+ }
+
+ NotifiedListener notifyCounter1= new NotifiedListener();
+ NotifiedListener notifyCounter2= new NotifiedListener();
+ FileBufferListener failingListener= new FileBufferListener() {
+ public void bufferCreated(IFileBuffer buffer) {
+ int i= 1/0; // force error
+ }
+ public void bufferDisposed(IFileBuffer buffer) {
+ int i= 1/0; // force error
+ }
+ };
+
+ fManager.addFileBufferListener(notifyCounter1);
+ fManager.addFileBufferListener(failingListener);
+ fManager.addFileBufferListener(notifyCounter2);
+
+ fManager.connect(fPath, null);
+ try {
+ ITextFileBuffer buffer= fManager.getTextFileBuffer(fPath);
+ assertNotNull(buffer);
+
+ Class clazz= getAnnotationModelClass();
+ if (clazz != null) {
+ IAnnotationModel model= buffer.getAnnotationModel();
+ assertTrue(clazz.isInstance(model));
+ }
+
+ } finally {
+ fManager.disconnect(fPath, null);
+ fManager.removeFileBufferListener(notifyCounter1);
+ fManager.removeFileBufferListener(failingListener);
+ fManager.removeFileBufferListener(notifyCounter2);
+ }
+
+ assertEquals(2, notifyCounter1.notifyCount);
+ assertEquals(2, notifyCounter2.notifyCount);
+ }
}

Back to the top