diff --git a/examples/client.go b/examples/client.go index a99403b..36f41dd 100644 --- a/examples/client.go +++ b/examples/client.go @@ -95,6 +95,7 @@ func main() { response, err := r.CreateJob(job) if err != nil { fmt.Print(err) + os.Exit(1) } fmt.Print(response.String()) @@ -105,6 +106,7 @@ func main() { response, err := r.KillJob(job.JobKey()) if err != nil { fmt.Print(err) + os.Exit(1) } fmt.Print(response.String()) @@ -114,6 +116,7 @@ func main() { response, err := r.RestartJob(job.JobKey()) if err != nil { fmt.Print(err) + os.Exit(1) } fmt.Print(response.String()) @@ -123,6 +126,7 @@ func main() { response, err := r.AddInstances(&aurora.InstanceKey{job.JobKey(), 0}, 5) if err != nil { fmt.Print(err) + os.Exit(1) } fmt.Print(response.String()) break @@ -135,6 +139,7 @@ func main() { resposne, err := r.StartJobUpdate(updateJob, "") if err != nil { fmt.Print(err) + os.Exit(1) } fmt.Print(resposne.String()) break @@ -143,6 +148,7 @@ func main() { response, err := r.AbortJobUpdate(job.JobKey(), *updateId, "") if err != nil { fmt.Print(err) + os.Exit(1) } fmt.Print(response.String()) break diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/application_exception_test.go b/vendor/git.apache.org/thrift.git/lib/go/thrift/application_exception_test.go deleted file mode 100644 index 7010f86..0000000 --- a/vendor/git.apache.org/thrift.git/lib/go/thrift/application_exception_test.go +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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. - */ - -package thrift - -import ( - "testing" -) - -func TestTApplicationException(t *testing.T) { - exc := NewTApplicationException(UNKNOWN_APPLICATION_EXCEPTION, "") - if exc.Error() != "" { - t.Fatalf("Expected empty string for exception but found '%s'", exc.Error()) - } - if exc.TypeId() != UNKNOWN_APPLICATION_EXCEPTION { - t.Fatalf("Expected type UNKNOWN for exception but found '%s'", exc.TypeId()) - } - exc = NewTApplicationException(WRONG_METHOD_NAME, "junk_method") - if exc.Error() != "junk_method" { - t.Fatalf("Expected 'junk_method' for exception but found '%s'", exc.Error()) - } - if exc.TypeId() != WRONG_METHOD_NAME { - t.Fatalf("Expected type WRONG_METHOD_NAME for exception but found '%s'", exc.TypeId()) - } -} diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/binary_protocol_test.go b/vendor/git.apache.org/thrift.git/lib/go/thrift/binary_protocol_test.go deleted file mode 100644 index 0462cc7..0000000 --- a/vendor/git.apache.org/thrift.git/lib/go/thrift/binary_protocol_test.go +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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. - */ - -package thrift - -import ( - "testing" -) - -func TestReadWriteBinaryProtocol(t *testing.T) { - ReadWriteProtocolTest(t, NewTBinaryProtocolFactoryDefault()) -} diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/buffered_transport_test.go b/vendor/git.apache.org/thrift.git/lib/go/thrift/buffered_transport_test.go deleted file mode 100644 index 95ec0cb..0000000 --- a/vendor/git.apache.org/thrift.git/lib/go/thrift/buffered_transport_test.go +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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. - */ - -package thrift - -import ( - "testing" -) - -func TestBufferedTransport(t *testing.T) { - trans := NewTBufferedTransport(NewTMemoryBuffer(), 10240) - TransportTest(t, trans, trans) -} diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/compact_protocol_test.go b/vendor/git.apache.org/thrift.git/lib/go/thrift/compact_protocol_test.go deleted file mode 100644 index f940b4e..0000000 --- a/vendor/git.apache.org/thrift.git/lib/go/thrift/compact_protocol_test.go +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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. - */ - -package thrift - -import ( - "bytes" - "testing" -) - -func TestReadWriteCompactProtocol(t *testing.T) { - ReadWriteProtocolTest(t, NewTCompactProtocolFactory()) - transports := []TTransport{ - NewTMemoryBuffer(), - NewStreamTransportRW(bytes.NewBuffer(make([]byte, 0, 16384))), - NewTFramedTransport(NewTMemoryBuffer()), - } - for _, trans := range transports { - p := NewTCompactProtocol(trans) - ReadWriteBool(t, p, trans) - p = NewTCompactProtocol(trans) - ReadWriteByte(t, p, trans) - p = NewTCompactProtocol(trans) - ReadWriteI16(t, p, trans) - p = NewTCompactProtocol(trans) - ReadWriteI32(t, p, trans) - p = NewTCompactProtocol(trans) - ReadWriteI64(t, p, trans) - p = NewTCompactProtocol(trans) - ReadWriteDouble(t, p, trans) - p = NewTCompactProtocol(trans) - ReadWriteString(t, p, trans) - p = NewTCompactProtocol(trans) - ReadWriteBinary(t, p, trans) - trans.Close() - } -} diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/exception_test.go b/vendor/git.apache.org/thrift.git/lib/go/thrift/exception_test.go deleted file mode 100644 index 71f5e2c..0000000 --- a/vendor/git.apache.org/thrift.git/lib/go/thrift/exception_test.go +++ /dev/null @@ -1,69 +0,0 @@ -/* - * 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. - */ - -package thrift - -import ( - "errors" - "testing" -) - -func TestPrependError(t *testing.T) { - err := NewTApplicationException(INTERNAL_ERROR, "original error") - err2, ok := PrependError("Prepend: ", err).(TApplicationException) - if !ok { - t.Fatal("Couldn't cast error TApplicationException") - } - if err2.Error() != "Prepend: original error" { - t.Fatal("Unexpected error string") - } - if err2.TypeId() != INTERNAL_ERROR { - t.Fatal("Unexpected type error") - } - - err3 := NewTProtocolExceptionWithType(INVALID_DATA, errors.New("original error")) - err4, ok := PrependError("Prepend: ", err3).(TProtocolException) - if !ok { - t.Fatal("Couldn't cast error TProtocolException") - } - if err4.Error() != "Prepend: original error" { - t.Fatal("Unexpected error string") - } - if err4.TypeId() != INVALID_DATA { - t.Fatal("Unexpected type error") - } - - err5 := NewTTransportException(TIMED_OUT, "original error") - err6, ok := PrependError("Prepend: ", err5).(TTransportException) - if !ok { - t.Fatal("Couldn't cast error TTransportException") - } - if err6.Error() != "Prepend: original error" { - t.Fatal("Unexpected error string") - } - if err6.TypeId() != TIMED_OUT { - t.Fatal("Unexpected type error") - } - - err7 := errors.New("original error") - err8 := PrependError("Prepend: ", err7) - if err8.Error() != "Prepend: original error" { - t.Fatal("Unexpected error string") - } -} diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/framed_transport.go b/vendor/git.apache.org/thrift.git/lib/go/thrift/framed_transport.go index c8bb887..d0bae21 100644 --- a/vendor/git.apache.org/thrift.git/lib/go/thrift/framed_transport.go +++ b/vendor/git.apache.org/thrift.git/lib/go/thrift/framed_transport.go @@ -48,7 +48,7 @@ func NewTFramedTransportFactory(factory TTransportFactory) TTransportFactory { } func NewTFramedTransportFactoryMaxLength(factory TTransportFactory, maxLength uint32) TTransportFactory { - return &tFramedTransportFactory{factory: factory, maxLength: maxLength} + return &tFramedTransportFactory{factory: factory, maxLength: maxLength} } func (p *tFramedTransportFactory) GetTransport(base TTransport) TTransport { @@ -164,3 +164,4 @@ func (p *TFramedTransport) readFrameHeader() (uint32, error) { func (p *TFramedTransport) RemainingBytes() (num_bytes uint64) { return uint64(p.frameSize) } + diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/framed_transport_test.go b/vendor/git.apache.org/thrift.git/lib/go/thrift/framed_transport_test.go deleted file mode 100644 index 8f683ef..0000000 --- a/vendor/git.apache.org/thrift.git/lib/go/thrift/framed_transport_test.go +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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. - */ - -package thrift - -import ( - "testing" -) - -func TestFramedTransport(t *testing.T) { - trans := NewTFramedTransport(NewTMemoryBuffer()) - TransportTest(t, trans, trans) -} diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/http_client_test.go b/vendor/git.apache.org/thrift.git/lib/go/thrift/http_client_test.go deleted file mode 100644 index 453680a..0000000 --- a/vendor/git.apache.org/thrift.git/lib/go/thrift/http_client_test.go +++ /dev/null @@ -1,106 +0,0 @@ -/* - * 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. - */ - -package thrift - -import ( - "net/http" - "testing" -) - -func TestHttpClient(t *testing.T) { - l, addr := HttpClientSetupForTest(t) - if l != nil { - defer l.Close() - } - trans, err := NewTHttpPostClient("http://" + addr.String()) - if err != nil { - l.Close() - t.Fatalf("Unable to connect to %s: %s", addr.String(), err) - } - TransportTest(t, trans, trans) -} - -func TestHttpClientHeaders(t *testing.T) { - l, addr := HttpClientSetupForTest(t) - if l != nil { - defer l.Close() - } - trans, err := NewTHttpPostClient("http://" + addr.String()) - if err != nil { - l.Close() - t.Fatalf("Unable to connect to %s: %s", addr.String(), err) - } - TransportHeaderTest(t, trans, trans) -} - -func TestHttpCustomClient(t *testing.T) { - l, addr := HttpClientSetupForTest(t) - if l != nil { - defer l.Close() - } - - httpTransport := &customHttpTransport{} - - trans, err := NewTHttpPostClientWithOptions("http://"+addr.String(), THttpClientOptions{ - Client: &http.Client{ - Transport: httpTransport, - }, - }) - if err != nil { - l.Close() - t.Fatalf("Unable to connect to %s: %s", addr.String(), err) - } - TransportHeaderTest(t, trans, trans) - - if !httpTransport.hit { - t.Fatalf("Custom client was not used") - } -} - -func TestHttpCustomClientPackageScope(t *testing.T) { - l, addr := HttpClientSetupForTest(t) - if l != nil { - defer l.Close() - } - httpTransport := &customHttpTransport{} - DefaultHttpClient = &http.Client{ - Transport: httpTransport, - } - - trans, err := NewTHttpPostClient("http://" + addr.String()) - if err != nil { - l.Close() - t.Fatalf("Unable to connect to %s: %s", addr.String(), err) - } - TransportHeaderTest(t, trans, trans) - - if !httpTransport.hit { - t.Fatalf("Custom client was not used") - } -} - -type customHttpTransport struct { - hit bool -} - -func (c *customHttpTransport) RoundTrip(req *http.Request) (*http.Response, error) { - c.hit = true - return http.DefaultTransport.RoundTrip(req) -} diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/iostream_transport.go b/vendor/git.apache.org/thrift.git/lib/go/thrift/iostream_transport.go index 70bede9..794872f 100644 --- a/vendor/git.apache.org/thrift.git/lib/go/thrift/iostream_transport.go +++ b/vendor/git.apache.org/thrift.git/lib/go/thrift/iostream_transport.go @@ -209,5 +209,6 @@ func (p *StreamTransport) WriteString(s string) (n int, err error) { func (p *StreamTransport) RemainingBytes() (num_bytes uint64) { const maxSize = ^uint64(0) - return maxSize // the thruth is, we just don't know unless framed is used + return maxSize // the thruth is, we just don't know unless framed is used } + diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/iostream_transport_test.go b/vendor/git.apache.org/thrift.git/lib/go/thrift/iostream_transport_test.go deleted file mode 100644 index 15a6116..0000000 --- a/vendor/git.apache.org/thrift.git/lib/go/thrift/iostream_transport_test.go +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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. - */ - -package thrift - -import ( - "bytes" - "testing" -) - -func TestStreamTransport(t *testing.T) { - trans := NewStreamTransportRW(bytes.NewBuffer(make([]byte, 0, 1024))) - TransportTest(t, trans, trans) -} - -func TestStreamTransportOpenClose(t *testing.T) { - trans := NewStreamTransportRW(bytes.NewBuffer(make([]byte, 0, 1024))) - if !trans.IsOpen() { - t.Fatal("StreamTransport should be already open") - } - if trans.Open() == nil { - t.Fatal("StreamTransport should return error when open twice") - } - if trans.Close() != nil { - t.Fatal("StreamTransport should not return error when closing open transport") - } - if trans.IsOpen() { - t.Fatal("StreamTransport should not be open after close") - } - if trans.Close() == nil { - t.Fatal("StreamTransport should return error when closing a non open transport") - } - if trans.Open() == nil { - t.Fatal("StreamTransport should not be able to reopen") - } -} diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/json_protocol_test.go b/vendor/git.apache.org/thrift.git/lib/go/thrift/json_protocol_test.go deleted file mode 100644 index 7104ce3..0000000 --- a/vendor/git.apache.org/thrift.git/lib/go/thrift/json_protocol_test.go +++ /dev/null @@ -1,649 +0,0 @@ -/* - * 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. - */ - -package thrift - -import ( - "encoding/base64" - "encoding/json" - "fmt" - "math" - "strconv" - "testing" -) - -func TestWriteJSONProtocolBool(t *testing.T) { - thetype := "boolean" - trans := NewTMemoryBuffer() - p := NewTJSONProtocol(trans) - for _, value := range BOOL_VALUES { - if e := p.WriteBool(value); e != nil { - t.Fatalf("Unable to write %s value %v due to error: %s", thetype, value, e.Error()) - } - if e := p.Flush(); e != nil { - t.Fatalf("Unable to write %s value %v due to error flushing: %s", thetype, value, e.Error()) - } - s := trans.String() - expected := "" - if value { - expected = "1" - } else { - expected = "0" - } - if s != expected { - t.Fatalf("Bad value for %s %v: %s expected", thetype, value, s) - } - v := -1 - if err := json.Unmarshal([]byte(s), &v); err != nil || (v != 0) != value { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) - } - trans.Reset() - } - trans.Close() -} - -func TestReadJSONProtocolBool(t *testing.T) { - thetype := "boolean" - for _, value := range BOOL_VALUES { - trans := NewTMemoryBuffer() - p := NewTJSONProtocol(trans) - if value { - trans.Write([]byte{'1'}) // not JSON_TRUE - } else { - trans.Write([]byte{'0'}) // not JSON_FALSE - } - trans.Flush() - s := trans.String() - v, e := p.ReadBool() - if e != nil { - t.Fatalf("Unable to read %s value %v due to error: %s", thetype, value, e.Error()) - } - if v != value { - t.Fatalf("Bad value for %s value %v, wrote: %v, received: %v", thetype, value, s, v) - } - vv := -1 - if err := json.Unmarshal([]byte(s), &vv); err != nil || (vv != 0) != value { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, vv) - } - trans.Reset() - trans.Close() - } -} - -func TestWriteJSONProtocolByte(t *testing.T) { - thetype := "byte" - trans := NewTMemoryBuffer() - p := NewTJSONProtocol(trans) - for _, value := range BYTE_VALUES { - if e := p.WriteByte(value); e != nil { - t.Fatalf("Unable to write %s value %v due to error: %s", thetype, value, e.Error()) - } - if e := p.Flush(); e != nil { - t.Fatalf("Unable to write %s value %v due to error flushing: %s", thetype, value, e.Error()) - } - s := trans.String() - if s != fmt.Sprint(value) { - t.Fatalf("Bad value for %s %v: %s", thetype, value, s) - } - v := int8(0) - if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) - } - trans.Reset() - } - trans.Close() -} - -func TestReadJSONProtocolByte(t *testing.T) { - thetype := "byte" - for _, value := range BYTE_VALUES { - trans := NewTMemoryBuffer() - p := NewTJSONProtocol(trans) - trans.WriteString(strconv.Itoa(int(value))) - trans.Flush() - s := trans.String() - v, e := p.ReadByte() - if e != nil { - t.Fatalf("Unable to read %s value %v due to error: %s", thetype, value, e.Error()) - } - if v != value { - t.Fatalf("Bad value for %s value %v, wrote: %v, received: %v", thetype, value, s, v) - } - if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) - } - trans.Reset() - trans.Close() - } -} - -func TestWriteJSONProtocolI16(t *testing.T) { - thetype := "int16" - trans := NewTMemoryBuffer() - p := NewTJSONProtocol(trans) - for _, value := range INT16_VALUES { - if e := p.WriteI16(value); e != nil { - t.Fatalf("Unable to write %s value %v due to error: %s", thetype, value, e.Error()) - } - if e := p.Flush(); e != nil { - t.Fatalf("Unable to write %s value %v due to error flushing: %s", thetype, value, e.Error()) - } - s := trans.String() - if s != fmt.Sprint(value) { - t.Fatalf("Bad value for %s %v: %s", thetype, value, s) - } - v := int16(0) - if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) - } - trans.Reset() - } - trans.Close() -} - -func TestReadJSONProtocolI16(t *testing.T) { - thetype := "int16" - for _, value := range INT16_VALUES { - trans := NewTMemoryBuffer() - p := NewTJSONProtocol(trans) - trans.WriteString(strconv.Itoa(int(value))) - trans.Flush() - s := trans.String() - v, e := p.ReadI16() - if e != nil { - t.Fatalf("Unable to read %s value %v due to error: %s", thetype, value, e.Error()) - } - if v != value { - t.Fatalf("Bad value for %s value %v, wrote: %v, received: %v", thetype, value, s, v) - } - if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) - } - trans.Reset() - trans.Close() - } -} - -func TestWriteJSONProtocolI32(t *testing.T) { - thetype := "int32" - trans := NewTMemoryBuffer() - p := NewTJSONProtocol(trans) - for _, value := range INT32_VALUES { - if e := p.WriteI32(value); e != nil { - t.Fatalf("Unable to write %s value %v due to error: %s", thetype, value, e.Error()) - } - if e := p.Flush(); e != nil { - t.Fatalf("Unable to write %s value %v due to error flushing: %s", thetype, value, e.Error()) - } - s := trans.String() - if s != fmt.Sprint(value) { - t.Fatalf("Bad value for %s %v: %s", thetype, value, s) - } - v := int32(0) - if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) - } - trans.Reset() - } - trans.Close() -} - -func TestReadJSONProtocolI32(t *testing.T) { - thetype := "int32" - for _, value := range INT32_VALUES { - trans := NewTMemoryBuffer() - p := NewTJSONProtocol(trans) - trans.WriteString(strconv.Itoa(int(value))) - trans.Flush() - s := trans.String() - v, e := p.ReadI32() - if e != nil { - t.Fatalf("Unable to read %s value %v due to error: %s", thetype, value, e.Error()) - } - if v != value { - t.Fatalf("Bad value for %s value %v, wrote: %v, received: %v", thetype, value, s, v) - } - if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) - } - trans.Reset() - trans.Close() - } -} - -func TestWriteJSONProtocolI64(t *testing.T) { - thetype := "int64" - trans := NewTMemoryBuffer() - p := NewTJSONProtocol(trans) - for _, value := range INT64_VALUES { - if e := p.WriteI64(value); e != nil { - t.Fatalf("Unable to write %s value %v due to error: %s", thetype, value, e.Error()) - } - if e := p.Flush(); e != nil { - t.Fatalf("Unable to write %s value %v due to error flushing: %s", thetype, value, e.Error()) - } - s := trans.String() - if s != fmt.Sprint(value) { - t.Fatalf("Bad value for %s %v: %s", thetype, value, s) - } - v := int64(0) - if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) - } - trans.Reset() - } - trans.Close() -} - -func TestReadJSONProtocolI64(t *testing.T) { - thetype := "int64" - for _, value := range INT64_VALUES { - trans := NewTMemoryBuffer() - p := NewTJSONProtocol(trans) - trans.WriteString(strconv.FormatInt(value, 10)) - trans.Flush() - s := trans.String() - v, e := p.ReadI64() - if e != nil { - t.Fatalf("Unable to read %s value %v due to error: %s", thetype, value, e.Error()) - } - if v != value { - t.Fatalf("Bad value for %s value %v, wrote: %v, received: %v", thetype, value, s, v) - } - if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) - } - trans.Reset() - trans.Close() - } -} - -func TestWriteJSONProtocolDouble(t *testing.T) { - thetype := "double" - trans := NewTMemoryBuffer() - p := NewTJSONProtocol(trans) - for _, value := range DOUBLE_VALUES { - if e := p.WriteDouble(value); e != nil { - t.Fatalf("Unable to write %s value %v due to error: %s", thetype, value, e.Error()) - } - if e := p.Flush(); e != nil { - t.Fatalf("Unable to write %s value %v due to error flushing: %s", thetype, value, e.Error()) - } - s := trans.String() - if math.IsInf(value, 1) { - if s != jsonQuote(JSON_INFINITY) { - t.Fatalf("Bad value for %s %v, wrote: %v, expected: %v", thetype, value, s, jsonQuote(JSON_INFINITY)) - } - } else if math.IsInf(value, -1) { - if s != jsonQuote(JSON_NEGATIVE_INFINITY) { - t.Fatalf("Bad value for %s %v, wrote: %v, expected: %v", thetype, value, s, jsonQuote(JSON_NEGATIVE_INFINITY)) - } - } else if math.IsNaN(value) { - if s != jsonQuote(JSON_NAN) { - t.Fatalf("Bad value for %s %v, wrote: %v, expected: %v", thetype, value, s, jsonQuote(JSON_NAN)) - } - } else { - if s != fmt.Sprint(value) { - t.Fatalf("Bad value for %s %v: %s", thetype, value, s) - } - v := float64(0) - if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) - } - } - trans.Reset() - } - trans.Close() -} - -func TestReadJSONProtocolDouble(t *testing.T) { - thetype := "double" - for _, value := range DOUBLE_VALUES { - trans := NewTMemoryBuffer() - p := NewTJSONProtocol(trans) - n := NewNumericFromDouble(value) - trans.WriteString(n.String()) - trans.Flush() - s := trans.String() - v, e := p.ReadDouble() - if e != nil { - t.Fatalf("Unable to read %s value %v due to error: %s", thetype, value, e.Error()) - } - if math.IsInf(value, 1) { - if !math.IsInf(v, 1) { - t.Fatalf("Bad value for %s %v, wrote: %v, received: %v", thetype, value, s, v) - } - } else if math.IsInf(value, -1) { - if !math.IsInf(v, -1) { - t.Fatalf("Bad value for %s %v, wrote: %v, received: %v", thetype, value, s, v) - } - } else if math.IsNaN(value) { - if !math.IsNaN(v) { - t.Fatalf("Bad value for %s %v, wrote: %v, received: %v", thetype, value, s, v) - } - } else { - if v != value { - t.Fatalf("Bad value for %s value %v, wrote: %v, received: %v", thetype, value, s, v) - } - if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) - } - } - trans.Reset() - trans.Close() - } -} - -func TestWriteJSONProtocolString(t *testing.T) { - thetype := "string" - trans := NewTMemoryBuffer() - p := NewTJSONProtocol(trans) - for _, value := range STRING_VALUES { - if e := p.WriteString(value); e != nil { - t.Fatalf("Unable to write %s value %v due to error: %s", thetype, value, e.Error()) - } - if e := p.Flush(); e != nil { - t.Fatalf("Unable to write %s value %v due to error flushing: %s", thetype, value, e.Error()) - } - s := trans.String() - if s[0] != '"' || s[len(s)-1] != '"' { - t.Fatalf("Bad value for %s '%v', wrote '%v', expected: %v", thetype, value, s, fmt.Sprint("\"", value, "\"")) - } - v := new(string) - if err := json.Unmarshal([]byte(s), v); err != nil || *v != value { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, *v) - } - trans.Reset() - } - trans.Close() -} - -func TestReadJSONProtocolString(t *testing.T) { - thetype := "string" - for _, value := range STRING_VALUES { - trans := NewTMemoryBuffer() - p := NewTJSONProtocol(trans) - trans.WriteString(jsonQuote(value)) - trans.Flush() - s := trans.String() - v, e := p.ReadString() - if e != nil { - t.Fatalf("Unable to read %s value %v due to error: %s", thetype, value, e.Error()) - } - if v != value { - t.Fatalf("Bad value for %s value %v, wrote: %v, received: %v", thetype, value, s, v) - } - v1 := new(string) - if err := json.Unmarshal([]byte(s), v1); err != nil || *v1 != value { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, *v1) - } - trans.Reset() - trans.Close() - } -} - -func TestWriteJSONProtocolBinary(t *testing.T) { - thetype := "binary" - value := protocol_bdata - b64value := make([]byte, base64.StdEncoding.EncodedLen(len(protocol_bdata))) - base64.StdEncoding.Encode(b64value, value) - b64String := string(b64value) - trans := NewTMemoryBuffer() - p := NewTJSONProtocol(trans) - if e := p.WriteBinary(value); e != nil { - t.Fatalf("Unable to write %s value %v due to error: %s", thetype, value, e.Error()) - } - if e := p.Flush(); e != nil { - t.Fatalf("Unable to write %s value %v due to error flushing: %s", thetype, value, e.Error()) - } - s := trans.String() - expectedString := fmt.Sprint("\"", b64String, "\"") - if s != expectedString { - t.Fatalf("Bad value for %s %v\n wrote: \"%v\"\nexpected: \"%v\"", thetype, value, s, expectedString) - } - v1, err := p.ReadBinary() - if err != nil { - t.Fatalf("Unable to read binary: %s", err.Error()) - } - if len(v1) != len(value) { - t.Fatalf("Invalid value for binary\nexpected: \"%v\"\n read: \"%v\"", value, v1) - } - for k, v := range value { - if v1[k] != v { - t.Fatalf("Invalid value for binary at %v\nexpected: \"%v\"\n read: \"%v\"", k, v, v1[k]) - } - } - trans.Close() -} - -func TestReadJSONProtocolBinary(t *testing.T) { - thetype := "binary" - value := protocol_bdata - b64value := make([]byte, base64.StdEncoding.EncodedLen(len(protocol_bdata))) - base64.StdEncoding.Encode(b64value, value) - b64String := string(b64value) - trans := NewTMemoryBuffer() - p := NewTJSONProtocol(trans) - trans.WriteString(jsonQuote(b64String)) - trans.Flush() - s := trans.String() - v, e := p.ReadBinary() - if e != nil { - t.Fatalf("Unable to read %s value %v due to error: %s", thetype, value, e.Error()) - } - if len(v) != len(value) { - t.Fatalf("Bad value for %s value length %v, wrote: %v, received length: %v", thetype, len(value), s, len(v)) - } - for i := 0; i < len(v); i++ { - if v[i] != value[i] { - t.Fatalf("Bad value for %s at index %d value %v, wrote: %v, received: %v", thetype, i, value[i], s, v[i]) - } - } - v1 := new(string) - if err := json.Unmarshal([]byte(s), v1); err != nil || *v1 != b64String { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, *v1) - } - trans.Reset() - trans.Close() -} - -func TestWriteJSONProtocolList(t *testing.T) { - thetype := "list" - trans := NewTMemoryBuffer() - p := NewTJSONProtocol(trans) - p.WriteListBegin(TType(DOUBLE), len(DOUBLE_VALUES)) - for _, value := range DOUBLE_VALUES { - if e := p.WriteDouble(value); e != nil { - t.Fatalf("Unable to write %s value %v due to error: %s", thetype, value, e.Error()) - } - } - p.WriteListEnd() - if e := p.Flush(); e != nil { - t.Fatalf("Unable to write %s due to error flushing: %s", thetype, e.Error()) - } - str := trans.String() - str1 := new([]interface{}) - err := json.Unmarshal([]byte(str), str1) - if err != nil { - t.Fatalf("Unable to decode %s, wrote: %s", thetype, str) - } - l := *str1 - if len(l) < 2 { - t.Fatalf("List must be at least of length two to include metadata") - } - if l[0] != "dbl" { - t.Fatal("Invalid type for list, expected: ", STRING, ", but was: ", l[0]) - } - if int(l[1].(float64)) != len(DOUBLE_VALUES) { - t.Fatal("Invalid length for list, expected: ", len(DOUBLE_VALUES), ", but was: ", l[1]) - } - for k, value := range DOUBLE_VALUES { - s := l[k+2] - if math.IsInf(value, 1) { - if s.(string) != JSON_INFINITY { - t.Fatalf("Bad value for %s at index %v %v, wrote: %q, expected: %q, originally wrote: %q", thetype, k, value, s, jsonQuote(JSON_INFINITY), str) - } - } else if math.IsInf(value, 0) { - if s.(string) != JSON_NEGATIVE_INFINITY { - t.Fatalf("Bad value for %s at index %v %v, wrote: %q, expected: %q, originally wrote: %q", thetype, k, value, s, jsonQuote(JSON_NEGATIVE_INFINITY), str) - } - } else if math.IsNaN(value) { - if s.(string) != JSON_NAN { - t.Fatalf("Bad value for %s at index %v %v, wrote: %q, expected: %q, originally wrote: %q", thetype, k, value, s, jsonQuote(JSON_NAN), str) - } - } else { - if s.(float64) != value { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s'", thetype, value, s) - } - } - trans.Reset() - } - trans.Close() -} - -func TestWriteJSONProtocolSet(t *testing.T) { - thetype := "set" - trans := NewTMemoryBuffer() - p := NewTJSONProtocol(trans) - p.WriteSetBegin(TType(DOUBLE), len(DOUBLE_VALUES)) - for _, value := range DOUBLE_VALUES { - if e := p.WriteDouble(value); e != nil { - t.Fatalf("Unable to write %s value %v due to error: %s", thetype, value, e.Error()) - } - } - p.WriteSetEnd() - if e := p.Flush(); e != nil { - t.Fatalf("Unable to write %s due to error flushing: %s", thetype, e.Error()) - } - str := trans.String() - str1 := new([]interface{}) - err := json.Unmarshal([]byte(str), str1) - if err != nil { - t.Fatalf("Unable to decode %s, wrote: %s", thetype, str) - } - l := *str1 - if len(l) < 2 { - t.Fatalf("Set must be at least of length two to include metadata") - } - if l[0] != "dbl" { - t.Fatal("Invalid type for set, expected: ", DOUBLE, ", but was: ", l[0]) - } - if int(l[1].(float64)) != len(DOUBLE_VALUES) { - t.Fatal("Invalid length for set, expected: ", len(DOUBLE_VALUES), ", but was: ", l[1]) - } - for k, value := range DOUBLE_VALUES { - s := l[k+2] - if math.IsInf(value, 1) { - if s.(string) != JSON_INFINITY { - t.Fatalf("Bad value for %s at index %v %v, wrote: %q, expected: %q, originally wrote: %q", thetype, k, value, s, jsonQuote(JSON_INFINITY), str) - } - } else if math.IsInf(value, 0) { - if s.(string) != JSON_NEGATIVE_INFINITY { - t.Fatalf("Bad value for %s at index %v %v, wrote: %q, expected: %q, originally wrote: %q", thetype, k, value, s, jsonQuote(JSON_NEGATIVE_INFINITY), str) - } - } else if math.IsNaN(value) { - if s.(string) != JSON_NAN { - t.Fatalf("Bad value for %s at index %v %v, wrote: %q, expected: %q, originally wrote: %q", thetype, k, value, s, jsonQuote(JSON_NAN), str) - } - } else { - if s.(float64) != value { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s'", thetype, value, s) - } - } - trans.Reset() - } - trans.Close() -} - -func TestWriteJSONProtocolMap(t *testing.T) { - thetype := "map" - trans := NewTMemoryBuffer() - p := NewTJSONProtocol(trans) - p.WriteMapBegin(TType(I32), TType(DOUBLE), len(DOUBLE_VALUES)) - for k, value := range DOUBLE_VALUES { - if e := p.WriteI32(int32(k)); e != nil { - t.Fatalf("Unable to write %s key int32 value %v due to error: %s", thetype, k, e.Error()) - } - if e := p.WriteDouble(value); e != nil { - t.Fatalf("Unable to write %s value float64 value %v due to error: %s", thetype, value, e.Error()) - } - } - p.WriteMapEnd() - if e := p.Flush(); e != nil { - t.Fatalf("Unable to write %s due to error flushing: %s", thetype, e.Error()) - } - str := trans.String() - if str[0] != '[' || str[len(str)-1] != ']' { - t.Fatalf("Bad value for %s, wrote: %q, in go: %q", thetype, str, DOUBLE_VALUES) - } - expectedKeyType, expectedValueType, expectedSize, err := p.ReadMapBegin() - if err != nil { - t.Fatalf("Error while reading map begin: %s", err.Error()) - } - if expectedKeyType != I32 { - t.Fatal("Expected map key type ", I32, ", but was ", expectedKeyType) - } - if expectedValueType != DOUBLE { - t.Fatal("Expected map value type ", DOUBLE, ", but was ", expectedValueType) - } - if expectedSize != len(DOUBLE_VALUES) { - t.Fatal("Expected map size of ", len(DOUBLE_VALUES), ", but was ", expectedSize) - } - for k, value := range DOUBLE_VALUES { - ik, err := p.ReadI32() - if err != nil { - t.Fatalf("Bad key for %s index %v, wrote: %v, expected: %v, error: %s", thetype, k, ik, string(k), err.Error()) - } - if int(ik) != k { - t.Fatalf("Bad key for %s index %v, wrote: %v, expected: %v", thetype, k, ik, k) - } - dv, err := p.ReadDouble() - if err != nil { - t.Fatalf("Bad value for %s index %v, wrote: %v, expected: %v, error: %s", thetype, k, dv, value, err.Error()) - } - s := strconv.FormatFloat(dv, 'g', 10, 64) - if math.IsInf(value, 1) { - if !math.IsInf(dv, 1) { - t.Fatalf("Bad value for %s at index %v %v, wrote: %v, expected: %v", thetype, k, value, s, jsonQuote(JSON_INFINITY)) - } - } else if math.IsInf(value, 0) { - if !math.IsInf(dv, 0) { - t.Fatalf("Bad value for %s at index %v %v, wrote: %v, expected: %v", thetype, k, value, s, jsonQuote(JSON_NEGATIVE_INFINITY)) - } - } else if math.IsNaN(value) { - if !math.IsNaN(dv) { - t.Fatalf("Bad value for %s at index %v %v, wrote: %v, expected: %v", thetype, k, value, s, jsonQuote(JSON_NAN)) - } - } else { - expected := strconv.FormatFloat(value, 'g', 10, 64) - if s != expected { - t.Fatalf("Bad value for %s at index %v %v, wrote: %v, expected %v", thetype, k, value, s, expected) - } - v := float64(0) - if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) - } - } - } - err = p.ReadMapEnd() - if err != nil { - t.Fatalf("Error while reading map end: %s", err.Error()) - } - trans.Close() -} diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/lowlevel_benchmarks_test.go b/vendor/git.apache.org/thrift.git/lib/go/thrift/lowlevel_benchmarks_test.go deleted file mode 100644 index a5094ae..0000000 --- a/vendor/git.apache.org/thrift.git/lib/go/thrift/lowlevel_benchmarks_test.go +++ /dev/null @@ -1,396 +0,0 @@ -/* - * 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. - */ - -package thrift - -import ( - "bytes" - "testing" -) - -var binaryProtoF = NewTBinaryProtocolFactoryDefault() -var compactProtoF = NewTCompactProtocolFactory() - -var buf = bytes.NewBuffer(make([]byte, 0, 1024)) - -var tfv = []TTransportFactory{ - NewTMemoryBufferTransportFactory(1024), - NewStreamTransportFactory(buf, buf, true), - NewTFramedTransportFactory(NewTMemoryBufferTransportFactory(1024)), -} - -func BenchmarkBinaryBool_0(b *testing.B) { - trans := tfv[0].GetTransport(nil) - p := binaryProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteBool(b, p, trans) - } -} - -func BenchmarkBinaryByte_0(b *testing.B) { - trans := tfv[0].GetTransport(nil) - p := binaryProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteByte(b, p, trans) - } -} - -func BenchmarkBinaryI16_0(b *testing.B) { - trans := tfv[0].GetTransport(nil) - p := binaryProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteI16(b, p, trans) - } -} - -func BenchmarkBinaryI32_0(b *testing.B) { - trans := tfv[0].GetTransport(nil) - p := binaryProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteI32(b, p, trans) - } -} -func BenchmarkBinaryI64_0(b *testing.B) { - trans := tfv[0].GetTransport(nil) - p := binaryProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteI64(b, p, trans) - } -} -func BenchmarkBinaryDouble_0(b *testing.B) { - trans := tfv[0].GetTransport(nil) - p := binaryProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteDouble(b, p, trans) - } -} -func BenchmarkBinaryString_0(b *testing.B) { - trans := tfv[0].GetTransport(nil) - p := binaryProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteString(b, p, trans) - } -} -func BenchmarkBinaryBinary_0(b *testing.B) { - trans := tfv[0].GetTransport(nil) - p := binaryProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteBinary(b, p, trans) - } -} - -func BenchmarkBinaryBool_1(b *testing.B) { - trans := tfv[1].GetTransport(nil) - p := binaryProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteBool(b, p, trans) - } -} - -func BenchmarkBinaryByte_1(b *testing.B) { - trans := tfv[1].GetTransport(nil) - p := binaryProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteByte(b, p, trans) - } -} - -func BenchmarkBinaryI16_1(b *testing.B) { - trans := tfv[1].GetTransport(nil) - p := binaryProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteI16(b, p, trans) - } -} - -func BenchmarkBinaryI32_1(b *testing.B) { - trans := tfv[1].GetTransport(nil) - p := binaryProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteI32(b, p, trans) - } -} -func BenchmarkBinaryI64_1(b *testing.B) { - trans := tfv[1].GetTransport(nil) - p := binaryProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteI64(b, p, trans) - } -} -func BenchmarkBinaryDouble_1(b *testing.B) { - trans := tfv[1].GetTransport(nil) - p := binaryProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteDouble(b, p, trans) - } -} -func BenchmarkBinaryString_1(b *testing.B) { - trans := tfv[1].GetTransport(nil) - p := binaryProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteString(b, p, trans) - } -} -func BenchmarkBinaryBinary_1(b *testing.B) { - trans := tfv[1].GetTransport(nil) - p := binaryProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteBinary(b, p, trans) - } -} - -func BenchmarkBinaryBool_2(b *testing.B) { - trans := tfv[2].GetTransport(nil) - p := binaryProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteBool(b, p, trans) - } -} - -func BenchmarkBinaryByte_2(b *testing.B) { - trans := tfv[2].GetTransport(nil) - p := binaryProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteByte(b, p, trans) - } -} - -func BenchmarkBinaryI16_2(b *testing.B) { - trans := tfv[2].GetTransport(nil) - p := binaryProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteI16(b, p, trans) - } -} - -func BenchmarkBinaryI32_2(b *testing.B) { - trans := tfv[2].GetTransport(nil) - p := binaryProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteI32(b, p, trans) - } -} -func BenchmarkBinaryI64_2(b *testing.B) { - trans := tfv[2].GetTransport(nil) - p := binaryProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteI64(b, p, trans) - } -} -func BenchmarkBinaryDouble_2(b *testing.B) { - trans := tfv[2].GetTransport(nil) - p := binaryProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteDouble(b, p, trans) - } -} -func BenchmarkBinaryString_2(b *testing.B) { - trans := tfv[2].GetTransport(nil) - p := binaryProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteString(b, p, trans) - } -} -func BenchmarkBinaryBinary_2(b *testing.B) { - trans := tfv[2].GetTransport(nil) - p := binaryProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteBinary(b, p, trans) - } -} - -func BenchmarkCompactBool_0(b *testing.B) { - trans := tfv[0].GetTransport(nil) - p := compactProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteBool(b, p, trans) - } -} - -func BenchmarkCompactByte_0(b *testing.B) { - trans := tfv[0].GetTransport(nil) - p := compactProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteByte(b, p, trans) - } -} - -func BenchmarkCompactI16_0(b *testing.B) { - trans := tfv[0].GetTransport(nil) - p := compactProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteI16(b, p, trans) - } -} - -func BenchmarkCompactI32_0(b *testing.B) { - trans := tfv[0].GetTransport(nil) - p := compactProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteI32(b, p, trans) - } -} -func BenchmarkCompactI64_0(b *testing.B) { - trans := tfv[0].GetTransport(nil) - p := compactProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteI64(b, p, trans) - } -} -func BenchmarkCompactDouble0(b *testing.B) { - trans := tfv[0].GetTransport(nil) - p := compactProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteDouble(b, p, trans) - } -} -func BenchmarkCompactString0(b *testing.B) { - trans := tfv[0].GetTransport(nil) - p := compactProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteString(b, p, trans) - } -} -func BenchmarkCompactBinary0(b *testing.B) { - trans := tfv[0].GetTransport(nil) - p := compactProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteBinary(b, p, trans) - } -} - -func BenchmarkCompactBool_1(b *testing.B) { - trans := tfv[1].GetTransport(nil) - p := compactProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteBool(b, p, trans) - } -} - -func BenchmarkCompactByte_1(b *testing.B) { - trans := tfv[1].GetTransport(nil) - p := compactProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteByte(b, p, trans) - } -} - -func BenchmarkCompactI16_1(b *testing.B) { - trans := tfv[1].GetTransport(nil) - p := compactProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteI16(b, p, trans) - } -} - -func BenchmarkCompactI32_1(b *testing.B) { - trans := tfv[1].GetTransport(nil) - p := compactProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteI32(b, p, trans) - } -} -func BenchmarkCompactI64_1(b *testing.B) { - trans := tfv[1].GetTransport(nil) - p := compactProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteI64(b, p, trans) - } -} -func BenchmarkCompactDouble1(b *testing.B) { - trans := tfv[1].GetTransport(nil) - p := compactProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteDouble(b, p, trans) - } -} -func BenchmarkCompactString1(b *testing.B) { - trans := tfv[1].GetTransport(nil) - p := compactProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteString(b, p, trans) - } -} -func BenchmarkCompactBinary1(b *testing.B) { - trans := tfv[1].GetTransport(nil) - p := compactProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteBinary(b, p, trans) - } -} - -func BenchmarkCompactBool_2(b *testing.B) { - trans := tfv[2].GetTransport(nil) - p := compactProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteBool(b, p, trans) - } -} - -func BenchmarkCompactByte_2(b *testing.B) { - trans := tfv[2].GetTransport(nil) - p := compactProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteByte(b, p, trans) - } -} - -func BenchmarkCompactI16_2(b *testing.B) { - trans := tfv[2].GetTransport(nil) - p := compactProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteI16(b, p, trans) - } -} - -func BenchmarkCompactI32_2(b *testing.B) { - trans := tfv[2].GetTransport(nil) - p := compactProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteI32(b, p, trans) - } -} -func BenchmarkCompactI64_2(b *testing.B) { - trans := tfv[2].GetTransport(nil) - p := compactProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteI64(b, p, trans) - } -} -func BenchmarkCompactDouble2(b *testing.B) { - trans := tfv[2].GetTransport(nil) - p := compactProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteDouble(b, p, trans) - } -} -func BenchmarkCompactString2(b *testing.B) { - trans := tfv[2].GetTransport(nil) - p := compactProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteString(b, p, trans) - } -} -func BenchmarkCompactBinary2(b *testing.B) { - trans := tfv[2].GetTransport(nil) - p := compactProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteBinary(b, p, trans) - } -} diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/memory_buffer_test.go b/vendor/git.apache.org/thrift.git/lib/go/thrift/memory_buffer_test.go deleted file mode 100644 index af2e8bf..0000000 --- a/vendor/git.apache.org/thrift.git/lib/go/thrift/memory_buffer_test.go +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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. - */ - -package thrift - -import ( - "testing" -) - -func TestMemoryBuffer(t *testing.T) { - trans := NewTMemoryBufferLen(1024) - TransportTest(t, trans, trans) -} diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/protocol.go b/vendor/git.apache.org/thrift.git/lib/go/thrift/protocol.go index 5b77363..45fa202 100644 --- a/vendor/git.apache.org/thrift.git/lib/go/thrift/protocol.go +++ b/vendor/git.apache.org/thrift.git/lib/go/thrift/protocol.go @@ -88,9 +88,9 @@ func SkipDefaultDepth(prot TProtocol, typeId TType) (err error) { // Skips over the next data element from the provided input TProtocol object. func Skip(self TProtocol, fieldType TType, maxDepth int) (err error) { - - if maxDepth <= 0 { - return NewTProtocolExceptionWithType(DEPTH_LIMIT, errors.New("Depth limit exceeded")) + + if maxDepth <= 0 { + return NewTProtocolExceptionWithType( DEPTH_LIMIT, errors.New("Depth limit exceeded")) } switch fieldType { diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/protocol_exception.go b/vendor/git.apache.org/thrift.git/lib/go/thrift/protocol_exception.go index 29ab75d..6e357ee 100644 --- a/vendor/git.apache.org/thrift.git/lib/go/thrift/protocol_exception.go +++ b/vendor/git.apache.org/thrift.git/lib/go/thrift/protocol_exception.go @@ -60,7 +60,7 @@ func NewTProtocolException(err error) TProtocolException { if err == nil { return nil } - if e, ok := err.(TProtocolException); ok { + if e,ok := err.(TProtocolException); ok { return e } if _, ok := err.(base64.CorruptInputError); ok { @@ -75,3 +75,4 @@ func NewTProtocolExceptionWithType(errType int, err error) TProtocolException { } return &tProtocolException{errType, err.Error()} } + diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/protocol_test.go b/vendor/git.apache.org/thrift.git/lib/go/thrift/protocol_test.go deleted file mode 100644 index 613eae6..0000000 --- a/vendor/git.apache.org/thrift.git/lib/go/thrift/protocol_test.go +++ /dev/null @@ -1,479 +0,0 @@ -/* - * 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. - */ - -package thrift - -import ( - "bytes" - "io/ioutil" - "math" - "net" - "net/http" - "testing" -) - -const PROTOCOL_BINARY_DATA_SIZE = 155 - -var ( - data string // test data for writing - protocol_bdata []byte // test data for writing; same as data - BOOL_VALUES []bool - BYTE_VALUES []int8 - INT16_VALUES []int16 - INT32_VALUES []int32 - INT64_VALUES []int64 - DOUBLE_VALUES []float64 - STRING_VALUES []string -) - -func init() { - protocol_bdata = make([]byte, PROTOCOL_BINARY_DATA_SIZE) - for i := 0; i < PROTOCOL_BINARY_DATA_SIZE; i++ { - protocol_bdata[i] = byte((i + 'a') % 255) - } - data = string(protocol_bdata) - BOOL_VALUES = []bool{false, true, false, false, true} - BYTE_VALUES = []int8{117, 0, 1, 32, 127, -128, -1} - INT16_VALUES = []int16{459, 0, 1, -1, -128, 127, 32767, -32768} - INT32_VALUES = []int32{459, 0, 1, -1, -128, 127, 32767, 2147483647, -2147483535} - INT64_VALUES = []int64{459, 0, 1, -1, -128, 127, 32767, 2147483647, -2147483535, 34359738481, -35184372088719, -9223372036854775808, 9223372036854775807} - DOUBLE_VALUES = []float64{459.3, 0.0, -1.0, 1.0, 0.5, 0.3333, 3.14159, 1.537e-38, 1.673e25, 6.02214179e23, -6.02214179e23, INFINITY.Float64(), NEGATIVE_INFINITY.Float64(), NAN.Float64()} - STRING_VALUES = []string{"", "a", "st[uf]f", "st,u:ff with spaces", "stuff\twith\nescape\\characters'...\"lots{of}fun"} -} - -type HTTPEchoServer struct{} -type HTTPHeaderEchoServer struct{} - -func (p *HTTPEchoServer) ServeHTTP(w http.ResponseWriter, req *http.Request) { - buf, err := ioutil.ReadAll(req.Body) - if err != nil { - w.WriteHeader(http.StatusBadRequest) - w.Write(buf) - } else { - w.WriteHeader(http.StatusOK) - w.Write(buf) - } -} - -func (p *HTTPHeaderEchoServer) ServeHTTP(w http.ResponseWriter, req *http.Request) { - buf, err := ioutil.ReadAll(req.Body) - if err != nil { - w.WriteHeader(http.StatusBadRequest) - w.Write(buf) - } else { - w.WriteHeader(http.StatusOK) - w.Write(buf) - } -} - -func HttpClientSetupForTest(t *testing.T) (net.Listener, net.Addr) { - addr, err := FindAvailableTCPServerPort(40000) - if err != nil { - t.Fatalf("Unable to find available tcp port addr: %s", err) - return nil, addr - } - l, err := net.Listen(addr.Network(), addr.String()) - if err != nil { - t.Fatalf("Unable to setup tcp listener on %s: %s", addr.String(), err) - return l, addr - } - go http.Serve(l, &HTTPEchoServer{}) - return l, addr -} - -func HttpClientSetupForHeaderTest(t *testing.T) (net.Listener, net.Addr) { - addr, err := FindAvailableTCPServerPort(40000) - if err != nil { - t.Fatalf("Unable to find available tcp port addr: %s", err) - return nil, addr - } - l, err := net.Listen(addr.Network(), addr.String()) - if err != nil { - t.Fatalf("Unable to setup tcp listener on %s: %s", addr.String(), err) - return l, addr - } - go http.Serve(l, &HTTPHeaderEchoServer{}) - return l, addr -} - -func ReadWriteProtocolTest(t *testing.T, protocolFactory TProtocolFactory) { - buf := bytes.NewBuffer(make([]byte, 0, 1024)) - l, addr := HttpClientSetupForTest(t) - defer l.Close() - transports := []TTransportFactory{ - NewTMemoryBufferTransportFactory(1024), - NewStreamTransportFactory(buf, buf, true), - NewTFramedTransportFactory(NewTMemoryBufferTransportFactory(1024)), - NewTHttpPostClientTransportFactory("http://" + addr.String()), - } - for _, tf := range transports { - trans := tf.GetTransport(nil) - p := protocolFactory.GetProtocol(trans) - ReadWriteBool(t, p, trans) - trans.Close() - } - for _, tf := range transports { - trans := tf.GetTransport(nil) - p := protocolFactory.GetProtocol(trans) - ReadWriteByte(t, p, trans) - trans.Close() - } - for _, tf := range transports { - trans := tf.GetTransport(nil) - p := protocolFactory.GetProtocol(trans) - ReadWriteI16(t, p, trans) - trans.Close() - } - for _, tf := range transports { - trans := tf.GetTransport(nil) - p := protocolFactory.GetProtocol(trans) - ReadWriteI32(t, p, trans) - trans.Close() - } - for _, tf := range transports { - trans := tf.GetTransport(nil) - p := protocolFactory.GetProtocol(trans) - ReadWriteI64(t, p, trans) - trans.Close() - } - for _, tf := range transports { - trans := tf.GetTransport(nil) - p := protocolFactory.GetProtocol(trans) - ReadWriteDouble(t, p, trans) - trans.Close() - } - for _, tf := range transports { - trans := tf.GetTransport(nil) - p := protocolFactory.GetProtocol(trans) - ReadWriteString(t, p, trans) - trans.Close() - } - for _, tf := range transports { - trans := tf.GetTransport(nil) - p := protocolFactory.GetProtocol(trans) - ReadWriteBinary(t, p, trans) - trans.Close() - } - for _, tf := range transports { - trans := tf.GetTransport(nil) - p := protocolFactory.GetProtocol(trans) - ReadWriteI64(t, p, trans) - ReadWriteDouble(t, p, trans) - ReadWriteBinary(t, p, trans) - ReadWriteByte(t, p, trans) - trans.Close() - } -} - -func ReadWriteBool(t testing.TB, p TProtocol, trans TTransport) { - thetype := TType(BOOL) - thelen := len(BOOL_VALUES) - err := p.WriteListBegin(thetype, thelen) - if err != nil { - t.Errorf("%s: %T %T %q Error writing list begin: %q", "ReadWriteBool", p, trans, err, thetype) - } - for k, v := range BOOL_VALUES { - err = p.WriteBool(v) - if err != nil { - t.Errorf("%s: %T %T %q Error writing bool in list at index %d: %q", "ReadWriteBool", p, trans, err, k, v) - } - } - p.WriteListEnd() - if err != nil { - t.Errorf("%s: %T %T %q Error writing list end: %q", "ReadWriteBool", p, trans, err, BOOL_VALUES) - } - p.Flush() - thetype2, thelen2, err := p.ReadListBegin() - if err != nil { - t.Errorf("%s: %T %T %q Error reading list: %q", "ReadWriteBool", p, trans, err, BOOL_VALUES) - } - _, ok := p.(*TSimpleJSONProtocol) - if !ok { - if thetype != thetype2 { - t.Errorf("%s: %T %T type %s != type %s", "ReadWriteBool", p, trans, thetype, thetype2) - } - if thelen != thelen2 { - t.Errorf("%s: %T %T len %s != len %s", "ReadWriteBool", p, trans, thelen, thelen2) - } - } - for k, v := range BOOL_VALUES { - value, err := p.ReadBool() - if err != nil { - t.Errorf("%s: %T %T %q Error reading bool at index %d: %q", "ReadWriteBool", p, trans, err, k, v) - } - if v != value { - t.Errorf("%s: index %d %q %q %q != %q", "ReadWriteBool", k, p, trans, v, value) - } - } - err = p.ReadListEnd() - if err != nil { - t.Errorf("%s: %T %T Unable to read list end: %q", "ReadWriteBool", p, trans, err) - } -} - -func ReadWriteByte(t testing.TB, p TProtocol, trans TTransport) { - thetype := TType(BYTE) - thelen := len(BYTE_VALUES) - err := p.WriteListBegin(thetype, thelen) - if err != nil { - t.Errorf("%s: %T %T %q Error writing list begin: %q", "ReadWriteByte", p, trans, err, thetype) - } - for k, v := range BYTE_VALUES { - err = p.WriteByte(v) - if err != nil { - t.Errorf("%s: %T %T %q Error writing byte in list at index %d: %q", "ReadWriteByte", p, trans, err, k, v) - } - } - err = p.WriteListEnd() - if err != nil { - t.Errorf("%s: %T %T %q Error writing list end: %q", "ReadWriteByte", p, trans, err, BYTE_VALUES) - } - err = p.Flush() - if err != nil { - t.Errorf("%s: %T %T %q Error flushing list of bytes: %q", "ReadWriteByte", p, trans, err, BYTE_VALUES) - } - thetype2, thelen2, err := p.ReadListBegin() - if err != nil { - t.Errorf("%s: %T %T %q Error reading list: %q", "ReadWriteByte", p, trans, err, BYTE_VALUES) - } - _, ok := p.(*TSimpleJSONProtocol) - if !ok { - if thetype != thetype2 { - t.Errorf("%s: %T %T type %s != type %s", "ReadWriteByte", p, trans, thetype, thetype2) - } - if thelen != thelen2 { - t.Errorf("%s: %T %T len %s != len %s", "ReadWriteByte", p, trans, thelen, thelen2) - } - } - for k, v := range BYTE_VALUES { - value, err := p.ReadByte() - if err != nil { - t.Errorf("%s: %T %T %q Error reading byte at index %d: %q", "ReadWriteByte", p, trans, err, k, v) - } - if v != value { - t.Errorf("%s: %T %T %d != %d", "ReadWriteByte", p, trans, v, value) - } - } - err = p.ReadListEnd() - if err != nil { - t.Errorf("%s: %T %T Unable to read list end: %q", "ReadWriteByte", p, trans, err) - } -} - -func ReadWriteI16(t testing.TB, p TProtocol, trans TTransport) { - thetype := TType(I16) - thelen := len(INT16_VALUES) - p.WriteListBegin(thetype, thelen) - for _, v := range INT16_VALUES { - p.WriteI16(v) - } - p.WriteListEnd() - p.Flush() - thetype2, thelen2, err := p.ReadListBegin() - if err != nil { - t.Errorf("%s: %T %T %q Error reading list: %q", "ReadWriteI16", p, trans, err, INT16_VALUES) - } - _, ok := p.(*TSimpleJSONProtocol) - if !ok { - if thetype != thetype2 { - t.Errorf("%s: %T %T type %s != type %s", "ReadWriteI16", p, trans, thetype, thetype2) - } - if thelen != thelen2 { - t.Errorf("%s: %T %T len %s != len %s", "ReadWriteI16", p, trans, thelen, thelen2) - } - } - for k, v := range INT16_VALUES { - value, err := p.ReadI16() - if err != nil { - t.Errorf("%s: %T %T %q Error reading int16 at index %d: %q", "ReadWriteI16", p, trans, err, k, v) - } - if v != value { - t.Errorf("%s: %T %T %d != %d", "ReadWriteI16", p, trans, v, value) - } - } - err = p.ReadListEnd() - if err != nil { - t.Errorf("%s: %T %T Unable to read list end: %q", "ReadWriteI16", p, trans, err) - } -} - -func ReadWriteI32(t testing.TB, p TProtocol, trans TTransport) { - thetype := TType(I32) - thelen := len(INT32_VALUES) - p.WriteListBegin(thetype, thelen) - for _, v := range INT32_VALUES { - p.WriteI32(v) - } - p.WriteListEnd() - p.Flush() - thetype2, thelen2, err := p.ReadListBegin() - if err != nil { - t.Errorf("%s: %T %T %q Error reading list: %q", "ReadWriteI32", p, trans, err, INT32_VALUES) - } - _, ok := p.(*TSimpleJSONProtocol) - if !ok { - if thetype != thetype2 { - t.Errorf("%s: %T %T type %s != type %s", "ReadWriteI32", p, trans, thetype, thetype2) - } - if thelen != thelen2 { - t.Errorf("%s: %T %T len %s != len %s", "ReadWriteI32", p, trans, thelen, thelen2) - } - } - for k, v := range INT32_VALUES { - value, err := p.ReadI32() - if err != nil { - t.Errorf("%s: %T %T %q Error reading int32 at index %d: %q", "ReadWriteI32", p, trans, err, k, v) - } - if v != value { - t.Errorf("%s: %T %T %d != %d", "ReadWriteI32", p, trans, v, value) - } - } - if err != nil { - t.Errorf("%s: %T %T Unable to read list end: %q", "ReadWriteI32", p, trans, err) - } -} - -func ReadWriteI64(t testing.TB, p TProtocol, trans TTransport) { - thetype := TType(I64) - thelen := len(INT64_VALUES) - p.WriteListBegin(thetype, thelen) - for _, v := range INT64_VALUES { - p.WriteI64(v) - } - p.WriteListEnd() - p.Flush() - thetype2, thelen2, err := p.ReadListBegin() - if err != nil { - t.Errorf("%s: %T %T %q Error reading list: %q", "ReadWriteI64", p, trans, err, INT64_VALUES) - } - _, ok := p.(*TSimpleJSONProtocol) - if !ok { - if thetype != thetype2 { - t.Errorf("%s: %T %T type %s != type %s", "ReadWriteI64", p, trans, thetype, thetype2) - } - if thelen != thelen2 { - t.Errorf("%s: %T %T len %s != len %s", "ReadWriteI64", p, trans, thelen, thelen2) - } - } - for k, v := range INT64_VALUES { - value, err := p.ReadI64() - if err != nil { - t.Errorf("%s: %T %T %q Error reading int64 at index %d: %q", "ReadWriteI64", p, trans, err, k, v) - } - if v != value { - t.Errorf("%s: %T %T %q != %q", "ReadWriteI64", p, trans, v, value) - } - } - if err != nil { - t.Errorf("%s: %T %T Unable to read list end: %q", "ReadWriteI64", p, trans, err) - } -} - -func ReadWriteDouble(t testing.TB, p TProtocol, trans TTransport) { - thetype := TType(DOUBLE) - thelen := len(DOUBLE_VALUES) - p.WriteListBegin(thetype, thelen) - for _, v := range DOUBLE_VALUES { - p.WriteDouble(v) - } - p.WriteListEnd() - p.Flush() - thetype2, thelen2, err := p.ReadListBegin() - if err != nil { - t.Errorf("%s: %T %T %q Error reading list: %q", "ReadWriteDouble", p, trans, err, DOUBLE_VALUES) - } - if thetype != thetype2 { - t.Errorf("%s: %T %T type %s != type %s", "ReadWriteDouble", p, trans, thetype, thetype2) - } - if thelen != thelen2 { - t.Errorf("%s: %T %T len %s != len %s", "ReadWriteDouble", p, trans, thelen, thelen2) - } - for k, v := range DOUBLE_VALUES { - value, err := p.ReadDouble() - if err != nil { - t.Errorf("%s: %T %T %q Error reading double at index %d: %q", "ReadWriteDouble", p, trans, err, k, v) - } - if math.IsNaN(v) { - if !math.IsNaN(value) { - t.Errorf("%s: %T %T math.IsNaN(%q) != math.IsNaN(%q)", "ReadWriteDouble", p, trans, v, value) - } - } else if v != value { - t.Errorf("%s: %T %T %v != %q", "ReadWriteDouble", p, trans, v, value) - } - } - err = p.ReadListEnd() - if err != nil { - t.Errorf("%s: %T %T Unable to read list end: %q", "ReadWriteDouble", p, trans, err) - } -} - -func ReadWriteString(t testing.TB, p TProtocol, trans TTransport) { - thetype := TType(STRING) - thelen := len(STRING_VALUES) - p.WriteListBegin(thetype, thelen) - for _, v := range STRING_VALUES { - p.WriteString(v) - } - p.WriteListEnd() - p.Flush() - thetype2, thelen2, err := p.ReadListBegin() - if err != nil { - t.Errorf("%s: %T %T %q Error reading list: %q", "ReadWriteString", p, trans, err, STRING_VALUES) - } - _, ok := p.(*TSimpleJSONProtocol) - if !ok { - if thetype != thetype2 { - t.Errorf("%s: %T %T type %s != type %s", "ReadWriteString", p, trans, thetype, thetype2) - } - if thelen != thelen2 { - t.Errorf("%s: %T %T len %s != len %s", "ReadWriteString", p, trans, thelen, thelen2) - } - } - for k, v := range STRING_VALUES { - value, err := p.ReadString() - if err != nil { - t.Errorf("%s: %T %T %q Error reading string at index %d: %q", "ReadWriteString", p, trans, err, k, v) - } - if v != value { - t.Errorf("%s: %T %T %d != %d", "ReadWriteString", p, trans, v, value) - } - } - if err != nil { - t.Errorf("%s: %T %T Unable to read list end: %q", "ReadWriteString", p, trans, err) - } -} - -func ReadWriteBinary(t testing.TB, p TProtocol, trans TTransport) { - v := protocol_bdata - p.WriteBinary(v) - p.Flush() - value, err := p.ReadBinary() - if err != nil { - t.Errorf("%s: %T %T Unable to read binary: %s", "ReadWriteBinary", p, trans, err.Error()) - } - if len(v) != len(value) { - t.Errorf("%s: %T %T len(v) != len(value)... %d != %d", "ReadWriteBinary", p, trans, len(v), len(value)) - } else { - for i := 0; i < len(v); i++ { - if v[i] != value[i] { - t.Errorf("%s: %T %T %s != %s", "ReadWriteBinary", p, trans, v, value) - } - } - } -} diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/rich_transport.go b/vendor/git.apache.org/thrift.git/lib/go/thrift/rich_transport.go index 4025beb..8e296a9 100644 --- a/vendor/git.apache.org/thrift.git/lib/go/thrift/rich_transport.go +++ b/vendor/git.apache.org/thrift.git/lib/go/thrift/rich_transport.go @@ -66,3 +66,4 @@ func writeByte(w io.Writer, c byte) error { _, err := w.Write(v[0:1]) return err } + diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/rich_transport_test.go b/vendor/git.apache.org/thrift.git/lib/go/thrift/rich_transport_test.go deleted file mode 100644 index 41513f8..0000000 --- a/vendor/git.apache.org/thrift.git/lib/go/thrift/rich_transport_test.go +++ /dev/null @@ -1,85 +0,0 @@ -/* - * 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. - */ - -package thrift - -import ( - "bytes" - "errors" - "io" - "reflect" - "testing" -) - -func TestEnsureTransportsAreRich(t *testing.T) { - buf := bytes.NewBuffer(make([]byte, 0, 1024)) - - transports := []TTransportFactory{ - NewTMemoryBufferTransportFactory(1024), - NewStreamTransportFactory(buf, buf, true), - NewTFramedTransportFactory(NewTMemoryBufferTransportFactory(1024)), - NewTHttpPostClientTransportFactory("http://127.0.0.1"), - } - for _, tf := range transports { - trans := tf.GetTransport(nil) - _, ok := trans.(TRichTransport) - if !ok { - t.Errorf("Transport %s does not implement TRichTransport interface", reflect.ValueOf(trans)) - } - } -} - -// TestReadByte tests whether readByte handles error cases correctly. -func TestReadByte(t *testing.T) { - for i, test := range readByteTests { - v, err := readByte(test.r) - if v != test.v { - t.Fatalf("TestReadByte %d: value differs. Expected %d, got %d", i, test.v, test.r.v) - } - if err != test.err { - t.Fatalf("TestReadByte %d: error differs. Expected %s, got %s", i, test.err, test.r.err) - } - } -} - -var someError = errors.New("Some error") -var readByteTests = []struct { - r *mockReader - v byte - err error -}{ - {&mockReader{0, 55, io.EOF}, 0, io.EOF}, // reader sends EOF w/o data - {&mockReader{0, 55, someError}, 0, someError}, // reader sends some other error - {&mockReader{1, 55, nil}, 55, nil}, // reader sends data w/o error - {&mockReader{1, 55, io.EOF}, 55, nil}, // reader sends data with EOF - {&mockReader{1, 55, someError}, 55, someError}, // reader sends data withsome error -} - -type mockReader struct { - n int - v byte - err error -} - -func (r *mockReader) Read(p []byte) (n int, err error) { - if r.n > 0 { - p[0] = r.v - } - return r.n, r.err -} diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/serializer_test.go b/vendor/git.apache.org/thrift.git/lib/go/thrift/serializer_test.go deleted file mode 100644 index 06d27a1..0000000 --- a/vendor/git.apache.org/thrift.git/lib/go/thrift/serializer_test.go +++ /dev/null @@ -1,169 +0,0 @@ -/* - * 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. - */ - -package thrift - -import ( - "errors" - "fmt" - "testing" -) - -type ProtocolFactory interface { - GetProtocol(t TTransport) TProtocol -} - -func compareStructs(m, m1 MyTestStruct) (bool, error) { - switch { - case m.On != m1.On: - return false, errors.New("Boolean not equal") - case m.B != m1.B: - return false, errors.New("Byte not equal") - case m.Int16 != m1.Int16: - return false, errors.New("Int16 not equal") - case m.Int32 != m1.Int32: - return false, errors.New("Int32 not equal") - case m.Int64 != m1.Int64: - return false, errors.New("Int64 not equal") - case m.D != m1.D: - return false, errors.New("Double not equal") - case m.St != m1.St: - return false, errors.New("String not equal") - - case len(m.Bin) != len(m1.Bin): - return false, errors.New("Binary size not equal") - case len(m.Bin) == len(m1.Bin): - for i := range m.Bin { - if m.Bin[i] != m1.Bin[i] { - return false, errors.New("Binary not equal") - } - } - case len(m.StringMap) != len(m1.StringMap): - return false, errors.New("StringMap size not equal") - case len(m.StringList) != len(m1.StringList): - return false, errors.New("StringList size not equal") - case len(m.StringSet) != len(m1.StringSet): - return false, errors.New("StringSet size not equal") - - case m.E != m1.E: - return false, errors.New("MyTestEnum not equal") - - default: - return true, nil - - } - return true, nil -} - -func ProtocolTest1(test *testing.T, pf ProtocolFactory) (bool, error) { - t := NewTSerializer() - t.Protocol = pf.GetProtocol(t.Transport) - var m = MyTestStruct{} - m.On = true - m.B = int8(0) - m.Int16 = 1 - m.Int32 = 2 - m.Int64 = 3 - m.D = 4.1 - m.St = "Test" - m.Bin = make([]byte, 10) - m.StringMap = make(map[string]string, 5) - m.StringList = make([]string, 5) - m.StringSet = make(map[string]struct{}, 5) - m.E = 2 - - s, err := t.WriteString(&m) - if err != nil { - return false, errors.New(fmt.Sprintf("Unable to Serialize struct\n\t %s", err)) - } - - t1 := NewTDeserializer() - t1.Protocol = pf.GetProtocol(t1.Transport) - var m1 = MyTestStruct{} - if err = t1.ReadString(&m1, s); err != nil { - return false, errors.New(fmt.Sprintf("Unable to Deserialize struct\n\t %s", err)) - - } - - return compareStructs(m, m1) - -} - -func ProtocolTest2(test *testing.T, pf ProtocolFactory) (bool, error) { - t := NewTSerializer() - t.Protocol = pf.GetProtocol(t.Transport) - var m = MyTestStruct{} - m.On = false - m.B = int8(0) - m.Int16 = 1 - m.Int32 = 2 - m.Int64 = 3 - m.D = 4.1 - m.St = "Test" - m.Bin = make([]byte, 10) - m.StringMap = make(map[string]string, 5) - m.StringList = make([]string, 5) - m.StringSet = make(map[string]struct{}, 5) - m.E = 2 - - s, err := t.WriteString(&m) - if err != nil { - return false, errors.New(fmt.Sprintf("Unable to Serialize struct\n\t %s", err)) - - } - - t1 := NewTDeserializer() - t1.Protocol = pf.GetProtocol(t1.Transport) - var m1 = MyTestStruct{} - if err = t1.ReadString(&m1, s); err != nil { - return false, errors.New(fmt.Sprintf("Unable to Deserialize struct\n\t %s", err)) - - } - - return compareStructs(m, m1) - -} - -func TestSerializer(t *testing.T) { - - var protocol_factories map[string]ProtocolFactory - protocol_factories = make(map[string]ProtocolFactory) - protocol_factories["Binary"] = NewTBinaryProtocolFactoryDefault() - protocol_factories["Compact"] = NewTCompactProtocolFactory() - //protocol_factories["SimpleJSON"] = NewTSimpleJSONProtocolFactory() - write only, can't be read back by design - protocol_factories["JSON"] = NewTJSONProtocolFactory() - - var tests map[string]func(*testing.T, ProtocolFactory) (bool, error) - tests = make(map[string]func(*testing.T, ProtocolFactory) (bool, error)) - tests["Test 1"] = ProtocolTest1 - tests["Test 2"] = ProtocolTest2 - //tests["Test 3"] = ProtocolTest3 // Example of how to add additional tests - - for name, pf := range protocol_factories { - - for test, f := range tests { - - if s, err := f(t, pf); !s || err != nil { - t.Errorf("%s Failed for %s protocol\n\t %s", test, name, err) - } - - } - } - -} diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/serializer_types_test.go b/vendor/git.apache.org/thrift.git/lib/go/thrift/serializer_types_test.go deleted file mode 100644 index 38ab8d6..0000000 --- a/vendor/git.apache.org/thrift.git/lib/go/thrift/serializer_types_test.go +++ /dev/null @@ -1,633 +0,0 @@ -/* - * 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. - */ - -package thrift - -// Autogenerated by Thrift Compiler (1.0.0-dev) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING - -/* THE FOLLOWING THRIFT FILE WAS USED TO CREATE THIS - -enum MyTestEnum { - FIRST = 1, - SECOND = 2, - THIRD = 3, - FOURTH = 4, -} - -struct MyTestStruct { - 1: bool on, - 2: byte b, - 3: i16 int16, - 4: i32 int32, - 5: i64 int64, - 6: double d, - 7: string st, - 8: binary bin, - 9: map stringMap, - 10: list stringList, - 11: set stringSet, - 12: MyTestEnum e, -} -*/ - -import ( - "fmt" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = ZERO -var _ = fmt.Printf - -var GoUnusedProtection__ int - -type MyTestEnum int64 - -const ( - MyTestEnum_FIRST MyTestEnum = 1 - MyTestEnum_SECOND MyTestEnum = 2 - MyTestEnum_THIRD MyTestEnum = 3 - MyTestEnum_FOURTH MyTestEnum = 4 -) - -func (p MyTestEnum) String() string { - switch p { - case MyTestEnum_FIRST: - return "FIRST" - case MyTestEnum_SECOND: - return "SECOND" - case MyTestEnum_THIRD: - return "THIRD" - case MyTestEnum_FOURTH: - return "FOURTH" - } - return "" -} - -func MyTestEnumFromString(s string) (MyTestEnum, error) { - switch s { - case "FIRST": - return MyTestEnum_FIRST, nil - case "SECOND": - return MyTestEnum_SECOND, nil - case "THIRD": - return MyTestEnum_THIRD, nil - case "FOURTH": - return MyTestEnum_FOURTH, nil - } - return MyTestEnum(0), fmt.Errorf("not a valid MyTestEnum string") -} - -func MyTestEnumPtr(v MyTestEnum) *MyTestEnum { return &v } - -type MyTestStruct struct { - On bool `thrift:"on,1" json:"on"` - B int8 `thrift:"b,2" json:"b"` - Int16 int16 `thrift:"int16,3" json:"int16"` - Int32 int32 `thrift:"int32,4" json:"int32"` - Int64 int64 `thrift:"int64,5" json:"int64"` - D float64 `thrift:"d,6" json:"d"` - St string `thrift:"st,7" json:"st"` - Bin []byte `thrift:"bin,8" json:"bin"` - StringMap map[string]string `thrift:"stringMap,9" json:"stringMap"` - StringList []string `thrift:"stringList,10" json:"stringList"` - StringSet map[string]struct{} `thrift:"stringSet,11" json:"stringSet"` - E MyTestEnum `thrift:"e,12" json:"e"` -} - -func NewMyTestStruct() *MyTestStruct { - return &MyTestStruct{} -} - -func (p *MyTestStruct) GetOn() bool { - return p.On -} - -func (p *MyTestStruct) GetB() int8 { - return p.B -} - -func (p *MyTestStruct) GetInt16() int16 { - return p.Int16 -} - -func (p *MyTestStruct) GetInt32() int32 { - return p.Int32 -} - -func (p *MyTestStruct) GetInt64() int64 { - return p.Int64 -} - -func (p *MyTestStruct) GetD() float64 { - return p.D -} - -func (p *MyTestStruct) GetSt() string { - return p.St -} - -func (p *MyTestStruct) GetBin() []byte { - return p.Bin -} - -func (p *MyTestStruct) GetStringMap() map[string]string { - return p.StringMap -} - -func (p *MyTestStruct) GetStringList() []string { - return p.StringList -} - -func (p *MyTestStruct) GetStringSet() map[string]struct{} { - return p.StringSet -} - -func (p *MyTestStruct) GetE() MyTestEnum { - return p.E -} -func (p *MyTestStruct) Read(iprot TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return PrependError(fmt.Sprintf("%T read error: ", p), err) - } - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - case 2: - if err := p.readField2(iprot); err != nil { - return err - } - case 3: - if err := p.readField3(iprot); err != nil { - return err - } - case 4: - if err := p.readField4(iprot); err != nil { - return err - } - case 5: - if err := p.readField5(iprot); err != nil { - return err - } - case 6: - if err := p.readField6(iprot); err != nil { - return err - } - case 7: - if err := p.readField7(iprot); err != nil { - return err - } - case 8: - if err := p.readField8(iprot); err != nil { - return err - } - case 9: - if err := p.readField9(iprot); err != nil { - return err - } - case 10: - if err := p.readField10(iprot); err != nil { - return err - } - case 11: - if err := p.readField11(iprot); err != nil { - return err - } - case 12: - if err := p.readField12(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyTestStruct) readField1(iprot TProtocol) error { - if v, err := iprot.ReadBool(); err != nil { - return PrependError("error reading field 1: ", err) - } else { - p.On = v - } - return nil -} - -func (p *MyTestStruct) readField2(iprot TProtocol) error { - if v, err := iprot.ReadByte(); err != nil { - return PrependError("error reading field 2: ", err) - } else { - temp := int8(v) - p.B = temp - } - return nil -} - -func (p *MyTestStruct) readField3(iprot TProtocol) error { - if v, err := iprot.ReadI16(); err != nil { - return PrependError("error reading field 3: ", err) - } else { - p.Int16 = v - } - return nil -} - -func (p *MyTestStruct) readField4(iprot TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return PrependError("error reading field 4: ", err) - } else { - p.Int32 = v - } - return nil -} - -func (p *MyTestStruct) readField5(iprot TProtocol) error { - if v, err := iprot.ReadI64(); err != nil { - return PrependError("error reading field 5: ", err) - } else { - p.Int64 = v - } - return nil -} - -func (p *MyTestStruct) readField6(iprot TProtocol) error { - if v, err := iprot.ReadDouble(); err != nil { - return PrependError("error reading field 6: ", err) - } else { - p.D = v - } - return nil -} - -func (p *MyTestStruct) readField7(iprot TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return PrependError("error reading field 7: ", err) - } else { - p.St = v - } - return nil -} - -func (p *MyTestStruct) readField8(iprot TProtocol) error { - if v, err := iprot.ReadBinary(); err != nil { - return PrependError("error reading field 8: ", err) - } else { - p.Bin = v - } - return nil -} - -func (p *MyTestStruct) readField9(iprot TProtocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return PrependError("error reading map begin: ", err) - } - tMap := make(map[string]string, size) - p.StringMap = tMap - for i := 0; i < size; i++ { - var _key0 string - if v, err := iprot.ReadString(); err != nil { - return PrependError("error reading field 0: ", err) - } else { - _key0 = v - } - var _val1 string - if v, err := iprot.ReadString(); err != nil { - return PrependError("error reading field 0: ", err) - } else { - _val1 = v - } - p.StringMap[_key0] = _val1 - } - if err := iprot.ReadMapEnd(); err != nil { - return PrependError("error reading map end: ", err) - } - return nil -} - -func (p *MyTestStruct) readField10(iprot TProtocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return PrependError("error reading list begin: ", err) - } - tSlice := make([]string, 0, size) - p.StringList = tSlice - for i := 0; i < size; i++ { - var _elem2 string - if v, err := iprot.ReadString(); err != nil { - return PrependError("error reading field 0: ", err) - } else { - _elem2 = v - } - p.StringList = append(p.StringList, _elem2) - } - if err := iprot.ReadListEnd(); err != nil { - return PrependError("error reading list end: ", err) - } - return nil -} - -func (p *MyTestStruct) readField11(iprot TProtocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return PrependError("error reading set begin: ", err) - } - tSet := make(map[string]struct{}, size) - p.StringSet = tSet - for i := 0; i < size; i++ { - var _elem3 string - if v, err := iprot.ReadString(); err != nil { - return PrependError("error reading field 0: ", err) - } else { - _elem3 = v - } - p.StringSet[_elem3] = struct{}{} - } - if err := iprot.ReadSetEnd(); err != nil { - return PrependError("error reading set end: ", err) - } - return nil -} - -func (p *MyTestStruct) readField12(iprot TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return PrependError("error reading field 12: ", err) - } else { - temp := MyTestEnum(v) - p.E = temp - } - return nil -} - -func (p *MyTestStruct) Write(oprot TProtocol) error { - if err := oprot.WriteStructBegin("MyTestStruct"); err != nil { - return PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := p.writeField2(oprot); err != nil { - return err - } - if err := p.writeField3(oprot); err != nil { - return err - } - if err := p.writeField4(oprot); err != nil { - return err - } - if err := p.writeField5(oprot); err != nil { - return err - } - if err := p.writeField6(oprot); err != nil { - return err - } - if err := p.writeField7(oprot); err != nil { - return err - } - if err := p.writeField8(oprot); err != nil { - return err - } - if err := p.writeField9(oprot); err != nil { - return err - } - if err := p.writeField10(oprot); err != nil { - return err - } - if err := p.writeField11(oprot); err != nil { - return err - } - if err := p.writeField12(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *MyTestStruct) writeField1(oprot TProtocol) (err error) { - if err := oprot.WriteFieldBegin("on", BOOL, 1); err != nil { - return PrependError(fmt.Sprintf("%T write field begin error 1:on: ", p), err) - } - if err := oprot.WriteBool(bool(p.On)); err != nil { - return PrependError(fmt.Sprintf("%T.on (1) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return PrependError(fmt.Sprintf("%T write field end error 1:on: ", p), err) - } - return err -} - -func (p *MyTestStruct) writeField2(oprot TProtocol) (err error) { - if err := oprot.WriteFieldBegin("b", BYTE, 2); err != nil { - return PrependError(fmt.Sprintf("%T write field begin error 2:b: ", p), err) - } - if err := oprot.WriteByte(int8(p.B)); err != nil { - return PrependError(fmt.Sprintf("%T.b (2) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return PrependError(fmt.Sprintf("%T write field end error 2:b: ", p), err) - } - return err -} - -func (p *MyTestStruct) writeField3(oprot TProtocol) (err error) { - if err := oprot.WriteFieldBegin("int16", I16, 3); err != nil { - return PrependError(fmt.Sprintf("%T write field begin error 3:int16: ", p), err) - } - if err := oprot.WriteI16(int16(p.Int16)); err != nil { - return PrependError(fmt.Sprintf("%T.int16 (3) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return PrependError(fmt.Sprintf("%T write field end error 3:int16: ", p), err) - } - return err -} - -func (p *MyTestStruct) writeField4(oprot TProtocol) (err error) { - if err := oprot.WriteFieldBegin("int32", I32, 4); err != nil { - return PrependError(fmt.Sprintf("%T write field begin error 4:int32: ", p), err) - } - if err := oprot.WriteI32(int32(p.Int32)); err != nil { - return PrependError(fmt.Sprintf("%T.int32 (4) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return PrependError(fmt.Sprintf("%T write field end error 4:int32: ", p), err) - } - return err -} - -func (p *MyTestStruct) writeField5(oprot TProtocol) (err error) { - if err := oprot.WriteFieldBegin("int64", I64, 5); err != nil { - return PrependError(fmt.Sprintf("%T write field begin error 5:int64: ", p), err) - } - if err := oprot.WriteI64(int64(p.Int64)); err != nil { - return PrependError(fmt.Sprintf("%T.int64 (5) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return PrependError(fmt.Sprintf("%T write field end error 5:int64: ", p), err) - } - return err -} - -func (p *MyTestStruct) writeField6(oprot TProtocol) (err error) { - if err := oprot.WriteFieldBegin("d", DOUBLE, 6); err != nil { - return PrependError(fmt.Sprintf("%T write field begin error 6:d: ", p), err) - } - if err := oprot.WriteDouble(float64(p.D)); err != nil { - return PrependError(fmt.Sprintf("%T.d (6) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return PrependError(fmt.Sprintf("%T write field end error 6:d: ", p), err) - } - return err -} - -func (p *MyTestStruct) writeField7(oprot TProtocol) (err error) { - if err := oprot.WriteFieldBegin("st", STRING, 7); err != nil { - return PrependError(fmt.Sprintf("%T write field begin error 7:st: ", p), err) - } - if err := oprot.WriteString(string(p.St)); err != nil { - return PrependError(fmt.Sprintf("%T.st (7) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return PrependError(fmt.Sprintf("%T write field end error 7:st: ", p), err) - } - return err -} - -func (p *MyTestStruct) writeField8(oprot TProtocol) (err error) { - if err := oprot.WriteFieldBegin("bin", STRING, 8); err != nil { - return PrependError(fmt.Sprintf("%T write field begin error 8:bin: ", p), err) - } - if err := oprot.WriteBinary(p.Bin); err != nil { - return PrependError(fmt.Sprintf("%T.bin (8) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return PrependError(fmt.Sprintf("%T write field end error 8:bin: ", p), err) - } - return err -} - -func (p *MyTestStruct) writeField9(oprot TProtocol) (err error) { - if err := oprot.WriteFieldBegin("stringMap", MAP, 9); err != nil { - return PrependError(fmt.Sprintf("%T write field begin error 9:stringMap: ", p), err) - } - if err := oprot.WriteMapBegin(STRING, STRING, len(p.StringMap)); err != nil { - return PrependError("error writing map begin: ", err) - } - for k, v := range p.StringMap { - if err := oprot.WriteString(string(k)); err != nil { - return PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) - } - if err := oprot.WriteString(string(v)); err != nil { - return PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) - } - } - if err := oprot.WriteMapEnd(); err != nil { - return PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return PrependError(fmt.Sprintf("%T write field end error 9:stringMap: ", p), err) - } - return err -} - -func (p *MyTestStruct) writeField10(oprot TProtocol) (err error) { - if err := oprot.WriteFieldBegin("stringList", LIST, 10); err != nil { - return PrependError(fmt.Sprintf("%T write field begin error 10:stringList: ", p), err) - } - if err := oprot.WriteListBegin(STRING, len(p.StringList)); err != nil { - return PrependError("error writing list begin: ", err) - } - for _, v := range p.StringList { - if err := oprot.WriteString(string(v)); err != nil { - return PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) - } - } - if err := oprot.WriteListEnd(); err != nil { - return PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return PrependError(fmt.Sprintf("%T write field end error 10:stringList: ", p), err) - } - return err -} - -func (p *MyTestStruct) writeField11(oprot TProtocol) (err error) { - if err := oprot.WriteFieldBegin("stringSet", SET, 11); err != nil { - return PrependError(fmt.Sprintf("%T write field begin error 11:stringSet: ", p), err) - } - if err := oprot.WriteSetBegin(STRING, len(p.StringSet)); err != nil { - return PrependError("error writing set begin: ", err) - } - for v, _ := range p.StringSet { - if err := oprot.WriteString(string(v)); err != nil { - return PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) - } - } - if err := oprot.WriteSetEnd(); err != nil { - return PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return PrependError(fmt.Sprintf("%T write field end error 11:stringSet: ", p), err) - } - return err -} - -func (p *MyTestStruct) writeField12(oprot TProtocol) (err error) { - if err := oprot.WriteFieldBegin("e", I32, 12); err != nil { - return PrependError(fmt.Sprintf("%T write field begin error 12:e: ", p), err) - } - if err := oprot.WriteI32(int32(p.E)); err != nil { - return PrependError(fmt.Sprintf("%T.e (12) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return PrependError(fmt.Sprintf("%T write field end error 12:e: ", p), err) - } - return err -} - -func (p *MyTestStruct) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("MyTestStruct(%+v)", *p) -} diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/server_socket_test.go b/vendor/git.apache.org/thrift.git/lib/go/thrift/server_socket_test.go deleted file mode 100644 index f08e8e9..0000000 --- a/vendor/git.apache.org/thrift.git/lib/go/thrift/server_socket_test.go +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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. - */ - -package thrift - -import ( - "fmt" - "testing" -) - -func TestSocketIsntListeningAfterInterrupt(t *testing.T) { - host := "127.0.0.1" - port := 9090 - addr := fmt.Sprintf("%s:%d", host, port) - - socket := CreateServerSocket(t, addr) - socket.Listen() - socket.Interrupt() - - newSocket := CreateServerSocket(t, addr) - err := newSocket.Listen() - defer newSocket.Interrupt() - if err != nil { - t.Fatalf("Failed to rebinds: %s", err) - } -} - -func CreateServerSocket(t *testing.T, addr string) *TServerSocket { - socket, err := NewTServerSocket(addr) - if err != nil { - t.Fatalf("Failed to create server socket: %s", err) - } - return socket -} diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/server_test.go b/vendor/git.apache.org/thrift.git/lib/go/thrift/server_test.go deleted file mode 100644 index ffaf457..0000000 --- a/vendor/git.apache.org/thrift.git/lib/go/thrift/server_test.go +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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. - */ - -package thrift - -import ( - "testing" -) - -func TestNothing(t *testing.T) { - -} diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/simple_json_protocol_test.go b/vendor/git.apache.org/thrift.git/lib/go/thrift/simple_json_protocol_test.go deleted file mode 100644 index 8f0dcc9..0000000 --- a/vendor/git.apache.org/thrift.git/lib/go/thrift/simple_json_protocol_test.go +++ /dev/null @@ -1,715 +0,0 @@ -/* - * 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. - */ - -package thrift - -import ( - "encoding/base64" - "encoding/json" - "fmt" - "math" - "strconv" - "strings" - "testing" -) - -func TestWriteSimpleJSONProtocolBool(t *testing.T) { - thetype := "boolean" - trans := NewTMemoryBuffer() - p := NewTSimpleJSONProtocol(trans) - for _, value := range BOOL_VALUES { - if e := p.WriteBool(value); e != nil { - t.Fatalf("Unable to write %s value %v due to error: %s", thetype, value, e.Error()) - } - if e := p.Flush(); e != nil { - t.Fatalf("Unable to write %s value %v due to error flushing: %s", thetype, value, e.Error()) - } - s := trans.String() - if s != fmt.Sprint(value) { - t.Fatalf("Bad value for %s %v: %s", thetype, value, s) - } - v := false - if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) - } - trans.Reset() - } - trans.Close() -} - -func TestReadSimpleJSONProtocolBool(t *testing.T) { - thetype := "boolean" - for _, value := range BOOL_VALUES { - trans := NewTMemoryBuffer() - p := NewTSimpleJSONProtocol(trans) - if value { - trans.Write(JSON_TRUE) - } else { - trans.Write(JSON_FALSE) - } - trans.Flush() - s := trans.String() - v, e := p.ReadBool() - if e != nil { - t.Fatalf("Unable to read %s value %v due to error: %s", thetype, value, e.Error()) - } - if v != value { - t.Fatalf("Bad value for %s value %v, wrote: %v, received: %v", thetype, value, s, v) - } - if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) - } - trans.Reset() - trans.Close() - } -} - -func TestWriteSimpleJSONProtocolByte(t *testing.T) { - thetype := "byte" - trans := NewTMemoryBuffer() - p := NewTSimpleJSONProtocol(trans) - for _, value := range BYTE_VALUES { - if e := p.WriteByte(value); e != nil { - t.Fatalf("Unable to write %s value %v due to error: %s", thetype, value, e.Error()) - } - if e := p.Flush(); e != nil { - t.Fatalf("Unable to write %s value %v due to error flushing: %s", thetype, value, e.Error()) - } - s := trans.String() - if s != fmt.Sprint(value) { - t.Fatalf("Bad value for %s %v: %s", thetype, value, s) - } - v := int8(0) - if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) - } - trans.Reset() - } - trans.Close() -} - -func TestReadSimpleJSONProtocolByte(t *testing.T) { - thetype := "byte" - for _, value := range BYTE_VALUES { - trans := NewTMemoryBuffer() - p := NewTSimpleJSONProtocol(trans) - trans.WriteString(strconv.Itoa(int(value))) - trans.Flush() - s := trans.String() - v, e := p.ReadByte() - if e != nil { - t.Fatalf("Unable to read %s value %v due to error: %s", thetype, value, e.Error()) - } - if v != value { - t.Fatalf("Bad value for %s value %v, wrote: %v, received: %v", thetype, value, s, v) - } - if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) - } - trans.Reset() - trans.Close() - } -} - -func TestWriteSimpleJSONProtocolI16(t *testing.T) { - thetype := "int16" - trans := NewTMemoryBuffer() - p := NewTSimpleJSONProtocol(trans) - for _, value := range INT16_VALUES { - if e := p.WriteI16(value); e != nil { - t.Fatalf("Unable to write %s value %v due to error: %s", thetype, value, e.Error()) - } - if e := p.Flush(); e != nil { - t.Fatalf("Unable to write %s value %v due to error flushing: %s", thetype, value, e.Error()) - } - s := trans.String() - if s != fmt.Sprint(value) { - t.Fatalf("Bad value for %s %v: %s", thetype, value, s) - } - v := int16(0) - if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) - } - trans.Reset() - } - trans.Close() -} - -func TestReadSimpleJSONProtocolI16(t *testing.T) { - thetype := "int16" - for _, value := range INT16_VALUES { - trans := NewTMemoryBuffer() - p := NewTSimpleJSONProtocol(trans) - trans.WriteString(strconv.Itoa(int(value))) - trans.Flush() - s := trans.String() - v, e := p.ReadI16() - if e != nil { - t.Fatalf("Unable to read %s value %v due to error: %s", thetype, value, e.Error()) - } - if v != value { - t.Fatalf("Bad value for %s value %v, wrote: %v, received: %v", thetype, value, s, v) - } - if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) - } - trans.Reset() - trans.Close() - } -} - -func TestWriteSimpleJSONProtocolI32(t *testing.T) { - thetype := "int32" - trans := NewTMemoryBuffer() - p := NewTSimpleJSONProtocol(trans) - for _, value := range INT32_VALUES { - if e := p.WriteI32(value); e != nil { - t.Fatalf("Unable to write %s value %v due to error: %s", thetype, value, e.Error()) - } - if e := p.Flush(); e != nil { - t.Fatalf("Unable to write %s value %v due to error flushing: %s", thetype, value, e.Error()) - } - s := trans.String() - if s != fmt.Sprint(value) { - t.Fatalf("Bad value for %s %v: %s", thetype, value, s) - } - v := int32(0) - if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) - } - trans.Reset() - } - trans.Close() -} - -func TestReadSimpleJSONProtocolI32(t *testing.T) { - thetype := "int32" - for _, value := range INT32_VALUES { - trans := NewTMemoryBuffer() - p := NewTSimpleJSONProtocol(trans) - trans.WriteString(strconv.Itoa(int(value))) - trans.Flush() - s := trans.String() - v, e := p.ReadI32() - if e != nil { - t.Fatalf("Unable to read %s value %v due to error: %s", thetype, value, e.Error()) - } - if v != value { - t.Fatalf("Bad value for %s value %v, wrote: %v, received: %v", thetype, value, s, v) - } - if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) - } - trans.Reset() - trans.Close() - } -} - -func TestReadSimpleJSONProtocolI32Null(t *testing.T) { - thetype := "int32" - value := "null" - - trans := NewTMemoryBuffer() - p := NewTSimpleJSONProtocol(trans) - trans.WriteString(value) - trans.Flush() - s := trans.String() - v, e := p.ReadI32() - - if e != nil { - t.Fatalf("Unable to read %s value %v due to error: %s", thetype, value, e.Error()) - } - if v != 0 { - t.Fatalf("Bad value for %s value %v, wrote: %v, received: %v", thetype, value, s, v) - } - trans.Reset() - trans.Close() -} - -func TestWriteSimpleJSONProtocolI64(t *testing.T) { - thetype := "int64" - trans := NewTMemoryBuffer() - p := NewTSimpleJSONProtocol(trans) - for _, value := range INT64_VALUES { - if e := p.WriteI64(value); e != nil { - t.Fatalf("Unable to write %s value %v due to error: %s", thetype, value, e.Error()) - } - if e := p.Flush(); e != nil { - t.Fatalf("Unable to write %s value %v due to error flushing: %s", thetype, value, e.Error()) - } - s := trans.String() - if s != fmt.Sprint(value) { - t.Fatalf("Bad value for %s %v: %s", thetype, value, s) - } - v := int64(0) - if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) - } - trans.Reset() - } - trans.Close() -} - -func TestReadSimpleJSONProtocolI64(t *testing.T) { - thetype := "int64" - for _, value := range INT64_VALUES { - trans := NewTMemoryBuffer() - p := NewTSimpleJSONProtocol(trans) - trans.WriteString(strconv.FormatInt(value, 10)) - trans.Flush() - s := trans.String() - v, e := p.ReadI64() - if e != nil { - t.Fatalf("Unable to read %s value %v due to error: %s", thetype, value, e.Error()) - } - if v != value { - t.Fatalf("Bad value for %s value %v, wrote: %v, received: %v", thetype, value, s, v) - } - if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) - } - trans.Reset() - trans.Close() - } -} - -func TestReadSimpleJSONProtocolI64Null(t *testing.T) { - thetype := "int32" - value := "null" - - trans := NewTMemoryBuffer() - p := NewTSimpleJSONProtocol(trans) - trans.WriteString(value) - trans.Flush() - s := trans.String() - v, e := p.ReadI64() - - if e != nil { - t.Fatalf("Unable to read %s value %v due to error: %s", thetype, value, e.Error()) - } - if v != 0 { - t.Fatalf("Bad value for %s value %v, wrote: %v, received: %v", thetype, value, s, v) - } - trans.Reset() - trans.Close() -} - -func TestWriteSimpleJSONProtocolDouble(t *testing.T) { - thetype := "double" - trans := NewTMemoryBuffer() - p := NewTSimpleJSONProtocol(trans) - for _, value := range DOUBLE_VALUES { - if e := p.WriteDouble(value); e != nil { - t.Fatalf("Unable to write %s value %v due to error: %s", thetype, value, e.Error()) - } - if e := p.Flush(); e != nil { - t.Fatalf("Unable to write %s value %v due to error flushing: %s", thetype, value, e.Error()) - } - s := trans.String() - if math.IsInf(value, 1) { - if s != jsonQuote(JSON_INFINITY) { - t.Fatalf("Bad value for %s %v, wrote: %v, expected: %v", thetype, value, s, jsonQuote(JSON_INFINITY)) - } - } else if math.IsInf(value, -1) { - if s != jsonQuote(JSON_NEGATIVE_INFINITY) { - t.Fatalf("Bad value for %s %v, wrote: %v, expected: %v", thetype, value, s, jsonQuote(JSON_NEGATIVE_INFINITY)) - } - } else if math.IsNaN(value) { - if s != jsonQuote(JSON_NAN) { - t.Fatalf("Bad value for %s %v, wrote: %v, expected: %v", thetype, value, s, jsonQuote(JSON_NAN)) - } - } else { - if s != fmt.Sprint(value) { - t.Fatalf("Bad value for %s %v: %s", thetype, value, s) - } - v := float64(0) - if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) - } - } - trans.Reset() - } - trans.Close() -} - -func TestReadSimpleJSONProtocolDouble(t *testing.T) { - thetype := "double" - for _, value := range DOUBLE_VALUES { - trans := NewTMemoryBuffer() - p := NewTSimpleJSONProtocol(trans) - n := NewNumericFromDouble(value) - trans.WriteString(n.String()) - trans.Flush() - s := trans.String() - v, e := p.ReadDouble() - if e != nil { - t.Fatalf("Unable to read %s value %v due to error: %s", thetype, value, e.Error()) - } - if math.IsInf(value, 1) { - if !math.IsInf(v, 1) { - t.Fatalf("Bad value for %s %v, wrote: %v, received: %v", thetype, value, s, v) - } - } else if math.IsInf(value, -1) { - if !math.IsInf(v, -1) { - t.Fatalf("Bad value for %s %v, wrote: %v, received: %v", thetype, value, s, v) - } - } else if math.IsNaN(value) { - if !math.IsNaN(v) { - t.Fatalf("Bad value for %s %v, wrote: %v, received: %v", thetype, value, s, v) - } - } else { - if v != value { - t.Fatalf("Bad value for %s value %v, wrote: %v, received: %v", thetype, value, s, v) - } - if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) - } - } - trans.Reset() - trans.Close() - } -} - -func TestWriteSimpleJSONProtocolString(t *testing.T) { - thetype := "string" - trans := NewTMemoryBuffer() - p := NewTSimpleJSONProtocol(trans) - for _, value := range STRING_VALUES { - if e := p.WriteString(value); e != nil { - t.Fatalf("Unable to write %s value %v due to error: %s", thetype, value, e.Error()) - } - if e := p.Flush(); e != nil { - t.Fatalf("Unable to write %s value %v due to error flushing: %s", thetype, value, e.Error()) - } - s := trans.String() - if s[0] != '"' || s[len(s)-1] != '"' { - t.Fatalf("Bad value for %s '%v', wrote '%v', expected: %v", thetype, value, s, fmt.Sprint("\"", value, "\"")) - } - v := new(string) - if err := json.Unmarshal([]byte(s), v); err != nil || *v != value { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, *v) - } - trans.Reset() - } - trans.Close() -} - -func TestReadSimpleJSONProtocolString(t *testing.T) { - thetype := "string" - for _, value := range STRING_VALUES { - trans := NewTMemoryBuffer() - p := NewTSimpleJSONProtocol(trans) - trans.WriteString(jsonQuote(value)) - trans.Flush() - s := trans.String() - v, e := p.ReadString() - if e != nil { - t.Fatalf("Unable to read %s value %v due to error: %s", thetype, value, e.Error()) - } - if v != value { - t.Fatalf("Bad value for %s value %v, wrote: %v, received: %v", thetype, value, s, v) - } - v1 := new(string) - if err := json.Unmarshal([]byte(s), v1); err != nil || *v1 != value { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, *v1) - } - trans.Reset() - trans.Close() - } -} -func TestReadSimpleJSONProtocolStringNull(t *testing.T) { - thetype := "string" - value := "null" - - trans := NewTMemoryBuffer() - p := NewTSimpleJSONProtocol(trans) - trans.WriteString(value) - trans.Flush() - s := trans.String() - v, e := p.ReadString() - if e != nil { - t.Fatalf("Unable to read %s value %v due to error: %s", thetype, value, e.Error()) - } - if v != "" { - t.Fatalf("Bad value for %s value %v, wrote: %v, received: %v", thetype, value, s, v) - } - trans.Reset() - trans.Close() -} - -func TestWriteSimpleJSONProtocolBinary(t *testing.T) { - thetype := "binary" - value := protocol_bdata - b64value := make([]byte, base64.StdEncoding.EncodedLen(len(protocol_bdata))) - base64.StdEncoding.Encode(b64value, value) - b64String := string(b64value) - trans := NewTMemoryBuffer() - p := NewTSimpleJSONProtocol(trans) - if e := p.WriteBinary(value); e != nil { - t.Fatalf("Unable to write %s value %v due to error: %s", thetype, value, e.Error()) - } - if e := p.Flush(); e != nil { - t.Fatalf("Unable to write %s value %v due to error flushing: %s", thetype, value, e.Error()) - } - s := trans.String() - if s != fmt.Sprint("\"", b64String, "\"") { - t.Fatalf("Bad value for %s %v\n wrote: %v\nexpected: %v", thetype, value, s, "\""+b64String+"\"") - } - v1 := new(string) - if err := json.Unmarshal([]byte(s), v1); err != nil || *v1 != b64String { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, *v1) - } - trans.Close() -} - -func TestReadSimpleJSONProtocolBinary(t *testing.T) { - thetype := "binary" - value := protocol_bdata - b64value := make([]byte, base64.StdEncoding.EncodedLen(len(protocol_bdata))) - base64.StdEncoding.Encode(b64value, value) - b64String := string(b64value) - trans := NewTMemoryBuffer() - p := NewTSimpleJSONProtocol(trans) - trans.WriteString(jsonQuote(b64String)) - trans.Flush() - s := trans.String() - v, e := p.ReadBinary() - if e != nil { - t.Fatalf("Unable to read %s value %v due to error: %s", thetype, value, e.Error()) - } - if len(v) != len(value) { - t.Fatalf("Bad value for %s value length %v, wrote: %v, received length: %v", thetype, len(value), s, len(v)) - } - for i := 0; i < len(v); i++ { - if v[i] != value[i] { - t.Fatalf("Bad value for %s at index %d value %v, wrote: %v, received: %v", thetype, i, value[i], s, v[i]) - } - } - v1 := new(string) - if err := json.Unmarshal([]byte(s), v1); err != nil || *v1 != b64String { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, *v1) - } - trans.Reset() - trans.Close() -} - -func TestReadSimpleJSONProtocolBinaryNull(t *testing.T) { - thetype := "binary" - value := "null" - - trans := NewTMemoryBuffer() - p := NewTSimpleJSONProtocol(trans) - trans.WriteString(value) - trans.Flush() - s := trans.String() - b, e := p.ReadBinary() - v := string(b) - - if e != nil { - t.Fatalf("Unable to read %s value %v due to error: %s", thetype, value, e.Error()) - } - if v != "" { - t.Fatalf("Bad value for %s value %v, wrote: %v, received: %v", thetype, value, s, v) - } - trans.Reset() - trans.Close() -} - -func TestWriteSimpleJSONProtocolList(t *testing.T) { - thetype := "list" - trans := NewTMemoryBuffer() - p := NewTSimpleJSONProtocol(trans) - p.WriteListBegin(TType(DOUBLE), len(DOUBLE_VALUES)) - for _, value := range DOUBLE_VALUES { - if e := p.WriteDouble(value); e != nil { - t.Fatalf("Unable to write %s value %v due to error: %s", thetype, value, e.Error()) - } - } - p.WriteListEnd() - if e := p.Flush(); e != nil { - t.Fatalf("Unable to write %s due to error flushing: %s", thetype, e.Error()) - } - str := trans.String() - str1 := new([]interface{}) - err := json.Unmarshal([]byte(str), str1) - if err != nil { - t.Fatalf("Unable to decode %s, wrote: %s", thetype, str) - } - l := *str1 - if len(l) < 2 { - t.Fatalf("List must be at least of length two to include metadata") - } - if int(l[0].(float64)) != DOUBLE { - t.Fatal("Invalid type for list, expected: ", DOUBLE, ", but was: ", l[0]) - } - if int(l[1].(float64)) != len(DOUBLE_VALUES) { - t.Fatal("Invalid length for list, expected: ", len(DOUBLE_VALUES), ", but was: ", l[1]) - } - for k, value := range DOUBLE_VALUES { - s := l[k+2] - if math.IsInf(value, 1) { - if s.(string) != JSON_INFINITY { - t.Fatalf("Bad value for %s at index %v %v, wrote: %q, expected: %q, originally wrote: %q", thetype, k, value, s, jsonQuote(JSON_INFINITY), str) - } - } else if math.IsInf(value, 0) { - if s.(string) != JSON_NEGATIVE_INFINITY { - t.Fatalf("Bad value for %s at index %v %v, wrote: %q, expected: %q, originally wrote: %q", thetype, k, value, s, jsonQuote(JSON_NEGATIVE_INFINITY), str) - } - } else if math.IsNaN(value) { - if s.(string) != JSON_NAN { - t.Fatalf("Bad value for %s at index %v %v, wrote: %q, expected: %q, originally wrote: %q", thetype, k, value, s, jsonQuote(JSON_NAN), str) - } - } else { - if s.(float64) != value { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s'", thetype, value, s) - } - } - trans.Reset() - } - trans.Close() -} - -func TestWriteSimpleJSONProtocolSet(t *testing.T) { - thetype := "set" - trans := NewTMemoryBuffer() - p := NewTSimpleJSONProtocol(trans) - p.WriteSetBegin(TType(DOUBLE), len(DOUBLE_VALUES)) - for _, value := range DOUBLE_VALUES { - if e := p.WriteDouble(value); e != nil { - t.Fatalf("Unable to write %s value %v due to error: %s", thetype, value, e.Error()) - } - } - p.WriteSetEnd() - if e := p.Flush(); e != nil { - t.Fatalf("Unable to write %s due to error flushing: %s", thetype, e.Error()) - } - str := trans.String() - str1 := new([]interface{}) - err := json.Unmarshal([]byte(str), str1) - if err != nil { - t.Fatalf("Unable to decode %s, wrote: %s", thetype, str) - } - l := *str1 - if len(l) < 2 { - t.Fatalf("Set must be at least of length two to include metadata") - } - if int(l[0].(float64)) != DOUBLE { - t.Fatal("Invalid type for set, expected: ", DOUBLE, ", but was: ", l[0]) - } - if int(l[1].(float64)) != len(DOUBLE_VALUES) { - t.Fatal("Invalid length for set, expected: ", len(DOUBLE_VALUES), ", but was: ", l[1]) - } - for k, value := range DOUBLE_VALUES { - s := l[k+2] - if math.IsInf(value, 1) { - if s.(string) != JSON_INFINITY { - t.Fatalf("Bad value for %s at index %v %v, wrote: %q, expected: %q, originally wrote: %q", thetype, k, value, s, jsonQuote(JSON_INFINITY), str) - } - } else if math.IsInf(value, 0) { - if s.(string) != JSON_NEGATIVE_INFINITY { - t.Fatalf("Bad value for %s at index %v %v, wrote: %q, expected: %q, originally wrote: %q", thetype, k, value, s, jsonQuote(JSON_NEGATIVE_INFINITY), str) - } - } else if math.IsNaN(value) { - if s.(string) != JSON_NAN { - t.Fatalf("Bad value for %s at index %v %v, wrote: %q, expected: %q, originally wrote: %q", thetype, k, value, s, jsonQuote(JSON_NAN), str) - } - } else { - if s.(float64) != value { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s'", thetype, value, s) - } - } - trans.Reset() - } - trans.Close() -} - -func TestWriteSimpleJSONProtocolMap(t *testing.T) { - thetype := "map" - trans := NewTMemoryBuffer() - p := NewTSimpleJSONProtocol(trans) - p.WriteMapBegin(TType(I32), TType(DOUBLE), len(DOUBLE_VALUES)) - for k, value := range DOUBLE_VALUES { - if e := p.WriteI32(int32(k)); e != nil { - t.Fatalf("Unable to write %s key int32 value %v due to error: %s", thetype, k, e.Error()) - } - if e := p.WriteDouble(value); e != nil { - t.Fatalf("Unable to write %s value float64 value %v due to error: %s", thetype, value, e.Error()) - } - } - p.WriteMapEnd() - if e := p.Flush(); e != nil { - t.Fatalf("Unable to write %s due to error flushing: %s", thetype, e.Error()) - } - str := trans.String() - if str[0] != '[' || str[len(str)-1] != ']' { - t.Fatalf("Bad value for %s, wrote: %q, in go: %q", thetype, str, DOUBLE_VALUES) - } - l := strings.Split(str[1:len(str)-1], ",") - if len(l) < 3 { - t.Fatal("Expected list of at least length 3 for map for metadata, but was of length ", len(l)) - } - expectedKeyType, _ := strconv.Atoi(l[0]) - expectedValueType, _ := strconv.Atoi(l[1]) - expectedSize, _ := strconv.Atoi(l[2]) - if expectedKeyType != I32 { - t.Fatal("Expected map key type ", I32, ", but was ", l[0]) - } - if expectedValueType != DOUBLE { - t.Fatal("Expected map value type ", DOUBLE, ", but was ", l[1]) - } - if expectedSize != len(DOUBLE_VALUES) { - t.Fatal("Expected map size of ", len(DOUBLE_VALUES), ", but was ", l[2]) - } - for k, value := range DOUBLE_VALUES { - strk := l[k*2+3] - strv := l[k*2+4] - ik, err := strconv.Atoi(strk) - if err != nil { - t.Fatalf("Bad value for %s index %v, wrote: %v, expected: %v, error: %s", thetype, k, strk, string(k), err.Error()) - } - if ik != k { - t.Fatalf("Bad value for %s index %v, wrote: %v, expected: %v", thetype, k, strk, k) - } - s := strv - if math.IsInf(value, 1) { - if s != jsonQuote(JSON_INFINITY) { - t.Fatalf("Bad value for %s at index %v %v, wrote: %v, expected: %v", thetype, k, value, s, jsonQuote(JSON_INFINITY)) - } - } else if math.IsInf(value, 0) { - if s != jsonQuote(JSON_NEGATIVE_INFINITY) { - t.Fatalf("Bad value for %s at index %v %v, wrote: %v, expected: %v", thetype, k, value, s, jsonQuote(JSON_NEGATIVE_INFINITY)) - } - } else if math.IsNaN(value) { - if s != jsonQuote(JSON_NAN) { - t.Fatalf("Bad value for %s at index %v %v, wrote: %v, expected: %v", thetype, k, value, s, jsonQuote(JSON_NAN)) - } - } else { - expected := strconv.FormatFloat(value, 'g', 10, 64) - if s != expected { - t.Fatalf("Bad value for %s at index %v %v, wrote: %v, expected %v", thetype, k, value, s, expected) - } - v := float64(0) - if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) - } - } - trans.Reset() - } - trans.Close() -} diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/simple_server.go b/vendor/git.apache.org/thrift.git/lib/go/thrift/simple_server.go index bdf4428..6b3811e 100644 --- a/vendor/git.apache.org/thrift.git/lib/go/thrift/simple_server.go +++ b/vendor/git.apache.org/thrift.git/lib/go/thrift/simple_server.go @@ -27,7 +27,7 @@ import ( // Simple, non-concurrent server for testing. type TSimpleServer struct { - quit chan struct{} + quit chan struct{} stopped int64 processorFactory TProcessorFactory diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/socket.go b/vendor/git.apache.org/thrift.git/lib/go/thrift/socket.go index 383b1fe..82e28b4 100644 --- a/vendor/git.apache.org/thrift.git/lib/go/thrift/socket.go +++ b/vendor/git.apache.org/thrift.git/lib/go/thrift/socket.go @@ -161,5 +161,6 @@ func (p *TSocket) Interrupt() error { func (p *TSocket) RemainingBytes() (num_bytes uint64) { const maxSize = ^uint64(0) - return maxSize // the thruth is, we just don't know unless framed is used + return maxSize // the thruth is, we just don't know unless framed is used } + diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/ssl_server_socket.go b/vendor/git.apache.org/thrift.git/lib/go/thrift/ssl_server_socket.go index 0615528..58f859b 100644 --- a/vendor/git.apache.org/thrift.git/lib/go/thrift/ssl_server_socket.go +++ b/vendor/git.apache.org/thrift.git/lib/go/thrift/ssl_server_socket.go @@ -20,9 +20,9 @@ package thrift import ( - "crypto/tls" "net" "time" + "crypto/tls" ) type TSSLServerSocket struct { diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/ssl_socket.go b/vendor/git.apache.org/thrift.git/lib/go/thrift/ssl_socket.go index 86a68a3..04d3850 100644 --- a/vendor/git.apache.org/thrift.git/lib/go/thrift/ssl_socket.go +++ b/vendor/git.apache.org/thrift.git/lib/go/thrift/ssl_socket.go @@ -166,5 +166,6 @@ func (p *TSSLSocket) Interrupt() error { func (p *TSSLSocket) RemainingBytes() (num_bytes uint64) { const maxSize = ^uint64(0) - return maxSize // the thruth is, we just don't know unless framed is used + return maxSize // the thruth is, we just don't know unless framed is used } + diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/transport.go b/vendor/git.apache.org/thrift.git/lib/go/thrift/transport.go index 70a85a8..4538996 100644 --- a/vendor/git.apache.org/thrift.git/lib/go/thrift/transport.go +++ b/vendor/git.apache.org/thrift.git/lib/go/thrift/transport.go @@ -34,6 +34,7 @@ type ReadSizeProvider interface { RemainingBytes() (num_bytes uint64) } + // Encapsulates the I/O layer type TTransport interface { io.ReadWriteCloser @@ -51,6 +52,7 @@ type stringWriter interface { WriteString(s string) (n int, err error) } + // This is "enchanced" transport with extra capabilities. You need to use one of these // to construct protocol. // Notably, TSocket does not implement this interface, and it is always a mistake to use @@ -63,3 +65,4 @@ type TRichTransport interface { Flusher ReadSizeProvider } + diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/transport_exception_test.go b/vendor/git.apache.org/thrift.git/lib/go/thrift/transport_exception_test.go deleted file mode 100644 index b44314f..0000000 --- a/vendor/git.apache.org/thrift.git/lib/go/thrift/transport_exception_test.go +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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. - */ - -package thrift - -import ( - "fmt" - "io" - - "testing" -) - -type timeout struct{ timedout bool } - -func (t *timeout) Timeout() bool { - return t.timedout -} - -func (t *timeout) Error() string { - return fmt.Sprintf("Timeout: %v", t.timedout) -} - -func TestTExceptionTimeout(t *testing.T) { - timeout := &timeout{true} - exception := NewTTransportExceptionFromError(timeout) - if timeout.Error() != exception.Error() { - t.Fatalf("Error did not match: expected %q, got %q", timeout.Error(), exception.Error()) - } - - if exception.TypeId() != TIMED_OUT { - t.Fatalf("TypeId was not TIMED_OUT: expected %v, got %v", TIMED_OUT, exception.TypeId()) - } -} - -func TestTExceptionEOF(t *testing.T) { - exception := NewTTransportExceptionFromError(io.EOF) - if io.EOF.Error() != exception.Error() { - t.Fatalf("Error did not match: expected %q, got %q", io.EOF.Error(), exception.Error()) - } - - if exception.TypeId() != END_OF_FILE { - t.Fatalf("TypeId was not END_OF_FILE: expected %v, got %v", END_OF_FILE, exception.TypeId()) - } -} diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/transport_test.go b/vendor/git.apache.org/thrift.git/lib/go/thrift/transport_test.go deleted file mode 100644 index 864958a..0000000 --- a/vendor/git.apache.org/thrift.git/lib/go/thrift/transport_test.go +++ /dev/null @@ -1,176 +0,0 @@ -/* - * 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. - */ - -package thrift - -import ( - "io" - "net" - "strconv" - "testing" -) - -const TRANSPORT_BINARY_DATA_SIZE = 4096 - -var ( - transport_bdata []byte // test data for writing; same as data - transport_header map[string]string -) - -func init() { - transport_bdata = make([]byte, TRANSPORT_BINARY_DATA_SIZE) - for i := 0; i < TRANSPORT_BINARY_DATA_SIZE; i++ { - transport_bdata[i] = byte((i + 'a') % 255) - } - transport_header = map[string]string{"key": "User-Agent", - "value": "Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1667.0 Safari/537.36"} -} - -func TransportTest(t *testing.T, writeTrans TTransport, readTrans TTransport) { - buf := make([]byte, TRANSPORT_BINARY_DATA_SIZE) - if !writeTrans.IsOpen() { - t.Fatalf("Transport %T not open: %s", writeTrans, writeTrans) - } - if !readTrans.IsOpen() { - t.Fatalf("Transport %T not open: %s", readTrans, readTrans) - } - _, err := writeTrans.Write(transport_bdata) - if err != nil { - t.Fatalf("Transport %T cannot write binary data of length %d: %s", writeTrans, len(transport_bdata), err) - } - err = writeTrans.Flush() - if err != nil { - t.Fatalf("Transport %T cannot flush write of binary data: %s", writeTrans, err) - } - n, err := io.ReadFull(readTrans, buf) - if err != nil { - t.Errorf("Transport %T cannot read binary data of length %d: %s", readTrans, TRANSPORT_BINARY_DATA_SIZE, err) - } - if n != TRANSPORT_BINARY_DATA_SIZE { - t.Errorf("Transport %T read only %d instead of %d bytes of binary data", readTrans, n, TRANSPORT_BINARY_DATA_SIZE) - } - for k, v := range buf { - if v != transport_bdata[k] { - t.Fatalf("Transport %T read %d instead of %d for index %d of binary data 2", readTrans, v, transport_bdata[k], k) - } - } - _, err = writeTrans.Write(transport_bdata) - if err != nil { - t.Fatalf("Transport %T cannot write binary data 2 of length %d: %s", writeTrans, len(transport_bdata), err) - } - err = writeTrans.Flush() - if err != nil { - t.Fatalf("Transport %T cannot flush write binary data 2: %s", writeTrans, err) - } - buf = make([]byte, TRANSPORT_BINARY_DATA_SIZE) - read := 1 - for n = 0; n < TRANSPORT_BINARY_DATA_SIZE && read != 0; { - read, err = readTrans.Read(buf[n:]) - if err != nil { - t.Errorf("Transport %T cannot read binary data 2 of total length %d from offset %d: %s", readTrans, TRANSPORT_BINARY_DATA_SIZE, n, err) - } - n += read - } - if n != TRANSPORT_BINARY_DATA_SIZE { - t.Errorf("Transport %T read only %d instead of %d bytes of binary data 2", readTrans, n, TRANSPORT_BINARY_DATA_SIZE) - } - for k, v := range buf { - if v != transport_bdata[k] { - t.Fatalf("Transport %T read %d instead of %d for index %d of binary data 2", readTrans, v, transport_bdata[k], k) - } - } -} - -func TransportHeaderTest(t *testing.T, writeTrans TTransport, readTrans TTransport) { - buf := make([]byte, TRANSPORT_BINARY_DATA_SIZE) - if !writeTrans.IsOpen() { - t.Fatalf("Transport %T not open: %s", writeTrans, writeTrans) - } - if !readTrans.IsOpen() { - t.Fatalf("Transport %T not open: %s", readTrans, readTrans) - } - // Need to assert type of TTransport to THttpClient to expose the Setter - httpWPostTrans := writeTrans.(*THttpClient) - httpWPostTrans.SetHeader(transport_header["key"], transport_header["value"]) - - _, err := writeTrans.Write(transport_bdata) - if err != nil { - t.Fatalf("Transport %T cannot write binary data of length %d: %s", writeTrans, len(transport_bdata), err) - } - err = writeTrans.Flush() - if err != nil { - t.Fatalf("Transport %T cannot flush write of binary data: %s", writeTrans, err) - } - // Need to assert type of TTransport to THttpClient to expose the Getter - httpRPostTrans := readTrans.(*THttpClient) - readHeader := httpRPostTrans.GetHeader(transport_header["key"]) - if err != nil { - t.Errorf("Transport %T cannot read HTTP Header Value", httpRPostTrans) - } - - if transport_header["value"] != readHeader { - t.Errorf("Expected HTTP Header Value %s, got %s", transport_header["value"], readHeader) - } - n, err := io.ReadFull(readTrans, buf) - if err != nil { - t.Errorf("Transport %T cannot read binary data of length %d: %s", readTrans, TRANSPORT_BINARY_DATA_SIZE, err) - } - if n != TRANSPORT_BINARY_DATA_SIZE { - t.Errorf("Transport %T read only %d instead of %d bytes of binary data", readTrans, n, TRANSPORT_BINARY_DATA_SIZE) - } - for k, v := range buf { - if v != transport_bdata[k] { - t.Fatalf("Transport %T read %d instead of %d for index %d of binary data 2", readTrans, v, transport_bdata[k], k) - } - } -} - -func CloseTransports(t *testing.T, readTrans TTransport, writeTrans TTransport) { - err := readTrans.Close() - if err != nil { - t.Errorf("Transport %T cannot close read transport: %s", readTrans, err) - } - if writeTrans != readTrans { - err = writeTrans.Close() - if err != nil { - t.Errorf("Transport %T cannot close write transport: %s", writeTrans, err) - } - } -} - -func FindAvailableTCPServerPort(startPort int) (net.Addr, error) { - for i := startPort; i < 65535; i++ { - s := "127.0.0.1:" + strconv.Itoa(i) - l, err := net.Listen("tcp", s) - if err == nil { - l.Close() - return net.ResolveTCPAddr("tcp", s) - } - } - return nil, NewTTransportException(UNKNOWN_TRANSPORT_EXCEPTION, "Could not find available server port") -} - -func valueInSlice(value string, slice []string) bool { - for _, v := range slice { - if value == v { - return true - } - } - return false -} diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/zlib_transport_test.go b/vendor/git.apache.org/thrift.git/lib/go/thrift/zlib_transport_test.go deleted file mode 100644 index f57610c..0000000 --- a/vendor/git.apache.org/thrift.git/lib/go/thrift/zlib_transport_test.go +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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. - */ - -package thrift - -import ( - "compress/zlib" - "testing" -) - -func TestZlibTransport(t *testing.T) { - trans, err := NewTZlibTransport(NewTMemoryBuffer(), zlib.BestCompression) - if err != nil { - t.Fatal(err) - } - TransportTest(t, trans, trans) -} diff --git a/vendor/vendor.json b/vendor/vendor.json index cab93cd..f8edbfe 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -4,10 +4,9 @@ "package": [ { "checksumSHA1": "hcwvwW3c+NPM+g4nyv1prqgNrC4=", - "origin": "github.com/rdelval/gorealis/vendor/git.apache.org/thrift.git/lib/go/thrift", "path": "git.apache.org/thrift.git/lib/go/thrift", - "revision": "bcad91771b7f0bff28a1cac1981d7ef2b9bcef3c", - "revisionTime": "2016-07-24T10:11:25Z" + "revision": "2007783e874d524a46b818598a45078448ecc53e", + "revisionTime": "2016-08-09T19:04:53Z" }, { "checksumSHA1": "GcaTbmmzSGqTb2X6qnNtmDyew1Q=",