omf_common 6.0.0.pre.6 → 6.0.0.pre.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,75 @@
1
+ require 'test_helper'
2
+ require 'fixture/pubsub'
3
+ require 'em/minitest/spec'
4
+
5
+ include OmfCommon
6
+
7
+ describe OmfCommon::Topic do
8
+ before do
9
+ @client = Blather::Client.new
10
+ @stream = MiniTest::Mock.new
11
+ @stream.expect(:send, true, [Blather::Stanza])
12
+ @client.post_init @stream, Blather::JID.new('n@d/r')
13
+ @comm = Class.new { include OmfCommon::DSL::Xmpp }.new
14
+ @topic = @comm.get_topic('mclaren')
15
+ end
16
+
17
+ describe "when topic object initialised" do
18
+ include EM::MiniTest::Spec
19
+
20
+ it "must be able to subscribe" do
21
+ Blather::Client.stub :new, @client do
22
+ subscription = Blather::XMPPNode.parse(subscription_xml)
23
+ write_callback = proc do |event|
24
+ event.must_be_kind_of Blather::Stanza::PubSub::Subscribe
25
+ event.node.must_equal 'mclaren'
26
+ subscription.id = event.id
27
+ subscription.node = event.node
28
+ @client.receive_data subscription
29
+ end
30
+ @client.stub :write, write_callback do
31
+ @topic.subscribe do |e|
32
+ e.must_equal subscription
33
+ e.node.must_equal 'mclaren'
34
+ done!
35
+ end
36
+ end
37
+ end
38
+ wait!
39
+ end
40
+
41
+ it "must react when message arrived" do
42
+ Blather::Client.stub :new, @client do
43
+ omf_status = Blather::XMPPNode.parse(omf_status_xml)
44
+ @client.receive_data omf_status
45
+ @topic.on_message do |n|
46
+ n.must_equal Message.parse(omf_status.items.first.payload)
47
+ done!
48
+ end
49
+
50
+ invalid_topic = @comm.get_topic('bob')
51
+ invalid_topic.on_message do |n|
52
+ raise 'Wont come here'
53
+ end
54
+ end
55
+ wait!
56
+ end
57
+
58
+ it "must react when certain messages arrived, specified by guards" do
59
+ Blather::Client.stub :new, @client do
60
+ omf_status = Blather::XMPPNode.parse(omf_status_xml)
61
+ @client.receive_data omf_status
62
+ @topic.on_message proc { |message| message.context_id == 'bob' } do |n|
63
+ raise 'Wont come here'
64
+ end
65
+
66
+ @topic.on_message proc { |message| message.context_id == "bf840fe9-c176-4fae-b7de-6fc27f183f76" } do |n|
67
+ n.must_equal Message.parse(omf_status.items.first.payload)
68
+ n.context_id.must_equal "bf840fe9-c176-4fae-b7de-6fc27f183f76"
69
+ done!
70
+ end
71
+ end
72
+ wait!
73
+ end
74
+ end
75
+ end
data/test/test_helper.rb CHANGED
@@ -1,3 +1,6 @@
1
+ require 'simplecov'
2
+ SimpleCov.start { add_filter "/test" }
3
+
1
4
  gem 'minitest'
2
5
  require 'minitest/autorun'
3
6
  require 'minitest/pride'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omf_common
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.0.pre.6
4
+ version: 6.0.0.pre.7
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-17 00:00:00.000000000 Z
12
+ date: 2012-10-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest
@@ -18,7 +18,7 @@ dependencies:
18
18
  requirements:
19
19
  - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: 2.11.3
21
+ version: '3.2'
22
22
  type: :development
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -26,7 +26,55 @@ dependencies:
26
26
  requirements:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
- version: 2.11.3
29
+ version: '3.2'
30
+ - !ruby/object:Gem::Dependency
31
+ name: em-minitest-spec
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: 1.1.1
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 1.1.1
46
+ - !ruby/object:Gem::Dependency
47
+ name: simplecov
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: eventmachine
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: 0.12.10
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 0.12.10
30
78
  - !ruby/object:Gem::Dependency
31
79
  name: blather
32
80
  requirement: !ruby/object:Gem::Requirement
@@ -89,17 +137,25 @@ files:
89
137
  - lib/omf_common.rb
90
138
  - lib/omf_common/comm.rb
91
139
  - lib/omf_common/command.rb
140
+ - lib/omf_common/core_ext/object.rb
92
141
  - lib/omf_common/core_ext/string.rb
93
142
  - lib/omf_common/dsl/xmpp.rb
143
+ - lib/omf_common/exec_app.rb
94
144
  - lib/omf_common/message.rb
95
- - lib/omf_common/protocol.rnc
96
- - lib/omf_common/protocol.rng
145
+ - lib/omf_common/protocol/6.0.rnc
146
+ - lib/omf_common/protocol/6.0.rng
147
+ - lib/omf_common/topic.rb
148
+ - lib/omf_common/topic_message.rb
97
149
  - lib/omf_common/version.rb
98
150
  - omf_common.gemspec
151
+ - test/fixture/pubsub.rb
99
152
  - test/omf_common/comm_spec.rb
100
153
  - test/omf_common/command_spec.rb
101
154
  - test/omf_common/core_ext/string_spec.rb
