omf_common 6.0.0.pre.10 → 6.0.0.pre.11

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.
Files changed (41) hide show
  1. data/bin/monitor_topic.rb +80 -0
  2. data/bin/send_create.rb +94 -0
  3. data/bin/send_request.rb +58 -0
  4. data/example/engine_alt.rb +136 -0
  5. data/example/vm_alt.rb +65 -0
  6. data/lib/omf_common.rb +224 -3
  7. data/lib/omf_common/comm.rb +113 -46
  8. data/lib/omf_common/comm/amqp/amqp_communicator.rb +76 -0
  9. data/lib/omf_common/comm/amqp/amqp_topic.rb +91 -0
  10. data/lib/omf_common/comm/local/local_communicator.rb +64 -0
  11. data/lib/omf_common/comm/local/local_topic.rb +42 -0
  12. data/lib/omf_common/comm/topic.rb +190 -0
  13. data/lib/omf_common/{dsl/xmpp.rb → comm/xmpp/communicator.rb} +93 -53
  14. data/lib/omf_common/comm/xmpp/topic.rb +147 -0
  15. data/lib/omf_common/{dsl → comm/xmpp}/xmpp_mp.rb +2 -0
  16. data/lib/omf_common/eventloop.rb +94 -0
  17. data/lib/omf_common/eventloop/em.rb +57 -0
  18. data/lib/omf_common/eventloop/local_evl.rb +78 -0
  19. data/lib/omf_common/message.rb +112 -229
  20. data/lib/omf_common/message/json/json_message.rb +129 -0
  21. data/lib/omf_common/message/xml/message.rb +410 -0
  22. data/lib/omf_common/message/xml/relaxng_schema.rb +17 -0
  23. data/lib/omf_common/message/xml/topic_message.rb +20 -0
  24. data/lib/omf_common/protocol/6.0.rnc +11 -21
  25. data/lib/omf_common/protocol/6.0.rng +52 -119
  26. data/lib/omf_common/version.rb +1 -1
  27. data/omf_common.gemspec +4 -2
  28. data/test/fixture/pubsub.rb +19 -19
  29. data/test/omf_common/{dsl/xmpp_spec.rb → comm/xmpp/communicator_spec.rb} +47 -111
  30. data/test/omf_common/comm/xmpp/topic_spec.rb +113 -0
  31. data/test/omf_common/comm_spec.rb +1 -0
  32. data/test/omf_common/message/xml/message_spec.rb +136 -0
  33. data/test/omf_common/message_spec.rb +37 -131
  34. data/test/test_helper.rb +4 -1
  35. metadata +38 -28
  36. data/lib/omf_common/core_ext/object.rb +0 -21
  37. data/lib/omf_common/relaxng_schema.rb +0 -17
  38. data/lib/omf_common/topic.rb +0 -34
  39. data/lib/omf_common/topic_message.rb +0 -20
  40. data/test/omf_common/topic_message_spec.rb +0 -114
  41. data/test/omf_common/topic_spec.rb +0 -75
@@ -0,0 +1,17 @@
1
+ require 'singleton'
2
+
3
+ module OmfCommon
4
+ class RelaxNGSchema
5
+ include Singleton
6
+
7
+ SCHEMA_FILE = "#{File.dirname(__FILE__)}/../../protocol/#{OmfCommon::PROTOCOL_VERSION}.rng"
8
+
9
+ def initialize
10
+ @rng = File.read(SCHEMA_FILE)
11
+ end
12
+
13
+ def validate(document)
14
+ Nokogiri::XML::RelaxNG(@rng).validate(document)
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,20 @@
1
+ # module OmfCommon
2
+ # class TopicMessage
3
+ # attr_accessor :body, :comm
4
+ #
5
+ # def initialize(body, comm)
6
+ # self.body ||= body
7
+ # self.comm ||= comm
8
+ # end
9
+ #
10
+ # def publish(topic_id, &block)
11
+ # comm.publish(topic_id, body.dup, &block)
12
+ # end
13
+ #
14
+ # %w(created status failed released).each do |itype|
15
+ # define_method("on_inform_#{itype}") do |*args, &message_block|
16
+ # comm.send("on_#{itype}_message", body, &message_block)
17
+ # end
18
+ # end
19
+ # end
20
+ # end
@@ -2,47 +2,37 @@ default namespace = "http://schema.mytestbed.net/omf/6.0/protocol"
2
2
 
