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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? testcmsstringutil.java

?? cms是開源的框架
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
/*
 * File   : $Source: /usr/local/cvs/opencms/test/org/opencms/util/TestCmsStringUtil.java,v $
 * Date   : $Date: 2006/03/27 14:52:42 $
 * Version: $Revision: 1.13 $
 *
 * This library is part of OpenCms -
 * the Open Source Content Mananagement System
 *
 * Copyright (c) 2005 Alkacon Software GmbH (http://www.alkacon.com)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * For further information about Alkacon Software GmbH, please see the
 * company website: http://www.alkacon.com
 *
 * For further information about OpenCms, please see the
 * project website: http://www.opencms.org
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

package org.opencms.util;

import org.opencms.i18n.CmsEncoder;

import java.util.Arrays;
import java.util.List;

import junit.framework.TestCase;

/** 
 * Test cases for {@link org.opencms.util.CmsStringUtil}.<p>
 * 
 * @author Andreas Zahner 
 * @author Achim Westermann 
 * 
 * @version $Revision: 1.13 $
 */
public class TestCmsStringUtil extends TestCase {

    /**
     * Default JUnit constructor.<p>
     * 
     * @param arg0 JUnit parameters
     */
    public TestCmsStringUtil(String arg0) {

        super(arg0);
    }

    /**
     * Tests content replacement during import.<p>
     */
    public void testCmsContentReplacement() {

        String content, result, context, search, replace;

        content = "<html><body>\n"
            + "See <a href=\"http://www.opencms.org/opencms/opencms/opencms/index.html\">\n"
            + "http://www.opencms.org/opencms/opencms/opencms/index.html</a>\n"
            + "or <a href=\"/opencms/opencms/opencms/index.html\">\n"
            + "/opencms/opencms/opencms/index.html</a>\n"
            + "<img src=\"/opencms/opencms/system/galleries/pics/test/test.gif\">\n"
            + "<img src=\"http://www.othersite.org/opencms/opencms/system/galleries/pics/test/test.gif\">\n"
            + "Some URL in the Text: http://www.thirdsite.org/opencms/opencms/some/url.html.\n"
            + "Another URL in the Text: /opencms/opencms/some/url.html.\n"
            + "</body></html>\n";

        result = "<html><body>\n"
            + "See <a href=\"http://www.opencms.org/opencms/opencms/opencms/index.html\">\n"
            + "http://www.opencms.org/opencms/opencms/opencms/index.html</a>\n"
            + "or <a href=\""
            + CmsStringUtil.MACRO_OPENCMS_CONTEXT
            + "/opencms/index.html\">\n"
            + CmsStringUtil.MACRO_OPENCMS_CONTEXT
            + "/opencms/index.html</a>\n"
            + "<img src=\""
            + CmsStringUtil.MACRO_OPENCMS_CONTEXT
            + "/system/galleries/pics/test/test.gif\">\n"
            + "<img src=\"http://www.othersite.org/opencms/opencms/system/galleries/pics/test/test.gif\">\n"
            + "Some URL in the Text: http://www.thirdsite.org/opencms/opencms/some/url.html.\n"
            + "Another URL in the Text: "
            + CmsStringUtil.MACRO_OPENCMS_CONTEXT
            + "/some/url.html.\n"
            + "</body></html>\n";

        context = "/opencms/opencms/";

        // search = "([>\"']\\s*)" + context;
        search = "([^\\w/])" + context;
        replace = "$1" + CmsStringUtil.escapePattern(CmsStringUtil.MACRO_OPENCMS_CONTEXT) + "/";

        String test = CmsStringUtil.substitutePerl(content, search, replace, "g");

        System.err.println(this.getClass().getName() + ".testCmsContentReplacement():");
        System.err.println(test);
        assertEquals(test, result);

        test = CmsStringUtil.substituteContextPath(content, context);
        assertEquals(test, result);
    }

    /**
     * Combined tests.<p>
     */
    public void testCombined() {

        String test;
        String content = "<p>A paragraph with text...<img src=\"/opencms/opencms/empty.gif\"></p>\n<a href=\"/opencms/opencms/test.jpg\">";
        String search = "/opencms/opencms/";
        String replace = "${path}";
        test = CmsStringUtil.substitute(content, search, replace);
        assertEquals(
            test,
            "<p>A paragraph with text...<img src=\"${path}empty.gif\"></p>\n<a href=\"${path}test.jpg\">");
        test = CmsStringUtil.substitute(test, replace, search);
        assertEquals(
            test,
            "<p>A paragraph with text...<img src=\"/opencms/opencms/empty.gif\"></p>\n<a href=\"/opencms/opencms/test.jpg\">");
    }

