cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject [2/6] cxf git commit: More Strema cleanup
Date Mon, 18 Apr 2016 23:24:08 GMT
More Strema cleanup


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

Branch: refs/heads/master-jaxrs-2.1
Commit: 679835fe23883ce9937ecf1e88b0d448d56a2992
Parents: d151322
Author: Colm O hEigeartaigh <coheigea@apache.org>
Authored: Mon Apr 18 11:39:26 2016 +0100
Committer: Colm O hEigeartaigh <coheigea@apache.org>
Committed: Mon Apr 18 11:39:26 2016 +0100

----------------------------------------------------------------------
 .../jaxrs/provider/DataSourceProviderTest.java    | 18 ++++++++++--------
 .../cxf/systest/jaxws/ClientServerMiscTest.java   | 15 ++++++++-------
 .../cxf/systest/jaxws/ClientServerTest.java       |  1 +
 .../datasource/DataSourceProviderTest.java        | 10 ++++------
 .../cxf/systest/swa/ClientServerSwaTest.java      |  4 ++--
 5 files changed, 25 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/679835fe/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/DataSourceProviderTest.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/DataSourceProviderTest.java
b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/DataSourceProviderTest.java
index ca87769..8b51eba 100644
--- a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/DataSourceProviderTest.java
+++ b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/DataSourceProviderTest.java
@@ -76,12 +76,13 @@ public class DataSourceProviderTest extends Assert {
         DataSourceProvider<DataSource> p = new DataSourceProvider<DataSource>();
         DataSource ds = new InputStreamDataSource(new ByteArrayInputStream("image".getBytes()),

                                                   "image/png"); 
-        ByteArrayOutputStream os = new ByteArrayOutputStream(); 
         MultivaluedMap<String, Object> outHeaders = new MetadataMap<String, Object>();
         
-        p.writeTo(ds, DataSource.class, DataSource.class, new Annotation[]{}, 
-                   MediaType.valueOf("image/png"), outHeaders, os);
-        assertEquals("image", os.toString());
+        try (ByteArrayOutputStream os = new ByteArrayOutputStream()) {
+            p.writeTo(ds, DataSource.class, DataSource.class, new Annotation[]{}, 
+                    MediaType.valueOf("image/png"), outHeaders, os);
+            assertEquals("image", os.toString());
+        }
         assertEquals(0, outHeaders.size());
     }
     
@@ -91,11 +92,12 @@ public class DataSourceProviderTest extends Assert {
         p.setUseDataSourceContentType(true);
         DataSource ds = new InputStreamDataSource(new ByteArrayInputStream("image".getBytes()),

                                                   "image/png"); 
-        ByteArrayOutputStream os = new ByteArrayOutputStream();
         MultivaluedMap<String, Object> outHeaders = new MetadataMap<String, Object>();
-        p.writeTo(ds, DataSource.class, DataSource.class, new Annotation[]{}, 
-                   MediaType.valueOf("image/jpeg"), outHeaders, os);
-        assertEquals("image", os.toString());
+        try (ByteArrayOutputStream os = new ByteArrayOutputStream()) {
+            p.writeTo(ds, DataSource.class, DataSource.class, new Annotation[]{}, 
+                    MediaType.valueOf("image/jpeg"), outHeaders, os);
+            assertEquals("image", os.toString());
+        }
         assertEquals("image/png", outHeaders.getFirst("Content-Type"));
     }
     