3
3
  start = (create | configure | request | release | inform)
4
4
 
5
- common_elements = attribute msg_id { text }, attribute timestamp { text }, attribute digest { text }, attribute signature { text }?
5
+ common_elements = attribute mid { text }?
6
+ & element ts { text }
7
+ & element src { text }?
8
+ & element replyto { text }?
9
+ & element props { property * }?
10
+ & element guard { property * }?
6
11
 
7
12
  anything = ( text | element * { (attribute type { text })?, (text | anything) * })
8
13
 
9
- prop_content = attribute key { text }, (attribute type { text })?, anything *
14
+ property = element * { (attribute type { text })?, anything * }
10
15
 
11
16
  create = element create {
12
17
  common_elements
13
- & element publish_to { text }?
14
- & element guard { element property { prop_content } * }?
15
- & element property { prop_content } *
18
+ & element rtype { text }
16
19
  }
17
20
 
18
21
  configure = element configure {
19
22
  common_elements
20
- & element publish_to { text }?
21
- & element guard { element property { prop_content } * }?
22
- & element property { prop_content } *
23
23
  }
24
24
 
25
25
  request = element request {
26
26
  common_elements
27
- & element publish_to { text }?
28
- & element guard { element property { prop_content } * }?
29
- & element property { prop_content } *
30
27
  }
31
28
 
32
29
  release = element release {
33
30
  common_elements
34
- & element publish_to { text }?
35
- & element resource_id { text }
36
- & element guard { element property { prop_content } * }?
37
- & element property { prop_content } *
31
+ & element res_id { text }?
38
32
  }
39
33
 
40
34
  inform = element inform {
41
35
  common_elements
42
- & element context_id { text }?
43
- & element inform_type { "CREATED" | "FAILED" | "STATUS" | "RELEASED" | "ERROR" | "WARN"}
44
- & element resource_id { text }?
45
- & element resource_address { text }?
46
- & element reason { text }?
47
- & element property { prop_content } *
36
+ & element cid { text }?
37
+ & element itype { "CREATION.OK" | "CREATION.FAILED" | "STATUS" | "RELEASED" | "ERROR" | "WARN" }
48
38
  }
@@ -10,12 +10,38 @@
10
10
  </choice>
11
11
  </start>
12
12
  <define name="common_elements">
13
- <attribute name="msg_id"/>
14
- <attribute name="timestamp"/>
15
- <attribute name="digest"/>
16
- <optional>
17
- <attribute name="signature"/>
18
- </optional>
13
+ <interleave>
14
+ <optional>
15
+ <attribute name="mid"/>
16
+ </optional>
17
+ <element name="ts">
18
+ <text/>
19
+ </element>
20
+ <optional>
21
+ <element name="src">
22
+ <text/>
23
+ </element>
24
+ </optional>
25
+ <optional>
26
+ <element name="replyto">
27
+ <text/>
28
+ </element>
29
+ </optional>
30
+ <optional>
31
+ <element name="props">
32
+ <zeroOrMore>
33
+ <ref name="property"/>
34
+ </zeroOrMore>
35
+ </element>
36
+ </optional>
37
+ <optional>
38
+ <element name="guard">
39
+ <zeroOrMore>
40
+ <ref name="property"/>
41
+ </zeroOrMore>
42
+ </element>
43
+ </optional>
44
+ </interleave>
19
45
  </define>
20
46
  <define name="anything">
21
47
  <choice>
@@ -34,91 +60,35 @@
34
60
  </element>
35
61
  </choice>
36
62
  </define>
