2010-11-12 22:44:11 +00:00
|
|
|
/* PokerTH automated tests.
|
|
|
|
|
Copyright (C) 2010 Lothar May
|
|
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU Affero General Public License as
|
|
|
|
|
published by the Free Software Foundation, either version 3 of the
|
|
|
|
|
License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU Affero General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
package pokerth_test;
|
|
|
|
|
|
|
|
|
|
import static org.junit.Assert.*;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Collection;
|
|
|
|
|
|
|
|
|
|
import org.junit.Test;
|
|
|
|
|
|
|
|
|
|
import pokerth_protocol.*;
|
|
|
|
|
import pokerth_protocol.NetGameInfo.EndRaiseModeEnumType;
|
|
|
|
|
import pokerth_protocol.NetGameInfo.NetGameTypeEnumType;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class CreateRankingGameTest extends TestBase {
|
|
|
|
|
|
|
|
|
|
static private int counter = 0;
|
|
|
|
|
|
|
|
|
|
private void createRankingGame(String password) throws Exception {
|
|
|
|
|
counter++;
|
|
|
|
|
Collection<Integer> l = new ArrayList<Integer>();
|
|
|
|
|
NetGameInfo gameInfo = createGameInfo(8, EndRaiseModeEnumType.EnumType.doubleBlinds, 0, 50, GuestUser + " create ranking game " + counter, l, 10, 0, 11, 10000);
|
2010-11-14 01:10:24 +00:00
|
|
|
sendMessage(createGameRequestMsg(
|
2010-11-12 22:44:11 +00:00
|
|
|
gameInfo,
|
|
|
|
|
NetGameTypeEnumType.EnumType.rankingGame,
|
|
|
|
|
20,
|
|
|
|
|
7,
|
|
|
|
|
password));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testCreateRankingGameAsGuest() throws Exception {
|
|
|
|
|
guestInit();
|
|
|
|
|
|
|
|
|
|
createRankingGame("");
|
|
|
|
|
PokerTHMessage msg;
|
2010-11-13 12:36:22 +00:00
|
|
|
msg = receiveMessage();
|
2010-11-12 22:44:11 +00:00
|
|
|
|
|
|
|
|
if (msg.isJoinGameReplyMessageSelected())
|
|
|
|
|
{
|
|
|
|
|
if (!msg.getJoinGameReplyMessage().getValue().getJoinGameResult().isJoinGameFailedSelected())
|
|
|
|
|
{
|
|
|
|
|
fail("Guest user could create ranking game!");
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-11-12 23:34:50 +00:00
|
|
|
else {
|
|
|
|
|
failOnErrorMessage(msg);
|
|
|
|
|
fail("Invalid message.");
|
2010-11-12 22:44:11 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testCreateRankingGameNoPasswordAsUser() throws Exception {
|
|
|
|
|
userInit();
|
|
|
|
|
|
|
|
|
|
createRankingGame("");
|
|
|
|
|
PokerTHMessage msg;
|
2010-11-13 12:36:22 +00:00
|
|
|
msg = receiveMessage();
|
2010-11-12 22:44:11 +00:00
|
|
|
|
2010-11-13 12:36:22 +00:00
|
|
|
if (msg.isGameListMessageSelected())
|
2010-11-12 22:44:11 +00:00
|
|
|
{
|
2010-11-13 12:36:22 +00:00
|
|
|
msg = receiveMessage();
|
2010-11-12 22:44:11 +00:00
|
|
|
if (msg.getJoinGameReplyMessage().getValue().getJoinGameResult().isJoinGameFailedSelected())
|
|
|
|
|
{
|
2010-11-13 12:36:22 +00:00
|
|
|
fail("Registered user could not join ranking game!");
|
2010-11-12 22:44:11 +00:00
|
|
|
}
|
|
|
|
|
}
|
2010-11-12 23:34:50 +00:00
|
|
|
else {
|
|
|
|
|
failOnErrorMessage(msg);
|
2010-11-13 12:36:22 +00:00
|
|
|
fail("Registered user could not create ranking game!");
|
2010-11-12 22:44:11 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testCreateRankingGameWithPasswordAsUser() throws Exception {
|
|
|
|
|
userInit();
|
|
|
|
|
|
|
|
|
|
createRankingGame(GamePassword);
|
|
|
|
|
PokerTHMessage msg;
|
2010-11-13 12:36:22 +00:00
|
|
|
msg = receiveMessage();
|
2010-11-12 22:44:11 +00:00
|
|
|
|
|
|
|
|
if (msg.isJoinGameReplyMessageSelected())
|
|
|
|
|
{
|
|
|
|
|
if (!msg.getJoinGameReplyMessage().getValue().getJoinGameResult().isJoinGameFailedSelected())
|
|
|
|
|
{
|
|
|
|
|
fail("Registered user should not be allowed to create ranking game with password!");
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-11-12 23:34:50 +00:00
|
|
|
else {
|
|
|
|
|
failOnErrorMessage(msg);
|
|
|
|
|
fail("Invalid message.");
|
2010-11-12 22:44:11 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|