use of javax.ws.rs.core.Variant in project jersey by jersey.
the class ResponseTest method fromResponseTest.
/*
* Create an instance of Response using
* Response.fromResponse(Response).build()
* verify that correct status code is returned
*/
@Test
public void fromResponseTest() {
int status = 200;
String content = "Test Only";
List<String> type = Arrays.asList("text/plain", "text/html");
List<String> encoding = Arrays.asList("gzip", "compress");
List<String> lang = Arrays.asList("en-US", "en-GB", "zh-CN");
MediaType mt1 = new MediaType("text", "plain");
MediaType mt2 = new MediaType("text", "html");
List<Variant> vts = Variant.VariantListBuilder.newInstance().mediaTypes(mt1, mt2).languages(new Locale("en", "US"), new Locale("en", "GB"), new Locale("zh", "CN")).encodings((String[]) encoding.toArray()).add().build();
String tmp;
for (Variant vt : vts) {
Response resp1 = Response.ok(content, vt).build();
Response resp = Response.fromResponse(resp1).build();
tmp = verifyResponse(resp, content, status, encoding, lang, type, null, null, null);
if (tmp.endsWith("false")) {
System.out.println("### " + tmp);
fail();
}
}
}
Aggregations