Package org.springframework.web.context.support

Examples of org.springframework.web.context.support.StaticWebApplicationContext.registerSingleton()


  }

  public void testBeanResolveWithRequestContext() throws Exception {
    StaticWebApplicationContext applicationContext = new StaticWebApplicationContext();
    ((Flow) this.requestContext.getActiveFlow()).setApplicationContext(applicationContext);
    applicationContext.registerSingleton("test", Bean.class);
    Object actual = this.resolver.getValue(this.elContext, null, "test");
    assertTrue(this.elContext.isPropertyResolved());
    assertNotNull(actual);
    assertTrue(actual instanceof Bean);
  }
View Full Code Here


  public void constructorTest() throws Exception{
    BoostedFlowController controller = new BoostedFlowController();

    StaticWebApplicationContext appContext = new StaticWebApplicationContext();
    String adapterKey = "BoostedFlowHandlerAdapter";
    appContext.registerSingleton(adapterKey, BoostedFlowHandlerAdapter.class);

    /*
    //BoostedFlowHandlerAdapter adapter = new BoostedFlowHandlerAdapter();
 
    
View Full Code Here

  public void testDetectHandlerMappingFromParent() throws ServletException, IOException {
    // create a parent context that includes a mapping
    StaticWebApplicationContext parent = new StaticWebApplicationContext();
    parent.setServletContext(servletConfig.getServletContext());
    parent.registerSingleton("parentHandler", ControllerFromParent.class, new MutablePropertyValues());

    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.addPropertyValue(new PropertyValue("mappings", URL_KNOWN_ONLY_PARENT + "=parentHandler"));

    parent.registerSingleton("parentMapping", SimpleUrlHandlerMapping.class, pvs);
View Full Code Here

    parent.registerSingleton("parentHandler", ControllerFromParent.class, new MutablePropertyValues());

    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.addPropertyValue(new PropertyValue("mappings", URL_KNOWN_ONLY_PARENT + "=parentHandler"));

    parent.registerSingleton("parentMapping", SimpleUrlHandlerMapping.class, pvs);
    parent.refresh();

    DispatcherServlet complexDispatcherServlet = new DispatcherServlet();
    // will have parent
    complexDispatcherServlet.setContextClass(ComplexWebApplicationContext.class);
View Full Code Here

  }

  @Test
  public void testXmlViewResolver() throws Exception {
    StaticWebApplicationContext wac = new StaticWebApplicationContext();
    wac.registerSingleton("testBean", TestBean.class);
    wac.setServletContext(new MockServletContext());
    wac.refresh();
    TestBean testBean = (TestBean) wac.getBean("testBean");
    XmlViewResolver vr = new XmlViewResolver();
    vr.setLocation(new ClassPathResource("org/springframework/web/servlet/view/views.xml"));
View Full Code Here

  }

  @Test
  public void controllerAdvice() throws Exception {
    StaticWebApplicationContext cxt = new StaticWebApplicationContext();
    cxt.registerSingleton("exceptionHandler", ApplicationExceptionHandler.class);
    cxt.refresh();

    ExceptionHandlerExceptionResolver resolver = new ExceptionHandlerExceptionResolver();
    resolver.setApplicationContext(cxt);
    resolver.afterPropertiesSet();
View Full Code Here

  }

  @Test
  public void updateTargetUrl() throws Exception {
    StaticWebApplicationContext wac = new StaticWebApplicationContext();
    wac.registerSingleton("requestDataValueProcessor", RequestDataValueProcessorWrapper.class);
    wac.setServletContext(new MockServletContext());
    wac.refresh();

    RequestDataValueProcessor mockProcessor = mock(RequestDataValueProcessor.class);
    wac.getBean(RequestDataValueProcessorWrapper.class).setRequestDataValueProcessor(mockProcessor);
View Full Code Here


  @Test
  public void updateTargetUrlWithContextLoader() throws Exception {
    StaticWebApplicationContext wac = new StaticWebApplicationContext();
    wac.registerSingleton("requestDataValueProcessor", RequestDataValueProcessorWrapper.class);

    MockServletContext servletContext = new MockServletContext();
    ContextLoader contextLoader = new ContextLoader(wac);
    contextLoader.initWebApplicationContext(servletContext);
View Full Code Here

    @Override
    protected WebApplicationContext createServletApplicationContext() {
      StaticWebApplicationContext servletContext =
          new StaticWebApplicationContext();
      servletContext.registerSingleton("bean", MyBean.class);
      return servletContext;
    }

    @Override
    protected String[] getServletMappings() {
View Full Code Here

      extends AbstractContextLoaderInitializer {

    @Override
    protected WebApplicationContext createRootApplicationContext() {
      StaticWebApplicationContext rootContext = new StaticWebApplicationContext();
      rootContext.registerSingleton(BEAN_NAME, MyBean.class);
      return rootContext;
    }
  }

  private static class MyBean {
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.