use of jakarta.ws.rs.core.Cookie in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method parseTest2.
/*
* @testName: parseTest2
*
* @assertion_ids: JAXRS:JAVADOC:60; JAXRS:JAVADOC:53; JAXRS:JAVADOC:54;
* JAXRS:JAVADOC:55; JAXRS:JAVADOC:56; JAXRS:JAVADOC:57;
*
* @test_Strategy: Create a version 0 Cookie instance by Parsing a String
*/
@Test
public void parseTest2() throws Fault {
String cookie_toParse = "$Version=\"1\"; Customer=\"WILE_E_COYOTE\"; $Path=\"/acme\"";
String name = "customer";
String value = "wile_e_coyote";
String path = "/acme";
String domain = "";
int version = 1;
Cookie ck7 = jakarta.ws.rs.core.Cookie.valueOf(cookie_toParse);
verifyCookie(ck7, name, value, path, domain, version);
}
use of jakarta.ws.rs.core.Cookie in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method constructorTest4.
/*
* @testName: constructorTest4
*
* @assertion_ids: JAXRS:JAVADOC:51; JAXRS:JAVADOC:53; JAXRS:JAVADOC:54;
* JAXRS:JAVADOC:55; JAXRS:JAVADOC:56; JAXRS:JAVADOC:57;
*
* @test_Strategy: Create a version 1 Cookie instance using Constructor
* Cookie(String, String, String, String, int)
*/
@Test
public void constructorTest4() throws Fault {
String name = "name_1";
String value = "value_1";
String path = "/acme";
String domain = "y.x.foo.com";
int version = 1;
Cookie ck4 = new Cookie(name, value, path, domain, version);
verifyCookie(ck4, name, value, path, domain, version);
}
use of jakarta.ws.rs.core.Cookie in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method toStringTest.
/*
* @testName: toStringTest
*
* @assertion_ids: JAXRS:JAVADOC:49; JAXRS:JAVADOC:59;
*
* @test_Strategy: Create two Cookie instances using Constructor Cookie(String,
* String, String, String, int). Change the parameters one by one, make sure
* hashCode() and equals method work.
*/
@Test
public void toStringTest() throws Fault {
boolean pass = true;
StringBuffer sb = new StringBuffer();
String name = "name_1";
String value = "value_1";
String path = "/acme";
String domain = "y.x.foo.com";
int version = 0;
Cookie ck11 = new Cookie(name, value, path, domain, version);
String cookie = ck11.toString().toLowerCase();
if (!cookie.contains("name_1")) {
pass = false;
sb.append("Name test failed" + newline);
}
if (!cookie.contains("value_1")) {
pass = false;
sb.append("Value test failed" + newline);
}
if (!cookie.contains("acme")) {
pass = false;
sb.append("path test failed" + newline);
}
if (!cookie.contains("y.x.foo.com")) {
pass = false;
sb.append("domain test failed" + newline);
}
assertTrue(pass, "At least one assertion failed: " + sb.toString());
}
use of jakarta.ws.rs.core.Cookie in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method constructorTest1.
/*
* @testName: constructorTest1
*
* @assertion_ids: JAXRS:JAVADOC:51; JAXRS:JAVADOC:53; JAXRS:JAVADOC:54;
* JAXRS:JAVADOC:55; JAXRS:JAVADOC:56; JAXRS:JAVADOC:57;
*
* @test_Strategy: Create a Cookie instance using Constructor Cookie(String,
* String)
*/
@Test
public void constructorTest1() throws Fault {
String name = "name_1";
String value = "value_1";
int version = 1;
String domain = "";
String path = "";
Cookie ck1 = new Cookie(name, value);
verifyCookie(ck1, name, value, path, domain, version);
}
use of jakarta.ws.rs.core.Cookie in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method getCookiesIsImmutableTest.
/*
* @testName: getCookiesIsImmutableTest
*
* @assertion_ids: JAXRS:JAVADOC:432; JAXRS:JAVADOC:455; JAXRS:JAVADOC:456;
* JAXRS:SPEC:85; JAXRS:JAVADOC:427;
*
* @test_Strategy: Get any cookies that accompanied the request. Returns a
* read-only map of cookie name (String) to Cookie.
*
* ClientRequestFilter.abortWith
*/
@Test
public void getCookiesIsImmutableTest() throws Fault {
final Cookie cts = new Cookie("cts", "cts");
ContextProvider provider = new ContextProvider() {
@Override
protected void checkFilterContext(ClientRequestContext context) throws Fault {
Map<String, Cookie> cookies = context.getCookies();
try {
cookies.put("test", cts);
} catch (Exception e) {
// either exception is thrown or put does nothing
}
cookies = context.getCookies();
Cookie cookie = cookies.get("test");
assertTrue(cookie == null, "getCookies is not read-only");
Response r = Response.ok().build();
context.abortWith(r);
}
};
Invocation invocation = buildBuilder(provider).cookie(cts).buildGet();
Response response = invoke(invocation);
assertStatus(response, Status.OK);
}
Aggregations