List of usage examples for org.springframework.mock.web MockServletContext MockServletContext
public MockServletContext()
From source file:org.tonguetied.web.CookieUtilsTest.java
/** * @throws java.lang.Exception//from w ww.j a va 2 s . c o m */ @Before public void setUp() throws Exception { ServletContext context = new MockServletContext(); request = new MockHttpServletRequest(context); request.setContextPath("/test"); }
From source file:newcontroller.handler.impl.HttpMessageConverterHandlerBridgeTest.java
@Test public void testBridge() throws Exception { HttpServletRequest request = MockMvcRequestBuilders.get("/").param("foo", "aaa").param("bar", "100") .buildRequest(new MockServletContext()); MockHttpServletResponse response = new MockHttpServletResponse(); HttpMessageConverterHandlerBridge<String> bridge = new HttpMessageConverterHandlerBridge<>("Hello World!", new StringHttpMessageConverter()); bridge.bridge(new DefaultRequest(request), new DefaultResponse(response)); assertThat(response.getContentAsString(), is("Hello World!")); }
From source file:com.github.persapiens.jsfboot.ServletContextConfigurerIT.java
public void testKey() { ServletContext servletContext = new MockServletContext(); ServletContextConfigurer servletContextConfigurer = new JsfServletContextConfigurer(servletContext); servletContextConfigurer.configure(); assertThat(servletContext.getInitParameter("jsf.key")).isEqualTo("value"); }
From source file:org.sventon.cache.DefaultCacheGatewayTest.java
private CacheGateway createCache() throws CacheException { final ConfigDirectory configDirectory = TestUtils.getTestConfigDirectory(); configDirectory.setCreateDirectories(false); final MockServletContext servletContext = new MockServletContext(); servletContext.setContextPath("sventon-test"); configDirectory.setServletContext(servletContext); final DirEntryCacheManager cacheManager = new DirEntryCacheManager(configDirectory); final DirEntryCache entryCache = new CompassDirEntryCache(new File("test")); entryCache.init();/*from w w w . j a v a 2 s. c om*/ cacheManager.addCache(repositoryName, entryCache); for (DirEntry dirEntry : TestUtils.getDirectoryList()) { entryCache.add(dirEntry); } final DefaultCacheGateway cache = new DefaultCacheGateway(); cache.setEntryCacheManager(cacheManager); return cache; }
From source file:org.jtwig.unit.loader.impl.WebResourceLoaderTest.java
@Before public void before() throws Exception { ctx = new MockServletContext(); loader = new WebResourceLoader(ctx); }
From source file:com.xemantic.tadedon.guice.servlet.GuiceServletsTest.java
@Test public void shouldGetProductionStageWhenNoStageSpecified() throws Exception { // given//from www .ja va2 s . c o m MockServletContext context = new MockServletContext(); // when Stage stage = GuiceServlets.getStage(context); // then assertThat(stage, is(Stage.PRODUCTION)); }
From source file:org.eclipse.virgo.snaps.core.internal.webapp.container.SnapHttpServletTests.java
@Before public void before() { MockServletContext parentContext = new MockServletContext(); Bundle bundle = createMock(Bundle.class); SnapServletContext context = new SnapServletContext(parentContext, bundle, "/contextPath"); this.parentSession = new MockHttpSession(); this.snapSession = new SnapHttpSession(parentSession, context); }
From source file:org.joinfaces.mojarra.MojarraServletContextConfigurerIT.java
@Test public void testConfigure() { ServletContext servletContext = new MockServletContext(); MojarraServletContextConfigurer mojarraServletContextConfigurer = MojarraServletContextConfigurer.builder() .mojarraProperties(this.mojarraProperties).servletContext(servletContext).build(); mojarraServletContextConfigurer.configure(); assertThat(servletContext.getInitParameter(MojarraServletContextConfigurer.PREFFIX + ".clientStateTimeout")) .isEqualTo("10"); }
From source file:org.joinfaces.myfaces.MyfacesServletContextConfigurerIT.java
@Test public void testConfigure() { ServletContext servletContext = new MockServletContext(); MyfacesServletContextConfigurer myfacesServletContextConfigurer = MyfacesServletContextConfigurer.builder() .myfacesProperties(this.myfacesProperties).servletContext(servletContext).build(); myfacesServletContextConfigurer.configure(); assertThat(servletContext//from ww w. j av a 2 s. com .getInitParameter(MyfacesServletContextConfigurer.PREFFIX + "STRICT_JSF_2_CC_EL_RESOLVER")) .isEqualTo("myElResolver"); }
From source file:org.jasig.cas.web.init.SafeContextLoaderListenerTests.java
protected void setUp() throws Exception { this.listener = new SafeContextLoaderListener(); this.servletContext = new MockServletContext(); this.servletContextEvent = new ServletContextEvent(this.servletContext); }