Rev 30 | Blame | Compare with Previous | Last modification | View Log | RSS feed
## 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.#require 'thrift'module Fixturesmodule Structsclass OneBoolinclude Thrift::Structattr_accessor :boolFIELDS = {1 => {:type => Thrift::Types::BOOL, :name => 'bool'}}def validateendendclass OneByteinclude Thrift::Structattr_accessor :byteFIELDS = {1 => {:type => Thrift::Types::BYTE, :name => 'byte'}}def validateendendclass OneI16include Thrift::Structattr_accessor :i16FIELDS = {1 => {:type => Thrift::Types::I16, :name => 'i16'}}def validateendendclass OneI32include Thrift::Structattr_accessor :i32FIELDS = {1 => {:type => Thrift::Types::I32, :name => 'i32'}}def validateendendclass OneI64include Thrift::Structattr_accessor :i64FIELDS = {1 => {:type => Thrift::Types::I64, :name => 'i64'}}def validateendendclass OneDoubleinclude Thrift::Structattr_accessor :doubleFIELDS = {1 => {:type => Thrift::Types::DOUBLE, :name => 'double'}}def validateendendclass OneStringinclude Thrift::Structattr_accessor :stringFIELDS = {1 => {:type => Thrift::Types::STRING, :name => 'string'}}def validateendendclass OneMapinclude Thrift::Structattr_accessor :mapFIELDS = {1 => {:type => Thrift::Types::MAP, :name => 'map', :key => {:type => Thrift::Types::STRING}, :value => {:type => Thrift::Types::STRING}}}def validateendendclass NestedMapinclude Thrift::Structattr_accessor :mapFIELDS = {0 => {:type => Thrift::Types::MAP, :name => 'map', :key => {:type => Thrift::Types::I32}, :value => {:type => Thrift::Types::MAP, :key => {:type => Thrift::Types::I32}, :value => {:type => Thrift::Types::I32}}}}def validateendendclass OneListinclude Thrift::Structattr_accessor :listFIELDS = {1 => {:type => Thrift::Types::LIST, :name => 'list', :element => {:type => Thrift::Types::STRING}}}def validateendendclass NestedListinclude Thrift::Structattr_accessor :listFIELDS = {0 => {:type => Thrift::Types::LIST, :name => 'list', :element => {:type => Thrift::Types::LIST, :element => { :type => Thrift::Types::I32 } } }}def validateendendclass OneSetinclude Thrift::Structattr_accessor :setFIELDS = {1 => {:type => Thrift::Types::SET, :name => 'set', :element => {:type => Thrift::Types::STRING}}}def validateendendclass NestedSetinclude Thrift::Structattr_accessor :setFIELDS = {1 => {:type => Thrift::Types::SET, :name => 'set', :element => {:type => Thrift::Types::SET, :element => { :type => Thrift::Types::STRING } }}}def validateendend# struct OneOfEach {# 1: bool im_true,# 2: bool im_false,# 3: byte a_bite,# 4: i16 integer16,# 5: i32 integer32,# 6: i64 integer64,# 7: double double_precision,# 8: string some_characters,# 9: string zomg_unicode,# 10: bool what_who,# 11: binary base64,# }class OneOfEachinclude Thrift::Structattr_accessor :im_true, :im_false, :a_bite, :integer16, :integer32, :integer64, :double_precision, :some_characters, :zomg_unicode, :what_who, :base64FIELDS = {1 => {:type => Thrift::Types::BOOL, :name => 'im_true'},2 => {:type => Thrift::Types::BOOL, :name => 'im_false'},3 => {:type => Thrift::Types::BYTE, :name => 'a_bite'},4 => {:type => Thrift::Types::I16, :name => 'integer16'},5 => {:type => Thrift::Types::I32, :name => 'integer32'},6 => {:type => Thrift::Types::I64, :name => 'integer64'},7 => {:type => Thrift::Types::DOUBLE, :name => 'double_precision'},8 => {:type => Thrift::Types::STRING, :name => 'some_characters'},9 => {:type => Thrift::Types::STRING, :name => 'zomg_unicode'},10 => {:type => Thrift::Types::BOOL, :name => 'what_who'},11 => {:type => Thrift::Types::STRING, :name => 'base64'}}# Added for assert_equaldef ==(other)[:im_true, :im_false, :a_bite, :integer16, :integer32, :integer64, :double_precision, :some_characters, :zomg_unicode, :what_who, :base64].each do |f|var = "@#{f}"return false if instance_variable_get(var) != other.instance_variable_get(var)endtrueenddef validateendend# struct Nested1 {# 1: list<OneOfEach> a_list# 2: map<i32, OneOfEach> i32_map# 3: map<i64, OneOfEach> i64_map# 4: map<double, OneOfEach> dbl_map# 5: map<string, OneOfEach> str_map# }class Nested1include Thrift::Structattr_accessor :a_list, :i32_map, :i64_map, :dbl_map, :str_mapFIELDS = {1 => {:type => Thrift::Types::LIST, :name => 'a_list', :element => {:type => Thrift::Types::STRUCT, :class => OneOfEach}},2 => {:type => Thrift::Types::MAP, :name => 'i32_map', :key => {:type => Thrift::Types::I32}, :value => {:type => Thrift::Types::STRUCT, :class => OneOfEach}},3 => {:type => Thrift::Types::MAP, :name => 'i64_map', :key => {:type => Thrift::Types::I64}, :value => {:type => Thrift::Types::STRUCT, :class => OneOfEach}},4 => {:type => Thrift::Types::MAP, :name => 'dbl_map', :key => {:type => Thrift::Types::DOUBLE}, :value => {:type => Thrift::Types::STRUCT, :class => OneOfEach}},5 => {:type => Thrift::Types::MAP, :name => 'str_map', :key => {:type => Thrift::Types::STRING}, :value => {:type => Thrift::Types::STRUCT, :class => OneOfEach}}}def validateendend# struct Nested2 {# 1: list<Nested1> a_list# 2: map<i32, Nested1> i32_map# 3: map<i64, Nested1> i64_map# 4: map<double, Nested1> dbl_map# 5: map<string, Nested1> str_map# }class Nested2include Thrift::Structattr_accessor :a_list, :i32_map, :i64_map, :dbl_map, :str_mapFIELDS = {1 => {:type => Thrift::Types::LIST, :name => 'a_list', :element => {:type => Thrift::Types::STRUCT, :class => Nested1}},2 => {:type => Thrift::Types::MAP, :name => 'i32_map', :key => {:type => Thrift::Types::I32}, :value => {:type => Thrift::Types::STRUCT, :class => Nested1}},3 => {:type => Thrift::Types::MAP, :name => 'i64_map', :key => {:type => Thrift::Types::I64}, :value => {:type => Thrift::Types::STRUCT, :class => Nested1}},4 => {:type => Thrift::Types::MAP, :name => 'dbl_map', :key => {:type => Thrift::Types::DOUBLE}, :value => {:type => Thrift::Types::STRUCT, :class => Nested1}},5 => {:type => Thrift::Types::MAP, :name => 'str_map', :key => {:type => Thrift::Types::STRING}, :value => {:type => Thrift::Types::STRUCT, :class => Nested1}}}def validateendend# struct Nested3 {# 1: list<Nested2> a_list# 2: map<i32, Nested2> i32_map# 3: map<i64, Nested2> i64_map# 4: map<double, Nested2> dbl_map# 5: map<string, Nested2> str_map# }class Nested3include Thrift::Structattr_accessor :a_list, :i32_map, :i64_map, :dbl_map, :str_mapFIELDS = {1 => {:type => Thrift::Types::LIST, :name => 'a_list', :element => {:type => Thrift::Types::STRUCT, :class => Nested2}},2 => {:type => Thrift::Types::MAP, :name => 'i32_map', :key => {:type => Thrift::Types::I32}, :value => {:type => Thrift::Types::STRUCT, :class => Nested2}},3 => {:type => Thrift::Types::MAP, :name => 'i64_map', :key => {:type => Thrift::Types::I64}, :value => {:type => Thrift::Types::STRUCT, :class => Nested2}},4 => {:type => Thrift::Types::MAP, :name => 'dbl_map', :key => {:type => Thrift::Types::DOUBLE}, :value => {:type => Thrift::Types::STRUCT, :class => Nested2}},5 => {:type => Thrift::Types::MAP, :name => 'str_map', :key => {:type => Thrift::Types::STRING}, :value => {:type => Thrift::Types::STRUCT, :class => Nested2}}}def validateendend# struct Nested4 {# 1: list<Nested3> a_list# 2: map<i32, Nested3> i32_map# 3: map<i64, Nested3> i64_map# 4: map<double, Nested3> dbl_map# 5: map<string, Nested3> str_map# }class Nested4include Thrift::Structattr_accessor :a_list, :i32_map, :i64_map, :dbl_map, :str_mapFIELDS = {1 => {:type => Thrift::Types::LIST, :name => 'a_list', :element => {:type => Thrift::Types::STRUCT, :class => Nested3}},2 => {:type => Thrift::Types::MAP, :name => 'i32_map', :key => {:type => Thrift::Types::I32}, :value => {:type => Thrift::Types::STRUCT, :class => Nested3}},3 => {:type => Thrift::Types::MAP, :name => 'i64_map', :key => {:type => Thrift::Types::I64}, :value => {:type => Thrift::Types::STRUCT, :class => Nested3}},4 => {:type => Thrift::Types::MAP, :name => 'dbl_map', :key => {:type => Thrift::Types::DOUBLE}, :value => {:type => Thrift::Types::STRUCT, :class => Nested3}},5 => {:type => Thrift::Types::MAP, :name => 'str_map', :key => {:type => Thrift::Types::STRING}, :value => {:type => Thrift::Types::STRUCT, :class => Nested3}}}def validateendendendend