### Question:
AegisElementProvider extends AbstractAegisProvider<T> { public void writeTo(T obj, Class<?> type, Type genericType, Annotation[] anns, MediaType m, MultivaluedMap<String, Object> headers, OutputStream os) throws IOException { if (type == null) { type = obj.getClass(); } if (genericType == null) { genericType = type; } AegisContext context = getAegisContext(type, genericType); AegisType aegisType = context.getTypeMapping().getType(genericType); AegisWriter<XMLStreamWriter> aegisWriter = context.createXMLStreamWriter(); try { String enc = HttpUtils.getSetEncoding(m, headers, StandardCharsets.UTF_8.name()); XMLStreamWriter xmlStreamWriter = createStreamWriter(aegisType.getSchemaType(), enc, os); xmlStreamWriter.writeStartDocument(); aegisWriter.write(obj, aegisType.getSchemaType(), false, xmlStreamWriter, aegisType); xmlStreamWriter.writeEndDocument(); xmlStreamWriter.close(); } catch (Exception e) { throw ExceptionUtils.toInternalServerErrorException(e, null); } }  T readFrom(Class<T> type, Type genericType, Annotation[] annotations, MediaType m,
        MultivaluedMap<String, String> headers, InputStream is); void writeTo(T obj, Class<?> type, Type genericType, Annotation[] anns,
        MediaType m, MultivaluedMap<String, Object> headers, OutputStream os);  }### Answer:
@Test public void testWriteTo() throws Exception { MessageBodyWriter<Object> p = new AegisElementProvider<>(); ByteArrayOutputStream os = new ByteArrayOutputStream(); AegisTestBean bean = new AegisTestBean(); bean.setBoolValue(Boolean.TRUE); bean.setStrValue("hovercraft"); p.writeTo(bean, null, null, new Annotation[]{}, MediaType.APPLICATION_OCTET_STREAM_TYPE, new MetadataMap<String, Object>(), os); byte[] bytes = os.toByteArray(); String xml = new String(bytes, "utf-8"); assertEquals(simpleBeanXml, xml); }
@Test public void testNoNamespaceWriteTo() throws Exception { MessageBodyWriter<Object> p = new NoNamespaceAegisElementProvider<>(); ByteArrayOutputStream os = new ByteArrayOutputStream(); AegisTestBean bean = new AegisTestBean(); bean.setBoolValue(Boolean.TRUE); bean.setStrValue("hovercraft"); p.writeTo(bean, null, null, new Annotation[]{}, MediaType.APPLICATION_OCTET_STREAM_TYPE, new MetadataMap<String, Object>(), os); byte[] bytes = os.toByteArray(); String xml = new String(bytes, "utf-8"); assertEquals(noNamespaceXml, xml); }