use of jakarta.ws.rs.core.Response in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method getLanguageTest.
/*
* @testName: getLanguageTest
*
* @assertion_ids: JAXRS:JAVADOC:850;
*
* @test_Strategy: Get the language of the message entity.
*/
@Test
public void getLanguageTest() throws Fault {
Response response = Response.ok().language(Locale.CANADA_FRENCH).build();
Locale locale = response.getLanguage();
assertTrue(Locale.CANADA_FRENCH.equals(locale), "Locale" + Locale.CANADA_FRENCH + "does NOT match response#getLocale()" + locale);
logMsg("#getLocale matches the Content-Language HTTP header");
}
use of jakarta.ws.rs.core.Response in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method cacheControlTest.
/*
* @testName: cacheControlTest
*
* @assertion_ids: JAXRS:JAVADOC:139; JAXRS:JAVADOC:141; JAXRS:JAVADOC:142;
* JAXRS:JAVADOC:123; JAXRS:JAVADOC:124; JAXRS:JAVADOC:125;
*
* @test_Strategy: Create an instance of Response using
* Response.ResponseBuilder.cacheControl(String).build() verify that correct
* status code is returned
*/
@Test
public void cacheControlTest() throws Fault {
VerificationResult result;
int status = 200;
boolean nostore = true;
CacheControl ccl4 = new CacheControl();
ccl4.setNoStore(nostore);
List<String> ccl = Arrays.asList("no-store", "no-transform");
Response resp = Response.status(status).cacheControl(ccl4).build();
result = verifyStatus(resp, status);
result.append(verifyCacheControl(resp, ccl));
logMsg(result);
assertResultTrue(result);
}
use of jakarta.ws.rs.core.Response in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method temporaryRedirectTest.
/*
* @testName: temporaryRedirectTest
*
* @assertion_ids: JAXRS:JAVADOC:140; JAXRS:JAVADOC:141; JAXRS:JAVADOC:123;
* JAXRS:JAVADOC:124; JAXRS:JAVADOC:125;
*
* @test_Strategy: Create an instance of Response using
* Response.temporaryRedirect(URI).build() verify that correct status code is
* returned
*/
@Test
public void temporaryRedirectTest() throws Fault {
VerificationResult result = new VerificationResult();
URI test_uri = null;
try {
test_uri = new URI("http://java.sun.com/j2se/1.3/");
} catch (URISyntaxException ex) {
result.message.append("Unexpected exception thrown:").append(ex.getMessage());
result.pass = false;
}
Response resp = Response.temporaryRedirect(test_uri).build();
HashMap<String, String> expected_map = new HashMap<String, String>();
expected_map.put("Location", "http://java.sun.com/j2se/1.3/");
result.append(verifyStatus(resp, 307));
result.append(verifyHeaders(resp, expected_map));
logMsg(result);
assertResultTrue(result);
}
use of jakarta.ws.rs.core.Response in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method getHeaderStringUsingHeaderDelegateTest.
/*
* @testName: getHeaderStringUsingHeaderDelegateTest
*
* @assertion_ids: JAXRS:JAVADOC:849;
*
* @test_Strategy: Get a message header as a single string value. Each single
* header value is converted to String using a RuntimeDelegate.HeaderDelegate
* or using its toString
*/
@Test
public void getHeaderStringUsingHeaderDelegateTest() throws Fault {
StringBean bean = new StringBean("s3");
RuntimeDelegate original = RuntimeDelegate.getInstance();
RuntimeDelegate.setInstance(new StringBeanRuntimeDelegate(original));
try {
Response response = Response.ok().header(bean.get(), bean).build();
String header = response.getHeaderString(bean.get());
assertContainsIgnoreCase(header, bean.get(), "Header", bean.get(), "has unexpected value", header);
logMsg("HeaderDelegate is used for header", bean.get());
} finally {
RuntimeDelegate.setInstance(original);
StringBeanRuntimeDelegate.assertNotStringBeanRuntimeDelegate();
}
}
use of jakarta.ws.rs.core.Response in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method getLinksIsNotNullTest.
/*
* @testName: getLinksIsNotNullTest
*
* @assertion_ids: JAXRS:JAVADOC:855;
*
* @test_Strategy: Does not return null.
*/
@Test
public void getLinksIsNotNullTest() throws Fault {
Response response = Response.ok().build();
Set<Link> responseLinks = response.getLinks();
assertTrue(responseLinks != null, "#getLinks() returned null!");
assertTrue(responseLinks.size() == 0, "#getLinks() returned non-empty map!");
logMsg("#getLinks contains no links as expected");
}
Aggregations