Polishing test cases.

This commit is contained in:
lotodore
2010-11-13 12:36:22 +00:00
parent c583d19002
commit 55f7bb7132
6 changed files with 151 additions and 31 deletions
@@ -0,0 +1,52 @@
package pokerth_protocol;
//
// This file was generated by the BinaryNotes compiler.
// See http://bnotes.sourceforge.net
// Any modifications to this file will be lost upon recompilation of the source ASN.1.
//
import org.bn.*;
import org.bn.annotations.*;
import org.bn.annotations.constraints.*;
import org.bn.coders.*;
import org.bn.types.*;
@ASN1PreparedElement
@ASN1Sequence ( name = "ChatRequestTypePrivate", isSet = false )
public class ChatRequestTypePrivate implements IASN1PreparedElement {
@ASN1Element ( name = "targetPlayerId", isOptional = false , hasTag = false , hasDefaultValue = false )
private NonZeroId targetPlayerId = null;
public NonZeroId getTargetPlayerId () {
return this.targetPlayerId;
}
public void setTargetPlayerId (NonZeroId value) {
this.targetPlayerId = value;
}
public void initWithDefaults() {
}
private static IASN1PreparedElementData preparedData = CoderFactory.getInstance().newPreparedElementData(ChatRequestTypePrivate.class);
public IASN1PreparedElementData getPreparedData() {
return preparedData;
}
}
+7 -3
View File
@@ -47,9 +47,13 @@ public class CreateGameTest extends TestBase {
GamePassword));
PokerTHMessage msg;
do {
msg = receiveMessage();
} while (msg.isPlayerListMessageSelected() || msg.isGameListMessageSelected());
msg = receiveMessage();
if (!msg.isGameListMessageSelected()) {
failOnErrorMessage(msg);
fail("Invalid message.");
}
msg = receiveMessage();
if (msg.isJoinGameReplyMessageSelected())
{
if (msg.getJoinGameReplyMessage().getValue().getJoinGameResult().isJoinGameAckSelected())
@@ -51,9 +51,7 @@ public class CreateRankingGameTest extends TestBase {
createRankingGame("");
PokerTHMessage msg;
do {
msg = receiveMessage();
} while (msg.isPlayerListMessageSelected() || msg.isGameListMessageSelected());
msg = receiveMessage();
if (msg.isJoinGameReplyMessageSelected())
{
@@ -74,20 +72,19 @@ public class CreateRankingGameTest extends TestBase {
createRankingGame("");
PokerTHMessage msg;
do {
msg = receiveMessage();
} while (msg.isPlayerListMessageSelected() || msg.isGameListMessageSelected());
msg = receiveMessage();
if (msg.isJoinGameReplyMessageSelected())
if (msg.isGameListMessageSelected())
{
msg = receiveMessage();
if (msg.getJoinGameReplyMessage().getValue().getJoinGameResult().isJoinGameFailedSelected())
{
fail("Registered user could not create ranking game!");
fail("Registered user could not join ranking game!");
}
}
else {
failOnErrorMessage(msg);
fail("Invalid message.");
fail("Registered user could not create ranking game!");
}
}
@@ -97,9 +94,7 @@ public class CreateRankingGameTest extends TestBase {
createRankingGame(GamePassword);
PokerTHMessage msg;
do {
msg = receiveMessage();
} while (msg.isPlayerListMessageSelected() || msg.isGameListMessageSelected());
msg = receiveMessage();
if (msg.isJoinGameReplyMessageSelected())
{
+66 -13
View File
@@ -10,9 +10,11 @@ import org.junit.Test;
import pokerth_protocol.NetGameInfo;
import pokerth_protocol.NonZeroId;
import pokerth_protocol.PokerTHMessage;
import pokerth_protocol.StartEventAckMessage;
import pokerth_protocol.StartEventMessage;
import pokerth_protocol.NetGameInfo.EndRaiseModeEnumType;
import pokerth_protocol.NetGameInfo.NetGameTypeEnumType;
import pokerth_protocol.StartEventAckMessage.StartEventAckMessageSequenceType;
import pokerth_protocol.StartEventMessage.StartEventMessageSequenceType;
@@ -32,10 +34,16 @@ public class RunNormalGameTest extends TestBase {
""));
PokerTHMessage msg;
do {
msg = receiveMessage();
} while (msg.isPlayerListMessageSelected() || msg.isGameListMessageSelected());
// Game list update (new game)
msg = receiveMessage();
if (!msg.isGameListMessageSelected()) {
failOnErrorMessage(msg);
fail("Invalid message.");
}
// Join game ack.
msg = receiveMessage();
if (msg.isJoinGameReplyMessageSelected()) {
if (!msg.getJoinGameReplyMessage().getValue().getJoinGameResult().isJoinGameAckSelected()) {
fail("Could not create game!");
@@ -47,6 +55,13 @@ public class RunNormalGameTest extends TestBase {
}
long gameId = msg.getJoinGameReplyMessage().getValue().getGameId().getValue();
// Game list update (player joined).
msg = receiveMessage();
if (!msg.isGameListMessageSelected()) {
failOnErrorMessage(msg);
fail("Invalid message.");
}
StartEventMessageSequenceType gameStartType = new StartEventMessageSequenceType();
gameStartType.setGameId(new NonZeroId(gameId));
gameStartType.setFillWithComputerPlayers(true);
@@ -56,22 +71,47 @@ public class RunNormalGameTest extends TestBase {
msg.selectStartEventMessage(startMsg);
sendMessage(msg);
do {
// Now the computer players should join.
for (int i = 0; i < 9; i++) {
msg = receiveMessage();
} while (msg.isGameListMessageSelected());
if (!msg.isGamePlayerMessageSelected()) {
failOnErrorMessage(msg);
fail("Invalid message.");
}
msg = receiveMessage();
if (!msg.isGameListMessageSelected()) {
failOnErrorMessage(msg);
fail("Invalid message.");
}
}
if (msg.isGameStartMessageSelected()) {
// Server should confirm start event.
msg = receiveMessage();
if (!msg.isStartEventMessageSelected()) {
failOnErrorMessage(msg);
fail("Invalid message.");
}
// Acknowledge start event.
StartEventAckMessageSequenceType startType = new StartEventAckMessageSequenceType();
startType.setGameId(new NonZeroId(gameId));
StartEventAckMessage startAck = new StartEventAckMessage();
startAck.setValue(startType);
msg = new PokerTHMessage();
msg.selectStartEventAckMessage(startAck);
sendMessage(msg);
// Game list update (game now running).
msg = receiveMessage();
if (!msg.isGameListMessageSelected()) {
failOnErrorMessage(msg);
fail("Invalid message.");
}
do {
msg = receiveMessage();
} while (
msg.isGameListMessageSelected()
|| msg.isGamePlayerMessageSelected()
|| msg.isStartEventMessageSelected()
);
msg = receiveMessage();
if (!msg.isGameStartMessageSelected()) {
failOnErrorMessage(msg);
fail("Invalid message.");
}
do {
msg = receiveMessage();
@@ -88,5 +128,18 @@ public class RunNormalGameTest extends TestBase {
if (!msg.isEndOfGameMessageSelected()) {
fail("No end of game received.");
}
// Now the computer players should leave.
for (int i = 0; i < 9; i++) {
msg = receiveMessage();
if (!msg.isGamePlayerMessageSelected()) {
failOnErrorMessage(msg);
fail("Invalid message.");
}
msg = receiveMessage();
if (!msg.isGameListMessageSelected()) {
failOnErrorMessage(msg);
fail("Invalid message.");
}
}
}
}
@@ -45,10 +45,13 @@ public class StartNormalGameTest extends TestBase {
""));
PokerTHMessage msg;
do {
msg = receiveMessage();
} while (msg.isPlayerListMessageSelected() || msg.isGameListMessageSelected());
msg = receiveMessage();
if (!msg.isGameListMessageSelected()) {
failOnErrorMessage(msg);
fail("Invalid message.");
}
msg = receiveMessage();
if (msg.isJoinGameReplyMessageSelected()) {
if (!msg.getJoinGameReplyMessage().getValue().getJoinGameResult().isJoinGameAckSelected()) {
fail("Could not create game!");
+13
View File
@@ -54,6 +54,7 @@ public abstract class TestBase {
@Before
public void setUp() throws Exception {
Thread.sleep(2000);
InetAddress localaddr = InetAddress.getLocalHost();
sock = new Socket(localaddr, 7234);
encoder = CoderFactory.getInstance().newEncoder("BER");
@@ -118,6 +119,12 @@ public abstract class TestBase {
failOnErrorMessage(msg);
fail("Invalid message.");
}
// Waiting for player list update.
msg = receiveMessage();
if (!msg.isPlayerListMessageSelected()) {
failOnErrorMessage(msg);
fail("Invalid message.");
}
}
public void userInit() throws Exception {
@@ -180,6 +187,12 @@ public abstract class TestBase {
failOnErrorMessage(msg);
fail("Invalid message.");
}
// Waiting for player list update.
msg = receiveMessage();
if (!msg.isPlayerListMessageSelected()) {
failOnErrorMessage(msg);
fail("Invalid message.");
}
}
public PokerTHMessage createJoinGameRequestMsg(NetGameInfo gameInfo, NetGameTypeEnumType.EnumType type, int playerActionTimeout, int guiSpeed, String password) {