use of org.springframework.mock.web.test.MockServletContext in project spring-framework by spring-projects.
the class JythonScriptTemplateTests method setup.
@Before
public void setup() {
this.webAppContext = mock(WebApplicationContext.class);
this.servletContext = new MockServletContext();
this.servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, this.webAppContext);
}
use of org.springframework.mock.web.test.MockServletContext in project spring-framework by spring-projects.
the class NashornScriptTemplateTests method setup.
@Before
public void setup() {
this.webAppContext = mock(WebApplicationContext.class);
this.servletContext = new MockServletContext();
this.servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, this.webAppContext);
}
use of org.springframework.mock.web.test.MockServletContext in project spring-framework by spring-projects.
the class TestValidator method loadBeanDefinitions.
private void loadBeanDefinitions(String fileName) {
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(this.appContext);
ClassPathResource resource = new ClassPathResource(fileName, MessageBrokerBeanDefinitionParserTests.class);
reader.loadBeanDefinitions(resource);
this.appContext.setServletContext(new MockServletContext());
this.appContext.refresh();
}
use of org.springframework.mock.web.test.MockServletContext in project spring-framework by spring-projects.
the class ResourceTests method testServletContextResourceWithRelativePath.
@Test
public void testServletContextResourceWithRelativePath() throws IOException {
MockServletContext sc = new MockServletContext();
Resource resource = new ServletContextResource(sc, "dir/");
Resource relative = resource.createRelative("subdir");
assertEquals(new ServletContextResource(sc, "dir/subdir"), relative);
}
use of org.springframework.mock.web.test.MockServletContext in project spring-framework by spring-projects.
the class Spr8510Tests method abstractRefreshableWAC_respectsProgrammaticConfigLocations.
@Test
public void abstractRefreshableWAC_respectsProgrammaticConfigLocations() {
XmlWebApplicationContext ctx = new XmlWebApplicationContext();
ctx.setConfigLocation("programmatic.xml");
ContextLoaderListener cll = new ContextLoaderListener(ctx);
MockServletContext sc = new MockServletContext();
try {
cll.contextInitialized(new ServletContextEvent(sc));
fail("expected exception");
} catch (Throwable t) {
// assert that an attempt was made to load the correct XML
assertTrue(t.getMessage(), t.getMessage().endsWith("Could not open ServletContext resource [/programmatic.xml]"));
}
}
Aggregations