use of org.glassfish.jersey.message.internal.QualitySourceMediaType in project jersey by jersey.
the class QualitySourceMediaTypeProviderTest method testFirefoxAcceptHeader.
@Test
public void testFirefoxAcceptHeader() throws Exception {
final String header = "text/xml,application/xml,application/xhtml+xml,text/html;qs=0.9,text/plain;qs=0.8,image/png,*/*;" + "qs=0.5";
final List<QualitySourceMediaType> l = HttpHeaderReader.readQualitySourceMediaType(header);
assertEquals(7, l.size());
MediaType m;
m = l.get(0);
assertEquals("text", m.getType());
assertEquals("xml", m.getSubtype());
assertEquals(0, m.getParameters().size());
m = l.get(1);
assertEquals("application", m.getType());
assertEquals("xml", m.getSubtype());
assertEquals(0, m.getParameters().size());
m = l.get(2);
assertEquals("application", m.getType());
assertEquals("xhtml+xml", m.getSubtype());
assertEquals(0, m.getParameters().size());
m = l.get(3);
assertEquals("image", m.getType());
assertEquals("png", m.getSubtype());
assertEquals(0, m.getParameters().size());
m = l.get(4);
assertEquals("text", m.getType());
assertEquals("html", m.getSubtype());
assertEquals(1, 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.QualitySourceMediaType in project jersey by jersey.
the class QualitySourceMediaTypeProviderTest method testOneMediaType.
@Test
public void testOneMediaType() throws Exception {
final String header = "application/xml";
final List<QualitySourceMediaType> l = HttpHeaderReader.readQualitySourceMediaType(header);
assertEquals(1, l.size());
final MediaType m = l.get(0);
assertEquals("application", m.getType());
assertEquals("xml", m.getSubtype());
assertEquals(0, m.getParameters().size());
}
use of org.glassfish.jersey.message.internal.QualitySourceMediaType in project jersey by jersey.
the class QualitySourceMediaTypeProviderTest method testMultipleMediaTypeWithQuality2.
@Test
public void testMultipleMediaTypeWithQuality2() throws Exception {
final String header = "application/xml;qs=0.1, text/xml;qs=0.2, text/html;qs=0.93";
final List<QualitySourceMediaType> l = HttpHeaderReader.readQualitySourceMediaType(header);
assertEquals(3, 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(1, m.getParameters().size());
m = l.get(2);
assertEquals("application", m.getType());
assertEquals("xml", m.getSubtype());
assertEquals(1, m.getParameters().size());
}
use of org.glassfish.jersey.message.internal.QualitySourceMediaType in project jersey by jersey.
the class QualitySourceMediaTypeProviderTest method testMediaTypeSpecifityHTTPExample1.
@Test
public void testMediaTypeSpecifityHTTPExample1() throws Exception {
final String header = "text/*, text/html, text/html;level=1, */*";
final List<QualitySourceMediaType> l = HttpHeaderReader.readQualitySourceMediaType(header);
MediaType m;
m = l.get(0);
assertEquals("text", m.getType());
assertEquals("html", m.getSubtype());
assertEquals(0, m.getParameters().size());
m = l.get(1);
assertEquals("text", m.getType());
assertEquals("html", m.getSubtype());
assertEquals(1, m.getParameters().size());
m = l.get(2);
assertEquals("text", m.getType());
assertEquals("*", m.getSubtype());
assertEquals(0, m.getParameters().size());
m = l.get(3);
assertEquals("*", m.getType());
assertEquals("*", m.getSubtype());
assertEquals(0, m.getParameters().size());
}
use of org.glassfish.jersey.message.internal.QualitySourceMediaType in project jersey by jersey.
the class QualitySourceMediaTypeProviderTest method testMediaTypeSpecifityWithQuality.
@Test
public void testMediaTypeSpecifityWithQuality() throws Exception {
final String header = "*/*, */*;qs=0.5, text/*, text/*;qs=0.5, text/plain, text/plain;qs=0.5";
final List<QualitySourceMediaType> l = HttpHeaderReader.readQualitySourceMediaType(header);
assertEquals(6, l.size());
MediaType m;
m = l.get(0);
assertEquals("text", m.getType());
assertEquals("plain", m.getSubtype());
assertEquals(0, m.getParameters().size());
m = l.get(1);
assertEquals("text", m.getType());
assertEquals("*", m.getSubtype());
assertEquals(0, m.getParameters().size());
m = l.get(2);
assertEquals("*", m.getType());
assertEquals("*", m.getSubtype());
assertEquals(0, m.getParameters().size());
m = l.get(3);
assertEquals("text", m.getType());
assertEquals("plain", m.getSubtype());
assertEquals(1, m.getParameters().size());
m = l.get(4);
assertEquals("text", m.getType());
assertEquals("*", m.getSubtype());
assertEquals(1, m.getParameters().size());
m = l.get(5);
assertEquals("*", m.getType());
assertEquals("*", m.getSubtype());
assertEquals(1, m.getParameters().size());
}
Aggregations