userprofiletest.java
来自「我想下载一个东西」· Java 代码 · 共 82 行
JAVA
82 行
package com.ecyrd.jspwiki;import junit.framework.*;import java.io.*;import java.util.*;import org.apache.log4j.*;/** * Tests the UserProfile class. * @author Janne Jalkanen */public class UserProfileTest extends TestCase{ public UserProfileTest( String s ) { super( s ); Properties props = new Properties(); try { props.load( TestEngine.findTestProperties() ); PropertyConfigurator.configure(props); } catch( IOException e ) {} } public void setUp() throws Exception { } public void tearDown() { } public void testStringRepresentation() throws Exception { UserProfile p = new UserProfile("username=JanneJalkanen"); assertEquals( "name", "JanneJalkanen",p.getName() ); } /** * Sometimes not all servlet containers offer you correctly * decoded cookies. Reported by KalleKivimaa. */ public void testBrokenStringRepresentation() throws Exception { UserProfile p = new UserProfile("username%3DJanneJalkanen"); assertEquals( "name", "JanneJalkanen",p.getName() ); } public void testUTFStringRepresentation() throws Exception { UserProfile p = new UserProfile(); p.setName("M滗m鲻"); String s = p.getStringRepresentation(); UserProfile p2 = new UserProfile( s ); assertEquals( "name", "M滗m鲻", p2.getName() ); } public void testUTFURLStringRepresentation() throws Exception { UserProfile p = new UserProfile("username="+TextUtil.urlEncodeUTF8("M滗m鲻")); assertEquals( "name", "M滗m鲻",p.getName() ); } public static Test suite() { return new TestSuite( UserProfileTest.class ); }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?