### Question:
PrimitiveTextProvider extends AbstractConfigurableProvider implements MessageBodyReader<T>, MessageBodyWriter<T> { public void writeTo(T obj, Class<?> type, Type genType, Annotation[] anns, MediaType mt, MultivaluedMap<String, Object> headers, OutputStream os) throws IOException { String encoding = HttpUtils.getSetEncoding(mt, headers, StandardCharsets.UTF_8.name()); byte[] bytes = obj.toString().getBytes(encoding); os.write(bytes); }  boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mt); T readFrom(Class<T> type, Type genType, Annotation[] anns, MediaType mt,
                      MultivaluedMap<String, String> headers, InputStream is); long getSize(T t, Class<?> type, Type genericType, Annotation[] annotations, MediaType mt); boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mt); void writeTo(T obj, Class<?> type, Type genType, Annotation[] anns,
                        MediaType mt, MultivaluedMap<String, Object> headers,
                        OutputStream os);  }### Answer:
@SuppressWarnings({ "unchecked", "rawtypes" }) @Test public void testWriteBoolean() throws Exception { MessageBodyWriter p = new PrimitiveTextProvider(); ByteArrayOutputStream os = new ByteArrayOutputStream(); p.writeTo(Boolean.TRUE, null, null, null, MediaType.TEXT_PLAIN_TYPE, null, os); assertArrayEquals(new String("true").getBytes(), os.toByteArray()); os = new ByteArrayOutputStream(); final boolean value = true; p.writeTo(value, null, null, null, MediaType.TEXT_PLAIN_TYPE, null, os); assertArrayEquals(new String("true").getBytes(), os.toByteArray()); }
@Test public void testWriteStringISO() throws Exception { MessageBodyWriter<String> p = new PrimitiveTextProvider<>(); ByteArrayOutputStream os = new ByteArrayOutputStream(); MultivaluedMap<String, Object> headers = new MetadataMap<>(); String eWithAcute = "\u00E9"; String helloStringUTF16 = "Hello, my name is F" + eWithAcute + "lix Agn" + eWithAcute + "s"; p.writeTo(helloStringUTF16, String.class, String.class, null, MediaType.valueOf("text/plain;charset=ISO-8859-1"), headers, os); byte[] iso88591bytes = helloStringUTF16.getBytes("ISO-8859-1"); String helloStringISO88591 = new String(iso88591bytes, "ISO-8859-1"); assertEquals(helloStringISO88591, os.toString("ISO-8859-1")); }