Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mocking a Printer

We have to build some software in Java that at the end prints some documents. Different documents should go to different trays of the printer. Because during development we don't have the same printer available as our customer, we are looking for a little piece of software that mocks a printer. We should be able to configure that mock, for example how many trays there are available.

Does anyone know such a tool for mac or windows?

like image 841
fkleinko Avatar asked Dec 20 '12 08:12

fkleinko


2 Answers

Write an abstraction layer which you implement once for your customer's "real" printer and once for a "virtual" printer. Write integration tests for the customer version, run those tests in your customer's environment. Code against the abstraction layer.

like image 53
Sean Patrick Floyd Avatar answered Oct 23 '22 21:10

Sean Patrick Floyd


You could create a dummy printer yourself on windows, without any special software.

In Windows 7:

  1. Control Panel
  2. Devices and Printers
  3. [Right click] Add a Printer
  4. Add a local printer
  5. Use an existing port (assuming it already exists, create a new one if it doesn't)
  6. File: (to print to a file), NUL: (to print nowhere) or CON: (to print to console)
  7. Select a printer you wish to emulate from the list of printers.

If you set it as default printer, it should be easy enough to use from java code.

like image 24
eis Avatar answered Oct 23 '22 22:10

eis