📄 testusermanager.java
字号:
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space
// Source File Name: TestUserManager.java
package org.gudy.azureus2.ui.console.multiuser;
import java.io.*;
import java.util.Collection;
import junit.framework.TestCase;
import org.gudy.azureus2.ui.console.UserProfile;
// Referenced classes of package org.gudy.azureus2.ui.console.multiuser:
// UserManager
public class TestUserManager extends TestCase
{
private static final class InMemoryUserManager extends UserManager
{
public void save(OutputStream out)
{
doSave(out);
}
public void load(InputStream in)
{
doLoad(in);
}
public InMemoryUserManager(String fileName)
{
super(fileName);
}
}
private InMemoryUserManager manager;
private UserProfile profile1;
private UserProfile profile2;
public TestUserManager()
{
}
protected void setUp()
throws Exception
{
super.setUp();
manager = new InMemoryUserManager(null);
profile1 = new UserProfile();
profile1.setUsername("myuser1");
profile1.setPassword("mypassword");
manager.addUser(profile1);
profile2 = new UserProfile();
profile2.setUsername("myuser2");
profile2.setPassword("zigzag");
profile2.setUserType("user");
manager.addUser(profile2);
}
protected void tearDown()
throws Exception
{
super.tearDown();
}
public void testLoadSave()
{
ByteArrayOutputStream out = new ByteArrayOutputStream();
manager.save(out);
System.out.println((new StringBuilder()).append("Saved to: ").append(new String(out.toByteArray())).toString());
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
InMemoryUserManager newManager = new InMemoryUserManager(null);
newManager.load(in);
UserProfile profile3 = new UserProfile();
profile3.setUserType("guest");
profile3.setUsername("user3");
profile3.setPassword("whatever");
assertTrue(manager.getUsers().contains(profile1));
assertTrue(manager.getUsers().contains(profile2));
assertFalse(manager.getUsers().contains(profile3));
assertTrue(newManager.getUsers().contains(profile1));
assertTrue(newManager.getUsers().contains(profile2));
assertFalse(newManager.getUsers().contains(profile3));
}
public void testAuthenticate()
{
assertEquals("verify authentication succeeds", profile1, manager.authenticate("myuser1", "mypassword"));
assertNull("verify authentication fails", manager.authenticate("myuser1", "mypassword_shouldfail"));
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -