?? testtagutils.java
字號:
/*
* Copyright 2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.struts.taglib;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.apache.commons.logging.LogFactory;
import org.apache.commons.logging.Log;
/**
* Unit tests for the TagUtils.
*/
public class TestTagUtils extends TestCase {
/** All logging goes through this logger */
private static Log log = LogFactory.getLog(TestTagUtils.class);
protected TagUtils tagutils = TagUtils.getInstance();
/**
* Defines the testcase name for JUnit.
*
* @param theName the testcase's name.
*/
public TestTagUtils(String theName) {
super(theName);
}
/**
* Start the tests.
*
* @param theArgs the arguments. Not used
*/
public static void main(String[] theArgs) {
junit.awtui.TestRunner.main(
new String[] {TestTagUtils.class.getName()});
}
/**
* @return a test suite (<code>TestSuite</code>) that includes all methods
* starting with "test"
*/
public static Test suite() {
// All methods starting with "test" will be executed in the test suite.
return new TestSuite(TestTagUtils.class);
}
public void setUp() {
}
public void tearDown() {
}
/**
* Test Operators.
*/
public void testFilter() {
// Test Null
assertNull("Filter Test 1", tagutils.filter(null));
// Test Empty String
assertEquals("Filter Test 2", "", tagutils.filter(""));
// Test Single Character
assertEquals("Filter Test 3", "a", tagutils.filter("a"));
// Test Multiple Characters
assertEquals("Filter Test 4", "adhdfhdfhadhf", tagutils.filter("adhdfhdfhadhf"));
// Test Each filtered Character
assertEquals("Filter Test 5", "<", tagutils.filter("<"));
assertEquals("Filter Test 6", ">", tagutils.filter(">"));
assertEquals("Filter Test 7", "&", tagutils.filter("&"));
assertEquals("Filter Test 8", """, tagutils.filter("\""));
assertEquals("Filter Test 9", "'", tagutils.filter("'"));
// Test filtering beginning, middle, end
assertEquals("Filter Test 10", "a<", tagutils.filter("a<"));
assertEquals("Filter Test 11", "<a", tagutils.filter("<a"));
assertEquals("Filter Test 12", "a<a", tagutils.filter("a<a"));
// Test filtering beginning, middle, end
assertEquals("Filter Test 13", "abc<", tagutils.filter("abc<"));
assertEquals("Filter Test 14", "<abc", tagutils.filter("<abc"));
assertEquals("Filter Test 15", "abc<abc", tagutils.filter("abc<abc"));
// Test Multiple Characters
assertEquals("Filter Test 16", "<input type="text" value='Me & You'>",
tagutils.filter("<input type=\"text\" value='Me & You'>"));
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
增大字號
Ctrl + =
減小字號
Ctrl + -