]> git.proxmox.com Git - ceph.git/blame - ceph/src/jaegertracing/thrift/test/rb/core/transport/test_transport.rb
buildsys: switch source download to quincy
[ceph.git] / ceph / src / jaegertracing / thrift / test / rb / core / transport / test_transport.rb
CommitLineData
f67539c2
TL
1#
2# Licensed to the Apache Software Foundation (ASF) under one
3# or more contributor license agreements. See the NOTICE file
4# distributed with this work for additional information
5# regarding copyright ownership. The ASF licenses this file
6# to you under the Apache License, Version 2.0 (the
7# "License"); you may not use this file except in compliance
8# with the License. You may obtain a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing,
13# software distributed under the License is distributed on an
14# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15# KIND, either express or implied. See the License for the
16# specific language governing permissions and limitations
17# under the License.
18#
19
20require File.join(File.dirname(__FILE__), '../../test_helper')
21
22require 'thrift'
23
24class DummyTransport < Thrift::BaseTransport
25 def initialize(data)
26 @data = data
27 end
28
29 def read(size)
30 @data.slice!(0, size)
31 end
32end
33
34# TTransport is basically an abstract class, but isn't raising NotImplementedError
35class TestThriftTransport < Test::Unit::TestCase
36 def setup
37 @trans = Thrift::BaseTransport.new
38 end
39
40 def test_open?
41 assert_nil @trans.open?
42 end
43
44 def test_open
45 assert_nil @trans.open
46 end
47
48 def test_close
49 assert_nil @trans.close
50 end
51
52 # TODO:
53 # This doesn't necessarily test he right thing.
54 # It _looks_ like read isn't guaranteed to return the length
55 # you ask for and read_all is. This means our test needs to check
56 # for blocking. -- Kevin Clark 3/27/08
57 def test_read_all
58 # Implements read
59 t = DummyTransport.new("hello")
60 assert_equal "hello", t.read_all(5)
61 end
62
63 def test_write
64 assert_nil @trans.write(5) # arbitrary value
65 end
66
67 def test_flush
68 assert_nil @trans.flush
69 end
70end