37
- <define name="prop_content">
38
- <attribute name="key"/>
39
- <optional>
40
- <attribute name="type"/>
41
- </optional>
42
- <zeroOrMore>
43
- <ref name="anything"/>
44
- </zeroOrMore>
63
+ <define name="property">
64
+ <element>
65
+ <anyName/>
66
+ <optional>
67
+ <attribute name="type"/>
68
+ </optional>
69
+ <zeroOrMore>
70
+ <ref name="anything"/>
71
+ </zeroOrMore>
72
+ </element>
45
73
  </define>
46
74
  <define name="create">
47
75
  <element name="create">
48
76
  <interleave>
49
77
  <ref name="common_elements"/>
50
- <optional>
51
- <element name="publish_to">
52
- <text/>
53
- </element>
54
- </optional>
55
- <optional>
56
- <element name="guard">
57
- <zeroOrMore>
58
- <element name="property">
59
- <ref name="prop_content"/>
60
- </element>
61
- </zeroOrMore>
62
- </element>
63
- </optional>
64
- <zeroOrMore>
65
- <element name="property">
66
- <ref name="prop_content"/>
67
- </element>
68
- </zeroOrMore>
78
+ <element name="rtype">
79
+ <text/>
80
+ </element>
69
81
  </interleave>
70
82
  </element>
71
83
  </define>
72
84
  <define name="configure">
73
85
  <element name="configure">
74
- <interleave>
75
- <ref name="common_elements"/>
76
- <optional>
77
- <element name="publish_to">
78
- <text/>
79
- </element>
80
- </optional>
81
- <optional>
82
- <element name="guard">
83
- <zeroOrMore>
84
- <element name="property">
85
- <ref name="prop_content"/>
86
- </element>
87
- </zeroOrMore>
88
- </element>
89
- </optional>
90
- <zeroOrMore>
91
- <element name="property">
92
- <ref name="prop_content"/>
93
- </element>
94
- </zeroOrMore>
95
- </interleave>
86
+ <ref name="common_elements"/>
96
87
  </element>
97
88
  </define>
98
89
  <define name="request">
99
90
  <element name="request">
100
- <interleave>
101
- <ref name="common_elements"/>
102
- <optional>
103
- <element name="publish_to">
104
- <text/>
105
- </element>
106
- </optional>
107
- <optional>
108
- <element name="guard">
109
- <zeroOrMore>
110
- <element name="property">
111
- <ref name="prop_content"/>
112
- </element>
113
- </zeroOrMore>
114
- </element>
115
- </optional>
116
- <zeroOrMore>
117
- <element name="property">
118
- <ref name="prop_content"/>
119
- </element>
120
- </zeroOrMore>
121
- </interleave>
91
+ <ref name="common_elements"/>
122
92
  </element>
123
93
  </define>
124
94
  <define name="release">
@@ -126,27 +96,10 @@
126
96
  <interleave>
127
97
  <ref name="common_elements"/>
128
98
  <optional>
129
- <element name="publish_to">
99
+ <element name="res_id">
130
100
  <text/>
131
101
  </element>
132
102
  </optional>
133
- <element name="resource_id">
134
- <text/>
135
- </element>
136
- <optional>
137
- <element name="guard">
138
- <zeroOrMore>
139
- <element name="property">
140
- <ref name="prop_content"/>
141
- </element>
142
- </zeroOrMore>
143
- </element>
144
- </optional>
145
- <zeroOrMore>
146
- <element name="property">
147
- <ref name="prop_content"/>
148
- </element>
149
- </zeroOrMore>
150
103
  </interleave>
151
104
  </element>
152
105
  </define>
@@ -155,40 +108,20 @@
155
108
  <interleave>
156
109
  <ref name="common_elements"/>
157
110
  <optional>
158
- <element name="context_id">
111
+ <element name="cid">
159
112
  <text/>
160
113
  </element>
161
114
  </optional>
162
- <element name="inform_type">
115
+ <element name="itype">
163
116
  <choice>
164
- <value>CREATED</value>
165
- <value>FAILED</value>
117
+ <value>CREATION.OK</value>
118
+ <value>CREATION.FAILED</value>
166
119
  <value>STATUS</value>
167
120
  <value>RELEASED</value>
168
121
  <value>ERROR</value>
169
122
  <value>WARN</value>
170
123
  </choice>
