Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNatasha Carson2019-01-28 17:47:46 -0500
committerNatasha Carson2019-01-28 18:56:03 -0500
commitcdf66b6641ef4ffbe9da189f96a6744fc2a3f0bd (patch)
treea0245ea173f057821ad7eb45d1e348bbe8b43b43 /connector-bugzilla-rest
parent552922712edf3a1c49f00e9662ccac27462cfcff (diff)
downloadorg.eclipse.mylyn.tasks-cdf66b6641ef4ffbe9da189f96a6744fc2a3f0bd.tar.gz
org.eclipse.mylyn.tasks-cdf66b6641ef4ffbe9da189f96a6744fc2a3f0bd.tar.xz
org.eclipse.mylyn.tasks-cdf66b6641ef4ffbe9da189f96a6744fc2a3f0bd.zip
543815: Mylyn should use buffered output streamsR_3_25_0m_3_25_x
Buffered output streams and replaced try-finally with try resource Change-Id: I504647dc1a608df3502158eded47a917e9be37df Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=543815 Signed-off-by: Natasha Carson <natasha.carson@tasktop.com>
Diffstat (limited to 'connector-bugzilla-rest')
-rw-r--r--connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/src/org/eclipse/mylyn/bugzilla/rest/core/tests/BugzillaRestClientTest.java106
1 files changed, 48 insertions, 58 deletions
diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/src/org/eclipse/mylyn/bugzilla/rest/core/tests/BugzillaRestClientTest.java b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/src/org/eclipse/mylyn/bugzilla/rest/core/tests/BugzillaRestClientTest.java
index 813942f5d..d73ae6e0c 100644
--- a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/src/org/eclipse/mylyn/bugzilla/rest/core/tests/BugzillaRestClientTest.java
+++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/src/org/eclipse/mylyn/bugzilla/rest/core/tests/BugzillaRestClientTest.java
@@ -412,8 +412,8 @@ public class BugzillaRestClientTest implements IFixtureJUnitClass {
taskData.getRoot()
.getAttribute(BugzillaRestCreateTaskSchema.getDefault().TARGET_MILESTONE.getKey())
.setValue("M2");
- RepositoryResponse reposonse = connector.getClient(actualFixture.repository()).postTaskData(taskData, null,
- null);
+ RepositoryResponse reposonse = connector.getClient(actualFixture.repository())
+ .postTaskData(taskData, null, null);
assertEquals(ResponseKind.TASK_CREATED, reposonse.getReposonseKind());
}
@@ -461,8 +461,8 @@ public class BugzillaRestClientTest implements IFixtureJUnitClass {
TaskMapper mapper1 = new TaskMapper(taskData);
connector.getTaskMapping(taskDataSubmit).merge(mapper1);
- RepositoryResponse reposonse = connector.getClient(actualFixture.repository()).postTaskData(taskDataSubmit,
- null, null);
+ RepositoryResponse reposonse = connector.getClient(actualFixture.repository())
+ .postTaskData(taskDataSubmit, null, null);
assertEquals(ResponseKind.TASK_CREATED, reposonse.getReposonseKind());
}
@@ -563,7 +563,8 @@ public class BugzillaRestClientTest implements IFixtureJUnitClass {
assertEquals(
IOUtils.toString(
CommonTestUtil.getResource(this, actualFixture.getTestDataFolder() + "/taskDataFlags.txt")),
- flags.toString()); }
+ flags.toString());
+ }
@Test
public void testUpdateTaskData() throws Exception {
@@ -597,8 +598,8 @@ public class BugzillaRestClientTest implements IFixtureJUnitClass {
changed.add(attribute);
//Act
- RepositoryResponse reposonse = connector.getClient(actualFixture.repository()).postTaskData(taskDataGet,
- changed, null);
+ RepositoryResponse reposonse = connector.getClient(actualFixture.repository())
+ .postTaskData(taskDataGet, changed, null);
assertNotNull(reposonse);
assertNotNull(reposonse.getReposonseKind());
assertThat(reposonse.getReposonseKind(), is(ResponseKind.TASK_UPDATED));
@@ -636,8 +637,8 @@ public class BugzillaRestClientTest implements IFixtureJUnitClass {
changed.add(attribute);
//Act
- RepositoryResponse reposonse = connector.getClient(actualFixture.repository()).postTaskData(taskDataGet,
- changed, null);
+ RepositoryResponse reposonse = connector.getClient(actualFixture.repository())
+ .postTaskData(taskDataGet, changed, null);
assertNotNull(reposonse);
assertNotNull(reposonse.getReposonseKind());
assertThat(reposonse.getReposonseKind(), is(ResponseKind.TASK_UPDATED));
@@ -700,18 +701,13 @@ public class BugzillaRestClientTest implements IFixtureJUnitClass {
BugzillaRestTaskAttachmentHandler attachmentHandler = new BugzillaRestTaskAttachmentHandler(connector);
ITask task = new TaskTask(actualFixture.repository().getConnectorKind(),
actualFixture.repository().getRepositoryUrl(), taskId);
-
- InputStream in = CommonTestUtil.getResource(this, "testdata/icons/bugzilla-logo.gif");
File file = File.createTempFile("attachment", null);
file.deleteOnExit();
- OutputStream out = new FileOutputStream(file);
- try {
+
+ try (OutputStream out = new FileOutputStream(file);
+ InputStream in = CommonTestUtil.getResource(this, "testdata/icons/bugzilla-logo.gif")) {
IOUtils.copy(in, out);
- } finally {
- in.close();
- out.close();
}
-
FileTaskAttachmentSource attachment = new FileTaskAttachmentSource(file);
attachment.setContentType("image/gif");
attachment.setDescription("My Attachment 2");
@@ -774,16 +770,11 @@ public class BugzillaRestClientTest implements IFixtureJUnitClass {
BugzillaRestTaskAttachmentHandler attachmentHandler = new BugzillaRestTaskAttachmentHandler(connector);
ITask task = new TaskTask(actualFixture.repository().getConnectorKind(),
actualFixture.repository().getRepositoryUrl(), taskId);
-
- InputStream in = CommonTestUtil.getResource(this, "testdata/AttachmentTest.txt");
File file = File.createTempFile("attachment", null);
file.deleteOnExit();
- OutputStream out = new FileOutputStream(file);
- try {
+ try (OutputStream out = new FileOutputStream(file);
+ InputStream in = CommonTestUtil.getResource(this, "testdata/AttachmentTest.txt")) {
IOUtils.copy(in, out);
- } finally {
- in.close();
- out.close();
}
FileTaskAttachmentSource attachment = new FileTaskAttachmentSource(file);
@@ -861,10 +852,11 @@ public class BugzillaRestClientTest implements IFixtureJUnitClass {
taskData.getRoot()
.getAttribute(BugzillaRestCreateTaskSchema.getDefault().TARGET_MILESTONE.getKey())
.setValue("M2");
- taskData.getRoot().getAttribute(BugzillaRestCreateTaskSchema.getDefault().CC.getKey()).setValue(
- "admin@mylyn.eclipse.org, tests@mylyn.eclipse.org");
- RepositoryResponse reposonse = connector.getClient(actualFixture.repository()).postTaskData(taskData, null,
- null);
+ taskData.getRoot()
+ .getAttribute(BugzillaRestCreateTaskSchema.getDefault().CC.getKey())
+ .setValue("admin@mylyn.eclipse.org, tests@mylyn.eclipse.org");
+ RepositoryResponse reposonse = connector.getClient(actualFixture.repository())
+ .postTaskData(taskData, null, null);
assertNotNull(reposonse);
assertNotNull(reposonse.getReposonseKind());
assertThat(reposonse.getReposonseKind(), is(ResponseKind.TASK_CREATED));
@@ -914,10 +906,11 @@ public class BugzillaRestClientTest implements IFixtureJUnitClass {
taskData.getRoot()
.getAttribute(BugzillaRestCreateTaskSchema.getDefault().TARGET_MILESTONE.getKey())
.setValue("M2");
- taskData.getRoot().getAttribute(BugzillaRestCreateTaskSchema.getDefault().BLOCKS.getKey()).setValue(
- taskIdRel[0] + ", " + taskIdRel[1]);
- RepositoryResponse reposonse = connector.getClient(actualFixture.repository()).postTaskData(taskData, null,
- null);
+ taskData.getRoot()
+ .getAttribute(BugzillaRestCreateTaskSchema.getDefault().BLOCKS.getKey())
+ .setValue(taskIdRel[0] + ", " + taskIdRel[1]);
+ RepositoryResponse reposonse = connector.getClient(actualFixture.repository())
+ .postTaskData(taskData, null, null);
assertNotNull(reposonse);
assertNotNull(reposonse.getReposonseKind());
assertThat(reposonse.getReposonseKind(), is(ResponseKind.TASK_CREATED));
@@ -967,10 +960,11 @@ public class BugzillaRestClientTest implements IFixtureJUnitClass {
taskData.getRoot()
.getAttribute(BugzillaRestCreateTaskSchema.getDefault().TARGET_MILESTONE.getKey())
.setValue("M2");
- taskData.getRoot().getAttribute(BugzillaRestCreateTaskSchema.getDefault().DEPENDS_ON.getKey()).setValue(
- taskIdRel[0] + ", " + taskIdRel[1]);
- RepositoryResponse reposonse = connector.getClient(actualFixture.repository()).postTaskData(taskData, null,
- null);
+ taskData.getRoot()
+ .getAttribute(BugzillaRestCreateTaskSchema.getDefault().DEPENDS_ON.getKey())
+ .setValue(taskIdRel[0] + ", " + taskIdRel[1]);
+ RepositoryResponse reposonse = connector.getClient(actualFixture.repository())
+ .postTaskData(taskData, null, null);
assertNotNull(reposonse);
assertNotNull(reposonse.getReposonseKind());
assertThat(reposonse.getReposonseKind(), is(ResponseKind.TASK_CREATED));
@@ -995,8 +989,8 @@ public class BugzillaRestClientTest implements IFixtureJUnitClass {
changed.add(attribute);
//Act
- RepositoryResponse reposonse = connector.getClient(actualFixture.repository()).postTaskData(taskDataGet,
- changed, null);
+ RepositoryResponse reposonse = connector.getClient(actualFixture.repository())
+ .postTaskData(taskDataGet, changed, null);
assertNotNull(reposonse);
assertNotNull(reposonse.getReposonseKind());
assertThat(reposonse.getReposonseKind(), is(ResponseKind.TASK_UPDATED));
@@ -1045,8 +1039,8 @@ public class BugzillaRestClientTest implements IFixtureJUnitClass {
changed.add(taskDataOld.getRoot().getAttribute(BugzillaRestTaskSchema.getDefault().BLOCKS.getKey()));
//Act
- RepositoryResponse reposonse = connector.getClient(actualFixture.repository()).postTaskData(taskDataGet,
- changed, null);
+ RepositoryResponse reposonse = connector.getClient(actualFixture.repository())
+ .postTaskData(taskDataGet, changed, null);
assertNotNull(reposonse);
assertNotNull(reposonse.getReposonseKind());
assertThat(reposonse.getReposonseKind(), is(ResponseKind.TASK_UPDATED));
@@ -1093,8 +1087,8 @@ public class BugzillaRestClientTest implements IFixtureJUnitClass {
changed.add(taskDataOld.getRoot().getAttribute(BugzillaRestTaskSchema.getDefault().BLOCKS.getKey()));
//Act
- RepositoryResponse reposonse = connector.getClient(actualFixture.repository()).postTaskData(taskDataGet,
- changed, null);
+ RepositoryResponse reposonse = connector.getClient(actualFixture.repository())
+ .postTaskData(taskDataGet, changed, null);
assertNotNull(reposonse);
assertNotNull(reposonse.getReposonseKind());
assertThat(reposonse.getReposonseKind(), is(ResponseKind.TASK_UPDATED));
@@ -1142,8 +1136,8 @@ public class BugzillaRestClientTest implements IFixtureJUnitClass {
changed.add(taskDataOld.getRoot().getAttribute(BugzillaRestTaskSchema.getDefault().DEPENDS_ON.getKey()));
//Act
- RepositoryResponse reposonse = connector.getClient(actualFixture.repository()).postTaskData(taskDataGet,
- changed, null);
+ RepositoryResponse reposonse = connector.getClient(actualFixture.repository())
+ .postTaskData(taskDataGet, changed, null);
assertNotNull(reposonse);
assertNotNull(reposonse.getReposonseKind());
assertThat(reposonse.getReposonseKind(), is(ResponseKind.TASK_UPDATED));
@@ -1191,8 +1185,8 @@ public class BugzillaRestClientTest implements IFixtureJUnitClass {
changed.add(taskDataOld.getRoot().getAttribute(BugzillaRestTaskSchema.getDefault().DEPENDS_ON.getKey()));
//Act
- RepositoryResponse reposonse = connector.getClient(actualFixture.repository()).postTaskData(taskDataGet,
- changed, null);
+ RepositoryResponse reposonse = connector.getClient(actualFixture.repository())
+ .postTaskData(taskDataGet, changed, null);
assertNotNull(reposonse);
assertNotNull(reposonse.getReposonseKind());
assertThat(reposonse.getReposonseKind(), is(ResponseKind.TASK_UPDATED));
@@ -1268,8 +1262,8 @@ public class BugzillaRestClientTest implements IFixtureJUnitClass {
}
//Act
- RepositoryResponse reposonse = connector.getClient(actualFixture.repository()).postTaskData(taskDataGet,
- changed, null);
+ RepositoryResponse reposonse = connector.getClient(actualFixture.repository())
+ .postTaskData(taskDataGet, changed, null);
assertNotNull(reposonse);
assertNotNull(reposonse.getReposonseKind());
assertThat(reposonse.getReposonseKind(), is(ResponseKind.TASK_UPDATED));
@@ -1385,8 +1379,8 @@ public class BugzillaRestClientTest implements IFixtureJUnitClass {
}
}
- RepositoryResponse reposonse = connector.getClient(actualFixture.repository()).postTaskData(taskDataGet,
- changed, null);
+ RepositoryResponse reposonse = connector.getClient(actualFixture.repository())
+ .postTaskData(taskDataGet, changed, null);
assertNotNull(reposonse);
assertNotNull(reposonse.getReposonseKind());
assertThat(reposonse.getReposonseKind(), is(ResponseKind.TASK_UPDATED));
@@ -1575,8 +1569,8 @@ public class BugzillaRestClientTest implements IFixtureJUnitClass {
}
}
- RepositoryResponse reposonse = connector.getClient(actualFixture.repository()).postTaskData(taskDataGet,
- changed, null);
+ RepositoryResponse reposonse = connector.getClient(actualFixture.repository())
+ .postTaskData(taskDataGet, changed, null);
assertNotNull(reposonse);
assertNotNull(reposonse.getReposonseKind());
assertThat(reposonse.getReposonseKind(), is(ResponseKind.TASK_UPDATED));
@@ -1781,15 +1775,11 @@ public class BugzillaRestClientTest implements IFixtureJUnitClass {
ITask task = new TaskTask(actualFixture.repository().getConnectorKind(),
actualFixture.repository().getRepositoryUrl(), taskId);
- InputStream in = CommonTestUtil.getResource(this, "testdata/AttachmentTest.txt");
File file = File.createTempFile("attachment", null);
file.deleteOnExit();
- OutputStream out = new FileOutputStream(file);
- try {
+ try (OutputStream out = new FileOutputStream(file);
+ InputStream in = CommonTestUtil.getResource(this, "testdata/AttachmentTest.txt")) {
IOUtils.copy(in, out);
- } finally {
- in.close();
- out.close();
}
FileTaskAttachmentSource attachment = new FileTaskAttachmentSource(file);

Back to the top