Search in sources :

Example 1 with ActionServlet30

use of org.mifos.framework.struts.ActionServlet30 in project head by mifos.

the class MifosMockStrutsTestCase method setStrutsConfig.

protected void setStrutsConfig() throws IOException {
    /*
         * Add a pointer to the context directory so that the web.xml file can be located when running test cases using
         * the junit plugin inside Eclipse.
         * 
         * Find the Web Resources dir (where WEB-INF lives) via Classpath, not hard-coded filenames.
         */
    Resource r = new ClassPathResource("META-INF/resources/WEB-INF/struts-config.xml");
    if (!r.exists() || !r.isReadable()) {
        fail(r.getDescription() + " does not exist or is not readable");
    }
    File webResourcesDirectory = r.getFile().getParentFile().getParentFile();
    mockStruts.setContextDirectory(webResourcesDirectory);
    setConfigFile("/WEB-INF/struts-config.xml,/WEB-INF/other-struts-config.xml");
    /*
         * Because there is no more old-style web.xml as strutstest expects, we simply hard-code our ActionServlet
         * (actually our new ActionServlet30).
         * 
         * Because web.xml (now web-fragment.xml) isn't actually read, the ActionServlet is not initialized with servlet
         * init-params config for all /WEB-INF/*-struts-config.xml listed in web(-fragment).xml, nor are the
         * context-param read into config initParameter from web.xml by the MockStrutsTestCase. All Mifos *StrutsTest
         * don't seem to need that though, and pass with this.
         */
    mockStruts.setActionServlet(new ActionServlet30());
    request = mockStruts.getMockRequest();
    context = mockStruts.getMockContext();
}
Also used : ActionServlet30(org.mifos.framework.struts.ActionServlet30) ClassPathResource(org.springframework.core.io.ClassPathResource) Resource(org.springframework.core.io.Resource) File(java.io.File) ClassPathResource(org.springframework.core.io.ClassPathResource)

Aggregations

File (java.io.File)1 ActionServlet30 (org.mifos.framework.struts.ActionServlet30)1 ClassPathResource (org.springframework.core.io.ClassPathResource)1 Resource (org.springframework.core.io.Resource)1