use of com.tvd12.ezyhttp.server.core.request.SimpleRequestArguments in project ezyhttp by youngmonkeys.
the class SimpleRequestArgumentsTest method cookieNullTest.
@Test
public void cookieNullTest() {
// given
SimpleRequestArguments sut = new SimpleRequestArguments();
sut.setCookies(null);
// when
// then
Asserts.assertNull(sut.getCookieValue(0));
Asserts.assertNull(sut.getCookieValue(1));
Asserts.assertNull(sut.getCookieValue("unknown"));
Asserts.assertNull(sut.getCookie("unknown"));
sut.release();
}
use of com.tvd12.ezyhttp.server.core.request.SimpleRequestArguments in project ezyhttp by youngmonkeys.
the class SimpleRequestArgumentsTest method getByDefaultButNotNullTest.
@Test
public void getByDefaultButNotNullTest() {
// given
SimpleRequestArguments sut = new SimpleRequestArguments();
sut.setParameter("key", new String[] { "paramValue0" });
sut.setHeader("key", "headerValue0");
sut.setCookies(new Cookie[] { new Cookie("key", "cookieValue0") });
// when
// then
Asserts.assertEquals("paramValue0", sut.getParameter(0, "paramValue"));
Asserts.assertEquals("paramValue0", sut.getParameter("key", "paramValue"));
Asserts.assertEquals("headerValue0", sut.getHeader(0, "headerValue"));
Asserts.assertEquals("headerValue0", sut.getHeader("key", "headerValue"));
Asserts.assertEquals("cookieValue0", sut.getCookieValue(0, "cookieValue"));
Asserts.assertEquals("cookieValue0", sut.getCookieValue("key", "cookieValue"));
sut.release();
}
use of com.tvd12.ezyhttp.server.core.request.SimpleRequestArguments in project ezyhttp by youngmonkeys.
the class SimpleRequestArgumentsTest method headerTest.
@Test
public void headerTest() {
// given
SimpleRequestArguments sut = new SimpleRequestArguments();
sut.setHeader("hello", "world");
sut.setHeader("foo", "bar");
// when
String headerOverSize = sut.getHeader(3);
String headerByName = sut.getHeader("hello");
// then
Asserts.assertNull(headerOverSize);
Asserts.assertEquals("world", headerByName);
sut.release();
}
use of com.tvd12.ezyhttp.server.core.request.SimpleRequestArguments in project ezyhttp by youngmonkeys.
the class SimpleRequestArgumentsTest method cookieEmptyTest.
@Test
public void cookieEmptyTest() {
// given
SimpleRequestArguments sut = new SimpleRequestArguments();
sut.setCookies(new Cookie[0]);
// when
// then
Asserts.assertNull(sut.getCookieValue(0));
Asserts.assertNull(sut.getCookieValue(1));
Asserts.assertNull(sut.getCookieValue("unknown"));
Asserts.assertNull(sut.getCookie("unknown"));
sut.release();
}
use of com.tvd12.ezyhttp.server.core.request.SimpleRequestArguments in project ezyhttp by youngmonkeys.
the class SimpleRequestArgumentsTest method pathVariableTest.
@Test
public void pathVariableTest() {
// given
SimpleRequestArguments sut = new SimpleRequestArguments();
sut.setUriTemplate("/{foo}/{bar}");
HttpServletRequest servletRequest = mock(HttpServletRequest.class);
when(servletRequest.getRequestURI()).thenReturn("/hello/world");
sut.setRequest(servletRequest);
// when
String pathVariableByIndex = sut.getPathVariable(1);
String pathVariableOverIndex = sut.getPathVariable(3);
String pathVariableByName = sut.getPathVariable("foo");
// then
Asserts.assertNull(pathVariableOverIndex);
Asserts.assertEquals("hello", pathVariableByName);
Asserts.assertEquals("world", pathVariableByIndex);
verify(servletRequest, times(1)).getRequestURI();
sut.release();
}
Aggregations