BodyPart { public MultivaluedMap<String, String> getHeaders() { return this.headers; } BodyPart();  BodyPart(final MediaType mediaType);  BodyPart(final Object entity, final MediaType mediaType); Object getEntity(); void setEntity(final Object entity); MultivaluedMap<String, String> getHeaders(); MultivaluedMap<String, ParameterizedHeader> getParameterizedHeaders(); ContentDisposition getContentDisposition(); void setContentDisposition(final ContentDisposition contentDisposition); MediaType getMediaType(); void setMediaType(final MediaType mediaType); MultiPart getParent(); void setParent(final MultiPart parent); Providers getProviders(); void setProviders(final Providers providers); void cleanup(); BodyPart entity(final Object entity); T getEntityAs(final Class<T> clazz); BodyPart type(final MediaType type); BodyPart contentDisposition(final ContentDisposition contentDisposition); void setMessageBodyWorkers(final MessageBodyWorkers messageBodyWorkers); public MessageBodyWorkers messageBodyWorkers; }
@Test public void testHeaders() { MultivaluedMap<String, String> headers = bodyPart.getHeaders(); assertNotNull(headers); assertNull(headers.get(HttpHeaders.ACCEPT)); headers.add(HttpHeaders.ACCEPT, "application/xml"); assertEquals("application/xml", headers.getFirst(HttpHeaders.ACCEPT)); headers.add(HttpHeaders.ACCEPT, "application/json"); assertEquals("application/xml", headers.getFirst(HttpHeaders.ACCEPT)); List values = headers.get(HttpHeaders.ACCEPT); assertTrue(values.contains("application/xml")); assertTrue(values.contains("application/json")); assertNotNull(headers.get("accept")); assertNotNull(headers.get("ACCEPT")); }