use of org.springframework.mock.web.MockHttpServletResponse in project spring-security by spring-projects.
the class DefaultLoginPageGeneratingFilterTests method generatingPageWithOpenIdFilterOnlyIsSuccessFul.
@Test
public void generatingPageWithOpenIdFilterOnlyIsSuccessFul() throws Exception {
DefaultLoginPageGeneratingFilter filter = new DefaultLoginPageGeneratingFilter(new MockProcessingFilter());
filter.doFilter(new MockHttpServletRequest("GET", "/login"), new MockHttpServletResponse(), chain);
}
use of org.springframework.mock.web.MockHttpServletResponse in project spring-security by spring-projects.
the class RequestCacheAwareFilterTests method savedRequestIsRemovedAfterMatch.
@Test
public void savedRequestIsRemovedAfterMatch() throws Exception {
RequestCacheAwareFilter filter = new RequestCacheAwareFilter();
HttpSessionRequestCache cache = new HttpSessionRequestCache();
MockHttpServletRequest request = new MockHttpServletRequest("POST", "/destination");
MockHttpServletResponse response = new MockHttpServletResponse();
cache.saveRequest(request, response);
assertThat(request.getSession().getAttribute(HttpSessionRequestCache.SAVED_REQUEST)).isNotNull();
filter.doFilter(request, response, new MockFilterChain());
assertThat(request.getSession().getAttribute(HttpSessionRequestCache.SAVED_REQUEST)).isNull();
}
use of org.springframework.mock.web.MockHttpServletResponse in project rdbcache by rdbcache.
the class RTQueryApisTest method retrieveVersionInfo.
@Test
public void retrieveVersionInfo() throws Exception {
try {
RequestBuilder requestBuilder = MockMvcRequestBuilders.get("/rtquery/v1/version-info").accept(MediaType.APPLICATION_JSON);
ResultActions actions = mockMvc.perform(requestBuilder);
MvcResult result = actions.andReturn();
MockHttpServletResponse response = result.getResponse();
assertEquals(200, response.getStatus());
String body = response.getContentAsString();
// System.out.println(body);
Map<String, Object> map = Utils.toMap(body);
assertTrue(map.containsKey("timestamp"));
assertTrue(map.containsKey("duration"));
assertTrue(map.containsKey("data"));
assertTrue(map.containsKey("trace_id"));
Map<String, Object> data = (Map<String, Object>) map.get("data");
assertTrue(data.size() > 0);
} catch (Exception e) {
e.printStackTrace();
fail(e.getCause().getMessage());
}
}
use of org.springframework.mock.web.MockHttpServletResponse in project rdbcache by rdbcache.
the class RTQueryApisTest method retrieveLocalCacheData.
@Test
public void retrieveLocalCacheData() throws Exception {
try {
InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("test-data.json");
assertNotNull(inputStream);
String text = null;
try (final Reader reader = new InputStreamReader(inputStream)) {
text = CharStreams.toString(reader);
}
assertNotNull(text);
Map<String, Object> testData = Utils.toMap(text);
assertNotNull(testData);
Mockito.when(localCache.listAllData()).thenReturn(testData);
PowerMockito.mockStatic(AppCtx.class);
BDDMockito.when(AppCtx.getLocalCache()).thenReturn(localCache);
RequestBuilder requestBuilder = MockMvcRequestBuilders.get("/rtquery/v1/cache/data").accept(MediaType.APPLICATION_JSON);
ResultActions actions = mockMvc.perform(requestBuilder);
MvcResult result = actions.andReturn();
MockHttpServletResponse response = result.getResponse();
assertEquals(response.getStatus(), 200);
String body = response.getContentAsString();
// System.out.println(body);
Map<String, Object> map = Utils.toMap(body);
assertTrue(map.containsKey("timestamp"));
assertTrue(map.containsKey("duration"));
assertTrue(map.containsKey("data"));
assertTrue(map.containsKey("trace_id"));
Map<String, Object> data = (Map<String, Object>) map.get("data");
assertTrue(data.size() > 0);
} catch (Exception e) {
e.printStackTrace();
fail(e.getCause().getMessage());
}
}
use of org.springframework.mock.web.MockHttpServletResponse in project rdbcache by rdbcache.
the class RTQueryApisTest method retrieveLocalCacheConfig.
@Test
public void retrieveLocalCacheConfig() throws Exception {
RequestBuilder requestBuilder = MockMvcRequestBuilders.get("/rtquery/v1/cache/config").accept(MediaType.APPLICATION_JSON);
ResultActions actions = mockMvc.perform(requestBuilder);
MvcResult result = actions.andReturn();
MockHttpServletResponse response = result.getResponse();
assertEquals(200, response.getStatus());
String body = response.getContentAsString();
// System.out.println(body);
Map<String, Object> map = Utils.toMap(body);
assertTrue(map.containsKey("timestamp"));
assertTrue(map.containsKey("duration"));
assertTrue(map.containsKey("data"));
assertTrue(map.containsKey("trace_id"));
Map<String, Object> data = (Map<String, Object>) map.get("data");
assertTrue(data.size() > 0);
}
Aggregations