Package org.springframework.web.context.support

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


        final String[] locationArray = locations.toArray(new String[locations.size()]);
        for (int i = 0; i < locationArray.length; i++) {
            locationArray[i] = "classpath:" + locationArray[i];
        }
       
        final XmlWebApplicationContext context = new XmlWebApplicationContext(){
            @Override
            public String[] getConfigLocations() {
                return locationArray;
            }
        };
        context.setServletContext(new AttributeServletContext());
        context.refresh();
        return context;
    }
View Full Code Here


 
  private ConfigurableWebApplicationContext wac;

  public void setUp() throws Exception {
    MockServletContext sc = new MockServletContext("");
    wac = new XmlWebApplicationContext();
    wac.setServletContext(sc);
    wac.setConfigLocations(new String[] {CONF});
    wac.refresh();
  }
View Full Code Here

  private ConfigurableWebApplicationContext root;

  private MessageSource themeMsgSource;

  protected ConfigurableApplicationContext createContext() throws Exception {
    root = new XmlWebApplicationContext();
    MockServletContext sc = new MockServletContext();
    root.setServletContext(sc);
    root.setConfigLocations(new String[] {"/org/springframework/web/context/WEB-INF/applicationContext.xml"});
    root.refresh();

    ConfigurableWebApplicationContext wac = new XmlWebApplicationContext();
    wac.setParent(root);
    wac.setServletContext(sc);
    wac.setNamespace("test-servlet");
    wac.setConfigLocations(new String[] {"/org/springframework/web/context/WEB-INF/test-servlet.xml"});
    wac.refresh();

    Theme theme = ((ThemeSource) wac).getTheme(AbstractThemeResolver.ORIGINAL_DEFAULT_THEME_NAME);
    assertNotNull(theme);
    assertTrue("Theme name has to be the default theme name", AbstractThemeResolver.ORIGINAL_DEFAULT_THEME_NAME.equals(theme.getName()));
    themeMsgSource = theme.getMessageSource();
View Full Code Here

  private HandlerMapping hm;

  public void setUp() throws Exception {
    MockServletContext sc = new MockServletContext("");
    this.wac = new XmlWebApplicationContext();
    this.wac.setServletContext(sc);
    this.wac.setConfigLocations(new String[] {LOCATION});
    this.wac.refresh();
    this.hm = (HandlerMapping) this.wac.getBean("mapping");
  }
View Full Code Here

  private HandlerMapping hm4;

  public void setUp() throws Exception {
    MockServletContext sc = new MockServletContext("");
    this.wac = new XmlWebApplicationContext();
    this.wac.setServletContext(sc);
    this.wac.setConfigLocations(new String[] {LOCATION});
    this.wac.refresh();
    this.hm = (HandlerMapping) this.wac.getBean("mapping");
    this.hm2 = (HandlerMapping) this.wac.getBean("mapping2");
View Full Code Here

  private ConfigurableWebApplicationContext wac;

  public void setUp() throws Exception {
    MockServletContext sc = new MockServletContext("");
    wac = new XmlWebApplicationContext();
    wac.setServletContext(sc);
    wac.setConfigLocations(new String[] {CONF});
    wac.refresh();
    hm = (HandlerMapping) wac.getBean("urlMapping");
  }
View Full Code Here

public class AopNamespaceHandlerScopeTests extends TestCase {

  private ApplicationContext context;

  public void setUp() {
    XmlWebApplicationContext wac = new XmlWebApplicationContext();
    wac.setConfigLocations(new String[] {"classpath:org/springframework/aop/config/aopNamespaceHandlerScopeTests.xml"});
    wac.refresh();
    this.context = wac;
  }
View Full Code Here

*/
public class SimpleUrlHandlerMappingTests extends TestCase {

  public void testHandlerBeanNotFound() throws Exception {
    MockServletContext sc = new MockServletContext("");
    XmlWebApplicationContext root = new XmlWebApplicationContext();
    root.setServletContext(sc);
    root.setConfigLocations(new String[] {"/org/springframework/web/servlet/handler/map1.xml"});
    root.refresh();
    XmlWebApplicationContext wac = new XmlWebApplicationContext();
    wac.setParent(root);
    wac.setServletContext(sc);
    wac.setNamespace("map2err");
    wac.setConfigLocations(new String[] {"/org/springframework/web/servlet/handler/map2err.xml"});
    try {
      wac.refresh();
      fail("Should have thrown NoSuchBeanDefinitionException");
    }
    catch (FatalBeanException ex) {
      NoSuchBeanDefinitionException nestedEx = (NoSuchBeanDefinitionException) ex.getCause();
      assertEquals("mainControlle", nestedEx.getBeanName());
View Full Code Here

    checkMappings("urlMappingWithProps");
  }

  private void checkMappings(String beanName) throws Exception {
    MockServletContext sc = new MockServletContext("");
    XmlWebApplicationContext wac = new XmlWebApplicationContext();
    wac.setServletContext(sc);
    wac.setConfigLocations(new String[] {"/org/springframework/web/servlet/handler/map2.xml"});
    wac.refresh();
    Object bean = wac.getBean("mainController");
    Object otherBean = wac.getBean("otherController");
    Object defaultBean = wac.getBean("starController");
    HandlerMapping hm = (HandlerMapping) wac.getBean(beanName);

    MockHttpServletRequest req = new MockHttpServletRequest("GET", "/welcome.html");
    HandlerExecutionChain hec = getHandler(hm, req);
    assertTrue("Handler is correct bean", hec != null && hec.getHandler() == bean);
    assertEquals("/welcome.html", req.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE));
View Full Code Here

  private HandlerMapping hm4;

  public void setUp() throws Exception {
    MockServletContext sc = new MockServletContext("");
    this.wac = new XmlWebApplicationContext();
    this.wac.setServletContext(sc);
    this.wac.setConfigLocations(new String[] {LOCATION});
    this.wac.refresh();
    this.hm = (HandlerMapping) this.wac.getBean("mapping");
    this.hm2 = (HandlerMapping) this.wac.getBean("mapping2");
View Full Code Here

TOP

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

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.