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

PDF Books
Show collection (0 pages)
Collections help

Search

Retail:Mocking Hardware Manager printers for testing

Introduction

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 127.0.0.1 is used to connect the localhost but actually all IP in the range 127.0.0.0 to 127.255.255.254 will go the loopback network interface so to simulate several hardware manager instances we can define the Hardware manager URLs this way:

http://127.0.0.1:8090/printer
http://127.0.1.1:8090/printer
http://127.0.2.1:8090/printer 
http://127.0.3.1:8090/printer

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 openbravohw.properties 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:

127.0.4.1,.*1234.*

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

Regular expressions follow the Pattern java syntax for regular expressions: https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html

The list of fail conditions for receipt printers is prepended by printermock.fail, for reports reportmock.fail, for customer displays displaymock.fail and for PDF processes pdfmock.fail.

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

# Fail conditions for mock devices
printermock.fail=127.0.1.1,.*54321.*
printermock.fail.2=127.0.4.1,.*1234.*
printermock.fail.3=127.0.5.1,.*Avalanche.*
printermock.fail.4=127.0.5.1,.*GPS.*

reportmock.fail=127.0.1.1,.*54321.*
reportmock.fail.2=127.0.4.1,.*1234.*

displaymock.fail=127.0.1.1,.*54321.*
displaymock.fail.2=127.0.4.1,.*1234.*

pdfmock.fail=127.0.1.1,.*54321.*
pdfmock.fail.2=127.0.4.1,.*1234.*

Retrieved from "http://wiki.openbravo.com/wiki/Retail:Mocking_Hardware_Manager_printers_for_testing"

This page has been accessed 219 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.