Examples of AnnotationConfigWebApplicationContext


Examples of org.springframework.web.context.support.AnnotationConfigWebApplicationContext

  }

  @Test
  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());
    context.close();
  }
View Full Code Here

Examples of org.springframework.web.context.support.AnnotationConfigWebApplicationContext

*/
public class ClientConfigurationTests {

  @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",
                CoreMatchers.startsWith("http://example.com/authorize")));
    context.close();
  }
View Full Code Here

Examples of org.springframework.web.context.support.AnnotationConfigWebApplicationContext

  public AuthorizationServerConfigurationTests(Class<? extends Exception> error, Class<?>... resource) {
    if (error != null) {
      expected.expect(error);
    }
    this.resources = resource;
    context = new AnnotationConfigWebApplicationContext();
    context.setServletContext(new MockServletContext());
    context.register(resource);
  }
View Full Code Here

Examples of org.springframework.web.context.support.AnnotationConfigWebApplicationContext

*/
public class ServletInitializer extends AbstractDispatcherServletInitializer {

  @Override
  protected WebApplicationContext createServletApplicationContext() {
    AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
    context.register(SecurityConfig.class, WebMvcConfig.class);
    return context;
  }
View Full Code Here

Examples of org.springframework.web.context.support.AnnotationConfigWebApplicationContext

*/
public class RestExporterWebInitializer implements WebApplicationInitializer {

  @Override public void onStartup(ServletContext ctx) throws ServletException {

    AnnotationConfigWebApplicationContext rootCtx = new AnnotationConfigWebApplicationContext();
    rootCtx.register(ApplicationConfig.class);

    ctx.addListener(new ContextLoaderListener(rootCtx));

    RepositoryRestExporterServlet exporter = new RepositoryRestExporterServlet();

View Full Code Here

Examples of org.springframework.web.context.support.AnnotationConfigWebApplicationContext

public class ValidatorAutowiringTest {

  @Test
  public void explicitValidator() {
    AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
    context.register(MyValidatorConfiguration.class);
    context.setServletContext(new MockServletContext());
    context.refresh();

    context.getBean(Validator.class); // Fails as there are two Validator beans in the context
  }
View Full Code Here

Examples of org.springframework.web.context.support.AnnotationConfigWebApplicationContext

public class ApplicationInitializer implements WebApplicationInitializer {

  @Override
  public void onStartup(ServletContext servletContext) throws ServletException {
    //Load application context
    AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
    rootContext.register(ApplicationContext.class);
    rootContext.setDisplayName("Spring Thymeleaf Tutorial");
   
    //Context loader listener
    servletContext.addListener(new ContextLoaderListener(rootContext));
   
    //Dispatcher servlet
View Full Code Here

Examples of org.springframework.web.context.support.AnnotationConfigWebApplicationContext

//        AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
//        rootContext.register(AppConfig.class);
//        sc.addListener(new ContextLoaderListener(rootContext));

        //2、springmvc上下文
        AnnotationConfigWebApplicationContext springMvcContext = new AnnotationConfigWebApplicationContext();
        springMvcContext.register(MvcConfiguration.class);
        //3、DispatcherServlet
        DispatcherServlet dispatcherServlet = new DispatcherServlet(springMvcContext);
        ServletRegistration.Dynamic dynamic = sc.addServlet("dispatcherServlet", dispatcherServlet);
        dynamic.setLoadOnStartup(1);
        dynamic.addMapping("/");
View Full Code Here

Examples of org.springframework.web.context.support.AnnotationConfigWebApplicationContext

      ctx.setConfigLocation("classpath:applicationContext.xml");
      servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, ctx);
      return ctx;
    }
    logger.info("No application context found");
    ConfigurableWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
    ctx.setId("VRaptor");
    servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, ctx);
    return ctx;
  }
View Full Code Here

Examples of org.springframework.web.context.support.AnnotationConfigWebApplicationContext

      XmlWebApplicationContext ctx = new XmlWebApplicationContext();
      ctx.setConfigLocation("classpath:applicationContext.xml");
      return ctx;
    }
    logger.info("No application context found");
    ConfigurableWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
    ctx.setId("VRaptor");
    return ctx;
  }
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.