Package org.springframework.web.context.support

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


        } else {
            ctx2.setConfigLocations(new String[] {"classpath:/META-INF/cxf/cxf.xml",
                                                  location});
            createdContext = ctx2;
        }
        ctx2.refresh();
        return ctx2;
    }
    public void destroyBus() {
        if (busCreated) {
            //if we created the Bus, we need to destroy it.  Otherwise, spring will handleit.
View Full Code Here


  public void test() {

    XmlWebApplicationContext wac = new XmlWebApplicationContext();
    wac.setConfigLocation("file:src/main/webapp/WEB-INF/spring/root-context.xml");
    wac.setServletContext(new MockServletContext());
    wac.refresh();
   
    ServletWebRequest webRequest = new ServletWebRequest(new MockHttpServletRequest());
    RequestContextHolder.setRequestAttributes(webRequest);
   
    MyBeanClass myBeanClass = wac.getBean("myBeanClass", MyBeanClass.class);
View Full Code Here

        ConfigurableWebApplicationContext ac = new XmlWebApplicationContext();
        ServletContext msc = (ServletContext) new MockServletContext();
        msc.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, ac);
        ac.setServletContext(msc);
        ac.setConfigLocations(new String[] {"org/apache/struts2/spring/StrutsSpringObjectFactoryTest-applicationContext.xml"});
        ac.refresh();
        StrutsSpringObjectFactory fac = new StrutsSpringObjectFactory("constructor", null, null, msc, null, container);

        assertEquals(AutowireCapableBeanFactory.AUTOWIRE_CONSTRUCTOR, fac.getAutowireStrategy());
    }
View Full Code Here

        XmlWebApplicationContext context = new XmlWebApplicationContext();
        context.setServletContext(servletContext);
        context.setConfigLocations(new String[] {
            configuration
        });
        context.refresh();
        context.start();

        servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, context);

        return context;
View Full Code Here

  @Before
  public void setUp() {
    XmlWebApplicationContext wac = new XmlWebApplicationContext();
    wac.setConfigLocations(new String[] {CONTEXT});
    wac.refresh();
    this.context = wac;
  }

  @Test
  public void testSingletonScoping() throws Exception {
View Full Code Here

  @Test
  public void xmlWebApplicationContext() {
    AbstractRefreshableWebApplicationContext ctx = new XmlWebApplicationContext();
    ctx.setConfigLocation("classpath:" + XML_PATH);
    ctx.setEnvironment(prodWebEnv);
    ctx.refresh();

    assertHasEnvironment(ctx, prodWebEnv);
    assertEnvironmentBeanRegistered(ctx);
    assertEnvironmentAwareInvoked(ctx, prodWebEnv);
    assertThat(ctx.containsBean(DEV_BEAN_NAME), is(false));
View Full Code Here

  public void handlerBeanNotFound() 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"});
View Full Code Here

    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

  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);
View Full Code Here

    XmlWebApplicationContext wac = new XmlWebApplicationContext();
    wac.setParent(root);
    wac.setServletContext(sc);
    wac.setNamespace("testNamespace");
    wac.setConfigLocations(new String[] {"/org/springframework/web/context/WEB-INF/test-servlet.xml"});
    wac.refresh();
    try {
      wac.getMessage("someMessage", null, Locale.getDefault());
      fail("Should have thrown NoSuchMessageException");
    }
    catch (NoSuchMessageException ex) {
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.