155
+ - test/omf_common/dsl/xmpp_spec.rb
102
156
  - test/omf_common/message_spec.rb
157
+ - test/omf_common/topic_message_spec.rb
158
+ - test/omf_common/topic_spec.rb
103
159
  - test/test_helper.rb
104
160
  homepage: https://www.mytestbed.net
105
161
  licenses: []
@@ -126,3 +182,4 @@ signing_key:
126
182
  specification_version: 3
127
183
  summary: Common library of OMF
128
184
  test_files: []
185
+ has_rdoc:
@@ -1,42 +0,0 @@
1
- default namespace = "http://schema.mytestbed.net/6.0/protocol"
2
-
3
- element (create | configure) {
4
- attribute msg_id { text },
5
- element context_id { text },
6
- element property {
7
- (attribute key { text } | element key { text }),
8
- (attribute type { text } | element type { text })?,
9
- (element value { text } | text),
10
- element unit { text }?,
11
- element precision { text }?
12
- }*
13
- } |
14
- element request {
15
- attribute msg_id { text },
16
- element context_id { text },
17
- element publish_to { text }?,
18
- element property {
19
- (attribute key { text } | element key { text }),
20
- element min_value { text }?,
21
- element max_value { text }?
22
- }*
23
- } |
24
- element inform {
25
- attribute msg_id { text },
26
- element context_id { text },
27
- element inform_type { "CREATED" | "FAILED" | "STATUS" | "RELEASED" },
28
- element resource_id { text }?,
29
- element resource_address { text }?,
30
- element error_message { text }?,
31
- element property {
32
- (attribute key { text } | element key { text }),
33
- element current { text },
34
- element target { text }?,
35
- element msg { text }?,
36
- element progress { text }?
37
- }*
38
- } |
39
- element release {
40
- attribute msg_id { text },
41
- element context_id { text }
42
- }
@@ -1,141 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <choice ns="http://schema.mytestbed.net/6.0/protocol" xmlns="http://relaxng.org/ns/structure/1.0">
3
- <element>
4
- <choice>
5
- <name>create</name>
6
- <name>configure</name>
7
- </choice>
8
- <attribute name="msg_id"/>
9
- <element name="context_id">
10
- <text/>
11
- </element>
12
- <zeroOrMore>
13
- <element name="property">
14
- <choice>
15
- <attribute name="key"/>
16
- <element name="key">
17
- <text/>
18
- </element>
19
- </choice>
20
- <optional>
21
- <choice>
22
- <attribute name="type"/>
23
- <element name="type">
24
- <text/>
25
- </element>
26
- </choice>
27
- </optional>
28
- <choice>
29
- <element name="value">
30
- <text/>
31
- </element>
32
- <text/>
33
- </choice>
34
- <optional>
35
- <element name="unit">
36
- <text/>
37
- </element>
38
- </optional>
39
- <optional>
40
- <element name="precision">
41
- <text/>
42
- </element>
43
- </optional>
44
- </element>
45
- </zeroOrMore>
46
- </element>
47
- <element name="request">
48
- <attribute name="msg_id"/>
49
- <element name="context_id">
50
- <text/>
51
- </element>
52
- <optional>
53
- <element name="publish_to">
54
- <text/>
55
- </element>
56
- </optional>
57
- <zeroOrMore>
58
- <element name="property">
59
- <choice>
60
- <attribute name="key"/>
61
- <element name="key">
62
- <text/>
63
- </element>
64
- </choice>
65
- <optional>
66
- <element name="min_value">
67
- <text/>
68
- </element>
69
- </optional>
70
- <optional>
71
- <element name="max_value">
72
- <text/>
73
- </element>
74
- </optional>
75
- </element>
76
- </zeroOrMore>
77
- </element>
78
- <element name="inform">
79
- <attribute name="msg_id"/>
80
- <element name="context_id">
81
- <text/>
82
- </element>
83
- <element name="inform_type">
84
- <choice>
85
- <value>CREATED</value>
86
- <value>FAILED</value>
87
- <value>STATUS</value>
88
- <value>RELEASED</value>
89
- </choice>
90
- </element>
91
- <optional>
92
- <element name="resource_id">
93
- <text/>
94
- </element>
95
- </optional>
96
- <optional>
97
- <element name="resource_address">
98
- <text/>
99
- </element>
100
- </optional>
101
- <optional>
102
- <element name="error_message">
103
- <text/>
104
- </element>
105
- </optional>
106
- <zeroOrMore>
107
- <element name="property">
108
- <choice>
109
- <attribute name="key"/>
110
- <element name="key">
111
- <text/>
112
- </element>
113
- </choice>
114
- <element name="current">
115
- <text/>
116
- </element>
117
- <optional>
118
- <element name="target">
119
- <text/>
120
- </element>
121
- </optional>
122
- <optional>
123
- <element name="msg">
124
- <text/>
125
- </element>
126
- </optional>
127
- <optional>
128
- <element name="progress">
129
- <text/>
130
- </element>
131
- </optional>
132
- </element>
133
- </zeroOrMore>
134
- </element>
135
- <element name="release">
136
- <attribute name="msg_id"/>
137
- <element name="context_id">
138
- <text/>
139
- </element>
140
- </element>
141
- </choice>