    /**
     * Tests for complext import patterns.<p>
     */
    public void testComplexPatternForImport() {

        String content = "<cms:link>/pics/test.gif</cms:link> <img src=\"/pics/test.gif\"> script = '/pics/test.gif' <cms:link> /pics/othertest.gif </cms:link>\n"
            + "<cms:link>/mymodule/pics/test.gif</cms:link> <img src=\"/mymodule/pics/test.gif\"> script = '/mymodule/pics/test.gif' <cms:link> /mymodule/system/galleries/pics/othertest.gif </cms:link>";
        String search = "([>\"']\\s*)/pics/";
        String replace = "$1/system/galleries/pics/";
        String test = CmsStringUtil.substitutePerl(content, search, replace, "g");
        assertEquals(
            test,
            "<cms:link>/system/galleries/pics/test.gif</cms:link> <img src=\"/system/galleries/pics/test.gif\"> script = '/system/galleries/pics/test.gif' <cms:link> /system/galleries/pics/othertest.gif </cms:link>\n"
                + "<cms:link>/mymodule/pics/test.gif</cms:link> <img src=\"/mymodule/pics/test.gif\"> script = '/mymodule/pics/test.gif' <cms:link> /mymodule/system/galleries/pics/othertest.gif </cms:link>");
    }

    /**
     * Tests for the escape patterns.<p>
     */
    public void testEscapePattern() {

        String test;
        test = CmsStringUtil.escapePattern("/opencms/opencms");
        assertEquals(test, "\\/opencms\\/opencms");
        test = CmsStringUtil.escapePattern("/opencms/$");
        assertEquals(test, "\\/opencms\\/\\$");
    }

    /**
     * Tests the body tag extraction.<p> 
     */
    public void testExtractHtmlBody() {

        String content, result;
        String innerContent = "This is body content in the body\n<h1>A headline</h1>\nSome text in the body\n";

        content = "<html><body>" + innerContent + "</body></html>";
        result = CmsStringUtil.extractHtmlBody(content);
        assertEquals(result, innerContent);

        content = "<html><body style='css' background-color:#ffffff>" + innerContent + "</body></html>";
        result = CmsStringUtil.extractHtmlBody(content);
        assertEquals(result, innerContent);

        content = "<html>\n<title>Test</title>\n<body style='css' background-color:#ffffff>"
            + innerContent
            + "</body>\n</html>";
        result = CmsStringUtil.extractHtmlBody(content);
        assertEquals(result, innerContent);

        content = "<html>< body style='css' background-color:#ffffff>" + innerContent + "</ BODY>";
        result = CmsStringUtil.extractHtmlBody(content);
        assertEquals(result, innerContent);

        content = "<BODY>" + innerContent + "</boDY></html></body><body>somemoretext</BODY>";
        result = CmsStringUtil.extractHtmlBody(content);
        assertEquals(result, innerContent);

        content = innerContent + "</boDY></html>";
        result = CmsStringUtil.extractHtmlBody(content);
        assertEquals(result, innerContent);

        content = "<html><BODY>" + innerContent;
        result = CmsStringUtil.extractHtmlBody(content);
        assertEquals(result, innerContent);

        content = innerContent;
        result = CmsStringUtil.extractHtmlBody(content);
        assertEquals(result, innerContent);
    }

    /**
     * Tests the xml encoding extraction.<p>
     */
    public void testExtractXmlEncoding() {

        String xml, result;

        xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
            + "<!DOCTYPE opencms SYSTEM"
            + "\"http://www.opencms.org/dtd/6.0/opencms-importexport.dtd\">\n"
            + "<opencms/>";

        result = CmsStringUtil.extractXmlEncoding(xml);
        assertEquals(result, CmsEncoder.ENCODING_UTF_8);

        xml = "<?xml version=\"1.0\" encoding='ISO-8859-1'?>\n" + "<opencms/>";

        result = CmsStringUtil.extractXmlEncoding(xml);
        assertEquals(result, "ISO-8859-1");
    }

