avro 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,192 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one
2
+ # or more contributor license agreements. See the NOTICE file
3
+ # distributed with this work for additional information
4
+ # regarding copyright ownership. The ASF licenses this file
5
+ # to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance
7
+ # with the License. You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ require 'test_help'
18
+
19
+ class TestProtocol < Test::Unit::TestCase
20
+
21
+ class ExampleProtocol
22
+ attr_reader :protocol_string, :valid, :name
23
+ attr_accessor :comment
24
+ def initialize(protocol_string, name=nil, comment='')
25
+ @protocol_string = protocol_string
26
+ @name = name || protocol_string # default to schema_string for name
27
+ @comment = comment
28
+ end
29
+ end
30
+ #
31
+ # Example Protocols
32
+ #
33
+
34
+ EXAMPLES = [
35
+ ExampleProtocol.new(<<-EOS, true),
36
+ {
37
+ "namespace": "com.acme",
38
+ "protocol": "HelloWorld",
39
+
40
+ "types": [
41
+ {"name": "Greeting", "type": "record", "fields": [
42
+ {"name": "message", "type": "string"}]},
43
+ {"name": "Curse", "type": "error", "fields": [
44
+ {"name": "message", "type": "string"}]}
45
+ ],
46
+
47
+ "messages": {
48
+ "hello": {
49
+ "request": [{"name": "greeting", "type": "Greeting" }],
50
+ "response": "Greeting",
51
+ "errors": ["Curse"]
52
+ }
53
+ }
54
+ }
55
+ EOS
56
+
57
+ ExampleProtocol.new(<<-EOS, true),
58
+ {"namespace": "org.apache.avro.test",
59
+ "protocol": "Simple",
60
+
61
+ "types": [
62
+ {"name": "Kind", "type": "enum", "symbols": ["FOO","BAR","BAZ"]},
63
+
64
+ {"name": "MD5", "type": "fixed", "size": 16},
65
+
66
+ {"name": "TestRecord", "type": "record",
67
+ "fields": [
68
+ {"name": "name", "type": "string", "order": "ignore"},
69
+ {"name": "kind", "type": "Kind", "order": "descending"},
70
+ {"name": "hash", "type": "MD5"}
71
+ ]
72
+ },
73
+
74
+ {"name": "TestError", "type": "error", "fields": [
75
+ {"name": "message", "type": "string"}
76
+ ]
77
+ }
78
+
79
+ ],
80
+
81
+ "messages": {
82
+
83
+ "hello": {
84
+ "request": [{"name": "greeting", "type": "string"}],
85
+ "response": "string"
86
+ },
87
+
88
+ "echo": {
89
+ "request": [{"name": "record", "type": "TestRecord"}],
90
+ "response": "TestRecord"
91
+ },
92
+
93
+ "add": {
94
+ "request": [{"name": "arg1", "type": "int"}, {"name": "arg2", "type": "int"}],
95
+ "response": "int"
96
+ },
97
+
98
+ "echoBytes": {
99
+ "request": [{"name": "data", "type": "bytes"}],
100
+ "response": "bytes"
101
+ },
102
+
103
+ "error": {
104
+ "request": [],
105
+ "response": "null",
106
+ "errors": ["TestError"]
107
+ }
108
+ }
109
+
110
+ }
111
+ EOS
112
+ ExampleProtocol.new(<<-EOS, true),
113
+ {"namespace": "org.apache.avro.test.namespace",
114
+ "protocol": "TestNamespace",
115
+
116
+ "types": [
117
+ {"name": "org.apache.avro.test.util.MD5", "type": "fixed", "size": 16},
118
+ {"name": "TestRecord", "type": "record",
119
+ "fields": [ {"name": "hash", "type": "org.apache.avro.test.util.MD5"} ]
120
+ },
121
+ {"name": "TestError", "namespace": "org.apache.avro.test.errors",
122
+ "type": "error", "fields": [ {"name": "message", "type": "string"} ]
123
+ }
124
+ ],
125
+
126
+ "messages": {
127
+ "echo": {
128
+ "request": [{"name": "record", "type": "TestRecord"}],
129
+ "response": "TestRecord"
130
+ },
131
+
132
+ "error": {
133
+ "request": [],
134
+ "response": "null",
135
+ "errors": ["org.apache.avro.test.errors.TestError"]
136
+ }
137
+
138
+ }
139
+
140
+ }
141
+ EOS
142
+ ExampleProtocol.new(<<-EOS, true)
143
+ {"namespace": "org.apache.avro.test",
144
+ "protocol": "BulkData",
145
+
146
+ "types": [],
147
+
148
+ "messages": {
149
+
150
+ "read": {
151
+ "request": [],
152
+ "response": "bytes"
153
+ },
154
+
155
+ "write": {
156
+ "request": [ {"name": "data", "type": "bytes"} ],
157
+ "response": "null"
158
+ }
159
+
160
+ }
161
+
162
+ }
163
+ EOS
164
+ ]
165
+
166
+ Protocol = Avro::Protocol
167
+ def test_parse
168
+ EXAMPLES.each do |example|
169
+ assert_nothing_raised("should be valid: #{example.protocol_string}") {
170
+ Protocol.parse(example.protocol_string)
171
+ }
172
+ end
173
+ end
174
+
175
+ def test_valid_cast_to_string_after_parse
176
+ EXAMPLES.each do |example|
177
+ assert_nothing_raised("round tripped okay #{example.protocol_string}") {
178
+ foo = Protocol.parse(example.protocol_string).to_s
179
+ Protocol.parse(foo)
180
+ }
181
+ end
182
+ end
183
+
184
+ def test_equivalence_after_round_trip
185
+ EXAMPLES.each do |example|
186
+ original = Protocol.parse(example.protocol_string)
187
+ round_trip = Protocol.parse(original.to_s)
188
+
189
+ assert_equal original, round_trip
190
+ end
191
+ end
192
+ end
Binary file
metadata ADDED
@@ -0,0 +1,94 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: avro
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.3.0
5
+ platform: ruby
6
+ authors:
7
+ - Apache Software Foundation
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2010-03-01 00:00:00 -08:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: yajl-ruby
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
25
+ description: Apache is a data serialization and RPC format
26
+ email: avro-dev@hadoop.apache.org
27
+ executables: []
28
+
29
+ extensions: []
30
+
31
+ extra_rdoc_files:
32
+ - CHANGELOG
33
+ - lib/avro.rb
34
+ - lib/avro/collect_hash.rb
35
+ - lib/avro/data_file.rb
36
+ - lib/avro/io.rb
37
+ - lib/avro/ipc.rb
38
+ - lib/avro/protocol.rb
39
+ - lib/avro/schema.rb
40
+ files:
41
+ - CHANGELOG
42
+ - Manifest
43
+ - Rakefile
44
+ - avro.gemspec
45
+ - interop/test_interop.rb
46
+ - lib/avro.rb
47
+ - lib/avro/collect_hash.rb
48
+ - lib/avro/data_file.rb
49
+ - lib/avro/io.rb
50
+ - lib/avro/ipc.rb
51
+ - lib/avro/protocol.rb
52
+ - lib/avro/schema.rb
53
+ - test/random_data.rb
54
+ - test/sample_ipc_client.rb
55
+ - test/sample_ipc_server.rb
56
+ - test/test_help.rb
57
+ - test/test_io.rb
58
+ - test/test_protocol.rb
59
+ - tmp/test.rb.avro
60
+ has_rdoc: true
61
+ homepage: http://hadoop.apache.org/avro/
62
+ licenses: []
63
+
64
+ post_install_message:
65
+ rdoc_options:
66
+ - --line-numbers
67
+ - --inline-source
68
+ - --title
69
+ - Avro
70
+ require_paths:
71
+ - lib
72
+ required_ruby_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: "0"
77
+ version:
78
+ required_rubygems_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: "1.2"
83
+ version:
84
+ requirements: []
85
+
86
+ rubyforge_project: avro
87
+ rubygems_version: 1.3.5
88
+ signing_key:
89
+ specification_version: 3
90
+ summary: Apache Avro for Ruby
91
+ test_files:
92
+ - test/test_help.rb
93
+ - test/test_io.rb
94
+ - test/test_protocol.rb