Пример #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"));
 }
Пример #3
0
  protected void setUp() throws Exception {
    super.setUp();
    // we test the database manager on live! We're testing against a real database! Scary!
    MockDatabaseManager.revertDatabaseManager();
    // MockDatabaseManager.replaceDatabaseManager();
    currHighest = DatabaseManager.getInstance().findMaxPlayerId();
    DBPlayer temp = DatabaseManager.getInstance().getPlayer(currHighest + "");

    // some convoluted logic so we don't spam that many people into the db
    if (temp != null
        && (temp.getPassword().equalsIgnoreCase("hello")
            || temp.getPassword().equalsIgnoreCase("goodbye")
            || temp.getName().equalsIgnoreCase("test"))) playerId = currHighest;
    else playerId = currHighest + 1;

    DatabaseManager.getInstance().registerPlayer("hello");
    try {
      Message.unconfigure();
      assertTrue(Configure.configure());
    } catch (Exception e) {
      fail("Unable to setup Message tests.");
    }
  }