View source | Discuss this page | Page history | Printable version   
Main Page
Upload file
What links here
Recent changes

PDF Books
Show collection (0 pages)
Collections help


Retail:Mocking Hardware Manager printers for testing


Bulbgraph.png   Starting from RR17Q1 below functionality is available

In order to create automated tests for the selecting printer functionalities we require to simulate the execution of several hardware managers instances and also simulate success and fail responses for each of the simulated hardware based on the request sent. These requests can be requests to print receipts, reports, pdf files and messages to show in the customer display. The output of these requests are not needed to be actually printed. Simulate several hardware manager instances To simulate several hardware manager instances in the local we will use the loopback network interface. Tipicaly the IP is used to connect the localhost but actually all IP in the range to will go the loopback network interface so to simulate several hardware manager instances we can define the Hardware manager URLs this way:

With only one Hardware Manager running in localhost will be seen as multiple hardware manager instances from the Web POS

Mock devices

To simulate success and fail conditions new devices mock has been created for receipt printers, customer displays and PDF processes. These devices will act as regular devices but will not produce any output at all and will return success or fail depending on the request sent. To define a mock printer configure your printers in the file this way:

## Receipt printers ##
machine.printer = mock
machine.printer.2 = mock

To define a mock customer display use:

## Customer display ##
machine.display = mock

And to define a mock PDF process:

## Printing PDF ##
process.printpdf = mock

Success and fail conditions

By default all the mock devices will return a success response to every request processed. To define when to fail you have to configure a list of network ip and a regular expression for each device. Then if the request client in sent to the network IP described in the fail condition and the body of the request matches with the regular expression, then it will fail. An exception is raised and a server failure will be sent to the client.

An example of a fail condition definition is:,.*1234.*

This means that if the network IP client used is and the body of the request contains 1234 the request will fail.

Regular expressions follow the Pattern java syntax for regular expressions:

The list of fail conditions for receipt printers is prepended by, for reports, for customer displays and for PDF processes

This is an example of several fail conditions for all devices:

# Fail conditions for mock devices,.*54321.*,.*1234.*,.*Avalanche.*,.*GPS.*,.*54321.*,.*1234.*,.*54321.*,.*1234.*,.*54321.*,.*1234.*

Retrieved from ""

This page has been accessed 192 times. This page was last modified on 21 December 2016, at 14:57. Content is available under Creative Commons Attribution-ShareAlike 2.5 Spain License.