#!/usr/local/bin/php <?php $expected = "I expect this to be echo'd out"; $client = new PlutonClient('inprogress'); $client->initialize(); $request = new PlutonClientRequest(); $request->setRequestData($expected); $request->setContext("echo.sleepMS", "3000"); $client->addRequest('system.echo.0.raw', $request); $client->executeAndWaitSent(); if ($request->inProgress()) { print "Request is in progress - good\n"; } else { print "Request is NOT in progress - bad\n"; exit(1); } $res = $client->executeAndWaitAny(); print "executeAndWaitAny returned {$res}\n"; if ($request->inProgress()) { print "Request is still in progress - bad\n"; exit(2); } else { print "Request is NOT in progress - good\n"; } $responseData = null; $request->getResponseData($responseData); if ($responseData !== $expected) { print "Client test failed\n expected: {$expected}\n received: {$responseData}\n"; exit(3); } else { print "Client test successful\n";
#!/usr/bin/php <?php $pc = new PlutonClient("phpClient"); $pc->initialize(); $clReq1 = new PlutonClientRequest(); $clReq2 = new PlutonClientRequest(); $req1 = "1234567890"; $req2 = "qwertyuiop"; $clReq1->setRequestData($req1); if (!$pc->addRequest(SERVICE_KEY, $clReq1)) { print_r("addRequest Error! " . $pc->getFault() . "\n"); exit(-1); } $clReq2->setRequestData($req2); if (!$pc->addRequest(SERVICE_KEY, $clReq2)) { print_r("addRequest Error! " . $pc->getFault() . "\n"); exit(-1); } // ExecuteAndWaitALL $pc->executeAndWaitAll(); if ($pc->hasFault()) { print_r("Fault! " . $pc->getFault() . "\n"); exit(-1); } $response = ''; $fault = $clReq1->getResponseData($response); if ($fault != 0) { print_r("fault: " . $clReq1->getFaultText() . "\n"); exit(1); } if ($response != $req1) {
#!/usr/local/bin/php <?php $client = new PlutonClient('fault'); $client->initialize("/does/not/exist"); if ($client->hasFault()) { print "client has fault after bogus initialize - good\n"; } else { print "client does NOT have fault after bogus initialize - bad\n"; exit(1); } $ftext = $client->getFault(); $fc = $client->getFaultCode(); $flong = $client->getFaultMessage("LONG", 1); $fshort = $client->getFaultMessage("SHORT", 0); print "Fault code={$fc} Text={$ftext}\n"; print "Short={$fshort}\n"; print "Long={$flong}\n"; if (strlen($flong) == 0) { print "Long message should not be zero length\n"; exit(3); } if (strlen($fshort) == strlen($flong)) { print "Hmm expected short message to be shorter than long message\n"; exit(4); } $client->initialize(); $client->reset(); if ($client->hasFault()) { print "client has fault after reset - bad\n"; exit(5); }