Exemplo n.º 1
0
 @Test
 public void testRequestParams_withParameters() throws Exception {
   when(request.getParameter("valid1")).thenReturn("validvalue1");
   assertThat(
       Traceables.requestParams(request, "valid1", "invalid2").asString(),
       is(equalTo("HttpServletRequest.params: [[{valid1=validvalue1, invalid2=null}]]")));
 }
Exemplo n.º 2
0
 @Test
 public void testCookieAttributes_whenCookieSomeAttributesAndDoesNotHaveSome() throws Exception {
   when(request.getCookies()).thenReturn(cookies);
   when(cookies[0].getName()).thenReturn("validkey1");
   when(cookies[0].getValue()).thenReturn("validvalue1");
   assertThat(
       Traceables.cookieAttrs(request, "validkey1", "invalidkey1").asString(),
       is(equalTo("Cookie[].attrs: [[{validkey1=validvalue1}]]")));
 }
Exemplo n.º 3
0
 @Test
 public void testSessionAttributes_whenSesessionHasSomeAttributesAndDoesNotHaveSome()
     throws Exception {
   when(request.getSession(false)).thenReturn(session);
   when(session.getAttribute("valid1")).thenReturn("validvalue1");
   assertThat(
       Traceables.sessionAttrs(request, "valid1", "invalid1").asString(),
       is(equalTo("HttpSession.attrs: [[{valid1=validvalue1, invalid1=null}]]")));
 }
Exemplo n.º 4
0
 @Test
 public void testCookieAttributes_whenRequestIsNull() throws Exception {
   assertThat(
       Traceables.cookieAttrs(null, "validkey1").asString(),
       is(equalTo("[Unable to retrieve Cookie[] - null HttpServletRequest]")));
 }
Exemplo n.º 5
0
 @Test
 public void testCookieAttributes_whenCookieIsNull() throws Exception {
   when(request.getCookies()).thenReturn(null);
   assertThat(
       Traceables.cookieAttrs(request, "validkey1").asString(), is(equalTo("[null - Cookie[]]")));
 }
Exemplo n.º 6
0
 @Test
 public void testSessionAttributes_whenSessionIsNull() throws Exception {
   when(request.getSession(false)).thenReturn(null);
   assertThat(Traceables.sessionAttrs(request).asString(), is(equalTo("[null - HttpSession]")));
 }
Exemplo n.º 7
0
 @Test
 public void testSessionAttributes() throws Exception {
   assertThat(
       Traceables.sessionAttrs(null).asString(),
       is(equalTo("[Unable to getSession - null HttpServletRequest]")));
 }
Exemplo n.º 8
0
 @Test
 public void testRequestParams_withParameters_whichAreNotPresentOnTheRequest() throws Exception {
   assertThat(
       Traceables.requestParams(request, "invalid1", "invalid2").asString(),
       is(equalTo("HttpServletRequest.params: [[{invalid1=null, invalid2=null}]]")));
 }
Exemplo n.º 9
0
 @Test
 public void testRequestParams_whenNoParametersAreSpecifiedForTracing_delegatesToRequest()
     throws Exception {
   assertThat(Traceables.requestParams(request).asString(), is(notNullValue(String.class)));
 }
Exemplo n.º 10
0
 @Test
 public void testRequestParams_whenRequestIsNull_shouldOutput_nullRequestString()
     throws Exception {
   assertThat(
       Traceables.requestParams(null).asString(), is(equalTo("[null - HttpServletRequest]")));
 }