Examples of XmlWebApplicationContext


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

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

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

*/
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

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

    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

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

  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

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

     * @return
     */
    private ApplicationContext createSpringContext(ApplicationContext ctx,
                                                   ServletConfig sc,
                                                   String location) {
        XmlWebApplicationContext ctx2 = new XmlWebApplicationContext();
        ctx2.setServletConfig(sc);

        Resource r = ctx2.getResource(location);
        try {
            InputStream in = r.getInputStream();
            in.close();
        } catch (IOException e) {
            //ignore
            r = ctx2.getResource("classpath:" + location);
            try {
                r.getInputStream().close();
            } catch (IOException e2) {
                //ignore
                r = null;
            }
        }
        try {
            if (r != null) {
                location = r.getURL().toExternalForm();
            }
        } catch (IOException e) {
            //ignore
        }       
        if (ctx != null) {
            ctx2.setParent(ctx);
            String names[] = ctx.getBeanNamesForType(Bus.class);
            if (names == null || names.length == 0) {
                ctx2.setConfigLocations(new String[] {"classpath:/META-INF/cxf/cxf.xml",
                                                      location});               
            } else {
                ctx2.setConfigLocations(new String[] {location});                               
            }
        } else {
            ctx2.setConfigLocations(new String[] {"classpath:/META-INF/cxf/cxf.xml",
                                                  location});           
        }
        ctx2.refresh();
        return ctx2;
    }
View Full Code Here

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

        List<String> servletLocations = new ArrayList<String>();
        servletLocations.add(CONTEXT_SERVLET);
        servletLocations.add(CONTEXT_TEST_SERVLET);
        servletLocations.addAll(localLocations);

        XmlWebApplicationContext servletContext = new XmlWebApplicationContext();
        servletContext.setParent(modelContext);
        servletContext.setConfigLocations(Iterables.toArray(servletLocations, String.class));
        servletContext.setAllowCircularReferences(true);
        servletContext.setAllowBeanDefinitionOverriding(true);

        MockServletContext mockServletContext = new MockServletContext();
        servletContext.setServletContext(mockServletContext);

        MockServletConfig mockServletConfig = new MockServletConfig(mockServletContext, "springServlet");
        servletContext.setServletConfig(mockServletConfig);

        servletContext.refresh();

        return servletContext;
    }
View Full Code Here

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

  public static WicketTester getWicketTester(long langId) {
    Application app = new Application();
       
    WicketTester tester = new WicketTester(app);
    ServletContext sc = app.getServletContext();
        XmlWebApplicationContext xmlContext = new XmlWebApplicationContext();
        xmlContext.setConfigLocation("classpath:openmeetings-applicationContext.xml");
        xmlContext.setServletContext(sc);
        xmlContext.refresh();
        sc.setAttribute(ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, xmlContext);
        if (langId > 0) {
          WebSession.get().setLanguage(langId);
        }
        InitializationContainer.initComplete = true;
View Full Code Here

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

    }

    public void testWithSpringContext() throws Exception {
       

        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, msc);

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

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

               
                break;               
            }
        }

        XmlWebApplicationContext wctx = new XmlWebApplicationContext();
        wctx.setParent(ctx);
        wctx.setConfigLocation("");
        wctx.setServletContext(servletContext);
        wctx.refresh();
       
        servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, wctx);

        server.start();
       
View Full Code Here

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

                servletContext = context.getServletContext();
            }
        }

        XmlWebApplicationContext wctx = new XmlWebApplicationContext();
        wctx.setParent(ctx);
        wctx.setConfigLocation("");
        wctx.setServletContext(servletContext);
        wctx.refresh();
       
        servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, wctx);

        server.start();
       
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.