@Test public void shouldReturnTheSameSessionForConsecutiveCalls() { Map<String, Cookie> cookies = new HashMap<>(); Cookie sessionCookie = new Cookie(HttpSessionImpl.COOKIE_NAME, "sessionId"); cookies.put(HttpSessionImpl.COOKIE_NAME, sessionCookie); httpServletRequestImpl = builder.withCookies(cookies).withServletContext(servletContext).build(); when(servletContext.getSession("sessionId")).thenReturn(new HttpSessionImpl("sessionId", System.currentTimeMillis())); assertThat(httpServletRequestImpl.getSession(), is(instanceOf(HttpSessionImpl.class))); assertThat(httpServletRequestImpl.getSession().equals(httpServletRequestImpl.getSession()), is(true)); }
@Test public void shouldReturnSession() { Map<String, Cookie> cookies = new HashMap<>(); Cookie sessionCookie = new Cookie(HttpSessionImpl.COOKIE_NAME, "sessionId"); cookies.put(HttpSessionImpl.COOKIE_NAME, sessionCookie); httpServletRequestImpl = builder.withCookies(cookies).withServletContext(servletContext).build(); when(servletContext.getSession("sessionId")).thenReturn(new HttpSessionImpl("sessionId", System.currentTimeMillis())); assertThat(httpServletRequestImpl.getSession(), is(instanceOf(HttpSessionImpl.class))); }
.withServerName("serverName") .withSecure(true) .withServletContext(servletContext) .withMultipart(true) .withUploadedFiles(new HashSet<UploadedFile>());
builder.withServletContext(getImplicitServletContext()) .withInputStream(in) .withStatus(status)