use of jakarta.ws.rs.core.Response in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method languageTest.
/*
* @testName: languageTest
*
* @assertion_ids: JAXRS:JAVADOC:139; JAXRS:JAVADOC:141; JAXRS:JAVADOC:149;
* JAXRS:JAVADOC:123; JAXRS:JAVADOC:124; JAXRS:JAVADOC:125;
*
* @test_Strategy: Create an instance of Response using
* Response.ResponseBuilder.language(String).build() verify that correct
* status code is returned
*/
@Test
public void languageTest() throws Fault {
VerificationResult result = new VerificationResult();
int status = 200;
List<String> lang = getLangList();
for (String language : lang) {
Response resp = Response.status(status).language(language).build();
result.append(verifyStatus(resp, status));
result.append(verifyLanguage(resp, lang));
}
logMsg(result);
assertResultTrue(result);
}
use of jakarta.ws.rs.core.Response in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method getHeaderStringTest.
/*
* @testName: getHeaderStringTest
*
* @assertion_ids: JAXRS:JAVADOC:849;
*
* @test_Strategy: Get a message header as a single string value.
*/
@Test
public void getHeaderStringTest() throws Fault {
CacheControl ccl = new CacheControl();
ccl.setNoStore(true);
NewCookie cookie = new NewCookie("cookie", "eikooc");
String encoding = "gzip";
Date date = Calendar.getInstance().getTime();
Response response = Response.ok().cacheControl(ccl).cookie(cookie).encoding(encoding).expires(date).language(Locale.CANADA_FRENCH).build();
logMsg("Found following objects:");
logMsg((Object[]) JaxrsCommonClient.getMetadata(response.getHeaders()));
assertContainsIgnoreCase(response.getHeaderString(HttpHeaders.CACHE_CONTROL), "no-store", "Cache-Control:no-store has not been found");
assertContainsIgnoreCase(response.getHeaderString(HttpHeaders.CACHE_CONTROL), "no-transform", "Cache-Control:no-transform has not been found");
assertContainsIgnoreCase(response.getHeaderString(HttpHeaders.SET_COOKIE), "cookie=eikooc", "Set-Cookie:cookie=eikooc has not been found");
assertContainsIgnoreCase(response.getHeaderString(HttpHeaders.CONTENT_ENCODING), "gzip", "Content-Encoding:gzip has not been found");
assertNotNull(response.getHeaderString(HttpHeaders.EXPIRES), "Expires has not been found");
assertContainsIgnoreCase(langToString(response.getHeaderString("Content-Language")), langToString(Locale.CANADA_FRENCH), "Content-Language:", langToString(Locale.CANADA_FRENCH), "has not been found");
assertNull(response.getHeaderString("unknown"), "Unknown header has been found", response.getHeaderString("unknown"));
}
use of jakarta.ws.rs.core.Response in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method getFamilyTest.
/* Run test */
/*
* @testName: getFamilyTest
*
* @assertion_ids: JAXRS:JAVADOC:302;
*
* @test_Strategy: Get the class of status code
*/
@Test
public void getFamilyTest() throws Fault {
Response response;
for (int i = 0; i != status_codes.length; i++) {
response = Response.status(status_codes[i]).build();
StatusType type = response.getStatusInfo();
Family family = type.getFamily();
assertTrue(family == status_family[i], "unexpected family " + family + " differs from " + status_family[i]);
logMsg("Found expected family", family, "for status", status_codes[i]);
}
}
use of jakarta.ws.rs.core.Response in project jaxrs-api by eclipse-ee4j.
the class BuilderClientIT method allowStringArrayTruncateDuplicatesTest.
/*
* @testName: allowStringArrayTruncateDuplicatesTest
*
* @assertion_ids: JAXRS:JAVADOC:875;
*
* @test_Strategy: Set the list of allowed methods for the resource.
*/
@Test
public void allowStringArrayTruncateDuplicatesTest() throws Fault {
String[] methods = { Request.OPTIONS.name(), Request.OPTIONS.name() };
ResponseBuilder rb = RuntimeDelegate.getInstance().createResponseBuilder();
Response response = rb.allow(methods).build();
Set<String> set = response.getAllowedMethods();
assertEqualsInt(1, set.size(), "Only one allow method should be present");
assertEquals(set.iterator().next(), Request.OPTIONS.name(), Request.OPTIONS.name(), "has not been found in allowed methods");
logMsg(Request.OPTIONS.name(), "has been found in allowed methods");
}
use of jakarta.ws.rs.core.Response in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method postTest.
// ------------------------------------------------------------------
// ---------------------------POST-----------------------------------
// ------------------------------------------------------------------
/*
* @testName: postTest
*
* @assertion_ids: JAXRS:JAVADOC:397;
*
* @test_Strategy: Invoke HTTP post method for the current request
* asynchronously.
*/
@Test
public void postTest() throws Fault {
AsyncInvoker async = startAsyncInvokerForMethod("post");
Entity<String> entity = Entity.entity("post", MediaType.WILDCARD_TYPE);
Future<Response> future = async.post(entity);
checkFutureOkResponseNoTime(future);
// return future;
}
Aggregations