Accept ah2 = new Accept(mtList);
assertEquals("toString", ah1.toString(), ah2.toString());
}
public void testEvaluation() {
Accept acceptHeaderA =
Accept
.valueOf("application/atom+xml;type=entry;q=0.6, " + "application/atom+xml;q=0.714, "
+ "application/json, "
+ "application/pdf;q=0.712;ignored=qExtension");
assertFalse("text/plain not acceptable", acceptHeaderA
.isAcceptable(MediaType.TEXT_PLAIN_TYPE));
assertTrue("json acceptable", acceptHeaderA.isAcceptable(MediaType.APPLICATION_JSON_TYPE));
assertTrue("atom;entry acceptable", acceptHeaderA
.isAcceptable(MediaTypeUtils.ATOM_ENTRY_TYPE));
assertTrue("application/pdf acceptable", acceptHeaderA
.isAcceptable(MediaTypeUtils.PDF_TYPE));
Accept acceptHeaderB = Accept.valueOf("text/*, */*;q=0.1, text/plain;q=0");
Accept acceptHeaderReverse = Accept.valueOf("text/plain;q=0, */*;q=0.1, text/*");
assertTrue("image/jpeg acceptable", acceptHeaderB
.isAcceptable(MediaTypeUtils.IMAGE_JPEG_TYPE));
assertTrue("image/jpeg acceptable", acceptHeaderReverse
.isAcceptable(MediaTypeUtils.IMAGE_JPEG_TYPE));
assertTrue("text/html acceptable", acceptHeaderB.isAcceptable(MediaType
.valueOf("text/html")));
assertTrue("text/html acceptable", acceptHeaderReverse.isAcceptable(MediaType
.valueOf("text/html")));
assertFalse("text/plain not acceptable", acceptHeaderB
.isAcceptable(MediaType.TEXT_PLAIN_TYPE));
assertFalse("text/plain not acceptable", acceptHeaderReverse
.isAcceptable(MediaType.TEXT_PLAIN_TYPE));
}