Package org.springframework.web.context.support

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


        MockServletContext sc = new MockServletContext();
        StaticWebApplicationContext wac = new StaticWebApplicationContext();
        wac.setServletContext(sc);
        wac.getDefaultListableBeanFactory().registerSingleton("sessionFactory", sf);
        wac.getDefaultListableBeanFactory().registerSingleton("mySessionFactory", sf2);
        wac.refresh();
        sc.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);
        MockHttpServletRequest request = new MockHttpServletRequest(sc);
        MockHttpServletResponse response = new MockHttpServletResponse();

        MockFilterConfig filterConfig = new MockFilterConfig(wac.getServletContext(), "filter");
View Full Code Here


        MockServletContext servletContext = new MockServletContext();
        servletContext.setAttribute(StaticWebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, context);

        context.setServletContext(servletContext);
        context.registerSingleton("listener", MockApplicationListener.class, null);
        context.refresh();

        MockHttpSession session = new MockHttpSession(servletContext);
        MockApplicationListener listener = (MockApplicationListener) context.getBean("listener");

        HttpSessionEvent event = new HttpSessionEvent(session);
View Full Code Here

    MockServletContext sc = new MockServletContext();
    StaticWebApplicationContext wac = new StaticWebApplicationContext();
    wac.setServletContext(sc);
    wac.getDefaultListableBeanFactory().registerSingleton("entityManagerFactory", factory);
    wac.getDefaultListableBeanFactory().registerSingleton("myEntityManagerFactory", factory2);
    wac.refresh();
    sc.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);
    MockHttpServletRequest request = new MockHttpServletRequest(sc);
    MockHttpServletResponse response = new MockHttpServletResponse();

    MockFilterConfig filterConfig = new MockFilterConfig(wac.getServletContext(), "filter");
View Full Code Here

  public void testDelegatingVariableResolver() {
    final StaticWebApplicationContext wac = new StaticWebApplicationContext();
    wac.registerSingleton("bean1", TestBean.class, null);
    wac.registerSingleton("var1", TestBean.class, null);
    wac.refresh();
    TestBean bean1 = (TestBean) wac.getBean("bean1");

    // We need to override the getWebApplicationContext method here:
    // FacesContext and ExternalContext are hard to mock.
    DelegatingVariableResolver resolver = new DelegatingVariableResolver(new OriginalVariableResolver()) {
View Full Code Here

  public void testSpringBeanVariableResolver() {
    final StaticWebApplicationContext wac = new StaticWebApplicationContext();
    wac.registerSingleton("bean1", TestBean.class, null);
    wac.registerSingleton("var1", TestBean.class, null);
    wac.refresh();
    TestBean bean1 = (TestBean) wac.getBean("bean1");
    TestBean var1 = (TestBean) wac.getBean("var1");

    // We need to override the getWebApplicationContext method here:
    // FacesContext and ExternalContext are hard to mock.
View Full Code Here

  }

  public void testThemeSourceNestingWithParentDefault() throws NoSuchMessageException {
    StaticWebApplicationContext leaf = new StaticWebApplicationContext();
    leaf.setParent(getApplicationContext());
    leaf.refresh();
    assertNotNull("theme still found", leaf.getTheme("theme"));
    MessageSource ms = leaf.getTheme("theme").getMessageSource();
    String msg = ms.getMessage("theme.example2", null, null, Locale.UK);
    assertEquals("correct overridden msg", "test-message2", msg);
  }
View Full Code Here

    ServletContext sc = new MockServletContext();

    StaticWebApplicationContext wac = new StaticWebApplicationContext();
    wac.setServletContext(sc);
    wac.registerSingleton("targetFilter", MockFilter.class);
    wac.refresh();
    sc.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);

    MockFilter targetFilter = (MockFilter) wac.getBean("targetFilter");

    MockFilterConfig proxyConfig = new MockFilterConfig(sc);
View Full Code Here

  private void doTestWithApplicationContext(boolean lazy) throws Exception {
    StaticWebApplicationContext wac = new StaticWebApplicationContext();
    wac.setServletContext(new MockServletContext());
    wac.getServletContext().setAttribute(WebUtils.TEMP_DIR_CONTEXT_ATTRIBUTE, new File("mytemp"));
    wac.refresh();
    MockCommonsMultipartResolver resolver = new MockCommonsMultipartResolver();
    resolver.setMaxUploadSize(1000);
    resolver.setMaxInMemorySize(100);
    resolver.setDefaultEncoding("enc");
    if (lazy) {
View Full Code Here

    ServletContext sc = new MockServletContext();

    StaticWebApplicationContext wac = new StaticWebApplicationContext();
    wac.setServletContext(sc);
    wac.registerSingleton("targetFilter", MockFilter.class);
    wac.refresh();
    sc.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);

    MockFilter targetFilter = (MockFilter) wac.getBean("targetFilter");

    MockFilterConfig proxyConfig = new MockFilterConfig(sc, "targetFilter");
View Full Code Here

  public void testWithServletContextAndFilter() throws Exception {
    StaticWebApplicationContext wac = new StaticWebApplicationContext();
    wac.setServletContext(new MockServletContext());
    wac.registerSingleton("filterMultipartResolver", MockCommonsMultipartResolver.class, new MutablePropertyValues());
    wac.getServletContext().setAttribute(WebUtils.TEMP_DIR_CONTEXT_ATTRIBUTE, new File("mytemp"));
    wac.refresh();
    wac.getServletContext().setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);
    CommonsMultipartResolver resolver = new CommonsMultipartResolver(wac.getServletContext());
    assertTrue(resolver.getFileItemFactory().getRepository().getAbsolutePath().endsWith("mytemp"));

    MockFilterConfig filterConfig = new MockFilterConfig(wac.getServletContext(), "filter");
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.