use of com.linkedin.restli.examples.greetings.client.CookieBuilders in project rest.li by linkedin.
the class TestCookieResource method testClearCookies.
/**
* Test the clear cookie functionality
*
* @throws RemoteInvocationException
*/
@Test
public void testClearCookies() throws RemoteInvocationException {
List<HttpCookie> requestCookies = Arrays.asList(new HttpCookie("will", "1"), new HttpCookie("lost", "1"));
GetRequest<Greeting> req = new CookieBuilders().get().id(1L).setCookies(requestCookies).clearCookies().build();
Response<Greeting> resp = REST_CLIENT.sendRequest(req).getResponse();
List<String> responseCookies = CookieUtil.encodeSetCookies(resp.getCookies());
// Since the cookies are cleared, there should be no response from the server
Assert.assertEquals(CookieUtil.decodeSetCookies(responseCookies), Collections.singletonList(new HttpCookie("empty_name", "empty_cookie")));
}
use of com.linkedin.restli.examples.greetings.client.CookieBuilders in project rest.li by linkedin.
the class TestCookieResource method testCookiesNormal.
/**
* A customized get test for inquring the cookies routing, look up in Cookie resource file
*
* @throws RemoteInvocationException
*/
@Test
public void testCookiesNormal() throws RemoteInvocationException {
List<HttpCookie> requestCookies = Arrays.asList(new HttpCookie("GET", "10"));
GetRequest<Greeting> req = new CookieBuilders().get().id(1L).setCookies(requestCookies).build();
Response<Greeting> resp = REST_CLIENT.sendRequest(req).getResponse();
Assert.assertEquals(resp.getCookies(), Collections.singletonList(new HttpCookie("10", "GET")));
}
use of com.linkedin.restli.examples.greetings.client.CookieBuilders in project rest.li by linkedin.
the class TestCookieResource method testCookieBatchGet.
/**
* Try a batch command get to see the cookie setting is ok or not
*
* @throws RemoteInvocationException
*/
@Test
public void testCookieBatchGet() throws RemoteInvocationException {
List<HttpCookie> requestCookies = Arrays.asList(new HttpCookie("B", "1"), new HttpCookie("A", "2"), new HttpCookie("G", "3"), new HttpCookie("E", "4"), new HttpCookie("T", "5"));
BatchGetRequest<Greeting> req = new CookieBuilders().batchGet().ids(1L, 2L).setCookies(requestCookies).build();
Response<BatchResponse<Greeting>> resp = REST_CLIENT.sendRequest(req).getResponse();
List<HttpCookie> getBackResponseCookie = Arrays.asList(new HttpCookie("1", "B"), new HttpCookie("2", "A"), new HttpCookie("3", "G"), new HttpCookie("4", "E"), new HttpCookie("5", "T"));
;
Assert.assertEquals(resp.getCookies(), getBackResponseCookie);
}
use of com.linkedin.restli.examples.greetings.client.CookieBuilders in project rest.li by linkedin.
the class TestCookieResource method testAddCookies.
/**
* Test the add cookie functionality
*
* @throws RemoteInvocationException
*/
@Test
public void testAddCookies() throws RemoteInvocationException {
CookieGetBuilder builderTmp = new CookieBuilders().get().id(1L);
builderTmp.addCookie(new HttpCookie("C", "3"));
builderTmp.addCookie(new HttpCookie("B", "2"));
builderTmp.addCookie(new HttpCookie("A", "1"));
GetRequest<Greeting> req = builderTmp.build();
Response<Greeting> resp = REST_CLIENT.sendRequest(req).getResponse();
List<HttpCookie> expectedCookies = Arrays.asList(new HttpCookie("3", "C"), new HttpCookie("2", "B"), new HttpCookie("1", "A"));
Assert.assertEquals(resp.getCookies(), expectedCookies);
}
Aggregations