亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? urlrewritefiltercontainertest.java

?? jsp中 urlRewrite的源代碼 很有用的喔
?? JAVA
字號:
/**
 * Copyright (c) 2005, Paul Tuckey
 * All rights reserved.
 *
 * Each copy or derived work must preserve the copyright notice and this
 * notice unmodified.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 */
package org.tuckey.web.filters.urlrewrite;

import junit.framework.Test;
import junit.framework.TestSuite;
import org.apache.cactus.FilterTestCase;
import org.apache.cactus.WebRequest;
import org.apache.cactus.WebResponse;
import org.apache.cactus.server.RequestDispatcherWrapper;
import org.tuckey.web.filters.urlrewrite.utils.Log;
import org.tuckey.web.filters.urlrewrite.utils.StringUtils;

import javax.servlet.FilterChain;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletResponseWrapper;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @author Paul Tuckey
 * @version $Revision: 1.4 $ $Date: 2005/12/07 10:22:15 $
 */
public class UrlRewriteFilterContainerTest extends FilterTestCase {

    private UrlRewriteFilter filter = new UrlRewriteFilter();
    private String CONTENT = "<p>some content</p>";

    public void setUp() {
        config.setInitParameter("logLevel", "sysout:TRACE");
        filter.init(config);
    }

    public void tearDown() {
        filter.destroy();
    }


    /**
     * mock chain for use with tests
     */
    private FilterChain testFilterChain = new FilterChain() {
        public void doFilter(ServletRequest theRequest,
                             ServletResponse theResponse) throws IOException {
            PrintWriter writer = theResponse.getWriter();
            writer.print(CONTENT);
            writer.close();
        }
    };


    public static Test suite() {
        return new TestSuite(UrlRewriteFilterContainerTest.class);
    }

    public class TestResponseWrapper extends HttpServletResponseWrapper {
        public String redirectToUrl = "not yet!";
        private int status;

        public TestResponseWrapper(HttpServletResponse httpServletResponse) {
            super(httpServletResponse);
        }

        public void sendRedirect(String to) {
            this.redirectToUrl = to;
        }

        public void setStatus(int i) {
            status = i;
            super.setStatus(i);
        }

        public int getStatus() {
            return status;
        }

        public String encodeRedirectURL(String s) {
            return super.encodeRedirectURL(s) + ";jsess";
        }
    }

    public class TestRequestWrapper extends HttpServletRequestWrapper {
        TestRequestDispatcherWrapper dispatcher;
        public String dispatcherUrl = "not set";
        public String contextPath = "not set";

        public TestRequestWrapper(HttpServletRequest httpServletRequest) {
            super(httpServletRequest);
        }

        public RequestDispatcher getRequestDispatcher(String url) {
            dispatcherUrl = url;
            dispatcher = new TestRequestDispatcherWrapper(super.getRequestDispatcher(url));
            return dispatcher;
        }

        public String getContextPath() {
            return contextPath;
        }

        public void setContextPath(String contextPath) {
            this.contextPath = contextPath;
        }
    }

    public class TestRequestDispatcherWrapper extends RequestDispatcherWrapper {
        boolean forwarding = false;
        boolean including = false;

        public TestRequestDispatcherWrapper(RequestDispatcher requestDispatcher) {
            super(requestDispatcher);
        }

        public void forward(ServletRequest servletRequest, ServletResponse servletResponse)
                throws ServletException, IOException {
            forwarding = true;
            super.forward(servletRequest, servletResponse);
        }

        public void include(ServletRequest servletRequest, ServletResponse servletResponse)
                throws ServletException, IOException {
            including = true;
            super.include(servletRequest, servletResponse);
        }
    }


    /**
     *
     */
    public void beginProduct(WebRequest theRequest) {
        theRequest.setURL("blah.org", "", "/products/987", null, null);
    }

    public void testProduct() throws ServletException, IOException {
        filter.doFilter(request, response, testFilterChain);
    }

    public void endProduct(WebResponse theResponse) {
        assertEquals("product 987", theResponse.getText());
    }