    /**
     * Tests for the resource name formatting.<p>
     */
    public void testFormatResourceName() {

        String test;
        test = "/xmlcontentdemo/list.jsp";
        assertEquals("/.../list.jsp", CmsStringUtil.formatResourceName(test, 10));
        test = "/xmlcontentdemo/list.jsp";
        assertEquals("/xmlcontentdemo/list.jsp", CmsStringUtil.formatResourceName(test, 25));
        test = "/averylongresourcename.jsp";
        assertEquals("/averylongresourcename.jsp", CmsStringUtil.formatResourceName(test, 25));
        test = "/folder1/folder2/averylongresourcename.jsp";
        assertEquals("/.../averylongresourcename.jsp", CmsStringUtil.formatResourceName(test, 25));
        test = "/myfolder/subfolder/index.html";
        assertEquals("/.../subfolder/index.html", CmsStringUtil.formatResourceName(test, 21));
        test = "/myfolder/subfolder/subsubfolder/index.html";
        assertEquals("/.../subfolder/subsubfolder/index.html", CmsStringUtil.formatResourceName(test, 34));
        assertEquals("/.../subsubfolder/index.html", CmsStringUtil.formatResourceName(test, 25));
        assertEquals("/.../index.html", CmsStringUtil.formatResourceName(test, 21));
        test = "/demopages/search-demo/example-documents/";
        assertEquals("/.../search-demo/example-documents/", CmsStringUtil.formatResourceName(test, 39));
        assertEquals("/demopages/search-demo/example-documents/", CmsStringUtil.formatResourceName(test, 40));
    }

    /**
     * Further tests.<p> 
     */
    public void testLine() {

        String content = "<edittemplate><![CDATA[<H4><IMG style=\"WIDTH: 77px; HEIGHT: 77px\" alt=\"Homepage animation\" hspace=8 src=\"/opencms/opencms/pics/alkacon/x_hp_ani04.gif\" align=right vspace=8 border=0><IMG style=\"WIDTH: 307px; HEIGHT: 52px\" alt=\"Homepage animation\" hspace=0 src=\"/opencms/opencms/pics/alkacon/x_hp_ani05.gif\" vspace=8 border=0></H4>\n<P>Alkacon Software provides software development services for the digital business. We are specialized in web - based content management solutions build on open source Java Software. </P>\n<P>Alkacon Software is a major contributor to the <A href=\"http://www.opencms.org\" target=_blank>OpenCms Project</A>. OpenCms is an enterprise - ready content management platform build in Java from open source components. OpenCms can easily be deployed on almost any existing IT infrastructure and provides powerful features especially suited for large enterprise internet or intranet applications. </P>\n<P>Alkacon Software offers standard <A href=\"/alkacon/en/services/opencms/index.html\" target=_self>service and support </A>packages for OpenCms, providing an optional layer of security and convenience often required for mission critical OpenCms installations.</P>\n<UL>\n<LI><IMG style=\"WIDTH: 125px; HEIGHT: 34px\" alt=OpenCms hspace=3 src=\"/opencms/opencms/pics/alkacon/logo_opencms_125.gif\" align=right border=0>Learn more about our <A href=\"/alkacon/en/services/index.html\" target=_self>Services</A> \n<LI>Subscribe to our&nbsp;<A href=\"/alkacon/en/company/contact/newsletter.html\" target=_self>Company Newsletter</A> \n<LI>Questions? <A href=\"/alkacon/en/company/contact/index.html\" target=_self>Contact us</A></LI></UL>\n<P>&nbsp;</P>]]></edittemplate>";
        String search = "/pics/";
        String replace = "/system/galleries/pics/";
        String test = CmsStringUtil.substitute(content, search, replace);
        assertEquals(
            test,
            "<edittemplate><![CDATA[<H4><IMG style=\"WIDTH: 77px; HEIGHT: 77px\" alt=\"Homepage animation\" hspace=8 src=\"/opencms/opencms/system/galleries/pics/alkacon/x_hp_ani04.gif\" align=right vspace=8 border=0><IMG style=\"WIDTH: 307px; HEIGHT: 52px\" alt=\"Homepage animation\" hspace=0 src=\"/opencms/opencms/system/galleries/pics/alkacon/x_hp_ani05.gif\" vspace=8 border=0></H4>\n<P>Alkacon Software provides software development services for the digital business. We are specialized in web - based content management solutions build on open source Java Software. </P>\n<P>Alkacon Software is a major contributor to the <A href=\"http://www.opencms.org\" target=_blank>OpenCms Project</A>. OpenCms is an enterprise - ready content management platform build in Java from open source components. OpenCms can easily be deployed on almost any existing IT infrastructure and provides powerful features especially suited for large enterprise internet or intranet applications. </P>\n<P>Alkacon Software offers standard <A href=\"/alkacon/en/services/opencms/index.html\" target=_self>service and support </A>packages for OpenCms, providing an optional layer of security and convenience often required for mission critical OpenCms installations.</P>\n<UL>\n<LI><IMG style=\"WIDTH: 125px; HEIGHT: 34px\" alt=OpenCms hspace=3 src=\"/opencms/opencms/system/galleries/pics/alkacon/logo_opencms_125.gif\" align=right border=0>Learn more about our <A href=\"/alkacon/en/services/index.html\" target=_self>Services</A> \n<LI>Subscribe to our&nbsp;<A href=\"/alkacon/en/company/contact/newsletter.html\" target=_self>Company Newsletter</A> \n<LI>Questions? <A href=\"/alkacon/en/company/contact/index.html\" target=_self>Contact us</A></LI></UL>\n<P>&nbsp;</P>]]></edittemplate>");
    }