171
124
  </element>
172
- <optional>
173
- <element name="resource_id">
174
- <text/>
175
- </element>
176
- </optional>
177
- <optional>
178
- <element name="resource_address">
179
- <text/>
180
- </element>
181
- </optional>
182
- <optional>
183
- <element name="reason">
184
- <text/>
185
- </element>
186
- </optional>
187
- <zeroOrMore>
188
- <element name="property">
189
- <ref name="prop_content"/>
190
- </element>
191
- </zeroOrMore>
192
125
  </interleave>
193
126
  </element>
194
127
  </define>
@@ -1,4 +1,4 @@
1
1
  module OmfCommon
2
- VERSION = "6.0.0.pre.10"
2
+ VERSION = "6.0.0.pre.11"
3
3
  PROTOCOL_VERSION = "6.0"
4
4
  end
data/omf_common.gemspec CHANGED
@@ -7,9 +7,11 @@ Gem::Specification.new do |s|
7
7
  s.version = OmfCommon::VERSION
8
8
  s.authors = ["NICTA"]
9
9
  s.email = ["omf-user@lists.nicta.com.au"]
10
- s.homepage = "https://www.mytestbed.net"
10
+ s.homepage = "http://omf.mytestbed.net"
11
11
  s.summary = %q{Common library of OMF}
12
12
  s.description = %q{Common library of OMF, a generic framework for controlling and managing networking testbeds.}
13
+ s.required_ruby_version = '>= 1.9.3'
14
+ s.license = 'MIT'
13
15
 
14
16
  s.rubyforge_project = "omf_common"
15
17
 
@@ -23,7 +25,7 @@ Gem::Specification.new do |s|
23
25
  s.add_development_dependency "em-minitest-spec", "~> 1.1.1"
24
26
  s.add_development_dependency "simplecov"
25
27
  s.add_runtime_dependency "eventmachine", "~> 0.12.10"
26
- s.add_runtime_dependency "blather", "= 0.8.0"
28
+ s.add_runtime_dependency "blather", "= 0.8.1"
27
29
  s.add_runtime_dependency "logging", "~> 1.7.1"
28
30
  s.add_runtime_dependency "hashie", "~> 1.2.0"
29
31
  s.add_runtime_dependency "oml4r", "~> 2.8.0"
@@ -170,13 +170,12 @@ def omf_created_xml
170
170
  <<-NODE
171
171
  <message from="pubsub.localhost" to="bravo@localhost" id="mclaren__bravo@localhost__FT6ea">
172
172
  <event xmlns="http://jabber.org/protocol/pubsub#event">
173
- <items node="mclaren">
173
+ <items node="test_topic">
174
174
  <item id="4JMgcKzxFDLsP74">
175
- <inform xmlns="http://schema.mytestbed.net/omf/6.0/protocol" msg_id="a2b6aba9f11dc5bb88306a32d0720641f5020c1f">
176
- <context_id>bf840fe9-c176-4fae-b7de-6fc27f183f76</context_id>
177
- <inform_type>CREATED</inform_type>
178
- <resource_id>444f17fb-546e-4685-a0d0-63e64fa046c8</resource_id>
179
- <resource_address>444f17fb-546e-4685-a0d0-63e64fa046c8</resource_address>
175
+ <inform xmlns="http://schema.mytestbed.net/omf/6.0/protocol" mid="a2b6aba9f11dc5bb88306a32d0720641f5020c1f">
176
+ <cid>bf840fe9-c176-4fae-b7de-6fc27f183f76</cid>
177
+ <itype>CREATION.OK</itype>
178
+ <res_id>444f17fb-546e-4685-a0d0-63e64fa046c8</res_id>
180
179
  </inform>
181
180
  </item>
182
181
  </items>
@@ -192,11 +191,11 @@ def omf_status_xml
192
191
  <<-NODE
193
192
  <message from="pubsub.localhost" to="bravo@localhost" id="mclaren__bravo@localhost__FT6ea">
194
193
  <event xmlns="http://jabber.org/protocol/pubsub#event">
