use of org.glassfish.jersey.message.internal.AcceptableMediaType in project jersey by jersey.
the class AcceptMediaTypeProviderTest method testFirefoxAcceptHeaderWithPrority.
@Test
public void testFirefoxAcceptHeaderWithPrority() throws Exception {
String header = "text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5";
List<AcceptableMediaType> l = HttpHeaderReader.readAcceptMediaType(header, HttpHeaderReader.readQualitySourceMediaType("text/html;qs=1"));
assertEquals(7, l.size());
MediaType m;
m = l.get(0);
assertEquals("text", m.getType());
assertEquals("html", m.getSubtype());
assertEquals(1, m.getParameters().size());
m = l.get(1);
assertEquals("text", m.getType());
assertEquals("xml", m.getSubtype());
assertEquals(0, m.getParameters().size());
m = l.get(2);
assertEquals("application", m.getType());
assertEquals("xml", m.getSubtype());
assertEquals(0, m.getParameters().size());
m = l.get(3);
assertEquals("application", m.getType());
assertEquals("xhtml+xml", m.getSubtype());
assertEquals(0, m.getParameters().size());
m = l.get(4);
assertEquals("image", m.getType());
assertEquals("png", m.getSubtype());
assertEquals(0, m.getParameters().size());
m = l.get(5);
assertEquals("text", m.getType());
assertEquals("plain", m.getSubtype());
assertEquals(1, m.getParameters().size());
m = l.get(6);
assertEquals("*", m.getType());
assertEquals("*", m.getSubtype());
assertEquals(1, m.getParameters().size());
}
use of org.glassfish.jersey.message.internal.AcceptableMediaType in project jersey by jersey.
the class AcceptMediaTypeProviderTest method testOneMediaType.
@Test
public void testOneMediaType() throws Exception {
String header = "application/xml";
List<AcceptableMediaType> l = HttpHeaderReader.readAcceptMediaType(header);
assertEquals(1, l.size());
MediaType m = l.get(0);
assertEquals("application", m.getType());
assertEquals("xml", m.getSubtype());
assertEquals(0, m.getParameters().size());
}
Aggregations