⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 staticfiltertest.java

📁 基于Maven的质量保证自动化环境配置和演示程序
💻 JAVA
字号:
package com.cib.webapp.filter;

import junit.framework.TestCase;
import org.springframework.mock.web.MockFilterConfig;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;

public class StaticFilterTest extends TestCase {
    private StaticFilter filter = null;

    protected void setUp() throws Exception {
        filter = new StaticFilter();
        MockFilterConfig config = new MockFilterConfig();
        config.addInitParameter("includes", "/scripts/*");
        filter.init(config);
    }

    public void testFilterDoesntForwardWhenPathMatches() throws Exception {
        MockHttpServletRequest request = new MockHttpServletRequest("GET", "/scripts/dojo/test.html");
        MockHttpServletResponse response = new MockHttpServletResponse();
        MockFilterChain chain = new MockFilterChain();

        filter.doFilter(request, response, chain);

        assertNull(chain.getForwardURL());
    }

    public void testFilterForwardsWhenPathDoesntMatch() throws Exception {
        MockHttpServletRequest request = new MockHttpServletRequest("GET", "/editProfile.html");
        MockHttpServletResponse response = new MockHttpServletResponse();
        MockFilterChain chain = new MockFilterChain();

        filter.doFilter(request, response, chain);

        assertNotNull(chain.getForwardURL());
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -