@Test public void oneMarshallerCanHaveMultipleMediaTypes() throws Exception { Unmarshaller<HttpEntity, String> xmlUnmarshaller = Unmarshaller.forMediaTypes( Arrays.asList(MediaTypes.APPLICATION_XML, MediaTypes.TEXT_XML), Unmarshaller.entityToString()) .thenApply((str) -> "xml"); { CompletionStage<String> resultStage = xmlUnmarshaller.unmarshall( HttpEntities.create(ContentTypes.TEXT_XML_UTF8, "<suchXml/>"), system().dispatcher(), materializer()); assertEquals("xml", resultStage.toCompletableFuture().get(3, TimeUnit.SECONDS)); } { CompletionStage<String> resultStage = xmlUnmarshaller.unmarshall( HttpEntities.create( ContentTypes.create(MediaTypes.APPLICATION_XML, HttpCharsets.UTF_8), "<suchXml/>"), system().dispatcher(), materializer()); assertEquals("xml", resultStage.toCompletableFuture().get(3, TimeUnit.SECONDS)); } }