-
Notifications
You must be signed in to change notification settings - Fork 0
tests
The hub has a command-line interface which implements the HubConnector
interface to be able to test the ASAPHub manually.
Each instance of the CLI represents an ASAPPeer.
The CLI instances could be started on different machine to communicate with Hub over the network (TCP-IP).
It's also possible to start multiple CLI instances on one machine.
Before you can use the CLI a Hub instance must be started. The CLI provides the following commands:
-
set-id [peer-id] [multichannel false/true]
sets the peer-id -
peers
gets all registered peers from the hub -
connect [target-peer-id]
establishes a connection with the peer "target-peer-id" and sends the message "hello world" -
help
prints all available commands to the console -
history
prints the command history, which could be used as input (testplan) for the automated CLI tests -
exit
terminates the application
The automated CLI tests can be used to implement integration tests based on findings from the manual testing.
The test class reads all testplans from the testplans
directory.
A test plan is defined as subdirectory contain one .txt
file for each peer.
The testplan .txt
files have one CLI command at each line.
After reading the testplan files the AutomatedCLITests
class will create one HubConnector-CLI instance for each peer.
The commands from the .txt
files will be used as user input.
This approach makes it possible to trace back bugs which were found while manual testing.
- create new subdirectory inside
testplans/
- create a
.txt
file for each peer - add the CLI commands of each peer to these files
- execute the test class
AutomatedCLITests
which is located atsrc/test/java/net/sharksystem/hub/AutomatedCLITests.java
The following directory tree shows the file structure to setup a integration for alice and bob. Each subdirectory represents one integration test.
testplans/
├─ alice_bob_encounter_good/
│ ├─ alice.txt
│ ├─ bob.txt
The ASAPHub repository already contains some example testplans.
The class HubUsageTests
implements integration tests which are showing how to use the hub.
Additionally these tests could be used as healthcheck to make sure everything is working fine after refactoring the source code.
The HubUsageTests
class implements tests using the HubManager
and additional tests using a self implemented HubConnector class.
Inside these tests an ASAP encounter between alice and bob is initiated.