use of jakarta.ws.rs.core.NewCookie in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method constructorTest22.
/*
* @testName: constructorTest22
*
* @assertion_ids: JAXRS:JAVADOC:108; JAXRS:JAVADOC:100; JAXRS:JAVADOC:101;
* JAXRS:JAVADOC:103; JAXRS:JAVADOC:49; JAXRS:JAVADOC:53; JAXRS:JAVADOC:54;
* JAXRS:JAVADOC:55; JAXRS:JAVADOC:56;
*
* @test_Strategy: Create a version 1 NewCookie instance using constructor
* Cookie(String, String, String, String, int) NewCookie(Cookie, String
* comment, int maxAge, boolean secure)
*/
@Test
public void constructorTest22() throws Fault {
String name = "name_1";
String value = "value_1";
String path = "/acme";
String domain = "y.x.foo.com";
int version = 1;
String comment = "cts test comment";
int maxage = jakarta.ws.rs.core.NewCookie.DEFAULT_MAX_AGE;
boolean secure = false;
Cookie ck22 = new Cookie(name, value, path, domain, version);
NewCookie nck22 = new NewCookie(ck22, comment, maxage, secure);
verifyNewCookie(nck22, name, value, path, domain, version, comment, maxage, secure);
}
use of jakarta.ws.rs.core.NewCookie in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method getCookiesIsImmutableTest.
/*
* @testName: getCookiesIsImmutableTest
*
* @assertion_ids: JAXRS:JAVADOC:844;
*
* @test_Strategy: returns a read-only map of cookie name (String) to Cookie.
*/
@Test
public void getCookiesIsImmutableTest() throws Fault {
NewCookie cookie1 = new NewCookie("c1", "v1");
NewCookie cookie2 = new NewCookie("c2", "v2");
Response response = Response.ok().cookie(cookie1).build();
// getCookies test
Map<String, NewCookie> map;
try {
map = response.getCookies();
map.put("c2", cookie2);
} catch (Exception e) {
// can throw an exception or nothing or return a copy map
}
map = response.getCookies();
assertTrue(!map.containsKey("c2"), "getCookies is not read-only returned" + map.get("c2"));
logMsg("#getCookies is read-only as expected");
}
use of jakarta.ws.rs.core.NewCookie in project jaxrs-api by eclipse-ee4j.
the class ResponseFilter method getCookiesIsReadOnly.
public void getCookiesIsReadOnly() {
NewCookie cookie = new NewCookie(COOKIENAME, COOKIENAME);
Map<String, NewCookie> cookies = responseContext.getCookies();
if (assertTrue(!cookies.containsKey(COOKIENAME), COOKIENAME, "is already present"))
return;
try {
cookies.put(COOKIENAME, cookie);
} catch (Exception e) {
// Not mandatory, but possible as cookies is read-only
}
cookies = responseContext.getCookies();
if (assertTrue(!cookies.containsKey(COOKIENAME), "#getCookies is Not readOnly"))
return;
setEntity("getCookies is read-only as expected");
}
use of jakarta.ws.rs.core.NewCookie in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method getCookiesTest.
/*
* @testName: getCookiesTest
*
* @assertion_ids: JAXRS:JAVADOC:844;
*
* @test_Strategy: Get any new cookies set on the response message.
*/
@Test
public void getCookiesTest() throws Fault {
Response response = invokeGet("cookies");
// getCookies test
Map<String, NewCookie> map = response.getCookies();
for (Entry<String, NewCookie> entry : map.entrySet()) {
String key = entry.getKey();
String value = entry.getValue().getValue();
if (key.equals("c1"))
assertEquals(value, "v1", value, "does not match expected v1");
else if (key.equals("c2"))
assertEquals(value, "v2", value, "does not match expected v2");
else
fault("Got unknown cookie", entry.getKey());
}
logMsg("#getCookies returned expected cookies");
}
use of jakarta.ws.rs.core.NewCookie in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method getCookiesIsImmutableTest.
/*
* @testName: getCookiesIsImmutableTest
*
* @assertion_ids: JAXRS:JAVADOC:844;
*
* @test_Strategy: returns a read-only map of cookie name (String) to Cookie.
*/
@Test
public void getCookiesIsImmutableTest() throws Fault {
NewCookie cookie3 = new NewCookie("c3", "v3");
Response response = invokeGet("cookies");
// getCookies test
Map<String, NewCookie> map;
try {
map = response.getCookies();
map.put("c3", cookie3);
} catch (Exception e) {
// can throw an exception or nothing or return a copy map
}
map = response.getCookies();
assertFalse(map.containsKey("c3"), "getCookies is not read-only returned" + map.get("c3"));
logMsg("#getCookies is read-only as expected");
}
Aggregations