Map<String, String> qMap08 = new HashMap<String, String>();
qMap08.put("q", "0.8");
MediaType textXMLQ08 = new MediaType("text", "xml", qMap08);
ClientResponse response =
client.resource(getBaseURI() + "/context/httpheaders/acceptablemediatypes")
.accept(textPlainTypeQ1, wildCardQ06, jsonQ07, textXMLQ08).get();
assertEquals(200, response.getStatusCode());
String responseBody = response.getEntity(String.class);
assertEquals("acceptablemediatypes:text/plain:text/xml:application/json:*/*:", responseBody);
assertEquals("text/plain;q=1.0", response.getHeaders().getFirst("Content-Type"));
response =
client.resource(getBaseURI() + "/context/httpheaders/acceptablemediatypes")
.accept(textPlainTypeQ1).accept(wildCardQ06).accept(jsonQ07).accept(textXMLQ08)
.get();
assertEquals(200, response.getStatusCode());
responseBody = response.getEntity(String.class);
assertEquals("acceptablemediatypes:text/plain:text/xml:application/json:*/*:", responseBody);
assertEquals("text/plain;q=1.0", response.getHeaders().getFirst("Content-Type"));
response =
client.resource(getBaseURI() + "/context/httpheaders/acceptablemediatypes")
.header("Accept",
"text/plain;q=1.0,*/*;q=0.6, application/json;q=0.7,text/xml;q=0.8").get();
assertEquals(200, response.getStatusCode());
responseBody = response.getEntity(String.class);
assertEquals("acceptablemediatypes:text/plain:text/xml:application/json:*/*:", responseBody);
assertEquals("text/plain;q=1.0", response.getHeaders().getFirst("Content-Type"));
response =
client.resource(getBaseURI() + "/context/httpheaders/acceptablemediatypes")
.header("Accept", "text/plain;q=1.0").header("Accept", "*/*;q=0.6")
.header("Accept", "application/json;q=0.7").header("Accept", "text/xml;q=0.8")
.get();
assertEquals(200, response.getStatusCode());
responseBody = response.getEntity(String.class);
assertEquals("acceptablemediatypes:text/plain:text/xml:application/json:*/*:", responseBody);
assertEquals("text/plain;q=1.0", response.getHeaders().getFirst("Content-Type"));
}