use of jakarta.ws.rs.core.Cookie in project jaxrs-api by eclipse-ee4j.
the class BasicExamples method asyncCallbackUsingSubResourceClient.
public void asyncCallbackUsingSubResourceClient() throws Exception {
final Client client = ClientBuilder.newClient();
WebTarget anyCustomerUri = client.target("http://jaxrs.examples.org/jaxrsApplication/customers/{id}");
// invoke a request in background
Future<Customer> handle = // Target
anyCustomerUri.resolveTemplate("id", 123).request().async().get(new InvocationCallback<Customer>() {
@Override
public void completed(Customer customer) {
// do something
}
@Override
public void failed(Throwable throwable) {
// do something
}
});
handle.cancel(true);
// invoke another request in background
// Target
anyCustomerUri.resolveTemplate("id", 456).request().async().get(new InvocationCallback<Response>() {
@Override
public void completed(Response customer) {
// do something
}
@Override
public void failed(Throwable throwable) {
// do something
}
});
// invoke one more request using newClient
Future<Response> response = anyCustomerUri.resolveTemplate("id", 789).request().cookie(new Cookie("fooName", "XYZ")).async().get();
assert response.get() != null;
}
use of jakarta.ws.rs.core.Cookie in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method getCookiesTest.
/*
* @testName: getCookiesTest
*
* @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 getCookiesTest() throws Fault {
Cookie cts = new Cookie("cts", "cts");
Cookie tck = new Cookie("tck", "tck");
Cookie jee = new Cookie("jee", "jee");
ContextProvider provider = new ContextProvider() {
@Override
protected void checkFilterContext(ClientRequestContext context) throws Fault {
String cookies = JaxrsUtil.iterableToString(";", context.getCookies().values());
Response r = Response.ok(cookies).build();
context.abortWith(r);
}
};
Invocation invocation = buildBuilder(provider).cookie(cts).cookie(tck).cookie(jee).buildGet();
Response response = invoke(invocation);
String entity = response.readEntity(String.class);
assertContains(entity, "cts");
assertContains(entity, "tck");
assertContains(entity, "jee");
}
use of jakarta.ws.rs.core.Cookie in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method constructorTest5.
/*
* @testName: constructorTest5
*
* @assertion_ids: JAXRS:JAVADOC:49; JAXRS:JAVADOC:53; JAXRS:JAVADOC:54;
* JAXRS:JAVADOC:55; JAXRS:JAVADOC:56; JAXRS:JAVADOC:57;
*
* @test_Strategy: Create a version 0 Cookie instance using Constructor
* Cookie(String, String, String, String, int)
*/
@Test
public void constructorTest5() throws Fault {
String name = "name_1";
String value = "value_1";
String path = "/acme";
String domain = "y.x.foo.com";
int version = 0;
Cookie ck5 = new Cookie(name, value, path, domain, version);
verifyCookie(ck5, name, value, path, domain, version);
}
use of jakarta.ws.rs.core.Cookie in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method constructorTest2.
/*
* @testName: constructorTest2
*
* @assertion_ids: JAXRS:JAVADOC:50; 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, String, String)
*/
@Test
public void constructorTest2() throws Fault {
String name = "name_1";
String value = "value_1";
String path = "/acme";
String domain = "";
int version = 1;
Cookie ck2 = new Cookie(name, value, path, domain);
verifyCookie(ck2, name, value, path, domain, version);
}
use of jakarta.ws.rs.core.Cookie in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method constructorTest3.
/*
* @testName: constructorTest3
*
* @assertion_ids: JAXRS:JAVADOC:50; 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, String, String)
*/
@Test
public void constructorTest3() throws Fault {
String name = "name_1";
String value = "value_1";
String path = "";
String domain = "y.x.foo.com";
int version = 1;
Cookie ck3 = new Cookie(name, value, path, domain);
verifyCookie(ck3, name, value, path, domain, version);
}
Aggregations