use of jakarta.ws.rs.core.Variant in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method encodingTest.
/*
* @testName: encodingTest
*
* @assertion_ids: JAXRS:JAVADOC:268; JAXRS:JAVADOC:264; JAXRS:JAVADOC:267;
* JAXRS:JAVADOC:263; JAXRS:JAVADOC:265; JAXRS:JAVADOC:255; JAXRS:JAVADOC:256;
* JAXRS:JAVADOC:257;
*
* @test_Strategy: Create a VariantListBuilder instance using
* Variant.VariantListBuilder.newInstance(); Add one MediaType to it with two
* encodings; Verify that two variants in the returned List
*/
@Test
public void encodingTest() throws Fault {
boolean pass = true;
StringBuffer sb = new StringBuffer();
List<String> encoding = Arrays.asList("gzip", "compress");
List<String> lang = new ArrayList<String>();
MediaType mt1 = new MediaType();
List<MediaType> types = Arrays.asList(mt1);
List<Variant> vts = Variant.VariantListBuilder.newInstance().mediaTypes(mt1).encodings("gzip", "compress").add().build();
String status = verifyVariants(vts, types, encoding, lang, 2);
if (status.endsWith("false")) {
pass = false;
}
sb.append(status);
TestUtil.logTrace(sb.toString());
assertTrue(pass, "At least one assertion faled: " + sb.toString());
}
use of jakarta.ws.rs.core.Variant in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method variantsTest.
/*
* @testName: variantsTest
*
* @assertion_ids: JAXRS:JAVADOC:139; JAXRS:JAVADOC:141; JAXRS:JAVADOC:160;
* JAXRS:JAVADOC:123; JAXRS:JAVADOC:124; JAXRS:JAVADOC:125;
*
* @test_Strategy: Create an instance of Response using
* Response.status(int).variants(List<Variant>).build() verify that correct
* status code is returned
*/
@Test
public void variantsTest() throws Fault {
VerificationResult result;
Response resp = null;
int status = 200;
// String type = "text/plain";
List<String> encoding = Arrays.asList("gzip", "compress");
List<String> vars = Arrays.asList("accept-language", "accept-encoding");
MediaType mt = new MediaType("text", "plain");
List<Variant> vts = getVariantList(encoding, mt);
resp = Response.status(status).variants(vts).build();
result = verifyStatus(resp, status);
result.append(verifyVary(resp, vars));
logMsg(result);
assertResultTrue(result);
}
use of jakarta.ws.rs.core.Variant in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method fromResponseTest.
/*
* @testName: fromResponseTest
*
* @assertion_ids: JAXRS:JAVADOC:122; JAXRS:JAVADOC:141; JAXRS:JAVADOC:123;
* JAXRS:JAVADOC:124; JAXRS:JAVADOC:125;
*
* @test_Strategy: Create an instance of Response using
* Response.fromResponse(Response).build() verify that correct status code is
* returned
*/
@Test
public void fromResponseTest() throws Fault {
VerificationResult result = new VerificationResult();
int status = 200;
String content = "Test Only";
List<String> type = Arrays.asList("text/plain", "text/html");
List<String> encoding = Arrays.asList("gzip", "compress");
MediaType mt1 = new MediaType("text", "plain");
MediaType mt2 = new MediaType("text", "html");
List<Variant> vts = getVariantList(encoding, mt1, mt2);
for (int i = 0; i < vts.size(); i++) {
Variant vt = vts.get(i);
Response resp1 = Response.ok(content, vt).build();
Response resp = Response.fromResponse(resp1).build();
result.append(verifyContent(resp, content));
result.append(verifyStatus(resp, status));
result.append(verifyEncoding(resp, encoding));
result.append(verifyLanguage(resp, getLangList()));
result.append(verifyContentType(resp, type));
}
logMsg(result);
assertResultTrue(result);
}
use of jakarta.ws.rs.core.Variant in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method okTest5.
/*
* @testName: okTest5
*
* @assertion_ids: JAXRS:JAVADOC:135; JAXRS:JAVADOC:141; JAXRS:JAVADOC:123;
* JAXRS:JAVADOC:124; JAXRS:JAVADOC:125; JAXRS:JAVADOC:91; JAXRS:JAVADOC:268;
* JAXRS:JAVADOC:267; JAXRS:JAVADOC:266; JAXRS:JAVADOC:265; JAXRS:JAVADOC:263;
* JAXRS:JAVADOC:264;
*
* @test_Strategy: Create an instance of Response using Response.ok(String,
* Variant).build() verify that correct status code is returned
*/
@Test
public void okTest5() throws Fault {
VerificationResult result = new VerificationResult();
Response resp = null;
int status = 200;
String content = "Test Only";
List<String> encoding = Arrays.asList("gzip", "compress");
MediaType mt = new MediaType("text", "plain");
List<Variant> vts = getVariantList(encoding, mt);
for (int i = 0; i < vts.size(); i++) {
Variant vt = vts.get(i);
resp = Response.ok(content, vt).build();
result.append(verifyContent(resp, content));
result.append(verifyStatus(resp, status));
result.append(verifyEncoding(resp, encoding));
result.append(verifyLanguage(resp, getLangList()));
result.append(verifyContentType(resp, Collections.singletonList(mt.toString())));
}
logMsg(result.message);
assertResultTrue(result);
}
Aggregations