195
- <items node="mclaren">
194
+ <items node="test_topic">
196
195
  <item id="4JMgcKzxFDLsP74">
197
- <inform xmlns="http://schema.mytestbed.net/omf/6.0/protocol" msg_id="a2b6aba9f11dc5bb88306a32d0720641f5020c1f">
198
- <context_id>bf840fe9-c176-4fae-b7de-6fc27f183f76</context_id>
199
- <inform_type>STATUS</inform_type>
196
+ <inform xmlns="http://schema.mytestbed.net/omf/6.0/protocol" mid="a2b6aba9f11dc5bb88306a32d0720641f5020c1f">
197
+ <cid>bf840fe9-c176-4fae-b7de-6fc27f183f76</cid>
198
+ <itype>STATUS</itype>
200
199
  <property key="bob">bob</property>
201
200
  </inform>
202
201
  </item>
@@ -213,11 +212,11 @@ def omf_failed_xml
213
212
  <<-NODE
214
213
  <message from="pubsub.localhost" to="bravo@localhost" id="mclaren__bravo@localhost__FT6ea">
215
214
  <event xmlns="http://jabber.org/protocol/pubsub#event">
216
- <items node="mclaren">
215
+ <items node="test_topic">
217
216
  <item id="4JMgcKzxFDLsP74">
218
- <inform xmlns="http://schema.mytestbed.net/omf/6.0/protocol" msg_id="a2b6aba9f11dc5bb88306a32d0720641f5020c1f">
219
- <context_id>bf840fe9-c176-4fae-b7de-6fc27f183f76</context_id>
220
- <inform_type>FAILED</inform_type>
217
+ <inform xmlns="http://schema.mytestbed.net/omf/6.0/protocol" mid="a2b6aba9f11dc5bb88306a32d0720641f5020c1f">
218
+ <cid>bf840fe9-c176-4fae-b7de-6fc27f183f76</cid>
219
+ <itype>CREATION.FAILED</itype>
221
220
  <reason>No idea</reason>
222
221
  </inform>
223
222
  </item>
@@ -234,12 +233,13 @@ def omf_released_xml
234
233
  <<-NODE
235
234
  <message from="pubsub.localhost" to="bravo@localhost" id="mclaren__bravo@localhost__FT6ea">
236
235
  <event xmlns="http://jabber.org/protocol/pubsub#event">
237
- <items node="mclaren">
236
+ <items node="test_topic">
238
237
  <item id="4JMgcKzxFDLsP74">
239
- <inform xmlns="http://schema.mytestbed.net/omf/6.0/protocol" msg_id="a2b6aba9f11dc5bb88306a32d0720641f5020c1f">
240
- <context_id>bf840fe9-c176-4fae-b7de-6fc27f183f76</context_id>
241
- <inform_type>RELEASED</inform_type>
242
- <resource_id>444f17fb-546e-4685-a0d0-63e64fa046c8</resource_id>
238
+ <inform xmlns="http://schema.mytestbed.net/omf/6.0/protocol">
239
+ <mid>a2b6aba9f11dc5bb88306a32d0720641f5020c1f</mid>
240
+ <cid>bf840fe9-c176-4fae-b7de-6fc27f183f76</cid>
241
+ <itype>RELEASED</itype>
242
+ <res_id>444f17fb-546e-4685-a0d0-63e64fa046c8</res_id>
243
243
  </inform>
244
244
  </item>
245
245
  </items>
@@ -2,39 +2,41 @@ require 'test_helper'
2
2
  require 'fixture/pubsub'
3
3
  require 'em/minitest/spec'
4
4
 
5
- describe OmfCommon::DSL::Xmpp do
5
+ require 'omf_common/comm/xmpp/communicator'
6
+
7
+ describe OmfCommon::Comm::XMPP::Communicator do
6
8
  before do
7
9
  @client = Blather::Client.new
8
10
  @stream = MiniTest::Mock.new
9
11
  @stream.expect(:send, true, [Blather::Stanza])
10
- @client.post_init @stream, Blather::JID.new('n@d/r')
11
- @xmpp = OmfCommon::Comm.new(:xmpp)
12
+ @client.post_init @stream, Blather::JID.new('bob@example.com')
13
+ @xmpp = OmfCommon::Comm::XMPP::Communicator.new
12
14
  end
