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

📄 functionreplacertest.java

📁 UrlRewriteFilter 是一个不错的URL转换工具
💻 JAVA
字号:
package org.tuckey.web.filters.urlrewrite.utils;

import junit.framework.TestCase;

import javax.servlet.ServletException;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;


public class FunctionReplacerTest  extends TestCase {

    public void setUp() {
        Log.setLevel("DEBUG");
    }

    public void testSimple1() throws InvocationTargetException, IOException, ServletException {
        assertTrue(FunctionReplacer.containsFunction("a${lower:HEllo}b"));
        assertEquals("ahellob", FunctionReplacer.replace("a${lower:HElLO}b"));
    }

    public void testSimple2() throws InvocationTargetException, IOException, ServletException {
        assertTrue(FunctionReplacer.containsFunction("a${upper:HEllo}b"));
        assertEquals("aHELLOb", FunctionReplacer.replace("a${upper:hellO}b"));
    }

    public void testSimple3() throws InvocationTargetException, IOException, ServletException {
        assertTrue(FunctionReplacer.containsFunction("a${replace:a b c: :_}b"));
        assertEquals("aa_b_cb", FunctionReplacer.replace("a${replace:a b c: :_}b"));
    }

    public void testSimple4() throws InvocationTargetException, IOException, ServletException {
        assertTrue(FunctionReplacer.containsFunction("a${replaceFirst:a b c: :_}b"));
        assertEquals("aa_b cb", FunctionReplacer.replace("a${replaceFirst:a b c: :_}b"));
    }

    public void testSimple5() throws InvocationTargetException, IOException, ServletException {
        assertTrue(FunctionReplacer.containsFunction("a${escape:a b c} b"));
        assertEquals("aa+b+c b", FunctionReplacer.replace("a${escape:a b c} b"));
    }

    public void testSimple6() throws InvocationTargetException, IOException, ServletException {
        assertTrue(FunctionReplacer.containsFunction("a${trim: b } b"));
        assertEquals("ab b", FunctionReplacer.replace("a${trim: b } b"));
    }

    public void testSimple7() throws InvocationTargetException, IOException, ServletException {
        assertTrue(FunctionReplacer.containsFunction("a${length:asdf} b"));
        assertEquals("a4 b", FunctionReplacer.replace("a${length:asdf} b"));
    }


}

⌨️ 快捷键说明

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