Polishing test cases.
This commit is contained in:
@@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -47,9 +47,13 @@ public class CreateGameTest extends TestBase {
|
|||||||
GamePassword));
|
GamePassword));
|
||||||
|
|
||||||
PokerTHMessage msg;
|
PokerTHMessage msg;
|
||||||
do {
|
|
||||||
msg = receiveMessage();
|
msg = receiveMessage();
|
||||||
} while (msg.isPlayerListMessageSelected() || msg.isGameListMessageSelected());
|
if (!msg.isGameListMessageSelected()) {
|
||||||
|
failOnErrorMessage(msg);
|
||||||
|
fail("Invalid message.");
|
||||||
|
}
|
||||||
|
|
||||||
|
msg = receiveMessage();
|
||||||
if (msg.isJoinGameReplyMessageSelected())
|
if (msg.isJoinGameReplyMessageSelected())
|
||||||
{
|
{
|
||||||
if (msg.getJoinGameReplyMessage().getValue().getJoinGameResult().isJoinGameAckSelected())
|
if (msg.getJoinGameReplyMessage().getValue().getJoinGameResult().isJoinGameAckSelected())
|
||||||
|
|||||||
@@ -51,9 +51,7 @@ public class CreateRankingGameTest extends TestBase {
|
|||||||
|
|
||||||
createRankingGame("");
|
createRankingGame("");
|
||||||
PokerTHMessage msg;
|
PokerTHMessage msg;
|
||||||
do {
|
|
||||||
msg = receiveMessage();
|
msg = receiveMessage();
|
||||||
} while (msg.isPlayerListMessageSelected() || msg.isGameListMessageSelected());
|
|
||||||
|
|
||||||
if (msg.isJoinGameReplyMessageSelected())
|
if (msg.isJoinGameReplyMessageSelected())
|
||||||
{
|
{
|
||||||
@@ -74,20 +72,19 @@ public class CreateRankingGameTest extends TestBase {
|
|||||||
|
|
||||||
createRankingGame("");
|
createRankingGame("");
|
||||||
PokerTHMessage msg;
|
PokerTHMessage msg;
|
||||||
do {
|
|
||||||
msg = receiveMessage();
|
msg = receiveMessage();
|
||||||
} while (msg.isPlayerListMessageSelected() || msg.isGameListMessageSelected());
|
|
||||||
|
|
||||||
if (msg.isJoinGameReplyMessageSelected())
|
if (msg.isGameListMessageSelected())
|
||||||
{
|
{
|
||||||
|
msg = receiveMessage();
|
||||||
if (msg.getJoinGameReplyMessage().getValue().getJoinGameResult().isJoinGameFailedSelected())
|
if (msg.getJoinGameReplyMessage().getValue().getJoinGameResult().isJoinGameFailedSelected())
|
||||||
{
|
{
|
||||||
fail("Registered user could not create ranking game!");
|
fail("Registered user could not join ranking game!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
failOnErrorMessage(msg);
|
failOnErrorMessage(msg);
|
||||||
fail("Invalid message.");
|
fail("Registered user could not create ranking game!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,9 +94,7 @@ public class CreateRankingGameTest extends TestBase {
|
|||||||
|
|
||||||
createRankingGame(GamePassword);
|
createRankingGame(GamePassword);
|
||||||
PokerTHMessage msg;
|
PokerTHMessage msg;
|
||||||
do {
|
|
||||||
msg = receiveMessage();
|
msg = receiveMessage();
|
||||||
} while (msg.isPlayerListMessageSelected() || msg.isGameListMessageSelected());
|
|
||||||
|
|
||||||
if (msg.isJoinGameReplyMessageSelected())
|
if (msg.isJoinGameReplyMessageSelected())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -10,9 +10,11 @@ import org.junit.Test;
|
|||||||
import pokerth_protocol.NetGameInfo;
|
import pokerth_protocol.NetGameInfo;
|
||||||
import pokerth_protocol.NonZeroId;
|
import pokerth_protocol.NonZeroId;
|
||||||
import pokerth_protocol.PokerTHMessage;
|
import pokerth_protocol.PokerTHMessage;
|
||||||
|
import pokerth_protocol.StartEventAckMessage;
|
||||||
import pokerth_protocol.StartEventMessage;
|
import pokerth_protocol.StartEventMessage;
|
||||||
import pokerth_protocol.NetGameInfo.EndRaiseModeEnumType;
|
import pokerth_protocol.NetGameInfo.EndRaiseModeEnumType;
|
||||||
import pokerth_protocol.NetGameInfo.NetGameTypeEnumType;
|
import pokerth_protocol.NetGameInfo.NetGameTypeEnumType;
|
||||||
|
import pokerth_protocol.StartEventAckMessage.StartEventAckMessageSequenceType;
|
||||||
import pokerth_protocol.StartEventMessage.StartEventMessageSequenceType;
|
import pokerth_protocol.StartEventMessage.StartEventMessageSequenceType;
|
||||||
|
|
||||||
|
|
||||||
@@ -32,10 +34,16 @@ public class RunNormalGameTest extends TestBase {
|
|||||||
""));
|
""));
|
||||||
|
|
||||||
PokerTHMessage msg;
|
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.isJoinGameReplyMessageSelected()) {
|
||||||
if (!msg.getJoinGameReplyMessage().getValue().getJoinGameResult().isJoinGameAckSelected()) {
|
if (!msg.getJoinGameReplyMessage().getValue().getJoinGameResult().isJoinGameAckSelected()) {
|
||||||
fail("Could not create game!");
|
fail("Could not create game!");
|
||||||
@@ -47,6 +55,13 @@ public class RunNormalGameTest extends TestBase {
|
|||||||
}
|
}
|
||||||
long gameId = msg.getJoinGameReplyMessage().getValue().getGameId().getValue();
|
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();
|
StartEventMessageSequenceType gameStartType = new StartEventMessageSequenceType();
|
||||||
gameStartType.setGameId(new NonZeroId(gameId));
|
gameStartType.setGameId(new NonZeroId(gameId));
|
||||||
gameStartType.setFillWithComputerPlayers(true);
|
gameStartType.setFillWithComputerPlayers(true);
|
||||||
@@ -56,22 +71,47 @@ public class RunNormalGameTest extends TestBase {
|
|||||||
msg.selectStartEventMessage(startMsg);
|
msg.selectStartEventMessage(startMsg);
|
||||||
sendMessage(msg);
|
sendMessage(msg);
|
||||||
|
|
||||||
do {
|
// Now the computer players should join.
|
||||||
|
for (int i = 0; i < 9; i++) {
|
||||||
msg = receiveMessage();
|
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);
|
failOnErrorMessage(msg);
|
||||||
fail("Invalid message.");
|
fail("Invalid message.");
|
||||||
}
|
}
|
||||||
|
|
||||||
do {
|
|
||||||
msg = receiveMessage();
|
msg = receiveMessage();
|
||||||
} while (
|
if (!msg.isGameStartMessageSelected()) {
|
||||||
msg.isGameListMessageSelected()
|
failOnErrorMessage(msg);
|
||||||
|| msg.isGamePlayerMessageSelected()
|
fail("Invalid message.");
|
||||||
|| msg.isStartEventMessageSelected()
|
}
|
||||||
);
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
msg = receiveMessage();
|
msg = receiveMessage();
|
||||||
@@ -88,5 +128,18 @@ public class RunNormalGameTest extends TestBase {
|
|||||||
if (!msg.isEndOfGameMessageSelected()) {
|
if (!msg.isEndOfGameMessageSelected()) {
|
||||||
fail("No end of game received.");
|
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;
|
PokerTHMessage msg;
|
||||||
do {
|
|
||||||
msg = receiveMessage();
|
msg = receiveMessage();
|
||||||
} while (msg.isPlayerListMessageSelected() || msg.isGameListMessageSelected());
|
if (!msg.isGameListMessageSelected()) {
|
||||||
|
failOnErrorMessage(msg);
|
||||||
|
fail("Invalid message.");
|
||||||
|
}
|
||||||
|
|
||||||
|
msg = receiveMessage();
|
||||||
if (msg.isJoinGameReplyMessageSelected()) {
|
if (msg.isJoinGameReplyMessageSelected()) {
|
||||||
if (!msg.getJoinGameReplyMessage().getValue().getJoinGameResult().isJoinGameAckSelected()) {
|
if (!msg.getJoinGameReplyMessage().getValue().getJoinGameResult().isJoinGameAckSelected()) {
|
||||||
fail("Could not create game!");
|
fail("Could not create game!");
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ public abstract class TestBase {
|
|||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
|
Thread.sleep(2000);
|
||||||
InetAddress localaddr = InetAddress.getLocalHost();
|
InetAddress localaddr = InetAddress.getLocalHost();
|
||||||
sock = new Socket(localaddr, 7234);
|
sock = new Socket(localaddr, 7234);
|
||||||
encoder = CoderFactory.getInstance().newEncoder("BER");
|
encoder = CoderFactory.getInstance().newEncoder("BER");
|
||||||
@@ -118,6 +119,12 @@ public abstract class TestBase {
|
|||||||
failOnErrorMessage(msg);
|
failOnErrorMessage(msg);
|
||||||
fail("Invalid message.");
|
fail("Invalid message.");
|
||||||
}
|
}
|
||||||
|
// Waiting for player list update.
|
||||||
|
msg = receiveMessage();
|
||||||
|
if (!msg.isPlayerListMessageSelected()) {
|
||||||
|
failOnErrorMessage(msg);
|
||||||
|
fail("Invalid message.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void userInit() throws Exception {
|
public void userInit() throws Exception {
|
||||||
@@ -180,6 +187,12 @@ public abstract class TestBase {
|
|||||||
failOnErrorMessage(msg);
|
failOnErrorMessage(msg);
|
||||||
fail("Invalid message.");
|
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) {
|
public PokerTHMessage createJoinGameRequestMsg(NetGameInfo gameInfo, NetGameTypeEnumType.EnumType type, int playerActionTimeout, int guiSpeed, String password) {
|
||||||
|
|||||||
Reference in New Issue
Block a user