Chapter 4. Basic API overview

Table of Contents

API Overview
Creating simple test
Adding test to suite

API Overview

All test cases should extend tigase.tests.AbstractTest class, which offers a couple of handy methods that makes writing a test case easier. The most useful and basic are following:

  • handling user/admin account/connection:

    • createAccount() - returns AccountBuilder allowing adjusting settings of particular user account;
    • getAdminAccount() and getJaxmppAdmin() - get either Account object related to admin account or Jaxmpp object directly.
    • removeUserAccount(Jaxmpp jaxmpp) - delete particular user account
  • vhost management:

    • addVhost(Jaxmpp adminJaxmpp, String prefix)
    • removeVhost(Jaxmpp adminJaxmpp, String VHost)
  • user basic xmpp functionality methods:

    • changePresenceAndWait(Jaxmpp from, Jaxmpp to, Presence.Show p)
    • sendAndFail(Jaxmpp from, Jaxmpp to)
    • sendAndWait(Jaxmpp j, IQ iq, AsyncCallback asyncCallback)
    • sendAndWait(Jaxmpp from, Jaxmpp to, Message message)
    • sendAndWait(Jaxmpp from, Jaxmpp to, String message)
    • testSendAndWait(Jaxmpp from, Jaxmpp to)
    • testSubscribeAndWait(Jaxmpp from, Jaxmpp to)
  • utility and configuration

In addition tigase.tests.utils.AccountBuilder class allows:

  • setUsername(String username) - set username/local part name of particular account
  • setDomain(String domain) - set domain name of particular account
  • setPassword(String password) - set password of particular account
  • setEmail(String email) - set e-mail address of particular account
  • setLogPrefix(String logPrefix) - allows to customize log prefix for log entries for this particular account
  • setRegister(boolean register) - specify whether account should be registered automatically

For the purpose of testing delayed response tigase.tests.Mutex can be used: * waitFor(long timeout, String…​ items) - instruct Mutex to wait for the particular items during configured timeout * notify(String…​ itemName) - upon receiving desired response notify Mutex about it * isItemNotified(String item) - can be used to verify whether particular item was received (useful in asserts)