public void testAuthCodeRedirect() throws Exception {
AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
context.setServletContext(new MockServletContext());
context.register(ClientContext.class);
context.refresh();
MockMvc mvc = MockMvcBuilders.webAppContextSetup(context).addFilters(new OAuth2ClientContextFilter()).build();
mvc.perform(MockMvcRequestBuilders.get("/photos"))
.andExpect(MockMvcResultMatchers.status().isFound())
.andExpect(
MockMvcResultMatchers.header().string("Location",
CoreMatchers.startsWith("http://example.com/authorize")));