13
15
 
14
16
  describe "when communicating to xmpp server (via mocking)" do
15
17
  include EM::MiniTest::Spec
16
18
 
17
- it "must be able to connect" do
18
- Blather::Stream::Client.stub(:start, @client) do
19
- Blather::Client.stub :new, @client do
20
- @xmpp.jid.inspect.must_equal "n@d/r"
21
- @xmpp.connect('bob', 'pw', 'example.com')
22
- @xmpp.jid.inspect.must_equal "bob@example.com"
19
+ it "must be able to connect and tigger on_connected callbacks" do
20
+ Blather::Client.stub :new, @client do
21
+ @xmpp.jid.inspect.must_equal "bob@example.com"
22
+
23
+ @xmpp.on_connected do |communicator|
24
+ communicator.must_be_kind_of OmfCommon::Comm::XMPP::Communicator
23
25
  end
26
+ @stream.verify
24
27
  end
25
28
  end
26
29
 
27
30
  it "must be able to disconnect" do
28
- Blather::Stream::Client.stub(:start, @client) do
29
- Blather::Client.stub :new, @client do
30
- @stream.expect(:close_connection_after_writing, true)
31
- @xmpp.disconnect
32
- @stream.verify
33
- end
31
+ Blather::Client.stub :new, @client do
32
+ @stream.expect(:close_connection_after_writing, true)
33
+ @xmpp.disconnect
34
+ @stream.verify
34
35
  end
35
36
  end
36
37
 
37
38
  it "must be able to subscribe & trigger callback when subscribed" do
39
+ skip
38
40
  Blather::Client.stub :new, @client do
39
41
  subscription = Blather::XMPPNode.parse(subscription_xml)
40
42
  write_callback = proc do |event|
@@ -43,7 +45,11 @@ describe OmfCommon::DSL::Xmpp do
43
45
  @client.receive_data subscription
44
46
  end
45
47
  @client.stub :write, write_callback do
46
- @xmpp.subscribe('xmpp_topic') { |e| e.must_equal subscription; done! }
48
+ @xmpp.subscribe('xmpp_topic') do |topic|
49
+ topic.must_be_kind_of OmfCommon::Comm::XMPP::Topic
50
+ topic.id.must_equal :xmpp_topic
51
+ done!
52
+ end
47
53
  end
48
54
  end
49
55
  wait!
@@ -51,17 +57,11 @@ describe OmfCommon::DSL::Xmpp do
51
57
 
52
58
  it "must be able to create topic & trigger callback when created" do
53
59
  Blather::Client.stub :new, @client do
54
- created = Blather::XMPPNode.parse(created_xml)
55
- write_callback = proc do |event|
56
- event.must_be_kind_of Blather::Stanza::PubSub::Create
57
- created.id = event.id
58
- @client.receive_data created
59
- end
60
- @client.stub :write, write_callback do
61
- @xmpp.create_topic('xmpp_topic') { |event| event.must_equal created; done! }
60
+ OmfCommon.stub :comm, @xmpp do
61
+ @stream.expect(:send, true, [Blather::Stanza])
62
+ @xmpp.create_topic('xmpp_topic').must_be_kind_of OmfCommon::Comm::XMPP::Topic
62
63
  end
63
64
  end
64
- wait!
65
65
  end
66
66
 
67
67
  it "must be able to delete topic & trigger callback when topic deleted" do
@@ -73,7 +73,9 @@ describe OmfCommon::DSL::Xmpp do
73
73
  @client.receive_data deleted
74
74
  end
75
75
  @client.stub :write, write_callback do
76
- @xmpp.delete_topic('xmpp_topic') { |event| event.must_equal deleted; done! }
76
+ @xmpp.delete_topic('xmpp_topic') do |stanza|
77
+ done!
78
+ end
77
79
  end
78
80
  end
79
81
  wait!
@@ -97,8 +99,8 @@ describe OmfCommon::DSL::Xmpp do
97
99
  it "must be able to publish if message is valid" do
