📄 gamecontrollertest.java
字号:
package net.sf.jawp.gf.persistence.test;
import javax.security.auth.login.LoginException;
import net.sf.jawp.gf.api.domain.User;
import net.sf.jawp.gf.api.services.LoginService;
import net.sf.jawp.gf.api.services.UserService;
import net.sf.jawp.gf.system.GameController;
import net.sf.jawp.util.PasswordUtil;
import junit.framework.TestCase;
/**
*
* @author jarek
* @version $Revision: 1.14 $
*
*/
public class GameControllerTest extends TestCase
{
private static final String PREVAYLER_FOLDER = "prevayler_store/user_test";
public GameControllerTest(final String name)
{
super(name);
}
protected void setUp() throws Exception
{
}
protected void tearDown() throws Exception
{
}
public final void testRegister()
{
registerTestUser();
final GameController<?, ? , ?> contr = new GameController(GameControllerTest.PREVAYLER_FOLDER, true);
contr.dispose();
}
private void registerTestUser()
{
final GameController<?, ? , ?> contr = new GameController(GameControllerTest.PREVAYLER_FOLDER, false);
final UserService serv = contr.getUserService();
serv.registerUser( "test", "dupa.8");
contr.close();
}
public final void testLogin() throws LoginException
{
registerTestUser();
final GameController<?, ? , ?> contr = new GameController(GameControllerTest.PREVAYLER_FOLDER, true);
try
{
final UserService<?> serv = contr.getUserService();
final LoginService<?> logServ = serv.initLogin( "test");
final String servSeed = logServ.getServerSeed();
final User usr = logServ.login( PasswordUtil.encryptMix("dupa.8", servSeed)).getLoggedUser();
System.out.println("logged test:" + usr);
if (!usr.getLogin().equals("test"))
{
throw new RuntimeException("problem with login");
}
}
finally
{
contr.dispose();
}
}
public final void testSteps()
{
registerTestUser();
final GameController<?, ? , ?> contr = new GameController(GameControllerTest.PREVAYLER_FOLDER, true);
try
{
contr.doStep(1000);
contr.doStep(1000);
contr.doStep(1000);
}
finally
{
contr.dispose();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -