cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject [1/2] cxf git commit: [CXF-7424] Adding a test
Date Thu, 22 Jun 2017 10:54:44 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 8d7bd0e8c -> 2dc6d0569


[CXF-7424] Adding a test


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

Branch: refs/heads/master
Commit: f5e8457e0fca31f8dc7af9b6368ba84331fcf742
Parents: 8d7bd0e
Author: Sergey Beryozkin <sberyozkin@gmail.com>
Authored: Thu Jun 22 11:10:02 2017 +0100
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Thu Jun 22 11:53:56 2017 +0100

----------------------------------------------------------------------
 .../jaxrs/provider/BinaryDataProviderTest.java    | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/f5e8457e/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/BinaryDataProviderTest.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/BinaryDataProviderTest.java
b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/BinaryDataProviderTest.java
index 3bbfda3..f67e0fd 100644
--- a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/BinaryDataProviderTest.java
+++ b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/BinaryDataProviderTest.java
@@ -95,6 +95,24 @@ public class BinaryDataProviderTest extends Assert {
         bytes = baos.toByteArray();
         assertTrue(Arrays.equals(new String("hi").getBytes(), bytes));
     }
+    
+    @SuppressWarnings({ "unchecked", "rawtypes" })
+    @Test
+    public void testReadBytesFromUtf8() throws Exception {
+        MessageBodyReader p = new BinaryDataProvider();
+        byte[] utf8Bytes = "世界ーファイル".getBytes("UTF-8");
+        byte[] readBytes = (byte[])p.readFrom(byte[].class, byte[].class, new Annotation[]{},
+                                          MediaType.APPLICATION_OCTET_STREAM_TYPE,
+                                          new MetadataMap<String, Object>(),
+                                          new ByteArrayInputStream(utf8Bytes));
+        assertTrue(Arrays.equals(utf8Bytes, readBytes));
+
+        readBytes = (byte[])p.readFrom(byte[].class, byte[].class, new Annotation[]{},
+                                              MediaType.valueOf("application/octet-stream;charset=UTF-8"),
+                                              new MetadataMap<String, Object>(),
+                                              new ByteArrayInputStream(utf8Bytes));
+        assertTrue(Arrays.equals(utf8Bytes, readBytes));
+    }
 
     @SuppressWarnings({ "unchecked", "rawtypes" })
     @Test


Mime
View raw message