diff options
author | Jim King <jim.king@simplivity.com> | 2015-06-29 18:12:48 -0400 |
---|---|---|
committer | Roger Meier <roger@apache.org> | 2015-07-03 20:48:50 +0200 |
commit | 5903d6745989897fae58f8370c62a1dd5bfe7e66 (patch) | |
tree | e8ad4dc5e59ac3b3bfbf408082e706db02668885 /test/php | |
parent | 2fadc8d5cace1854cdd94483f7f231080bbd2d64 (diff) | |
download | thrift-5903d6745989897fae58f8370c62a1dd5bfe7e66.tar.gz |
THRIFT-3211: add php client compact protocol to make cross test
This closes #532
Diffstat (limited to 'test/php')
-rwxr-xr-x | test/php/TestClient.php | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/test/php/TestClient.php b/test/php/TestClient.php index 4ec4eab26..ce57dc08e 100755 --- a/test/php/TestClient.php +++ b/test/php/TestClient.php @@ -38,8 +38,10 @@ $loader->register(); */ /** Include the Thrift base */ -/** Include the binary protocol */ +/** Include the protocols */ use Thrift\Protocol\TBinaryProtocol; +use Thrift\Protocol\TCompactProtocol; +use Thrift\Protocol\TJSONProtocol; /** Include the socket layer */ use Thrift\Transport\TSocket; @@ -49,6 +51,19 @@ use Thrift\Transport\TSocketPool; use Thrift\Transport\TFramedTransport; use Thrift\Transport\TBufferedTransport; +function makeProtocol($transport, $PROTO) +{ + if ($PROTO == 'binary') { + return new TBinaryProtocol($transport); + } else if ($PROTO == 'compact') { + return new TCompactProtocol($transport); + } else if ($PROTO == 'json') { + return new TJSONProtocol($transport); + } + + die ("--protocol must be one of {binary|compact|json}"); +} + $host = 'localhost'; $port = 9090; @@ -63,9 +78,11 @@ if ($argc > 2) { foreach ($argv as $arg) { if (substr($arg, 0, 7) == '--port=') { $port = substr($arg, 7); - } else if (substr($arg, 0, 11) == '--transport=') { - $MODE = substr($arg, 11); - } + } else if (substr($arg, 0, 12) == '--transport=') { + $MODE = substr($arg, 12); + } else if (substr($arg, 0, 11) == '--protocol=') { + $PROTO = substr($arg, 11); + } } $hosts = array('localhost'); @@ -80,12 +97,12 @@ if ($MODE == 'inline') { } else if ($MODE == 'framed') { $framedSocket = new TFramedTransport($socket); $transport = $framedSocket; - $protocol = new TBinaryProtocol($transport); + $protocol = makeProtocol($transport, $PROTO); $testClient = new \ThriftTest\ThriftTestClient($protocol); } else { $bufferedSocket = new TBufferedTransport($socket, 1024, 1024); $transport = $bufferedSocket; - $protocol = new TBinaryProtocol($transport); + $protocol = makeProtocol($transport, $PROTO); $testClient = new \ThriftTest\ThriftTestClient($protocol); } |