diff options
author | Sam Davis | 2016-01-07 22:04:14 +0000 |
---|---|---|
committer | Gerrit Code Review @ Eclipse.org | 2016-01-11 23:34:30 +0000 |
commit | b8c3dc881367e5895382a0c6a70ae462f357cf4f (patch) | |
tree | bcf8c9d50ed92b2fc346556b42bf8bcc9afe960d | |
parent | 29ad84fef70ab643c52fce1b21f24bdc0657c7d0 (diff) | |
download | org.eclipse.mylyn.tasks-b8c3dc881367e5895382a0c6a70ae462f357cf4f.tar.gz org.eclipse.mylyn.tasks-b8c3dc881367e5895382a0c6a70ae462f357cf4f.tar.xz org.eclipse.mylyn.tasks-b8c3dc881367e5895382a0c6a70ae462f357cf4f.zip |
tests should throw exceptions instead of catching and failing
Change-Id: If80ff6bd2b9258a4674365721315fea77d4257a2
2 files changed, 26 insertions, 72 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 c3508f1c4..b7992cd5a 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 @@ -86,12 +86,8 @@ public class BugzillaAttachmentHandlerTest extends AbstractBugzillaTest { attachment.setDescription("Description"); attachment.setName("My Attachment 1"); - try { - client.postAttachment(taskData.getTaskId(), attachmentMapper.getComment(), attachment, attrAttachment, - new NullProgressMonitor()); - } catch (Exception e) { - fail("never reach this!"); - } + client.postAttachment(taskData.getTaskId(), attachmentMapper.getComment(), attachment, attrAttachment, + new NullProgressMonitor()); taskData = BugzillaFixture.current().getTask(taskData.getTaskId(), client); assertNotNull(taskData); numAttached = taskData.getAttributeMapper().getAttributesByType(taskData, TaskAttribute.TYPE_ATTACHMENT).size(); @@ -297,12 +293,8 @@ public class BugzillaAttachmentHandlerTest extends AbstractBugzillaTest { /* Test uploading a proper file */ write.write("test file"); write.close(); - try { - client.postAttachment(taskData.getTaskId(), attachmentMapper.getComment(), attachment, attrAttachment, - new NullProgressMonitor()); - } catch (Exception e) { - fail("never reach this!"); - } + client.postAttachment(taskData.getTaskId(), attachmentMapper.getComment(), attachment, attrAttachment, + new NullProgressMonitor()); taskData = BugzillaFixture.current().getTask(taskData.getTaskId(), client); assertNotNull(taskData); @@ -313,7 +305,8 @@ public class BugzillaAttachmentHandlerTest extends AbstractBugzillaTest { } public void testAttachmentWithUnicode() throws Exception { - testAttachmentWithSpecialCharacters("\u00E7\u00F1\u00A5\u20AC\u00A3\u00BD\u00BC\u03B2\u03B8\u53F0\u5317\u3096\u3097\uFF73"); + testAttachmentWithSpecialCharacters( + "\u00E7\u00F1\u00A5\u20AC\u00A3\u00BD\u00BC\u03B2\u03B8\u53F0\u5317\u3096\u3097\uFF73"); } public void testAttachmentWithSpecialCharacters() throws Exception { @@ -424,12 +417,8 @@ public class BugzillaAttachmentHandlerTest extends AbstractBugzillaTest { } else { obsolete.setValue("1"); //$NON-NLS-1$ } - try { - ((BugzillaTaskDataHandler) connector.getTaskDataHandler()).postUpdateAttachment(repository, attachment, - "update", new NullProgressMonitor()); - } catch (CoreException e) { - fail("CoreException expected reached"); - } + ((BugzillaTaskDataHandler) connector.getTaskDataHandler()).postUpdateAttachment(repository, attachment, + "update", new NullProgressMonitor()); } @@ -458,13 +447,8 @@ public class BugzillaAttachmentHandlerTest extends AbstractBugzillaTest { attachment.setDescription(AttachmentUtil.CONTEXT_DESCRIPTION); attachment.setName("mylyn-context.zip"); - try { - client.postAttachment(taskData.getTaskId(), attachmentMapper.getComment(), attachment, attrAttachment, - new NullProgressMonitor()); - } catch (Exception e) { - fail("never reach this!"); - } - + client.postAttachment(taskData.getTaskId(), attachmentMapper.getComment(), attachment, attrAttachment, + new NullProgressMonitor()); } public void testObsoleteAttachment() throws Exception { @@ -543,7 +527,8 @@ public class BugzillaAttachmentHandlerTest extends AbstractBugzillaTest { File sourceContextFile = TasksUiPlugin.getContextStore().getFileForContext(task); sourceContextFile.createNewFile(); sourceContextFile.deleteOnExit(); - repository.setCredentials(AuthenticationType.REPOSITORY, new AuthenticationCredentials("wrong", "wrong"), false); + repository.setCredentials(AuthenticationType.REPOSITORY, new AuthenticationCredentials("wrong", "wrong"), + false); try { FileTaskAttachmentSource attachment = new FileTaskAttachmentSource(sourceContextFile); attachment.setContentType(FileTaskAttachmentSource.APPLICATION_OCTET_STREAM); @@ -603,12 +588,8 @@ public class BugzillaAttachmentHandlerTest extends AbstractBugzillaTest { attachment.setDescription("Description"); attachment.setName("My Attachment 1"); - try { - client.postAttachment(taskData.getTaskId(), attachmentMapper.getComment(), attachment, attrAttachment, - new NullProgressMonitor()); - } catch (Exception e) { - fail("never reach this!"); - } + client.postAttachment(taskData.getTaskId(), attachmentMapper.getComment(), attachment, attrAttachment, + new NullProgressMonitor()); taskData = BugzillaFixture.current().getTask(taskData.getTaskId(), client); assertNotNull(taskData); numAttached = taskData.getAttributeMapper().getAttributesByType(taskData, TaskAttribute.TYPE_ATTACHMENT).size(); @@ -675,12 +656,8 @@ public class BugzillaAttachmentHandlerTest extends AbstractBugzillaTest { attachment.setDescription("Description"); attachment.setName("My Attachment 1"); - try { - client.postAttachment(taskData.getTaskId(), attachmentMapper.getComment(), attachment, attrAttachment, - new NullProgressMonitor()); - } catch (Exception e) { - fail("never reach this!"); - } + client.postAttachment(taskData.getTaskId(), attachmentMapper.getComment(), attachment, attrAttachment, + new NullProgressMonitor()); taskData = BugzillaFixture.current().getTask(taskData.getTaskId(), client); assertNotNull(taskData); numAttached = taskData.getAttributeMapper().getAttributesByType(taskData, TaskAttribute.TYPE_ATTACHMENT).size(); @@ -702,8 +679,6 @@ public class BugzillaAttachmentHandlerTest extends AbstractBugzillaTest { } catch (CoreException e) { String message = e.getMessage(); assertTrue(message.startsWith("invalid attachment id: ")); - } catch (Exception e) { - fail("CoreException expected"); } finally { out.close(); } diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/support/BugzillaHarness.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/support/BugzillaHarness.java index 1edcd306e..835bd93b6 100644 --- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/support/BugzillaHarness.java +++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/support/BugzillaHarness.java @@ -13,7 +13,6 @@ package org.eclipse.mylyn.bugzilla.tests.support; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.fail; import java.io.BufferedWriter; import java.io.File; @@ -200,12 +199,8 @@ public class BugzillaHarness { attachment.setContentType("text/plain"); attachment.setDescription("Description"); attachment.setName("My Attachment 1"); - try { - priviledgedClient().postAttachment(taskData.getTaskId(), attachmentMapper.getComment(), attachment, - attrAttachment, new NullProgressMonitor()); - } catch (Exception e) { - fail("never reach this!"); - } + priviledgedClient().postAttachment(taskData.getTaskId(), attachmentMapper.getComment(), attachment, + attrAttachment, new NullProgressMonitor()); taskData = fixture.getTask(taskData.getTaskId(), priviledgedClient()); assertNotNull(taskData); @@ -386,12 +381,8 @@ public class BugzillaHarness { attachment.setContentType("text/plain"); attachment.setDescription("My Attachment 1"); attachment.setName("My Attachment 1"); - try { - priviledgedClient().postAttachment(taskData.getTaskId(), attachmentMapper.getComment(), attachment, - attrAttachment, new NullProgressMonitor()); - } catch (Exception e) { - fail("never reach this!"); - } + priviledgedClient().postAttachment(taskData.getTaskId(), attachmentMapper.getComment(), attachment, + attrAttachment, new NullProgressMonitor()); taskData = fixture.getTask(taskData.getTaskId(), priviledgedClient()); assertNotNull(taskData); @@ -414,12 +405,8 @@ public class BugzillaHarness { attachment.setContentType("text/plain"); attachment.setDescription("My Attachment 2"); attachment.setName("My Attachment 2"); - try { - priviledgedClient().postAttachment(taskData.getTaskId(), attachmentMapper.getComment(), attachment, - attrAttachment, new NullProgressMonitor()); - } catch (Exception e) { - fail("never reach this!"); - } + priviledgedClient().postAttachment(taskData.getTaskId(), attachmentMapper.getComment(), attachment, + attrAttachment, new NullProgressMonitor()); taskData = fixture.getTask(taskData.getTaskId(), priviledgedClient()); assertNotNull(taskData); @@ -446,12 +433,8 @@ public class BugzillaHarness { if (child != null) { child.setValue("1"); } - try { - priviledgedClient().postAttachment(taskData.getTaskId(), attachmentMapper.getComment(), attachment, - attrAttachment, new NullProgressMonitor()); - } catch (Exception e) { - fail("never reach this!"); - } + priviledgedClient().postAttachment(taskData.getTaskId(), attachmentMapper.getComment(), attachment, + attrAttachment, new NullProgressMonitor()); taskData = fixture.getTask(taskData.getTaskId(), priviledgedClient()); assertNotNull(taskData); @@ -478,12 +461,8 @@ public class BugzillaHarness { if (child != null) { child.setValue("1"); } - try { - priviledgedClient().postAttachment(taskData.getTaskId(), attachmentMapper.getComment(), attachment, - attrAttachment, new NullProgressMonitor()); - } catch (Exception e) { - fail("never reach this!"); - } + priviledgedClient().postAttachment(taskData.getTaskId(), attachmentMapper.getComment(), attachment, + attrAttachment, new NullProgressMonitor()); taskData = fixture.getTask(taskData.getTaskId(), priviledgedClient()); assertNotNull(taskData); |