    /**
     * Tests <code>{@link CmsStringUtil#splitAsArray(String, char)}</code>.<p>
     */
    public void testSplitCharDelimiter() {

        String toSplit;
        char delimChar = '/';
        String[] arrayResult;
        List listResult;

        // test usability for path-tokenization (e.g. admin tool of workplace)
        toSplit = "/system/workplace/admin/searchindex/";
        arrayResult = CmsStringUtil.splitAsArray(toSplit, delimChar);
        assertEquals(4, arrayResult.length);
        assertEquals("system", arrayResult[0]);
        assertEquals("workplace", arrayResult[1]);
        assertEquals("admin", arrayResult[2]);
        assertEquals("searchindex", arrayResult[3]);
        listResult = CmsStringUtil.splitAsList(toSplit, delimChar);
        assertEquals(Arrays.asList(arrayResult), listResult);

        // test an empty String: 
        toSplit = "";
        arrayResult = CmsStringUtil.splitAsArray(toSplit, delimChar);
        assertEquals(0, arrayResult.length);
        listResult = CmsStringUtil.splitAsList(toSplit, delimChar);
        assertEquals(Arrays.asList(arrayResult), listResult);

        // test a whitespace only String
        toSplit = "               ";
        arrayResult = CmsStringUtil.splitAsArray(toSplit, delimChar);
        assertEquals(1, arrayResult.length);
        assertEquals(toSplit, arrayResult[0]);
        listResult = CmsStringUtil.splitAsList(toSplit, delimChar);
        assertEquals(Arrays.asList(arrayResult), listResult);

        // with truncation
        listResult = CmsStringUtil.splitAsList(toSplit, delimChar, true);

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美日韩国产色站一区二区三区| 97久久超碰精品国产| 亚洲免费伊人电影| 国产精品毛片高清在线完整版 | 久久先锋资源网| 欧美一区二区大片| 日韩精品一区二区三区三区免费 | 久久久久久9999| 精品动漫一区二区三区在线观看| 91精品国产一区二区三区香蕉| 欧美色图在线观看| 3d成人h动漫网站入口| 欧美一区二区三区在线电影| 欧美大片一区二区三区| 久久女同互慰一区二区三区| 欧美激情综合五月色丁香小说| 亚洲国产激情av| 亚洲精品一二三| 亚洲成人av福利| 久久99精品久久久久| 激情综合网最新| 成人国产在线观看| 欧美在线免费播放| 精品国产一区二区精华| 国产欧美1区2区3区| 一区二区三区在线视频播放| 性欧美疯狂xxxxbbbb| 激情综合网最新| 一本大道久久a久久综合| 在线成人免费视频| 日韩免费福利电影在线观看| 久久久久99精品一区| 亚洲另类在线制服丝袜| 日本视频一区二区三区| 国产传媒一区在线| 欧美中文字幕一区| 久久色在线观看| 亚洲尤物视频在线| 韩国av一区二区三区| 色哟哟亚洲精品| 久久中文娱乐网| 亚洲无线码一区二区三区| 美女任你摸久久| 91视频91自| 精品国产一区二区三区av性色| 亚洲精品videosex极品| 玖玖九九国产精品| 欧美综合在线视频| 亚洲国产精品传媒在线观看| 天堂久久一区二区三区| av在线免费不卡| 精品日韩在线观看| 亚洲成年人影院| www.66久久| 久久九九国产精品| 免费成人av在线播放| 日本高清不卡视频| 国产精品传媒视频| 国产一区二区不卡老阿姨| 欧美日韩高清一区| 亚洲一区二区三区美女| 白白色 亚洲乱淫| 精品欧美一区二区久久| 日韩中文欧美在线| 精品污污网站免费看| 一区二区在线观看视频在线观看| 国产成人av电影在线观看| 精品久久国产老人久久综合| 天天影视涩香欲综合网| 欧美天天综合网| 一区二区三区中文免费| 91老师片黄在线观看| √…a在线天堂一区| 国产xxx精品视频大全| 久久精品视频免费| 国内成人精品2018免费看| 日韩精品一区二区三区在线观看| 污片在线观看一区二区| 精品视频在线看| 亚洲va欧美va国产va天堂影院| 在线中文字幕不卡| 一区二区三区四区亚洲| 欧洲亚洲精品在线| 日本伊人精品一区二区三区观看方式| 欧美日韩激情在线| 久久精品噜噜噜成人av农村| 精品国内二区三区| 国产99久久久国产精品| 国产精品大尺度| 欧美亚日韩国产aⅴ精品中极品| 亚洲国产精品精华液网站| 欧美日韩一二三区| 免费在线观看日韩欧美| 久久久国产精华| eeuss鲁一区二区三区| 亚洲最快最全在线视频| 欧美久久久久久蜜桃| 韩国视频一区二区| 亚洲视频在线观看三级| 欧美精品黑人性xxxx| 久久精品国产99久久6| 中文字幕av一区二区三区免费看| 成人av网站免费观看| 一区二区三区**美女毛片| 欧美一级片在线| 成人国产电影网| 亚洲无线码一区二区三区| 精品国产凹凸成av人导航| 国产91精品精华液一区二区三区| 亚洲视频小说图片| 欧美一区二区免费视频| 国产精品一区二区在线播放| 国产精品另类一区| 欧美肥妇毛茸茸| 国产伦精品一区二区三区视频青涩| 成人欧美一区二区三区白人 | 日本不卡的三区四区五区| 久久精品夜色噜噜亚洲aⅴ| 色婷婷久久综合| 久久99久久精品欧美| 亚洲精品精品亚洲| 国产偷v国产偷v亚洲高清| 日本韩国欧美在线| 懂色中文一区二区在线播放| 爽爽淫人综合网网站| 中文字幕中文字幕一区| 欧美xxx久久| 欧美系列日韩一区| 成人精品国产一区二区4080| 免费在线成人网| 亚洲午夜激情av| 亚洲嫩草精品久久| 久久先锋影音av鲁色资源| 欧美三区在线视频| 一本一道久久a久久精品| 国产福利91精品一区| 日本成人超碰在线观看| 亚洲影视资源网| 亚洲精品免费电影| 国产精品系列在线| 久久久精品一品道一区| 日韩午夜电影av| 欧美日本国产视频| 欧美怡红院视频| 91浏览器入口在线观看| 99re成人精品视频| 99久久国产综合色|国产精品| 国产乱码精品一区二区三 | 国产麻豆精品视频| 久久99久久99精品免视看婷婷| 亚洲va国产天堂va久久en| 亚洲网友自拍偷拍| 亚洲成av人综合在线观看| 亚洲一级二级在线| 亚洲1区2区3区视频| 亚洲国产成人va在线观看天堂| 亚洲自拍偷拍av| 亚洲在线成人精品| 日韩电影在线观看网站| 日韩高清国产一区在线| 欧美aⅴ一区二区三区视频| 奇米精品一区二区三区在线观看 | 波多野结衣精品在线| 不卡av电影在线播放| www.一区二区| 91黄色免费版| 6080国产精品一区二区| 日韩无一区二区| 欧美激情一区二区三区| 亚洲三级免费观看| 亚洲一区中文日韩| 一区二区三区波多野结衣在线观看 | 亚洲国产毛片aaaaa无费看 | 九色|91porny| 国产成人综合精品三级| 99r精品视频| 欧美亚洲自拍偷拍| 久久亚洲影视婷婷| 日韩一级片网站| 欧美国产欧美综合| 亚洲精品欧美二区三区中文字幕| 亚洲成人免费在线观看| 精品一二三四区| 91麻豆精品一区二区三区| 777久久久精品| 国产目拍亚洲精品99久久精品| 亚洲欧美日韩精品久久久久| 性做久久久久久免费观看 | 一区二区三区四区蜜桃| 美腿丝袜在线亚洲一区| www.久久精品| 3atv在线一区二区三区| 亚洲欧洲日韩av| 精品一区二区三区av| 日本福利一区二区| 国产婷婷色一区二区三区四区| 亚洲影院免费观看| 国产成人久久精品77777最新版本| 91麻豆产精品久久久久久| 日韩视频不卡中文|