Skip to content

Commit

Permalink
Test: Retry and Sleep if PDFReactor Server is unreachable (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
blankse authored Aug 1, 2022
1 parent 8f3dd00 commit c24dd96
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion tests/testdata/test.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use com\realobjects\pdfreactor\webservice\client\PDFreactor as PDFreactor;
use com\realobjects\pdfreactor\webservice\client\LogLevel as LogLevel;
use com\realobjects\pdfreactor\webservice\client\UnreachableServiceException;
use com\realobjects\pdfreactor\webservice\client\ViewerPreferences as ViewerPreferences;

$content = file_get_contents('resources/content.html');
Expand Down Expand Up @@ -36,7 +37,15 @@
],
];

$result = $pdfReactor->convertAsBinary($config);
for ($i = 0; $i < 5; $i++) {
try {
$result = $pdfReactor->convertAsBinary($config);
break;
} catch (UnreachableServiceException $e) {
echo 'PDF Reactor Server unreachable. Retry in 10 seconds.' . "\n";
sleep(10);
}
}

if (preg_match('/^%PDF-/', $result)) {
echo 'PDF generation was successful' . "\n";
Expand Down

0 comments on commit c24dd96

Please sign in to comment.