slyphon-zookeeper 0.1.7-java → 0.2.0-java

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.
data/spec/em_spec.rb ADDED
@@ -0,0 +1,138 @@
1
+ require File.expand_path('../spec_helper', __FILE__)
2
+ require 'zookeeper/em_client'
3
+
4
+ gem 'evented-spec', '~> 0.4.1'
5
+ require 'evented-spec'
6
+
7
+
8
+ describe 'ZookeeperEM' do
9
+ describe 'Client' do
10
+ include EventedSpec::SpecHelper
11
+ default_timeout 3.0
12
+
13
+ def setup_zk
14
+ @zk = ZookeeperEM::Client.new('localhost:2181')
15
+ em do
16
+ @zk.on_attached do
17
+ yield
18
+ end
19
+ end
20
+ end
21
+
22
+ def teardown_and_done
23
+ @zk.close { done }
24
+ end
25
+
26
+ describe 'selectable_io' do
27
+ it %[should return an IO object] do
28
+ setup_zk do
29
+ @zk.selectable_io.should be_instance_of(IO)
30
+ teardown_and_done
31
+ end
32
+ end
33
+
34
+ it %[should not be closed] do
35
+ setup_zk do
36
+ @zk.selectable_io.should_not be_closed
37
+ teardown_and_done
38
+ end
39
+ end
40
+
41
+ before do
42
+ @data_cb = ZookeeperCallbacks::DataCallback.new do
43
+ logger.debug { "cb called: #{@data_cb.inspect}" }
44
+ end
45
+ end
46
+
47
+ it %[should be read-ready if there's an event waiting] do
48
+ setup_zk do
49
+ @zk.get(:path => "/", :callback => @data_cb)
50
+
51
+ r, *_ = IO.select([@zk.selectable_io], [], [], 2)
52
+
53
+ r.should be_kind_of(Array)
54
+
55
+ teardown_and_done
56
+ end
57
+ end
58
+
59
+ it %[should not be read-ready if there's no event] do
60
+ pending "get this to work in jruby" if defined?(::JRUBY_VERSION)
61
+ # there's always an initial event after connect
62
+
63
+ # except in jruby
64
+ # if defined?(::JRUBY_VERSION)
65
+ # @zk.get(:path => '/', :callback => @data_cb)
66
+ # end
67
+
68
+ setup_zk do
69
+ events = 0
70
+
71
+ while true
72
+ r, *_ = IO.select([@zk.selectable_io], [], [], 0.2)
73
+
74
+ break unless r
75
+
76
+ h = @zk.get_next_event(false)
77
+ @zk.selectable_io.read(1)
78
+
79
+ events += 1
80
+
81
+ h.should be_kind_of(Hash)
82
+ end
83
+
84
+ events.should == 1
85
+
86
+ teardown_and_done
87
+ end
88
+ end
89
+ end
90
+
91
+ describe 'em_connection' do
92
+ before do
93
+ @zk = ZookeeperEM::Client.new('localhost:2181')
94
+ end
95
+
96
+ it %[should be nil before the reactor is started] do
97
+ @zk.em_connection.should be_nil
98
+
99
+ em do
100
+ teardown_and_done
101
+ end
102
+ end
103
+
104
+ it %[should fire off the on_attached callbacks once the reactor is managing us] do
105
+ @zk.on_attached do |*|
106
+ @zk.em_connection.should_not be_nil
107
+ @zk.em_connection.should be_instance_of(ZookeeperEM::ZKConnection)
108
+ teardown_and_done
109
+ end
110
+
111
+ em do
112
+ EM.reactor_running?.should be_true
113
+ end
114
+ end
115
+ end
116
+
117
+ describe 'callbacks' do
118
+ it %[should be called on the reactor thread] do
119
+ cb = lambda do |h|
120
+ EM.reactor_thread?.should be_true
121
+ logger.debug { "called back on the reactor thread? #{EM.reactor_thread?}" }
122
+ teardown_and_done
123
+ end
124
+
125
+ setup_zk do
126
+ @zk.on_attached do |*|
127
+ logger.debug { "on_attached called" }
128
+ rv = @zk.get(:path => '/', :callback => cb)
129
+ logger.debug { "rv from @zk.get: #{rv.inspect}" }
130
+ end
131
+ end
132
+ end
133
+ end
134
+
135
+ end
136
+ end
137
+
138
+
data/spec/spec_helper.rb CHANGED
@@ -13,6 +13,25 @@ Zookeeper.logger = Logger.new(File.expand_path('../../test.log', __FILE__)).tap
13
13
  log.level = Logger::DEBUG
14
14
  end
15
15
 
16
+ def logger
17
+ Zookeeper.logger
18
+ end
19
+
20
+
21
+ require 'rspec/core/formatters/progress_formatter'
22
+
23
+ module RSpec
24
+ module Core
25
+ module Formatters
26
+ class ProgressFormatter
27
+ def example_started(example)
28
+ Zookeeper.logger.info(yellow("=====<([ #{example.full_description} ])>====="))
29
+ super(example)
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
16
35
 
17
36
  RSpec.configure do |config|
18
37
  config.mock_with :flexmock
metadata CHANGED
@@ -1,70 +1,95 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slyphon-zookeeper
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 23
4
5
  prerelease:
5
- version: 0.1.7
6
+ segments:
7
+ - 0
8
+ - 2
9
+ - 0
10
+ version: 0.2.0
6
11
  platform: java
7
12
  authors:
8
- - Phillip Pearson
9
- - Eric Maland
10
- - Evan Weaver
11
- - Brian Wickman
12
- - Neil Conway
13
- - Jonathan D. Simms
13
+ - Phillip Pearson
14
+ - Eric Maland
15
+ - Evan Weaver
16
+ - Brian Wickman
17
+ - Neil Conway
18
+ - Jonathan D. Simms
14
19
  autorequire:
15
20
  bindir: bin
16
21
  cert_chain: []
17
22
 
18
- date: 2011-05-24 00:00:00 +00:00
23
+ date: 2011-06-17 00:00:00 +00:00
19
24
  default_executable:
20
25
  dependencies:
21
- - !ruby/object:Gem::Dependency
22
- name: rspec
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- version: 2.0.0
30
- type: :development
31
- version_requirements: *id001
32
- - !ruby/object:Gem::Dependency
33
- name: flexmock
34
- prerelease: false
35
- requirement: &id002 !ruby/object:Gem::Requirement
36
- none: false
37
- requirements:
38
- - - ~>
39
- - !ruby/object:Gem::Version
40
- version: 0.8.11
41
- type: :development
42
- version_requirements: *id002
43
- - !ruby/object:Gem::Dependency
44
- name: slyphon-log4j
45
- prerelease: false
46
- requirement: &id003 !ruby/object:Gem::Requirement
47
- none: false
48
- requirements:
49
- - - "="
50
- - !ruby/object:Gem::Version
51
- version: 1.2.15
52
- type: :runtime
53
- version_requirements: *id003
54
- - !ruby/object:Gem::Dependency
55
- name: slyphon-zookeeper_jar
56
- prerelease: false
57
- requirement: &id004 !ruby/object:Gem::Requirement
58
- none: false
59
- requirements:
60
- - - "="
61
- - !ruby/object:Gem::Version
62
- version: 3.3.3
63
- type: :runtime
64
- version_requirements: *id004
26
+ - !ruby/object:Gem::Dependency
27
+ name: rspec
28
+ prerelease: false
29
+ requirement: &id001 !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ hash: 15
35
+ segments:
36
+ - 2
37
+ - 0
38
+ - 0
39
+ version: 2.0.0
40
+ type: :development
41
+ version_requirements: *id001
42
+ - !ruby/object:Gem::Dependency
43
+ name: flexmock
44
+ prerelease: false
45
+ requirement: &id002 !ruby/object:Gem::Requirement
46
+ none: false
47
+ requirements:
48
+ - - ~>
49
+ - !ruby/object:Gem::Version
50
+ hash: 41
51
+ segments:
52
+ - 0
53
+ - 8
54
+ - 11
55
+ version: 0.8.11
56
+ type: :development
57
+ version_requirements: *id002
58
+ - !ruby/object:Gem::Dependency
59
+ name: slyphon-log4j
60
+ prerelease: false
61
+ requirement: &id003 !ruby/object:Gem::Requirement
62
+ none: false
63
+ requirements:
64
+ - - "="
65
+ - !ruby/object:Gem::Version
66
+ hash: 1
67
+ segments:
68
+ - 1
69
+ - 2
70
+ - 15
71
+ version: 1.2.15
72
+ type: :runtime
73
+ version_requirements: *id003
74
+ - !ruby/object:Gem::Dependency
75
+ name: slyphon-zookeeper_jar
76
+ prerelease: false
77
+ requirement: &id004 !ruby/object:Gem::Requirement
78
+ none: false
79
+ requirements:
80
+ - - "="
81
+ - !ruby/object:Gem::Version
82
+ hash: 13
83
+ segments:
84
+ - 3
85
+ - 3
86
+ - 3
87
+ version: 3.3.3
88
+ type: :runtime
89
+ version_requirements: *id004
65
90
  description: twitter's zookeeper client
66
91
  email:
67
- - slyphon@gmail.com
92
+ - slyphon@gmail.com
68
93
  executables: []
69
94
 
70
95
  extensions: []
@@ -72,41 +97,43 @@ extensions: []
72
97
  extra_rdoc_files: []
73
98
 
74
99
  files:
75
- - .gitignore
76
- - CHANGELOG
77
- - Gemfile
78
- - LICENSE
79
- - Manifest
80
- - README
81
- - Rakefile
82
- - examples/cloud_config.rb
83
- - ext/.gitignore
84
- - ext/extconf.rb
85
- - ext/zkc-3.3.3.tar.gz
86
- - ext/zookeeper_base.rb
87
- - ext/zookeeper_c.c
88
- - ext/zookeeper_lib.c
89
- - ext/zookeeper_lib.h
90
- - java/zookeeper_base.rb
91
- - lib/zookeeper.rb
92
- - lib/zookeeper/acls.rb
93
- - lib/zookeeper/callbacks.rb
94
- - lib/zookeeper/common.rb
95
- - lib/zookeeper/constants.rb
96
- - lib/zookeeper/exceptions.rb
97
- - lib/zookeeper/stat.rb
98
- - notes.txt
99
- - slyphon-zookeeper.gemspec
100
- - spec/default_watcher_spec.rb
101
- - spec/log4j.properties
102
- - spec/spec_helper.rb
103
- - spec/zookeeper_spec.rb
104
- - test/test_basic.rb
105
- - test/test_callback1.rb
106
- - test/test_close.rb
107
- - test/test_esoteric.rb
108
- - test/test_watcher1.rb
109
- - test/test_watcher2.rb
100
+ - .gitignore
101
+ - CHANGELOG
102
+ - Gemfile
103
+ - LICENSE
104
+ - Manifest
105
+ - README
106
+ - Rakefile
107
+ - examples/cloud_config.rb
108
+ - ext/.gitignore
109
+ - ext/extconf.rb
110
+ - ext/zkc-3.3.3.tar.gz
111
+ - ext/zookeeper_base.rb
112
+ - ext/zookeeper_c.c
113
+ - ext/zookeeper_lib.c
114
+ - ext/zookeeper_lib.h
115
+ - java/zookeeper_base.rb
116
+ - lib/zookeeper.rb
117
+ - lib/zookeeper/acls.rb
118
+ - lib/zookeeper/callbacks.rb
119
+ - lib/zookeeper/common.rb
120
+ - lib/zookeeper/constants.rb
121
+ - lib/zookeeper/em_client.rb
122
+ - lib/zookeeper/exceptions.rb
123
+ - lib/zookeeper/stat.rb
124
+ - notes.txt
125
+ - slyphon-zookeeper.gemspec
126
+ - spec/default_watcher_spec.rb
127
+ - spec/em_spec.rb
128
+ - spec/log4j.properties
129
+ - spec/spec_helper.rb
130
+ - spec/zookeeper_spec.rb
131
+ - test/test_basic.rb
132
+ - test/test_callback1.rb
133
+ - test/test_close.rb
134
+ - test/test_esoteric.rb
135
+ - test/test_watcher1.rb
136
+ - test/test_watcher2.rb
110
137
  has_rdoc: true
111
138
  homepage:
112
139
  licenses: []
@@ -115,35 +142,42 @@ post_install_message:
115
142
  rdoc_options: []
116
143
 
117
144
  require_paths:
118
- - lib
119
- - java
145
+ - lib
146
+ - java
120
147
  required_ruby_version: !ruby/object:Gem::Requirement
121
148
  none: false
122
149
  requirements:
123
- - - ">="
124
- - !ruby/object:Gem::Version
125
- version: "0"
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ hash: 3
153
+ segments:
154
+ - 0
155
+ version: "0"
126
156
  required_rubygems_version: !ruby/object:Gem::Requirement
127
157
  none: false
128
158
  requirements:
129
- - - ">="
130
- - !ruby/object:Gem::Version
131
- version: "0"
159
+ - - ">="
160
+ - !ruby/object:Gem::Version
161
+ hash: 3
162
+ segments:
163
+ - 0
164
+ version: "0"
132
165
  requirements: []
133
166
 
134
167
  rubyforge_project:
135
- rubygems_version: 1.5.1
168
+ rubygems_version: 1.6.2
136
169
  signing_key:
137
170
  specification_version: 3
138
171
  summary: twitter's zookeeper client
139
172
  test_files:
140
- - spec/default_watcher_spec.rb
141
- - spec/log4j.properties
142
- - spec/spec_helper.rb
143
- - spec/zookeeper_spec.rb
144
- - test/test_basic.rb
145
- - test/test_callback1.rb
146
- - test/test_close.rb
147
- - test/test_esoteric.rb
148
- - test/test_watcher1.rb
149
- - test/test_watcher2.rb
173
+ - spec/default_watcher_spec.rb
174
+ - spec/em_spec.rb
175
+ - spec/log4j.properties
176
+ - spec/spec_helper.rb
177
+ - spec/zookeeper_spec.rb
178
+ - test/test_basic.rb
179
+ - test/test_callback1.rb
180
+ - test/test_close.rb
181
+ - test/test_esoteric.rb
182
+ - test/test_watcher1.rb
183
+ - test/test_watcher2.rb