Skip to content
Marvin Rausch edited this page Apr 3, 2023 · 7 revisions

Test the hub manually using the CLI

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.

How to use the CLI

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

Automated CLI tests

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 a new test plan

  1. create new subdirectory inside testplans/
  2. create a .txt file for each peer
  3. add the CLI commands of each peer to these files
  4. execute the test class AutomatedCLITests which is located at src/test/java/net/sharksystem/hub/AutomatedCLITests.java

testplan file structure

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.

HubUsageTests

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.