    /**
     *
     */
    public void beginSimpleDistEx(WebRequest theRequest) {
        theRequest.setURL("blah.org", "", "/test/status/", null, null);
    }

    public void testSimpleDistEx() throws ServletException, IOException {
        TestResponseWrapper testResponseWrapper = new TestResponseWrapper(response);
        TestRequestWrapper testRequestWrapper = new TestRequestWrapper(request);
        testRequestWrapper.setContextPath("/blah");
        filter.doFilter(testRequestWrapper, testResponseWrapper, testFilterChain);
        assertEquals("/blah/rewrite-status", testResponseWrapper.redirectToUrl);
    }

    /**
     *
     */
    public void beginBasicSets(WebRequest theRequest) {
        theRequest.setURL("blah.org", "", "/settest/674", null, null);
    }

    public void testBasicSets() throws ServletException, IOException {
        TestRequestWrapper testRequestWrapper = new TestRequestWrapper(request);
        filter.doFilter(testRequestWrapper, response, testFilterChain);
        assertTrue(response.containsHeader("cache-control"));
        assertEquals("hello!", request.getSession().getAttribute("testsession"));
    }


    /**
     *
     */
    public void beginMultipleProduct(WebRequest theRequest) {
        theRequest.setURL("blah.org", "", "/multiple/products/987", null, null);
    }

    public void testMultipleProduct() throws ServletException, IOException {
        filter.doFilter(request, response, testFilterChain);
    }

    public void endMultipleProduct(WebResponse theResponse) {
        assertEquals("product 987", theResponse.getText());
    }

    /**
     *
     */
    public void beginNullTo(WebRequest theRequest) {
        theRequest.setURL("blah.org", "", "/hideme/anb.jsp;dsaddd?asdasds#sdsfd", null, null);
    }

    public void testNullTo() throws ServletException, IOException {
        filter.doFilter(request, response, testFilterChain);
    }

    public void endNullTo(WebResponse theResponse) {
        assertEquals("should have status set", 403, theResponse.getStatusCode());
        assertFalse("should not output above content", CONTENT.equals(StringUtils.trim(theResponse.getText())));
    }

    /**
     *
     */
    public void beginYear(WebRequest theRequest) {
        theRequest.setURL("blah.org", "", "/time/year/current", null, null);
    }

    public void testYear() throws ServletException, IOException {
        filter.doFilter(request, response, testFilterChain);
    }

    public void endYear(WebResponse theResponse) {
        assertEquals("echo yearisbetween1970and3000", theResponse.getText());
    }

    /**
     *
     */
    public void beginTestAxis(WebRequest theRequest) {
        theRequest.setURL("blah.org", "", "/services/blah?qwerty", null, null);
    }

    public void testTestAxis() throws ServletException, IOException {
        TestResponseWrapper testResponseWrapper = new TestResponseWrapper(response);
        filter.doFilter(request, testResponseWrapper, testFilterChain);
        assertEquals("/axis/services/blah?qwerty", testResponseWrapper.redirectToUrl);
    }


    /**
     *
     */
    public void beginTestErik(WebRequest theRequest) {
        theRequest.setURL("blah.org", "", "/eriktest/hi.ho", null, null);
        theRequest.addHeader("host", "blah.com");
    }

    public void testTestErik() throws ServletException, IOException {
        TestResponseWrapper testResponseWrapper = new TestResponseWrapper(response);
        filter.doFilter(request, testResponseWrapper, testFilterChain);
        assertEquals("http://www.example.com/context/hi.ho", testResponseWrapper.redirectToUrl);
    }

    /**
     *
     */
    public void beginTestEncode(WebRequest theRequest) {
        theRequest.setURL("blah.org", "", "/went%20to%20bahamas/", null, null);
    }

    public void testTestEncode() throws ServletException, IOException {
        TestResponseWrapper testResponseWrapper = new TestResponseWrapper(response);
        filter.doFilter(request, testResponseWrapper, testFilterChain);
        assertEquals("/bahamas/;jsess", testResponseWrapper.redirectToUrl);
    }

