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

📄 teststringtools.java

📁 JAVA做的J2EE下CA认证系统 基于EJB开发
💻 JAVA
字号:
/************************************************************************* *                                                                       * *  EJBCA: The OpenSource Certificate Authority                          * *                                                                       * *  This software 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 any later version.                    * *                                                                       * *  See terms of license at gnu.org.                                     * *                                                                       * *************************************************************************/package se.anatom.ejbca.util;import junit.framework.TestCase;import org.apache.log4j.Logger;/** * Tests the StringTools class . * * @version $Id: TestStringTools.java,v 1.4.2.1 2005/08/18 07:32:40 anatom Exp $ */public class TestStringTools extends TestCase {    private static Logger log = Logger.getLogger(TestStringTools.class);    /**     * Creates a new TestStringTools object.     *     * @param name name     */    public TestStringTools(String name) {        super(name);    }    protected void setUp() throws Exception {        log.debug(">setUp()");        log.debug("<setUp()");    }    protected void tearDown() throws Exception {        log.debug(">tearDown()");        log.debug("<tearDown()");    }    /**     * tests stipping whitespace     *     * @throws Exception error     */    public void test01StripWhitespace() throws Exception {        log.debug(">test01StripWhitespace()");        String test = " foo \t bar \r\n\r\n \f\f\f quu x                  ";        assertEquals("foobarquux", StringTools.stripWhitespace(test));        log.debug(">test01StripWhitespace()");    }    public void test02IpStringToOctets() throws Exception {        log.debug(">test02IpStringToOctets()");        String ip = "23.34.45.167";        byte[] octs = StringTools.ipStringToOctets(ip);        for (int i=0;i<octs.length;i++) {            log.debug("octs["+i+"]="+(int)octs[i]);        }        log.debug(">test02IpStringToOctets()");    }    public void test03Strip() throws Exception {    	log.debug(">test03Strip()");    	String strip1 = "foo$bar:far%";    	String stripped = StringTools.strip(strip1);    	assertTrue("String has chars that should be stripped!", StringTools.hasSqlStripChars(strip1));    	assertEquals("String not stripped correctly!", stripped, "foo/bar/far/");		log.debug("<test03Strip()");    }    public void test04Strip() throws Exception {        log.debug(">test04Strip()");        String strip1 = "CN=foo, O=Acme\\, Inc, OU=;\\/<>bar";        String stripped = StringTools.strip(strip1);        assertTrue("String has chars that should be stripped!", StringTools.hasSqlStripChars(strip1));        assertEquals("String not stripped correctly!", stripped, "CN=foo, O=Acme\\, Inc, OU=/////bar");        log.debug("<test04Strip()");    }}

⌨️ 快捷键说明

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