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

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

?? 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一区二区三区免费野_久草精品视频
91电影在线观看| 国产伦精品一区二区三区免费迷| 91麻豆免费视频| 亚洲一区二区在线免费看| 91成人在线精品| 天堂蜜桃一区二区三区| 精品人伦一区二区色婷婷| 国内外精品视频| 日韩理论片在线| 欧美日韩免费视频| 国产综合色产在线精品| 亚洲少妇30p| 欧美一区二区三区的| 国产 日韩 欧美大片| 亚洲精品欧美二区三区中文字幕| 欧美日韩的一区二区| 国产麻豆精品视频| 樱花影视一区二区| 欧美成人精品1314www| k8久久久一区二区三区 | 偷窥少妇高潮呻吟av久久免费| 欧美一区二区播放| 成人av小说网| 免费看日韩精品| 一区精品在线播放| 欧美一区二区三区日韩| 成人免费毛片嘿嘿连载视频| 亚洲国产精品麻豆| 国产日韩欧美高清| 在线成人av影院| 成人黄色在线网站| 久久精品99国产精品| 亚洲色图第一区| 久久亚洲精精品中文字幕早川悠里| 99国产精品久久久久| 久久99国产精品麻豆| 一区二区三区四区不卡在线 | 亚洲v精品v日韩v欧美v专区| 国产亚洲综合av| 在线播放国产精品二区一二区四区 | 国产精一品亚洲二区在线视频| 亚洲激情自拍偷拍| 国产日韩精品一区| 日韩你懂的在线观看| 在线观看日韩国产| av在线不卡免费看| 国产精品123| 久久国产精品一区二区| 无码av中文一区二区三区桃花岛| 国产精品午夜电影| 久久中文字幕电影| 日韩欧美高清一区| 884aa四虎影成人精品一区| 色哟哟精品一区| 波波电影院一区二区三区| 韩国v欧美v日本v亚洲v| 美女看a上一区| 视频一区欧美精品| 午夜精品一区二区三区免费视频 | 久久久久久久网| 欧美不卡一区二区三区四区| 欧美体内she精高潮| 91官网在线免费观看| 日本精品视频一区二区| 色综合一区二区| 色综合天天在线| 成人免费av资源| 成人av在线播放网址| 99精品在线观看视频| 99久久久精品| 一本到高清视频免费精品| 91视频国产资源| 91极品视觉盛宴| 欧美三区免费完整视频在线观看| 欧美色图第一页| 91精品国产综合久久久久久久久久 | 在线成人av网站| 91精品国产品国语在线不卡| 91精品国产一区二区三区| 91精品国产综合久久久蜜臀粉嫩| 欧美日韩一区高清| 91精品国产日韩91久久久久久| 56国语精品自产拍在线观看| 91精品综合久久久久久| 日韩精品一区二区三区老鸭窝| 精品国产乱码久久久久久闺蜜 | 亚洲国产精品t66y| 亚洲天堂a在线| 亚洲成人自拍一区| 日本免费在线视频不卡一不卡二| 久久精品二区亚洲w码| 国内国产精品久久| 成人高清伦理免费影院在线观看| 99久久伊人精品| 欧美日韩国产另类不卡| 精品美女一区二区三区| 国产精品久久久久影视| 亚洲国产一二三| 国内精品在线播放| 色婷婷av一区二区三区大白胸| 欧美日韩视频第一区| 欧美mv和日韩mv的网站| 亚洲天堂免费在线观看视频| 午夜欧美视频在线观看| 国产主播一区二区| 在线免费av一区| 亚洲精品一区二区三区福利 | 日韩vs国产vs欧美| 粉嫩aⅴ一区二区三区四区| 一本高清dvd不卡在线观看| 欧美一区二区三区日韩| 亚洲欧美在线视频| 美女被吸乳得到大胸91| av在线一区二区| 日韩欧美亚洲另类制服综合在线| 国产精品美女久久久久久久久| 亚洲福利视频一区二区| 成人免费不卡视频| 欧美一区二区播放| 亚洲精品老司机| 国内精品国产成人| 欧美群妇大交群的观看方式| 日本一区二区成人在线| 美女mm1313爽爽久久久蜜臀| 一本到一区二区三区| 26uuu亚洲| 日韩成人一级大片| 91麻豆免费观看| 日本一区二区免费在线| 日韩精彩视频在线观看| 91免费看片在线观看| 国产情人综合久久777777| 日本不卡不码高清免费观看| 99久久99久久综合| 久久久久久夜精品精品免费| 五月天中文字幕一区二区| 91热门视频在线观看| 国产亚洲精久久久久久| 蜜桃视频在线一区| 欧美日韩精品一区二区天天拍小说| 中文字幕中文字幕一区| 国产电影精品久久禁18| 欧美tickling挠脚心丨vk| 亚洲国产cao| 91精品办公室少妇高潮对白| 国产精品嫩草影院av蜜臀| 韩国女主播一区二区三区| 欧美一区二区三区视频在线| 婷婷久久综合九色综合绿巨人| 色婷婷久久久久swag精品| 国产偷国产偷精品高清尤物| 激情深爱一区二区| 欧美刺激午夜性久久久久久久| 亚洲国产综合视频在线观看| 一本一道久久a久久精品| 日韩伦理免费电影| 一区二区三区在线免费播放 | 日韩欧美专区在线| 亚洲一区二区在线视频| 97精品久久久午夜一区二区三区 | 91网站在线观看视频| 国产亲近乱来精品视频| 国产一区二区伦理片| 久久精品一区四区| 国产精品一卡二| 国产日韩一级二级三级| 成人黄色国产精品网站大全在线免费观看| 精品国一区二区三区| 老司机午夜精品| 日韩欧美中文一区二区| 免费精品视频最新在线| 欧美不卡一区二区| 国产一区二区三区四| 欧美国产激情二区三区 | 国产精品小仙女| 蜜桃视频一区二区三区| 精品国产免费一区二区三区香蕉| 极品美女销魂一区二区三区| 国产亚洲欧美日韩在线一区| 成人av电影观看| 亚洲国产日韩在线一区模特 | 欧美自拍偷拍一区| 午夜视频在线观看一区| 日韩精品中文字幕一区| 91精品国产综合久久精品麻豆 | 国产自产2019最新不卡| 欧美国产精品中文字幕| 色欧美乱欧美15图片| 日韩精品免费专区| 久久网站热最新地址| 97久久超碰精品国产| 日韩精品电影在线| 久久精品亚洲乱码伦伦中文| 91在线视频官网| 日本午夜精品视频在线观看| 久久久亚洲高清| 在线亚洲免费视频| 久久国产精品99久久久久久老狼| 欧美国产精品劲爆| 欧美精品高清视频|