Spring Framework MockServletContext - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework MockServletContext class.

This code example shows how to use the following methods:addInitParameter
    } 
 
    @Override 
    protected ModuleDef[] provideExtraModuleDefs() 
    { 
        servletContext = new MockServletContext();
        servletContext.addInitParameter(
                "contextConfigLocation", 
                "classpath*:applicationContext.xml"); 
        return new ModuleDef[] 
        { new SpringModuleDef(servletContext) };
    } 
 
} 
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:addInitParameter, setContextPath
        bean.afterPropertiesSet(); 
 
        MockDatabase db = new MockDatabase(true); 
        DataSourceFactory.setInstance(db); 
 
        servletContext = new MockServletContext("file:src/main/webapp"); 
 
        servletContext.addInitParameter("contextConfigLocation",  
                                        "classpath:/org/opennms/web/rest/applicationContext-test.xml " + 
                                        "classpath:/META-INF/opennms/applicationContext-commonConfigs.xml " + 
                                        "classpath*:/META-INF/opennms/component-service.xml " + 
                                        "classpath*:/META-INF/opennms/component-dao.xml " + 
                                        "classpath:/META-INF/opennms/applicationContext-reportingCore.xml " + 
                                        "classpath:/org/opennms/web/svclayer/applicationContext-svclayer.xml " + 
                                        "classpath:/META-INF/opennms/applicationContext-reporting.xml " + 
                                        "/WEB-INF/applicationContext-spring-security.xml " + 
                                        "/WEB-INF/applicationContext-spring-webflow.xml" 
        ); 
 
        servletContext.addInitParameter("parentContextKey", "daoContext"); 

7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
	public void test3() throws Exception {
		try { 
			PortletBagFactory portletBagFactory = new PortletBagFactory();
 
			portletBagFactory.setClassLoader(getClass().getClassLoader());
			portletBagFactory.setServletContext(new MockServletContext());
 
			portletBagFactory.create(new PortletImpl());
 
			Assert.fail();
		} 
		catch (IllegalStateException ise) {
		} 
	} 
 
	@Test
	public void test4_initializedInstance() throws Exception {
		try { 
			PortletImpl portletImpl = new PortletImpl();
 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:addInitParameter, setContextPath
		bean.afterPropertiesSet(); 
 
		MockDatabase db = new MockDatabase(true); 
		DataSourceFactory.setInstance(db); 
 
		servletContext = new MockServletContext("file:src/main/webapp"); 
 
		servletContext.addInitParameter( 
				"contextConfigLocation",  
				"classpath:/META-INF/opennms/applicationContext-commonConfigs.xml " + 
				"classpath:/META-INF/opennms/applicationContext-soa.xml " + 
				"classpath:/META-INF/opennms/applicationContext-dao.xml " + 
				"classpath*:/META-INF/opennms/component-service.xml " + 
				"classpath*:/META-INF/opennms/component-dao.xml " + 
 
				// Contexts within this project 
				"/WEB-INF/applicationContext-common.xml " + 
				"/WEB-INF/applicationContext-serviceRegistryRemoting.xml " + 
				"/WEB-INF/applicationContext-spring-security.xml " +  
				"/WEB-INF/applicationContext-svclayer.xml " 

7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:addInitParameter
    } 
 
    @Test 
    public void testAllowsRenewContextParam() throws Exception { 
        final Cas10TicketValidationFilter f = new Cas10TicketValidationFilter(); 
        final MockServletContext context = new MockServletContext(); 
        context.addInitParameter("casServerUrlPrefix", "https://cas.example.com"); 
        context.addInitParameter("renew", "true"); 
        final TicketValidator validator = f.getTicketValidator(new MockFilterConfig(context)); 
        assertTrue(validator instanceof Cas10TicketValidator); 
        assertTrue(((Cas10TicketValidator) validator).isRenew()); 
    } 
} 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
	private MockServletContext servletContext; 
	private MockHttpServletRequest request; 
 
	@Before 
	public void setup() { 
		servletContext = new MockServletContext(); 
		request = new MockHttpServletRequest(); 
		response = new MockHttpServletResponse(); 
		pageContext = new MockPageContext(servletContext, request, response); 
	} 
 
	@Test 
	public void initWithExplicitApiKey() throws Exception { 
		FacebookInitTag tag = new FacebookInitTag(); 
		tag.setPageContext(pageContext); 
		tag.setAppId("test-id"); 
		assertEquals(TagSupport.SKIP_BODY, tag.doStartTag()); 
		assertEquals(TagSupport.EVAL_PAGE, tag.doEndTag()); 
		assertEquals( 
			"<script src='http://connect.facebook.net/en_US/all.js'></script><div id='fb-root'></div>" + 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:addInitParameter
        ctx.stop(); 
        System.out.println("Completed in " + (end - start) + "ms"); 
    } 
 
    private static MockServletContext createServletContext() { 
        MockServletContext context = new MockServletContext("src/webapp", new FileSystemResourceLoader()); 
        context.addInitParameter("database.driver.class", "org.hsqldb.jdbcDriver"); 
        context.addInitParameter("database.driver.url", "jdbc:hsqldb:mem:webapp-template"); 
        context.addInitParameter("database.driver.username", "sa"); 
        context.addInitParameter("database.driver.password", ""); 
        context.addInitParameter("hibernate.dialect", "org.hibernate.dialect.HSQLDialect"); 
        context.addInitParameter("hibernate.cache.provider_class", "org.hibernate.cache.NoCacheProvider"); 
        return context; 
    } 
 
    private static XmlWebApplicationContext createRootApplicationContext(MockServletContext servletContext) { 
        XmlWebApplicationContext applicationContext = new XmlWebApplicationContext(); 
        applicationContext.setServletContext(servletContext); 
        applicationContext.refresh(); 
        return applicationContext; 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
This code example shows how to use the following methods:addInitParameter
    } 
 
    @Test 
    public void testAllowsRenewContextParam() throws Exception { 
        final Saml11TicketValidationFilter f = new Saml11TicketValidationFilter(); 
        final MockServletContext context = new MockServletContext(); 
        context.addInitParameter("casServerUrlPrefix", "https://cas.example.com"); 
        context.addInitParameter("renew", "true"); 
        final TicketValidator validator = f.getTicketValidator(new MockFilterConfig(context)); 
        assertTrue(validator instanceof Saml11TicketValidator); 
        assertTrue(((Saml11TicketValidator) validator).isRenew()); 
    } 
} 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
    private MockServletContext servletContext;
 
    @Before 
    public void setup() { 
        token = new DefaultCsrfToken("header", "param", "token");
        servletContext = new MockServletContext();
    } 
 
    @Test
    public void defaults() throws Exception {
        mockWebTestUtils(); 
        MockHttpServletRequest request = logout().buildRequest(servletContext);
 
        assertThat(request.getMethod()).isEqualTo("POST");
        assertThat(request.getParameter(token.getParameterName())).isEqualTo(token.getToken());
        assertThat(request.getRequestURI()).isEqualTo("/logout");
        verify(repository).saveToken(eq(token), any(HttpServletRequest.class), any(HttpServletResponse.class));
    } 
 
    @Test
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java