List of usage examples for org.springframework.mock.web MockServletContext MockServletContext
public MockServletContext()
From source file:org.geoserver.ows.StylePublisherTest.java
@Override protected void onSetUp(SystemTestData testData) throws Exception { Catalog catalog = getCatalog();/*from w w w .j a va 2 s . c o m*/ publisher = new StylePublisher(catalog); publisher.setServletContext(new MockServletContext()); GeoServerResourceLoader resourceLoader = getResourceLoader(); // add style - global resourceLoader.copyFromClassPath("org/geoserver/ows/smileyface.png", "styles/smileyface.png"); paths.add(new String[] { "styles", "smileyface.png" }); // add style - global in subdirectory resourceLoader.copyFromClassPath("org/geoserver/ows/smileyface.png", "styles/icons/smileyface.png"); paths.add(new String[] { "styles", "icons", "smileyface.png" }); // add style - workspaced resourceLoader.copyFromClassPath("org/geoserver/ows/house.svg", "workspaces/cite/styles/house.svg"); paths.add(new String[] { "styles", "cite", "house.svg" }); // add style - workspaced in subdirectory resourceLoader.copyFromClassPath("org/geoserver/ows/house.svg", "workspaces/cite/styles/icons/house.svg"); paths.add(new String[] { "styles", "cite", "icons", "house.svg" }); // add style - workspaced style with global image paths.add(new String[] { "styles", "cite", "smileyface.png" }); // add style - workspaced style with global image in subdirectory paths.add(new String[] { "styles", "cite", "icons", "smileyface.png" }); // testing over-riding global image with workspaced image resourceLoader.copyFromClassPath("org/geoserver/ows/smileyface.png", "styles/override.png"); resourceLoader.copyFromClassPath("org/geoserver/ows/grass_fill.png", "workspaces/cite/styles/override.png"); // testing over-riding global image with workspaced image in subdirectory resourceLoader.copyFromClassPath("org/geoserver/ows/smileyface.png", "styles/icons/override.png"); resourceLoader.copyFromClassPath("org/geoserver/ows/grass_fill.png", "workspaces/cite/styles/icons/override.png"); }
From source file:org.kuali.mobility.shared.controllers.FileControllerTest.java
@BeforeClass public static void setUpClass() throws Exception { servletContext = new MockServletContext(); }
From source file:org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_8.SessionController1_8Test.java
@Before public void before() { controller = new SessionController1_8(); MockHttpServletRequest hsr = new MockHttpServletRequest(); hsr.setSession(new MockHttpSession(new MockServletContext(), SESSION_ID)); request = new ServletWebRequest(hsr); Context.getAdministrationService().saveGlobalProperty( new GlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_LOCALE_ALLOWED_LIST, "en_GB, sp, fr")); }
From source file:org.opennms.web.springframework.security.LdapAuthTest.java
@Before public void setUp() { m_servletContext = new MockServletContext(); m_servletContext.setContextPath(m_contextPath); }
From source file:org.osaf.cosmo.atom.provider.mock.BaseMockRequestContext.java
private static MockHttpServletRequest createRequest(String method, String uri) { MockServletContext ctx = new MockServletContext(); return new MockHttpServletRequest(ctx, method, uri); }
From source file:org.osaf.cosmo.BaseMockServletTestCase.java
/** */// www . ja v a 2s . c o m protected void setUp() throws Exception { securityManager = new MockSecurityManager(); servletContext = new MockServletContext(); servletConfig = new MockServletConfig(servletContext); }
From source file:org.springframework.boot.autoconfigure.AutoConfigurationReportLoggingInitializerTests.java
@Test public void canBeUsedInNonGenericApplicationContext() throws Exception { AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext(); context.setServletContext(new MockServletContext()); context.register(Config.class); new AutoConfigurationReportLoggingInitializer().initialize(context); context.refresh();//from www. java2 s . c o m assertNotNull(context.getBean(AutoConfigurationReport.class)); }
From source file:org.springframework.boot.autoconfigure.logging.AutoConfigurationReportLoggingInitializerTests.java
@Test public void canBeUsedInNonGenericApplicationContext() throws Exception { AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext(); context.setServletContext(new MockServletContext()); context.register(Config.class); new AutoConfigurationReportLoggingInitializer().initialize(context); context.refresh();/*w w w . j av a 2 s. c om*/ assertNotNull(context.getBean(ConditionEvaluationReport.class)); }
From source file:org.springframework.faces.mvc.servlet.FacesHandlerAdapterTests.java
private void doTestOverrideInitParams(boolean override) throws Exception { adapter.setOverrideInitParameters(override); ServletContext servletContext = new MockServletContext(); adapter.setServletContext(servletContext); ServletContext facesServletContext = adapter.getFacesServletContext(); assertEquals((override ? "false" : null), facesServletContext.getInitParameter("org.apache.myfaces.ERROR_HANDLING")); }
From source file:org.springframework.test.context.support.WebApplicationContextLoader.java
private void prepareContext(GenericWebApplicationContext context) { MockServletContext servletContext = new MockServletContext(); context.setServletContext(servletContext); servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, context); }