Package org.springframework.web.context.support

Examples of org.springframework.web.context.support.AnnotationConfigWebApplicationContext.refresh()


    for (Class<?> configClass : configClasses) {
      context.register(configClass);
    }

    context.refresh();

    return context;
  }
}
View Full Code Here


    }

    private void loadConfig(Class<?> config) {
        AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
        context.register(config);
        context.refresh();
        this.context = context;
        request.getServletContext().setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, context);
    }

    @Configuration
View Full Code Here

      AnnotationConfigWebApplicationContext wac = new AnnotationConfigWebApplicationContext();
    wac.setServletContext(servletContext);
    wac.setServletConfig(servletConfig);
      wac.register(WebConfig.class);
      wac.refresh();

      this.dispatcherServlet = new DispatcherServlet(wac);
      this.dispatcherServlet.init(servletConfig);
  }
View Full Code Here

    final AnnotationConfigWebApplicationContext root = new AnnotationConfigWebApplicationContext();
    root.setServletContext(servletContext); // registers the servlet context
    root.register(ApplicationConfiguration.class,
        RepositoryConfiguration.class);
    root.refresh(); // refreshes all beans
    return root;
  }
}
View Full Code Here

    final ServletContext ctx = sce.getServletContext();

    final AnnotationConfigWebApplicationContext root = new AnnotationConfigWebApplicationContext();
    root.setServletContext(ctx);
    root.scan("app");
    root.refresh();

    final Dynamic servlet = ctx.addServlet("spring", new DispatcherServlet(root));
    servlet.setLoadOnStartup(1);
    servlet.addMapping("/");
  }
View Full Code Here

    @Override
    protected WebApplicationContext createWebApplicationContext(ServletContext sc) {
  final AnnotationConfigWebApplicationContext springCtx = new AnnotationConfigWebApplicationContext();
  springCtx.setServletContext(sc);
  springCtx.scan("server");
  springCtx.refresh();

  sc.setAttribute(SPRING_CONTEXT, springCtx);

  return springCtx;
    }
View Full Code Here

  public void testDefaults() throws Exception {
    tokenStore.storeAccessToken(token, authentication);
    AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
    context.setServletContext(new MockServletContext());
    context.register(ResourceServerContext.class);
    context.refresh();
    MockMvc mvc = MockMvcBuilders.webAppContextSetup(context)
        .addFilters(new DelegatingFilterProxy(context.getBean("springSecurityFilterChain", Filter.class)))
        .build();
    mvc.perform(MockMvcRequestBuilders.get("/")).andExpect(MockMvcResultMatchers.status().isUnauthorized());
    context.close();
View Full Code Here

  public void testCustomTokenServices() throws Exception {
    tokenStore.storeAccessToken(token, authentication);
    AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
    context.setServletContext(new MockServletContext());
    context.register(TokenServicesContext.class);
    context.refresh();
    MockMvc mvc = MockMvcBuilders.webAppContextSetup(context)
        .addFilters(new DelegatingFilterProxy(context.getBean("springSecurityFilterChain", Filter.class)))
        .build();
    mvc.perform(MockMvcRequestBuilders.get("/")).andExpect(MockMvcResultMatchers.status().isUnauthorized());
    context.close();
View Full Code Here

  public void testCustomTokenExtractor() throws Exception {
    tokenStore.storeAccessToken(token, authentication);
    AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
    context.setServletContext(new MockServletContext());
    context.register(TokenExtractorContext.class);
    context.refresh();
    MockMvc mvc = MockMvcBuilders.webAppContextSetup(context)
        .addFilters(new DelegatingFilterProxy(context.getBean("springSecurityFilterChain", Filter.class)))
        .build();
    mvc.perform(MockMvcRequestBuilders.get("/").header("Authorization", "Bearer BAR")).andExpect(
        MockMvcResultMatchers.status().isNotFound());
View Full Code Here

  @Test
  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",
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.