hazelcast-client 0.0.2-jruby → 0.0.3-jruby

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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
@@ -10,7 +10,6 @@ module Hazelcast
10
10
  GEM_ROOT = File.expand_path(File.dirname(__FILE__)) unless defined?(GEM_ROOT)
11
11
 
12
12
  java_import 'com.hazelcast.client.HazelcastClient'
13
- # java_import 'java.util.Map'
14
13
 
15
14
  attr_reader :username, :password, :host
16
15
 
@@ -44,6 +44,36 @@ class Java::ComHazelcastClient::MapClientProxy
44
44
  end
45
45
  end
46
46
 
47
+ java_import 'com.hazelcast.core.EntryListener'
48
+
49
+ def on_entry_added(key = nil, include_value = true, &blk)
50
+ klass = Class.new
51
+ klass.send :include, EntryListener
52
+ klass.send :define_method, :entry_added, &blk
53
+ key ? add_entry_listener(klass.new, key, include_value) : add_entry_listener(klass.new, include_value)
54
+ end
55
+
56
+ def on_entry_removed(key = nil, include_value = true, &blk)
57
+ klass = Class.new
58
+ klass.send :include, EntryListener
59
+ klass.send :define_method, :entry_removed, &blk
60
+ key ? add_entry_listener(klass.new, key, include_value) : add_entry_listener(klass.new, include_value)
61
+ end
62
+
63
+ def on_entry_updated(key = nil, include_value = true, &blk)
64
+ klass = Class.new
65
+ klass.send :include, EntryListener
66
+ klass.send :define_method, :entry_updated, &blk
67
+ key ? add_entry_listener(klass.new, key, include_value) : add_entry_listener(klass.new, include_value)
68
+ end
69
+
70
+ def on_entry_evicted(key = nil, include_value = true, &blk)
71
+ klass = Class.new
72
+ klass.send :include, EntryListener
73
+ klass.send :define_method, :entry_evicted, &blk
74
+ key ? add_entry_listener(klass.new, key, include_value) : add_entry_listener(klass.new, include_value)
75
+ end
76
+
47
77
  end
48
78
 
49
79
 
data/test/test_map.rb CHANGED
@@ -46,4 +46,70 @@ class TestRubyHazeHash < Test::Unit::TestCase
46
46
  assert_equal "country=Unites States of America", predicate.to_s
47
47
  end
48
48
 
49
+ def test_entry_added
50
+ Notices.clear
51
+ map = CLIENT.map :test_entry_added
52
+ map.on_entry_added do |event|
53
+ Notices << "added : #{event.key} : #{event.value}"
54
+ end
55
+
56
+ assert_equal Notices.size, 0
57
+ k, v = "a1", "b2"
58
+ map[k] = v
59
+ sleep 0.5
60
+ puts "Notices : #{Notices.all.inspect}"
61
+ assert_equal Notices.size, 1
62
+ assert_equal Notices.last, "added : #{k} : #{v}"
63
+ end
64
+
65
+ def test_entry_removed
66
+ Notices.clear
67
+ map = CLIENT.map :test_entry_removed
68
+ map.on_entry_removed do |event|
69
+ Notices << "removed : #{event.key} : #{event.value}"
70
+ end
71
+
72
+ assert_equal Notices.size, 0
73
+ k, v = "a1", "b2"
74
+ map[k] = v
75
+ map.remove k
76
+ sleep 0.25
77
+ assert_equal Notices.size, 1
78
+ assert_equal Notices.last, "removed : #{k} : #{v}"
79
+ end
80
+
81
+ def test_entry_updated
82
+ Notices.clear
83
+ map = CLIENT.map :test_entry_updated
84
+ map.on_entry_updated do |event|
85
+ Notices << "updated : #{event.key} : #{event.value}"
86
+ end
87
+
88
+ assert_equal Notices.size, 0
89
+ k, v = "a1", "b2"
90
+ map[k] = "b1"
91
+ map[k] = v
92
+ sleep 0.25
93
+ puts "Notices : #{Notices.all.inspect}"
94
+ assert_equal Notices.size, 2
95
+ assert_equal Notices.first, "updated : #{k} : b1"
96
+ assert_equal Notices.last, "updated : #{k} : #{v}"
97
+ end
98
+
99
+ def test_entry_evicted
100
+ Notices.clear
101
+ map = CLIENT.map :test_entry_evicted
102
+ map.on_entry_evicted do |event|
103
+ Notices << "evicted : #{event.key} : #{event.value}"
104
+ end
105
+
106
+ assert_equal Notices.size, 0
107
+ k, v = "a1", "b2"
108
+ map[k] = v
109
+ map.evict k
110
+ sleep 0.25
111
+ assert_equal Notices.size, 1
112
+ assert_equal Notices.last, "evicted : #{k} : #{v}"
113
+ end
114
+
49
115
  end
metadata CHANGED
@@ -1,12 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hazelcast-client
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 0
8
- - 2
9
- version: 0.0.2
4
+ prerelease:
5
+ version: 0.0.3
10
6
  platform: jruby
11
7
  authors:
12
8
  - Adrian Madrid
@@ -14,20 +10,17 @@ autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
12
 
17
- date: 2011-01-08 00:00:00 -07:00
13
+ date: 2011-01-22 00:00:00 -07:00
18
14
  default_executable: hazelcast-client-console
19
15
  dependencies:
20
16
  - !ruby/object:Gem::Dependency
21
17
  name: hazelcast-jars
22
18
  prerelease: false
23
19
  requirement: &id001 !ruby/object:Gem::Requirement
20
+ none: false
24
21
  requirements:
25
22
  - - "="
26
23
  - !ruby/object:Gem::Version
27
- segments:
28
- - 1
29
- - 9
30
- - 1
31
24
  version: 1.9.1
32
25
  type: :runtime
33
26
  version_requirements: *id001
@@ -65,23 +58,21 @@ rdoc_options: []
65
58
  require_paths:
66
59
  - lib
67
60
  required_ruby_version: !ruby/object:Gem::Requirement
61
+ none: false
68
62
  requirements:
69
63
  - - ">="
70
64
  - !ruby/object:Gem::Version
71
- segments:
72
- - 0
73
65
  version: "0"
74
66
  required_rubygems_version: !ruby/object:Gem::Requirement
67
+ none: false
75
68
  requirements:
76
69
  - - ">="
77
70
  - !ruby/object:Gem::Version
78
- segments:
79
- - 0
80
71
  version: "0"
81
72
  requirements: []
82
73
 
83
74
  rubyforge_project: hazelcast-client
84
- rubygems_version: 1.3.6
75
+ rubygems_version: 1.4.2
85
76
  signing_key:
86
77
  specification_version: 3
87
78
  summary: Connecting to a Hazelcast Cluster has never been easier!