98
100
  Blather::Client.stub :new, @client do
99
101
  @stream.expect(:send, true, [Blather::Stanza::PubSub::Publish])
100
- @xmpp.publish 'xmpp_topic', Message.create {|v| v.property('type', 'test')}
101
- proc { @xmpp.publish 'xmpp_topic', Message.inform {|v| v.element('blah', 'blah')} }.must_raise StandardError
102
+ @xmpp.publish 'xmpp_topic', OmfCommon::Message.create(:create, { type: 'test' })
103
+ proc { @xmpp.publish 'xmpp_topic', OmfCommon::Message.create(:inform, nil, { blah: 'blah' })}.must_raise StandardError
102
104
  @stream.verify
103
105
  end
104
106
  end
@@ -112,7 +114,7 @@ describe OmfCommon::DSL::Xmpp do
112
114
  @client.receive_data published
113
115
  end
114
116
  @client.stub :write, write_callback do
115
- @xmpp.publish 'xmpp_topic', Message.create {|v| v.property('type', 'test')} do |event|
117
+ @xmpp.publish 'xmpp_topic', OmfCommon::Message.create(:create, { type: 'test' }) do |event|
116
118
  event.must_equal published
117
119
  done!
118
120
  end
@@ -158,6 +160,7 @@ describe OmfCommon::DSL::Xmpp do
158
160
 
159
161
  describe "when omf message related methods" do
160
162
  it "must generate omf create xml fragment" do
163
+ skip
161
164
  m1 = @xmpp.create_message([type: 'engine'])
162
165
  m2 = @xmpp.create_message do |v|
163
166
  v.property('type', 'engine')
@@ -170,6 +173,7 @@ describe OmfCommon::DSL::Xmpp do
170
173
  end
171
174
 
172
175
  it "must generate omf configure xml fragment" do
176
+ skip
173
177
  m1 = @xmpp.configure_message([throttle: 50])
174
178
  m2 = @xmpp.configure_message do |v|
175
179
  v.property('throttle', 50)
@@ -182,30 +186,33 @@ describe OmfCommon::DSL::Xmpp do
182
186
  end
183
187
 
184
188
  it "must generate omf inform xml fragment" do
185
- m1 = @xmpp.inform_message([inform_type: 'CREATED'])
189
+ skip
190
+ m1 = @xmpp.inform_message([itype: 'CREATION.OK'])
186
191
  m2 = @xmpp.inform_message do |v|
187
- v.property('inform_type', 'CREATED')
192
+ v.property('itype', 'CREATION.OK')
188
193
  end
189
194
  m1.must_be_kind_of OmfCommon::TopicMessage
190
195
  m2.must_be_kind_of OmfCommon::TopicMessage
191
196
  m1.body.name.must_equal 'inform'
192
- m1.body.to_xml.must_match /<property key="inform_type" type="string">CREATED<\/property>/
193
- m2.body.to_xml.must_match /<property key="inform_type" type="string">CREATED<\/property>/
197
+ m1.body.to_xml.must_match /<property key="itype" type="string">CREATION.OK<\/property>/
198
+ m2.body.to_xml.must_match /<property key="itype" type="string">CREATION.OK<\/property>/
194
199
  end
195
200
 
196
201
  it "must generate omf release xml fragment" do
197
- m1 = @xmpp.release_message([resource_id: 100])
202
+ skip
203
+ m1 = @xmpp.release_message([res_id: 100])
198
204
  m2 = @xmpp.release_message do |v|
199
- v.property('resource_id', 100)
205
+ v.property('res_id', 100)
200
206
  end
201
207
  m1.must_be_kind_of OmfCommon::TopicMessage
202
208
  m2.must_be_kind_of OmfCommon::TopicMessage
203
209
  m1.body.name.must_equal 'release'
204
- m1.body.to_xml.must_match /<property key="resource_id" type="integer">100<\/property>/
205
- m2.body.to_xml.must_match /<property key="resource_id" type="integer">100<\/property>/
210
+ m1.body.to_xml.must_match /<property key="res_id" type="integer">100<\/property>/
211
+ m2.body.to_xml.must_match /<property key="res_id" type="integer">100<\/property>/
206
212
  end
