use of jakarta.ws.rs.core.Response in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method statusTest3.
/*
* @testName: statusTest3
*
* @assertion_ids: JAXRS:JAVADOC:139; JAXRS:JAVADOC:131; JAXRS:JAVADOC:123;
* JAXRS:JAVADOC:124; JAXRS:JAVADOC:125; JAXRS:SPEC:14.2;
*
* @test_Strategy: Create an instance of Response using
* Response.ResponseBuilder.status(int).build() verify that correct status
* code is returned
*/
@Test
public void statusTest3() throws Fault {
VerificationResult result = new VerificationResult();
Response resp = null;
for (int status : status_codes) {
resp = Response.ok().status(status).build();
result.append(verifyStatus(resp, status));
}
logMsg(result);
assertResultTrue(result);
}
use of jakarta.ws.rs.core.Response in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method getLastModifiedNotPresentTest.
/*
* @testName: getLastModifiedNotPresentTest
*
* @assertion_ids: JAXRS:JAVADOC:851;
*
* @test_Strategy: Get null if not present.
*/
@Test
public void getLastModifiedNotPresentTest() throws Fault {
Response response = Response.ok().build();
Date responseDate = response.getLastModified();
assertTrue(responseDate == null, "response#getLastModified() should be null, was" + responseDate);
logMsg("#getLastModified() is null as expected");
}
use of jakarta.ws.rs.core.Response in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method getStringHeadersUsingHeaderDelegateTest.
/*
* @testName: getStringHeadersUsingHeaderDelegateTest
*
* @assertion_ids: JAXRS:JAVADOC:859;
*
* @test_Strategy: Get view of the response headers and their string values.
* Each single header value is converted to String using a
* RuntimeDelegate.HeaderDelegate or using its toString
*/
@Test
public void getStringHeadersUsingHeaderDelegateTest() throws Fault {
RuntimeDelegate original = RuntimeDelegate.getInstance();
RuntimeDelegate.setInstance(new StringBeanRuntimeDelegate(original));
try {
StringBuilder builder = new StringBuilder("s1");
StringBuffer buffer = new StringBuffer("s2");
StringBean bean = new StringBean("s3");
Response response = Response.ok().header(builder.toString(), builder).header(buffer.toString(), buffer).header(bean.get(), bean).build();
MultivaluedMap<String, String> headers = response.getStringHeaders();
String header = headers.getFirst(bean.get());
assertContainsIgnoreCase(bean.get(), header, "Header", bean.get(), "has unexpected value", header);
logMsg("#getStringHeaders contains expected values", JaxrsUtil.iterableToString(",", headers.entrySet()));
} finally {
RuntimeDelegate.setInstance(original);
StringBeanRuntimeDelegate.assertNotStringBeanRuntimeDelegate();
}
}
use of jakarta.ws.rs.core.Response in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method notAcceptableTest.
/*
* @testName: notAcceptableTest
*
* @assertion_ids: JAXRS:JAVADOC:127; 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.notAcceptable(vts).build() verify that correct status code is
* returned
*/
@Test
public void notAcceptableTest() throws Fault {
VerificationResult result;
Response resp = null;
int status = 406;
List<String> encoding = Arrays.asList("gzip", "compress");
MediaType mt = new MediaType("text", "plain");
List<Variant> vts = getVariantList(encoding, mt);
resp = Response.notAcceptable(vts).build();
result = verifyStatus(resp, status);
logMsg(result);
assertResultTrue(result);
}
use of jakarta.ws.rs.core.Response in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method notModifiedTest2.
/*
* @testName: notModifiedTest2
*
* @assertion_ids: JAXRS:JAVADOC:130; JAXRS:JAVADOC:141; JAXRS:JAVADOC:123;
* JAXRS:JAVADOC:124; JAXRS:JAVADOC:125;
*
* @test_Strategy: Create an instance of Response using
* Response.notModified(String).build() verify that correct status code is
* returned
*/
@Test
public void notModifiedTest2() throws Fault {
VerificationResult result;
Response resp = null;
int status = 304;
String tags = "TestOnly";
HashMap<String, String> expected_map = new HashMap<String, String>();
expected_map.put("ETAG", tags);
resp = Response.notModified(tags).build();
result = verifyStatus(resp, status);
result.append(verifyHeaders(resp, expected_map));
logMsg(result);
assertResultTrue(result);
}
Aggregations