summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.http.test/tst/org
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jgit.http.test/tst/org')
-rw-r--r--org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/ProtocolErrorTest.java10
-rw-r--r--org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SetAdditionalHeadersTest.java5
-rw-r--r--org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerTest.java11
3 files changed, 7 insertions, 19 deletions
diff --git a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/ProtocolErrorTest.java b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/ProtocolErrorTest.java
index 87d0bad85c..a1baae3b26 100644
--- a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/ProtocolErrorTest.java
+++ b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/ProtocolErrorTest.java
@@ -149,19 +149,15 @@ public class ProtocolErrorTest extends HttpTestCase {
c.setRequestProperty("Content-Type",
GitSmartHttpTools.RECEIVE_PACK_REQUEST_TYPE);
c.setFixedLengthStreamingMode(reqbin.length);
- OutputStream out = c.getOutputStream();
- try {
+ try (OutputStream out = c.getOutputStream()) {
out.write(reqbin);
- } finally {
- out.close();
}
assertEquals(200, c.getResponseCode());
assertEquals(GitSmartHttpTools.RECEIVE_PACK_RESULT_TYPE,
c.getContentType());
- InputStream rawin = c.getInputStream();
- try {
+ try (InputStream rawin = c.getInputStream()) {
PacketLineIn pckin = new PacketLineIn(rawin);
assertEquals("unpack error "
+ JGitText.get().packfileIsTruncatedNoParam,
@@ -169,8 +165,6 @@ public class ProtocolErrorTest extends HttpTestCase {
assertEquals("ng refs/objects/A n/a (unpacker error)",
pckin.readString());
assertSame(PacketLineIn.END, pckin.readString());
- } finally {
- rawin.close();
}
} finally {
c.disconnect();
diff --git a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SetAdditionalHeadersTest.java b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SetAdditionalHeadersTest.java
index ef8daec31f..fbc54f3872 100644
--- a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SetAdditionalHeadersTest.java
+++ b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SetAdditionalHeadersTest.java
@@ -107,8 +107,7 @@ public class SetAdditionalHeadersTest extends HttpTestCase {
assertEquals("http", remoteURI.getScheme());
- Transport t = Transport.open(dst, remoteURI);
- try {
+ try (Transport t = Transport.open(dst, remoteURI)) {
assertTrue("isa TransportHttp", t instanceof TransportHttp);
assertTrue("isa HttpTransport", t instanceof HttpTransport);
@@ -117,8 +116,6 @@ public class SetAdditionalHeadersTest extends HttpTestCase {
headers.put("AnotherKey", "someValue");
((TransportHttp) t).setAdditionalHeaders(headers);
t.openFetch();
- } finally {
- t.close();
}
List<AccessEvent> requests = getRequests();
diff --git a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerTest.java b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerTest.java
index 6ded21f8cc..d8541aa13d 100644
--- a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerTest.java
+++ b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerTest.java
@@ -267,9 +267,9 @@ public class SmartClientSmartServerTest extends HttpTestCase {
final HttpServletResponse r = (HttpServletResponse) response;
r.setContentType("text/plain");
r.setCharacterEncoding("UTF-8");
- PrintWriter w = r.getWriter();
- w.print("OK");
- w.close();
+ try (PrintWriter w = r.getWriter()) {
+ w.print("OK");
+ }
}
@Override
@@ -397,11 +397,8 @@ public class SmartClientSmartServerTest extends HttpTestCase {
assertTrue("isa TransportHttp", t instanceof TransportHttp);
assertTrue("isa HttpTransport", t instanceof HttpTransport);
- FetchConnection c = t.openFetch();
- try {
+ try (FetchConnection c = t.openFetch()) {
map = c.getRefsMap();
- } finally {
- c.close();
}
}