test/test_protocol.rb in avro-1.8.2 vs test/test_protocol.rb in avro-1.9.0

- old
+ new

@@ -3,13 +3,13 @@ # 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. @@ -137,11 +137,11 @@ } } EOS - ExampleProtocol.new(<<-EOS, true) + ExampleProtocol.new(<<-EOS, true), {"namespace": "org.apache.avro.test", "protocol": "BulkData", "types": [], @@ -159,10 +159,33 @@ } } EOS + ExampleProtocol.new(<<-EOS, true), +{ + "namespace": "com.acme", + "protocol": "HelloWorld", + "doc": "protocol_documentation", + + "types": [ + {"name": "Greeting", "type": "record", "fields": [ + {"name": "message", "type": "string"}]}, + {"name": "Curse", "type": "error", "fields": [ + {"name": "message", "type": "string"}]} + ], + + "messages": { + "hello": { + "doc": "message_documentation", + "request": [{"name": "greeting", "type": "Greeting" }], + "response": "Greeting", + "errors": ["Curse"] + } + } +} +EOS ] Protocol = Avro::Protocol def test_parse EXAMPLES.each do |example| @@ -193,7 +216,17 @@ def test_namespaces protocol = Protocol.parse(EXAMPLES.first.protocol_string) protocol.types.each do |type| assert_equal type.namespace, 'com.acme' end + end + + def test_protocol_doc_attribute + original = Protocol.parse(EXAMPLES.last.protocol_string) + assert_equal 'protocol_documentation', original.doc + end + + def test_protocol_message_doc_attribute + original = Protocol.parse(EXAMPLES.last.protocol_string) + assert_equal 'message_documentation', original.messages['hello'].doc end end