207
213
 
208
214
  it "must generate omf request xml fragment" do
215
+ skip
209
216
  m1 = @xmpp.request_message([:max_rpm, {:provider => {country: 'japan'}}, :max_power])
210
217
  m2 = @xmpp.request_message do |v|
211
218
  v.property('max_rpm')
@@ -224,86 +231,15 @@ describe OmfCommon::DSL::Xmpp do
224
231
  end
225
232
  end
226
233
 
227
- describe "when informed message received" do
228
- include EM::MiniTest::Spec
229
-
230
- it "must react to omf created message" do
231
- Blather::Client.stub :new, @client do
232
- omf_create = OmfCommon::Message.create { |v| v.property('type', 'engine') }
233
- omf_create.stub :msg_id, "bf840fe9-c176-4fae-b7de-6fc27f183f76" do
234
- omf_created = Blather::XMPPNode.parse(omf_created_xml)
235
- @client.receive_data omf_created
236
- @xmpp.on_created_message(omf_create) do |n|
237
- n.must_equal Message.parse(omf_created.items.first.payload)
238
- done!
239
- end
240
- end
241
- end
242
- wait!
243
- end
244
-
245
- it "must react to omf status message" do
246
- Blather::Client.stub :new, @client do
247
- omf_request = OmfCommon::Message.request { |v| v.property('bob') }
248
- omf_request.stub :msg_id, "bf840fe9-c176-4fae-b7de-6fc27f183f76" do
249
- omf_status = Blather::XMPPNode.parse(omf_status_xml)
250
- @client.receive_data omf_status
251
- @xmpp.on_status_message(omf_request) do |n|
252
- n.must_equal Message.parse(omf_status.items.first.payload)
253
- done!
254
- end
255
- end
256
- end
257
- wait!
258
- end
259
-
260
- it "must react to omf release message" do
261
- Blather::Client.stub :new, @client do
262
- omf_release = OmfCommon::Message.release { |v| v.property('resource_id', '100') }
263
- omf_release.stub :msg_id, "bf840fe9-c176-4fae-b7de-6fc27f183f76" do
264
- omf_released = Blather::XMPPNode.parse(omf_released_xml)
265
- @client.receive_data omf_released
266
- @xmpp.on_released_message(omf_release) do |n|
267
- n.must_equal Message.parse(omf_released.items.first.payload)
268
- done!
269
- end
270
- end
271
- end
272
- wait!
273
- end
274
-
275
- it "must react to omf failed message" do
276
- Blather::Client.stub :new, @client do
277
- omf_create = OmfCommon::Message.create { |v| v.property('type', 'engine') }
278
- omf_create.stub :msg_id, "bf840fe9-c176-4fae-b7de-6fc27f183f76" do
279
- omf_failed = Blather::XMPPNode.parse(omf_failed_xml)
280
- @client.receive_data omf_failed
281
- @xmpp.on_failed_message(omf_create) do |n|
282
- n.must_equal Message.parse(omf_failed.items.first.payload)
283
- done!
284
- end
285
- end
286
- end
287
- wait!
288
- end
289
- end
290
-
291
234
  describe "when use event machine style method" do
292
235
  include EM::MiniTest::Spec
293
236
 
294
237
  it "must accept these methods and forward to event machine" do
295
- @xmpp.add_timer(0.05) { done! }
296
- @xmpp.add_periodic_timer(0.05) { done! }
238
+ skip
239
+ OmfCommon.eventloop.after(0.05) { done! }
240
+ OmfCommon.eventloop.every(0.05) { done! }
297
241
  wait!
298
242
  end
299
243
  end
300
-
301
- describe "when asked to get a topic object" do
302
- it "must return a topic object (pubsub topic) or nil if not found" do
303
- topic = @xmpp.get_topic('xmpp_topic')
304
- topic.must_be_kind_of OmfCommon::Topic
305
- topic.comm.must_equal @xmpp
306
- end
307
- end
308
244
  end
309
245