📄 userprofiletest.java
字号:
package com.ecyrd.jspwiki.auth;import junit.framework.*;import java.io.*;import java.util.*;import org.apache.log4j.*;import com.ecyrd.jspwiki.*;/** * 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 testEquals() { UserProfile p = new UserProfile(); UserProfile p2 = new UserProfile(); p.setName("Alice"); p2.setName("Bob"); assertFalse( p.equals( p2 ) ); } public void testEquals2() { UserProfile p = new UserProfile(); UserProfile p2 = new UserProfile(); p.setName("Alice"); p2.setName("Alice"); assertTrue( p.equals( p2 ) ); } public void testStringRepresentation() throws Exception { UserProfile p = UserProfile.parseStringRepresentation("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 = UserProfile.parseStringRepresentation("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 = UserProfile.parseStringRepresentation( s ); assertEquals( "name", "M滗m鲻", p2.getName() ); } public void testUTFURLStringRepresentation() throws Exception { UserProfile p = UserProfile.parseStringRepresentation("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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -