New test cases for player info requests - also tests basic avatar handling.

This commit is contained in:
lotodore
2011-02-13 00:22:03 +00:00
parent 381d47deea
commit 8780b98545
3 changed files with 20 additions and 5 deletions
+1
View File
@@ -26,6 +26,7 @@ import org.junit.runners.Suite;
@Suite.SuiteClasses( { @Suite.SuiteClasses( {
GuestLoginTest.class, GuestLoginTest.class,
AuthLoginTest.class, AuthLoginTest.class,
PlayerInfoTest.class,
CreateGameTest.class, CreateGameTest.class,
CreateRankingGameTest.class, CreateRankingGameTest.class,
StartNormalGameTest.class, StartNormalGameTest.class,
@@ -248,6 +248,9 @@ public class RunRankingGameTest extends TestBase {
} }
} while (!msg.isEndOfGameMessageSelected()); } while (!msg.isEndOfGameMessageSelected());
for (int i = 0; i < 9; i++) {
s[i].close();
}
Thread.sleep(2000); Thread.sleep(2000);
// Check database entry for the game. // Check database entry for the game.
+16 -5
View File
@@ -80,11 +80,12 @@ public abstract class TestBase {
return decoder.decode(s.getInputStream(), PokerTHMessage.class); return decoder.decode(s.getInputStream(), PokerTHMessage.class);
} }
public void guestInit() throws Exception { public long guestInit() throws Exception {
guestInit(sock); return guestInit(sock);
} }
public void guestInit(Socket s) throws Exception { public long guestInit(Socket s) throws Exception {
long playerId = 0;
PokerTHMessage msg = receiveMessage(s); PokerTHMessage msg = receiveMessage(s);
AnnounceMessage announce = msg.getAnnounceMessage(); AnnounceMessage announce = msg.getAnnounceMessage();
assertTrue(announce.getValue().getServerType().getValue() == ServerTypeEnumType.EnumType.serverTypeInternetAuth); assertTrue(announce.getValue().getServerType().getValue() == ServerTypeEnumType.EnumType.serverTypeInternetAuth);
@@ -107,11 +108,11 @@ public abstract class TestBase {
sendMessage(msg, s); sendMessage(msg, s);
msg = receiveMessage(s); msg = receiveMessage(s);
if (msg.isInitAckMessageSelected()) if (msg.isInitAckMessageSelected()) {
{
InitAckMessage initAck = msg.getInitAckMessage(); InitAckMessage initAck = msg.getInitAckMessage();
assertTrue(initAck.getValue().getYourPlayerId().getValue() != 0L); assertTrue(initAck.getValue().getYourPlayerId().getValue() != 0L);
assertTrue(!initAck.getValue().isYourAvatarPresent()); assertTrue(!initAck.getValue().isYourAvatarPresent());
playerId = initAck.getValue().getYourPlayerId().getValue();
} }
else { else {
failOnErrorMessage(msg); failOnErrorMessage(msg);
@@ -123,6 +124,7 @@ public abstract class TestBase {
failOnErrorMessage(msg); failOnErrorMessage(msg);
fail("Invalid message."); fail("Invalid message.");
} }
return playerId;
} }
public long userInit() throws Exception { public long userInit() throws Exception {
@@ -130,6 +132,10 @@ public abstract class TestBase {
} }
public long userInit(Socket s, String user, String password) throws Exception { public long userInit(Socket s, String user, String password) throws Exception {
return userInit(s, user, password, null);
}
public long userInit(Socket s, String user, String password, byte[] avatarData) throws Exception {
long playerId = 0; long playerId = 0;
PokerTHMessage msg = receiveMessage(s); PokerTHMessage msg = receiveMessage(s);
AnnounceMessage announce = msg.getAnnounceMessage(); AnnounceMessage announce = msg.getAnnounceMessage();
@@ -142,6 +148,11 @@ public abstract class TestBase {
requestedVersion.setMajor(PROTOCOL_VERSION_MAJOR); requestedVersion.setMajor(PROTOCOL_VERSION_MAJOR);
requestedVersion.setMinor(PROTOCOL_VERSION_MINOR); requestedVersion.setMinor(PROTOCOL_VERSION_MINOR);
AuthenticatedLogin authLogin = new AuthenticatedLogin(); AuthenticatedLogin authLogin = new AuthenticatedLogin();
AvatarHash avatar = null;
if (avatarData != null) {
avatar = new AvatarHash(avatarData);
}
authLogin.setAvatar(avatar);
authLogin.setClientUserData(scramAuth.executeStep1(user).getBytes()); authLogin.setClientUserData(scramAuth.executeStep1(user).getBytes());
LoginChoiceType loginType = new LoginChoiceType(); LoginChoiceType loginType = new LoginChoiceType();
loginType.selectAuthenticatedLogin(authLogin); loginType.selectAuthenticatedLogin(authLogin);