#!/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";
Exemple #2
0
#!/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 
function abortme($why, $excode)
{
    print "Attributes1 failed: {$why}\n";
    exit($excode);
}
$client = new PlutonClient('attributes');
$api = $client->getAPIVersion();
print "API={$api}\n\n";
print "Setting attributes\n";
$request = new PlutonClientRequest();
$request->setAttribute(PLUTON_NOWAIT_ATTR);
$request->setAttribute(PLUTON_NOREMOTE_ATTR);
$request->setAttribute(PLUTON_NORETRY_ATTR);
$request->setAttribute(PLUTON_KEEPAFFINITY_ATTR);
$request->setAttribute(PLUTON_NEEDAFFINITY_ATTR);
$request->setAttribute(PLUTON_ALL_ATTR);
print "Fetching attributes\n";
function checkAttribute($req, $name, $att, $val)
{
    $b = $req->getAttribute($att);
    if ($b != $val) {
        abortme("Attribute not as expected for {$name} as {$b} != {$val}", 1);
    }
    print "{$name}={$b} ok\n";
}
checkAttribute($request, "PLUTON_NOWAIT_ATTR", PLUTON_NOWAIT_ATTR, 1);
checkAttribute($request, "PLUTON_NOREMOTE_ATTR", PLUTON_NOREMOTE_ATTR, 1);
checkAttribute($request, "PLUTON_NORETRY_ATTR", PLUTON_NORETRY_ATTR, 1);
checkAttribute($request, "PLUTON_KEEPAFFINITY_ATTR", PLUTON_KEEPAFFINITY_ATTR, 1);
#!/usr/local/bin/php
<?php 
function abortme($why, $excode)
{
    print "Context1 failed: {$why}\n";
    exit($excode);
}
$client = new PlutonClient('context');
$request = new PlutonClientRequest();
$client->initialize();
if (!$request->setContext("random", 23)) {
    abortme("Context set of innocuous name failed", 1);
}
if ($request->setContext("pluton.haha", 24)) {
    abortme("Context set of protected namespace succeeded", 2);
}
$request->reset();
$request->setContext("echo.sleepMS", "3300");
$res = $client->addRequest("system.echo.0.raw", $request);
print "AddRequest = {$res}\n";
if (!$res) {
    $em1 = $request->getFaultText();
    $em2 = $client->getFault();
    abortme("addRequest Failed with {$em1}:{$em2}", 3);
}
$st = time();
$res = $client->executeAndWaitAll();
print "E&WAll = {$res}\n";
$et = time();
print "Time diffs st={$st} et={$et}\n";
if ($st + 2 > $et) {
Exemple #5
0
#!/usr/local/bin/php
<?php 
$expected = "I expect this to be echo'd out";
$client = new PlutonClient('timeout');
$client->initialize();
$client->setTimeoutMilliSeconds(1000);
$to = $client->getTimeoutMilliSeconds();
if ($to != 1000) {
    print "Expected timeout to be 1000 rather than {$to}\n";
    exit(1);
}
$request = new PlutonClientRequest();
$request->setRequestData($expected);
$request->setContext("echo.sleepMS", "3000");
$client->addRequest('system.echo.0.raw', $request);
$res = $client->executeAndWaitAll();
print "Result of E&W with timeout is {$res}\n";
if ($request->hasFault()) {
    print "Request has fault - good\n";
} else {
    print "Request does NOT have fault - bad\n";
    exit(2);
}
$fc = $request->getFaultCode();
# We happen to know that timeout is -19
if ($fc != -19) {
    print "Expected fault code of -19 rather than {$fc}\n";
    exit(4);
}
Exemple #6
0
#!/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);
}
Exemple #7
0
#!/usr/local/bin/php
<?php 
$expected = "I expect this to be echo'd out";
$client = new PlutonClient('execute');
$client->initialize();
$request10 = new PlutonClientRequest();
$request10->setRequestData($expected);
$request10->setClientHandle(10);
$request2 = new PlutonClientRequest();
$request2->setRequestData($expected);
$request2->setClientHandle(2);
$request3 = new PlutonClientRequest();
$request3->setRequestData($expected);
$request3->setClientHandle(3);
$client->addRequest('system.echo.0.raw', $request10);
$client->addRequest('system.echo.0.raw', $request2);
$client->addRequest('system.echo.0.raw', $request3);
$res = $client->executeAndWaitOne($request2);
print "executeAndWaitOne returned {$res}\n";
if ($res != 1) {
    print "E&WOne failed. Expected return of 1 rather than {$res}\n";
    exit(2);
}
print "executeAndWaitOne = {$res} = ok\n";
$res = $client->executeAndWaitAny();
if ($res != 10 && $res != 3) {
    print "E&WAny failed. Expected return of 10 or 3 rather than {$res}\n";
    exit(2);
}
print "executeAndWaitAny returned 3 or 10 - good\n";
print "executeAndWaitAny first = ok\n";