Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid King2014-08-29 19:18:19 +0000
committerDavid King2014-08-30 00:30:00 +0000
commit44162f71e128ec940d1c8ce79103fa8b8a6f53c6 (patch)
treeba1e39b1081d00ad73bed414d563d81448e81362 /org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla
parentbbf3291895d4a3b6afa4a61741c99968bda78728 (diff)
downloadorg.eclipse.mylyn.tasks-44162f71e128ec940d1c8ce79103fa8b8a6f53c6.tar.gz
org.eclipse.mylyn.tasks-44162f71e128ec940d1c8ce79103fa8b8a6f53c6.tar.xz
org.eclipse.mylyn.tasks-44162f71e128ec940d1c8ce79103fa8b8a6f53c6.zip
442726: Attachments with unicode characters in file names get submittedR_3_13_0e_4_4_m_3_13_x
wrongly Change-Id: Ib46683040f56fb0d524108ada844ef0d76a06907 Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=442726 Signed-off-by: David King <david.king@tasktop.com>
Diffstat (limited to 'org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla')
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaAttachmentHandlerTest.java53
1 files changed, 53 insertions, 0 deletions
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaAttachmentHandlerTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaAttachmentHandlerTest.java
index 3f278c6da..4db4e8fbf 100644
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaAttachmentHandlerTest.java
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaAttachmentHandlerTest.java
@@ -19,6 +19,7 @@ import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.OutputStream;
import java.util.Date;
+import java.util.List;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
@@ -311,6 +312,58 @@ public class BugzillaAttachmentHandlerTest extends AbstractBugzillaTest {
assertTrue(attachFile.delete());
}
+ public void testAttachmentWithUnicode() throws Exception {
+ testAttachmentWithSpecialCharacters("\u00E7\u00F1\u00A5\u20AC\u00A3\u00BD\u00BC\u03B2\u03B8\u53F0\u5317\u3096\u3097\uFF73");
+ }
+
+ public void testAttachmentWithSpecialCharacters() throws Exception {
+ testAttachmentWithSpecialCharacters("~`!@#$%^&()_-+={[}];',");
+ }
+
+ private void testAttachmentWithSpecialCharacters(String specialCharacters) throws Exception {
+ TaskData taskData = BugzillaFixture.current().createTask(PrivilegeLevel.USER, null, null);
+ assertNotNull(taskData);
+
+ TaskAttribute attachmentAttr = taskData.getAttributeMapper().createTaskAttachment(taskData);
+ TaskAttachmentMapper attachmentMapper = TaskAttachmentMapper.createFrom(attachmentAttr);
+
+ String description = "Test attachment " + specialCharacters + System.currentTimeMillis();
+ attachmentMapper.setDescription(description);
+ attachmentMapper.setContentType("text/plain");
+ attachmentMapper.setPatch(false);
+ attachmentMapper.applyTo(attachmentAttr);
+
+ String filename = "test" + specialCharacters + System.currentTimeMillis() + ".txt";
+ File attachFile = new File(filename);
+ attachFile.createNewFile();
+ attachFile.deleteOnExit();
+ BufferedWriter write = new BufferedWriter(new FileWriter(attachFile));
+ write.write("test file content");
+ write.close();
+
+ FileTaskAttachmentSource attachment = new FileTaskAttachmentSource(attachFile);
+ attachment.setContentType("text/plain");
+ attachment.setDescription(description);
+ attachment.setName(filename);
+
+ client.postAttachment(taskData.getTaskId(), attachmentMapper.getComment(), attachment, attachmentAttr,
+ new NullProgressMonitor());
+
+ taskData = BugzillaFixture.current().getTask(taskData.getTaskId(), client);
+ assertNotNull(taskData);
+ List<TaskAttribute> attachmentAttrs = taskData.getAttributeMapper().getAttributesByType(taskData,
+ TaskAttribute.TYPE_ATTACHMENT);
+ assertEquals(1, attachmentAttrs.size());
+
+ attachmentMapper = TaskAttachmentMapper.createFrom(attachmentAttrs.get(0));
+ assertEquals(description, attachmentMapper.getDescription());
+ assertEquals(filename, attachmentMapper.getFileName());
+ assertEquals("text/plain", attachmentMapper.getContentType());
+ assertEquals(Boolean.FALSE, attachmentMapper.isPatch());
+
+ assertTrue(attachFile.delete());
+ }
+
private void assertFileEmptyError(Exception e) {
if (BugzillaFixture.current().getBugzillaVersion().compareTo(BugzillaVersion.BUGZILLA_4_5_2) >= 0) {
assertEquals("An unknown repository error has occurred: file is empty", e.getMessage());

Back to the top