Package org.springframework.web.context.support

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


  }

  public void testFormController() throws Exception {
    DispatcherPortlet portlet = new DispatcherPortlet() {
      protected ApplicationContext createPortletApplicationContext(ApplicationContext parent) throws BeansException {
        GenericWebApplicationContext wac = new GenericWebApplicationContext();
        wac.registerBeanDefinition("controller", new RootBeanDefinition(MyFormController.class));
        wac.refresh();
        return wac;
      }

      protected void render(ModelAndView mv, RenderRequest request, RenderResponse response) throws Exception {
        new TestView().render(mv.getViewName(), mv.getModel(), request, response);
View Full Code Here


  }

  public void testModelFormController() throws Exception {
    DispatcherPortlet portlet = new DispatcherPortlet() {
      protected ApplicationContext createPortletApplicationContext(ApplicationContext parent) throws BeansException {
        GenericWebApplicationContext wac = new GenericWebApplicationContext();
        wac.registerBeanDefinition("controller", new RootBeanDefinition(MyModelFormController.class));
        wac.refresh();
        return wac;
      }

      protected void render(ModelAndView mv, RenderRequest request, RenderResponse response) throws Exception {
        new TestView().render(mv.getViewName(), mv.getModel(), request, response);
View Full Code Here

  }

  public void testCommandProvidingFormController() throws Exception {
    DispatcherPortlet portlet = new DispatcherPortlet() {
      protected ApplicationContext createPortletApplicationContext(ApplicationContext parent) throws BeansException {
        GenericWebApplicationContext wac = new GenericWebApplicationContext();
        wac.registerBeanDefinition("controller", new RootBeanDefinition(MyCommandProvidingFormController.class));
        RootBeanDefinition adapterDef = new RootBeanDefinition(AnnotationMethodHandlerAdapter.class);
        adapterDef.getPropertyValues().addPropertyValue("webBindingInitializer", new MyWebBindingInitializer());
        wac.registerBeanDefinition("handlerAdapter", adapterDef);
        wac.refresh();
        return wac;
      }

      protected void render(ModelAndView mv, RenderRequest request, RenderResponse response) throws Exception {
        new TestView().render(mv.getViewName(), mv.getModel(), request, response);
View Full Code Here

  }

  public void testTypedCommandProvidingFormController() throws Exception {
    DispatcherPortlet portlet = new DispatcherPortlet() {
      protected ApplicationContext createPortletApplicationContext(ApplicationContext parent) throws BeansException {
        GenericWebApplicationContext wac = new GenericWebApplicationContext();
        wac.registerBeanDefinition("controller", new RootBeanDefinition(MyTypedCommandProvidingFormController.class));
        wac.registerBeanDefinition("controller2", new RootBeanDefinition(MyOtherTypedCommandProvidingFormController.class));
        RootBeanDefinition adapterDef = new RootBeanDefinition(AnnotationMethodHandlerAdapter.class);
        adapterDef.getPropertyValues().addPropertyValue("webBindingInitializer", new MyWebBindingInitializer());
        adapterDef.getPropertyValues().addPropertyValue("customArgumentResolver", new MySpecialArgumentResolver());
        wac.registerBeanDefinition("handlerAdapter", adapterDef);
        wac.refresh();
        return wac;
      }
      protected void render(ModelAndView mv, RenderRequest request, RenderResponse response) throws Exception {
        new TestView().render(mv.getViewName(), mv.getModel(), request, response);
      }
View Full Code Here

  }

  public void testBinderInitializingCommandProvidingFormController() throws Exception {
    DispatcherPortlet portlet = new DispatcherPortlet() {
      protected ApplicationContext createPortletApplicationContext(ApplicationContext parent) throws BeansException {
        GenericWebApplicationContext wac = new GenericWebApplicationContext();
        wac.registerBeanDefinition("controller", new RootBeanDefinition(MyBinderInitializingCommandProvidingFormController.class));
        wac.refresh();
        return wac;
      }

      protected void render(ModelAndView mv, RenderRequest request, RenderResponse response) throws Exception {
        new TestView().render(mv.getViewName(), mv.getModel(), request, response);
View Full Code Here

  protected String getDesiredContentType() {
    return "text/html";
  }

  public void testConfigureExporterParametersWithEncodingFromPropertiesFile() throws Exception {
    GenericWebApplicationContext ac = new GenericWebApplicationContext();
    ac.setServletContext(new MockServletContext());
    BeanDefinitionReader reader = new PropertiesBeanDefinitionReader(ac);
    reader.loadBeanDefinitions(new ClassPathResource("view.properties", getClass()));
    ac.refresh();

    AbstractJasperReportsView view = (AbstractJasperReportsView) ac.getBean("report");
    String encoding = (String) view.getConvertedExporterParameters().get(JRHtmlExporterParameter.CHARACTER_ENCODING);
    assertEquals("UTF-8", encoding);

    request.setAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE, ac);
    view.render(getModel(), request, response);
View Full Code Here

  public void testBinderInitializingCommandProvidingFormController() throws Exception {
    @SuppressWarnings("serial")
    DispatcherServlet servlet = new DispatcherServlet() {
      protected WebApplicationContext createWebApplicationContext(WebApplicationContext parent) {
        GenericWebApplicationContext wac = new GenericWebApplicationContext();
        wac.registerBeanDefinition("controller", new RootBeanDefinition(MyBinderInitializingCommandProvidingFormController.class));
        wac.registerBeanDefinition("viewResolver", new RootBeanDefinition(TestViewResolver.class));
        wac.refresh();
        return wac;
      }
    };
    servlet.init(new MockServletConfig());
View Full Code Here

  public void testSpecificBinderInitializingCommandProvidingFormController() throws Exception {
    @SuppressWarnings("serial")
    DispatcherServlet servlet = new DispatcherServlet() {
      protected WebApplicationContext createWebApplicationContext(WebApplicationContext parent) {
        GenericWebApplicationContext wac = new GenericWebApplicationContext();
        wac.registerBeanDefinition("controller", new RootBeanDefinition(MySpecificBinderInitializingCommandProvidingFormController.class));
        wac.registerBeanDefinition("viewResolver", new RootBeanDefinition(TestViewResolver.class));
        wac.refresh();
        return wac;
      }
    };
    servlet.init(new MockServletConfig());
View Full Code Here

    final MockServletConfig servletConfig = new MockServletConfig(servletContext);

    @SuppressWarnings("serial")
    DispatcherServlet servlet = new DispatcherServlet() {
      protected WebApplicationContext createWebApplicationContext(WebApplicationContext parent) {
        GenericWebApplicationContext wac = new GenericWebApplicationContext();
        wac.setServletContext(servletContext);
        RootBeanDefinition bd = new RootBeanDefinition(MyParameterDispatchingController.class);
        bd.setScope(WebApplicationContext.SCOPE_REQUEST);
        wac.registerBeanDefinition("controller", bd);
        AnnotationConfigUtils.registerAnnotationConfigProcessors(wac);
        wac.getBeanFactory().registerResolvableDependency(ServletConfig.class, servletConfig);
        wac.refresh();
        return wac;
      }
    };
    servlet.init(servletConfig);
View Full Code Here

  public void testMethodNameDispatchingController() throws Exception {
    @SuppressWarnings("serial")
    DispatcherServlet servlet = new DispatcherServlet() {
      protected WebApplicationContext createWebApplicationContext(WebApplicationContext parent) {
        GenericWebApplicationContext wac = new GenericWebApplicationContext();
        wac.registerBeanDefinition("controller", new RootBeanDefinition(MethodNameDispatchingController.class));
        wac.refresh();
        return wac;
      }
    };
    servlet.init(new MockServletConfig());
View Full Code Here

TOP

Related Classes of org.springframework.web.context.support.GenericWebApplicationContext

Copyright © 2018 www.massapicom. 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.