http://git-wip-us.apache.org/repos/asf/cxf/blob/679835fe/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ClientServerMiscTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ClientServerMiscTest.java
b/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ClientServerMiscTest.java
index ead7c4f..0ae5a02 100644
--- a/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ClientServerMiscTest.java
+++ b/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ClientServerMiscTest.java
@@ -887,14 +887,15 @@ public class ClientServerMiscTest extends AbstractBusClientServerTestBase
{
         String str = IOUtils.readStringFromStream(con.getInputStream());
         
         //Check to make sure SESSIONID is a string
-        BufferedReader reader = new BufferedReader(new StringReader(str)); 
-        String s = reader.readLine();
-        while (s != null) {
-            if (s.contains("SESSIONID") && s.contains("element ")) {
-                assertTrue(s.contains("string"));
-                assertFalse(s.contains("headerObj"));
+        try (BufferedReader reader = new BufferedReader(new StringReader(str))) {
+            String s = reader.readLine();
+            while (s != null) {
+                if (s.contains("SESSIONID") && s.contains("element ")) {
+                    assertTrue(s.contains("string"));
+                    assertFalse(s.contains("headerObj"));
+                }
+                s = reader.readLine();   
             }
-            s = reader.readLine();   
         }
         //wsdl is correct, now make sure we can actually invoke it 
         QName name = new QName("http://cxf.apache.org/cxf5064", 

http://git-wip-us.apache.org/repos/asf/cxf/blob/679835fe/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java
b/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java
index abc9ed8..7bece33 100644
--- a/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java
+++ b/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java
@@ -805,6 +805,7 @@ public class ClientServerTest extends AbstractBusClientServerTestBase
{
         GZIPInputStream inputStream = new GZIPInputStream(in);
         Document doc = StaxUtils.read(inputStream);
         assertNotNull(doc);
+        inputStream.close();
     }
     
     @Test

http://git-wip-us.apache.org/repos/asf/cxf/blob/679835fe/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/datasource/DataSourceProviderTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/datasource/DataSourceProviderTest.java
b/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/datasource/DataSourceProviderTest.java
index 792fa8e..35d1fce 100644
--- a/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/datasource/DataSourceProviderTest.java
+++ b/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/datasource/DataSourceProviderTest.java
@@ -90,9 +90,9 @@ public class DataSourceProviderTest extends AbstractBusClientServerTestBase
{
 
         conn.setRequestMethod("POST");
         conn.addRequestProperty("Content-Type", contentType);
-        OutputStream out = conn.getOutputStream();
-        IOUtils.copy(in, out);
-        out.close();
+        try (OutputStream out = conn.getOutputStream()) {
+            IOUtils.copy(in, out);
+        }
         MimeMultipart mm = readAttachmentParts(conn.getContentType(),
                                                conn.getInputStream());
 
@@ -101,8 +101,7 @@ public class DataSourceProviderTest extends AbstractBusClientServerTestBase
{
     }
 
     private void printSource(Source source) {
-        try {
-            ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        try (ByteArrayOutputStream bos = new ByteArrayOutputStream()) {
             StreamResult sr = new StreamResult(bos);
             TransformerFactory transformerFactory = TransformerFactory.newInstance();
             transformerFactory.setFeature(javax.xml.XMLConstants.FEATURE_SECURE_PROCESSING,
true);
@@ -112,7 +111,6 @@ public class DataSourceProviderTest extends AbstractBusClientServerTestBase
{
             transformer.setOutputProperties(oprops);
             transformer.transform(source, sr);
             assertEquals(bos.toString(), "<doc><response>Hello</response></doc>");
-            bos.close();
         } catch (Exception e) {
             e.printStackTrace();
         }

http://git-wip-us.apache.org/repos/asf/cxf/blob/679835fe/systests/jaxws/src/test/java/org/apache/cxf/systest/swa/ClientServerSwaTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxws/src/test/java/org/apache/cxf/systest/swa/ClientServerSwaTest.java
b/systests/jaxws/src/test/java/org/apache/cxf/systest/swa/ClientServerSwaTest.java
index 4e5c166..997d3d7 100644
--- a/systests/jaxws/src/test/java/org/apache/cxf/systest/swa/ClientServerSwaTest.java
+++ b/systests/jaxws/src/test/java/org/apache/cxf/systest/swa/ClientServerSwaTest.java
@@ -174,12 +174,12 @@ public class ClientServerSwaTest extends AbstractBusClientServerTestBase
{
         port.echoDataRef(structHolder);
 
         handler = structHolder.value.getDataRef();
-        InputStream bis = null;
-        bis = handler.getDataSource().getInputStream();
+        InputStream bis = handler.getDataSource().getInputStream();
         byte b[] = new byte[10];
         bis.read(b, 0, 10);
         String string = IOUtils.newStringFromBytes(b);
         assertEquals("testfoobar", string);
+        bis.close();
     }
     
     @Test


Mime
View raw message