    /**
     * note, had trouble keeping true utf (multi byte) chars as cvs buggers them up!
     */
    public void beginTestUtf(WebRequest theRequest) {
        theRequest.setURL("blah.org", "", "/utf/F阾el'ha飗olap黭/", null, null);
    }

    public void testTestUtf() throws ServletException, IOException {
        TestResponseWrapper testResponseWrapper = new TestResponseWrapper(response);
        filter.doFilter(request, testResponseWrapper, testFilterChain);
        assertEquals("/utf-redir/F阾el'ha飗olap黭/", testResponseWrapper.redirectToUrl);
    }

    /**
     *
     */
    public void beginSimpleRun(WebRequest theRequest) {
        theRequest.setURL("blah.org", "", "/run/test/test1", null, null);
    }

    public void testSimpleRun() throws ServletException, IOException {
        assertTrue("should be inited", TestRunObj.isInitCalled());

        TestResponseWrapper testResponseWrapper = new TestResponseWrapper(response);
        filter.doFilter(request, testResponseWrapper, testFilterChain);
    }

    public void endSimpleRun(WebResponse theResponse) {
        assertEquals("this is " + TestRunObj.class.getName(), theResponse.getText());
    }

}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美日韩久久一区| 国产成人综合亚洲网站| 久久成人综合网| 国产成人av福利| 91国在线观看| 日韩欧美一区二区在线视频| 国产性色一区二区| 亚洲欧美激情视频在线观看一区二区三区 | 一本一道波多野结衣一区二区| 欧美中文字幕亚洲一区二区va在线 | 日韩视频在线你懂得| 国产亚洲精品7777| 亚洲国产乱码最新视频 | 日韩一级高清毛片| 中文字幕一区日韩精品欧美| 亚洲成人免费在线| 成人深夜视频在线观看| 欧美三区在线视频| 国产欧美精品一区二区三区四区| 夜夜嗨av一区二区三区四季av| 奇米色一区二区| 99r精品视频| 欧美成人性福生活免费看| 最新成人av在线| 国产在线国偷精品免费看| 精品视频免费看| 国产精品久久午夜| 久久国产婷婷国产香蕉| 色老汉一区二区三区| 久久久一区二区三区捆绑**| 亚洲成人动漫在线免费观看| a在线欧美一区| 日韩精品一区国产麻豆| 亚洲精品高清在线| 懂色av一区二区三区免费看| 欧美日韩卡一卡二| 亚洲激情图片小说视频| 国产精品一二三在| 91精品国产色综合久久久蜜香臀| 国产精品久久综合| 国产在线精品一区二区三区不卡 | 亚洲视频在线一区观看| 激情久久五月天| 欧美日韩国产影片| 亚洲欧洲制服丝袜| 成人美女视频在线看| 日韩精品中文字幕一区二区三区| 亚洲国产日韩在线一区模特| 成人中文字幕电影| 久久精子c满五个校花| 三级欧美在线一区| 欧洲一区二区av| 亚洲欧美电影院| 国产成人aaa| 26uuu亚洲| 精品亚洲aⅴ乱码一区二区三区| 欧美视频日韩视频| 亚洲免费观看高清完整版在线| 丁香另类激情小说| 欧美激情在线看| 国产大陆a不卡| 国产午夜精品久久| 国产精品白丝jk黑袜喷水| 精品福利av导航| 热久久免费视频| 91精品中文字幕一区二区三区| 亚洲自拍偷拍图区| 91福利小视频| 亚洲一区在线观看免费| 在线观看日韩国产| 亚洲在线成人精品| 99国产麻豆精品| 最新欧美精品一区二区三区| 成人性视频免费网站| 欧美激情综合网| 9色porny自拍视频一区二区| 中文字幕精品一区二区精品绿巨人 | 国产白丝精品91爽爽久久| 久久品道一品道久久精品| 国产一区福利在线| 久久精品无码一区二区三区| 大尺度一区二区| 亚洲视频一二三区| 色先锋资源久久综合| 亚洲国产欧美另类丝袜| 欧美久久一区二区| 蜜乳av一区二区| 久久婷婷综合激情| 99在线精品视频| 亚洲中国最大av网站| 555www色欧美视频| 麻豆免费精品视频| 久久久国产精品麻豆| 99久久亚洲一区二区三区青草| 亚洲免费在线视频一区 二区| 在线视频欧美区| 日韩国产在线观看一区| 精品国产凹凸成av人网站| 韩国欧美一区二区| 亚洲国产电影在线观看| 在线精品亚洲一区二区不卡| 丝瓜av网站精品一区二区| 日韩亚洲欧美中文三级| 国产盗摄女厕一区二区三区| 亚洲免费观看高清完整版在线观看| 欧美无乱码久久久免费午夜一区| 免费在线观看不卡| 国产亚洲精品bt天堂精选| www.av亚洲| 日韩在线播放一区二区| 国产亚洲成av人在线观看导航 | 国产精品成人免费在线| 欧洲中文字幕精品| 国产在线精品一区二区不卡了| 一区在线播放视频| 91精品欧美综合在线观看最新| 国产永久精品大片wwwapp| 亚洲男人天堂一区| 精品久久国产老人久久综合| 丁香亚洲综合激情啪啪综合| 亚洲一区二区欧美激情| 久久嫩草精品久久久久| 在线一区二区视频| 久久成人羞羞网站| 一区二区三区四区不卡在线| 日韩免费视频一区| 91论坛在线播放| 久久99精品国产.久久久久久| 国产精品美女久久久久av爽李琼 | 久久精品国产一区二区三区免费看| 国产精品免费视频一区| 欧美丰满美乳xxx高潮www| 成人av免费观看| 日日夜夜一区二区| 中文字幕一区二区三区不卡在线| 欧美一区二区三区在线视频| www.日韩大片| 精品在线亚洲视频| 亚洲成人免费影院| 中文字幕在线不卡| 久久综合九色综合97婷婷| 欧美日韩亚洲综合| 成人av免费在线播放| 九九九久久久精品| 亚洲最大的成人av| 欧美激情一区二区三区| 欧美不卡激情三级在线观看| 色婷婷精品久久二区二区蜜臀av| 国产一区二区伦理| 青青草国产精品亚洲专区无| 一区二区三区在线观看动漫| 亚洲国产精品成人综合 | 国产在线看一区| 青青草成人在线观看| 一区二区三区高清| 亚洲欧美自拍偷拍色图| 久久影院视频免费| 欧美一二三区在线观看| 欧美性生交片4| 色先锋aa成人| 成人伦理片在线| 国产精品影视网| 久久国产人妖系列| 日本中文字幕一区二区视频| 亚洲综合色噜噜狠狠| 亚洲男人的天堂网| 中文字幕高清不卡| 国产婷婷色一区二区三区四区| 欧美一级欧美一级在线播放| 欧美三级午夜理伦三级中视频| 色婷婷av一区二区| youjizz久久| 播五月开心婷婷综合| 粉嫩高潮美女一区二区三区 | 久久蜜臀精品av| 亚洲精品在线三区| 精品国产一二三区| 精品久久久三级丝袜| 日韩一区二区视频| 91精品国产aⅴ一区二区| 欧美久久一区二区| 欧美精品乱码久久久久久按摩| 欧美网站大全在线观看| 欧美日韩亚洲不卡| 欧美色图免费看| 欧美日韩国产影片| 在线成人午夜影院| 欧美一区二区三区视频在线| 欧美精品久久久久久久多人混战| 欧美亚洲综合一区| 欧美色涩在线第一页| 欧美午夜宅男影院| 欧美日韩国产小视频在线观看| 欧美日韩在线播| 91精品国产麻豆| 日韩欧美国产不卡| 久久久久久久久久久电影| 久久久精品蜜桃| 国产精品美女久久久久aⅴ| 18涩涩午夜精品.www|