Spring Framework MockServletConfig - 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 MockServletConfig class.

This code example shows how to use the following methods:addInitParameter
        ServletContextEvent e = new ServletContextEvent(servletContext); 
        contextListener = new ContextLoaderListener(); 
        contextListener.contextInitialized(e); 
 
        servletContext.setContextPath(contextPath); 
        servletConfig = new MockServletConfig(servletContext, "dispatcher");     
        servletConfig.addInitParameter("com.sun.jersey.config.property.resourceConfigClass", "com.sun.jersey.api.core.PackagesResourceConfig"); 
        servletConfig.addInitParameter("com.sun.jersey.config.property.packages", "org.opennms.web.rest"); 
 
        try { 
 
            MockFilterConfig filterConfig = new MockFilterConfig(servletContext, "openSessionInViewFilter"); 
            filter = new OpenSessionInViewFilter();         
            filter.init(filterConfig); 
 
            dispatcher = new SpringServlet(); 
            dispatcher.init(servletConfig); 
 
        } catch (ServletException se) { 
            throw se.getRootCause(); 

6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:addInitParameter, getServletContext
		this.parentContext = parentContext; 
	} 
 
	@Before 
	public void beforeBase() throws Exception { 
		MockServletConfig servletConfig = new MockServletConfig("repository"); 
		servletConfig.addInitParameter("contextConfigLocation", "classpath:test-empty-context.xml"); 
		StaticWebApplicationContext webApplicationContext = new StaticWebApplicationContext(); 
		webApplicationContext.setParent(parentContext); 
		webApplicationContext.refresh(); 
		servletConfig.getServletContext().setAttribute(WebApplicationContext.class.getName() + ".ROOT", webApplicationContext); 
		dispatchServlet = new DispatcherServlet(); 
		dispatchServlet.init(servletConfig); 
		servletTestHelper.setUp(dispatchServlet); 
		entityServletHelper = new EntityServletTestHelper(dispatchServlet); 
	} 
 
	@After 
	public void afterBase() throws Exception { 
		servletTestHelper.tearDown(); 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
				new AutoDeployMockServletContext( 
					new FileSystemResourceLoader()); 
 
			ServletContextPool.put(StringPool.BLANK, mockServletContext); 
 
			MockServletConfig mockServletConfig = new MockServletConfig( 
				mockServletContext); 
 
			_mainServlet = new MainServlet(); 
 
			try { 
				_mainServlet.init(mockServletConfig); 
			} 
			catch (ServletException se) { 
				throw new RuntimeException( 
					"The main servlet could not be initialized"); 
			} 
		} 
 
		return null; 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:addInitParameter
		ServletContextEvent e = new ServletContextEvent(servletContext); 
		contextListener = new ContextLoaderListener(); 
		contextListener.contextInitialized(e); 
 
		servletContext.setContextPath(contextPath); 
		servletConfig = new MockServletConfig(servletContext, "dispatcher");     
		servletConfig.addInitParameter("com.sun.jersey.config.property.resourceConfigClass", "com.sun.jersey.api.core.PackagesResourceConfig"); 
		servletConfig.addInitParameter("com.sun.jersey.config.property.packages", "org.opennms.web.rest"); 
 
		try { 
 
			MockFilterConfig filterConfig = new MockFilterConfig(servletContext, "openSessionInViewFilter"); 
			filter = new OpenSessionInViewFilter(); 
			filter.init(filterConfig); 
		} catch (ServletException se) { 
			throw se.getRootCause(); 
		} 
	} 
} 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:addInitParameter
		File testUserRoot = fileEntityRepository.getUserRepoDirectory(getTestUser()).getParentFile(); 
		FileUtils.deleteQuietly(testUserRoot); 
		testUserRoot.mkdirs(); 
		CompressionUtils.unzip(new ClassPathResource("TEST_USER.zip").getFile(), testUserRoot); 
		testUserRoot.deleteOnExit(); 
		MockServletConfig servletConfig = new MockServletConfig(); 
		servletConfig.addInitParameter("SVNParentPath", testUserRoot.getAbsolutePath()); 
		DAVConfig davConfig = new DAVConfig(servletConfig); 
		svnController.setDAVConfig(davConfig); 
	} 
 
 
	@Test 
	public void testHandleError() throws IOException { 
		DAVException davE = new DAVException("Test Error", 404, 0); 
		HttpServletResponse resp = new MockHttpServletResponse(); 
		SvnDavController.handleError(davE, resp); 
	} 
 
	@Test 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
 
@SuppressWarnings("deprecation") 
public class ResourceServletTests extends TestCase { 
 
	ServletContext servletContext = new ResourceTestMockServletContext(); 
	ServletConfig config = new MockServletConfig(servletContext); 
	MockHttpServletResponse response = new MockHttpServletResponse(); 
	MockHttpServletRequest request = new MockHttpServletRequest(); 
 
	String[] requestElements; 
 
	ResourceServlet servlet; 
 
	protected void setUp() throws Exception { 
		servlet = new ResourceServlet(); 
		servlet.init(config); 
	} 
 
	public final void testExecute() throws Exception { 
 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
	private final DispatcherServlet dispatcherServlet; 
 
	public DispatcherServletChannelInitializer() throws ServletException { 
 
		MockServletContext servletContext = new MockServletContext(); 
		MockServletConfig servletConfig = new MockServletConfig(servletContext); 
 
		AnnotationConfigWebApplicationContext wac = new AnnotationConfigWebApplicationContext(); 
		wac.setServletContext(servletContext); 
		wac.setServletConfig(servletConfig); 
		wac.register(WebConfig.class); 
		wac.refresh(); 
 
		this.dispatcherServlet = new DispatcherServlet(wac); 
		this.dispatcherServlet.init(servletConfig); 
	} 
 
	@Override 
	public void initChannel(SocketChannel channel) throws Exception { 
		// Create a default pipeline implementation. 
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getServletContext
        return dispatcherServlet; 
    } 
 
	public static ServletContext getServletContext()  
	{ 
		return servletConfig.getServletContext(); 
	} 
	 
	public static ApplicationContext getApplicationContext() 
	{ 
		return dispatcherServlet.getWebApplicationContext(); 
	} 
	 
	public static WebFrameworkServiceRegistry getServiceRegistry() 
	{ 
		return (WebFrameworkServiceRegistry) getApplicationContext().getBean("webframework.service.registry"); 
	} 
	 
	public static ModelObjectService getObjectService() 
	{ 
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
 
		mockBundleWiring(); 
 
		when( 
			_servlet.getServletConfig()
		).thenReturn( 
			new MockServletConfig(servletName)
		); 
 
		_bundleServletContext.registerServlet(
			servletName, Arrays.asList(urlPatterns), _servlet, null,
			_httpContext);
 
		Servlet servlet = _bundleServletContext.getServlet(servletName);
 
		Assert.assertNotNull(servlet);
 
		Assert.assertEquals(
			servletName, servlet.getServletConfig().getServletName());
 
3
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
    { 
 
        MockServletContext mockServletContext = new MockServletContext(); 
        mockServletContext.setContextPath( "direct-memory" ); 
 
        MockServletConfig mockServletConfig = new MockServletConfig( mockServletContext ); 
 
        directMemoryServlet.init( mockServletConfig ); 
    } 
 
    @Test 
    public void badRequest() 
        throws Exception 
    { 
 
        MockHttpServletRequest request = new MockHttpServletRequest(); 
        request.addHeader( "Accept", MediaType.APPLICATION_JSON ); 
 
        MockHttpServletResponse response = new MockHttpServletResponse(); 
 
4
CodeRank
Experience pair programming with AI  Get Codota for Java