You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by co...@apache.org on 2016/04/07 13:25:35 UTC

[2/2] cxf git commit: Close a socket

Close a socket


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/8cfbd97e
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/8cfbd97e
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/8cfbd97e

Branch: refs/heads/3.1.x-fixes
Commit: 8cfbd97e0e394dca4f67b4d9bef92380f839f23b
Parents: c57a949
Author: Colm O hEigeartaigh <co...@apache.org>
Authored: Thu Apr 7 11:50:54 2016 +0100
Committer: Colm O hEigeartaigh <co...@apache.org>
Committed: Thu Apr 7 11:52:02 2016 +0100

----------------------------------------------------------------------
 .../jaxrs/JAXRSClientServerSpringBookTest.java  | 35 ++++++++++----------
 1 file changed, 18 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/8cfbd97e/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java
index f15c640..5994269 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java
@@ -785,24 +785,25 @@ public class JAXRSClientServerSpringBookTest extends AbstractBusClientServerTest
     @Test
     public void testRetrieveBookAegis3() throws Exception {
         
-        Socket s = new Socket("localhost", Integer.parseInt(PORT));
-        
-        InputStream is = this.getClass().getResourceAsStream("resources/retrieveRequest.txt");
-        byte[] bytes = IOUtils.readBytesFromStream(is);
-        s.getOutputStream().write(bytes);
-        s.getOutputStream().flush();
-        
-        BufferedReader r = new BufferedReader(new InputStreamReader(s.getInputStream()));
-        StringBuilder sb = new StringBuilder();
-        String str = null;
-        while ((str = r.readLine()) != null) {
-            sb.append(str);
-        }
+        try (Socket s = new Socket("localhost", Integer.parseInt(PORT));
+            InputStream is = this.getClass().getResourceAsStream("resources/retrieveRequest.txt")) {
+        
+            byte[] bytes = IOUtils.readBytesFromStream(is);
+            s.getOutputStream().write(bytes);
+            s.getOutputStream().flush();
+        
+            BufferedReader r = new BufferedReader(new InputStreamReader(s.getInputStream()));
+            StringBuilder sb = new StringBuilder();
+            String str = null;
+            while ((str = r.readLine()) != null) {
+                sb.append(str);
+            }
         
-        String aegisData = sb.toString();
-        s.getInputStream().close();
-        s.close();
-        assertTrue(aegisData.contains("CXF in Action - 2"));
+            String aegisData = sb.toString();
+            s.getInputStream().close();
+            s.close();
+            assertTrue(aegisData.contains("CXF in Action - 2"));
+        }
         
     }