Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorspingel2010-02-08 03:09:05 +0000
committerspingel2010-02-08 03:09:05 +0000
commit3eafa16f874c738a0ab2210adc412d2a4e7762c1 (patch)
treed5fd6f797cc094d8f9194d70fc225c9d402c50bb /org.eclipse.mylyn.tasks.tests
parent82f91f6e1870726df4fd0644852ada1c2f70cc59 (diff)
downloadorg.eclipse.mylyn.tasks-3eafa16f874c738a0ab2210adc412d2a4e7762c1.tar.gz
org.eclipse.mylyn.tasks-3eafa16f874c738a0ab2210adc412d2a4e7762c1.tar.xz
org.eclipse.mylyn.tasks-3eafa16f874c738a0ab2210adc412d2a4e7762c1.zip
NEW - bug 301185: empty file created when attachment download fails
https://bugs.eclipse.org/bugs/show_bug.cgi?id=301185
Diffstat (limited to 'org.eclipse.mylyn.tasks.tests')
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskAttachmentTest.java16
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/connector/MockAttachmentHandler.java9
2 files changed, 25 insertions, 0 deletions
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskAttachmentTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskAttachmentTest.java
index 377b76ef1..284189629 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskAttachmentTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskAttachmentTest.java
@@ -16,6 +16,7 @@ import java.io.RandomAccessFile;
import junit.framework.TestCase;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Status;
import org.eclipse.mylyn.internal.tasks.core.TaskAttachment;
import org.eclipse.mylyn.internal.tasks.core.TaskRepositoryManager;
@@ -109,4 +110,19 @@ public class TaskAttachmentTest extends TestCase {
}
assertEquals(expected, new String(data));
}
+
+ public void testDownloadAttachmentJobExceptionThrown() throws Exception {
+ File file = File.createTempFile("mylyn", null);
+ file.delete();
+
+ attachmentHandler.setException(new CoreException(Status.CANCEL_STATUS));
+
+ DownloadAttachmentJob job = new DownloadAttachmentJob(attachment, file);
+ job.schedule();
+ job.join();
+
+ assertEquals(Status.OK_STATUS, job.getResult());
+ assertFalse(file.exists());
+ }
+
}
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/connector/MockAttachmentHandler.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/connector/MockAttachmentHandler.java
index ec2fe6364..5d5ed1e79 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/connector/MockAttachmentHandler.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/connector/MockAttachmentHandler.java
@@ -27,8 +27,14 @@ import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
*/
public class MockAttachmentHandler extends AbstractTaskAttachmentHandler {
+ private CoreException exception;
+
private byte[] data;
+ public void setException(CoreException exception) {
+ this.exception = exception;
+ }
+
public void setAttachmentData(byte[] data) {
this.data = data;
}
@@ -46,6 +52,9 @@ public class MockAttachmentHandler extends AbstractTaskAttachmentHandler {
@Override
public InputStream getContent(TaskRepository repository, ITask task, TaskAttribute attachmentAttribute,
IProgressMonitor monitor) throws CoreException {
+ if (exception != null) {
+ throw exception;
+ }
return new ByteArrayInputStream(data);
}

Back to the top