示例#1
0
  public void testTableChatResponse() {
    Player player = new Player(192);
    Table table = new Table(42);
    table.joinTable(player);
    TableView.createTableView(table, lobby, null);
    String existing = TableView.getTableView().getChat().getText();
    String text = "Hello!";

    String message =
        Message.responseHeader(true)
            + "<tableChatResponse table='"
            + table.getNumber()
            + "' player='"
            + player.getID()
            + "'>"
            + "<text>"
            + text
            + "</text>"
            + "</tableChatResponse></response>";

    Document d = Message.construct(message);
    Message m = new Message(d);

    // process message on client
    context.getClient().process(m);

    // validate new text appended
    String newText = TableView.getTableView().getChat().getText().trim();
    assertEquals(existing + player.getID() + ": " + text, newText);
  }
示例#2
0
 // test logging in and out
 public void testLoginAndLogout() {
   String s =
       "<request version=\"1.0\" id=\"589a39591271844e3fbe32bbb9281ad9\"><login player=\""
           + playerId
           + "\" password=\"goodbye\" self-register=\"false\"/></request>";
   Document d = Message.construct(s);
   Message m1 = new Message(d);
   m1.setOriginator(playerId + "");
   assertFalse(DatabaseManager.getInstance().loginPlayer(playerId + "", "hello"));
   assertTrue(DatabaseManager.getInstance().logoutPlayer(m1));
   assertFalse(DatabaseManager.getInstance().loginPlayer(playerId + "", "wrong password"));
   assertTrue(DatabaseManager.getInstance().loginPlayer(playerId + "", "hello"));
 }