Instantiate ZAP as a daemon prgramatically with Java
296 views
Skip to first unread message
Albert
unread,
May 9, 2016, 11:27:35 AM5/9/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to OWASP ZAP User Group
Hi,
I am running ZAP for automated testing and I been so far successful to run my set up when I have an instance of ZAP running. I am however now working on a test fixture that would start zap before the tests are run and tear it down at the end.
ZAP should run as a daemon in that case.
For some reason ZAP does not seem to start. Even when debugging appears as instantiated.
This is is the way I am calling it:
clientApi = new ClientApi(host, port);
When debuging the code, an instance of clientAPI is created, listing localhost:8502 however I can't see any listening ports.
If i run the JUnit test that use ZAP they will fail with connection exception.
However if I start ZAP on that machine using the ./zap.sh and then run the JUnit tests that use zap will sucessfuly pass using the runing instance.
How can I instantiate ZAP in java programatically in daemon mode so I can use it as a fixture in Junit test?
thc...@gmail.com
unread,
May 9, 2016, 11:48:04 AM5/9/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to zaprox...@googlegroups.com
Hi.
You should be able to achieve that with the class ProcessBuilder. [1]
For example:
ProcessBuilder pb = new ProcessBuilder("/path/to/zap.sh", "-daemon");
// Set up redirection of output...
pb.start();
// Wait for ZAP to start... for example: [2]
// Run tests...
// Shutdown ZAP with ClientApi.