Upgrading vendor folder dependencies.
This commit is contained in:
parent
4a0cbcd770
commit
acbe9ad9e5
229 changed files with 10735 additions and 4528 deletions
1
vendor/git.apache.org/thrift.git/lib/Makefile.am
generated
vendored
1
vendor/git.apache.org/thrift.git/lib/Makefile.am
generated
vendored
|
@ -87,6 +87,7 @@ endif
|
|||
if WITH_NODEJS
|
||||
SUBDIRS += nodejs
|
||||
PRECROSS_TARGET += precross-nodejs
|
||||
SUBDIRS += nodets
|
||||
endif
|
||||
|
||||
if WITH_LUA
|
||||
|
|
12
vendor/git.apache.org/thrift.git/lib/c_glib/src/thrift/c_glib/protocol/thrift_protocol.c
generated
vendored
12
vendor/git.apache.org/thrift.git/lib/c_glib/src/thrift/c_glib/protocol/thrift_protocol.c
generated
vendored
|
@ -465,7 +465,7 @@ thrift_protocol_skip (ThriftProtocol *protocol, ThriftType type, GError **error)
|
|||
}
|
||||
case T_STRUCT:
|
||||
{
|
||||
guint32 result = 0;
|
||||
gint32 result = 0;
|
||||
gchar *name;
|
||||
gint16 fid;
|
||||
ThriftType ftype;
|
||||
|
@ -475,6 +475,10 @@ thrift_protocol_skip (ThriftProtocol *protocol, ThriftType type, GError **error)
|
|||
{
|
||||
result += thrift_protocol_read_field_begin (protocol, &name, &ftype,
|
||||
&fid, error);
|
||||
if (result < 0)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
if (ftype == T_STOP)
|
||||
{
|
||||
break;
|
||||
|
@ -487,7 +491,7 @@ thrift_protocol_skip (ThriftProtocol *protocol, ThriftType type, GError **error)
|
|||
}
|
||||
case T_SET:
|
||||
{
|
||||
guint32 result = 0;
|
||||
gint32 result = 0;
|
||||
ThriftType elem_type;
|
||||
guint32 i, size;
|
||||
result += thrift_protocol_read_set_begin (protocol, &elem_type, &size,
|
||||
|
@ -501,7 +505,7 @@ thrift_protocol_skip (ThriftProtocol *protocol, ThriftType type, GError **error)
|
|||
}
|
||||
case T_MAP:
|
||||
{
|
||||
guint32 result = 0;
|
||||
gint32 result = 0;
|
||||
ThriftType elem_type;
|
||||
ThriftType key_type;
|
||||
guint32 i, size;
|
||||
|
@ -517,7 +521,7 @@ thrift_protocol_skip (ThriftProtocol *protocol, ThriftType type, GError **error)
|
|||
}
|
||||
case T_LIST:
|
||||
{
|
||||
guint32 result = 0;
|
||||
gint32 result = 0;
|
||||
ThriftType elem_type;
|
||||
guint32 i, size;
|
||||
result += thrift_protocol_read_list_begin (protocol, &elem_type, &size,
|
||||
|
|
2
vendor/git.apache.org/thrift.git/lib/cocoa/src/Thrift.h
generated
vendored
2
vendor/git.apache.org/thrift.git/lib/cocoa/src/Thrift.h
generated
vendored
|
@ -17,4 +17,4 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
#define ThriftVersion @"1.0.0-dev"
|
||||
#define ThriftVersion @"0.12.0"
|
||||
|
|
9
vendor/git.apache.org/thrift.git/lib/cpp/libthrift.vcxproj
generated
vendored
9
vendor/git.apache.org/thrift.git/lib/cpp/libthrift.vcxproj
generated
vendored
|
@ -53,12 +53,9 @@
|
|||
<ClCompile Include="src\thrift\server\TSimpleServer.cpp"/>
|
||||
<ClCompile Include="src\thrift\server\TThreadPoolServer.cpp"/>
|
||||
<ClCompile Include="src\thrift\server\TThreadedServer.cpp"/>
|
||||
<ClCompile Include="src\thrift\server\TConnectedClient.cpp"/>
|
||||
<ClCompile Include="src\thrift\server\TNonblockingServer.cpp"/>
|
||||
<ClCompile Include="src\thrift\server\TServerFramework.cpp"/>
|
||||
<ClCompile Include="src\thrift\server\TSimpleServer.cpp"/>
|
||||
<ClCompile Include="src\thrift\server\TThreadedServer.cpp"/>
|
||||
<ClCompile Include="src\thrift\server\TThreadPoolServer.cpp"/>
|
||||
<ClCompile Include="src\thrift\server\TConnectedClient.cpp"/>
|
||||
<ClCompile Include="src\thrift\server\TNonblockingServer.cpp"/>
|
||||
<ClCompile Include="src\thrift\server\TServerFramework.cpp"/>
|
||||
<ClCompile Include="src\thrift\TApplicationException.cpp"/>
|
||||
<ClCompile Include="src\thrift\TOutput.cpp"/>
|
||||
<ClCompile Include="src\thrift\transport\TBufferTransports.cpp"/>
|
||||
|
|
4
vendor/git.apache.org/thrift.git/lib/cpp/src/thrift/protocol/TJSONProtocol.cpp
generated
vendored
4
vendor/git.apache.org/thrift.git/lib/cpp/src/thrift/protocol/TJSONProtocol.cpp
generated
vendored
|
@ -899,7 +899,7 @@ uint32_t TJSONProtocol::readJSONDouble(double& num) {
|
|||
}
|
||||
try {
|
||||
num = fromString<double>(str);
|
||||
} catch (std::runtime_error e) {
|
||||
} catch (std::runtime_error& e) {
|
||||
throw TProtocolException(TProtocolException::INVALID_DATA,
|
||||
"Expected numeric value; got \"" + str + "\"");
|
||||
}
|
||||
|
@ -912,7 +912,7 @@ uint32_t TJSONProtocol::readJSONDouble(double& num) {
|
|||
result += readJSONNumericChars(str);
|
||||
try {
|
||||
num = fromString<double>(str);
|
||||
} catch (std::runtime_error e) {
|
||||
} catch (std::runtime_error& e) {
|
||||
throw TProtocolException(TProtocolException::INVALID_DATA,
|
||||
"Expected numeric value; got \"" + str + "\"");
|
||||
}
|
||||
|
|
2
vendor/git.apache.org/thrift.git/lib/cpp/src/thrift/qt/TQIODeviceTransport.cpp
generated
vendored
2
vendor/git.apache.org/thrift.git/lib/cpp/src/thrift/qt/TQIODeviceTransport.cpp
generated
vendored
|
@ -91,7 +91,7 @@ uint32_t TQIODeviceTransport::read(uint8_t* buf, uint32_t len) {
|
|||
"read(): underlying QIODevice is not open");
|
||||
}
|
||||
|
||||
actualSize = (uint32_t)std::min((qint64)len, dev_->bytesAvailable());
|
||||
actualSize = (uint32_t)(std::min)((qint64)len, dev_->bytesAvailable());
|
||||
readSize = dev_->read(reinterpret_cast<char*>(buf), actualSize);
|
||||
|
||||
if (readSize < 0) {
|
||||
|
|
2
vendor/git.apache.org/thrift.git/lib/cpp/src/thrift/transport/TBufferTransports.h
generated
vendored
2
vendor/git.apache.org/thrift.git/lib/cpp/src/thrift/transport/TBufferTransports.h
generated
vendored
|
@ -449,7 +449,7 @@ private:
|
|||
// Common initialization done by all constructors.
|
||||
void initCommon(uint8_t* buf, uint32_t size, bool owner, uint32_t wPos) {
|
||||
|
||||
maxBufferSize_ = std::numeric_limits<uint32_t>::max();
|
||||
maxBufferSize_ = (std::numeric_limits<uint32_t>::max)();
|
||||
|
||||
if (buf == NULL && size != 0) {
|
||||
assert(owner);
|
||||
|
|
5
vendor/git.apache.org/thrift.git/lib/cpp/src/thrift/transport/TFileTransport.cpp
generated
vendored
5
vendor/git.apache.org/thrift.git/lib/cpp/src/thrift/transport/TFileTransport.cpp
generated
vendored
|
@ -65,7 +65,6 @@ using stdcxx::shared_ptr;
|
|||
using std::cerr;
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
using std::min;
|
||||
using std::string;
|
||||
using namespace apache::thrift::protocol;
|
||||
using namespace apache::thrift::concurrency;
|
||||
|
@ -705,8 +704,8 @@ eventInfo* TFileTransport::readEvent() {
|
|||
readState_.event_->eventBuffPos_ = 0;
|
||||
}
|
||||
// take either the entire event or the remaining bytes in the buffer
|
||||
int reclaimBuffer = min((uint32_t)(readState_.bufferLen_ - readState_.bufferPtr_),
|
||||
readState_.event_->eventSize_ - readState_.event_->eventBuffPos_);
|
||||
int reclaimBuffer = (std::min)((uint32_t)(readState_.bufferLen_ - readState_.bufferPtr_),
|
||||
readState_.event_->eventSize_ - readState_.event_->eventBuffPos_);
|
||||
|
||||
// copy data from read buffer into event buffer
|
||||
memcpy(readState_.event_->eventBuff_ + readState_.event_->eventBuffPos_,
|
||||
|
|
2
vendor/git.apache.org/thrift.git/lib/cpp/src/thrift/transport/THeaderTransport.cpp
generated
vendored
2
vendor/git.apache.org/thrift.git/lib/cpp/src/thrift/transport/THeaderTransport.cpp
generated
vendored
|
@ -511,7 +511,7 @@ void THeaderTransport::flush() {
|
|||
|
||||
// Pkt size
|
||||
ptrdiff_t szHbp = (headerStart - pktStart - 4);
|
||||
if (static_cast<uint64_t>(szHbp) > static_cast<uint64_t>(std::numeric_limits<uint32_t>().max()) - (headerSize + haveBytes)) {
|
||||
if (static_cast<uint64_t>(szHbp) > static_cast<uint64_t>((std::numeric_limits<uint32_t>().max)()) - (headerSize + haveBytes)) {
|
||||
throw TTransportException(TTransportException::CORRUPTED_DATA,
|
||||
"Header section size is unreasonable");
|
||||
}
|
||||
|
|
11
vendor/git.apache.org/thrift.git/lib/cpp/src/thrift/transport/TSocketPool.cpp
generated
vendored
11
vendor/git.apache.org/thrift.git/lib/cpp/src/thrift/transport/TSocketPool.cpp
generated
vendored
|
@ -21,6 +21,9 @@
|
|||
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#if __cplusplus >= 201703L
|
||||
#include <random>
|
||||
#endif
|
||||
|
||||
#include <thrift/transport/TSocketPool.h>
|
||||
|
||||
|
@ -188,7 +191,13 @@ void TSocketPool::open() {
|
|||
}
|
||||
|
||||
if (randomize_ && numServers > 1) {
|
||||
random_shuffle(servers_.begin(), servers_.end());
|
||||
#if __cplusplus >= 201703L
|
||||
std::random_device rng;
|
||||
std::mt19937 urng(rng());
|
||||
std::shuffle(servers_.begin(), servers_.end(), urng);
|
||||
#else
|
||||
std::random_shuffle(servers_.begin(), servers_.end());
|
||||
#endif
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < numServers; ++i) {
|
||||
|
|
2
vendor/git.apache.org/thrift.git/lib/cpp/test/TMemoryBufferTest.cpp
generated
vendored
2
vendor/git.apache.org/thrift.git/lib/cpp/test/TMemoryBufferTest.cpp
generated
vendored
|
@ -111,7 +111,7 @@ BOOST_AUTO_TEST_CASE(test_exceptions) {
|
|||
|
||||
BOOST_AUTO_TEST_CASE(test_default_maximum_buffer_size)
|
||||
{
|
||||
BOOST_CHECK_EQUAL(std::numeric_limits<uint32_t>::max(), TMemoryBuffer().getMaxBufferSize());
|
||||
BOOST_CHECK_EQUAL((std::numeric_limits<uint32_t>::max)(), TMemoryBuffer().getMaxBufferSize());
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_default_buffer_size)
|
||||
|
|
|
@ -56,5 +56,5 @@ using System.Runtime.InteropServices;
|
|||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("0.11.0.*")]
|
||||
[assembly: AssemblyFileVersion("0.11.0.*")]
|
||||
[assembly: AssemblyVersion("0.12.0.*")]
|
||||
[assembly: AssemblyFileVersion("0.12.0.*")]
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
<UpdateRequired>false</UpdateRequired>
|
||||
<MapFileExtensions>true</MapFileExtensions>
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||
<ApplicationVersion>0.12.0.%2a</ApplicationVersion>
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
|
@ -115,4 +115,4 @@
|
|||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
</Project>
|
||||
|
|
4
vendor/git.apache.org/thrift.git/lib/csharp/src/Properties/AssemblyInfo.cs
generated
vendored
4
vendor/git.apache.org/thrift.git/lib/csharp/src/Properties/AssemblyInfo.cs
generated
vendored
|
@ -51,5 +51,5 @@ using System.Runtime.InteropServices;
|
|||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("1.0.0.1")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.1")]
|
||||
[assembly: AssemblyVersion("0.12.0.1")]
|
||||
[assembly: AssemblyFileVersion("0.12.0.1")]
|
||||
|
|
4
vendor/git.apache.org/thrift.git/lib/csharp/src/Thrift.csproj
generated
vendored
4
vendor/git.apache.org/thrift.git/lib/csharp/src/Thrift.csproj
generated
vendored
|
@ -45,7 +45,7 @@
|
|||
<UpdateRequired>false</UpdateRequired>
|
||||
<MapFileExtensions>true</MapFileExtensions>
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||
<ApplicationVersion>0.12.0.%2a</ApplicationVersion>
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
|
@ -153,4 +153,4 @@
|
|||
<ProjectExtensions>
|
||||
<VisualStudio AllowExistingFolder="true" />
|
||||
</ProjectExtensions>
|
||||
</Project>
|
||||
</Project>
|
||||
|
|
27
vendor/git.apache.org/thrift.git/lib/csharp/src/Transport/TBufferedTransport.cs
generated
vendored
27
vendor/git.apache.org/thrift.git/lib/csharp/src/Transport/TBufferedTransport.cs
generated
vendored
|
@ -81,7 +81,7 @@ namespace Thrift.Transport
|
|||
inputBuffer.Capacity = bufSize;
|
||||
|
||||
while (true)
|
||||
{
|
||||
{
|
||||
int got = inputBuffer.Read(buf, off, len);
|
||||
if (got > 0)
|
||||
return got;
|
||||
|
@ -129,9 +129,8 @@ namespace Thrift.Transport
|
|||
}
|
||||
}
|
||||
|
||||
public override void Flush()
|
||||
private void InternalFlush()
|
||||
{
|
||||
CheckNotDisposed();
|
||||
if (!IsOpen)
|
||||
throw new TTransportException(TTransportException.ExceptionType.NotOpen);
|
||||
if (outputBuffer.Length > 0)
|
||||
|
@ -139,9 +138,31 @@ namespace Thrift.Transport
|
|||
transport.Write(outputBuffer.GetBuffer(), 0, (int)outputBuffer.Length);
|
||||
outputBuffer.SetLength(0);
|
||||
}
|
||||
}
|
||||
|
||||
public override void Flush()
|
||||
{
|
||||
CheckNotDisposed();
|
||||
InternalFlush();
|
||||
|
||||
transport.Flush();
|
||||
}
|
||||
|
||||
public override IAsyncResult BeginFlush(AsyncCallback callback, object state)
|
||||
{
|
||||
CheckNotDisposed();
|
||||
InternalFlush();
|
||||
|
||||
return transport.BeginFlush( callback, state);
|
||||
}
|
||||
|
||||
public override void EndFlush(IAsyncResult asyncResult)
|
||||
{
|
||||
transport.EndFlush( asyncResult);
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected void CheckNotDisposed()
|
||||
{
|
||||
if (_IsDisposed)
|
||||
|
|
21
vendor/git.apache.org/thrift.git/lib/csharp/src/Transport/TFramedTransport.cs
generated
vendored
21
vendor/git.apache.org/thrift.git/lib/csharp/src/Transport/TFramedTransport.cs
generated
vendored
|
@ -108,7 +108,7 @@ namespace Thrift.Transport
|
|||
writeBuffer.Write(buf, off, len);
|
||||
}
|
||||
|
||||
public override void Flush()
|
||||
private void InternalFlush()
|
||||
{
|
||||
CheckNotDisposed();
|
||||
if (!IsOpen)
|
||||
|
@ -126,10 +126,29 @@ namespace Thrift.Transport
|
|||
transport.Write(buf, 0, len);
|
||||
|
||||
InitWriteBuffer();
|
||||
}
|
||||
|
||||
public override void Flush()
|
||||
{
|
||||
CheckNotDisposed();
|
||||
InternalFlush();
|
||||
|
||||
transport.Flush();
|
||||
}
|
||||
|
||||
public override IAsyncResult BeginFlush(AsyncCallback callback, object state)
|
||||
{
|
||||
CheckNotDisposed();
|
||||
InternalFlush();
|
||||
|
||||
return transport.BeginFlush( callback, state);
|
||||
}
|
||||
|
||||
public override void EndFlush(IAsyncResult asyncResult)
|
||||
{
|
||||
transport.EndFlush( asyncResult);
|
||||
}
|
||||
|
||||
private void InitWriteBuffer()
|
||||
{
|
||||
// Reserve space for message header to be put right before sending it out
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
<UpdateRequired>false</UpdateRequired>
|
||||
<MapFileExtensions>true</MapFileExtensions>
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||
<ApplicationVersion>0.12.0.%2a</ApplicationVersion>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
</PropertyGroup>
|
||||
|
@ -145,4 +145,4 @@ for %25%25I in ("%25THRIFT_FILE%25") do set THRIFT_SHORT=%25%25~fsI
|
|||
|
||||
</PreBuildEvent>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
|
|
@ -51,5 +51,5 @@ using System.Runtime.InteropServices;
|
|||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
[assembly: AssemblyVersion("0.12.0.0")]
|
||||
[assembly: AssemblyFileVersion("0.12.0.0")]
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
<UpdateRequired>false</UpdateRequired>
|
||||
<MapFileExtensions>true</MapFileExtensions>
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||
<ApplicationVersion>0.12.0.%2a</ApplicationVersion>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
</PropertyGroup>
|
||||
|
@ -145,4 +145,4 @@ for %25%25I in ("%25THRIFT_FILE%25") do set THRIFT_SHORT=%25%25~fsI
|
|||
|
||||
</PreBuildEvent>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
|
|
@ -51,5 +51,5 @@ using System.Runtime.InteropServices;
|
|||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
[assembly: AssemblyVersion("0.12.0.0")]
|
||||
[assembly: AssemblyFileVersion("0.12.0.0")]
|
||||
|
|
|
@ -49,5 +49,5 @@ using System.Runtime.InteropServices;
|
|||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("1.0.0.1")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.1")]
|
||||
[assembly: AssemblyVersion("0.12.0.0")]
|
||||
[assembly: AssemblyFileVersion("0.12.0.0")]
|
||||
|
|
2
vendor/git.apache.org/thrift.git/lib/d/src/thrift/base.d
generated
vendored
2
vendor/git.apache.org/thrift.git/lib/d/src/thrift/base.d
generated
vendored
|
@ -50,7 +50,7 @@ class TCompoundOperationException : TException {
|
|||
/// The Thrift version string, used for informative purposes.
|
||||
// Note: This is currently hardcoded, but will likely be filled in by the build
|
||||
// system in future versions.
|
||||
enum VERSION = "1.0.0 dev";
|
||||
enum VERSION = "0.12.0";
|
||||
|
||||
/**
|
||||
* Functions used for logging inside Thrift.
|
||||
|
|
42
vendor/git.apache.org/thrift.git/lib/d/test/client_pool_test.d
generated
vendored
42
vendor/git.apache.org/thrift.git/lib/d/test/client_pool_test.d
generated
vendored
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
module client_pool_test;
|
||||
|
||||
import core.sync.semaphore : Semaphore;
|
||||
import core.time : Duration, dur;
|
||||
import core.thread : Thread;
|
||||
import std.algorithm;
|
||||
|
@ -28,6 +29,7 @@ import std.getopt;
|
|||
import std.range;
|
||||
import std.stdio;
|
||||
import std.typecons;
|
||||
import std.variant : Variant;
|
||||
import thrift.base;
|
||||
import thrift.async.libevent;
|
||||
import thrift.async.socket;
|
||||
|
@ -37,9 +39,12 @@ import thrift.codegen.async_client_pool;
|
|||
import thrift.codegen.client;
|
||||
import thrift.codegen.client_pool;
|
||||
import thrift.codegen.processor;
|
||||
import thrift.protocol.base;
|
||||
import thrift.protocol.binary;
|
||||
import thrift.server.base;
|
||||
import thrift.server.simple;
|
||||
import thrift.server.transport.socket;
|
||||
import thrift.transport.base;
|
||||
import thrift.transport.buffered;
|
||||
import thrift.transport.socket;
|
||||
import thrift.util.cancellation;
|
||||
|
@ -108,11 +113,29 @@ private:
|
|||
}
|
||||
}
|
||||
|
||||
class ServerPreServeHandler : TServerEventHandler {
|
||||
this(Semaphore sem) {
|
||||
sem_ = sem;
|
||||
}
|
||||
|
||||
override void preServe() {
|
||||
sem_.notify();
|
||||
}
|
||||
|
||||
Variant createContext(TProtocol input, TProtocol output) { return Variant.init; }
|
||||
void deleteContext(Variant serverContext, TProtocol input, TProtocol output) {}
|
||||
void preProcess(Variant serverContext, TTransport transport) {}
|
||||
|
||||
private:
|
||||
Semaphore sem_;
|
||||
}
|
||||
|
||||
class ServerThread : Thread {
|
||||
this(ExTestHandler handler, TCancellation cancellation) {
|
||||
this(ExTestHandler handler, ServerPreServeHandler serverHandler, TCancellation cancellation) {
|
||||
super(&run);
|
||||
handler_ = handler;
|
||||
cancellation_ = cancellation;
|
||||
serverHandler_ = serverHandler;
|
||||
}
|
||||
private:
|
||||
void run() {
|
||||
|
@ -123,16 +146,17 @@ private:
|
|||
serverTransport.recvTimeout = dur!"seconds"(3);
|
||||
auto transportFactory = new TBufferedTransportFactory;
|
||||
|
||||
auto server = new TSimpleServer(
|
||||
processor, serverTransport, transportFactory, protocolFactory);
|
||||
auto server = new TSimpleServer(processor, serverTransport, transportFactory, protocolFactory);
|
||||
server.eventHandler = serverHandler_;
|
||||
server.serve(cancellation_);
|
||||
} catch (Exception e) {
|
||||
writefln("Server thread on port %s failed: %s", handler_.port, e);
|
||||
}
|
||||
}
|
||||
|
||||
TCancellation cancellation_;
|
||||
ExTestHandler handler_;
|
||||
ServerPreServeHandler serverHandler_;
|
||||
TCancellation cancellation_;
|
||||
}
|
||||
|
||||
void main(string[] args) {
|
||||
|
@ -145,6 +169,9 @@ void main(string[] args) {
|
|||
|
||||
immutable ports = cast(immutable)array(map!"cast(ushort)a"(iota(port, port + 6)));
|
||||
|
||||
// semaphore that will be incremented whenever each server thread has bound and started listening
|
||||
Semaphore sem = new Semaphore(0);
|
||||
|
||||
version (none) {
|
||||
// Cannot use this due to multiple DMD @@BUG@@s:
|
||||
// 1. »function D main is a nested function and cannot be accessed from array«
|
||||
|
@ -174,11 +201,10 @@ version (none) {
|
|||
}
|
||||
|
||||
// Fire up the server threads.
|
||||
foreach (h; handlers) (new ServerThread(h, serverCancellation)).start();
|
||||
foreach (h; handlers) (new ServerThread(h, new ServerPreServeHandler(sem), serverCancellation)).start();
|
||||
|
||||
// Give the servers some time to get up. This should really be accomplished
|
||||
// via a barrier here and in the preServe() hook.
|
||||
Thread.sleep(dur!"msecs"(10));
|
||||
// wait until all the handlers signal that they're ready to serve
|
||||
foreach (h; handlers) (sem.wait(dur!`seconds`(1)));
|
||||
|
||||
syncClientPoolTest(ports, handlers);
|
||||
asyncClientPoolTest(ports, handlers);
|
||||
|
|
2
vendor/git.apache.org/thrift.git/lib/dart/pubspec.yaml
generated
vendored
2
vendor/git.apache.org/thrift.git/lib/dart/pubspec.yaml
generated
vendored
|
@ -16,7 +16,7 @@
|
|||
# under the License.
|
||||
|
||||
name: thrift
|
||||
version: 1.0.0-dev
|
||||
version: 0.12.0
|
||||
description: >
|
||||
A Dart library for Apache Thrift
|
||||
author: Apache Thrift Developers <dev@thrift.apache.org>
|
||||
|
|
2
vendor/git.apache.org/thrift.git/lib/delphi/src/Thrift.pas
generated
vendored
2
vendor/git.apache.org/thrift.git/lib/delphi/src/Thrift.pas
generated
vendored
|
@ -27,7 +27,7 @@ uses
|
|||
Thrift.Protocol;
|
||||
|
||||
const
|
||||
Version = '1.0.0-dev';
|
||||
Version = '0.12.0';
|
||||
|
||||
type
|
||||
TException = Thrift.Exception.TException; // compatibility alias
|
||||
|
|
2
vendor/git.apache.org/thrift.git/lib/go/README.md
generated
vendored
2
vendor/git.apache.org/thrift.git/lib/go/README.md
generated
vendored
|
@ -29,7 +29,7 @@ Thrift supports Go 1.7+
|
|||
In following Go conventions, we recommend you use the 'go' tool to install
|
||||
Thrift for go.
|
||||
|
||||
$ go get git.apache.org/thrift.git/lib/go/thrift/...
|
||||
$ go get github.com/apache/thrift/lib/go/thrift/...
|
||||
|
||||
Will retrieve and install the most recent version of the package.
|
||||
|
||||
|
|
2
vendor/git.apache.org/thrift.git/lib/go/thrift/serializer_types_test.go
generated
vendored
2
vendor/git.apache.org/thrift.git/lib/go/thrift/serializer_types_test.go
generated
vendored
|
@ -19,7 +19,7 @@
|
|||
|
||||
package thrift
|
||||
|
||||
// Autogenerated by Thrift Compiler (1.0.0-dev)
|
||||
// Autogenerated by Thrift Compiler (0.12.0)
|
||||
// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
|
||||
|
||||
/* THE FOLLOWING THRIFT FILE WAS USED TO CREATE THIS
|
||||
|
|
15
vendor/git.apache.org/thrift.git/lib/go/thrift/server_socket.go
generated
vendored
15
vendor/git.apache.org/thrift.git/lib/go/thrift/server_socket.go
generated
vendored
|
@ -75,7 +75,9 @@ func (p *TServerSocket) Accept() (TTransport, error) {
|
|||
return nil, errTransportInterrupted
|
||||
}
|
||||
|
||||
p.mu.Lock()
|
||||
listener := p.listener
|
||||
p.mu.Unlock()
|
||||
if listener == nil {
|
||||
return nil, NewTTransportException(NOT_OPEN, "No underlying server socket")
|
||||
}
|
||||
|
@ -115,19 +117,20 @@ func (p *TServerSocket) Addr() net.Addr {
|
|||
}
|
||||
|
||||
func (p *TServerSocket) Close() error {
|
||||
defer func() {
|
||||
p.listener = nil
|
||||
}()
|
||||
var err error
|
||||
p.mu.Lock()
|
||||
if p.IsListening() {
|
||||
return p.listener.Close()
|
||||
err = p.listener.Close()
|
||||
p.listener = nil
|
||||
}
|
||||
return nil
|
||||
p.mu.Unlock()
|
||||
return err
|
||||
}
|
||||
|
||||
func (p *TServerSocket) Interrupt() error {
|
||||
p.mu.Lock()
|
||||
defer p.mu.Unlock()
|
||||
p.interrupted = true
|
||||
p.mu.Unlock()
|
||||
p.Close()
|
||||
|
||||
return nil
|
||||
|
|
4
vendor/git.apache.org/thrift.git/lib/haxe/README.md
generated
vendored
4
vendor/git.apache.org/thrift.git/lib/haxe/README.md
generated
vendored
|
@ -71,8 +71,8 @@ either from the official ASF repo, or via the github mirror.
|
|||
|
||||
- To set up any **stable version**, choose the appropriate branch (e.g. `0.10.0`):
|
||||
|
||||
- `haxelib git thrift https://git.apache.org/thrift.git 0.10.0 lib/haxe`
|
||||
- `haxelib git thrift https://github.com/apache/thrift.git 0.10.0 lib/haxe`
|
||||
- `haxelib git thrift https://git.apache.org/thrift.git 0.12.0 lib/haxe`
|
||||
- `haxelib git thrift https://github.com/apache/thrift.git 0.12.0 lib/haxe`
|
||||
|
||||
- To set up the current **development version**, use the `master` branch:
|
||||
|
||||
|
|
2
vendor/git.apache.org/thrift.git/lib/haxe/haxelib.json
generated
vendored
2
vendor/git.apache.org/thrift.git/lib/haxe/haxelib.json
generated
vendored
|
@ -4,7 +4,7 @@
|
|||
"license": "Apache",
|
||||
"tags": ["thrift", "rpc", "serialization", "cross", "framework"],
|
||||
"description": "Haxe bindings for the Apache Thrift RPC and serialization framework",
|
||||
"version": "1.0.0-dev",
|
||||
"version": "0.12.0",
|
||||
"releasenote": "Licensed under Apache License, Version 2.0. The Apache Thrift compiler needs to be installed separately.",
|
||||
"contributors": ["Apache Software Foundation (ASF)"],
|
||||
"dependencies": { },
|
||||
|
|
8
vendor/git.apache.org/thrift.git/lib/hs/Thrift.cabal
generated
vendored
8
vendor/git.apache.org/thrift.git/lib/hs/Thrift.cabal
generated
vendored
|
@ -18,8 +18,8 @@
|
|||
--
|
||||
|
||||
Name: thrift
|
||||
Version: 1.0.0-dev
|
||||
Cabal-Version: >= 1.24
|
||||
Version: 0.12.0
|
||||
Cabal-Version: 1.24
|
||||
License: OtherLicense
|
||||
Category: Foreign
|
||||
Build-Type: Simple
|
||||
|
@ -63,8 +63,7 @@ Library
|
|||
Thrift.Transport.IOBuffer,
|
||||
Thrift.Transport.Memory,
|
||||
Thrift.Types
|
||||
Default-Language:
|
||||
Haskell2010
|
||||
Default-Language: Haskell2010
|
||||
Default-Extensions:
|
||||
DeriveDataTypeable,
|
||||
ExistentialQuantification,
|
||||
|
@ -82,3 +81,4 @@ Test-Suite spec
|
|||
Ghc-Options: -Wall
|
||||
main-is: Spec.hs
|
||||
Build-Depends: base, thrift, hspec, QuickCheck >= 2.8.2, bytestring >= 0.10, unordered-containers >= 0.2.6
|
||||
Default-Language: Haskell2010
|
||||
|
|
4
vendor/git.apache.org/thrift.git/lib/java/gradle.properties
generated
vendored
4
vendor/git.apache.org/thrift.git/lib/java/gradle.properties
generated
vendored
|
@ -1,9 +1,9 @@
|
|||
# This file is shared currently between this Gradle build and the
|
||||
# Ant builds for fd303 and JavaScript. Keep the dotted notation for
|
||||
# the properties to minimize the changes in the dependencies.
|
||||
thrift.version=1.0.0
|
||||
thrift.version=0.12.0
|
||||
thrift.groupid=org.apache.thrift
|
||||
release=false
|
||||
release=true
|
||||
|
||||
# Local Install paths
|
||||
install.path=/usr/local/lib
|
||||
|
|
42
vendor/git.apache.org/thrift.git/lib/js/Gruntfile.js
generated
vendored
42
vendor/git.apache.org/thrift.git/lib/js/Gruntfile.js
generated
vendored
|
@ -221,31 +221,37 @@ module.exports = function(grunt) {
|
|||
// The main thrift library file. not es6 yet :(
|
||||
lib: {
|
||||
src: ['src/**/*.js'],
|
||||
options: {
|
||||
// options here to override JSHint defaults
|
||||
globals: {
|
||||
jQuery: true,
|
||||
console: true,
|
||||
module: true,
|
||||
document: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
// The test files use es6
|
||||
test: {
|
||||
src: ['Gruntfile.js', 'test/*.js'],
|
||||
options: {
|
||||
// options here to override JSHint defaults
|
||||
globals: {
|
||||
jQuery: true,
|
||||
console: true,
|
||||
module: true,
|
||||
document: true,
|
||||
},
|
||||
esversion: 6,
|
||||
}
|
||||
},
|
||||
}
|
||||
gen_js_code: {
|
||||
src: ['test/gen-js/*.js', 'test/gen-js-jquery/*.js'],
|
||||
},
|
||||
gen_es6_code: {
|
||||
src: ['test/gen-js-es6/*.js'],
|
||||
options: {
|
||||
esversion: 6,
|
||||
}
|
||||
},
|
||||
gen_node_code: {
|
||||
src: ['test/gen-nodejs/*.js'],
|
||||
options: {
|
||||
node: true,
|
||||
}
|
||||
},
|
||||
gen_node_es6_code: {
|
||||
src: ['test/gen-nodejs-es6/*.js'],
|
||||
options: {
|
||||
node: true,
|
||||
esversion: 6,
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
grunt.loadNpmTasks('grunt-contrib-uglify');
|
||||
|
@ -269,8 +275,8 @@ module.exports = function(grunt) {
|
|||
]);
|
||||
|
||||
grunt.registerTask('test', [
|
||||
'jshint',
|
||||
'installAndGenerate',
|
||||
'jshint',
|
||||
'shell:ThriftTestServer', 'shell:ThriftTestServer_TLS',
|
||||
'shell:ThriftTestServerES6', 'shell:ThriftTestServerES6_TLS',
|
||||
'wait',
|
||||
|
|
3094
vendor/git.apache.org/thrift.git/lib/js/package-lock.json
generated
vendored
3094
vendor/git.apache.org/thrift.git/lib/js/package-lock.json
generated
vendored
File diff suppressed because it is too large
Load diff
2
vendor/git.apache.org/thrift.git/lib/js/package.json
generated
vendored
2
vendor/git.apache.org/thrift.git/lib/js/package.json
generated
vendored
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "thrift",
|
||||
"version": "1.0.0",
|
||||
"version": "0.12.0",
|
||||
"devDependencies": {
|
||||
"grunt": "^1.0.2",
|
||||
"grunt-cli": "^1.2.0",
|
||||
|
|
2
vendor/git.apache.org/thrift.git/lib/js/src/thrift.js
generated
vendored
2
vendor/git.apache.org/thrift.git/lib/js/src/thrift.js
generated
vendored
|
@ -46,7 +46,7 @@ var Thrift = {
|
|||
* @const {string} Version
|
||||
* @memberof Thrift
|
||||
*/
|
||||
Version: '1.0.0-dev',
|
||||
Version: '0.12.0',
|
||||
|
||||
/**
|
||||
* Thrift IDL type string to Id mapping.
|
||||
|
|
2
vendor/git.apache.org/thrift.git/lib/lua/THttpTransport.lua
generated
vendored
2
vendor/git.apache.org/thrift.git/lib/lua/THttpTransport.lua
generated
vendored
|
@ -25,7 +25,7 @@ THttpTransport = TTransportBase:new{
|
|||
wBuf = '',
|
||||
rBuf = '',
|
||||
CRLF = '\r\n',
|
||||
VERSION = '1.0.0',
|
||||
VERSION = '0.12.0',
|
||||
isServer = true
|
||||
}
|
||||
|
||||
|
|
2
vendor/git.apache.org/thrift.git/lib/lua/Thrift.lua
generated
vendored
2
vendor/git.apache.org/thrift.git/lib/lua/Thrift.lua
generated
vendored
|
@ -48,7 +48,7 @@ function ttable_size(t)
|
|||
return count
|
||||
end
|
||||
|
||||
version = 1.0
|
||||
version = '0.12.0'
|
||||
|
||||
TType = {
|
||||
STOP = 0,
|
||||
|
|
4
vendor/git.apache.org/thrift.git/lib/netcore/Thrift/Properties/AssemblyInfo.cs
generated
vendored
4
vendor/git.apache.org/thrift.git/lib/netcore/Thrift/Properties/AssemblyInfo.cs
generated
vendored
|
@ -52,5 +52,5 @@ using System.Runtime.InteropServices;
|
|||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
|
||||
[assembly: AssemblyVersion("1.0.0.1")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.1")]
|
||||
[assembly: AssemblyVersion("0.12.0.0")]
|
||||
[assembly: AssemblyFileVersion("0.12.0.0")]
|
||||
|
|
|
@ -149,7 +149,7 @@ namespace Thrift.Transports.Client
|
|||
}
|
||||
|
||||
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/x-thrift"));
|
||||
httpClient.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue("THttpClientTransport", "1.0.0"));
|
||||
httpClient.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue("THttpClientTransport", "0.12.0"));
|
||||
|
||||
if (CustomHeaders != null)
|
||||
{
|
||||
|
@ -223,4 +223,4 @@ namespace Thrift.Transports.Client
|
|||
_isDisposed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
3
vendor/git.apache.org/thrift.git/lib/nodejs/Makefile.am
generated
vendored
3
vendor/git.apache.org/thrift.git/lib/nodejs/Makefile.am
generated
vendored
|
@ -27,8 +27,9 @@ all-local: deps
|
|||
|
||||
precross: deps stubs
|
||||
|
||||
# TODO: Lint nodejs lib and gen-code as part of build
|
||||
check: deps
|
||||
cd $(top_srcdir) && $(NPM) test && cd lib/nodejs
|
||||
cd $(top_srcdir) && $(NPM) test && $(NPM) run lint-tests && cd lib/nodejs
|
||||
|
||||
clean-local:
|
||||
$(RM) -r test/gen-nodejs
|
||||
|
|
1
vendor/git.apache.org/thrift.git/lib/nodejs/lib/thrift/json_protocol.js
generated
vendored
1
vendor/git.apache.org/thrift.git/lib/nodejs/lib/thrift/json_protocol.js
generated
vendored
|
@ -18,7 +18,6 @@
|
|||
*/
|
||||
|
||||
var Int64 = require('node-int64');
|
||||
var InputBufferUnderrunError = require('./transport').InputBufferUnderrunError;
|
||||
var Thrift = require('./thrift');
|
||||
var Type = Thrift.Type;
|
||||
var util = require("util");
|
||||
|
|
143
vendor/git.apache.org/thrift.git/lib/nodejs/test/binary.test.js
generated
vendored
143
vendor/git.apache.org/thrift.git/lib/nodejs/test/binary.test.js
generated
vendored
|
@ -17,19 +17,19 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
var test = require('tape');
|
||||
var binary = require('thrift/binary');
|
||||
const test = require("tape");
|
||||
const binary = require("thrift/binary");
|
||||
|
||||
var cases = {
|
||||
"Should read signed byte": function(assert){
|
||||
const cases = {
|
||||
"Should read signed byte": function(assert) {
|
||||
assert.equal(1, binary.readByte(0x01));
|
||||
assert.equal(-1, binary.readByte(0xFF));
|
||||
assert.equal(-1, binary.readByte(0xff));
|
||||
|
||||
assert.equal(127, binary.readByte(0x7F));
|
||||
assert.equal(127, binary.readByte(0x7f));
|
||||
assert.equal(-128, binary.readByte(0x80));
|
||||
assert.end();
|
||||
},
|
||||
"Should write byte": function(assert){
|
||||
"Should write byte": function(assert) {
|
||||
//Protocol simply writes to the buffer. Nothing to test.. yet.
|
||||
assert.ok(true);
|
||||
assert.end();
|
||||
|
@ -76,58 +76,135 @@ var cases = {
|
|||
assert.deepEqual([0xff, 0xff, 0xff, 0xff], binary.writeI32([], -1));
|
||||
|
||||
// Min I32
|
||||
assert.deepEqual([0x80, 0x00, 0x00, 0x00], binary.writeI32([], -2147483648));
|
||||
assert.deepEqual(
|
||||
[0x80, 0x00, 0x00, 0x00],
|
||||
binary.writeI32([], -2147483648)
|
||||
);
|
||||
// Max I32
|
||||
assert.deepEqual([0x7f, 0xff, 0xff, 0xff], binary.writeI32([], 2147483647));
|
||||
assert.end();
|
||||
},
|
||||
|
||||
"Should read doubles": function(assert) {
|
||||
assert.equal(0, binary.readDouble([0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]))
|
||||
assert.equal(0, binary.readDouble([0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]))
|
||||
assert.equal(1, binary.readDouble([0x3f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]))
|
||||
assert.equal(2, binary.readDouble([0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]))
|
||||
assert.equal(-2, binary.readDouble([0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]))
|
||||
assert.equal(
|
||||
0,
|
||||
binary.readDouble([0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00])
|
||||
);
|
||||
assert.equal(
|
||||
0,
|
||||
binary.readDouble([0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00])
|
||||
);
|
||||
assert.equal(
|
||||
1,
|
||||
binary.readDouble([0x3f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00])
|
||||
);
|
||||
assert.equal(
|
||||
2,
|
||||
binary.readDouble([0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00])
|
||||
);
|
||||
assert.equal(
|
||||
-2,
|
||||
binary.readDouble([0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00])
|
||||
);
|
||||
|
||||
assert.equal(Math.PI, binary.readDouble([0x40, 0x9, 0x21, 0xfb, 0x54, 0x44, 0x2d, 0x18]))
|
||||
assert.equal(
|
||||
Math.PI,
|
||||
binary.readDouble([0x40, 0x9, 0x21, 0xfb, 0x54, 0x44, 0x2d, 0x18])
|
||||
);
|
||||
|
||||
assert.equal(Infinity, binary.readDouble([0x7f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]))
|
||||
assert.equal(-Infinity, binary.readDouble([0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]))
|
||||
assert.equal(
|
||||
Infinity,
|
||||
binary.readDouble([0x7f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00])
|
||||
);
|
||||
assert.equal(
|
||||
-Infinity,
|
||||
binary.readDouble([0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00])
|
||||
);
|
||||
|
||||
assert.ok(isNaN(binary.readDouble([0x7f, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00])))
|
||||
assert.ok(
|
||||
isNaN(binary.readDouble([0x7f, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]))
|
||||
);
|
||||
|
||||
assert.equal(1/3, binary.readDouble([0x3f, 0xd5, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55]))
|
||||
assert.equal(
|
||||
1 / 3,
|
||||
binary.readDouble([0x3f, 0xd5, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55])
|
||||
);
|
||||
|
||||
// Min subnormal positive double
|
||||
assert.equal(4.9406564584124654e-324, binary.readDouble([0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01]))
|
||||
assert.equal(
|
||||
4.9406564584124654e-324,
|
||||
binary.readDouble([0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01])
|
||||
);
|
||||
// Min normal positive double
|
||||
assert.equal(2.2250738585072014e-308, binary.readDouble([0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]))
|
||||
assert.equal(
|
||||
2.2250738585072014e-308,
|
||||
binary.readDouble([0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00])
|
||||
);
|
||||
// Max positive double
|
||||
assert.equal(1.7976931348623157e308, binary.readDouble([0x7f, 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff]))
|
||||
assert.equal(
|
||||
1.7976931348623157e308,
|
||||
binary.readDouble([0x7f, 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff])
|
||||
);
|
||||
assert.end();
|
||||
},
|
||||
|
||||
"Should write doubles": function(assert) {
|
||||
assert.deepEqual([0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], binary.writeDouble([], 0));
|
||||
assert.deepEqual([0x3f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], binary.writeDouble([], 1));
|
||||
assert.deepEqual([0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], binary.writeDouble([], 2));
|
||||
assert.deepEqual([0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], binary.writeDouble([], -2));
|
||||
assert.deepEqual(
|
||||
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
|
||||
binary.writeDouble([], 0)
|
||||
);
|
||||
assert.deepEqual(
|
||||
[0x3f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
|
||||
binary.writeDouble([], 1)
|
||||
);
|
||||
assert.deepEqual(
|
||||
[0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
|
||||
binary.writeDouble([], 2)
|
||||
);
|
||||
assert.deepEqual(
|
||||
[0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
|
||||
binary.writeDouble([], -2)
|
||||
);
|
||||
|
||||
assert.deepEqual([0x40, 0x9, 0x21, 0xfb, 0x54, 0x44, 0x2d, 0x18], binary.writeDouble([], Math.PI));
|
||||
assert.deepEqual(
|
||||
[0x40, 0x9, 0x21, 0xfb, 0x54, 0x44, 0x2d, 0x18],
|
||||
binary.writeDouble([], Math.PI)
|
||||
);
|
||||
|
||||
assert.deepEqual([0x7f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], binary.writeDouble([], Infinity));
|
||||
assert.deepEqual([0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], binary.writeDouble([], -Infinity));
|
||||
assert.deepEqual(
|
||||
[0x7f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
|
||||
binary.writeDouble([], Infinity)
|
||||
);
|
||||
assert.deepEqual(
|
||||
[0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
|
||||
binary.writeDouble([], -Infinity)
|
||||
);
|
||||
|
||||
assert.deepEqual([0x7f, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], binary.writeDouble([], NaN));
|
||||
assert.deepEqual(
|
||||
[0x7f, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
|
||||
binary.writeDouble([], NaN)
|
||||
);
|
||||
|
||||
assert.deepEqual([0x3f, 0xd5, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55], binary.writeDouble([], 1/3));
|
||||
assert.deepEqual(
|
||||
[0x3f, 0xd5, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55],
|
||||
binary.writeDouble([], 1 / 3)
|
||||
);
|
||||
|
||||
// Min subnormal positive double
|
||||
assert.deepEqual([0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01], binary.writeDouble([], 4.9406564584124654e-324));
|
||||
assert.deepEqual(
|
||||
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01],
|
||||
binary.writeDouble([], 4.9406564584124654e-324)
|
||||
);
|
||||
// Min normal positive double
|
||||
assert.deepEqual([0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], binary.writeDouble([], 2.2250738585072014e-308));
|
||||
assert.deepEqual(
|
||||
[0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
|
||||
binary.writeDouble([], 2.2250738585072014e-308)
|
||||
);
|
||||
// Max positive double
|
||||
assert.deepEqual([0x7f, 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff], binary.writeDouble([], 1.7976931348623157e308));
|
||||
assert.deepEqual(
|
||||
[0x7f, 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff],
|
||||
binary.writeDouble([], 1.7976931348623157e308)
|
||||
);
|
||||
assert.end();
|
||||
}
|
||||
};
|
||||
|
|
138
vendor/git.apache.org/thrift.git/lib/nodejs/test/client.js
generated
vendored
138
vendor/git.apache.org/thrift.git/lib/nodejs/test/client.js
generated
vendored
|
@ -19,125 +19,149 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
var fs = require('fs');
|
||||
var assert = require('assert');
|
||||
var thrift = require('thrift');
|
||||
var helpers = require('./helpers');
|
||||
var ThriftTest = require('./gen-nodejs/ThriftTest');
|
||||
var ThriftTestDriver = require('./test_driver').ThriftTestDriver;
|
||||
var ThriftTestDriverPromise = require('./test_driver').ThriftTestDriverPromise;
|
||||
var SecondService = require('./gen-nodejs/SecondService');
|
||||
var ttypes = require('./gen-nodejs/ThriftTest_types');
|
||||
const assert = require("assert");
|
||||
const thrift = require("thrift");
|
||||
const helpers = require("./helpers");
|
||||
|
||||
var program = require('commander');
|
||||
const ThriftTest = require(`./${helpers.genPath}/ThriftTest`);
|
||||
const ThriftTestDriver = require("./test_driver").ThriftTestDriver;
|
||||
const ThriftTestDriverPromise = require("./test_driver")
|
||||
.ThriftTestDriverPromise;
|
||||
const SecondService = require(`./${helpers.genPath}/SecondService`);
|
||||
|
||||
const program = require("commander");
|
||||
|
||||
program
|
||||
.option('-p, --protocol <protocol>', 'Set thrift protocol (binary|compact|json) [protocol]')
|
||||
.option('-t, --transport <transport>', 'Set thrift transport (buffered|framed|http) [transport]')
|
||||
.option('--port <port>', 'Set thrift server port number to connect', 9090)
|
||||
.option('--host <host>', 'Set thrift server host to connect', 'localhost')
|
||||
.option('--domain-socket <path>', 'Set thrift server unix domain socket to connect')
|
||||
.option('--ssl', 'use SSL transport')
|
||||
.option('--promise', 'test with promise style functions')
|
||||
.option('-t, --type <type>', 'Select server type (http|multiplex|tcp|websocket)', 'tcp')
|
||||
.option(
|
||||
"-p, --protocol <protocol>",
|
||||
"Set thrift protocol (binary|compact|json) [protocol]"
|
||||
)
|
||||
.option(
|
||||
"-t, --transport <transport>",
|
||||
"Set thrift transport (buffered|framed|http) [transport]"
|
||||
)
|
||||
.option("--port <port>", "Set thrift server port number to connect", 9090)
|
||||
.option("--host <host>", "Set thrift server host to connect", "localhost")
|
||||
.option(
|
||||
"--domain-socket <path>",
|
||||
"Set thrift server unix domain socket to connect"
|
||||
)
|
||||
.option("--ssl", "use SSL transport")
|
||||
.option("--callback", "test with callback style functions")
|
||||
.option(
|
||||
"-t, --type <type>",
|
||||
"Select server type (http|multiplex|tcp|websocket)",
|
||||
"tcp"
|
||||
)
|
||||
.option("--es6", "Use es6 code")
|
||||
.option("--es5", "Use es5 code")
|
||||
.parse(process.argv);
|
||||
|
||||
var host = program.host;
|
||||
var port = program.port;
|
||||
var domainSocket = program.domainSocket;
|
||||
var type = program.type;
|
||||
var ssl = program.ssl;
|
||||
var promise = program.promise;
|
||||
const host = program.host;
|
||||
const port = program.port;
|
||||
const domainSocket = program.domainSocket;
|
||||
const ssl = program.ssl;
|
||||
let type = program.type;
|
||||
|
||||
/* for compatibility with cross test invocation for http transport testing */
|
||||
if (program.transport === 'http') {
|
||||
program.transport = 'buffered';
|
||||
type = 'http';
|
||||
if (program.transport === "http") {
|
||||
program.transport = "buffered";
|
||||
type = "http";
|
||||
}
|
||||
|
||||
var options = {
|
||||
const options = {
|
||||
transport: helpers.transports[program.transport],
|
||||
protocol: helpers.protocols[program.protocol]
|
||||
};
|
||||
|
||||
if (type === 'http' || type === 'websocket') {
|
||||
options.path = '/test';
|
||||
if (type === "http" || type === "websocket") {
|
||||
options.path = "/test";
|
||||
}
|
||||
|
||||
if (type === 'http') {
|
||||
options.headers = {"Connection": "close"};
|
||||
if (type === "http") {
|
||||
options.headers = { Connection: "close" };
|
||||
}
|
||||
|
||||
if (ssl) {
|
||||
if (type === 'tcp' || type === 'multiplex') {
|
||||
if (type === "tcp" || type === "multiplex") {
|
||||
options.rejectUnauthorized = false;
|
||||
} else if (type === 'http') {
|
||||
} else if (type === "http") {
|
||||
options.nodeOptions = { rejectUnauthorized: false };
|
||||
options.https = true;
|
||||
} else if (type === 'websocket') {
|
||||
} else if (type === "websocket") {
|
||||
options.wsOptions = { rejectUnauthorized: false };
|
||||
options.secure = true;
|
||||
}
|
||||
}
|
||||
|
||||
var connection;
|
||||
var client;
|
||||
var testDriver = promise ? ThriftTestDriverPromise : ThriftTestDriver;
|
||||
let connection;
|
||||
let client;
|
||||
const testDriver = program.callback
|
||||
? ThriftTestDriver
|
||||
: ThriftTestDriverPromise;
|
||||
if (helpers.ecmaMode === "es6" && program.callback) {
|
||||
console.log("ES6 does not support callback style");
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
if (type === 'tcp' || type === 'multiplex') {
|
||||
if (type === "tcp" || type === "multiplex") {
|
||||
if (domainSocket) {
|
||||
connection = thrift.createUDSConnection(domainSocket, options);
|
||||
} else {
|
||||
connection = ssl ?
|
||||
thrift.createSSLConnection(host, port, options) :
|
||||
thrift.createConnection(host, port, options);
|
||||
connection = ssl
|
||||
? thrift.createSSLConnection(host, port, options)
|
||||
: thrift.createConnection(host, port, options);
|
||||
}
|
||||
} else if (type === 'http') {
|
||||
} else if (type === "http") {
|
||||
if (domainSocket) {
|
||||
connection = thrift.createHttpUDSConnection(domainSocket, options);
|
||||
} else {
|
||||
connection = thrift.createHttpConnection(host, port, options);
|
||||
}
|
||||
} else if (type === 'websocket') {
|
||||
} else if (type === "websocket") {
|
||||
connection = thrift.createWSConnection(host, port, options);
|
||||
connection.open();
|
||||
}
|
||||
|
||||
connection.on('error', function(err) {
|
||||
assert(false, err);
|
||||
connection.on("error", function(err) {
|
||||
assert(false, err);
|
||||
});
|
||||
|
||||
if (type === 'tcp') {
|
||||
if (type === "tcp") {
|
||||
client = thrift.createClient(ThriftTest, connection);
|
||||
runTests();
|
||||
} else if (type === 'multiplex') {
|
||||
var mp = new thrift.Multiplexer();
|
||||
} else if (type === "multiplex") {
|
||||
const mp = new thrift.Multiplexer();
|
||||
client = mp.createClient("ThriftTest", ThriftTest, connection);
|
||||
secondclient = mp.createClient("SecondService", SecondService, connection);
|
||||
const secondclient = mp.createClient(
|
||||
"SecondService",
|
||||
SecondService,
|
||||
connection
|
||||
);
|
||||
|
||||
connection.on('connect', function() {
|
||||
connection.on("connect", function() {
|
||||
secondclient.secondtestString("Test", function(err, response) {
|
||||
assert(!err);
|
||||
assert.equal("testString(\"Test\")", response);
|
||||
assert.equal('testString("Test")', response);
|
||||
});
|
||||
|
||||
runTests();
|
||||
});
|
||||
} else if (type === 'http') {
|
||||
} else if (type === "http") {
|
||||
client = thrift.createHttpClient(ThriftTest, connection);
|
||||
runTests();
|
||||
} else if (type === 'websocket') {
|
||||
} else if (type === "websocket") {
|
||||
client = thrift.createWSClient(ThriftTest, connection);
|
||||
runTests();
|
||||
}
|
||||
|
||||
function runTests() {
|
||||
testDriver(client, function (status) {
|
||||
testDriver(client, function(status) {
|
||||
console.log(status);
|
||||
if (type !== 'http' && type !== 'websocket') {
|
||||
if (type !== "http" && type !== "websocket") {
|
||||
connection.end();
|
||||
}
|
||||
if (type !== 'multiplex') {
|
||||
if (type !== "multiplex") {
|
||||
process.exit(0);
|
||||
}
|
||||
});
|
||||
|
|
316
vendor/git.apache.org/thrift.git/lib/nodejs/test/deep-constructor.test.js
generated
vendored
316
vendor/git.apache.org/thrift.git/lib/nodejs/test/deep-constructor.test.js
generated
vendored
|
@ -17,39 +17,36 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
var ttypes = require('./gen-nodejs/JsDeepConstructorTest_types');
|
||||
var thrift = require('thrift');
|
||||
var test = require('tape');
|
||||
var bufferEquals = require('buffer-equals');
|
||||
const ttypes = require("./gen-nodejs/JsDeepConstructorTest_types");
|
||||
const thrift = require("thrift");
|
||||
const test = require("tape");
|
||||
const bufferEquals = require("buffer-equals");
|
||||
|
||||
function serializeBinary(data) {
|
||||
var buff;
|
||||
var transport = new thrift.TBufferedTransport(null, function(msg){
|
||||
let buff;
|
||||
const transport = new thrift.TBufferedTransport(null, function(msg) {
|
||||
buff = msg;
|
||||
});
|
||||
var prot = new thrift.TBinaryProtocol(transport);
|
||||
const prot = new thrift.TBinaryProtocol(transport);
|
||||
data.write(prot);
|
||||
prot.flush();
|
||||
return buff;
|
||||
|
||||
}
|
||||
|
||||
|
||||
function deserializeBinary(serialized, type) {
|
||||
var t = new thrift.TFramedTransport(serialized);
|
||||
var p = new thrift.TBinaryProtocol(t);
|
||||
var data = new type();
|
||||
const t = new thrift.TFramedTransport(serialized);
|
||||
const p = new thrift.TBinaryProtocol(t);
|
||||
const data = new type();
|
||||
data.read(p);
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
function serializeJSON(data) {
|
||||
var buff;
|
||||
var transport = new thrift.TBufferedTransport(null, function(msg){
|
||||
let buff;
|
||||
const transport = new thrift.TBufferedTransport(null, function(msg) {
|
||||
buff = msg;
|
||||
});
|
||||
var protocol = new thrift.TJSONProtocol(transport);
|
||||
const protocol = new thrift.TJSONProtocol(transport);
|
||||
protocol.writeMessageBegin("", 0, 0);
|
||||
data.write(protocol);
|
||||
protocol.writeMessageEnd();
|
||||
|
@ -57,45 +54,41 @@ function serializeJSON(data) {
|
|||
return buff;
|
||||
}
|
||||
|
||||
|
||||
function deserializeJSON(serialized, type) {
|
||||
var transport = new thrift.TFramedTransport(serialized);
|
||||
var protocol = new thrift.TJSONProtocol(transport);
|
||||
const transport = new thrift.TFramedTransport(serialized);
|
||||
const protocol = new thrift.TJSONProtocol(transport);
|
||||
protocol.readMessageBegin();
|
||||
var data = new type();
|
||||
const data = new type();
|
||||
data.read(protocol);
|
||||
protocol.readMessageEnd();
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
function createThriftObj() {
|
||||
|
||||
return new ttypes.Complex({
|
||||
|
||||
struct_field: new ttypes.Simple({value: 'a'}),
|
||||
struct_field: new ttypes.Simple({ value: "a" }),
|
||||
|
||||
struct_list_field: [
|
||||
new ttypes.Simple({value: 'b'}),
|
||||
new ttypes.Simple({value: 'c'}),
|
||||
new ttypes.Simple({ value: "b" }),
|
||||
new ttypes.Simple({ value: "c" })
|
||||
],
|
||||
|
||||
struct_set_field: [
|
||||
new ttypes.Simple({value: 'd'}),
|
||||
new ttypes.Simple({value: 'e'}),
|
||||
new ttypes.Simple({ value: "d" }),
|
||||
new ttypes.Simple({ value: "e" })
|
||||
],
|
||||
|
||||
struct_map_field: {
|
||||
A: new ttypes.Simple({value: 'f'}),
|
||||
B: new ttypes.Simple({value: 'g'})
|
||||
A: new ttypes.Simple({ value: "f" }),
|
||||
B: new ttypes.Simple({ value: "g" })
|
||||
},
|
||||
|
||||
struct_nested_containers_field: [
|
||||
[
|
||||
{
|
||||
C: [
|
||||
new ttypes.Simple({value: 'h'}),
|
||||
new ttypes.Simple({value: 'i'})
|
||||
new ttypes.Simple({ value: "h" }),
|
||||
new ttypes.Simple({ value: "i" })
|
||||
]
|
||||
}
|
||||
]
|
||||
|
@ -104,59 +97,57 @@ function createThriftObj() {
|
|||
struct_nested_containers_field2: {
|
||||
D: [
|
||||
{
|
||||
DA: new ttypes.Simple({value: 'j'})
|
||||
DA: new ttypes.Simple({ value: "j" })
|
||||
},
|
||||
{
|
||||
DB: new ttypes.Simple({value: 'k'})
|
||||
DB: new ttypes.Simple({ value: "k" })
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
list_of_list_field: [
|
||||
['l00', 'l01', 'l02'],
|
||||
['l10', 'l11', 'l12'],
|
||||
['l20', 'l21', 'l22'],
|
||||
["l00", "l01", "l02"],
|
||||
["l10", "l11", "l12"],
|
||||
["l20", "l21", "l22"]
|
||||
],
|
||||
|
||||
list_of_list_of_list_field: [
|
||||
[['m000', 'm001', 'm002'], ['m010', 'm011', 'm012'], ['m020', 'm021', 'm022']],
|
||||
[['m100', 'm101', 'm102'], ['m110', 'm111', 'm112'], ['m120', 'm121', 'm122']],
|
||||
[['m200', 'm201', 'm202'], ['m210', 'm211', 'm212'], ['m220', 'm221', 'm222']],
|
||||
],
|
||||
|
||||
|
||||
[
|
||||
["m000", "m001", "m002"],
|
||||
["m010", "m011", "m012"],
|
||||
["m020", "m021", "m022"]
|
||||
],
|
||||
[
|
||||
["m100", "m101", "m102"],
|
||||
["m110", "m111", "m112"],
|
||||
["m120", "m121", "m122"]
|
||||
],
|
||||
[
|
||||
["m200", "m201", "m202"],
|
||||
["m210", "m211", "m212"],
|
||||
["m220", "m221", "m222"]
|
||||
]
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function createJsObj() {
|
||||
|
||||
return {
|
||||
struct_field: { value: "a" },
|
||||
|
||||
struct_field: {value: 'a'},
|
||||
struct_list_field: [{ value: "b" }, { value: "c" }],
|
||||
|
||||
struct_list_field: [
|
||||
{value: 'b'},
|
||||
{value: 'c'},
|
||||
],
|
||||
|
||||
struct_set_field: [
|
||||
{value: 'd'},
|
||||
{value: 'e'},
|
||||
],
|
||||
struct_set_field: [{ value: "d" }, { value: "e" }],
|
||||
|
||||
struct_map_field: {
|
||||
A: {value: 'f'},
|
||||
B: {value: 'g'}
|
||||
A: { value: "f" },
|
||||
B: { value: "g" }
|
||||
},
|
||||
|
||||
struct_nested_containers_field: [
|
||||
[
|
||||
{
|
||||
C: [
|
||||
{value: 'h'},
|
||||
{value: 'i'}
|
||||
]
|
||||
C: [{ value: "h" }, { value: "i" }]
|
||||
}
|
||||
]
|
||||
],
|
||||
|
@ -164,131 +155,142 @@ function createJsObj() {
|
|||
struct_nested_containers_field2: {
|
||||
D: [
|
||||
{
|
||||
DA: {value: 'j'}
|
||||
DA: { value: "j" }
|
||||
},
|
||||
{
|
||||
DB: {value: 'k'}
|
||||
DB: { value: "k" }
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
list_of_list_field: [
|
||||
['l00', 'l01', 'l02'],
|
||||
['l10', 'l11', 'l12'],
|
||||
['l20', 'l21', 'l22'],
|
||||
["l00", "l01", "l02"],
|
||||
["l10", "l11", "l12"],
|
||||
["l20", "l21", "l22"]
|
||||
],
|
||||
|
||||
list_of_list_of_list_field: [
|
||||
[['m000', 'm001', 'm002'], ['m010', 'm011', 'm012'], ['m020', 'm021', 'm022']],
|
||||
[['m100', 'm101', 'm102'], ['m110', 'm111', 'm112'], ['m120', 'm121', 'm122']],
|
||||
[['m200', 'm201', 'm202'], ['m210', 'm211', 'm212'], ['m220', 'm221', 'm222']],
|
||||
],
|
||||
|
||||
[
|
||||
["m000", "m001", "m002"],
|
||||
["m010", "m011", "m012"],
|
||||
["m020", "m021", "m022"]
|
||||
],
|
||||
[
|
||||
["m100", "m101", "m102"],
|
||||
["m110", "m111", "m112"],
|
||||
["m120", "m121", "m122"]
|
||||
],
|
||||
[
|
||||
["m200", "m201", "m202"],
|
||||
["m210", "m211", "m212"],
|
||||
["m220", "m221", "m222"]
|
||||
]
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
function assertValues(obj, assert) {
|
||||
assert.equals(obj.struct_field.value, 'a');
|
||||
assert.equals(obj.struct_list_field[0].value, 'b');
|
||||
assert.equals(obj.struct_list_field[1].value, 'c');
|
||||
assert.equals(obj.struct_set_field[0].value, 'd');
|
||||
assert.equals(obj.struct_set_field[1].value, 'e');
|
||||
assert.equals(obj.struct_map_field.A.value, 'f');
|
||||
assert.equals(obj.struct_map_field.B.value, 'g');
|
||||
assert.equals(obj.struct_nested_containers_field[0][0].C[0].value, 'h');
|
||||
assert.equals(obj.struct_nested_containers_field[0][0].C[1].value, 'i');
|
||||
assert.equals(obj.struct_nested_containers_field2.D[0].DA.value, 'j');
|
||||
assert.equals(obj.struct_nested_containers_field2.D[1].DB.value, 'k');
|
||||
assert.equals(obj.list_of_list_field[0][0], 'l00');
|
||||
assert.equals(obj.list_of_list_field[0][1], 'l01');
|
||||
assert.equals(obj.list_of_list_field[0][2], 'l02');
|
||||
assert.equals(obj.list_of_list_field[1][0], 'l10');
|
||||
assert.equals(obj.list_of_list_field[1][1], 'l11');
|
||||
assert.equals(obj.list_of_list_field[1][2], 'l12');
|
||||
assert.equals(obj.list_of_list_field[2][0], 'l20');
|
||||
assert.equals(obj.list_of_list_field[2][1], 'l21');
|
||||
assert.equals(obj.list_of_list_field[2][2], 'l22');
|
||||
assert.equals(obj.struct_field.value, "a");
|
||||
assert.equals(obj.struct_list_field[0].value, "b");
|
||||
assert.equals(obj.struct_list_field[1].value, "c");
|
||||
assert.equals(obj.struct_set_field[0].value, "d");
|
||||
assert.equals(obj.struct_set_field[1].value, "e");
|
||||
assert.equals(obj.struct_map_field.A.value, "f");
|
||||
assert.equals(obj.struct_map_field.B.value, "g");
|
||||
assert.equals(obj.struct_nested_containers_field[0][0].C[0].value, "h");
|
||||
assert.equals(obj.struct_nested_containers_field[0][0].C[1].value, "i");
|
||||
assert.equals(obj.struct_nested_containers_field2.D[0].DA.value, "j");
|
||||
assert.equals(obj.struct_nested_containers_field2.D[1].DB.value, "k");
|
||||
assert.equals(obj.list_of_list_field[0][0], "l00");
|
||||
assert.equals(obj.list_of_list_field[0][1], "l01");
|
||||
assert.equals(obj.list_of_list_field[0][2], "l02");
|
||||
assert.equals(obj.list_of_list_field[1][0], "l10");
|
||||
assert.equals(obj.list_of_list_field[1][1], "l11");
|
||||
assert.equals(obj.list_of_list_field[1][2], "l12");
|
||||
assert.equals(obj.list_of_list_field[2][0], "l20");
|
||||
assert.equals(obj.list_of_list_field[2][1], "l21");
|
||||
assert.equals(obj.list_of_list_field[2][2], "l22");
|
||||
|
||||
assert.equals(obj.list_of_list_of_list_field[0][0][0], 'm000');
|
||||
assert.equals(obj.list_of_list_of_list_field[0][0][1], 'm001');
|
||||
assert.equals(obj.list_of_list_of_list_field[0][0][2], 'm002');
|
||||
assert.equals(obj.list_of_list_of_list_field[0][1][0], 'm010');
|
||||
assert.equals(obj.list_of_list_of_list_field[0][1][1], 'm011');
|
||||
assert.equals(obj.list_of_list_of_list_field[0][1][2], 'm012');
|
||||
assert.equals(obj.list_of_list_of_list_field[0][2][0], 'm020');
|
||||
assert.equals(obj.list_of_list_of_list_field[0][2][1], 'm021');
|
||||
assert.equals(obj.list_of_list_of_list_field[0][2][2], 'm022');
|
||||
assert.equals(obj.list_of_list_of_list_field[0][0][0], "m000");
|
||||
assert.equals(obj.list_of_list_of_list_field[0][0][1], "m001");
|
||||
assert.equals(obj.list_of_list_of_list_field[0][0][2], "m002");
|
||||
assert.equals(obj.list_of_list_of_list_field[0][1][0], "m010");
|
||||
assert.equals(obj.list_of_list_of_list_field[0][1][1], "m011");
|
||||
assert.equals(obj.list_of_list_of_list_field[0][1][2], "m012");
|
||||
assert.equals(obj.list_of_list_of_list_field[0][2][0], "m020");
|
||||
assert.equals(obj.list_of_list_of_list_field[0][2][1], "m021");
|
||||
assert.equals(obj.list_of_list_of_list_field[0][2][2], "m022");
|
||||
|
||||
assert.equals(obj.list_of_list_of_list_field[1][0][0], 'm100');
|
||||
assert.equals(obj.list_of_list_of_list_field[1][0][1], 'm101');
|
||||
assert.equals(obj.list_of_list_of_list_field[1][0][2], 'm102');
|
||||
assert.equals(obj.list_of_list_of_list_field[1][1][0], 'm110');
|
||||
assert.equals(obj.list_of_list_of_list_field[1][1][1], 'm111');
|
||||
assert.equals(obj.list_of_list_of_list_field[1][1][2], 'm112');
|
||||
assert.equals(obj.list_of_list_of_list_field[1][2][0], 'm120');
|
||||
assert.equals(obj.list_of_list_of_list_field[1][2][1], 'm121');
|
||||
assert.equals(obj.list_of_list_of_list_field[1][2][2], 'm122');
|
||||
assert.equals(obj.list_of_list_of_list_field[1][0][0], "m100");
|
||||
assert.equals(obj.list_of_list_of_list_field[1][0][1], "m101");
|
||||
assert.equals(obj.list_of_list_of_list_field[1][0][2], "m102");
|
||||
assert.equals(obj.list_of_list_of_list_field[1][1][0], "m110");
|
||||
assert.equals(obj.list_of_list_of_list_field[1][1][1], "m111");
|
||||
assert.equals(obj.list_of_list_of_list_field[1][1][2], "m112");
|
||||
assert.equals(obj.list_of_list_of_list_field[1][2][0], "m120");
|
||||
assert.equals(obj.list_of_list_of_list_field[1][2][1], "m121");
|
||||
assert.equals(obj.list_of_list_of_list_field[1][2][2], "m122");
|
||||
|
||||
assert.equals(obj.list_of_list_of_list_field[2][0][0], 'm200');
|
||||
assert.equals(obj.list_of_list_of_list_field[2][0][1], 'm201');
|
||||
assert.equals(obj.list_of_list_of_list_field[2][0][2], 'm202');
|
||||
assert.equals(obj.list_of_list_of_list_field[2][1][0], 'm210');
|
||||
assert.equals(obj.list_of_list_of_list_field[2][1][1], 'm211');
|
||||
assert.equals(obj.list_of_list_of_list_field[2][1][2], 'm212');
|
||||
assert.equals(obj.list_of_list_of_list_field[2][2][0], 'm220');
|
||||
assert.equals(obj.list_of_list_of_list_field[2][2][1], 'm221');
|
||||
assert.equals(obj.list_of_list_of_list_field[2][2][2], 'm222');
|
||||
assert.equals(obj.list_of_list_of_list_field[2][0][0], "m200");
|
||||
assert.equals(obj.list_of_list_of_list_field[2][0][1], "m201");
|
||||
assert.equals(obj.list_of_list_of_list_field[2][0][2], "m202");
|
||||
assert.equals(obj.list_of_list_of_list_field[2][1][0], "m210");
|
||||
assert.equals(obj.list_of_list_of_list_field[2][1][1], "m211");
|
||||
assert.equals(obj.list_of_list_of_list_field[2][1][2], "m212");
|
||||
assert.equals(obj.list_of_list_of_list_field[2][2][0], "m220");
|
||||
assert.equals(obj.list_of_list_of_list_field[2][2][1], "m221");
|
||||
assert.equals(obj.list_of_list_of_list_field[2][2][2], "m222");
|
||||
}
|
||||
|
||||
function createTestCases(serialize, deserialize) {
|
||||
|
||||
var cases = {
|
||||
|
||||
"Serialize/deserialize should return equal object": function(assert){
|
||||
var tObj = createThriftObj();
|
||||
var received = deserialize(serialize(tObj), ttypes.Complex);
|
||||
assert.ok(tObj !== received, 'not the same object');
|
||||
const cases = {
|
||||
"Serialize/deserialize should return equal object": function(assert) {
|
||||
const tObj = createThriftObj();
|
||||
const received = deserialize(serialize(tObj), ttypes.Complex);
|
||||
assert.ok(tObj !== received, "not the same object");
|
||||
assert.deepEqual(tObj, received);
|
||||
assert.end();
|
||||
},
|
||||
|
||||
"Nested structs and containers initialized from plain js objects should serialize same as if initialized from thrift objects": function(assert) {
|
||||
var tObj1 = createThriftObj();
|
||||
var tObj2 = new ttypes.Complex(createJsObj());
|
||||
"Nested structs and containers initialized from plain js objects should serialize same as if initialized from thrift objects": function(
|
||||
assert
|
||||
) {
|
||||
const tObj1 = createThriftObj();
|
||||
const tObj2 = new ttypes.Complex(createJsObj());
|
||||
assertValues(tObj2, assert);
|
||||
var s1 = serialize(tObj1);
|
||||
var s2 = serialize(tObj2);
|
||||
const s1 = serialize(tObj1);
|
||||
const s2 = serialize(tObj2);
|
||||
assert.ok(bufferEquals(s1, s2));
|
||||
assert.end();
|
||||
},
|
||||
|
||||
"Modifications to args object should not affect constructed Thrift object": function (assert) {
|
||||
|
||||
var args = createJsObj();
|
||||
"Modifications to args object should not affect constructed Thrift object": function(
|
||||
assert
|
||||
) {
|
||||
const args = createJsObj();
|
||||
assertValues(args, assert);
|
||||
|
||||
var tObj = new ttypes.Complex(args);
|
||||
const tObj = new ttypes.Complex(args);
|
||||
assertValues(tObj, assert);
|
||||
|
||||
args.struct_field.value = 'ZZZ';
|
||||
args.struct_list_field[0].value = 'ZZZ';
|
||||
args.struct_list_field[1].value = 'ZZZ';
|
||||
args.struct_set_field[0].value = 'ZZZ';
|
||||
args.struct_set_field[1].value = 'ZZZ';
|
||||
args.struct_map_field.A.value = 'ZZZ';
|
||||
args.struct_map_field.B.value = 'ZZZ';
|
||||
args.struct_nested_containers_field[0][0].C[0] = 'ZZZ';
|
||||
args.struct_nested_containers_field[0][0].C[1] = 'ZZZ';
|
||||
args.struct_nested_containers_field2.D[0].DA = 'ZZZ';
|
||||
args.struct_nested_containers_field2.D[0].DB = 'ZZZ';
|
||||
args.struct_field.value = "ZZZ";
|
||||
args.struct_list_field[0].value = "ZZZ";
|
||||
args.struct_list_field[1].value = "ZZZ";
|
||||
args.struct_set_field[0].value = "ZZZ";
|
||||
args.struct_set_field[1].value = "ZZZ";
|
||||
args.struct_map_field.A.value = "ZZZ";
|
||||
args.struct_map_field.B.value = "ZZZ";
|
||||
args.struct_nested_containers_field[0][0].C[0] = "ZZZ";
|
||||
args.struct_nested_containers_field[0][0].C[1] = "ZZZ";
|
||||
args.struct_nested_containers_field2.D[0].DA = "ZZZ";
|
||||
args.struct_nested_containers_field2.D[0].DB = "ZZZ";
|
||||
|
||||
assertValues(tObj, assert);
|
||||
assert.end();
|
||||
},
|
||||
|
||||
"nulls are ok": function(assert) {
|
||||
var tObj = new ttypes.Complex({
|
||||
const tObj = new ttypes.Complex({
|
||||
struct_field: null,
|
||||
struct_list_field: null,
|
||||
struct_set_field: null,
|
||||
|
@ -296,7 +298,7 @@ function createTestCases(serialize, deserialize) {
|
|||
struct_nested_containers_field: null,
|
||||
struct_nested_containers_field2: null
|
||||
});
|
||||
var received = deserialize(serialize(tObj), ttypes.Complex);
|
||||
const received = deserialize(serialize(tObj), ttypes.Complex);
|
||||
assert.strictEqual(tObj.struct_field, null);
|
||||
assert.ok(tObj !== received);
|
||||
assert.deepEqual(tObj, received);
|
||||
|
@ -304,11 +306,11 @@ function createTestCases(serialize, deserialize) {
|
|||
},
|
||||
|
||||
"Can make list with objects": function(assert) {
|
||||
var tObj = new ttypes.ComplexList({
|
||||
"struct_list_field": [new ttypes.Complex({})]
|
||||
const tObj = new ttypes.ComplexList({
|
||||
struct_list_field: [new ttypes.Complex({})]
|
||||
});
|
||||
var innerObj = tObj.struct_list_field[0];
|
||||
assert.ok(innerObj instanceof ttypes.Complex)
|
||||
const innerObj = tObj.struct_list_field[0];
|
||||
assert.ok(innerObj instanceof ttypes.Complex);
|
||||
assert.strictEqual(innerObj.struct_field, null);
|
||||
assert.strictEqual(innerObj.struct_list_field, null);
|
||||
assert.strictEqual(innerObj.struct_set_field, null);
|
||||
|
@ -317,17 +319,15 @@ function createTestCases(serialize, deserialize) {
|
|||
assert.strictEqual(innerObj.struct_nested_containers_field2, null);
|
||||
assert.end();
|
||||
}
|
||||
|
||||
};
|
||||
return cases;
|
||||
}
|
||||
|
||||
|
||||
function run(name, cases){
|
||||
function run(name, cases) {
|
||||
Object.keys(cases).forEach(function(caseName) {
|
||||
test(name + ': ' + caseName, cases[caseName]);
|
||||
test(name + ": " + caseName, cases[caseName]);
|
||||
});
|
||||
}
|
||||
|
||||
run('binary', createTestCases(serializeBinary, deserializeBinary));
|
||||
run('json', createTestCases(serializeJSON, deserializeJSON));
|
||||
run("binary", createTestCases(serializeBinary, deserializeBinary));
|
||||
run("json", createTestCases(serializeJSON, deserializeJSON));
|
||||
|
|
166
vendor/git.apache.org/thrift.git/lib/nodejs/test/exceptions.js
generated
vendored
166
vendor/git.apache.org/thrift.git/lib/nodejs/test/exceptions.js
generated
vendored
|
@ -17,72 +17,130 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
var test = require('tape');
|
||||
var thrift = require('../lib/thrift/thrift.js');
|
||||
var InputBufferUnderrunError = require('../lib/thrift/input_buffer_underrun_error');
|
||||
"use strict";
|
||||
const test = require("tape");
|
||||
const thrift = require("../lib/thrift/thrift.js");
|
||||
const InputBufferUnderrunError = require("../lib/thrift/input_buffer_underrun_error");
|
||||
|
||||
test('TApplicationException', function t(assert) {
|
||||
var e = new thrift.TApplicationException(1, 'foo');
|
||||
assert.ok(e instanceof thrift.TApplicationException, 'is instanceof TApplicationException');
|
||||
assert.ok(e instanceof thrift.TException, 'is instanceof TException');
|
||||
assert.ok(e instanceof Error, 'is instanceof Error');
|
||||
assert.equal(typeof e.stack, 'string', 'has stack trace');
|
||||
assert.ok(/^TApplicationException: foo/.test(e.stack), 'Stack trace has correct error name and message');
|
||||
assert.ok(e.stack.indexOf('test/exceptions.js:7:11') !== -1, 'stack trace starts on correct line and column');
|
||||
assert.equal(e.name, 'TApplicationException', 'has function name TApplicationException');
|
||||
assert.equal(e.message, 'foo', 'has error message "foo"');
|
||||
assert.equal(e.type, 1, 'has type 1');
|
||||
test("TApplicationException", function t(assert) {
|
||||
const e = new thrift.TApplicationException(1, "foo");
|
||||
assert.ok(
|
||||
e instanceof thrift.TApplicationException,
|
||||
"is instanceof TApplicationException"
|
||||
);
|
||||
assert.ok(e instanceof thrift.TException, "is instanceof TException");
|
||||
assert.ok(e instanceof Error, "is instanceof Error");
|
||||
assert.equal(typeof e.stack, "string", "has stack trace");
|
||||
assert.ok(
|
||||
/^TApplicationException: foo/.test(e.stack),
|
||||
"Stack trace has correct error name and message"
|
||||
);
|
||||
assert.ok(
|
||||
e.stack.indexOf("test/exceptions.js:7:11") !== -1,
|
||||
"stack trace starts on correct line and column"
|
||||
);
|
||||
assert.equal(
|
||||
e.name,
|
||||
"TApplicationException",
|
||||
"has function name TApplicationException"
|
||||
);
|
||||
assert.equal(e.message, "foo", 'has error message "foo"');
|
||||
assert.equal(e.type, 1, "has type 1");
|
||||
assert.end();
|
||||
});
|
||||
|
||||
test('unexpected TApplicationException ', function t(assert) {
|
||||
var e = new thrift.TApplicationException(1, 100);
|
||||
assert.ok(e instanceof thrift.TApplicationException, 'is instanceof TApplicationException');
|
||||
assert.ok(e instanceof thrift.TException, 'is instanceof TException');
|
||||
assert.ok(e instanceof Error, 'is instanceof Error');
|
||||
assert.equal(typeof e.stack, 'string', 'has stack trace');
|
||||
assert.ok(/^TApplicationException: 100/.test(e.stack), 'Stack trace has correct error name and message');
|
||||
assert.ok(e.stack.indexOf('test/exceptions.js:7:11') !== -1, 'stack trace starts on correct line and column');
|
||||
assert.equal(e.name, 'TApplicationException', 'has function name TApplicationException');
|
||||
assert.equal(e.message, 100, 'has error message 100');
|
||||
assert.equal(e.type, 1, 'has type 1');
|
||||
test("unexpected TApplicationException ", function t(assert) {
|
||||
const e = new thrift.TApplicationException(1, 100);
|
||||
assert.ok(
|
||||
e instanceof thrift.TApplicationException,
|
||||
"is instanceof TApplicationException"
|
||||
);
|
||||
assert.ok(e instanceof thrift.TException, "is instanceof TException");
|
||||
assert.ok(e instanceof Error, "is instanceof Error");
|
||||
assert.equal(typeof e.stack, "string", "has stack trace");
|
||||
assert.ok(
|
||||
/^TApplicationException: 100/.test(e.stack),
|
||||
"Stack trace has correct error name and message"
|
||||
);
|
||||
assert.ok(
|
||||
e.stack.indexOf("test/exceptions.js:7:11") !== -1,
|
||||
"stack trace starts on correct line and column"
|
||||
);
|
||||
assert.equal(
|
||||
e.name,
|
||||
"TApplicationException",
|
||||
"has function name TApplicationException"
|
||||
);
|
||||
assert.equal(e.message, 100, "has error message 100");
|
||||
assert.equal(e.type, 1, "has type 1");
|
||||
assert.end();
|
||||
});
|
||||
|
||||
test('TException', function t(assert) {
|
||||
var e = new thrift.TException('foo');
|
||||
assert.ok(e instanceof thrift.TException, 'is instanceof TException');
|
||||
assert.ok(e instanceof Error, 'is instanceof Error');
|
||||
assert.equal(typeof e.stack, 'string', 'has stack trace');
|
||||
assert.ok(/^TException: foo/.test(e.stack), 'Stack trace has correct error name and message');
|
||||
assert.ok(e.stack.indexOf('test/exceptions.js:21:11') !== -1, 'stack trace starts on correct line and column');
|
||||
assert.equal(e.name, 'TException', 'has function name TException');
|
||||
assert.equal(e.message, 'foo', 'has error message "foo"');
|
||||
test("TException", function t(assert) {
|
||||
const e = new thrift.TException("foo");
|
||||
assert.ok(e instanceof thrift.TException, "is instanceof TException");
|
||||
assert.ok(e instanceof Error, "is instanceof Error");
|
||||
assert.equal(typeof e.stack, "string", "has stack trace");
|
||||
assert.ok(
|
||||
/^TException: foo/.test(e.stack),
|
||||
"Stack trace has correct error name and message"
|
||||
);
|
||||
assert.ok(
|
||||
e.stack.indexOf("test/exceptions.js:21:11") !== -1,
|
||||
"stack trace starts on correct line and column"
|
||||
);
|
||||
assert.equal(e.name, "TException", "has function name TException");
|
||||
assert.equal(e.message, "foo", 'has error message "foo"');
|
||||
assert.end();
|
||||
});
|
||||
|
||||
test('TProtocolException', function t(assert) {
|
||||
var e = new thrift.TProtocolException(1, 'foo');
|
||||
assert.ok(e instanceof thrift.TProtocolException, 'is instanceof TProtocolException');
|
||||
assert.ok(e instanceof Error, 'is instanceof Error');
|
||||
assert.equal(typeof e.stack, 'string', 'has stack trace');
|
||||
assert.ok(/^TProtocolException: foo/.test(e.stack), 'Stack trace has correct error name and message');
|
||||
assert.ok(e.stack.indexOf('test/exceptions.js:33:11') !== -1, 'stack trace starts on correct line and column');
|
||||
assert.equal(e.name, 'TProtocolException', 'has function name TProtocolException');
|
||||
assert.equal(e.message, 'foo', 'has error message "foo"');
|
||||
assert.equal(e.type, 1, 'has type 1');
|
||||
test("TProtocolException", function t(assert) {
|
||||
const e = new thrift.TProtocolException(1, "foo");
|
||||
assert.ok(
|
||||
e instanceof thrift.TProtocolException,
|
||||
"is instanceof TProtocolException"
|
||||
);
|
||||
assert.ok(e instanceof Error, "is instanceof Error");
|
||||
assert.equal(typeof e.stack, "string", "has stack trace");
|
||||
assert.ok(
|
||||
/^TProtocolException: foo/.test(e.stack),
|
||||
"Stack trace has correct error name and message"
|
||||
);
|
||||
assert.ok(
|
||||
e.stack.indexOf("test/exceptions.js:33:11") !== -1,
|
||||
"stack trace starts on correct line and column"
|
||||
);
|
||||
assert.equal(
|
||||
e.name,
|
||||
"TProtocolException",
|
||||
"has function name TProtocolException"
|
||||
);
|
||||
assert.equal(e.message, "foo", 'has error message "foo"');
|
||||
assert.equal(e.type, 1, "has type 1");
|
||||
assert.end();
|
||||
});
|
||||
|
||||
test('InputBufferUnderrunError', function t(assert) {
|
||||
var e = new InputBufferUnderrunError('foo');
|
||||
assert.ok(e instanceof InputBufferUnderrunError, 'is instanceof InputBufferUnderrunError');
|
||||
assert.ok(e instanceof Error, 'is instanceof Error');
|
||||
assert.equal(typeof e.stack, 'string', 'has stack trace');
|
||||
assert.ok(/^InputBufferUnderrunError: foo/.test(e.stack), 'Stack trace has correct error name and message');
|
||||
assert.ok(e.stack.indexOf('test/exceptions.js:46:11') !== -1, 'stack trace starts on correct line and column');
|
||||
assert.equal(e.name, 'InputBufferUnderrunError', 'has function name InputBufferUnderrunError');
|
||||
assert.equal(e.message, 'foo', 'has error message "foo"');
|
||||
test("InputBufferUnderrunError", function t(assert) {
|
||||
const e = new InputBufferUnderrunError("foo");
|
||||
assert.ok(
|
||||
e instanceof InputBufferUnderrunError,
|
||||
"is instanceof InputBufferUnderrunError"
|
||||
);
|
||||
assert.ok(e instanceof Error, "is instanceof Error");
|
||||
assert.equal(typeof e.stack, "string", "has stack trace");
|
||||
assert.ok(
|
||||
/^InputBufferUnderrunError: foo/.test(e.stack),
|
||||
"Stack trace has correct error name and message"
|
||||
);
|
||||
assert.ok(
|
||||
e.stack.indexOf("test/exceptions.js:46:11") !== -1,
|
||||
"stack trace starts on correct line and column"
|
||||
);
|
||||
assert.equal(
|
||||
e.name,
|
||||
"InputBufferUnderrunError",
|
||||
"has function name InputBufferUnderrunError"
|
||||
);
|
||||
assert.equal(e.message, "foo", 'has error message "foo"');
|
||||
assert.end();
|
||||
});
|
||||
|
|
19
vendor/git.apache.org/thrift.git/lib/nodejs/test/helpers.js
generated
vendored
19
vendor/git.apache.org/thrift.git/lib/nodejs/test/helpers.js
generated
vendored
|
@ -17,16 +17,21 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
var thrift = require('../lib/thrift');
|
||||
"use strict";
|
||||
const thrift = require("../lib/thrift");
|
||||
|
||||
module.exports.transports = {
|
||||
'buffered': thrift.TBufferedTransport,
|
||||
'framed': thrift.TFramedTransport
|
||||
buffered: thrift.TBufferedTransport,
|
||||
framed: thrift.TFramedTransport
|
||||
};
|
||||
|
||||
module.exports.protocols = {
|
||||
'json': thrift.TJSONProtocol,
|
||||
'binary': thrift.TBinaryProtocol,
|
||||
'compact': thrift.TCompactProtocol
|
||||
json: thrift.TJSONProtocol,
|
||||
binary: thrift.TBinaryProtocol,
|
||||
compact: thrift.TCompactProtocol
|
||||
};
|
||||
|
||||
module.exports.ecmaMode = process.argv.includes("--es6") ? "es6" : "es5";
|
||||
module.exports.genPath = process.argv.includes("--es6")
|
||||
? "gen-nodejs-es6"
|
||||
: "gen-nodejs";
|
||||
|
|
121
vendor/git.apache.org/thrift.git/lib/nodejs/test/server.js
generated
vendored
121
vendor/git.apache.org/thrift.git/lib/nodejs/test/server.js
generated
vendored
|
@ -19,96 +19,119 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var thrift = require('../lib/thrift');
|
||||
var program = require('commander');
|
||||
var helpers = require('./helpers');
|
||||
|
||||
var ThriftTest = require('./gen-nodejs/ThriftTest');
|
||||
var SecondService = require('./gen-nodejs/SecondService');
|
||||
var ThriftTestHandler = require('./test_handler').AsyncThriftTestHandler;
|
||||
var ThriftTestHandlerPromise = require('./test_handler').SyncThriftTestHandler;
|
||||
var ttypes = require('./gen-nodejs/ThriftTest_types');
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const thrift = require("../lib/thrift");
|
||||
const program = require("commander");
|
||||
const helpers = require("./helpers");
|
||||
|
||||
program
|
||||
.option('-p, --protocol <protocol>', 'Set thrift protocol (binary|compact|json)', 'binary')
|
||||
.option('-t, --transport <transport>', 'Set thrift transport (buffered|framed|http)', 'buffered')
|
||||
.option('--ssl', 'use ssl transport')
|
||||
.option('--port <port>', 'Set thrift server port', 9090)
|
||||
.option('--domain-socket <path>', 'Set thift server unix domain socket')
|
||||
.option('--promise', 'test with promise style functions')
|
||||
.option('-t, --type <type>', 'Select server type (http|multiplex|tcp|websocket)', 'tcp')
|
||||
.option(
|
||||
"-p, --protocol <protocol>",
|
||||
"Set thrift protocol (binary|compact|json)",
|
||||
"binary"
|
||||
)
|
||||
.option(
|
||||
"-t, --transport <transport>",
|
||||
"Set thrift transport (buffered|framed|http)",
|
||||
"buffered"
|
||||
)
|
||||
.option("--ssl", "use ssl transport")
|
||||
.option("--port <port>", "Set thrift server port", 9090)
|
||||
.option("--domain-socket <path>", "Set thift server unix domain socket")
|
||||
.option(
|
||||
"-t, --type <type>",
|
||||
"Select server type (http|multiplex|tcp|websocket)",
|
||||
"tcp"
|
||||
)
|
||||
.option("--callback", "test with callback style functions")
|
||||
.option("--es6", "Use es6 code")
|
||||
.option("--es5", "Use es5 code")
|
||||
.parse(process.argv);
|
||||
|
||||
var port = program.port;
|
||||
var domainSocket = program.domainSocket;
|
||||
var type = program.type;
|
||||
var ssl = program.ssl;
|
||||
var promise = program.promise;
|
||||
const ThriftTest = require(`./${helpers.genPath}/ThriftTest`);
|
||||
const SecondService = require(`./${helpers.genPath}/SecondService`);
|
||||
const { ThriftTestHandler } = require("./test_handler");
|
||||
|
||||
var handler = program.promise ? ThriftTestHandler : ThriftTestHandlerPromise;
|
||||
const port = program.port;
|
||||
const domainSocket = program.domainSocket;
|
||||
const ssl = program.ssl;
|
||||
|
||||
if (program.transport === 'http') {
|
||||
program.transport = 'buffered';
|
||||
type = 'http';
|
||||
let type = program.type;
|
||||
if (program.transport === "http") {
|
||||
program.transport = "buffered";
|
||||
type = "http";
|
||||
}
|
||||
|
||||
var options = {
|
||||
let options = {
|
||||
transport: helpers.transports[program.transport],
|
||||
protocol: helpers.protocols[program.protocol]
|
||||
};
|
||||
|
||||
if (type === 'http' || type ==='websocket') {
|
||||
options.handler = handler;
|
||||
if (type === "http" || type === "websocket") {
|
||||
options.handler = ThriftTestHandler;
|
||||
options.processor = ThriftTest;
|
||||
|
||||
options = {
|
||||
services: { "/test": options },
|
||||
cors: {
|
||||
'*': true
|
||||
"*": true
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
if (type === 'multiplex') {
|
||||
var SecondServiceHandler = {
|
||||
let processor;
|
||||
if (type === "multiplex") {
|
||||
const SecondServiceHandler = {
|
||||
secondtestString: function(thing, result) {
|
||||
console.log('testString("' + thing + '")');
|
||||
result(null, 'testString("' + thing + '")');
|
||||
}
|
||||
};
|
||||
|
||||
var processor = new thrift.MultiplexedProcessor();
|
||||
processor = new thrift.MultiplexedProcessor();
|
||||
|
||||
processor.registerProcessor("ThriftTest",
|
||||
new ThriftTest.Processor(ThriftTestHandler));
|
||||
|
||||
processor.registerProcessor("SecondService",
|
||||
new SecondService.Processor(SecondServiceHandler));
|
||||
processor.registerProcessor(
|
||||
"ThriftTest",
|
||||
new ThriftTest.Processor(ThriftTestHandler)
|
||||
);
|
||||
|
||||
processor.registerProcessor(
|
||||
"SecondService",
|
||||
new SecondService.Processor(SecondServiceHandler)
|
||||
);
|
||||
}
|
||||
|
||||
if (ssl) {
|
||||
if (type === 'tcp' || type === 'multiplex' || type === 'http' || type === 'websocket') {
|
||||
if (
|
||||
type === "tcp" ||
|
||||
type === "multiplex" ||
|
||||
type === "http" ||
|
||||
type === "websocket"
|
||||
) {
|
||||
options.tls = {
|
||||
key: fs.readFileSync(path.resolve(__dirname, 'server.key')),
|
||||
cert: fs.readFileSync(path.resolve(__dirname, 'server.crt'))
|
||||
key: fs.readFileSync(path.resolve(__dirname, "server.key")),
|
||||
cert: fs.readFileSync(path.resolve(__dirname, "server.crt"))
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
var server;
|
||||
if (type === 'tcp') {
|
||||
server = thrift.createServer(ThriftTest, handler, options);
|
||||
} else if (type === 'multiplex') {
|
||||
let server;
|
||||
if (type === "tcp") {
|
||||
server = thrift.createServer(ThriftTest, ThriftTestHandler, options);
|
||||
} else if (type === "multiplex") {
|
||||
server = thrift.createMultiplexServer(processor, options);
|
||||
} else if (type === 'http' || type === 'websocket') {
|
||||
} else if (type === "http" || type === "websocket") {
|
||||
server = thrift.createWebServer(options);
|
||||
}
|
||||
|
||||
if (domainSocket) {
|
||||
server.listen(domainSocket);
|
||||
} else if (type === 'tcp' || type === 'multiplex' || type === 'http' || type === 'websocket') {
|
||||
} else if (
|
||||
type === "tcp" ||
|
||||
type === "multiplex" ||
|
||||
type === "http" ||
|
||||
type === "websocket"
|
||||
) {
|
||||
server.listen(port);
|
||||
}
|
||||
|
|
227
vendor/git.apache.org/thrift.git/lib/nodejs/test/test-cases.js
generated
vendored
227
vendor/git.apache.org/thrift.git/lib/nodejs/test/test-cases.js
generated
vendored
|
@ -17,139 +17,156 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
var ttypes = require('./gen-nodejs/ThriftTest_types');
|
||||
var Int64 = require('node-int64');
|
||||
const helpers = require("./helpers");
|
||||
const ttypes = require(`./${helpers.genPath}/ThriftTest_types`);
|
||||
const Int64 = require("node-int64");
|
||||
|
||||
//all Languages in UTF-8
|
||||
/*jshint -W100 */
|
||||
var stringTest = module.exports.stringTest = "Afrikaans, Alemannisch, Aragonés, العربية, مصرى, " +
|
||||
"Asturianu, Aymar aru, Azərbaycan, Башҡорт, Boarisch, Žemaitėška, " +
|
||||
"Беларуская, Беларуская (тарашкевіца), Български, Bamanankan, " +
|
||||
"বাংলা, Brezhoneg, Bosanski, Català, Mìng-dĕ̤ng-ngṳ̄, Нохчийн, " +
|
||||
"Cebuano, ᏣᎳᎩ, Česky, Словѣ́ньскъ / ⰔⰎⰑⰂⰡⰐⰠⰔⰍⰟ, Чӑвашла, Cymraeg, " +
|
||||
"Dansk, Zazaki, ދިވެހިބަސް, Ελληνικά, Emiliàn e rumagnòl, English, " +
|
||||
"Esperanto, Español, Eesti, Euskara, فارسی, Suomi, Võro, Føroyskt, " +
|
||||
"Français, Arpetan, Furlan, Frysk, Gaeilge, 贛語, Gàidhlig, Galego, " +
|
||||
"Avañe'ẽ, ગુજરાતી, Gaelg, עברית, हिन्दी, Fiji Hindi, Hrvatski, " +
|
||||
"Kreyòl ayisyen, Magyar, Հայերեն, Interlingua, Bahasa Indonesia, " +
|
||||
"Ilokano, Ido, Íslenska, Italiano, 日本語, Lojban, Basa Jawa, " +
|
||||
"ქართული, Kongo, Kalaallisut, ಕನ್ನಡ, 한국어, Къарачай-Малкъар, " +
|
||||
"Ripoarisch, Kurdî, Коми, Kernewek, Кыргызча, Latina, Ladino, " +
|
||||
"Lëtzebuergesch, Limburgs, Lingála, ລາວ, Lietuvių, Latviešu, Basa " +
|
||||
"Banyumasan, Malagasy, Македонски, മലയാളം, मराठी, مازِرونی, Bahasa " +
|
||||
"Melayu, Nnapulitano, Nedersaksisch, नेपाल भाषा, Nederlands, " +
|
||||
"Norsk (nynorsk), Norsk (bokmål), Nouormand, Diné bizaad, " +
|
||||
"Occitan, Иронау, Papiamentu, Deitsch, Polski, پنجابی, پښتو, " +
|
||||
"Norfuk / Pitkern, Português, Runa Simi, Rumantsch, Romani, Română, " +
|
||||
"Русский, Саха тыла, Sardu, Sicilianu, Scots, Sámegiella, Simple " +
|
||||
"English, Slovenčina, Slovenščina, Српски / Srpski, Seeltersk, " +
|
||||
"Svenska, Kiswahili, தமிழ், తెలుగు, Тоҷикӣ, ไทย, Türkmençe, Tagalog, " +
|
||||
"Türkçe, Татарча/Tatarça, Українська, اردو, Tiếng Việt, Volapük, " +
|
||||
"Walon, Winaray, 吴语, isiXhosa, ייִדיש, Yorùbá, Zeêuws, 中文, " +
|
||||
"Bân-lâm-gú, 粵語";
|
||||
const stringTest = (module.exports.stringTest =
|
||||
"Afrikaans, Alemannisch, Aragonés, العربية, مصرى, " +
|
||||
"Asturianu, Aymar aru, Azərbaycan, Башҡорт, Boarisch, Žemaitėška, " +
|
||||
"Беларуская, Беларуская (тарашкевіца), Български, Bamanankan, " +
|
||||
"বাংলা, Brezhoneg, Bosanski, Català, Mìng-dĕ̤ng-ngṳ̄, Нохчийн, " +
|
||||
"Cebuano, ᏣᎳᎩ, Česky, Словѣ́ньскъ / ⰔⰎⰑⰂⰡⰐⰠⰔⰍⰟ, Чӑвашла, Cymraeg, " +
|
||||
"Dansk, Zazaki, ދިވެހިބަސް, Ελληνικά, Emiliàn e rumagnòl, English, " +
|
||||
"Esperanto, Español, Eesti, Euskara, فارسی, Suomi, Võro, Føroyskt, " +
|
||||
"Français, Arpetan, Furlan, Frysk, Gaeilge, 贛語, Gàidhlig, Galego, " +
|
||||
"Avañe'ẽ, ગુજરાતી, Gaelg, עברית, हिन्दी, Fiji Hindi, Hrvatski, " +
|
||||
"Kreyòl ayisyen, Magyar, Հայերեն, Interlingua, Bahasa Indonesia, " +
|
||||
"Ilokano, Ido, Íslenska, Italiano, 日本語, Lojban, Basa Jawa, " +
|
||||
"ქართული, Kongo, Kalaallisut, ಕನ್ನಡ, 한국어, Къарачай-Малкъар, " +
|
||||
"Ripoarisch, Kurdî, Коми, Kernewek, Кыргызча, Latina, Ladino, " +
|
||||
"Lëtzebuergesch, Limburgs, Lingála, ລາວ, Lietuvių, Latviešu, Basa " +
|
||||
"Banyumasan, Malagasy, Македонски, മലയാളം, मराठी, مازِرونی, Bahasa " +
|
||||
"Melayu, Nnapulitano, Nedersaksisch, नेपाल भाषा, Nederlands, " +
|
||||
"Norsk (nynorsk), Norsk (bokmål), Nouormand, Diné bizaad, " +
|
||||
"Occitan, Иронау, Papiamentu, Deitsch, Polski, پنجابی, پښتو, " +
|
||||
"Norfuk / Pitkern, Português, Runa Simi, Rumantsch, Romani, Română, " +
|
||||
"Русский, Саха тыла, Sardu, Sicilianu, Scots, Sámegiella, Simple " +
|
||||
"English, Slovenčina, Slovenščina, Српски / Srpski, Seeltersk, " +
|
||||
"Svenska, Kiswahili, தமிழ், తెలుగు, Тоҷикӣ, ไทย, Türkmençe, Tagalog, " +
|
||||
"Türkçe, Татарча/Tatarça, Українська, اردو, Tiếng Việt, Volapük, " +
|
||||
"Walon, Winaray, 吴语, isiXhosa, ייִדיש, Yorùbá, Zeêuws, 中文, " +
|
||||
"Bân-lâm-gú, 粵語");
|
||||
/*jshint +W100 */
|
||||
|
||||
var specialCharacters = module.exports.specialCharacters = 'quote: \" backslash:' +
|
||||
' forwardslash-escaped: \/ ' +
|
||||
' backspace: \b formfeed: \f newline: \n return: \r tab: ' +
|
||||
' now-all-of-them-together: "\\\/\b\n\r\t' +
|
||||
' now-a-bunch-of-junk: !@#$%&()(&%$#{}{}<><><' +
|
||||
' char-to-test-json-parsing: ]] \"]] \\" }}}{ [[[ ';
|
||||
const specialCharacters = (module.exports.specialCharacters =
|
||||
'quote: " backslash:' +
|
||||
" forwardslash-escaped: / " +
|
||||
" backspace: \b formfeed: \f newline: \n return: \r tab: " +
|
||||
' now-all-of-them-together: "\\/\b\n\r\t' +
|
||||
" now-a-bunch-of-junk: !@#$%&()(&%$#{}{}<><><" +
|
||||
' char-to-test-json-parsing: ]] "]] \\" }}}{ [[[ ');
|
||||
|
||||
var mapTestInput = module.exports.mapTestInput = {
|
||||
"a":"123", "a b":"with spaces ", "same":"same", "0":"numeric key",
|
||||
"longValue":stringTest, stringTest:"long key"
|
||||
};
|
||||
const mapTestInput = (module.exports.mapTestInput = {
|
||||
a: "123",
|
||||
"a b": "with spaces ",
|
||||
same: "same",
|
||||
"0": "numeric key",
|
||||
longValue: stringTest,
|
||||
stringTest: "long key"
|
||||
});
|
||||
|
||||
var simple = [
|
||||
['testVoid', undefined],
|
||||
['testString', 'Test'],
|
||||
['testString', ''],
|
||||
['testString', stringTest],
|
||||
['testString', specialCharacters],
|
||||
['testBool', true],
|
||||
['testBool', false],
|
||||
['testByte', 1],
|
||||
['testByte', 0],
|
||||
['testByte', -1],
|
||||
['testByte', -127],
|
||||
['testI32', -1],
|
||||
['testDouble', -5.2098523],
|
||||
['testDouble', 7.012052175215044],
|
||||
['testEnum', ttypes.Numberz.ONE],
|
||||
['testI64', 5],
|
||||
['testI64', -5],
|
||||
['testI64', 734359738368],
|
||||
['testI64', -734359738368],
|
||||
['testI64', new Int64(new Buffer([0, 0x20, 0, 0, 0, 0, 0, 1]))], // 2^53+1
|
||||
['testI64', new Int64(
|
||||
new Buffer([0xff, 0xdf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff]))], // -2^53-1
|
||||
['testTypedef', 69]
|
||||
]
|
||||
const simple = [
|
||||
["testVoid", undefined],
|
||||
["testString", "Test"],
|
||||
["testString", ""],
|
||||
["testString", stringTest],
|
||||
["testString", specialCharacters],
|
||||
["testBool", true],
|
||||
["testBool", false],
|
||||
["testByte", 1],
|
||||
["testByte", 0],
|
||||
["testByte", -1],
|
||||
["testByte", -127],
|
||||
["testI32", -1],
|
||||
["testDouble", -5.2098523],
|
||||
["testDouble", 7.012052175215044],
|
||||
["testEnum", ttypes.Numberz.ONE],
|
||||
["testI64", 5],
|
||||
["testI64", -5],
|
||||
["testI64", 734359738368],
|
||||
["testI64", -734359738368],
|
||||
["testI64", new Int64(new Buffer([0, 0x20, 0, 0, 0, 0, 0, 1]))], // 2^53+1
|
||||
[
|
||||
"testI64",
|
||||
new Int64(new Buffer([0xff, 0xdf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff]))
|
||||
], // -2^53-1
|
||||
["testTypedef", 69]
|
||||
];
|
||||
|
||||
var mapout = {};
|
||||
for (var i = 0; i < 5; ++i) {
|
||||
mapout[i] = i-10;
|
||||
const mapout = {};
|
||||
for (let i = 0; i < 5; ++i) {
|
||||
mapout[i] = i - 10;
|
||||
}
|
||||
|
||||
var deep = [
|
||||
['testList', [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]],
|
||||
const deep = [
|
||||
[
|
||||
"testList",
|
||||
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
|
||||
]
|
||||
];
|
||||
|
||||
var deepUnordered = [
|
||||
['testMap', mapout],
|
||||
['testSet', [1,2,3]],
|
||||
['testStringMap', mapTestInput]
|
||||
const deepUnordered = [
|
||||
["testMap", mapout],
|
||||
["testSet", [1, 2, 3]],
|
||||
["testStringMap", mapTestInput]
|
||||
];
|
||||
|
||||
var out = new ttypes.Xtruct({
|
||||
string_thing: 'Zero',
|
||||
const out = new ttypes.Xtruct({
|
||||
string_thing: "Zero",
|
||||
byte_thing: 1,
|
||||
i32_thing: -3,
|
||||
i64_thing: 1000000
|
||||
});
|
||||
|
||||
var out2 = new ttypes.Xtruct2();
|
||||
const out2 = new ttypes.Xtruct2();
|
||||
out2.byte_thing = 1;
|
||||
out2.struct_thing = out;
|
||||
out2.i32_thing = 5;
|
||||
|
||||
var crazy = new ttypes.Insanity({
|
||||
"userMap":{ "5":5, "8":8 },
|
||||
"xtructs":[new ttypes.Xtruct({
|
||||
"string_thing":"Goodbye4",
|
||||
"byte_thing":4,
|
||||
"i32_thing":4,
|
||||
"i64_thing":4
|
||||
}), new ttypes.Xtruct({
|
||||
"string_thing":"Hello2",
|
||||
"byte_thing":2,
|
||||
"i32_thing":2,
|
||||
"i64_thing":2
|
||||
})]
|
||||
const crazy = new ttypes.Insanity({
|
||||
userMap: { "5": 5, "8": 8 },
|
||||
xtructs: [
|
||||
new ttypes.Xtruct({
|
||||
string_thing: "Goodbye4",
|
||||
byte_thing: 4,
|
||||
i32_thing: 4,
|
||||
i64_thing: 4
|
||||
}),
|
||||
new ttypes.Xtruct({
|
||||
string_thing: "Hello2",
|
||||
byte_thing: 2,
|
||||
i32_thing: 2,
|
||||
i64_thing: 2
|
||||
})
|
||||
]
|
||||
});
|
||||
|
||||
var crazy2 = new ttypes.Insanity({
|
||||
"userMap":{ "5":5, "8":8 },
|
||||
"xtructs":[{
|
||||
"string_thing":"Goodbye4",
|
||||
"byte_thing":4,
|
||||
"i32_thing":4,
|
||||
"i64_thing":4
|
||||
}, {
|
||||
"string_thing":"Hello2",
|
||||
"byte_thing":2,
|
||||
"i32_thing":2,
|
||||
"i64_thing":2
|
||||
}]
|
||||
const crazy2 = new ttypes.Insanity({
|
||||
userMap: { "5": 5, "8": 8 },
|
||||
xtructs: [
|
||||
{
|
||||
string_thing: "Goodbye4",
|
||||
byte_thing: 4,
|
||||
i32_thing: 4,
|
||||
i64_thing: 4
|
||||
},
|
||||
{
|
||||
string_thing: "Hello2",
|
||||
byte_thing: 2,
|
||||
i32_thing: 2,
|
||||
i64_thing: 2
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
|
||||
var insanity = {
|
||||
"1":{ "2": crazy, "3": crazy },
|
||||
"2":{ "6":{ "userMap":{}, "xtructs":[] } }
|
||||
const insanity = {
|
||||
"1": { "2": crazy, "3": crazy },
|
||||
"2": { "6": { userMap: {}, xtructs: [] } }
|
||||
};
|
||||
|
||||
module.exports.simple = simple;
|
||||
|
|
24
vendor/git.apache.org/thrift.git/lib/nodejs/test/testAll.sh
generated
vendored
24
vendor/git.apache.org/thrift.git/lib/nodejs/test/testAll.sh
generated
vendored
|
@ -33,21 +33,21 @@ export NODE_PATH="${DIR}:${DIR}/../lib:${NODE_PATH}"
|
|||
|
||||
testServer()
|
||||
{
|
||||
echo " Testing $1 Client/Server with protocol $2 and transport $3 $4";
|
||||
echo " [ECMA $1] Testing $2 Client/Server with protocol $3 and transport $4 $5";
|
||||
RET=0
|
||||
if [ -n "${COVER}" ]; then
|
||||
${ISTANBUL} cover ${DIR}/server.js --dir ${REPORT_PREFIX}${COUNT} --handle-sigint -- --type $1 -p $2 -t $3 $4 &
|
||||
${ISTANBUL} cover ${DIR}/server.js --dir ${REPORT_PREFIX}${COUNT} --handle-sigint -- --type $2 -p $3 -t $4 $5 &
|
||||
COUNT=$((COUNT+1))
|
||||
else
|
||||
node ${DIR}/server.js --type $1 -p $2 -t $3 $4 &
|
||||
node ${DIR}/server.js --${1} --type $2 -p $3 -t $4 $5 &
|
||||
fi
|
||||
SERVERPID=$!
|
||||
sleep 0.1
|
||||
if [ -n "${COVER}" ]; then
|
||||
${ISTANBUL} cover ${DIR}/client.js --dir ${REPORT_PREFIX}${COUNT} -- --type $1 -p $2 -t $3 $4 || RET=1
|
||||
${ISTANBUL} cover ${DIR}/client.js --dir ${REPORT_PREFIX}${COUNT} -- --${1} --type $2 -p $3 -t $4 $5 || RET=1
|
||||
COUNT=$((COUNT+1))
|
||||
else
|
||||
node ${DIR}/client.js --type $1 -p $2 -t $3 $4 || RET=1
|
||||
node ${DIR}/client.js --${1} --type $2 -p $3 -t $4 $5 || RET=1
|
||||
fi
|
||||
kill -2 $SERVERPID || RET=1
|
||||
wait $SERVERPID
|
||||
|
@ -61,6 +61,9 @@ TESTOK=0
|
|||
|
||||
${DIR}/../../../compiler/cpp/thrift -o ${DIR} --gen js:node ${DIR}/../../../test/ThriftTest.thrift
|
||||
${DIR}/../../../compiler/cpp/thrift -o ${DIR} --gen js:node ${DIR}/../../../test/JsDeepConstructorTest.thrift
|
||||
mkdir ${DIR}/gen-nodejs-es6
|
||||
${DIR}/../../../compiler/cpp/thrift -out ${DIR}/gen-nodejs-es6 --gen js:node,es6 ${DIR}/../../../test/ThriftTest.thrift
|
||||
${DIR}/../../../compiler/cpp/thrift -out ${DIR}/gen-nodejs-es6 --gen js:node,es6 ${DIR}/../../../test/JsDeepConstructorTest.thrift
|
||||
|
||||
#unit tests
|
||||
|
||||
|
@ -71,15 +74,16 @@ node ${DIR}/deep-constructor.test.js || TESTOK=1
|
|||
|
||||
for type in tcp multiplex websocket http
|
||||
do
|
||||
|
||||
for protocol in compact binary json
|
||||
do
|
||||
|
||||
for transport in buffered framed
|
||||
do
|
||||
testServer $type $protocol $transport || TESTOK=1
|
||||
testServer $type $protocol $transport --ssl || TESTOK=1
|
||||
testServer $type $protocol $transport --promise || TESTOK=1
|
||||
for ecma_version in es5 es6
|
||||
do
|
||||
testServer $ecma_version $type $protocol $transport || TESTOK=1
|
||||
testServer $ecma_version $type $protocol $transport --ssl || TESTOK=1
|
||||
testServer $ecma_version $type $protocol $transport --callback || TESTOK=1
|
||||
done
|
||||
done
|
||||
done
|
||||
done
|
||||
|
|
409
vendor/git.apache.org/thrift.git/lib/nodejs/test/test_driver.js
generated
vendored
409
vendor/git.apache.org/thrift.git/lib/nodejs/test/test_driver.js
generated
vendored
|
@ -17,252 +17,279 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
// This is the Node.js test driver for the standard Apache Thrift
|
||||
// test service. The driver invokes every function defined in the
|
||||
// Thrift Test service with a representative range of parameters.
|
||||
//
|
||||
// The ThriftTestDriver function requires a client object
|
||||
// connected to a server hosting the Thrift Test service and
|
||||
// supports an optional callback function which is called with
|
||||
// a status message when the test is complete.
|
||||
// This is the Node.js test driver for the standard Apache Thrift
|
||||
// test service. The driver invokes every function defined in the
|
||||
// Thrift Test service with a representative range of parameters.
|
||||
//
|
||||
// The ThriftTestDriver function requires a client object
|
||||
// connected to a server hosting the Thrift Test service and
|
||||
// supports an optional callback function which is called with
|
||||
// a status message when the test is complete.
|
||||
|
||||
var test = require('tape');
|
||||
//var assert = require('assert');
|
||||
var ttypes = require('./gen-nodejs/ThriftTest_types');
|
||||
var TException = require('thrift').Thrift.TException;
|
||||
var Int64 = require('node-int64');
|
||||
var testCases = require('./test-cases');
|
||||
const test = require("tape");
|
||||
|
||||
const helpers = require("./helpers");
|
||||
const ttypes = require(`./${helpers.genPath}/ThriftTest_types`);
|
||||
const TException = require("thrift").Thrift.TException;
|
||||
const Int64 = require("node-int64");
|
||||
const testCases = require("./test-cases");
|
||||
|
||||
exports.ThriftTestDriver = function(client, callback) {
|
||||
test(
|
||||
"NodeJS Style Callback Client Tests",
|
||||
{ skip: helpers.ecmaMode === "es6" },
|
||||
function(assert) {
|
||||
const checkRecursively = makeRecursiveCheck(assert);
|
||||
|
||||
test('NodeJS Style Callback Client Tests', function(assert) {
|
||||
|
||||
var checkRecursively = makeRecursiveCheck(assert);
|
||||
|
||||
function makeAsserter(assertionFn) {
|
||||
return function(c) {
|
||||
var fnName = c[0];
|
||||
var expected = c[1];
|
||||
client[fnName](expected, function(err, actual) {
|
||||
assert.error(err, fnName + ': no callback error');
|
||||
assertionFn(actual, expected, fnName);
|
||||
})
|
||||
};
|
||||
}
|
||||
|
||||
testCases.simple.forEach(makeAsserter(function(a, e, m){
|
||||
if (a instanceof Int64) {
|
||||
var e64 = e instanceof Int64 ? e : new Int64(e);
|
||||
assert.deepEqual(a.buffer, e64.buffer, m);
|
||||
} else {
|
||||
assert.equal(a, e, m);
|
||||
function makeAsserter(assertionFn) {
|
||||
return function(c) {
|
||||
const fnName = c[0];
|
||||
const expected = c[1];
|
||||
client[fnName](expected, function(err, actual) {
|
||||
assert.error(err, fnName + ": no callback error");
|
||||
assertionFn(actual, expected, fnName);
|
||||
});
|
||||
};
|
||||
}
|
||||
}));
|
||||
testCases.deep.forEach(makeAsserter(assert.deepEqual));
|
||||
testCases.deepUnordered.forEach(makeAsserter(makeUnorderedDeepEqual(assert)));
|
||||
|
||||
var arr = [];
|
||||
for (var i = 0; i < 256; ++i) {
|
||||
arr[i] = 255 - i;
|
||||
}
|
||||
var buf = new Buffer(arr);
|
||||
client.testBinary(buf, function(err, response) {
|
||||
assert.error(err, 'testBinary: no callback error');
|
||||
assert.equal(response.length, 256, 'testBinary');
|
||||
assert.deepEqual(response, buf, 'testBinary(Buffer)');
|
||||
});
|
||||
var buf = new Buffer(arr);
|
||||
client.testBinary(buf.toString('binary'), function(err, response) {
|
||||
assert.error(err, 'testBinary: no callback error');
|
||||
assert.equal(response.length, 256, 'testBinary');
|
||||
assert.deepEqual(response, buf, 'testBinary(string)');
|
||||
});
|
||||
testCases.simple.forEach(
|
||||
makeAsserter(function(a, e, m) {
|
||||
if (a instanceof Int64) {
|
||||
const e64 = e instanceof Int64 ? e : new Int64(e);
|
||||
assert.deepEqual(a.buffer, e64.buffer, m);
|
||||
} else {
|
||||
assert.equal(a, e, m);
|
||||
}
|
||||
})
|
||||
);
|
||||
testCases.deep.forEach(makeAsserter(assert.deepEqual));
|
||||
testCases.deepUnordered.forEach(
|
||||
makeAsserter(makeUnorderedDeepEqual(assert))
|
||||
);
|
||||
|
||||
client.testMapMap(42, function(err, response) {
|
||||
var expected = {
|
||||
"4": {"1":1, "2":2, "3":3, "4":4},
|
||||
"-4": {"-4":-4, "-3":-3, "-2":-2, "-1":-1}
|
||||
};
|
||||
assert.error(err, 'testMapMap: no callback error');
|
||||
assert.deepEqual(expected, response, 'testMapMap');
|
||||
});
|
||||
|
||||
client.testStruct(testCases.out, function(err, response) {
|
||||
assert.error(err, 'testStruct: no callback error');
|
||||
checkRecursively(testCases.out, response, 'testStruct');
|
||||
});
|
||||
|
||||
client.testNest(testCases.out2, function(err, response) {
|
||||
assert.error(err, 'testNest: no callback error');
|
||||
checkRecursively(testCases.out2, response, 'testNest');
|
||||
});
|
||||
|
||||
client.testInsanity(testCases.crazy, function(err, response) {
|
||||
assert.error(err, 'testInsanity: no callback error');
|
||||
checkRecursively(testCases.insanity, response, 'testInsanity');
|
||||
});
|
||||
|
||||
client.testInsanity(testCases.crazy2, function(err, response) {
|
||||
assert.error(err, 'testInsanity2: no callback error');
|
||||
checkRecursively(testCases.insanity, response, 'testInsanity2');
|
||||
});
|
||||
|
||||
client.testException('TException', function(err, response) {
|
||||
assert.ok(err instanceof TException, 'testException: correct error type');
|
||||
assert.ok(!response, 'testException: no response');
|
||||
});
|
||||
|
||||
client.testException('Xception', function(err, response) {
|
||||
assert.ok(err instanceof ttypes.Xception, 'testException: correct error type');
|
||||
assert.ok(!response, 'testException: no response');
|
||||
assert.equal(err.errorCode, 1001, 'testException: correct error code');
|
||||
assert.equal('Xception', err.message, 'testException: correct error message');
|
||||
});
|
||||
|
||||
client.testException('no Exception', function(err, response) {
|
||||
assert.error(err, 'testException: no callback error');
|
||||
assert.ok(!response, 'testException: no response');
|
||||
});
|
||||
|
||||
client.testOneway(0, function(err, response) {
|
||||
assert.error(err, 'testOneway: no callback error');
|
||||
assert.strictEqual(response, undefined, 'testOneway: void response');
|
||||
});
|
||||
|
||||
checkOffByOne(function(done) {
|
||||
client.testI32(-1, function(err, response) {
|
||||
assert.error(err, 'checkOffByOne: no callback error');
|
||||
assert.equal(-1, response);
|
||||
assert.end();
|
||||
done();
|
||||
const arr = [];
|
||||
for (let i = 0; i < 256; ++i) {
|
||||
arr[i] = 255 - i;
|
||||
}
|
||||
let buf = new Buffer(arr);
|
||||
client.testBinary(buf, function(err, response) {
|
||||
assert.error(err, "testBinary: no callback error");
|
||||
assert.equal(response.length, 256, "testBinary");
|
||||
assert.deepEqual(response, buf, "testBinary(Buffer)");
|
||||
});
|
||||
buf = new Buffer(arr);
|
||||
client.testBinary(buf.toString("binary"), function(err, response) {
|
||||
assert.error(err, "testBinary: no callback error");
|
||||
assert.equal(response.length, 256, "testBinary");
|
||||
assert.deepEqual(response, buf, "testBinary(string)");
|
||||
});
|
||||
}, callback);
|
||||
|
||||
});
|
||||
client.testMapMap(42, function(err, response) {
|
||||
const expected = {
|
||||
"4": { "1": 1, "2": 2, "3": 3, "4": 4 },
|
||||
"-4": { "-4": -4, "-3": -3, "-2": -2, "-1": -1 }
|
||||
};
|
||||
assert.error(err, "testMapMap: no callback error");
|
||||
assert.deepEqual(expected, response, "testMapMap");
|
||||
});
|
||||
|
||||
client.testStruct(testCases.out, function(err, response) {
|
||||
assert.error(err, "testStruct: no callback error");
|
||||
checkRecursively(testCases.out, response, "testStruct");
|
||||
});
|
||||
|
||||
client.testNest(testCases.out2, function(err, response) {
|
||||
assert.error(err, "testNest: no callback error");
|
||||
checkRecursively(testCases.out2, response, "testNest");
|
||||
});
|
||||
|
||||
client.testInsanity(testCases.crazy, function(err, response) {
|
||||
assert.error(err, "testInsanity: no callback error");
|
||||
checkRecursively(testCases.insanity, response, "testInsanity");
|
||||
});
|
||||
|
||||
client.testInsanity(testCases.crazy2, function(err, response) {
|
||||
assert.error(err, "testInsanity2: no callback error");
|
||||
checkRecursively(testCases.insanity, response, "testInsanity2");
|
||||
});
|
||||
|
||||
client.testException("TException", function(err, response) {
|
||||
assert.ok(
|
||||
err instanceof TException,
|
||||
"testException: correct error type"
|
||||
);
|
||||
assert.ok(!response, "testException: no response");
|
||||
});
|
||||
|
||||
client.testException("Xception", function(err, response) {
|
||||
assert.ok(
|
||||
err instanceof ttypes.Xception,
|
||||
"testException: correct error type"
|
||||
);
|
||||
assert.ok(!response, "testException: no response");
|
||||
assert.equal(err.errorCode, 1001, "testException: correct error code");
|
||||
assert.equal(
|
||||
"Xception",
|
||||
err.message,
|
||||
"testException: correct error message"
|
||||
);
|
||||
});
|
||||
|
||||
client.testException("no Exception", function(err, response) {
|
||||
assert.error(err, "testException: no callback error");
|
||||
assert.ok(!response, "testException: no response");
|
||||
});
|
||||
|
||||
client.testOneway(0, function(err, response) {
|
||||
assert.error(err, "testOneway: no callback error");
|
||||
assert.strictEqual(response, undefined, "testOneway: void response");
|
||||
});
|
||||
|
||||
checkOffByOne(function(done) {
|
||||
client.testI32(-1, function(err, response) {
|
||||
assert.error(err, "checkOffByOne: no callback error");
|
||||
assert.equal(-1, response);
|
||||
assert.end();
|
||||
done();
|
||||
});
|
||||
}, callback);
|
||||
}
|
||||
);
|
||||
|
||||
// ES6 does not support callback style
|
||||
if (helpers.ecmaMode === "es6") {
|
||||
checkOffByOne(done => done(), callback);
|
||||
}
|
||||
};
|
||||
|
||||
exports.ThriftTestDriverPromise = function(client, callback) {
|
||||
|
||||
test('Q Promise Client Tests', function(assert) {
|
||||
|
||||
var checkRecursively = makeRecursiveCheck(assert);
|
||||
|
||||
function fail(msg) {
|
||||
return function() {
|
||||
assert.fail(msg);
|
||||
}
|
||||
}
|
||||
test("Promise Client Tests", function(assert) {
|
||||
const checkRecursively = makeRecursiveCheck(assert);
|
||||
|
||||
function makeAsserter(assertionFn) {
|
||||
return function(c) {
|
||||
var fnName = c[0];
|
||||
var expected = c[1];
|
||||
const fnName = c[0];
|
||||
const expected = c[1];
|
||||
client[fnName](expected)
|
||||
.then(function(actual) {
|
||||
assertionFn(actual, expected, fnName);
|
||||
})
|
||||
.fail(fail('fnName'));
|
||||
.catch(() => assert.fail("fnName"));
|
||||
};
|
||||
}
|
||||
|
||||
testCases.simple.forEach(makeAsserter(function(a, e, m){
|
||||
if (a instanceof Int64) {
|
||||
var e64 = e instanceof Int64 ? e : new Int64(e);
|
||||
assert.deepEqual(a.buffer, e64.buffer, m);
|
||||
} else {
|
||||
assert.equal(a, e, m);
|
||||
}
|
||||
}));
|
||||
testCases.simple.forEach(
|
||||
makeAsserter(function(a, e, m) {
|
||||
if (a instanceof Int64) {
|
||||
const e64 = e instanceof Int64 ? e : new Int64(e);
|
||||
assert.deepEqual(a.buffer, e64.buffer, m);
|
||||
} else {
|
||||
assert.equal(a, e, m);
|
||||
}
|
||||
})
|
||||
);
|
||||
testCases.deep.forEach(makeAsserter(assert.deepEqual));
|
||||
testCases.deepUnordered.forEach(makeAsserter(makeUnorderedDeepEqual(assert)));
|
||||
testCases.deepUnordered.forEach(
|
||||
makeAsserter(makeUnorderedDeepEqual(assert))
|
||||
);
|
||||
|
||||
client.testStruct(testCases.out)
|
||||
client
|
||||
.testStruct(testCases.out)
|
||||
.then(function(response) {
|
||||
checkRecursively(testCases.out, response, 'testStruct');
|
||||
checkRecursively(testCases.out, response, "testStruct");
|
||||
})
|
||||
.fail(fail('testStruct'));
|
||||
.catch(() => assert.fail("testStruct"));
|
||||
|
||||
client.testNest(testCases.out2)
|
||||
client
|
||||
.testNest(testCases.out2)
|
||||
.then(function(response) {
|
||||
checkRecursively(testCases.out2, response, 'testNest');
|
||||
checkRecursively(testCases.out2, response, "testNest");
|
||||
})
|
||||
.fail(fail('testNest'));
|
||||
.catch(() => assert.fail("testNest"));
|
||||
|
||||
client.testInsanity(testCases.crazy)
|
||||
client
|
||||
.testInsanity(testCases.crazy)
|
||||
.then(function(response) {
|
||||
checkRecursively(testCases.insanity, response, 'testInsanity');
|
||||
checkRecursively(testCases.insanity, response, "testInsanity");
|
||||
})
|
||||
.fail(fail('testInsanity'));
|
||||
.catch(() => assert.fail("testInsanity"));
|
||||
|
||||
client.testInsanity(testCases.crazy2)
|
||||
client
|
||||
.testInsanity(testCases.crazy2)
|
||||
.then(function(response) {
|
||||
checkRecursively(testCases.insanity, response, 'testInsanity2');
|
||||
checkRecursively(testCases.insanity, response, "testInsanity2");
|
||||
})
|
||||
.fail(fail('testInsanity2'));
|
||||
.catch(() => assert.fail("testInsanity2"));
|
||||
|
||||
client.testException('TException')
|
||||
.then(function(response) {
|
||||
fail('testException: TException');
|
||||
client
|
||||
.testException("TException")
|
||||
.then(function() {
|
||||
assert.fail("testException: TException");
|
||||
})
|
||||
.fail(function(err) {
|
||||
.catch(function(err) {
|
||||
assert.ok(err instanceof TException);
|
||||
});
|
||||
|
||||
client.testException('Xception')
|
||||
.then(function(response) {
|
||||
fail('testException: Xception');
|
||||
client
|
||||
.testException("Xception")
|
||||
.then(function() {
|
||||
assert.fail("testException: Xception");
|
||||
})
|
||||
.fail(function(err) {
|
||||
.catch(function(err) {
|
||||
assert.ok(err instanceof ttypes.Xception);
|
||||
assert.equal(err.errorCode, 1001);
|
||||
assert.equal('Xception', err.message);
|
||||
assert.equal("Xception", err.message);
|
||||
});
|
||||
|
||||
client.testException('no Exception')
|
||||
client
|
||||
.testException("no Exception")
|
||||
.then(function(response) {
|
||||
assert.equal(undefined, response); //void
|
||||
})
|
||||
.fail(fail('testException'));
|
||||
.catch(() => assert.fail("testException"));
|
||||
|
||||
client.testOneway(0)
|
||||
client
|
||||
.testOneway(0)
|
||||
.then(function(response) {
|
||||
assert.strictEqual(response, undefined, 'testOneway: void response')
|
||||
assert.strictEqual(response, undefined, "testOneway: void response");
|
||||
})
|
||||
.fail(fail('testOneway: should not reject'));
|
||||
.catch(() => assert.fail("testOneway: should not reject"));
|
||||
|
||||
checkOffByOne(function(done) {
|
||||
client.testI32(-1)
|
||||
client
|
||||
.testI32(-1)
|
||||
.then(function(response) {
|
||||
assert.equal(-1, response);
|
||||
assert.end();
|
||||
done();
|
||||
assert.equal(-1, response);
|
||||
assert.end();
|
||||
done();
|
||||
})
|
||||
.fail(fail('checkOffByOne'));
|
||||
.catch(() => assert.fail("checkOffByOne"));
|
||||
}, callback);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
// Helper Functions
|
||||
// =========================================================
|
||||
|
||||
function makeRecursiveCheck(assert) {
|
||||
|
||||
return function (map1, map2, msg) {
|
||||
var equal = true;
|
||||
|
||||
var equal = checkRecursively(map1, map2);
|
||||
return function(map1, map2, msg) {
|
||||
const equal = checkRecursively(map1, map2);
|
||||
|
||||
assert.ok(equal, msg);
|
||||
|
||||
// deepEqual doesn't work with fields using node-int64
|
||||
function checkRecursively(map1, map2) {
|
||||
if (typeof map1 !== 'function' && typeof map2 !== 'function') {
|
||||
if (!map1 || typeof map1 !== 'object') {
|
||||
if (typeof map1 !== "function" && typeof map2 !== "function") {
|
||||
if (!map1 || typeof map1 !== "object") {
|
||||
//Handle int64 types (which use node-int64 in Node.js JavaScript)
|
||||
if ((typeof map1 === "number") && (typeof map2 === "object") &&
|
||||
(map2.buffer) && (map2.buffer instanceof Buffer) && (map2.buffer.length === 8)) {
|
||||
var n = new Int64(map2.buffer);
|
||||
if (
|
||||
typeof map1 === "number" &&
|
||||
typeof map2 === "object" &&
|
||||
map2.buffer &&
|
||||
map2.buffer instanceof Buffer &&
|
||||
map2.buffer.length === 8
|
||||
) {
|
||||
const n = new Int64(map2.buffer);
|
||||
return map1 === n.toNumber();
|
||||
} else {
|
||||
return map1 == map2;
|
||||
|
@ -274,15 +301,14 @@ function makeRecursiveCheck(assert) {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function checkOffByOne(done, callback) {
|
||||
|
||||
var retry_limit = 30;
|
||||
var retry_interval = 100;
|
||||
var test_complete = false;
|
||||
var retrys = 0;
|
||||
const retry_limit = 30;
|
||||
const retry_interval = 100;
|
||||
let test_complete = false;
|
||||
let retrys = 0;
|
||||
|
||||
/**
|
||||
* redo a simple test after the oneway to make sure we aren't "off by one" --
|
||||
|
@ -299,14 +325,17 @@ function checkOffByOne(done, callback) {
|
|||
|
||||
//We wait up to retry_limit * retry_interval for the test suite to complete
|
||||
function TestForCompletion() {
|
||||
if(test_complete && callback) {
|
||||
if (test_complete && callback) {
|
||||
callback("Server successfully tested!");
|
||||
} else {
|
||||
if (++retrys < retry_limit) {
|
||||
setTimeout(TestForCompletion, retry_interval);
|
||||
} else if (callback) {
|
||||
callback("Server test failed to complete after " +
|
||||
(retry_limit * retry_interval / 1000) + " seconds");
|
||||
callback(
|
||||
"Server test failed to complete after " +
|
||||
(retry_limit * retry_interval) / 1000 +
|
||||
" seconds"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -317,15 +346,15 @@ function checkOffByOne(done, callback) {
|
|||
function makeUnorderedDeepEqual(assert) {
|
||||
return function(actual, expected, name) {
|
||||
assert.equal(actual.length, expected.length, name);
|
||||
for (var k in actual) {
|
||||
var found = false;
|
||||
for (var k2 in expected) {
|
||||
for (const k in actual) {
|
||||
let found = false;
|
||||
for (const k2 in expected) {
|
||||
if (actual[k] === expected[k2]) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
assert.fail('Unexpected value ' + actual[k] + ' with key ' + k);
|
||||
assert.fail("Unexpected value " + actual[k] + " with key " + k);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
129
vendor/git.apache.org/thrift.git/lib/nodejs/test/test_handler.js
generated
vendored
129
vendor/git.apache.org/thrift.git/lib/nodejs/test/test_handler.js
generated
vendored
|
@ -19,18 +19,17 @@
|
|||
|
||||
//This is the server side Node test handler for the standard
|
||||
// Apache Thrift test service.
|
||||
const helpers = require("./helpers");
|
||||
const ttypes = require(`./${helpers.genPath}/ThriftTest_types`);
|
||||
const TException = require("thrift").Thrift.TException;
|
||||
|
||||
var ttypes = require('./gen-nodejs/ThriftTest_types');
|
||||
var TException = require('thrift').Thrift.TException;
|
||||
|
||||
function makeSyncHandler(label) {
|
||||
function makeSyncHandler() {
|
||||
return function(thing) {
|
||||
//console.log(label + '(\'' + thing + '\')');
|
||||
return thing;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
var syncHandlers = {
|
||||
const syncHandlers = {
|
||||
testVoid: testVoid,
|
||||
testMapMap: testMapMap,
|
||||
testInsanity: testInsanity,
|
||||
|
@ -44,10 +43,10 @@ function makeAsyncHandler(label) {
|
|||
return function(thing, result) {
|
||||
thing = syncHandlers[label](thing);
|
||||
result(null, thing);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
var asyncHandlers = {
|
||||
const asyncHandlers = {
|
||||
testVoid: testVoidAsync,
|
||||
testMulti: testMultiAsync,
|
||||
testException: testExceptionAsync,
|
||||
|
@ -55,22 +54,22 @@ var asyncHandlers = {
|
|||
testOneway: testOnewayAsync
|
||||
};
|
||||
|
||||
var identityHandlers = [
|
||||
'testString',
|
||||
'testBool',
|
||||
'testByte',
|
||||
'testI32',
|
||||
'testI64',
|
||||
'testDouble',
|
||||
'testBinary',
|
||||
'testStruct',
|
||||
'testNest',
|
||||
'testMap',
|
||||
'testStringMap',
|
||||
'testSet',
|
||||
'testList',
|
||||
'testEnum',
|
||||
'testTypedef'
|
||||
const identityHandlers = [
|
||||
"testString",
|
||||
"testBool",
|
||||
"testByte",
|
||||
"testI32",
|
||||
"testI64",
|
||||
"testDouble",
|
||||
"testBinary",
|
||||
"testStruct",
|
||||
"testNest",
|
||||
"testMap",
|
||||
"testStringMap",
|
||||
"testSet",
|
||||
"testList",
|
||||
"testEnum",
|
||||
"testTypedef"
|
||||
];
|
||||
|
||||
function testVoid() {
|
||||
|
@ -81,13 +80,11 @@ function testVoidAsync(result) {
|
|||
result(testVoid());
|
||||
}
|
||||
|
||||
function testMapMap(hello) {
|
||||
//console.log('testMapMap(' + hello + ')');
|
||||
|
||||
var mapmap = [];
|
||||
var pos = [];
|
||||
var neg = [];
|
||||
for (var i = 1; i < 5; i++) {
|
||||
function testMapMap() {
|
||||
const mapmap = [];
|
||||
const pos = [];
|
||||
const neg = [];
|
||||
for (let i = 1; i < 5; i++) {
|
||||
pos[i] = i;
|
||||
neg[-i] = -i;
|
||||
}
|
||||
|
@ -102,16 +99,16 @@ function testInsanity(argument) {
|
|||
//console.log(argument);
|
||||
//console.log(')');
|
||||
|
||||
var first_map = [];
|
||||
var second_map = [];
|
||||
const first_map = [];
|
||||
const second_map = [];
|
||||
|
||||
first_map[ttypes.Numberz.TWO] = argument;
|
||||
first_map[ttypes.Numberz.THREE] = argument;
|
||||
|
||||
var looney = new ttypes.Insanity();
|
||||
const looney = new ttypes.Insanity();
|
||||
second_map[ttypes.Numberz.SIX] = looney;
|
||||
|
||||
var insane = [];
|
||||
const insane = [];
|
||||
insane[1] = first_map;
|
||||
insane[2] = second_map;
|
||||
|
||||
|
@ -120,11 +117,11 @@ function testInsanity(argument) {
|
|||
return insane;
|
||||
}
|
||||
|
||||
function testMulti(arg0, arg1, arg2, arg3, arg4, arg5) {
|
||||
function testMulti(arg0, arg1, arg2) {
|
||||
//console.log('testMulti()');
|
||||
|
||||
var hello = new ttypes.Xtruct();
|
||||
hello.string_thing = 'Hello2';
|
||||
const hello = new ttypes.Xtruct();
|
||||
hello.string_thing = "Hello2";
|
||||
hello.byte_thing = arg0;
|
||||
hello.i32_thing = arg1;
|
||||
hello.i64_thing = arg2;
|
||||
|
@ -132,18 +129,18 @@ function testMulti(arg0, arg1, arg2, arg3, arg4, arg5) {
|
|||
}
|
||||
|
||||
function testMultiAsync(arg0, arg1, arg2, arg3, arg4, arg5, result) {
|
||||
var hello = testMulti(arg0, arg1, arg2, arg3, arg4, arg5);
|
||||
const hello = testMulti(arg0, arg1, arg2, arg3, arg4, arg5);
|
||||
result(null, hello);
|
||||
}
|
||||
|
||||
function testException(arg) {
|
||||
//console.log('testException('+arg+')');
|
||||
if (arg === 'Xception') {
|
||||
var x = new ttypes.Xception();
|
||||
if (arg === "Xception") {
|
||||
const x = new ttypes.Xception();
|
||||
x.errorCode = 1001;
|
||||
x.message = arg;
|
||||
throw x;
|
||||
} else if (arg === 'TException') {
|
||||
} else if (arg === "TException") {
|
||||
throw new TException(arg);
|
||||
} else {
|
||||
return;
|
||||
|
@ -152,12 +149,12 @@ function testException(arg) {
|
|||
|
||||
function testExceptionAsync(arg, result) {
|
||||
//console.log('testException('+arg+')');
|
||||
if (arg === 'Xception') {
|
||||
var x = new ttypes.Xception();
|
||||
if (arg === "Xception") {
|
||||
const x = new ttypes.Xception();
|
||||
x.errorCode = 1001;
|
||||
x.message = arg;
|
||||
result(x);
|
||||
} else if (arg === 'TException') {
|
||||
} else if (arg === "TException") {
|
||||
result(new TException(arg));
|
||||
} else {
|
||||
result(null);
|
||||
|
@ -166,49 +163,48 @@ function testExceptionAsync(arg, result) {
|
|||
|
||||
function testMultiException(arg0, arg1) {
|
||||
//console.log('testMultiException(' + arg0 + ', ' + arg1 + ')');
|
||||
if (arg0 === ('Xception')) {
|
||||
var x = new ttypes.Xception();
|
||||
if (arg0 === "Xception") {
|
||||
const x = new ttypes.Xception();
|
||||
x.errorCode = 1001;
|
||||
x.message = 'This is an Xception';
|
||||
x.message = "This is an Xception";
|
||||
throw x;
|
||||
} else if (arg0 === ('Xception2')) {
|
||||
var x2 = new ttypes.Xception2();
|
||||
} else if (arg0 === "Xception2") {
|
||||
const x2 = new ttypes.Xception2();
|
||||
x2.errorCode = 2002;
|
||||
x2.struct_thing = new ttypes.Xtruct();
|
||||
x2.struct_thing.string_thing = 'This is an Xception2';
|
||||
x2.struct_thing.string_thing = "This is an Xception2";
|
||||
throw x2;
|
||||
}
|
||||
|
||||
var res = new ttypes.Xtruct();
|
||||
const res = new ttypes.Xtruct();
|
||||
res.string_thing = arg1;
|
||||
return res;
|
||||
}
|
||||
|
||||
function testMultiExceptionAsync(arg0, arg1, result) {
|
||||
//console.log('testMultiException(' + arg0 + ', ' + arg1 + ')');
|
||||
if (arg0 === ('Xception')) {
|
||||
var x = new ttypes.Xception();
|
||||
if (arg0 === "Xception") {
|
||||
const x = new ttypes.Xception();
|
||||
x.errorCode = 1001;
|
||||
x.message = 'This is an Xception';
|
||||
x.message = "This is an Xception";
|
||||
result(x);
|
||||
} else if (arg0 === ('Xception2')) {
|
||||
var x2 = new ttypes.Xception2();
|
||||
} else if (arg0 === "Xception2") {
|
||||
const x2 = new ttypes.Xception2();
|
||||
x2.errorCode = 2002;
|
||||
x2.struct_thing = new ttypes.Xtruct();
|
||||
x2.struct_thing.string_thing = 'This is an Xception2';
|
||||
x2.struct_thing.string_thing = "This is an Xception2";
|
||||
result(x2);
|
||||
} else {
|
||||
var res = new ttypes.Xtruct();
|
||||
const res = new ttypes.Xtruct();
|
||||
res.string_thing = arg1;
|
||||
result(null, res);
|
||||
}
|
||||
}
|
||||
|
||||
function testOneway(sleepFor) {
|
||||
//console.log('testOneway(' + sleepFor + ') => JavaScript (like Rust) never sleeps!');
|
||||
}
|
||||
//console.log('testOneway(' + sleepFor + ') => JavaScript (like Rust) never sleeps!');
|
||||
function testOneway() {}
|
||||
|
||||
function testOnewayAsync(sleepFor, result) {
|
||||
function testOnewayAsync(sleepFor) {
|
||||
testOneway(sleepFor);
|
||||
}
|
||||
|
||||
|
@ -217,11 +213,8 @@ identityHandlers.forEach(function(label) {
|
|||
asyncHandlers[label] = makeAsyncHandler(label);
|
||||
});
|
||||
|
||||
['testMapMap', 'testInsanity'].forEach(function(label) {
|
||||
["testMapMap", "testInsanity"].forEach(function(label) {
|
||||
asyncHandlers[label] = makeAsyncHandler(label);
|
||||
});
|
||||
|
||||
exports.ThriftTestHandler = asyncHandlers;
|
||||
|
||||
exports.AsyncThriftTestHandler = asyncHandlers;
|
||||
exports.SyncThriftTestHandler = asyncHandlers;
|
||||
|
|
1
vendor/git.apache.org/thrift.git/lib/nodets/.gitignore
generated
vendored
Normal file
1
vendor/git.apache.org/thrift.git/lib/nodets/.gitignore
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
test-compiled/
|
45
vendor/git.apache.org/thrift.git/lib/nodets/Makefile.am
generated
vendored
Executable file
45
vendor/git.apache.org/thrift.git/lib/nodets/Makefile.am
generated
vendored
Executable file
|
@ -0,0 +1,45 @@
|
|||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
# We call npm twice to work around npm issues
|
||||
|
||||
stubs: $(top_srcdir)/test/ThriftTest.thrift
|
||||
mkdir -p test-compiled
|
||||
$(THRIFT) --gen js:node,ts -o test/ $(top_srcdir)/test/ThriftTest.thrift && $(THRIFT) --gen js:node,ts -o test-compiled $(top_srcdir)/test/ThriftTest.thrift
|
||||
|
||||
ts-compile: stubs
|
||||
mkdir -p test-compiled
|
||||
../../node_modules/typescript/bin/tsc --outDir test-compiled/ --project test/tsconfig.json
|
||||
|
||||
deps: $(top_srcdir)/package.json
|
||||
$(NPM) install $(top_srcdir)/ || $(NPM) install $(top_srcdir)/
|
||||
|
||||
all-local: deps ts-compile
|
||||
|
||||
precross: deps stubs ts-compile
|
||||
|
||||
check: deps ts-compile
|
||||
cd $(top_srcdir) && $(NPM) run test-ts && cd lib/nodets
|
||||
|
||||
clean-local:
|
||||
$(RM) -r test/gen-nodejs
|
||||
$(RM) -r $(top_srcdir)/node_modules
|
||||
$(RM) -r test-compiled
|
||||
|
||||
EXTRA_DIST = \
|
||||
test \
|
||||
coding_standards.md
|
1
vendor/git.apache.org/thrift.git/lib/nodets/coding_standards.md
generated
vendored
Normal file
1
vendor/git.apache.org/thrift.git/lib/nodets/coding_standards.md
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
Please follow [General Coding Standards](/doc/coding_standards.md)
|
63
vendor/git.apache.org/thrift.git/lib/nodets/test/client.ts
generated
vendored
Normal file
63
vendor/git.apache.org/thrift.git/lib/nodets/test/client.ts
generated
vendored
Normal file
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import assert = require("assert");
|
||||
import thrift = require("thrift");
|
||||
import Thrift = thrift.Thrift;
|
||||
import ThriftTest = require("./gen-nodejs/ThriftTest");
|
||||
import test_driver = require("./test_driver");
|
||||
import ThriftTestDriver = test_driver.ThriftTestDriver;
|
||||
import ThriftTestDriverPromise = test_driver.ThriftTestDriverPromise;
|
||||
|
||||
// var program = require("commander");
|
||||
import * as program from "commander";
|
||||
|
||||
program
|
||||
.option("--port <port>", "Set thrift server port number to connect", 9090)
|
||||
.option("--promise", "test with promise style functions")
|
||||
.option("--protocol", "Set thrift protocol (binary) [protocol]")
|
||||
.parse(process.argv);
|
||||
|
||||
var port: number = program.port;
|
||||
var promise = program.promise;
|
||||
|
||||
var options = {
|
||||
transport: Thrift.TBufferedTransport,
|
||||
protocol: Thrift.TBinaryProtocol
|
||||
};
|
||||
|
||||
var testDriver = promise ? ThriftTestDriverPromise : ThriftTestDriver;
|
||||
|
||||
var connection = thrift.createConnection("localhost", port, options);
|
||||
|
||||
connection.on("error", function(err: string) {
|
||||
assert(false, err);
|
||||
});
|
||||
|
||||
var client = thrift.createClient(ThriftTest.Client, connection);
|
||||
runTests();
|
||||
|
||||
function runTests() {
|
||||
testDriver(client, function (status: string) {
|
||||
console.log(status);
|
||||
process.exit(0);
|
||||
});
|
||||
}
|
||||
|
||||
exports.expressoTest = function() {};
|
18
vendor/git.apache.org/thrift.git/lib/nodets/test/runClient.sh
generated
vendored
Executable file
18
vendor/git.apache.org/thrift.git/lib/nodets/test/runClient.sh
generated
vendored
Executable file
|
@ -0,0 +1,18 @@
|
|||
#! /bin/sh
|
||||
|
||||
DIR="$( cd "$( dirname "$0" )" && pwd )"
|
||||
|
||||
mkdir -p $DIR/../test-compiled
|
||||
|
||||
COMPILEDDIR="$(cd $DIR && cd ../test-compiled && pwd)"
|
||||
export NODE_PATH="${DIR}:${DIR}/../../nodejs/lib:${NODE_PATH}"
|
||||
|
||||
compile()
|
||||
{
|
||||
#generating thrift code
|
||||
${DIR}/../../../compiler/cpp/thrift -o ${DIR} --gen js:node,ts ${DIR}/../../../test/ThriftTest.thrift
|
||||
${DIR}/../../../compiler/cpp/thrift -o ${COMPILEDDIR} --gen js:node,ts ${DIR}/../../../test/ThriftTest.thrift
|
||||
}
|
||||
compile
|
||||
|
||||
node ${COMPILEDDIR}/client.js $*
|
20
vendor/git.apache.org/thrift.git/lib/nodets/test/runServer.sh
generated
vendored
Executable file
20
vendor/git.apache.org/thrift.git/lib/nodets/test/runServer.sh
generated
vendored
Executable file
|
@ -0,0 +1,20 @@
|
|||
#! /bin/sh
|
||||
|
||||
DIR="$( cd "$( dirname "$0" )" && pwd )"
|
||||
|
||||
mkdir -p $DIR/../test-compiled
|
||||
|
||||
COMPILEDDIR="$(cd $DIR && cd ../test-compiled && pwd)"
|
||||
export NODE_PATH="${DIR}:${DIR}/../../nodejs/lib:${NODE_PATH}"
|
||||
|
||||
compile()
|
||||
{
|
||||
#generating thrift code
|
||||
${DIR}/../../../compiler/cpp/thrift -o ${DIR} --gen js:node,ts ${DIR}/../../../test/ThriftTest.thrift
|
||||
${DIR}/../../../compiler/cpp/thrift -o ${COMPILEDDIR} --gen js:node,ts ${DIR}/../../../test/ThriftTest.thrift
|
||||
}
|
||||
compile
|
||||
|
||||
node ${COMPILEDDIR}/server.js $*
|
||||
|
||||
|
26
vendor/git.apache.org/thrift.git/lib/nodets/test/server.ts
generated
vendored
Normal file
26
vendor/git.apache.org/thrift.git/lib/nodets/test/server.ts
generated
vendored
Normal file
|
@ -0,0 +1,26 @@
|
|||
import thrift = require("thrift");
|
||||
var program = require('commander');
|
||||
import ThriftTest = require('./gen-nodejs/ThriftTest');
|
||||
import test_handler = require('./test_handler');
|
||||
|
||||
|
||||
program
|
||||
.option('--port <port>', 'Set thrift server port', 9090)
|
||||
.option('--promise', 'test with promise style functions')
|
||||
.option('--protocol', '"Set thrift protocol (binary) [protocol]"')
|
||||
.parse(process.argv);
|
||||
|
||||
var port: number = program.port;
|
||||
|
||||
var options: thrift.ServerOptions = {
|
||||
transport: thrift.TBufferedTransport,
|
||||
protocol: thrift.TBinaryProtocol
|
||||
};
|
||||
|
||||
var server: thrift.Server;
|
||||
if (program.promise) {
|
||||
server = thrift.createServer(ThriftTest.Processor, new test_handler.AsyncThriftTestHandler(), options);
|
||||
} else {
|
||||
server = thrift.createServer(ThriftTest.Processor, new test_handler.SyncThriftTestHandler(), options);
|
||||
}
|
||||
server.listen(port);
|
113
vendor/git.apache.org/thrift.git/lib/nodets/test/test-cases.ts
generated
vendored
Normal file
113
vendor/git.apache.org/thrift.git/lib/nodets/test/test-cases.ts
generated
vendored
Normal file
|
@ -0,0 +1,113 @@
|
|||
'use strict';
|
||||
|
||||
import ttypes = require('./gen-nodejs/ThriftTest_types');
|
||||
|
||||
//all Languages in UTF-8
|
||||
/*jshint -W100 */
|
||||
export var stringTest = "Afrikaans, Alemannisch, Aragonés, العربية, مصرى, " +
|
||||
"Asturianu, Aymar aru, Azərbaycan, Башҡорт, Boarisch, Žemaitėška, " +
|
||||
"Беларуская, Беларуская (тарашкевіца), Български, Bamanankan, " +
|
||||
"বাংলা, Brezhoneg, Bosanski, Català, Mìng-dĕ̤ng-ngṳ̄, Нохчийн, " +
|
||||
"Cebuano, ᏣᎳᎩ, Česky, Словѣ́ньскъ / ⰔⰎⰑⰂⰡⰐⰠⰔⰍⰟ, Чӑвашла, Cymraeg, " +
|
||||
"Dansk, Zazaki, ދިވެހިބަސް, Ελληνικά, Emiliàn e rumagnòl, English, " +
|
||||
"Esperanto, Español, Eesti, Euskara, فارسی, Suomi, Võro, Føroyskt, " +
|
||||
"Français, Arpetan, Furlan, Frysk, Gaeilge, 贛語, Gàidhlig, Galego, " +
|
||||
"Avañe'ẽ, ગુજરાતી, Gaelg, עברית, हिन्दी, Fiji Hindi, Hrvatski, " +
|
||||
"Kreyòl ayisyen, Magyar, Հայերեն, Interlingua, Bahasa Indonesia, " +
|
||||
"Ilokano, Ido, Íslenska, Italiano, 日本語, Lojban, Basa Jawa, " +
|
||||
"ქართული, Kongo, Kalaallisut, ಕನ್ನಡ, 한국어, Къарачай-Малкъар, " +
|
||||
"Ripoarisch, Kurdî, Коми, Kernewek, Кыргызча, Latina, Ladino, " +
|
||||
"Lëtzebuergesch, Limburgs, Lingála, ລາວ, Lietuvių, Latviešu, Basa " +
|
||||
"Banyumasan, Malagasy, Македонски, മലയാളം, मराठी, مازِرونی, Bahasa " +
|
||||
"Melayu, Nnapulitano, Nedersaksisch, नेपाल भाषा, Nederlands, " +
|
||||
"Norsk (nynorsk), Norsk (bokmål), Nouormand, Diné bizaad, " +
|
||||
"Occitan, Иронау, Papiamentu, Deitsch, Polski, پنجابی, پښتو, " +
|
||||
"Norfuk / Pitkern, Português, Runa Simi, Rumantsch, Romani, Română, " +
|
||||
"Русский, Саха тыла, Sardu, Sicilianu, Scots, Sámegiella, Simple " +
|
||||
"English, Slovenčina, Slovenščina, Српски / Srpski, Seeltersk, " +
|
||||
"Svenska, Kiswahili, தமிழ், తెలుగు, Тоҷикӣ, ไทย, Türkmençe, Tagalog, " +
|
||||
"Türkçe, Татарча/Tatarça, Українська, اردو, Tiếng Việt, Volapük, " +
|
||||
"Walon, Winaray, 吴语, isiXhosa, ייִדיש, Yorùbá, Zeêuws, 中文, " +
|
||||
"Bân-lâm-gú, 粵語";
|
||||
/*jshint +W100 */
|
||||
|
||||
export var specialCharacters = 'quote: \" backslash:' +
|
||||
' forwardslash-escaped: \/ ' +
|
||||
' backspace: \b formfeed: \f newline: \n return: \r tab: ' +
|
||||
' now-all-of-them-together: "\\\/\b\n\r\t' +
|
||||
' now-a-bunch-of-junk: !@#$%&()(&%$#{}{}<><><' +
|
||||
' char-to-test-json-parsing: ]] \"]] \\" }}}{ [[[ ';
|
||||
|
||||
export var mapTestInput = {
|
||||
"a":"123", "a b":"with spaces ", "same":"same", "0":"numeric key",
|
||||
"longValue":stringTest, stringTest:"long key"
|
||||
};
|
||||
|
||||
export var simple = [
|
||||
['testVoid', undefined],
|
||||
['testString', 'Test'],
|
||||
['testString', ''],
|
||||
['testString', stringTest],
|
||||
['testString', specialCharacters],
|
||||
['testByte', 1],
|
||||
['testByte', 0],
|
||||
['testByte', -1],
|
||||
['testByte', -127],
|
||||
['testI32', -1],
|
||||
['testDouble', -5.2098523],
|
||||
['testDouble', 7.012052175215044],
|
||||
['testEnum', ttypes.Numberz.ONE]
|
||||
];
|
||||
|
||||
export var simpleLoose = [
|
||||
['testI64', 5],
|
||||
['testI64', -5],
|
||||
['testI64', 734359738368],
|
||||
['testI64', -34359738368],
|
||||
['testI64', -734359738368],
|
||||
['testTypedef', 69]
|
||||
]
|
||||
|
||||
var mapout: {[key: number]: number; } = {};
|
||||
for (var i = 0; i < 5; ++i) {
|
||||
mapout[i] = i-10;
|
||||
}
|
||||
|
||||
export var deep = [
|
||||
['testMap', mapout],
|
||||
['testSet', [1,2,3]],
|
||||
['testList', [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]],
|
||||
['testStringMap', mapTestInput]
|
||||
];
|
||||
|
||||
export var out = new ttypes.Xtruct({
|
||||
string_thing: 'Zero',
|
||||
byte_thing: 1,
|
||||
i32_thing: -3,
|
||||
i64_thing: 1000000
|
||||
});
|
||||
|
||||
export var out2 = new ttypes.Xtruct2();
|
||||
out2.byte_thing = 1;
|
||||
out2.struct_thing = out;
|
||||
out2.i32_thing = 5;
|
||||
|
||||
export var crazy = new ttypes.Insanity({
|
||||
"userMap":{ "5":5, "8":8 },
|
||||
"xtructs":[new ttypes.Xtruct({
|
||||
"string_thing":"Goodbye4",
|
||||
"byte_thing":4,
|
||||
"i32_thing":4,
|
||||
"i64_thing":4
|
||||
}), new ttypes.Xtruct({
|
||||
"string_thing":"Hello2",
|
||||
"byte_thing":2,
|
||||
"i32_thing":2,
|
||||
"i64_thing":2
|
||||
})]
|
||||
});
|
||||
|
||||
export var insanity: any = {
|
||||
"1":{ "2": crazy, "3": crazy },
|
||||
"2":{ "6":{ "userMap":{}, "xtructs":[] } }
|
||||
};
|
38
vendor/git.apache.org/thrift.git/lib/nodets/test/testAll.sh
generated
vendored
Executable file
38
vendor/git.apache.org/thrift.git/lib/nodets/test/testAll.sh
generated
vendored
Executable file
|
@ -0,0 +1,38 @@
|
|||
#! /bin/sh
|
||||
|
||||
DIR="$( cd "$( dirname "$0" )" && pwd )"
|
||||
|
||||
mkdir -p $DIR/../test-compiled
|
||||
|
||||
COMPILEDDIR="$(cd $DIR && cd ../test-compiled && pwd)"
|
||||
export NODE_PATH="${DIR}:${DIR}/../../nodejs/lib:${NODE_PATH}"
|
||||
|
||||
compile()
|
||||
{
|
||||
#generating thrift code
|
||||
${DIR}/../../../compiler/cpp/thrift -o ${DIR} --gen js:node,ts ${DIR}/../../../test/ThriftTest.thrift
|
||||
${DIR}/../../../compiler/cpp/thrift -o ${COMPILEDDIR} --gen js:node,ts ${DIR}/../../../test/ThriftTest.thrift
|
||||
|
||||
tsc --outDir $COMPILEDDIR --project $DIR/tsconfig.json
|
||||
}
|
||||
compile
|
||||
|
||||
testServer()
|
||||
{
|
||||
echo "start server $1"
|
||||
RET=0
|
||||
node ${COMPILEDDIR}/server.js $1 &
|
||||
SERVERPID=$!
|
||||
sleep 1
|
||||
echo "start client $1"
|
||||
node ${COMPILEDDIR}/client.js $1 || RET=1
|
||||
kill -2 $SERVERPID || RET=1
|
||||
return $RET
|
||||
}
|
||||
|
||||
#integration tests
|
||||
|
||||
testServer || TESTOK=1
|
||||
testServer --promise || TESTOK=1
|
||||
|
||||
exit $TESTOK
|
278
vendor/git.apache.org/thrift.git/lib/nodets/test/test_driver.ts
generated
vendored
Normal file
278
vendor/git.apache.org/thrift.git/lib/nodets/test/test_driver.ts
generated
vendored
Normal file
|
@ -0,0 +1,278 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* 'License'); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
// This is the Node.js test driver for the standard Apache Thrift
|
||||
// test service. The driver invokes every function defined in the
|
||||
// Thrift Test service with a representative range of parameters.
|
||||
//
|
||||
// The ThriftTestDriver function requires a client object
|
||||
// connected to a server hosting the Thrift Test service and
|
||||
// supports an optional callback function which is called with
|
||||
// a status message when the test is complete.
|
||||
|
||||
import test = require("tape");
|
||||
import ttypes = require("./gen-nodejs/ThriftTest_types");
|
||||
import ThriftTest = require("./gen-nodejs/ThriftTest");
|
||||
import thrift = require("thrift");
|
||||
import Q = thrift.Q;
|
||||
import TException = thrift.Thrift.TException;
|
||||
var Int64 = require("node-int64");
|
||||
import testCases = require("./test-cases");
|
||||
|
||||
export function ThriftTestDriver(client: ThriftTest.Client, callback: (status: string) => void) {
|
||||
|
||||
test("NodeJS Style Callback Client Tests", function(assert) {
|
||||
|
||||
var checkRecursively = makeRecursiveCheck(assert);
|
||||
|
||||
function makeAsserter(assertionFn: (a: any, b: any, msg?: string) => void) {
|
||||
return function(c: (string | any)[]) {
|
||||
var fnName = c[0];
|
||||
var expected = c[1];
|
||||
(<any>client)[fnName](expected, function(err: any, actual: any) {
|
||||
assert.error(err, fnName + ": no callback error");
|
||||
assertionFn(actual, expected, fnName);
|
||||
})
|
||||
};
|
||||
}
|
||||
|
||||
testCases.simple.forEach(makeAsserter(assert.equal));
|
||||
testCases.simpleLoose.forEach(makeAsserter(function(a, e, m){
|
||||
assert.ok(a == e, m);
|
||||
}));
|
||||
testCases.deep.forEach(makeAsserter(assert.deepEqual));
|
||||
|
||||
client.testMapMap(42, function(err, response) {
|
||||
var expected: typeof response = {
|
||||
"4": {"1":1, "2":2, "3":3, "4":4},
|
||||
"-4": {"-4":-4, "-3":-3, "-2":-2, "-1":-1}
|
||||
};
|
||||
assert.error(err, 'testMapMap: no callback error');
|
||||
assert.deepEqual(expected, response, "testMapMap");
|
||||
});
|
||||
|
||||
client.testStruct(testCases.out, function(err, response) {
|
||||
assert.error(err, "testStruct: no callback error");
|
||||
checkRecursively(testCases.out, response, "testStruct");
|
||||
});
|
||||
|
||||
client.testNest(testCases.out2, function(err, response) {
|
||||
assert.error(err, "testNest: no callback error");
|
||||
checkRecursively(testCases.out2, response, "testNest");
|
||||
});
|
||||
|
||||
client.testInsanity(testCases.crazy, function(err, response) {
|
||||
assert.error(err, "testInsanity: no callback error");
|
||||
checkRecursively(testCases.insanity, response, "testInsanity");
|
||||
});
|
||||
|
||||
client.testException("TException", function(err, response) {
|
||||
assert.ok(err instanceof TException, 'testException: correct error type');
|
||||
assert.ok(!Boolean(response), 'testException: no response');
|
||||
});
|
||||
|
||||
client.testException("Xception", function(err, response) {
|
||||
assert.ok(err instanceof ttypes.Xception, 'testException: correct error type');
|
||||
assert.ok(!Boolean(response), 'testException: no response');
|
||||
assert.equal(err.errorCode, 1001, 'testException: correct error code');
|
||||
assert.equal('Xception', err.message, 'testException: correct error message');
|
||||
});
|
||||
|
||||
client.testException("no Exception", function(err, response) {
|
||||
assert.error(err, 'testException: no callback error');
|
||||
assert.ok(!Boolean(response), 'testException: no response');
|
||||
});
|
||||
|
||||
client.testOneway(0, function(err, response) {
|
||||
assert.error(err, 'testOneway: no callback error');
|
||||
assert.strictEqual(response, undefined, 'testOneway: void response');
|
||||
});
|
||||
|
||||
checkOffByOne(function(done) {
|
||||
client.testI32(-1, function(err, response) {
|
||||
assert.error(err, "checkOffByOne: no callback error");
|
||||
assert.equal(-1, response);
|
||||
assert.end();
|
||||
done();
|
||||
});
|
||||
}, callback);
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
export function ThriftTestDriverPromise(client: ThriftTest.Client, callback: (status: string) => void) {
|
||||
|
||||
test("Q Promise Client Tests", function(assert) {
|
||||
|
||||
var checkRecursively = makeRecursiveCheck(assert);
|
||||
|
||||
function fail(msg: string) {
|
||||
return function(error, response) {
|
||||
if (error !== null) {
|
||||
assert.fail(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function makeAsserter(assertionFn: (a: any, b: any, msg?: string) => void) {
|
||||
return function(c: (string | any)[]) {
|
||||
var fnName = c[0];
|
||||
var expected = c[1];
|
||||
(<any>client)[fnName](expected)
|
||||
.then(function(actual: any) {
|
||||
assertionFn(actual, expected, fnName);
|
||||
})
|
||||
.fail(fail("fnName"));
|
||||
};
|
||||
}
|
||||
|
||||
testCases.simple.forEach(makeAsserter(assert.equal));
|
||||
testCases.simpleLoose.forEach(makeAsserter(function(a, e, m){
|
||||
assert.ok(a == e, m);
|
||||
}));
|
||||
testCases.deep.forEach(makeAsserter(assert.deepEqual));
|
||||
|
||||
Q.resolve(client.testStruct(testCases.out))
|
||||
.then(function(response) {
|
||||
checkRecursively(testCases.out, response, "testStruct");
|
||||
})
|
||||
.fail(fail("testStruct"));
|
||||
|
||||
Q.resolve(client.testNest(testCases.out2))
|
||||
.then(function(response) {
|
||||
checkRecursively(testCases.out2, response, "testNest");
|
||||
})
|
||||
.fail(fail("testNest"));
|
||||
|
||||
Q.resolve(client.testInsanity(testCases.crazy))
|
||||
.then(function(response) {
|
||||
checkRecursively(testCases.insanity, response, "testInsanity");
|
||||
})
|
||||
.fail(fail("testInsanity"));
|
||||
|
||||
Q.resolve(client.testException("TException"))
|
||||
.then(function(response) {
|
||||
fail("testException: TException");
|
||||
})
|
||||
.fail(function(err) {
|
||||
assert.ok(err instanceof TException);
|
||||
});
|
||||
|
||||
Q.resolve(client.testException("Xception"))
|
||||
.then(function(response) {
|
||||
fail("testException: Xception");
|
||||
})
|
||||
.fail(function(err) {
|
||||
assert.ok(err instanceof ttypes.Xception);
|
||||
assert.equal(err.errorCode, 1001);
|
||||
assert.equal("Xception", err.message);
|
||||
});
|
||||
|
||||
Q.resolve(client.testException("no Exception"))
|
||||
.then(function(response) {
|
||||
assert.equal(undefined, response); //void
|
||||
})
|
||||
.fail(fail("testException"));
|
||||
|
||||
client.testOneway(0, fail("testOneway: should not answer"));
|
||||
|
||||
checkOffByOne(function(done) {
|
||||
Q.resolve(client.testI32(-1))
|
||||
.then(function(response) {
|
||||
assert.equal(-1, response);
|
||||
assert.end();
|
||||
done();
|
||||
})
|
||||
.fail(fail("checkOffByOne"));
|
||||
}, callback);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
// Helper Functions
|
||||
// =========================================================
|
||||
|
||||
function makeRecursiveCheck(assert: test.Test) {
|
||||
|
||||
return function (map1: any, map2: any, msg: string) {
|
||||
var equal = true;
|
||||
|
||||
var equal = checkRecursively(map1, map2);
|
||||
|
||||
assert.ok(equal, msg);
|
||||
|
||||
// deepEqual doesn't work with fields using node-int64
|
||||
function checkRecursively(map1: any, map2: any) : boolean {
|
||||
if (!(typeof map1 !== "function" && typeof map2 !== "function")) {
|
||||
return false;
|
||||
}
|
||||
if (!map1 || typeof map1 !== "object") {
|
||||
//Handle int64 types (which use node-int64 in Node.js JavaScript)
|
||||
if ((typeof map1 === "number") && (typeof map2 === "object") &&
|
||||
(map2.buffer) && (map2.buffer instanceof Buffer) && (map2.buffer.length === 8)) {
|
||||
var n = new Int64(map2.buffer);
|
||||
return map1 === n.toNumber();
|
||||
} else {
|
||||
return map1 == map2;
|
||||
}
|
||||
} else {
|
||||
return Object.keys(map1).every(function(key) {
|
||||
return checkRecursively(map1[key], map2[key]);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function checkOffByOne(done: (callback: () => void) => void, callback: (message: string) => void) {
|
||||
|
||||
var retry_limit = 30;
|
||||
var retry_interval = 100;
|
||||
var test_complete = false;
|
||||
var retrys = 0;
|
||||
|
||||
/**
|
||||
* redo a simple test after the oneway to make sure we aren't "off by one" --
|
||||
* if the server treated oneway void like normal void, this next test will
|
||||
* fail since it will get the void confirmation rather than the correct
|
||||
* result. In this circumstance, the client will throw the exception:
|
||||
*
|
||||
* Because this is the last test against the server, when it completes
|
||||
* the entire suite is complete by definition (the tests run serially).
|
||||
*/
|
||||
done(function() {
|
||||
test_complete = true;
|
||||
});
|
||||
|
||||
//We wait up to retry_limit * retry_interval for the test suite to complete
|
||||
function TestForCompletion() {
|
||||
if(test_complete && callback) {
|
||||
callback("Server successfully tested!");
|
||||
} else {
|
||||
if (++retrys < retry_limit) {
|
||||
setTimeout(TestForCompletion, retry_interval);
|
||||
} else if (callback) {
|
||||
callback("Server test failed to complete after " +
|
||||
(retry_limit * retry_interval / 1000) + " seconds");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setTimeout(TestForCompletion, retry_interval);
|
||||
}
|
299
vendor/git.apache.org/thrift.git/lib/nodets/test/test_handler.ts
generated
vendored
Normal file
299
vendor/git.apache.org/thrift.git/lib/nodets/test/test_handler.ts
generated
vendored
Normal file
|
@ -0,0 +1,299 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* 'License'); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
//This is the server side Node test handler for the standard
|
||||
// Apache Thrift test service.
|
||||
|
||||
import ttypes = require("./gen-nodejs/ThriftTest_types");
|
||||
import thrift = require("thrift");
|
||||
import Thrift = thrift.Thrift;
|
||||
import Q = require("q");
|
||||
|
||||
|
||||
export class SyncThriftTestHandler {
|
||||
testVoid(): Q.IPromise<void> {
|
||||
//console.log('testVoid()');
|
||||
return Q.resolve<void>(undefined);
|
||||
}
|
||||
testMapMap(hello: number) {
|
||||
//console.log('testMapMap(' + hello + ')');
|
||||
|
||||
var mapmap: {[key: number]: {[key: number]: number; }} = [];
|
||||
var pos: {[key: number]: number; } = [];
|
||||
var neg: {[key: number]: number; } = [];
|
||||
for (var i = 1; i < 5; i++) {
|
||||
pos[i] = i;
|
||||
neg[-i] = -i;
|
||||
}
|
||||
mapmap[4] = pos;
|
||||
mapmap[-4] = neg;
|
||||
|
||||
return Q.resolve(mapmap);
|
||||
}
|
||||
testInsanity(argument: ttypes.Insanity): Q.IPromise<{ [k: number]: any; }> {
|
||||
const first_map: { [k: number]: any; } = [];
|
||||
const second_map: { [k: number]: any; } = [];
|
||||
|
||||
first_map[ttypes.Numberz.TWO] = argument;
|
||||
first_map[ttypes.Numberz.THREE] = argument;
|
||||
|
||||
const looney = new ttypes.Insanity();
|
||||
second_map[ttypes.Numberz.SIX] = looney;
|
||||
|
||||
const insane: { [k: number]: any; } = [];
|
||||
insane[1] = first_map;
|
||||
insane[2] = second_map;
|
||||
|
||||
return Q.resolve(insane);
|
||||
}
|
||||
testMulti(arg0: any, arg1: number, arg2: number, arg3: { [k: number]: string; }, arg4: ttypes.Numberz, arg5: number) {
|
||||
var hello = new ttypes.Xtruct();
|
||||
hello.string_thing = 'Hello2';
|
||||
hello.byte_thing = arg0;
|
||||
hello.i32_thing = arg1;
|
||||
hello.i64_thing = arg2;
|
||||
return Q.resolve(hello);
|
||||
}
|
||||
testException(arg: string): Q.IPromise<void> {
|
||||
if (arg === 'Xception') {
|
||||
var x = new ttypes.Xception();
|
||||
x.errorCode = 1001;
|
||||
x.message = arg;
|
||||
throw x;
|
||||
} else if (arg === 'TException') {
|
||||
throw new Thrift.TException(arg);
|
||||
} else {
|
||||
return Q.resolve();
|
||||
}
|
||||
}
|
||||
testMultiException(arg0: string, arg1: string) {
|
||||
if (arg0 === ('Xception')) {
|
||||
var x = new ttypes.Xception();
|
||||
x.errorCode = 1001;
|
||||
x.message = 'This is an Xception';
|
||||
throw x;
|
||||
} else if (arg0 === ('Xception2')) {
|
||||
var x2 = new ttypes.Xception2();
|
||||
x2.errorCode = 2002;
|
||||
x2.struct_thing = new ttypes.Xtruct();
|
||||
x2.struct_thing.string_thing = 'This is an Xception2';
|
||||
throw x2;
|
||||
}
|
||||
|
||||
var res = new ttypes.Xtruct();
|
||||
res.string_thing = arg1;
|
||||
return Q.resolve(res);
|
||||
}
|
||||
testOneway(sleepFor: number) {
|
||||
}
|
||||
|
||||
testString(thing: string) {
|
||||
return Q.resolve(thing);
|
||||
}
|
||||
testBool(thing: boolean) {
|
||||
return Q.resolve(thing);
|
||||
}
|
||||
testByte(thing: number) {
|
||||
return Q.resolve(thing);
|
||||
}
|
||||
testI32(thing: number) {
|
||||
return Q.resolve(thing);
|
||||
}
|
||||
testI64(thing: number) {
|
||||
return Q.resolve(thing);
|
||||
}
|
||||
testDouble(thing: number) {
|
||||
return Q.resolve(thing);
|
||||
}
|
||||
testBinary(thing: Buffer) {
|
||||
return Q.resolve(thing);
|
||||
}
|
||||
testStruct(thing: ttypes.Xtruct) {
|
||||
return Q.resolve(thing);
|
||||
}
|
||||
testNest(thing: ttypes.Xtruct2) {
|
||||
return Q.resolve(thing);
|
||||
}
|
||||
testMap(thing: { [k: number]: number; }) {
|
||||
return Q.resolve(thing);
|
||||
}
|
||||
testStringMap(thing: { [k: string]: string; }) {
|
||||
return Q.resolve(thing);
|
||||
}
|
||||
testSet(thing: number[]) {
|
||||
return Q.resolve(thing);
|
||||
}
|
||||
testList(thing: number[]) {
|
||||
return Q.resolve(thing);
|
||||
}
|
||||
testEnum(thing: ttypes.Numberz) {
|
||||
return Q.resolve(thing);
|
||||
}
|
||||
testTypedef(thing: number) {
|
||||
return Q.resolve(thing);
|
||||
}
|
||||
}
|
||||
|
||||
export class AsyncThriftTestHandler {
|
||||
private syncHandler: SyncThriftTestHandler;
|
||||
constructor() {
|
||||
this.syncHandler = new SyncThriftTestHandler();
|
||||
}
|
||||
|
||||
testVoid(callback: (result: void) => void): Q.IPromise<void> {
|
||||
callback(undefined);
|
||||
return Q.resolve();
|
||||
}
|
||||
testMapMap(hello: number,
|
||||
callback: (err: any, result: { [k: number]: { [k: number]: number; }; }) => void):
|
||||
Q.IPromise<{ [k: number]: { [k: number]: number; }; }> {
|
||||
|
||||
var mapmap: {[key: number]: {[key: number]: number; }} = [];
|
||||
var pos: {[key: number]: number; } = [];
|
||||
var neg: {[key: number]: number; } = [];
|
||||
for (var i = 1; i < 5; i++) {
|
||||
pos[i] = i;
|
||||
neg[-i] = -i;
|
||||
}
|
||||
mapmap[4] = pos;
|
||||
mapmap[-4] = neg;
|
||||
|
||||
callback(null, mapmap);
|
||||
return Q.resolve();
|
||||
}
|
||||
testInsanity(argument: ttypes.Insanity, callback?: (err: any, result: { [k: number]: any; }) => void): Q.IPromise<{ [k: number]: any; }> {
|
||||
const first_map: { [k: number]: any; } = [];
|
||||
const second_map: { [k: number]: any; } = [];
|
||||
|
||||
first_map[ttypes.Numberz.TWO] = argument;
|
||||
first_map[ttypes.Numberz.THREE] = argument;
|
||||
|
||||
const looney = new ttypes.Insanity();
|
||||
second_map[ttypes.Numberz.SIX] = looney;
|
||||
|
||||
const insane: { [k: number]: any; } = [];
|
||||
insane[1] = first_map;
|
||||
insane[2] = second_map;
|
||||
|
||||
if (callback !== undefined){
|
||||
callback(null, insane);
|
||||
}
|
||||
return Q.resolve();
|
||||
}
|
||||
testMulti(arg0: any, arg1: number, arg2: number, arg3: { [k: number]: string; }, arg4: ttypes.Numberz, arg5: number, result: Function): Q.IPromise<ttypes.Xtruct> {
|
||||
var hello = this.syncHandler.testMulti(arg0, arg1, arg2, arg3, arg4, arg5);
|
||||
hello.then(hello => result(null, hello));
|
||||
return Q.resolve();
|
||||
}
|
||||
testException(arg: string, result: (err: any) => void): Q.IPromise<void> {
|
||||
if (arg === 'Xception') {
|
||||
var x = new ttypes.Xception();
|
||||
x.errorCode = 1001;
|
||||
x.message = arg;
|
||||
result(x);
|
||||
} else if (arg === 'TException') {
|
||||
result(new Thrift.TException(arg));
|
||||
} else {
|
||||
result(null);
|
||||
}
|
||||
return Q.resolve();
|
||||
}
|
||||
testMultiException(arg0: string, arg1: string, result: (err: any, res?: ttypes.Xtruct) => void): Q.IPromise<ttypes.Xtruct> {
|
||||
if (arg0 === ('Xception')) {
|
||||
var x = new ttypes.Xception();
|
||||
x.errorCode = 1001;
|
||||
x.message = 'This is an Xception';
|
||||
result(x);
|
||||
} else if (arg0 === ('Xception2')) {
|
||||
var x2 = new ttypes.Xception2();
|
||||
x2.errorCode = 2002;
|
||||
x2.struct_thing = new ttypes.Xtruct();
|
||||
x2.struct_thing.string_thing = 'This is an Xception2';
|
||||
result(x2);
|
||||
} else {
|
||||
var res = new ttypes.Xtruct();
|
||||
res.string_thing = arg1;
|
||||
result(null, res);
|
||||
}
|
||||
return Q.resolve();
|
||||
}
|
||||
testOneway(sleepFor: number, result: Function) {
|
||||
this.syncHandler.testOneway(sleepFor);
|
||||
}
|
||||
testString(thing: string, callback: (err: any, result: string) => void): Q.IPromise<string> {
|
||||
callback(null, thing);
|
||||
return Q.resolve();
|
||||
}
|
||||
testByte(thing: number, callback: (err: any, result: number) => void): Q.IPromise<number> {
|
||||
callback(null, thing);
|
||||
return Q.resolve();
|
||||
}
|
||||
testBool(thing: boolean, callback: (err: any, result: boolean) => void ): Q.IPromise<boolean> {
|
||||
callback(null, thing);
|
||||
return Q.resolve();
|
||||
}
|
||||
testI32(thing: number, callback: (err: any, result: number) => void): Q.IPromise<number> {
|
||||
callback(null, thing);
|
||||
return Q.resolve();
|
||||
}
|
||||
testI64(thing: number, callback: (err: any, result: number) => void): Q.IPromise<number> {
|
||||
callback(null, thing);
|
||||
return Q.resolve();
|
||||
}
|
||||
testDouble(thing: number, callback: (err: any, result: number) => void): Q.IPromise<number> {
|
||||
callback(null, thing);
|
||||
return Q.resolve();
|
||||
}
|
||||
testBinary(thing: Buffer, callback: (err: any, result: Buffer) => void): Q.IPromise<Buffer> {
|
||||
callback(null, thing);
|
||||
return Q.resolve();
|
||||
}
|
||||
testStruct(thing: ttypes.Xtruct, callback: (err: any, result: ttypes.Xtruct) => void): Q.IPromise<ttypes.Xtruct> {
|
||||
callback(null, thing);
|
||||
return Q.resolve();
|
||||
}
|
||||
testNest(thing: ttypes.Xtruct2, callback: (err: any, result: ttypes.Xtruct2) => void): Q.IPromise<ttypes.Xtruct2> {
|
||||
callback(null, thing);
|
||||
return Q.resolve();
|
||||
}
|
||||
testMap(thing: { [k: number]: number; }, callback: (err: any, result: { [k: number]: number; }) => void): Q.IPromise<{ [k: number]: number; }> {
|
||||
callback(null, thing);
|
||||
return Q.resolve();
|
||||
}
|
||||
testStringMap(thing: { [k: string]: string; }, callback: (err: any, result: { [k: string]: string; }) => void): Q.IPromise<{ [k: string]: string; }> {
|
||||
callback(null, thing);
|
||||
return Q.resolve();
|
||||
}
|
||||
testSet(thing: number[], callback: (err: any, result: number[]) => void): Q.IPromise<number[]> {
|
||||
callback(null, thing);
|
||||
return Q.resolve();
|
||||
}
|
||||
testList(thing: number[], callback: (err: any, result: number[]) => void): Q.IPromise<number[]> {
|
||||
callback(null, thing);
|
||||
return Q.resolve();
|
||||
}
|
||||
testEnum(thing: ttypes.Numberz, callback: (err: any, result: ttypes.Numberz) => void): Q.IPromise<ttypes.Numberz> {
|
||||
callback(null, thing);
|
||||
return Q.resolve();
|
||||
}
|
||||
testTypedef(thing: number, callback: (err: any, result: number) => void): Q.IPromise<number> {
|
||||
callback(null, thing);
|
||||
return Q.resolve();
|
||||
}
|
||||
}
|
22
vendor/git.apache.org/thrift.git/lib/nodets/test/tsconfig.json
generated
vendored
Normal file
22
vendor/git.apache.org/thrift.git/lib/nodets/test/tsconfig.json
generated
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"allowJs": false,
|
||||
"alwaysStrict": true,
|
||||
"baseUrl": ".",
|
||||
"declaration": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node",
|
||||
"noImplicitThis": true,
|
||||
"noUnusedLocals": true,
|
||||
"preserveConstEnums": true,
|
||||
"removeComments": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"target": "es6",
|
||||
"paths": {
|
||||
"thrift": ["../../nodejs/lib/thrift"]
|
||||
}
|
||||
}
|
||||
}
|
2
vendor/git.apache.org/thrift.git/lib/ocaml/_oasis
generated
vendored
2
vendor/git.apache.org/thrift.git/lib/ocaml/_oasis
generated
vendored
|
@ -1,5 +1,5 @@
|
|||
Name: libthrift-ocaml
|
||||
Version: 1.0
|
||||
Version: 0.12.0
|
||||
OASISFormat: 0.3
|
||||
Synopsis: OCaml bindings for the Apache Thrift RPC system
|
||||
Authors: Apache Thrift Developers <dev@thrift.apache.org>
|
||||
|
|
2
vendor/git.apache.org/thrift.git/lib/perl/lib/Thrift.pm
generated
vendored
2
vendor/git.apache.org/thrift.git/lib/perl/lib/Thrift.pm
generated
vendored
|
@ -31,6 +31,6 @@ use warnings;
|
|||
#
|
||||
|
||||
package Thrift;
|
||||
use version 0.77; our $VERSION = version->declare("v1.0_0");
|
||||
use version 0.77; our $VERSION = version->declare("v0.12.0_0");
|
||||
|
||||
1;
|
||||
|
|
20
vendor/git.apache.org/thrift.git/lib/perl/lib/Thrift/BinaryProtocol.pm
generated
vendored
20
vendor/git.apache.org/thrift.git/lib/perl/lib/Thrift/BinaryProtocol.pm
generated
vendored
|
@ -39,7 +39,7 @@ use version 0.77; our $VERSION = version->declare("$Thrift::VERSION");
|
|||
|
||||
use constant VERSION_MASK => 0xffff0000;
|
||||
use constant VERSION_1 => 0x80010000;
|
||||
use constant IS_BIG_ENDIAN => unpack("h*", pack("s", 1)) =~ /01/;
|
||||
use constant IS_BIG_ENDIAN => unpack('h*', pack('s', 1)) =~ m/01/;
|
||||
|
||||
sub new
|
||||
{
|
||||
|
@ -67,7 +67,8 @@ sub writeMessageEnd
|
|||
return 0;
|
||||
}
|
||||
|
||||
sub writeStructBegin{
|
||||
sub writeStructBegin
|
||||
{
|
||||
my $self = shift;
|
||||
my $name = shift;
|
||||
return 0;
|
||||
|
@ -253,7 +254,7 @@ sub readMessageBegin
|
|||
my $result = $self->readI32(\$version);
|
||||
if (($version & VERSION_MASK) > 0) {
|
||||
if (($version & VERSION_MASK) != VERSION_1) {
|
||||
die new Thrift::TProtocolException('Missing version identifier',
|
||||
die Thrift::TProtocolException->new('Missing version identifier',
|
||||
Thrift::TProtocolException::BAD_VERSION);
|
||||
}
|
||||
$$type = $version & 0x000000ff;
|
||||
|
@ -261,7 +262,8 @@ sub readMessageBegin
|
|||
$result +
|
||||
$self->readString($name) +
|
||||
$self->readI32($seqid);
|
||||
} else { # old client support code
|
||||
}
|
||||
else { # old client support code
|
||||
return
|
||||
$result +
|
||||
$self->readStringBody($name, $version) + # version here holds the size of the string
|
||||
|
@ -427,7 +429,7 @@ sub readI64
|
|||
|
||||
my ($hi,$lo)=unpack('NN',$data);
|
||||
|
||||
my $vec = new Bit::Vector(64);
|
||||
my $vec = Bit::Vector->new(64);
|
||||
|
||||
$vec->Chunk_Store(32,32,$hi);
|
||||
$vec->Chunk_Store(32,0,$lo);
|
||||
|
@ -467,7 +469,8 @@ sub readString
|
|||
|
||||
if ($len) {
|
||||
$$value = $self->{trans}->readAll($len);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$$value = '';
|
||||
}
|
||||
|
||||
|
@ -482,7 +485,8 @@ sub readStringBody
|
|||
|
||||
if ($len) {
|
||||
$$value = $self->{trans}->readAll($len);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$$value = '';
|
||||
}
|
||||
|
||||
|
@ -508,7 +512,7 @@ sub getProtocol{
|
|||
my $self = shift;
|
||||
my $trans = shift;
|
||||
|
||||
return new Thrift::BinaryProtocol($trans);
|
||||
return Thrift::BinaryProtocol->new($trans);
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
15
vendor/git.apache.org/thrift.git/lib/perl/lib/Thrift/Exception.pm
generated
vendored
15
vendor/git.apache.org/thrift.git/lib/perl/lib/Thrift/Exception.pm
generated
vendored
|
@ -29,11 +29,10 @@ use version 0.77; our $VERSION = version->declare("$Thrift::VERSION");
|
|||
|
||||
use overload '""' => sub {
|
||||
return
|
||||
ref( $_[0] )
|
||||
. " error: "
|
||||
. ( $_[0]->{message} || 'empty message' )
|
||||
. " (code "
|
||||
. ( defined $_[0]->{code} ? $_[0]->{code} : 'undefined' ) . ")";
|
||||
sprintf '%s error: %s (code %s)',
|
||||
ref( $_[0] ),
|
||||
( $_[0]->{message} || 'empty message' ),
|
||||
( defined $_[0]->{code} ? $_[0]->{code} : 'undefined' );
|
||||
};
|
||||
|
||||
sub new {
|
||||
|
@ -91,7 +90,8 @@ sub read {
|
|||
|
||||
if ($ftype == Thrift::TType::STRING) {
|
||||
$xfer += $input->readString(\$self->{message});
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$xfer += $input->skip($ftype);
|
||||
}
|
||||
|
||||
|
@ -101,7 +101,8 @@ sub read {
|
|||
/2/ && do{
|
||||
if ($ftype == Thrift::TType::I32) {
|
||||
$xfer += $input->readI32(\$self->{code});
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$xfer += $input->skip($ftype);
|
||||
}
|
||||
last;
|
||||
|
|
2
vendor/git.apache.org/thrift.git/lib/perl/lib/Thrift/FramedTransport.pm
generated
vendored
2
vendor/git.apache.org/thrift.git/lib/perl/lib/Thrift/FramedTransport.pm
generated
vendored
|
@ -70,7 +70,7 @@ sub close
|
|||
my $self = shift;
|
||||
|
||||
if (defined $self->{transport}) {
|
||||
$self->{transport}->close();
|
||||
$self->{transport}->close();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
33
vendor/git.apache.org/thrift.git/lib/perl/lib/Thrift/HttpClient.pm
generated
vendored
33
vendor/git.apache.org/thrift.git/lib/perl/lib/Thrift/HttpClient.pm
generated
vendored
|
@ -61,7 +61,7 @@ sub setTimeout
|
|||
|
||||
sub setRecvTimeout
|
||||
{
|
||||
warn "setRecvTimeout is deprecated - use setTimeout instead";
|
||||
warn 'setRecvTimeout is deprecated - use setTimeout instead';
|
||||
# note: recvTimeout was never used so we do not need to do anything here
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@ sub setSendTimeout
|
|||
my $self = shift;
|
||||
my $timeout = shift;
|
||||
|
||||
warn "setSendTimeout is deprecated - use setTimeout instead";
|
||||
warn 'setSendTimeout is deprecated - use setTimeout instead';
|
||||
|
||||
$self->setTimeout($timeout);
|
||||
}
|
||||
|
@ -102,8 +102,8 @@ sub close
|
|||
{
|
||||
my $self = shift;
|
||||
if (defined($self->{io})) {
|
||||
close($self->{io});
|
||||
$self->{io} = undef;
|
||||
close($self->{io});
|
||||
$self->{io} = undef;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -121,7 +121,7 @@ sub readAll
|
|||
my $buf = $self->read($len);
|
||||
|
||||
if (!defined($buf)) {
|
||||
die new Thrift::TTransportException("TSocket: Could not read $len bytes from input buffer",
|
||||
die Thrift::TTransportException->new("TSocket: Could not read $len bytes from input buffer",
|
||||
Thrift::TTransportException::END_OF_FILE);
|
||||
}
|
||||
return $buf;
|
||||
|
@ -140,17 +140,18 @@ sub read
|
|||
my $in = $self->{in};
|
||||
|
||||
if (!defined($in)) {
|
||||
die new Thrift::TTransportException("Response buffer is empty, no request.",
|
||||
die Thrift::TTransportException->new('Response buffer is empty, no request.',
|
||||
Thrift::TTransportException::END_OF_FILE);
|
||||
}
|
||||
eval {
|
||||
my $ret = sysread($in, $buf, $len);
|
||||
if (! defined($ret)) {
|
||||
die new Thrift::TTransportException("No more data available.",
|
||||
my $ret = sysread($in, $buf, $len);
|
||||
if (! defined($ret)) {
|
||||
die Thrift::TTransportException->new('No more data available.',
|
||||
Thrift::TTransportException::TIMED_OUT);
|
||||
}
|
||||
}; if($@){
|
||||
die new Thrift::TTransportException("$@", Thrift::TTransportException::UNKNOWN);
|
||||
}
|
||||
};
|
||||
if($@){
|
||||
die Thrift::TTransportException->new("$@", Thrift::TTransportException::UNKNOWN);
|
||||
}
|
||||
|
||||
return $buf;
|
||||
|
@ -173,8 +174,9 @@ sub flush
|
|||
{
|
||||
my $self = shift;
|
||||
|
||||
my $ua = LWP::UserAgent->new('timeout' => ($self->{timeout} / 1000),
|
||||
'agent' => 'Perl/THttpClient'
|
||||
my $ua = LWP::UserAgent->new(
|
||||
'timeout' => ($self->{timeout} / 1000),
|
||||
'agent' => 'Perl/THttpClient'
|
||||
);
|
||||
$ua->default_header('Accept' => 'application/x-thrift');
|
||||
$ua->default_header('Content-Type' => 'application/x-thrift');
|
||||
|
@ -184,8 +186,7 @@ sub flush
|
|||
$out->setpos(0); # rewind
|
||||
my $buf = join('', <$out>);
|
||||
|
||||
my $request = new HTTP::Request(POST => $self->{url}, undef, $buf);
|
||||
map { $request->header($_ => $self->{headers}->{$_}) } keys %{$self->{headers}};
|
||||
my $request = HTTP::Request->new(POST => $self->{url}, ($self->{headers} || undef), $buf);
|
||||
my $response = $ua->request($request);
|
||||
my $content_ref = $response->content_ref;
|
||||
|
||||
|
|
10
vendor/git.apache.org/thrift.git/lib/perl/lib/Thrift/MemoryBuffer.pm
generated
vendored
10
vendor/git.apache.org/thrift.git/lib/perl/lib/Thrift/MemoryBuffer.pm
generated
vendored
|
@ -35,10 +35,10 @@ sub new
|
|||
my $bufferSize= shift || 1024;
|
||||
|
||||
my $self = {
|
||||
buffer => '',
|
||||
bufferSize=> $bufferSize,
|
||||
wPos => 0,
|
||||
rPos => 0,
|
||||
buffer => '',
|
||||
bufferSize => $bufferSize,
|
||||
wPos => 0,
|
||||
rPos => 0,
|
||||
};
|
||||
|
||||
return bless($self,$classname);
|
||||
|
@ -117,7 +117,7 @@ sub readAll
|
|||
|
||||
my $avail = ($self->{wPos} - $self->{rPos});
|
||||
if ($avail < $len) {
|
||||
die new TTransportException("Attempt to readAll($len) found only $avail available",
|
||||
die TTransportException->new("Attempt to readAll($len) found only $avail available",
|
||||
Thrift::TTransportException::END_OF_FILE);
|
||||
}
|
||||
|
||||
|
|
14
vendor/git.apache.org/thrift.git/lib/perl/lib/Thrift/MultiplexedProcessor.pm
generated
vendored
14
vendor/git.apache.org/thrift.git/lib/perl/lib/Thrift/MultiplexedProcessor.pm
generated
vendored
|
@ -101,32 +101,32 @@ sub process {
|
|||
$input->readMessageBegin(\$fname, \$mtype, \$rseqid);
|
||||
|
||||
if ($mtype ne Thrift::TMessageType::CALL && $mtype ne Thrift::TMessageType::ONEWAY) {
|
||||
die new Thrift::TException("This should not have happened!?");
|
||||
die Thrift::TException->new('This should not have happened!?');
|
||||
}
|
||||
|
||||
# Extract the service name and the new Message name.
|
||||
if (index($fname, Thrift::MultiplexedProtocol::SEPARATOR) == -1) {
|
||||
if (defined $self->{defaultProcessor}) {
|
||||
return $self->{defaultProcessor}->process(
|
||||
new Thrift::StoredMessageProtocol($input, $fname, $mtype, $rseqid), $output
|
||||
Thrift::StoredMessageProtocol->new($input, $fname, $mtype, $rseqid), $output
|
||||
);
|
||||
} else {
|
||||
die new Thrift::TException("Service name not found in message name: {$fname} and no default processor defined. Did you " .
|
||||
"forget to use a MultiplexProtocol in your client?");
|
||||
die Thrift::TException->new("Service name not found in message name: {$fname} and no default processor defined. Did you " .
|
||||
'forget to use a MultiplexProtocol in your client?');
|
||||
}
|
||||
}
|
||||
|
||||
(my $serviceName, my $messageName) = split(':', $fname, 2);
|
||||
|
||||
if (!exists($self->{serviceProcessorMap}->{$serviceName})) {
|
||||
die new Thrift::TException("Service name not found: {$serviceName}. Did you forget " .
|
||||
"to call registerProcessor()?");
|
||||
die Thrift::TException->new("Service name not found: {$serviceName}. Did you forget " .
|
||||
'to call registerProcessor()?');
|
||||
}
|
||||
|
||||
# Dispatch processing to the stored processor
|
||||
my $processor = $self->{serviceProcessorMap}->{$serviceName};
|
||||
return $processor->process(
|
||||
new Thrift::StoredMessageProtocol($input, $messageName, $mtype, $rseqid), $output
|
||||
Thrift::StoredMessageProtocol->new($input, $messageName, $mtype, $rseqid), $output
|
||||
);
|
||||
}
|
||||
|
||||
|
|
2
vendor/git.apache.org/thrift.git/lib/perl/lib/Thrift/MultiplexedProtocol.pm
generated
vendored
2
vendor/git.apache.org/thrift.git/lib/perl/lib/Thrift/MultiplexedProtocol.pm
generated
vendored
|
@ -53,7 +53,7 @@ sub new {
|
|||
#
|
||||
sub writeMessageBegin
|
||||
{
|
||||
my $self = shift;
|
||||
my $self = shift;
|
||||
my ($name, $type, $seqid) = @_;
|
||||
|
||||
if ($type == Thrift::TMessageType::CALL || $type == Thrift::TMessageType::ONEWAY) {
|
||||
|
|
108
vendor/git.apache.org/thrift.git/lib/perl/lib/Thrift/Protocol.pm
generated
vendored
108
vendor/git.apache.org/thrift.git/lib/perl/lib/Thrift/Protocol.pm
generated
vendored
|
@ -81,14 +81,14 @@ sub getTransport
|
|||
sub writeMessageBegin
|
||||
{
|
||||
my ($name, $type, $seqid);
|
||||
die "abstract";
|
||||
die 'abstract';
|
||||
}
|
||||
|
||||
#
|
||||
# Close the message
|
||||
#
|
||||
sub writeMessageEnd {
|
||||
die "abstract";
|
||||
die 'abstract';
|
||||
}
|
||||
|
||||
#
|
||||
|
@ -101,7 +101,7 @@ sub writeMessageEnd {
|
|||
sub writeStructBegin {
|
||||
my ($name);
|
||||
|
||||
die "abstract";
|
||||
die 'abstract';
|
||||
}
|
||||
|
||||
#
|
||||
|
@ -111,7 +111,7 @@ sub writeStructBegin {
|
|||
# @return int How many bytes written
|
||||
#
|
||||
sub writeStructEnd {
|
||||
die "abstract";
|
||||
die 'abstract';
|
||||
}
|
||||
|
||||
#
|
||||
|
@ -126,79 +126,79 @@ sub writeStructEnd {
|
|||
sub writeFieldBegin {
|
||||
my ($fieldName, $fieldType, $fieldId);
|
||||
|
||||
die "abstract";
|
||||
die 'abstract';
|
||||
}
|
||||
|
||||
sub writeFieldEnd {
|
||||
die "abstract";
|
||||
die 'abstract';
|
||||
}
|
||||
|
||||
sub writeFieldStop {
|
||||
die "abstract";
|
||||
die 'abstract';
|
||||
}
|
||||
|
||||
sub writeMapBegin {
|
||||
my ($keyType, $valType, $size);
|
||||
|
||||
die "abstract";
|
||||
die 'abstract';
|
||||
}
|
||||
|
||||
sub writeMapEnd {
|
||||
die "abstract";
|
||||
die 'abstract';
|
||||
}
|
||||
|
||||
sub writeListBegin {
|
||||
my ($elemType, $size);
|
||||
die "abstract";
|
||||
die 'abstract';
|
||||
}
|
||||
|
||||
sub writeListEnd {
|
||||
die "abstract";
|
||||
die 'abstract';
|
||||
}
|
||||
|
||||
sub writeSetBegin {
|
||||
my ($elemType, $size);
|
||||
die "abstract";
|
||||
die 'abstract';
|
||||
}
|
||||
|
||||
sub writeSetEnd {
|
||||
die "abstract";
|
||||
die 'abstract';
|
||||
}
|
||||
|
||||
sub writeBool {
|
||||
my ($bool);
|
||||
die "abstract";
|
||||
die 'abstract';
|
||||
}
|
||||
|
||||
sub writeByte {
|
||||
my ($byte);
|
||||
die "abstract";
|
||||
die 'abstract';
|
||||
}
|
||||
|
||||
sub writeI16 {
|
||||
my ($i16);
|
||||
die "abstract";
|
||||
die 'abstract';
|
||||
}
|
||||
|
||||
sub writeI32 {
|
||||
my ($i32);
|
||||
die "abstract";
|
||||
die 'abstract';
|
||||
}
|
||||
|
||||
sub writeI64 {
|
||||
my ($i64);
|
||||
die "abstract";
|
||||
die 'abstract';
|
||||
}
|
||||
|
||||
sub writeDouble {
|
||||
my ($dub);
|
||||
die "abstract";
|
||||
die 'abstract';
|
||||
}
|
||||
|
||||
sub writeString
|
||||
{
|
||||
my ($str);
|
||||
die "abstract";
|
||||
die 'abstract';
|
||||
}
|
||||
|
||||
#
|
||||
|
@ -211,7 +211,7 @@ sub writeString
|
|||
sub readMessageBegin
|
||||
{
|
||||
my ($name, $type, $seqid);
|
||||
die "abstract";
|
||||
die 'abstract';
|
||||
}
|
||||
|
||||
#
|
||||
|
@ -219,105 +219,105 @@ sub readMessageBegin
|
|||
#
|
||||
sub readMessageEnd
|
||||
{
|
||||
die "abstract";
|
||||
die 'abstract';
|
||||
}
|
||||
|
||||
sub readStructBegin
|
||||
{
|
||||
my($name);
|
||||
|
||||
die "abstract";
|
||||
die 'abstract';
|
||||
}
|
||||
|
||||
sub readStructEnd
|
||||
{
|
||||
die "abstract";
|
||||
die 'abstract';
|
||||
}
|
||||
|
||||
sub readFieldBegin
|
||||
{
|
||||
my ($name, $fieldType, $fieldId);
|
||||
die "abstract";
|
||||
die 'abstract';
|
||||
}
|
||||
|
||||
sub readFieldEnd
|
||||
{
|
||||
die "abstract";
|
||||
die 'abstract';
|
||||
}
|
||||
|
||||
sub readMapBegin
|
||||
{
|
||||
my ($keyType, $valType, $size);
|
||||
die "abstract";
|
||||
die 'abstract';
|
||||
}
|
||||
|
||||
sub readMapEnd
|
||||
{
|
||||
die "abstract";
|
||||
die 'abstract';
|
||||
}
|
||||
|
||||
sub readListBegin
|
||||
{
|
||||
my ($elemType, $size);
|
||||
die "abstract";
|
||||
die 'abstract';
|
||||
}
|
||||
|
||||
sub readListEnd
|
||||
{
|
||||
die "abstract";
|
||||
die 'abstract';
|
||||
}
|
||||
|
||||
sub readSetBegin
|
||||
{
|
||||
my ($elemType, $size);
|
||||
die "abstract";
|
||||
die 'abstract';
|
||||
}
|
||||
|
||||
sub readSetEnd
|
||||
{
|
||||
die "abstract";
|
||||
die 'abstract';
|
||||
}
|
||||
|
||||
sub readBool
|
||||
{
|
||||
my ($bool);
|
||||
die "abstract";
|
||||
die 'abstract';
|
||||
}
|
||||
|
||||
sub readByte
|
||||
{
|
||||
my ($byte);
|
||||
die "abstract";
|
||||
die 'abstract';
|
||||
}
|
||||
|
||||
sub readI16
|
||||
{
|
||||
my ($i16);
|
||||
die "abstract";
|
||||
die 'abstract';
|
||||
}
|
||||
|
||||
sub readI32
|
||||
{
|
||||
my ($i32);
|
||||
die "abstract";
|
||||
die 'abstract';
|
||||
}
|
||||
|
||||
sub readI64
|
||||
{
|
||||
my ($i64);
|
||||
die "abstract";
|
||||
die 'abstract';
|
||||
}
|
||||
|
||||
sub readDouble
|
||||
{
|
||||
my ($dub);
|
||||
die "abstract";
|
||||
die 'abstract';
|
||||
}
|
||||
|
||||
sub readString
|
||||
{
|
||||
my ($str);
|
||||
die "abstract";
|
||||
die 'abstract';
|
||||
}
|
||||
|
||||
#
|
||||
|
@ -405,7 +405,7 @@ sub skip
|
|||
return $result;
|
||||
}
|
||||
|
||||
die new Thrift::TProtocolException("Type $type not recognized --- corrupt data?",
|
||||
die Thrift::TProtocolException->new("Type $type not recognized --- corrupt data?",
|
||||
Thrift::TProtocolException::INVALID_DATA);
|
||||
|
||||
}
|
||||
|
@ -424,7 +424,7 @@ sub skipBinary
|
|||
|
||||
if($type == Thrift::TType::BOOL)
|
||||
{
|
||||
return $itrans->readAll(1);
|
||||
return $itrans->readAll(1);
|
||||
}
|
||||
elsif($type == Thrift::TType::BYTE)
|
||||
{
|
||||
|
@ -459,17 +459,17 @@ sub skipBinary
|
|||
{
|
||||
my $result = 0;
|
||||
while (1) {
|
||||
my $ftype = 0;
|
||||
my $fid = 0;
|
||||
my $data = $itrans->readAll(1);
|
||||
my @arr = unpack('c', $data);
|
||||
$ftype = $arr[0];
|
||||
if ($ftype == Thrift::TType::STOP) {
|
||||
last;
|
||||
}
|
||||
# I16 field id
|
||||
$result += $itrans->readAll(2);
|
||||
$result += $self->skipBinary($itrans, $ftype);
|
||||
my $ftype = 0;
|
||||
my $fid = 0;
|
||||
my $data = $itrans->readAll(1);
|
||||
my @arr = unpack('c', $data);
|
||||
$ftype = $arr[0];
|
||||
if ($ftype == Thrift::TType::STOP) {
|
||||
last;
|
||||
}
|
||||
# I16 field id
|
||||
$result += $itrans->readAll(2);
|
||||
$result += $self->skipBinary($itrans, $ftype);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
@ -517,7 +517,7 @@ sub skipBinary
|
|||
return $result;
|
||||
}
|
||||
|
||||
die new Thrift::TProtocolException("Type $type not recognized --- corrupt data?",
|
||||
die Thrift::TProtocolException->new("Type $type not recognized --- corrupt data?",
|
||||
Thrift::TProtocolException::INVALID_DATA);
|
||||
}
|
||||
|
||||
|
@ -542,7 +542,7 @@ sub new {
|
|||
sub getProtocol
|
||||
{
|
||||
my ($trans);
|
||||
die "interface";
|
||||
die 'interface';
|
||||
}
|
||||
|
||||
|
||||
|
|
2
vendor/git.apache.org/thrift.git/lib/perl/lib/Thrift/SSLServerSocket.pm
generated
vendored
2
vendor/git.apache.org/thrift.git/lib/perl/lib/Thrift/SSLServerSocket.pm
generated
vendored
|
@ -48,7 +48,7 @@ sub new
|
|||
|
||||
sub __client
|
||||
{
|
||||
return new Thrift::SSLSocket();
|
||||
return Thrift::SSLSocket->new();
|
||||
}
|
||||
|
||||
sub __listen
|
||||
|
|
2
vendor/git.apache.org/thrift.git/lib/perl/lib/Thrift/SSLSocket.pm
generated
vendored
2
vendor/git.apache.org/thrift.git/lib/perl/lib/Thrift/SSLSocket.pm
generated
vendored
|
@ -34,7 +34,7 @@ use version 0.77; our $VERSION = version->declare("$Thrift::VERSION");
|
|||
# Construction and usage
|
||||
#
|
||||
# my $opts = {}
|
||||
# my $socket = new Thrift::SSLSocket(\%opts);
|
||||
# my $socket = Thrift::SSLSocket->new(\%opts);
|
||||
#
|
||||
# options:
|
||||
#
|
||||
|
|
39
vendor/git.apache.org/thrift.git/lib/perl/lib/Thrift/Server.pm
generated
vendored
39
vendor/git.apache.org/thrift.git/lib/perl/lib/Thrift/Server.pm
generated
vendored
|
@ -51,7 +51,7 @@ sub new
|
|||
|
||||
if (scalar @args == 2)
|
||||
{
|
||||
$self = _init($args[0], $args[1],
|
||||
$self = _init($args[0], $args[1],
|
||||
Thrift::BufferedTransportFactory->new(),
|
||||
Thrift::BufferedTransportFactory->new(),
|
||||
Thrift::BinaryProtocolFactory->new(),
|
||||
|
@ -67,7 +67,7 @@ sub new
|
|||
}
|
||||
else
|
||||
{
|
||||
die new Thrift::TException("Thrift::Server expects exactly 2, 4, or 6 args");
|
||||
die Thrift::TException->new('Thrift::Server expects exactly 2, 4, or 6 args');
|
||||
}
|
||||
|
||||
return bless($self,$classname);
|
||||
|
@ -94,7 +94,7 @@ sub _init
|
|||
|
||||
sub serve
|
||||
{
|
||||
die "abstract";
|
||||
die 'abstract';
|
||||
}
|
||||
|
||||
sub _clientBegin
|
||||
|
@ -115,7 +115,7 @@ sub _handleException
|
|||
my $self = shift;
|
||||
my $e = shift;
|
||||
|
||||
if ($e->isa("Thrift::TException") and exists $e->{message}) {
|
||||
if ($e->isa('Thrift::TException') and exists $e->{message}) {
|
||||
my $message = $e->{message};
|
||||
my $code = $e->{code};
|
||||
my $out = $code . ':' . $message;
|
||||
|
@ -123,10 +123,12 @@ sub _handleException
|
|||
$message =~ m/TTransportException/ and die $out;
|
||||
if ($message =~ m/Socket/) {
|
||||
# suppress Socket messages
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
warn $out;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
warn $e;
|
||||
}
|
||||
}
|
||||
|
@ -151,7 +153,7 @@ sub serve
|
|||
{
|
||||
my $self = shift;
|
||||
my $stop = 0;
|
||||
|
||||
|
||||
$self->{serverTransport}->listen();
|
||||
while (!$stop) {
|
||||
my $client = $self->{serverTransport}->accept();
|
||||
|
@ -166,10 +168,10 @@ sub serve
|
|||
{
|
||||
$self->{processor}->process($iprot, $oprot);
|
||||
}
|
||||
}; if($@) {
|
||||
};
|
||||
if($@) {
|
||||
$self->_handleException($@);
|
||||
}
|
||||
|
||||
$itrans->close();
|
||||
$otrans->close();
|
||||
} else {
|
||||
|
@ -184,7 +186,7 @@ sub serve
|
|||
#
|
||||
package Thrift::ForkingServer;
|
||||
use parent -norequire, 'Thrift::Server';
|
||||
use POSIX ":sys_wait_h";
|
||||
use POSIX ':sys_wait_h';
|
||||
use version 0.77; our $VERSION = version->declare("$Thrift::VERSION");
|
||||
|
||||
sub new
|
||||
|
@ -231,10 +233,12 @@ sub _client
|
|||
if ($pid)
|
||||
{
|
||||
$self->_parent($pid, $itrans, $otrans);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$self->_child($itrans, $otrans, $iprot, $oprot);
|
||||
}
|
||||
}; if($@) {
|
||||
};
|
||||
if($@) {
|
||||
$self->_handleException($@);
|
||||
}
|
||||
}
|
||||
|
@ -267,7 +271,8 @@ sub _child
|
|||
{
|
||||
$self->{processor}->process($iprot, $oprot);
|
||||
}
|
||||
}; if($@) {
|
||||
};
|
||||
if($@) {
|
||||
$ecode = 1;
|
||||
$self->_handleException($@);
|
||||
}
|
||||
|
@ -288,14 +293,16 @@ sub tryClose
|
|||
{
|
||||
$file->close();
|
||||
}
|
||||
}; if($@) {
|
||||
if ($@->isa("Thrift::TException") and exists $@->{message}) {
|
||||
};
|
||||
if($@) {
|
||||
if ($@->isa('Thrift::TException') and exists $@->{message}) {
|
||||
my $message = $@->{message};
|
||||
my $code = $@->{code};
|
||||
my $out = $code . ':' . $message;
|
||||
|
||||
warn $out;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
warn $@;
|
||||
}
|
||||
}
|
||||
|
|
17
vendor/git.apache.org/thrift.git/lib/perl/lib/Thrift/ServerSocket.pm
generated
vendored
17
vendor/git.apache.org/thrift.git/lib/perl/lib/Thrift/ServerSocket.pm
generated
vendored
|
@ -38,7 +38,7 @@ use version 0.77; our $VERSION = version->declare("$Thrift::VERSION");
|
|||
# @param[in] host host interface to listen on (undef = all interfaces)
|
||||
# @param[in] port port number to listen on (required)
|
||||
# @param[in] queue the listen queue size (default if not specified is 128)
|
||||
# @example my $serversock = new Thrift::ServerSocket(host => undef, port => port)
|
||||
# @example my $serversock = Thrift::ServerSocket->new(host => undef, port => port)
|
||||
#
|
||||
sub new
|
||||
{
|
||||
|
@ -49,7 +49,8 @@ sub new
|
|||
# Support both old-style "port number" construction and newer...
|
||||
if (ref($args) eq 'HASH') {
|
||||
$self = $args;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$self = { port => $args };
|
||||
}
|
||||
|
||||
|
@ -71,7 +72,7 @@ sub listen
|
|||
$self->{debugHandler}->($error);
|
||||
}
|
||||
|
||||
die new Thrift::TTransportException($error, Thrift::TTransportException::NOT_OPEN);
|
||||
die Thrift::TTransportException->new($error, Thrift::TTransportException::NOT_OPEN);
|
||||
};
|
||||
|
||||
$self->{handle} = $sock;
|
||||
|
@ -84,7 +85,7 @@ sub accept
|
|||
if ( exists $self->{handle} and defined $self->{handle} ) {
|
||||
my $client = $self->{handle}->accept();
|
||||
my $result = $self->__client();
|
||||
$result->{handle} = new IO::Select($client);
|
||||
$result->{handle} = IO::Select->new($client);
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
@ -93,12 +94,12 @@ sub accept
|
|||
|
||||
sub close
|
||||
{
|
||||
my $self = shift;
|
||||
|
||||
my $self = shift;
|
||||
|
||||
if ( exists $self->{handle} and defined $self->{handle} )
|
||||
{
|
||||
$self->{handle}->close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
###
|
||||
|
@ -107,7 +108,7 @@ sub close
|
|||
|
||||
sub __client
|
||||
{
|
||||
return new Thrift::Socket();
|
||||
return Thrift::Socket->new();
|
||||
}
|
||||
|
||||
sub __listen
|
||||
|
|
22
vendor/git.apache.org/thrift.git/lib/perl/lib/Thrift/Socket.pm
generated
vendored
22
vendor/git.apache.org/thrift.git/lib/perl/lib/Thrift/Socket.pm
generated
vendored
|
@ -36,7 +36,7 @@ use version 0.77; our $VERSION = version->declare("$Thrift::VERSION");
|
|||
# Construction and usage
|
||||
#
|
||||
# my $opts = {}
|
||||
# my $socket = new Thrift::Socket(\%opts);
|
||||
# my $socket = Thrift::Socket->new(\%opts);
|
||||
#
|
||||
# options:
|
||||
#
|
||||
|
@ -120,10 +120,10 @@ sub open
|
|||
|
||||
my $sock = $self->__open() || do {
|
||||
my $error = ref($self).': Could not connect to '.$self->{host}.':'.$self->{port}.' ('.$!.')';
|
||||
die new Thrift::TTransportException($error, Thrift::TTransportException::NOT_OPEN);
|
||||
die Thrift::TTransportException->new($error, Thrift::TTransportException::NOT_OPEN);
|
||||
};
|
||||
|
||||
$self->{handle} = new IO::Select( $sock );
|
||||
$self->{handle} = IO::Select->new( $sock );
|
||||
}
|
||||
|
||||
#
|
||||
|
@ -159,15 +159,17 @@ sub readAll
|
|||
|
||||
if (!defined $buf || $buf eq '') {
|
||||
|
||||
die new Thrift::TTransportException(ref($self).': Could not read '.$len.' bytes from '.
|
||||
die Thrift::TTransportException->new(ref($self).': Could not read '.$len.' bytes from '.
|
||||
$self->{host}.':'.$self->{port}, Thrift::TTransportException::END_OF_FILE);
|
||||
|
||||
} elsif ((my $sz = length($buf)) < $len) {
|
||||
}
|
||||
elsif ((my $sz = length($buf)) < $len) {
|
||||
|
||||
$pre .= $buf;
|
||||
$len -= $sz;
|
||||
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return $pre.$buf;
|
||||
}
|
||||
}
|
||||
|
@ -191,7 +193,7 @@ sub read
|
|||
|
||||
if (!defined $buf || $buf eq '') {
|
||||
|
||||
die new Thrift::TTransportException(ref($self).': Could not read '.$len.' bytes from '.
|
||||
die Thrift::TTransportException->new(ref($self).': Could not read '.$len.' bytes from '.
|
||||
$self->{host}.':'.$self->{port}, Thrift::TTransportException::END_OF_FILE);
|
||||
|
||||
}
|
||||
|
@ -217,7 +219,7 @@ sub write
|
|||
my @sockets = $self->{handle}->can_write( $self->{sendTimeout} / 1000 );
|
||||
|
||||
if(@sockets == 0){
|
||||
die new Thrift::TTransportException(ref($self).': timed out writing to bytes from '.
|
||||
die Thrift::TTransportException->new(ref($self).': timed out writing to bytes from '.
|
||||
$self->{host}.':'.$self->{port}, Thrift::TTransportException::TIMED_OUT);
|
||||
}
|
||||
|
||||
|
@ -225,7 +227,7 @@ sub write
|
|||
|
||||
if (!defined $sent || $sent == 0 ) {
|
||||
|
||||
die new Thrift::TTransportException(ref($self).': Could not write '.length($buf).' bytes '.
|
||||
die Thrift::TTransportException->new(ref($self).': Could not write '.length($buf).' bytes '.
|
||||
$self->{host}.':'.$self->{host}, Thrift::TTransportException::END_OF_FILE);
|
||||
|
||||
}
|
||||
|
@ -314,7 +316,7 @@ sub __wait
|
|||
my @sockets = $self->{handle}->can_read( $self->{recvTimeout} / 1000 );
|
||||
|
||||
if (@sockets == 0) {
|
||||
die new Thrift::TTransportException(ref($self).': timed out reading from '.
|
||||
die Thrift::TTransportException->new(ref($self).': timed out reading from '.
|
||||
$self->{host}.':'.$self->{port}, Thrift::TTransportException::TIMED_OUT);
|
||||
}
|
||||
|
||||
|
|
16
vendor/git.apache.org/thrift.git/lib/perl/lib/Thrift/Transport.pm
generated
vendored
16
vendor/git.apache.org/thrift.git/lib/perl/lib/Thrift/Transport.pm
generated
vendored
|
@ -54,7 +54,7 @@ use version 0.77; our $VERSION = version->declare("$Thrift::VERSION");
|
|||
#
|
||||
sub isOpen
|
||||
{
|
||||
die "abstract";
|
||||
die 'abstract';
|
||||
}
|
||||
|
||||
#
|
||||
|
@ -64,7 +64,7 @@ sub isOpen
|
|||
#
|
||||
sub open
|
||||
{
|
||||
die "abstract";
|
||||
die 'abstract';
|
||||
}
|
||||
|
||||
#
|
||||
|
@ -72,7 +72,7 @@ sub open
|
|||
#
|
||||
sub close
|
||||
{
|
||||
die "abstract";
|
||||
die 'abstract';
|
||||
}
|
||||
|
||||
#
|
||||
|
@ -84,7 +84,7 @@ sub close
|
|||
#
|
||||
sub read
|
||||
{
|
||||
die "abstract";
|
||||
die 'abstract';
|
||||
}
|
||||
|
||||
#
|
||||
|
@ -116,7 +116,7 @@ sub readAll
|
|||
#
|
||||
sub write
|
||||
{
|
||||
die "abstract";
|
||||
die 'abstract';
|
||||
}
|
||||
|
||||
#
|
||||
|
@ -162,17 +162,17 @@ use version 0.77; our $VERSION = version->declare("$Thrift::VERSION");
|
|||
|
||||
sub listen
|
||||
{
|
||||
die "abstract";
|
||||
die 'abstract';
|
||||
}
|
||||
|
||||
sub accept
|
||||
{
|
||||
die "abstract";
|
||||
die 'abstract';
|
||||
}
|
||||
|
||||
sub close
|
||||
{
|
||||
die "abstract";
|
||||
die 'abstract';
|
||||
}
|
||||
|
||||
|
||||
|
|
8
vendor/git.apache.org/thrift.git/lib/perl/lib/Thrift/UnixServerSocket.pm
generated
vendored
8
vendor/git.apache.org/thrift.git/lib/perl/lib/Thrift/UnixServerSocket.pm
generated
vendored
|
@ -37,8 +37,8 @@ use version 0.77; our $VERSION = version->declare("$Thrift::VERSION");
|
|||
# If a single argument is given that is a hash:
|
||||
# @param[in] path unix domain socket file name
|
||||
# @param[in] queue the listen queue size (default is not specified is supplied by ServerSocket)
|
||||
# @example my $serversock = new Thrift::UnixServerSocket($path);
|
||||
# @example my $serversock = new Thrift::UnixServerSocket(path => "somepath", queue => 64);
|
||||
# @example my $serversock = Thrift::UnixServerSocket->new($path);
|
||||
# @example my $serversock = Thrift::UnixServerSocket->new(path => "somepath", queue => 64);
|
||||
#
|
||||
sub new
|
||||
{
|
||||
|
@ -58,7 +58,7 @@ sub new
|
|||
|
||||
sub __client
|
||||
{
|
||||
return new Thrift::UnixSocket();
|
||||
return Thrift::UnixSocket->new();
|
||||
}
|
||||
|
||||
sub __listen
|
||||
|
@ -75,7 +75,7 @@ sub __listen
|
|||
if ($self->{debug}) {
|
||||
$self->{debugHandler}->($error);
|
||||
}
|
||||
die new Thrift::TTransportException($error, Thrift::TTransportException::NOT_OPEN);
|
||||
die Thrift::TTransportException->new($error, Thrift::TTransportException::NOT_OPEN);
|
||||
};
|
||||
|
||||
return $sock;
|
||||
|
|
4
vendor/git.apache.org/thrift.git/lib/perl/lib/Thrift/UnixSocket.pm
generated
vendored
4
vendor/git.apache.org/thrift.git/lib/perl/lib/Thrift/UnixSocket.pm
generated
vendored
|
@ -35,7 +35,7 @@ use version 0.77; our $VERSION = version->declare("$Thrift::VERSION");
|
|||
# Takes a unix domain socket filename.
|
||||
# See Thrift::Socket for base class parameters.
|
||||
# @param[in] path path to unix socket file
|
||||
# @example my $sock = new Thrift::UnixSocket($path);
|
||||
# @example my $sock = Thrift::UnixSocket->new($path);
|
||||
#
|
||||
sub new
|
||||
{
|
||||
|
@ -58,7 +58,7 @@ sub __open
|
|||
if ($self->{debug}) {
|
||||
$self->{debugHandler}->($error);
|
||||
}
|
||||
die new Thrift::TTransportException($error, Thrift::TTransportException::NOT_OPEN);
|
||||
die Thrift::TTransportException->new($error, Thrift::TTransportException::NOT_OPEN);
|
||||
};
|
||||
|
||||
return $sock;
|
||||
|
|
2
vendor/git.apache.org/thrift.git/lib/php/lib/Base/TBase.php
generated
vendored
2
vendor/git.apache.org/thrift.git/lib/php/lib/Base/TBase.php
generated
vendored
|
@ -33,7 +33,7 @@ use Thrift\Type\TType;
|
|||
*/
|
||||
abstract class TBase
|
||||
{
|
||||
static public $tmethod = array(
|
||||
public static $tmethod = array(
|
||||
TType::BOOL => 'Bool',
|
||||
TType::BYTE => 'Byte',
|
||||
TType::I16 => 'I16',
|
||||
|
|
2
vendor/git.apache.org/thrift.git/lib/php/lib/Exception/TApplicationException.php
generated
vendored
2
vendor/git.apache.org/thrift.git/lib/php/lib/Exception/TApplicationException.php
generated
vendored
|
@ -26,7 +26,7 @@ use Thrift\Type\TType;
|
|||
|
||||
class TApplicationException extends TException
|
||||
{
|
||||
static public $_TSPEC =
|
||||
public static $_TSPEC =
|
||||
array(1 => array('var' => 'message',
|
||||
'type' => TType::STRING),
|
||||
2 => array('var' => 'code',
|
||||
|
|
2
vendor/git.apache.org/thrift.git/lib/php/lib/Exception/TException.php
generated
vendored
2
vendor/git.apache.org/thrift.git/lib/php/lib/Exception/TException.php
generated
vendored
|
@ -56,7 +56,7 @@ class TException extends \Exception
|
|||
}
|
||||
}
|
||||
|
||||
static public $tmethod = array(
|
||||
public static $tmethod = array(
|
||||
TType::BOOL => 'Bool',
|
||||
TType::BYTE => 'Byte',
|
||||
TType::I16 => 'I16',
|
||||
|
|
18
vendor/git.apache.org/thrift.git/lib/php/lib/Transport/TCurlClient.php
generated
vendored
18
vendor/git.apache.org/thrift.git/lib/php/lib/Transport/TCurlClient.php
generated
vendored
|
@ -169,6 +169,24 @@ class TCurlClient extends TTransport
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Guarantees that the full amount of data is read. Since TCurlClient gets entire payload at
|
||||
* once, parent readAll cannot be used.
|
||||
*
|
||||
* @return string The data, of exact length
|
||||
* @throws TTransportException if cannot read data
|
||||
*/
|
||||
public function readAll($len)
|
||||
{
|
||||
$data = $this->read($len);
|
||||
|
||||
if (TStringFuncFactory::create()->strlen($data) !== $len) {
|
||||
throw new TTransportException('TCurlClient could not read '.$len.' bytes');
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes some data into the pending buffer
|
||||
*
|
||||
|
|
25
vendor/git.apache.org/thrift.git/lib/php/lib/Transport/THttpClient.php
generated
vendored
25
vendor/git.apache.org/thrift.git/lib/php/lib/Transport/THttpClient.php
generated
vendored
|
@ -88,14 +88,23 @@ class THttpClient extends TTransport
|
|||
*/
|
||||
protected $headers_;
|
||||
|
||||
/**
|
||||
* Context additional options
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $context_;
|
||||
|
||||
/**
|
||||
* Make a new HTTP client.
|
||||
*
|
||||
* @param string $host
|
||||
* @param int $port
|
||||
* @param int $port
|
||||
* @param string $uri
|
||||
* @param string $scheme
|
||||
* @param array $context
|
||||
*/
|
||||
public function __construct($host, $port = 80, $uri = '', $scheme = 'http')
|
||||
public function __construct($host, $port = 80, $uri = '', $scheme = 'http', array $context = array())
|
||||
{
|
||||
if ((TStringFuncFactory::create()->strlen($uri) > 0) && ($uri{0} != '/')) {
|
||||
$uri = '/' . $uri;
|
||||
|
@ -108,6 +117,7 @@ class THttpClient extends TTransport
|
|||
$this->handle_ = null;
|
||||
$this->timeout_ = null;
|
||||
$this->headers_ = array();
|
||||
$this->context_ = $context;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -211,16 +221,21 @@ class THttpClient extends TTransport
|
|||
$headers[] = "$key: $value";
|
||||
}
|
||||
|
||||
$options = array('method' => 'POST',
|
||||
$options = $this->context_;
|
||||
|
||||
$baseHttpOptions = isset($options["http"]) ? $options["http"] : array();
|
||||
|
||||
$httpOptions = $baseHttpOptions + array('method' => 'POST',
|
||||
'header' => implode("\r\n", $headers),
|
||||
'max_redirects' => 1,
|
||||
'content' => $this->buf_);
|
||||
if ($this->timeout_ > 0) {
|
||||
$options['timeout'] = $this->timeout_;
|
||||
$httpOptions['timeout'] = $this->timeout_;
|
||||
}
|
||||
$this->buf_ = '';
|
||||
|
||||
$contextid = stream_context_create(array('http' => $options));
|
||||
$options["http"] = $httpOptions;
|
||||
$contextid = stream_context_create($options);
|
||||
$this->handle_ = @fopen(
|
||||
$this->scheme_ . '://' . $host . $this->uri_,
|
||||
'r',
|
||||
|
|
|
@ -305,7 +305,7 @@ public:
|
|||
|
||||
void skip(size_t len) {
|
||||
while (len) {
|
||||
size_t chunk_size = std::min(len, buffer_used);
|
||||
size_t chunk_size = (std::min)(len, buffer_used);
|
||||
if (chunk_size) {
|
||||
buffer_ptr = reinterpret_cast<char*>(buffer_ptr) + chunk_size;
|
||||
buffer_used -= chunk_size;
|
||||
|
@ -318,7 +318,7 @@ public:
|
|||
|
||||
void readBytes(void* buf, size_t len) {
|
||||
while (len) {
|
||||
size_t chunk_size = std::min(len, buffer_used);
|
||||
size_t chunk_size = (std::min)(len, buffer_used);
|
||||
if (chunk_size) {
|
||||
memcpy(buf, buffer_ptr, chunk_size);
|
||||
buffer_ptr = reinterpret_cast<char*>(buffer_ptr) + chunk_size;
|
||||
|
|
2
vendor/git.apache.org/thrift.git/lib/py/setup.py
generated
vendored
2
vendor/git.apache.org/thrift.git/lib/py/setup.py
generated
vendored
|
@ -90,7 +90,7 @@ def run_setup(with_binary):
|
|||
twisted_deps = ['twisted']
|
||||
|
||||
setup(name='thrift',
|
||||
version='1.0.0-dev',
|
||||
version='0.12.0',
|
||||
description='Python bindings for the Apache Thrift RPC system',
|
||||
author='Thrift Developers',
|
||||
author_email='dev@thrift.apache.org',
|
||||
|
|
4
vendor/git.apache.org/thrift.git/lib/py/src/ext/protocol.h
generated
vendored
4
vendor/git.apache.org/thrift.git/lib/py/src/ext/protocol.h
generated
vendored
|
@ -33,8 +33,8 @@ class ProtocolBase {
|
|||
|
||||
public:
|
||||
ProtocolBase()
|
||||
: stringLimit_(std::numeric_limits<int32_t>::max()),
|
||||
containerLimit_(std::numeric_limits<int32_t>::max()),
|
||||
: stringLimit_((std::numeric_limits<int32_t>::max)()),
|
||||
containerLimit_((std::numeric_limits<int32_t>::max)()),
|
||||
output_(NULL) {}
|
||||
inline virtual ~ProtocolBase();
|
||||
|
||||
|
|
20
vendor/git.apache.org/thrift.git/lib/py/src/ext/protocol.tcc
generated
vendored
20
vendor/git.apache.org/thrift.git/lib/py/src/ext/protocol.tcc
generated
vendored
|
@ -144,7 +144,7 @@ inline int read_buffer(PyObject* buf, char** output, int len) {
|
|||
*output = PyBytes_AS_STRING(buf2->buf) + buf2->pos;
|
||||
#endif
|
||||
Py_ssize_t pos0 = buf2->pos;
|
||||
buf2->pos = std::min(buf2->pos + static_cast<Py_ssize_t>(len), buf2->string_size);
|
||||
buf2->pos = (std::min)(buf2->pos + static_cast<Py_ssize_t>(len), buf2->string_size);
|
||||
return static_cast<int>(buf2->pos - pos0);
|
||||
}
|
||||
}
|
||||
|
@ -212,7 +212,7 @@ inline bool check_ssize_t_32(Py_ssize_t len) {
|
|||
if (INT_CONV_ERROR_OCCURRED(len)) {
|
||||
return false;
|
||||
}
|
||||
if (!CHECK_RANGE(len, 0, std::numeric_limits<int32_t>::max())) {
|
||||
if (!CHECK_RANGE(len, 0, (std::numeric_limits<int32_t>::max)())) {
|
||||
PyErr_SetString(PyExc_OverflowError, "size out of range: exceeded INT32_MAX");
|
||||
return false;
|
||||
}
|
||||
|
@ -360,8 +360,8 @@ bool ProtocolBase<Impl>::encodeValue(PyObject* value, TType type, PyObject* type
|
|||
case T_I08: {
|
||||
int8_t val;
|
||||
|
||||
if (!parse_pyint(value, &val, std::numeric_limits<int8_t>::min(),
|
||||
std::numeric_limits<int8_t>::max())) {
|
||||
if (!parse_pyint(value, &val, (std::numeric_limits<int8_t>::min)(),
|
||||
(std::numeric_limits<int8_t>::max)())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -371,8 +371,8 @@ bool ProtocolBase<Impl>::encodeValue(PyObject* value, TType type, PyObject* type
|
|||
case T_I16: {
|
||||
int16_t val;
|
||||
|
||||
if (!parse_pyint(value, &val, std::numeric_limits<int16_t>::min(),
|
||||
std::numeric_limits<int16_t>::max())) {
|
||||
if (!parse_pyint(value, &val, (std::numeric_limits<int16_t>::min)(),
|
||||
(std::numeric_limits<int16_t>::max)())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -382,8 +382,8 @@ bool ProtocolBase<Impl>::encodeValue(PyObject* value, TType type, PyObject* type
|
|||
case T_I32: {
|
||||
int32_t val;
|
||||
|
||||
if (!parse_pyint(value, &val, std::numeric_limits<int32_t>::min(),
|
||||
std::numeric_limits<int32_t>::max())) {
|
||||
if (!parse_pyint(value, &val, (std::numeric_limits<int32_t>::min)(),
|
||||
(std::numeric_limits<int32_t>::max)())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -397,8 +397,8 @@ bool ProtocolBase<Impl>::encodeValue(PyObject* value, TType type, PyObject* type
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!CHECK_RANGE(nval, std::numeric_limits<int64_t>::min(),
|
||||
std::numeric_limits<int64_t>::max())) {
|
||||
if (!CHECK_RANGE(nval, (std::numeric_limits<int64_t>::min)(),
|
||||
(std::numeric_limits<int64_t>::max)())) {
|
||||
PyErr_SetString(PyExc_OverflowError, "int out of range");
|
||||
return false;
|
||||
}
|
||||
|
|
11
vendor/git.apache.org/thrift.git/lib/py/src/transport/TSocket.py
generated
vendored
11
vendor/git.apache.org/thrift.git/lib/py/src/transport/TSocket.py
generated
vendored
|
@ -159,6 +159,15 @@ class TServerSocket(TSocketBase, TServerTransportBase):
|
|||
self._unix_socket = unix_socket
|
||||
self._socket_family = socket_family
|
||||
self.handle = None
|
||||
self._backlog = 128
|
||||
|
||||
def setBacklog(self, backlog=None):
|
||||
if not self.handle:
|
||||
self._backlog = backlog
|
||||
else:
|
||||
# We cann't update backlog when it is already listening, since the
|
||||
# handle has been created.
|
||||
logger.warn('You have to set backlog before listen.')
|
||||
|
||||
def listen(self):
|
||||
res0 = self._resolveAddr()
|
||||
|
@ -183,7 +192,7 @@ class TServerSocket(TSocketBase, TServerTransportBase):
|
|||
if hasattr(self.handle, 'settimeout'):
|
||||
self.handle.settimeout(None)
|
||||
self.handle.bind(res[4])
|
||||
self.handle.listen(128)
|
||||
self.handle.listen(self._backlog)
|
||||
|
||||
def accept(self):
|
||||
client, addr = self.handle.accept()
|
||||
|
|
2
vendor/git.apache.org/thrift.git/lib/rb/thrift.gemspec
generated
vendored
2
vendor/git.apache.org/thrift.git/lib/rb/thrift.gemspec
generated
vendored
|
@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
|
|||
|
||||
Gem::Specification.new do |s|
|
||||
s.name = 'thrift'
|
||||
s.version = '1.0.0.0'
|
||||
s.version = '0.12.0'
|
||||
s.authors = ['Thrift Developers']
|
||||
s.email = ['dev@thrift.apache.org']
|
||||
s.homepage = 'http://thrift.apache.org'
|
||||
|
|
2
vendor/git.apache.org/thrift.git/lib/rs/Cargo.toml
generated
vendored
2
vendor/git.apache.org/thrift.git/lib/rs/Cargo.toml
generated
vendored
|
@ -1,7 +1,7 @@
|
|||
[package]
|
||||
name = "thrift"
|
||||
description = "Rust bindings for the Apache Thrift RPC system"
|
||||
version = "1.0.0"
|
||||
version = "0.12.0"
|
||||
license = "Apache-2.0"
|
||||
authors = ["Apache Thrift Developers <dev@thrift.apache.org>"]
|
||||
homepage = "http://thrift.apache.org"
|
||||
|
|
51
vendor/git.apache.org/thrift.git/lib/rs/README.md
generated
vendored
51
vendor/git.apache.org/thrift.git/lib/rs/README.md
generated
vendored
|
@ -37,6 +37,57 @@ Thrift compiler you're using.
|
|||
|
||||
Full [Rustdoc](https://docs.rs/thrift/)
|
||||
|
||||
## Compatibility
|
||||
|
||||
The Rust library and auto-generated code targets Rust versions 1.28+.
|
||||
It does not currently use any Rust 2018 features.
|
||||
|
||||
### Breaking Changes
|
||||
|
||||
Breaking changes are minimized. When they are made they will be outlined below with transition guidelines.
|
||||
|
||||
##### Thrift 0.12.0
|
||||
|
||||
* **[THRIFT-4529]** - Rust enum variants are now camel-cased instead of uppercased to conform to Rust naming conventions
|
||||
|
||||
Previously, enum variants were uppercased in the auto-generated code.
|
||||
For example, the following thrift enum:
|
||||
|
||||
```thrift
|
||||
// THRIFT
|
||||
enum Operation {
|
||||
ADD,
|
||||
SUBTRACT,
|
||||
MULTIPLY,
|
||||
DIVIDE,
|
||||
}
|
||||
```
|
||||
|
||||
used to generate:
|
||||
|
||||
```rust
|
||||
// OLD AUTO-GENERATED RUST
|
||||
pub enum Operation {
|
||||
ADD,
|
||||
SUBTRACT,
|
||||
MULTIPLY,
|
||||
DIVIDE,
|
||||
}
|
||||
```
|
||||
It *now* generates:
|
||||
```rust
|
||||
// NEW AUTO-GENERATED RUST
|
||||
pub enum Operation {
|
||||
Add,
|
||||
Subtract,
|
||||
Multiply,
|
||||
Divide,
|
||||
}
|
||||
```
|
||||
|
||||
You will have to change all enum variants in your code to use camel-cased names.
|
||||
This should be a search and replace.
|
||||
|
||||
## Contributing
|
||||
|
||||
Bug reports and PRs are always welcome! Please see the
|
||||
|
|
158
vendor/git.apache.org/thrift.git/lib/rs/src/errors.rs
generated
vendored
158
vendor/git.apache.org/thrift.git/lib/rs/src/errors.rs
generated
vendored
|
@ -198,8 +198,9 @@ impl Error {
|
|||
/// Create an `ApplicationError` from its wire representation.
|
||||
///
|
||||
/// Application code **should never** call this method directly.
|
||||
pub fn read_application_error_from_in_protocol(i: &mut TInputProtocol,)
|
||||
-> ::Result<ApplicationError> {
|
||||
pub fn read_application_error_from_in_protocol(
|
||||
i: &mut TInputProtocol,
|
||||
) -> ::Result<ApplicationError> {
|
||||
let mut message = "general remote error".to_owned();
|
||||
let mut kind = ApplicationErrorKind::Unknown;
|
||||
|
||||
|
@ -224,9 +225,8 @@ impl Error {
|
|||
}
|
||||
2 => {
|
||||
let remote_type_as_int = i.read_i32()?;
|
||||
let remote_kind: ApplicationErrorKind =
|
||||
TryFrom::try_from(remote_type_as_int)
|
||||
.unwrap_or(ApplicationErrorKind::Unknown);
|
||||
let remote_kind: ApplicationErrorKind = TryFrom::try_from(remote_type_as_int)
|
||||
.unwrap_or(ApplicationErrorKind::Unknown);
|
||||
i.read_field_end()?;
|
||||
kind = remote_kind;
|
||||
}
|
||||
|
@ -238,12 +238,10 @@ impl Error {
|
|||
|
||||
i.read_struct_end()?;
|
||||
|
||||
Ok(
|
||||
ApplicationError {
|
||||
kind: kind,
|
||||
message: message,
|
||||
},
|
||||
)
|
||||
Ok(ApplicationError {
|
||||
kind: kind,
|
||||
message: message,
|
||||
})
|
||||
}
|
||||
|
||||
/// Convert an `ApplicationError` into its wire representation and write
|
||||
|
@ -254,7 +252,9 @@ impl Error {
|
|||
e: &ApplicationError,
|
||||
o: &mut TOutputProtocol,
|
||||
) -> ::Result<()> {
|
||||
o.write_struct_begin(&TStructIdentifier { name: "TApplicationException".to_owned() },)?;
|
||||
o.write_struct_begin(&TStructIdentifier {
|
||||
name: "TApplicationException".to_owned(),
|
||||
})?;
|
||||
|
||||
let message_field = TFieldIdentifier::new("message", TType::String, 1);
|
||||
let type_field = TFieldIdentifier::new("type", TType::I32, 2);
|
||||
|
@ -309,23 +309,19 @@ impl Display for Error {
|
|||
|
||||
impl From<String> for Error {
|
||||
fn from(s: String) -> Self {
|
||||
Error::Application(
|
||||
ApplicationError {
|
||||
kind: ApplicationErrorKind::Unknown,
|
||||
message: s,
|
||||
},
|
||||
)
|
||||
Error::Application(ApplicationError {
|
||||
kind: ApplicationErrorKind::Unknown,
|
||||
message: s,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> From<&'a str> for Error {
|
||||
fn from(s: &'a str) -> Self {
|
||||
Error::Application(
|
||||
ApplicationError {
|
||||
kind: ApplicationErrorKind::Unknown,
|
||||
message: String::from(s),
|
||||
},
|
||||
)
|
||||
Error::Application(ApplicationError {
|
||||
kind: ApplicationErrorKind::Unknown,
|
||||
message: String::from(s),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -427,16 +423,10 @@ impl TryFrom<i32> for TransportErrorKind {
|
|||
4 => Ok(TransportErrorKind::EndOfFile),
|
||||
5 => Ok(TransportErrorKind::NegativeSize),
|
||||
6 => Ok(TransportErrorKind::SizeLimit),
|
||||
_ => {
|
||||
Err(
|
||||
Error::Protocol(
|
||||
ProtocolError {
|
||||
kind: ProtocolErrorKind::Unknown,
|
||||
message: format!("cannot convert {} to TransportErrorKind", from),
|
||||
},
|
||||
),
|
||||
)
|
||||
}
|
||||
_ => Err(Error::Protocol(ProtocolError {
|
||||
kind: ProtocolErrorKind::Unknown,
|
||||
message: format!("cannot convert {} to TransportErrorKind", from),
|
||||
})),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -444,47 +434,29 @@ impl TryFrom<i32> for TransportErrorKind {
|
|||
impl From<io::Error> for Error {
|
||||
fn from(err: io::Error) -> Self {
|
||||
match err.kind() {
|
||||
io::ErrorKind::ConnectionReset |
|
||||
io::ErrorKind::ConnectionRefused |
|
||||
io::ErrorKind::NotConnected => {
|
||||
Error::Transport(
|
||||
TransportError {
|
||||
kind: TransportErrorKind::NotOpen,
|
||||
message: err.description().to_owned(),
|
||||
},
|
||||
)
|
||||
}
|
||||
io::ErrorKind::AlreadyExists => {
|
||||
Error::Transport(
|
||||
TransportError {
|
||||
kind: TransportErrorKind::AlreadyOpen,
|
||||
message: err.description().to_owned(),
|
||||
},
|
||||
)
|
||||
}
|
||||
io::ErrorKind::TimedOut => {
|
||||
Error::Transport(
|
||||
TransportError {
|
||||
kind: TransportErrorKind::TimedOut,
|
||||
message: err.description().to_owned(),
|
||||
},
|
||||
)
|
||||
}
|
||||
io::ErrorKind::UnexpectedEof => {
|
||||
Error::Transport(
|
||||
TransportError {
|
||||
kind: TransportErrorKind::EndOfFile,
|
||||
message: err.description().to_owned(),
|
||||
},
|
||||
)
|
||||
}
|
||||
io::ErrorKind::ConnectionReset
|
||||
| io::ErrorKind::ConnectionRefused
|
||||
| io::ErrorKind::NotConnected => Error::Transport(TransportError {
|
||||
kind: TransportErrorKind::NotOpen,
|
||||
message: err.description().to_owned(),
|
||||
}),
|
||||
io::ErrorKind::AlreadyExists => Error::Transport(TransportError {
|
||||
kind: TransportErrorKind::AlreadyOpen,
|
||||
message: err.description().to_owned(),
|
||||
}),
|
||||
io::ErrorKind::TimedOut => Error::Transport(TransportError {
|
||||
kind: TransportErrorKind::TimedOut,
|
||||
message: err.description().to_owned(),
|
||||
}),
|
||||
io::ErrorKind::UnexpectedEof => Error::Transport(TransportError {
|
||||
kind: TransportErrorKind::EndOfFile,
|
||||
message: err.description().to_owned(),
|
||||
}),
|
||||
_ => {
|
||||
Error::Transport(
|
||||
TransportError {
|
||||
kind: TransportErrorKind::Unknown,
|
||||
message: err.description().to_owned(), // FIXME: use io error's debug string
|
||||
},
|
||||
)
|
||||
Error::Transport(TransportError {
|
||||
kind: TransportErrorKind::Unknown,
|
||||
message: err.description().to_owned(), // FIXME: use io error's debug string
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -492,12 +464,10 @@ impl From<io::Error> for Error {
|
|||
|
||||
impl From<string::FromUtf8Error> for Error {
|
||||
fn from(err: string::FromUtf8Error) -> Self {
|
||||
Error::Protocol(
|
||||
ProtocolError {
|
||||
kind: ProtocolErrorKind::InvalidData,
|
||||
message: err.description().to_owned(), // FIXME: use fmt::Error's debug string
|
||||
},
|
||||
)
|
||||
Error::Protocol(ProtocolError {
|
||||
kind: ProtocolErrorKind::InvalidData,
|
||||
message: err.description().to_owned(), // FIXME: use fmt::Error's debug string
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -583,16 +553,10 @@ impl TryFrom<i32> for ProtocolErrorKind {
|
|||
4 => Ok(ProtocolErrorKind::BadVersion),
|
||||
5 => Ok(ProtocolErrorKind::NotImplemented),
|
||||
6 => Ok(ProtocolErrorKind::DepthLimit),
|
||||
_ => {
|
||||
Err(
|
||||
Error::Protocol(
|
||||
ProtocolError {
|
||||
kind: ProtocolErrorKind::Unknown,
|
||||
message: format!("cannot convert {} to ProtocolErrorKind", from),
|
||||
},
|
||||
),
|
||||
)
|
||||
}
|
||||
_ => Err(Error::Protocol(ProtocolError {
|
||||
kind: ProtocolErrorKind::Unknown,
|
||||
message: format!("cannot convert {} to ProtocolErrorKind", from),
|
||||
})),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -697,16 +661,10 @@ impl TryFrom<i32> for ApplicationErrorKind {
|
|||
8 => Ok(ApplicationErrorKind::InvalidTransform),
|
||||
9 => Ok(ApplicationErrorKind::InvalidProtocol),
|
||||
10 => Ok(ApplicationErrorKind::UnsupportedClientType),
|
||||
_ => {
|
||||
Err(
|
||||
Error::Application(
|
||||
ApplicationError {
|
||||
kind: ApplicationErrorKind::Unknown,
|
||||
message: format!("cannot convert {} to ApplicationErrorKind", from),
|
||||
},
|
||||
),
|
||||
)
|
||||
}
|
||||
_ => Err(Error::Application(ApplicationError {
|
||||
kind: ApplicationErrorKind::Unknown,
|
||||
message: format!("cannot convert {} to ApplicationErrorKind", from),
|
||||
})),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
12
vendor/git.apache.org/thrift.git/lib/rs/src/lib.rs
generated
vendored
12
vendor/git.apache.org/thrift.git/lib/rs/src/lib.rs
generated
vendored
|
@ -63,13 +63,11 @@ extern crate log;
|
|||
/// return the value contained in the result, i.e. `expr.unwrap()`.
|
||||
#[cfg(test)]
|
||||
macro_rules! assert_success {
|
||||
($e: expr) => {
|
||||
{
|
||||
let res = $e;
|
||||
assert!(res.is_ok());
|
||||
res.unwrap()
|
||||
}
|
||||
}
|
||||
($e: expr) => {{
|
||||
let res = $e;
|
||||
assert!(res.is_ok());
|
||||
res.unwrap()
|
||||
}};
|
||||
}
|
||||
|
||||
pub mod protocol;
|
||||
|
|
290
vendor/git.apache.org/thrift.git/lib/rs/src/protocol/binary.rs
generated
vendored
290
vendor/git.apache.org/thrift.git/lib/rs/src/protocol/binary.rs
generated
vendored
|
@ -19,11 +19,13 @@ use byteorder::{BigEndian, ByteOrder, ReadBytesExt, WriteBytesExt};
|
|||
use std::convert::From;
|
||||
use try_from::TryFrom;
|
||||
|
||||
use {ProtocolError, ProtocolErrorKind};
|
||||
use transport::{TReadTransport, TWriteTransport};
|
||||
use super::{TFieldIdentifier, TInputProtocol, TInputProtocolFactory, TListIdentifier,
|
||||
TMapIdentifier, TMessageIdentifier, TMessageType};
|
||||
use super::{
|
||||
TFieldIdentifier, TInputProtocol, TInputProtocolFactory, TListIdentifier, TMapIdentifier,
|
||||
TMessageIdentifier, TMessageType,
|
||||
};
|
||||
use super::{TOutputProtocol, TOutputProtocolFactory, TSetIdentifier, TStructIdentifier, TType};
|
||||
use transport::{TReadTransport, TWriteTransport};
|
||||
use {ProtocolError, ProtocolErrorKind};
|
||||
|
||||
const BINARY_PROTOCOL_VERSION_1: u32 = 0x80010000;
|
||||
|
||||
|
@ -90,14 +92,10 @@ where
|
|||
// apparently we got a protocol-version header - check
|
||||
// it, and if it matches, read the rest of the fields
|
||||
if first_bytes[0..2] != [0x80, 0x01] {
|
||||
Err(
|
||||
::Error::Protocol(
|
||||
ProtocolError {
|
||||
kind: ProtocolErrorKind::BadVersion,
|
||||
message: format!("received bad version: {:?}", &first_bytes[0..2]),
|
||||
},
|
||||
),
|
||||
)
|
||||
Err(::Error::Protocol(ProtocolError {
|
||||
kind: ProtocolErrorKind::BadVersion,
|
||||
message: format!("received bad version: {:?}", &first_bytes[0..2]),
|
||||
}))
|
||||
} else {
|
||||
let message_type: TMessageType = TryFrom::try_from(first_bytes[3])?;
|
||||
let name = self.read_string()?;
|
||||
|
@ -110,20 +108,16 @@ where
|
|||
if self.strict {
|
||||
// we're in strict mode however, and that always
|
||||
// requires the protocol-version header to be written first
|
||||
Err(
|
||||
::Error::Protocol(
|
||||
ProtocolError {
|
||||
kind: ProtocolErrorKind::BadVersion,
|
||||
message: format!("received bad version: {:?}", &first_bytes[0..2]),
|
||||
},
|
||||
),
|
||||
)
|
||||
Err(::Error::Protocol(ProtocolError {
|
||||
kind: ProtocolErrorKind::BadVersion,
|
||||
message: format!("received bad version: {:?}", &first_bytes[0..2]),
|
||||
}))
|
||||
} else {
|
||||
// in the non-strict version the first message field
|
||||
// is the message name. strings (byte arrays) are length-prefixed,
|
||||
// so we've just read the length in the first 4 bytes
|
||||
let name_size = BigEndian::read_i32(&first_bytes) as usize;
|
||||
let mut name_buf: Vec<u8> = Vec::with_capacity(name_size);
|
||||
let mut name_buf: Vec<u8> = vec![0; name_size];
|
||||
self.transport.read_exact(&mut name_buf)?;
|
||||
let name = String::from_utf8(name_buf)?;
|
||||
|
||||
|
@ -154,7 +148,9 @@ where
|
|||
TType::Stop => Ok(0),
|
||||
_ => self.read_i16(),
|
||||
}?;
|
||||
Ok(TFieldIdentifier::new::<Option<String>, String, i16>(None, field_type, id),)
|
||||
Ok(TFieldIdentifier::new::<Option<String>, String, i16>(
|
||||
None, field_type, id,
|
||||
))
|
||||
}
|
||||
|
||||
fn read_field_end(&mut self) -> ::Result<()> {
|
||||
|
@ -183,27 +179,19 @@ where
|
|||
}
|
||||
|
||||
fn read_i16(&mut self) -> ::Result<i16> {
|
||||
self.transport
|
||||
.read_i16::<BigEndian>()
|
||||
.map_err(From::from)
|
||||
self.transport.read_i16::<BigEndian>().map_err(From::from)
|
||||
}
|
||||
|
||||
fn read_i32(&mut self) -> ::Result<i32> {
|
||||
self.transport
|
||||
.read_i32::<BigEndian>()
|
||||
.map_err(From::from)
|
||||
self.transport.read_i32::<BigEndian>().map_err(From::from)
|
||||
}
|
||||
|
||||
fn read_i64(&mut self) -> ::Result<i64> {
|
||||
self.transport
|
||||
.read_i64::<BigEndian>()
|
||||
.map_err(From::from)
|
||||
self.transport.read_i64::<BigEndian>().map_err(From::from)
|
||||
}
|
||||
|
||||
fn read_double(&mut self) -> ::Result<f64> {
|
||||
self.transport
|
||||
.read_f64::<BigEndian>()
|
||||
.map_err(From::from)
|
||||
self.transport.read_f64::<BigEndian>().map_err(From::from)
|
||||
}
|
||||
|
||||
fn read_string(&mut self) -> ::Result<String> {
|
||||
|
@ -346,17 +334,13 @@ where
|
|||
|
||||
fn write_field_begin(&mut self, identifier: &TFieldIdentifier) -> ::Result<()> {
|
||||
if identifier.id.is_none() && identifier.field_type != TType::Stop {
|
||||
return Err(
|
||||
::Error::Protocol(
|
||||
ProtocolError {
|
||||
kind: ProtocolErrorKind::Unknown,
|
||||
message: format!(
|
||||
"cannot write identifier {:?} without sequence number",
|
||||
&identifier
|
||||
),
|
||||
},
|
||||
return Err(::Error::Protocol(ProtocolError {
|
||||
kind: ProtocolErrorKind::Unknown,
|
||||
message: format!(
|
||||
"cannot write identifier {:?} without sequence number",
|
||||
&identifier
|
||||
),
|
||||
);
|
||||
}));
|
||||
}
|
||||
|
||||
self.write_byte(field_type_to_u8(identifier.field_type))?;
|
||||
|
@ -393,27 +377,19 @@ where
|
|||
}
|
||||
|
||||
fn write_i16(&mut self, i: i16) -> ::Result<()> {
|
||||
self.transport
|
||||
.write_i16::<BigEndian>(i)
|
||||
.map_err(From::from)
|
||||
self.transport.write_i16::<BigEndian>(i).map_err(From::from)
|
||||
}
|
||||
|
||||
fn write_i32(&mut self, i: i32) -> ::Result<()> {
|
||||
self.transport
|
||||
.write_i32::<BigEndian>(i)
|
||||
.map_err(From::from)
|
||||
self.transport.write_i32::<BigEndian>(i).map_err(From::from)
|
||||
}
|
||||
|
||||
fn write_i64(&mut self, i: i64) -> ::Result<()> {
|
||||
self.transport
|
||||
.write_i64::<BigEndian>(i)
|
||||
.map_err(From::from)
|
||||
self.transport.write_i64::<BigEndian>(i).map_err(From::from)
|
||||
}
|
||||
|
||||
fn write_double(&mut self, d: f64) -> ::Result<()> {
|
||||
self.transport
|
||||
.write_f64::<BigEndian>(d)
|
||||
.map_err(From::from)
|
||||
self.transport.write_f64::<BigEndian>(d).map_err(From::from)
|
||||
}
|
||||
|
||||
fn write_string(&mut self, s: &str) -> ::Result<()> {
|
||||
|
@ -520,36 +496,32 @@ fn field_type_from_u8(b: u8) -> ::Result<TType> {
|
|||
0x0F => Ok(TType::List),
|
||||
0x10 => Ok(TType::Utf8),
|
||||
0x11 => Ok(TType::Utf16),
|
||||
unkn => {
|
||||
Err(
|
||||
::Error::Protocol(
|
||||
ProtocolError {
|
||||
kind: ProtocolErrorKind::InvalidData,
|
||||
message: format!("cannot convert {} to TType", unkn),
|
||||
},
|
||||
),
|
||||
)
|
||||
}
|
||||
unkn => Err(::Error::Protocol(ProtocolError {
|
||||
kind: ProtocolErrorKind::InvalidData,
|
||||
message: format!("cannot convert {} to TType", unkn),
|
||||
})),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
||||
use protocol::{TFieldIdentifier, TInputProtocol, TListIdentifier, TMapIdentifier,
|
||||
TMessageIdentifier, TMessageType, TOutputProtocol, TSetIdentifier,
|
||||
TStructIdentifier, TType};
|
||||
use protocol::{
|
||||
TFieldIdentifier, TInputProtocol, TListIdentifier, TMapIdentifier, TMessageIdentifier,
|
||||
TMessageType, TOutputProtocol, TSetIdentifier, TStructIdentifier, TType,
|
||||
};
|
||||
use transport::{ReadHalf, TBufferChannel, TIoChannel, WriteHalf};
|
||||
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn must_write_message_call_begin() {
|
||||
let (_, mut o_prot) = test_objects();
|
||||
fn must_write_strict_message_call_begin() {
|
||||
let (_, mut o_prot) = test_objects(true);
|
||||
|
||||
let ident = TMessageIdentifier::new("test", TMessageType::Call, 1);
|
||||
assert!(o_prot.write_message_begin(&ident).is_ok());
|
||||
|
||||
#[cfg_attr(rustfmt, rustfmt::skip)]
|
||||
let expected: [u8; 16] = [
|
||||
0x80,
|
||||
0x01,
|
||||
|
@ -573,12 +545,40 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn must_write_message_reply_begin() {
|
||||
let (_, mut o_prot) = test_objects();
|
||||
fn must_write_non_strict_message_call_begin() {
|
||||
let (_, mut o_prot) = test_objects(false);
|
||||
|
||||
let ident = TMessageIdentifier::new("test", TMessageType::Call, 1);
|
||||
assert!(o_prot.write_message_begin(&ident).is_ok());
|
||||
|
||||
#[cfg_attr(rustfmt, rustfmt::skip)]
|
||||
let expected: [u8; 13] = [
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x04,
|
||||
0x74,
|
||||
0x65,
|
||||
0x73,
|
||||
0x74,
|
||||
0x01,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x01,
|
||||
];
|
||||
|
||||
assert_eq_written_bytes!(o_prot, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn must_write_strict_message_reply_begin() {
|
||||
let (_, mut o_prot) = test_objects(true);
|
||||
|
||||
let ident = TMessageIdentifier::new("test", TMessageType::Reply, 10);
|
||||
assert!(o_prot.write_message_begin(&ident).is_ok());
|
||||
|
||||
#[cfg_attr(rustfmt, rustfmt::skip)]
|
||||
let expected: [u8; 16] = [
|
||||
0x80,
|
||||
0x01,
|
||||
|
@ -601,9 +601,49 @@ mod tests {
|
|||
assert_eq_written_bytes!(o_prot, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn must_write_non_strict_message_reply_begin() {
|
||||
let (_, mut o_prot) = test_objects(false);
|
||||
|
||||
let ident = TMessageIdentifier::new("test", TMessageType::Reply, 10);
|
||||
assert!(o_prot.write_message_begin(&ident).is_ok());
|
||||
|
||||
#[cfg_attr(rustfmt, rustfmt::skip)]
|
||||
let expected: [u8; 13] = [
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x04,
|
||||
0x74,
|
||||
0x65,
|
||||
0x73,
|
||||
0x74,
|
||||
0x02,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x0A,
|
||||
];
|
||||
|
||||
assert_eq_written_bytes!(o_prot, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn must_round_trip_strict_message_begin() {
|
||||
let (mut i_prot, mut o_prot) = test_objects();
|
||||
let (mut i_prot, mut o_prot) = test_objects(true);
|
||||
|
||||
let sent_ident = TMessageIdentifier::new("test", TMessageType::Call, 1);
|
||||
assert!(o_prot.write_message_begin(&sent_ident).is_ok());
|
||||
|
||||
copy_write_buffer_to_read_buffer!(o_prot);
|
||||
|
||||
let received_ident = assert_success!(i_prot.read_message_begin());
|
||||
assert_eq!(&received_ident, &sent_ident);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn must_round_trip_non_strict_message_begin() {
|
||||
let (mut i_prot, mut o_prot) = test_objects(false);
|
||||
|
||||
let sent_ident = TMessageIdentifier::new("test", TMessageType::Call, 1);
|
||||
assert!(o_prot.write_message_begin(&sent_ident).is_ok());
|
||||
|
@ -616,28 +656,29 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn must_write_message_end() {
|
||||
assert_no_write(|o| o.write_message_end());
|
||||
assert_no_write(|o| o.write_message_end(), true);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn must_write_struct_begin() {
|
||||
assert_no_write(|o| o.write_struct_begin(&TStructIdentifier::new("foo")));
|
||||
assert_no_write(
|
||||
|o| o.write_struct_begin(&TStructIdentifier::new("foo")),
|
||||
true,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn must_write_struct_end() {
|
||||
assert_no_write(|o| o.write_struct_end());
|
||||
assert_no_write(|o| o.write_struct_end(), true);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn must_write_field_begin() {
|
||||
let (_, mut o_prot) = test_objects();
|
||||
let (_, mut o_prot) = test_objects(true);
|
||||
|
||||
assert!(
|
||||
o_prot
|
||||
.write_field_begin(&TFieldIdentifier::new("some_field", TType::String, 22))
|
||||
.is_ok()
|
||||
);
|
||||
assert!(o_prot
|
||||
.write_field_begin(&TFieldIdentifier::new("some_field", TType::String, 22))
|
||||
.is_ok());
|
||||
|
||||
let expected: [u8; 3] = [0x0B, 0x00, 0x16];
|
||||
assert_eq_written_bytes!(o_prot, expected);
|
||||
|
@ -645,7 +686,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn must_round_trip_field_begin() {
|
||||
let (mut i_prot, mut o_prot) = test_objects();
|
||||
let (mut i_prot, mut o_prot) = test_objects(true);
|
||||
|
||||
let sent_field_ident = TFieldIdentifier::new("foo", TType::I64, 20);
|
||||
assert!(o_prot.write_field_begin(&sent_field_ident).is_ok());
|
||||
|
@ -663,7 +704,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn must_write_stop_field() {
|
||||
let (_, mut o_prot) = test_objects();
|
||||
let (_, mut o_prot) = test_objects(true);
|
||||
|
||||
assert!(o_prot.write_field_stop().is_ok());
|
||||
|
||||
|
@ -673,7 +714,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn must_round_trip_field_stop() {
|
||||
let (mut i_prot, mut o_prot) = test_objects();
|
||||
let (mut i_prot, mut o_prot) = test_objects(true);
|
||||
|
||||
assert!(o_prot.write_field_stop().is_ok());
|
||||
|
||||
|
@ -691,18 +732,16 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn must_write_field_end() {
|
||||
assert_no_write(|o| o.write_field_end());
|
||||
assert_no_write(|o| o.write_field_end(), true);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn must_write_list_begin() {
|
||||
let (_, mut o_prot) = test_objects();
|
||||
let (_, mut o_prot) = test_objects(true);
|
||||
|
||||
assert!(
|
||||
o_prot
|
||||
.write_list_begin(&TListIdentifier::new(TType::Bool, 5))
|
||||
.is_ok()
|
||||
);
|
||||
assert!(o_prot
|
||||
.write_list_begin(&TListIdentifier::new(TType::Bool, 5))
|
||||
.is_ok());
|
||||
|
||||
let expected: [u8; 5] = [0x02, 0x00, 0x00, 0x00, 0x05];
|
||||
assert_eq_written_bytes!(o_prot, expected);
|
||||
|
@ -710,7 +749,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn must_round_trip_list_begin() {
|
||||
let (mut i_prot, mut o_prot) = test_objects();
|
||||
let (mut i_prot, mut o_prot) = test_objects(true);
|
||||
|
||||
let ident = TListIdentifier::new(TType::List, 900);
|
||||
assert!(o_prot.write_list_begin(&ident).is_ok());
|
||||
|
@ -723,18 +762,16 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn must_write_list_end() {
|
||||
assert_no_write(|o| o.write_list_end());
|
||||
assert_no_write(|o| o.write_list_end(), true);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn must_write_set_begin() {
|
||||
let (_, mut o_prot) = test_objects();
|
||||
let (_, mut o_prot) = test_objects(true);
|
||||
|
||||
assert!(
|
||||
o_prot
|
||||
.write_set_begin(&TSetIdentifier::new(TType::I16, 7))
|
||||
.is_ok()
|
||||
);
|
||||
assert!(o_prot
|
||||
.write_set_begin(&TSetIdentifier::new(TType::I16, 7))
|
||||
.is_ok());
|
||||
|
||||
let expected: [u8; 5] = [0x06, 0x00, 0x00, 0x00, 0x07];
|
||||
assert_eq_written_bytes!(o_prot, expected);
|
||||
|
@ -742,7 +779,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn must_round_trip_set_begin() {
|
||||
let (mut i_prot, mut o_prot) = test_objects();
|
||||
let (mut i_prot, mut o_prot) = test_objects(true);
|
||||
|
||||
let ident = TSetIdentifier::new(TType::I64, 2000);
|
||||
assert!(o_prot.write_set_begin(&ident).is_ok());
|
||||
|
@ -756,18 +793,16 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn must_write_set_end() {
|
||||
assert_no_write(|o| o.write_set_end());
|
||||
assert_no_write(|o| o.write_set_end(), true);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn must_write_map_begin() {
|
||||
let (_, mut o_prot) = test_objects();
|
||||
let (_, mut o_prot) = test_objects(true);
|
||||
|
||||
assert!(
|
||||
o_prot
|
||||
.write_map_begin(&TMapIdentifier::new(TType::I64, TType::Struct, 32))
|
||||
.is_ok()
|
||||
);
|
||||
assert!(o_prot
|
||||
.write_map_begin(&TMapIdentifier::new(TType::I64, TType::Struct, 32))
|
||||
.is_ok());
|
||||
|
||||
let expected: [u8; 6] = [0x0A, 0x0C, 0x00, 0x00, 0x00, 0x20];
|
||||
assert_eq_written_bytes!(o_prot, expected);
|
||||
|
@ -775,7 +810,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn must_round_trip_map_begin() {
|
||||
let (mut i_prot, mut o_prot) = test_objects();
|
||||
let (mut i_prot, mut o_prot) = test_objects(true);
|
||||
|
||||
let ident = TMapIdentifier::new(TType::Map, TType::Set, 100);
|
||||
assert!(o_prot.write_map_begin(&ident).is_ok());
|
||||
|
@ -788,12 +823,12 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn must_write_map_end() {
|
||||
assert_no_write(|o| o.write_map_end());
|
||||
assert_no_write(|o| o.write_map_end(), true);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn must_write_bool_true() {
|
||||
let (_, mut o_prot) = test_objects();
|
||||
let (_, mut o_prot) = test_objects(true);
|
||||
|
||||
assert!(o_prot.write_bool(true).is_ok());
|
||||
|
||||
|
@ -803,7 +838,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn must_write_bool_false() {
|
||||
let (_, mut o_prot) = test_objects();
|
||||
let (_, mut o_prot) = test_objects(true);
|
||||
|
||||
assert!(o_prot.write_bool(false).is_ok());
|
||||
|
||||
|
@ -813,7 +848,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn must_read_bool_true() {
|
||||
let (mut i_prot, _) = test_objects();
|
||||
let (mut i_prot, _) = test_objects(true);
|
||||
|
||||
set_readable_bytes!(i_prot, &[0x01]);
|
||||
|
||||
|
@ -823,7 +858,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn must_read_bool_false() {
|
||||
let (mut i_prot, _) = test_objects();
|
||||
let (mut i_prot, _) = test_objects(true);
|
||||
|
||||
set_readable_bytes!(i_prot, &[0x00]);
|
||||
|
||||
|
@ -833,7 +868,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn must_allow_any_non_zero_value_to_be_interpreted_as_bool_true() {
|
||||
let (mut i_prot, _) = test_objects();
|
||||
let (mut i_prot, _) = test_objects(true);
|
||||
|
||||
set_readable_bytes!(i_prot, &[0xAC]);
|
||||
|
||||
|
@ -843,7 +878,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn must_write_bytes() {
|
||||
let (_, mut o_prot) = test_objects();
|
||||
let (_, mut o_prot) = test_objects(true);
|
||||
|
||||
let bytes: [u8; 10] = [0x0A, 0xCC, 0xD1, 0x84, 0x99, 0x12, 0xAB, 0xBB, 0x45, 0xDF];
|
||||
|
||||
|
@ -856,8 +891,9 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn must_round_trip_bytes() {
|
||||
let (mut i_prot, mut o_prot) = test_objects();
|
||||
let (mut i_prot, mut o_prot) = test_objects(true);
|
||||
|
||||
#[cfg_attr(rustfmt, rustfmt::skip)]
|
||||
let bytes: [u8; 25] = [
|
||||
0x20,
|
||||
0xFD,
|
||||
|
@ -894,25 +930,27 @@ mod tests {
|
|||
assert_eq!(&received_bytes, &bytes);
|
||||
}
|
||||
|
||||
fn test_objects()
|
||||
-> (TBinaryInputProtocol<ReadHalf<TBufferChannel>>,
|
||||
TBinaryOutputProtocol<WriteHalf<TBufferChannel>>)
|
||||
{
|
||||
fn test_objects(
|
||||
strict: bool,
|
||||
) -> (
|
||||
TBinaryInputProtocol<ReadHalf<TBufferChannel>>,
|
||||
TBinaryOutputProtocol<WriteHalf<TBufferChannel>>,
|
||||
) {
|
||||
let mem = TBufferChannel::with_capacity(40, 40);
|
||||
|
||||
let (r_mem, w_mem) = mem.split().unwrap();
|
||||
|
||||
let i_prot = TBinaryInputProtocol::new(r_mem, true);
|
||||
let o_prot = TBinaryOutputProtocol::new(w_mem, true);
|
||||
let i_prot = TBinaryInputProtocol::new(r_mem, strict);
|
||||
let o_prot = TBinaryOutputProtocol::new(w_mem, strict);
|
||||
|
||||
(i_prot, o_prot)
|
||||
}
|
||||
|
||||
fn assert_no_write<F>(mut write_fn: F)
|
||||
fn assert_no_write<F>(mut write_fn: F, strict: bool)
|
||||
where
|
||||
F: FnMut(&mut TBinaryOutputProtocol<WriteHalf<TBufferChannel>>) -> ::Result<()>,
|
||||
{
|
||||
let (_, mut o_prot) = test_objects();
|
||||
let (_, mut o_prot) = test_objects(strict);
|
||||
assert!(write_fn(&mut o_prot).is_ok());
|
||||
assert_eq!(o_prot.transport.write_bytes().len(), 0);
|
||||
}
|
||||
|
|
199
vendor/git.apache.org/thrift.git/lib/rs/src/protocol/compact.rs
generated
vendored
199
vendor/git.apache.org/thrift.git/lib/rs/src/protocol/compact.rs
generated
vendored
|
@ -18,13 +18,15 @@
|
|||
use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt};
|
||||
use integer_encoding::{VarIntReader, VarIntWriter};
|
||||
use std::convert::From;
|
||||
use try_from::TryFrom;
|
||||
use std::io;
|
||||
use try_from::TryFrom;
|
||||
|
||||
use transport::{TReadTransport, TWriteTransport};
|
||||
use super::{TFieldIdentifier, TInputProtocol, TInputProtocolFactory, TListIdentifier,
|
||||
TMapIdentifier, TMessageIdentifier, TMessageType};
|
||||
use super::{
|
||||
TFieldIdentifier, TInputProtocol, TInputProtocolFactory, TListIdentifier, TMapIdentifier,
|
||||
TMessageIdentifier, TMessageType,
|
||||
};
|
||||
use super::{TOutputProtocol, TOutputProtocolFactory, TSetIdentifier, TStructIdentifier, TType};
|
||||
use transport::{TReadTransport, TWriteTransport};
|
||||
|
||||
const COMPACT_PROTOCOL_ID: u8 = 0x82;
|
||||
const COMPACT_VERSION: u8 = 0x01;
|
||||
|
@ -103,14 +105,10 @@ where
|
|||
fn read_message_begin(&mut self) -> ::Result<TMessageIdentifier> {
|
||||
let compact_id = self.read_byte()?;
|
||||
if compact_id != COMPACT_PROTOCOL_ID {
|
||||
Err(
|
||||
::Error::Protocol(
|
||||
::ProtocolError {
|
||||
kind: ::ProtocolErrorKind::BadVersion,
|
||||
message: format!("invalid compact protocol header {:?}", compact_id),
|
||||
},
|
||||
),
|
||||
)
|
||||
Err(::Error::Protocol(::ProtocolError {
|
||||
kind: ::ProtocolErrorKind::BadVersion,
|
||||
message: format!("invalid compact protocol header {:?}", compact_id),
|
||||
}))
|
||||
} else {
|
||||
Ok(())
|
||||
}?;
|
||||
|
@ -118,17 +116,13 @@ where
|
|||
let type_and_byte = self.read_byte()?;
|
||||
let received_version = type_and_byte & COMPACT_VERSION_MASK;
|
||||
if received_version != COMPACT_VERSION {
|
||||
Err(
|
||||
::Error::Protocol(
|
||||
::ProtocolError {
|
||||
kind: ::ProtocolErrorKind::BadVersion,
|
||||
message: format!(
|
||||
"cannot process compact protocol version {:?}",
|
||||
received_version
|
||||
),
|
||||
},
|
||||
Err(::Error::Protocol(::ProtocolError {
|
||||
kind: ::ProtocolErrorKind::BadVersion,
|
||||
message: format!(
|
||||
"cannot process compact protocol version {:?}",
|
||||
received_version
|
||||
),
|
||||
)
|
||||
}))
|
||||
} else {
|
||||
Ok(())
|
||||
}?;
|
||||
|
@ -140,7 +134,11 @@ where
|
|||
|
||||
self.last_read_field_id = 0;
|
||||
|
||||
Ok(TMessageIdentifier::new(service_call_name, message_type, sequence_number),)
|
||||
Ok(TMessageIdentifier::new(
|
||||
service_call_name,
|
||||
message_type,
|
||||
sequence_number,
|
||||
))
|
||||
}
|
||||
|
||||
fn read_message_end(&mut self) -> ::Result<()> {
|
||||
|
@ -154,7 +152,8 @@ where
|
|||
}
|
||||
|
||||
fn read_struct_end(&mut self) -> ::Result<()> {
|
||||
self.last_read_field_id = self.read_field_id_stack
|
||||
self.last_read_field_id = self
|
||||
.read_field_id_stack
|
||||
.pop()
|
||||
.expect("should have previous field ids");
|
||||
Ok(())
|
||||
|
@ -179,15 +178,13 @@ where
|
|||
}?;
|
||||
|
||||
match field_type {
|
||||
TType::Stop => {
|
||||
Ok(
|
||||
TFieldIdentifier::new::<Option<String>, String, Option<i16>>(
|
||||
None,
|
||||
TType::Stop,
|
||||
None,
|
||||
),
|
||||
)
|
||||
}
|
||||
TType::Stop => Ok(
|
||||
TFieldIdentifier::new::<Option<String>, String, Option<i16>>(
|
||||
None,
|
||||
TType::Stop,
|
||||
None,
|
||||
),
|
||||
),
|
||||
_ => {
|
||||
if field_delta != 0 {
|
||||
self.last_read_field_id += field_delta as i16;
|
||||
|
@ -195,13 +192,11 @@ where
|
|||
self.last_read_field_id = self.read_i16()?;
|
||||
};
|
||||
|
||||
Ok(
|
||||
TFieldIdentifier {
|
||||
name: None,
|
||||
field_type: field_type,
|
||||
id: Some(self.last_read_field_id),
|
||||
},
|
||||
)
|
||||
Ok(TFieldIdentifier {
|
||||
name: None,
|
||||
field_type: field_type,
|
||||
id: Some(self.last_read_field_id),
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -218,16 +213,10 @@ where
|
|||
match b {
|
||||
0x01 => Ok(true),
|
||||
0x02 => Ok(false),
|
||||
unkn => {
|
||||
Err(
|
||||
::Error::Protocol(
|
||||
::ProtocolError {
|
||||
kind: ::ProtocolErrorKind::InvalidData,
|
||||
message: format!("cannot convert {} into bool", unkn),
|
||||
},
|
||||
),
|
||||
)
|
||||
}
|
||||
unkn => Err(::Error::Protocol(::ProtocolError {
|
||||
kind: ::ProtocolErrorKind::InvalidData,
|
||||
message: format!("cannot convert {} into bool", unkn),
|
||||
})),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -259,9 +248,7 @@ where
|
|||
}
|
||||
|
||||
fn read_double(&mut self) -> ::Result<f64> {
|
||||
self.transport
|
||||
.read_f64::<BigEndian>()
|
||||
.map_err(From::from)
|
||||
self.transport.read_f64::<BigEndian>().map_err(From::from)
|
||||
}
|
||||
|
||||
fn read_string(&mut self) -> ::Result<String> {
|
||||
|
@ -315,7 +302,6 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
impl<T> io::Seek for TCompactInputProtocol<T>
|
||||
where
|
||||
T: io::Seek + TReadTransport,
|
||||
|
@ -450,7 +436,8 @@ where
|
|||
|
||||
fn write_struct_end(&mut self) -> ::Result<()> {
|
||||
self.assert_no_pending_bool_write();
|
||||
self.last_write_field_id = self.write_field_id_stack
|
||||
self.last_write_field_id = self
|
||||
.write_field_id_stack
|
||||
.pop()
|
||||
.expect("should have previous field ids");
|
||||
Ok(())
|
||||
|
@ -462,7 +449,7 @@ where
|
|||
if self.pending_write_bool_field_identifier.is_some() {
|
||||
panic!(
|
||||
"should not have a pending bool while writing another bool with id: \
|
||||
{:?}",
|
||||
{:?}",
|
||||
identifier
|
||||
)
|
||||
}
|
||||
|
@ -471,9 +458,7 @@ where
|
|||
}
|
||||
_ => {
|
||||
let field_type = type_to_u8(identifier.field_type);
|
||||
let field_id = identifier
|
||||
.id
|
||||
.expect("non-stop field should have field id");
|
||||
let field_id = identifier.id.expect("non-stop field should have field id");
|
||||
self.write_field_header(field_type, field_id)
|
||||
}
|
||||
}
|
||||
|
@ -537,9 +522,7 @@ where
|
|||
}
|
||||
|
||||
fn write_double(&mut self, d: f64) -> ::Result<()> {
|
||||
self.transport
|
||||
.write_f64::<BigEndian>(d)
|
||||
.map_err(From::from)
|
||||
self.transport.write_f64::<BigEndian>(d).map_err(From::from)
|
||||
}
|
||||
|
||||
fn write_string(&mut self, s: &str) -> ::Result<()> {
|
||||
|
@ -595,10 +578,7 @@ where
|
|||
//
|
||||
|
||||
fn write_byte(&mut self, b: u8) -> ::Result<()> {
|
||||
self.transport
|
||||
.write(&[b])
|
||||
.map_err(From::from)
|
||||
.map(|_| ())
|
||||
self.transport.write(&[b]).map_err(From::from).map(|_| ())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -639,7 +619,10 @@ fn type_to_u8(field_type: TType) -> u8 {
|
|||
TType::Set => 0x0A,
|
||||
TType::Map => 0x0B,
|
||||
TType::Struct => 0x0C,
|
||||
_ => panic!(format!("should not have attempted to convert {} to u8", field_type)),
|
||||
_ => panic!(format!(
|
||||
"should not have attempted to convert {} to u8",
|
||||
field_type
|
||||
)),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -663,25 +646,20 @@ fn u8_to_type(b: u8) -> ::Result<TType> {
|
|||
0x0A => Ok(TType::Set),
|
||||
0x0B => Ok(TType::Map),
|
||||
0x0C => Ok(TType::Struct),
|
||||
unkn => {
|
||||
Err(
|
||||
::Error::Protocol(
|
||||
::ProtocolError {
|
||||
kind: ::ProtocolErrorKind::InvalidData,
|
||||
message: format!("cannot convert {} into TType", unkn),
|
||||
},
|
||||
),
|
||||
)
|
||||
}
|
||||
unkn => Err(::Error::Protocol(::ProtocolError {
|
||||
kind: ::ProtocolErrorKind::InvalidData,
|
||||
message: format!("cannot convert {} into TType", unkn),
|
||||
})),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
||||
use protocol::{TFieldIdentifier, TInputProtocol, TListIdentifier, TMapIdentifier,
|
||||
TMessageIdentifier, TMessageType, TOutputProtocol, TSetIdentifier,
|
||||
TStructIdentifier, TType};
|
||||
use protocol::{
|
||||
TFieldIdentifier, TInputProtocol, TListIdentifier, TMapIdentifier, TMessageIdentifier,
|
||||
TMessageType, TOutputProtocol, TSetIdentifier, TStructIdentifier, TType,
|
||||
};
|
||||
use transport::{ReadHalf, TBufferChannel, TIoChannel, WriteHalf};
|
||||
|
||||
use super::*;
|
||||
|
@ -690,8 +668,13 @@ mod tests {
|
|||
fn must_write_message_begin_0() {
|
||||
let (_, mut o_prot) = test_objects();
|
||||
|
||||
assert_success!(o_prot.write_message_begin(&TMessageIdentifier::new("foo", TMessageType::Call, 431)));
|
||||
assert_success!(o_prot.write_message_begin(&TMessageIdentifier::new(
|
||||
"foo",
|
||||
TMessageType::Call,
|
||||
431
|
||||
)));
|
||||
|
||||
#[cfg_attr(rustfmt, rustfmt::skip)]
|
||||
let expected: [u8; 8] = [
|
||||
0x82, /* protocol ID */
|
||||
0x21, /* message type | protocol version */
|
||||
|
@ -710,10 +693,13 @@ mod tests {
|
|||
fn must_write_message_begin_1() {
|
||||
let (_, mut o_prot) = test_objects();
|
||||
|
||||
assert_success!(
|
||||
o_prot.write_message_begin(&TMessageIdentifier::new("bar", TMessageType::Reply, 991828))
|
||||
);
|
||||
assert_success!(o_prot.write_message_begin(&TMessageIdentifier::new(
|
||||
"bar",
|
||||
TMessageType::Reply,
|
||||
991828
|
||||
)));
|
||||
|
||||
#[cfg_attr(rustfmt, rustfmt::skip)]
|
||||
let expected: [u8; 9] = [
|
||||
0x82, /* protocol ID */
|
||||
0x41, /* message type | protocol version */
|
||||
|
@ -777,6 +763,7 @@ mod tests {
|
|||
assert_success!(o_prot.write_field_stop());
|
||||
assert_success!(o_prot.write_struct_end());
|
||||
|
||||
#[cfg_attr(rustfmt, rustfmt::skip)]
|
||||
let expected: [u8; 5] = [
|
||||
0x03, /* field type */
|
||||
0x00, /* first field id */
|
||||
|
@ -891,6 +878,7 @@ mod tests {
|
|||
assert_success!(o_prot.write_field_stop());
|
||||
assert_success!(o_prot.write_struct_end());
|
||||
|
||||
#[cfg_attr(rustfmt, rustfmt::skip)]
|
||||
let expected: [u8; 4] = [
|
||||
0x15, /* field delta (1) | field type */
|
||||
0x1A, /* field delta (1) | field type */
|
||||
|
@ -1003,6 +991,7 @@ mod tests {
|
|||
assert_success!(o_prot.write_field_stop());
|
||||
assert_success!(o_prot.write_struct_end());
|
||||
|
||||
#[cfg_attr(rustfmt, rustfmt::skip)]
|
||||
let expected: [u8; 8] = [
|
||||
0x05, /* field type */
|
||||
0x00, /* first field id */
|
||||
|
@ -1126,6 +1115,7 @@ mod tests {
|
|||
assert_success!(o_prot.write_field_stop());
|
||||
assert_success!(o_prot.write_struct_end());
|
||||
|
||||
#[cfg_attr(rustfmt, rustfmt::skip)]
|
||||
let expected: [u8; 10] = [
|
||||
0x16, /* field delta (1) | field type */
|
||||
0x85, /* field delta (8) | field type */
|
||||
|
@ -1290,6 +1280,7 @@ mod tests {
|
|||
assert_success!(o_prot.write_field_stop());
|
||||
assert_success!(o_prot.write_struct_end());
|
||||
|
||||
#[cfg_attr(rustfmt, rustfmt::skip)]
|
||||
let expected: [u8; 7] = [
|
||||
0x16, /* field delta (1) | field type */
|
||||
0x85, /* field delta (8) | field type */
|
||||
|
@ -1462,6 +1453,7 @@ mod tests {
|
|||
assert_success!(o_prot.write_field_stop());
|
||||
assert_success!(o_prot.write_struct_end());
|
||||
|
||||
#[cfg_attr(rustfmt, rustfmt::skip)]
|
||||
let expected: [u8; 7] = [
|
||||
0x16, /* field delta (1) | field type */
|
||||
0x85, /* field delta (8) | field type */
|
||||
|
@ -1634,6 +1626,7 @@ mod tests {
|
|||
assert_success!(o_prot.write_field_stop());
|
||||
assert_success!(o_prot.write_struct_end());
|
||||
|
||||
#[cfg_attr(rustfmt, rustfmt::skip)]
|
||||
let expected: [u8; 7] = [
|
||||
0x16, /* field delta (1) | field type */
|
||||
0x08, /* field type */
|
||||
|
@ -1803,6 +1796,7 @@ mod tests {
|
|||
assert_success!(o_prot.write_field_stop());
|
||||
assert_success!(o_prot.write_struct_end());
|
||||
|
||||
#[cfg_attr(rustfmt, rustfmt::skip)]
|
||||
let expected: [u8; 8] = [
|
||||
0x16, /* field delta (1) | field type */
|
||||
0x08, /* field type */
|
||||
|
@ -1968,6 +1962,7 @@ mod tests {
|
|||
assert_success!(o_prot.write_field_stop());
|
||||
assert_success!(o_prot.write_struct_end());
|
||||
|
||||
#[cfg_attr(rustfmt, rustfmt::skip)]
|
||||
let expected: [u8; 7] = [
|
||||
0x11, /* field delta (1) | true */
|
||||
0x82, /* field delta (8) | false */
|
||||
|
@ -2158,8 +2153,7 @@ mod tests {
|
|||
|
||||
let expected: [u8; 3] = [
|
||||
0xF9, /* 0xF0 | elem_type */
|
||||
0x8F,
|
||||
0x4E /* size as varint */,
|
||||
0x8F, 0x4E, /* size as varint */
|
||||
];
|
||||
|
||||
assert_eq_written_bytes!(o_prot, expected);
|
||||
|
@ -2217,9 +2211,7 @@ mod tests {
|
|||
|
||||
let expected: [u8; 4] = [
|
||||
0xF7, /* 0xF0 | elem_type */
|
||||
0xD3,
|
||||
0xBA,
|
||||
0x01 /* size as varint */,
|
||||
0xD3, 0xBA, 0x01, /* size as varint */
|
||||
];
|
||||
|
||||
assert_eq_written_bytes!(o_prot, expected);
|
||||
|
@ -2267,10 +2259,10 @@ mod tests {
|
|||
assert_eq!(
|
||||
&res,
|
||||
&TMapIdentifier {
|
||||
key_type: None,
|
||||
value_type: None,
|
||||
size: 0,
|
||||
}
|
||||
key_type: None,
|
||||
value_type: None,
|
||||
size: 0,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -2278,12 +2270,15 @@ mod tests {
|
|||
fn must_write_map_begin() {
|
||||
let (_, mut o_prot) = test_objects();
|
||||
|
||||
assert_success!(o_prot.write_map_begin(&TMapIdentifier::new(TType::Double, TType::String, 238)));
|
||||
assert_success!(o_prot.write_map_begin(&TMapIdentifier::new(
|
||||
TType::Double,
|
||||
TType::String,
|
||||
238
|
||||
)));
|
||||
|
||||
let expected: [u8; 3] = [
|
||||
0xEE,
|
||||
0x01, /* size as varint */
|
||||
0x78 /* key type | val type */,
|
||||
0xEE, 0x01, /* size as varint */
|
||||
0x78, /* key type | val type */
|
||||
];
|
||||
|
||||
assert_eq_written_bytes!(o_prot, expected);
|
||||
|
@ -2321,7 +2316,7 @@ mod tests {
|
|||
0x01, /* size as varint */
|
||||
0x11, /* key type | val type */
|
||||
0x01, /* key: true */
|
||||
0x02 /* val: false */,
|
||||
0x02, /* val: false */
|
||||
];
|
||||
|
||||
assert_eq_written_bytes!(o_prot, expected);
|
||||
|
@ -2366,10 +2361,10 @@ mod tests {
|
|||
assert!(i_prot.read_map_end().is_ok()); // will blow up if we try to read from empty buffer
|
||||
}
|
||||
|
||||
fn test_objects()
|
||||
-> (TCompactInputProtocol<ReadHalf<TBufferChannel>>,
|
||||
TCompactOutputProtocol<WriteHalf<TBufferChannel>>)
|
||||
{
|
||||
fn test_objects() -> (
|
||||
TCompactInputProtocol<ReadHalf<TBufferChannel>>,
|
||||
TCompactOutputProtocol<WriteHalf<TBufferChannel>>,
|
||||
) {
|
||||
let mem = TBufferChannel::with_capacity(80, 80);
|
||||
|
||||
let (r_mem, w_mem) = mem.split().unwrap();
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue