use of org.glassfish.jersey.message.internal.AcceptableMediaType in project jersey by jersey.
the class AcceptMediaTypeProviderTest method testMediaTypeSpecifityHTTPExample2.
@Test
public void testMediaTypeSpecifityHTTPExample2() throws Exception {
String header = "text/*, text/html;level=1, text/html, */*";
List<AcceptableMediaType> l = HttpHeaderReader.readAcceptMediaType(header);
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("html", m.getSubtype());
assertEquals(0, 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.AcceptableMediaType in project jersey by jersey.
the class AcceptMediaTypeProviderTest method testHttpURLConnectionAcceptHeaderWithPrority.
@Test
public void testHttpURLConnectionAcceptHeaderWithPrority() throws Exception {
String header = "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2";
List<AcceptableMediaType> l = HttpHeaderReader.readAcceptMediaType(header, HttpHeaderReader.readQualitySourceMediaType(MediaType.TEXT_HTML));
assertEquals(5, l.size());
MediaType m;
m = l.get(0);
assertEquals("text", m.getType());
assertEquals("html", m.getSubtype());
assertEquals(0, m.getParameters().size());
m = l.get(1);
assertEquals("image", m.getType());
assertEquals("gif", m.getSubtype());
assertEquals(0, m.getParameters().size());
m = l.get(2);
assertEquals("image", m.getType());
assertEquals("jpeg", m.getSubtype());
assertEquals(0, m.getParameters().size());
m = l.get(3);
assertEquals("*", m.getType());
assertEquals("*", m.getSubtype());
assertEquals(1, m.getParameters().size());
m = l.get(4);
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 testMultipleMediaType.
@Test
public void testMultipleMediaType() throws Exception {
String header = "application/xml, text/xml, text/html";
List<AcceptableMediaType> l = HttpHeaderReader.readAcceptMediaType(header);
assertEquals(3, l.size());
MediaType m;
m = l.get(0);
assertEquals("application", m.getType());
assertEquals("xml", m.getSubtype());
assertEquals(0, 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("text", m.getType());
assertEquals("html", m.getSubtype());
assertEquals(0, m.getParameters().size());
}
use of org.glassfish.jersey.message.internal.AcceptableMediaType in project jersey by jersey.
the class AcceptMediaTypeProviderTest method testMediaTypeSpecifityWithQuality.
@Test
public void testMediaTypeSpecifityWithQuality() throws Exception {
String header = "*/*, */*;q=0.5, text/*, text/*;q=0.5, text/plain, text/plain;q=0.5";
List<AcceptableMediaType> l = HttpHeaderReader.readAcceptMediaType(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());
}
use of org.glassfish.jersey.message.internal.AcceptableMediaType in project jersey by jersey.
the class AcceptMediaTypeProviderTest method testMediaTypeSpecifity.
@Test
public void testMediaTypeSpecifity() throws Exception {
String header = "*/*, text/*, text/plain";
List<AcceptableMediaType> l = HttpHeaderReader.readAcceptMediaType(header);
assertEquals(3, 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());
}
Aggregations