couchbase-jruby-client 0.1.0-java → 0.1.5-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.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/.jrubyrc +722 -0
  3. data/.ruby-version +1 -1
  4. data/README.md +12 -90
  5. data/couchbase-jruby-client.gemspec +6 -6
  6. data/lib/couchbase/async.rb +18 -0
  7. data/lib/couchbase/bucket.rb +90 -180
  8. data/lib/couchbase/constants.rb +17 -0
  9. data/lib/couchbase/design_doc.rb +83 -0
  10. data/lib/couchbase/error.rb +31 -0
  11. data/lib/couchbase/operations/arithmetic.rb +17 -0
  12. data/lib/couchbase/operations/delete.rb +17 -0
  13. data/lib/couchbase/operations/design_docs.rb +99 -0
  14. data/lib/couchbase/operations/get.rb +73 -67
  15. data/lib/couchbase/operations/stats.rb +28 -1
  16. data/lib/couchbase/operations/store.rb +114 -97
  17. data/lib/couchbase/operations/touch.rb +49 -19
  18. data/lib/couchbase/operations/unlock.rb +209 -0
  19. data/lib/couchbase/operations/utils.rb +22 -10
  20. data/lib/couchbase/operations.rb +21 -0
  21. data/lib/couchbase/query.rb +92 -0
  22. data/lib/couchbase/result.rb +18 -1
  23. data/lib/couchbase/transcoder.rb +36 -42
  24. data/lib/couchbase/version.rb +18 -1
  25. data/lib/couchbase/view.rb +30 -172
  26. data/lib/couchbase/view_row.rb +38 -98
  27. data/lib/couchbase.rb +74 -72
  28. data/test/profile/.jrubyrc +722 -0
  29. data/test/profile/Gemfile +5 -5
  30. data/test/profile/benchmark.rb +106 -124
  31. data/test/profile/profile.rb +59 -0
  32. data/test/setup.rb +10 -145
  33. data/test/test_arithmetic.rb +54 -77
  34. data/test/test_async.rb +74 -102
  35. data/test/test_bucket.rb +74 -60
  36. data/test/test_cas.rb +10 -23
  37. data/test/test_couchbase.rb +11 -3
  38. data/test/test_delete.rb +41 -43
  39. data/test/test_design_docs.rb +62 -0
  40. data/test/test_errors.rb +9 -18
  41. data/test/test_format.rb +21 -31
  42. data/test/test_get.rb +107 -151
  43. data/test/test_query.rb +23 -0
  44. data/test/test_stats.rb +9 -24
  45. data/test/test_store.rb +52 -65
  46. data/test/test_timer.rb +4 -12
  47. data/test/test_touch.rb +26 -33
  48. data/test/test_unlock.rb +47 -78
  49. data/test/test_utils.rb +2 -11
  50. data/test/test_version.rb +5 -14
  51. data/test/test_view.rb +87 -0
  52. metadata +27 -14
  53. data/lib/couchbase/jruby/couchbase_client.rb +0 -22
  54. data/lib/couchbase/jruby/future.rb +0 -8
data/test/test_store.rb CHANGED
@@ -19,98 +19,84 @@ require File.join(File.dirname(__FILE__), 'setup')
19
19
 
20
20
  class TestStore < MiniTest::Test
21
21
 
22
- def setup
23
- @mock = start_mock
24
- end
25
-
26
- def teardown
27
- stop_mock(@mock)
28
- end
29
-
30
22
  def test_trivial_set
31
- connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
32
- cas = connection.set(uniq_id, "bar")
23
+ cas = cb.set(uniq_id, "bar")
33
24
  assert(cas > 0)
34
25
  end
35
26
 
36
27
  def test_set_with_cas
37
- connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
38
28
 
39
- cas1 = connection.set(uniq_id, "bar1")
29
+ cas1 = cb.set(uniq_id, "bar1")
40
30
  assert cas1 > 0
41
31
 
42
32
  assert_raises(Couchbase::Error::KeyExists) do
43
- connection.set(uniq_id, "bar2", :cas => cas1+1)
33
+ cb.set(uniq_id, "bar2", :cas => cas1+1)
44
34
  end
45
35
 
46
- cas2 = connection.set(uniq_id, "bar2", :cas => cas1)
36
+ cas2 = cb.set(uniq_id, "bar2", :cas => cas1)
47
37
  assert cas2 > 0
48
38
  refute_equal cas2, cas1
49
39
 
50
- cas3 = connection.set(uniq_id, "bar3")
40
+ cas3 = cb.set(uniq_id, "bar3")
51
41
  assert cas3 > 0
52
42
  refute_equal cas3, cas2
53
43
  refute_equal cas3, cas1
54
44
  end
55
45
 
56
46
  def test_add
57
- connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
58
47
 
59
- cas1 = connection.add(uniq_id, "bar")
48
+ cas1 = cb.add(uniq_id, "bar")
60
49
  assert cas1 > 0
61
50
 
62
51
  assert_raises(Couchbase::Error::KeyExists) do
63
- connection.add(uniq_id, "bar")
52
+ cb.add(uniq_id, "bar")
64
53
  end
65
54
 
66
55
  assert_raises(Couchbase::Error::KeyExists) do
67
- connection.add(uniq_id, "bar", :cas => cas1)
56
+ cb.add(uniq_id, "bar", :cas => cas1)
68
57
  end
69
58
  end
70
59
 
71
60
  def test_replace
72
- connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
73
61
 
74
62
  assert_raises(Couchbase::Error::NotFound) do
75
- connection.replace(uniq_id, "bar")
63
+ cb.replace(uniq_id, "bar")
76
64
  end
77
65
 
78
- cas1 = connection.set(uniq_id, "bar")
66
+ cas1 = cb.set(uniq_id, "bar")
79
67
  assert cas1 > 0
80
68
 
81
- connection.replace(uniq_id, "bar")
69
+ cb.replace(uniq_id, "bar")
82
70
  end
83
71
 
84
72
  def test_acceptable_keys
85
- connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
86
73
 
87
- cas = connection.set(uniq_id.to_sym, "bar")
74
+ cas = cb.set(uniq_id.to_sym, "bar")
88
75
  assert cas > 0
89
76
 
90
- cas = connection.set(uniq_id.to_s, "bar")
77
+ cas = cb.set(uniq_id.to_s, "bar")
91
78
  assert cas > 0
92
79
 
93
80
  assert_raises(TypeError) do
94
- connection.set(nil, "bar")
81
+ cb.set(nil, "bar")
95
82
  end
96
83
 
97
84
  obj = {:foo => "bar", :baz => 1}
98
85
  assert_raises(TypeError) do
99
- connection.set(obj, "bar")
86
+ cb.set(obj, "bar")
100
87
  end
101
88
 
102
89
  class << obj
103
90
  alias :to_str :to_s
104
91
  end
105
92
 
106
- connection.set(obj, "bar")
93
+ cb.set(obj, "bar")
107
94
  assert cas > 0
108
95
  end
109
96
 
110
97
  def test_asynchronous_set
111
- connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
112
98
  ret = nil
113
- connection.run do |conn|
99
+ cb.run do |conn|
114
100
  conn.set(uniq_id("1"), "foo1") {|res| ret = res}
115
101
  conn.set(uniq_id("2"), "foo2") # ignore result
116
102
  end
@@ -123,72 +109,71 @@ class TestStore < MiniTest::Test
123
109
  end
124
110
 
125
111
  def test_it_raises_error_when_appending_or_prepending_to_missing_key
126
- skip
127
- connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
128
112
 
129
113
  assert_raises(Couchbase::Error::NotStored) do
130
- connection.append(uniq_id(:missing), "foo")
114
+ cb.append(uniq_id(:missing), "foo")
131
115
  end
132
116
 
133
117
  assert_raises(Couchbase::Error::NotStored) do
134
- connection.prepend(uniq_id(:missing), "foo")
118
+ cb.prepend(uniq_id(:missing), "foo")
135
119
  end
136
120
  end
137
121
 
138
122
  def test_append
139
- skip
140
- connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port, :default_format => :plain)
123
+ cb.default_format = :plain
141
124
 
142
- cas1 = connection.set(uniq_id, "foo")
125
+ cas1 = cb.set(uniq_id, "foo")
143
126
  assert cas1 > 0
144
- cas2 = connection.append(uniq_id, "bar")
127
+ cas2 = cb.append(uniq_id, "bar")
145
128
  assert cas2 > 0
146
129
  refute_equal cas2, cas1
147
130
 
148
- val = connection.get(uniq_id)
131
+ val = cb.get(uniq_id)
149
132
  assert_equal "foobar", val
133
+ ensure
134
+ cb.default_format = :document
150
135
  end
151
136
 
152
137
  def test_prepend
153
- skip
154
- connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port, :default_format => :plain)
138
+ skip 'Plain encoding isnt working correctly'
139
+ cb.default_format = :plain
155
140
 
156
- cas1 = connection.set(uniq_id, "foo")
141
+ cas1 = cb.set(uniq_id, "foo")
157
142
  assert cas1 > 0
158
- cas2 = connection.prepend(uniq_id, "bar")
143
+ cas2 = cb.prepend(uniq_id, "bar")
159
144
  assert cas2 > 0
160
145
  refute_equal cas2, cas1
161
146
 
162
- val = connection.get(uniq_id)
147
+ val = cb.get(uniq_id)
163
148
  assert_equal "barfoo", val
149
+ ensure
150
+ cb.default_format = :document
164
151
  end
165
152
 
166
153
  def test_set_with_prefix
167
154
  skip
168
155
  connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port, :key_prefix => "prefix:")
169
- connection.set(uniq_id(:foo), "bar")
170
- assert_equal "bar", connection.get(uniq_id(:foo))
156
+ cb.set(uniq_id(:foo), "bar")
157
+ assert_equal "bar", cb.get(uniq_id(:foo))
171
158
  expected = {uniq_id(:foo) => "bar"}
172
- assert_equal expected, connection.get(uniq_id(:foo), :assemble_hash => true)
159
+ assert_equal expected, cb.get(uniq_id(:foo), :assemble_hash => true)
173
160
 
174
161
  connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port, :key_prefix => nil)
175
162
  expected = {"prefix:#{uniq_id(:foo)}" => "bar"}
176
- assert_equal expected, connection.get("prefix:#{uniq_id(:foo)}", :assemble_hash => true)
163
+ assert_equal expected, cb.get("prefix:#{uniq_id(:foo)}", :assemble_hash => true)
177
164
  end
178
165
 
179
166
  ArbitraryData = Struct.new(:baz)
180
167
 
181
168
  def test_set_using_brackets
182
- connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
183
-
184
- connection[uniq_id(1)] = "foo"
185
- val = connection.get(uniq_id(1))
169
+ cb[uniq_id(1)] = "foo"
170
+ val = cb.get(uniq_id(1))
186
171
  assert_equal "foo", val
187
172
 
188
173
  # if RUBY_VERSION =~ /^1\.9/
189
174
  # eval <<-EOC
190
175
  # connection[uniq_id(3), :format => :marshal] = ArbitraryData.new("thing")
191
- # val = connection.get(uniq_id(3))
176
+ # val = cb.get(uniq_id(3))
192
177
  # assert val.is_a?(ArbitraryData)
193
178
  # assert_equal "thing", val.baz
194
179
  # EOC
@@ -196,21 +181,23 @@ class TestStore < MiniTest::Test
196
181
  end
197
182
 
198
183
  def test_multi_store
199
- connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port, :default_format => :plain)
200
- connection.add(uniq_id(:a) => "bbb", uniq_id(:z) => "yyy")
201
- assert_equal ["bbb", "yyy"], connection.get(uniq_id(:a), uniq_id(:z))
184
+ cb.default_format = :plain
185
+ cb.add(uniq_id(:a) => "bbb", uniq_id(:z) => "yyy")
186
+ assert_equal ["bbb", "yyy"], cb.get(uniq_id(:a), uniq_id(:z))
202
187
 
203
- # connection.prepend(uniq_id(:a) => "aaa", uniq_id(:z) => "xxx")
204
- # assert_equal ["aaabbb", "xxxyyy"], connection.get(uniq_id(:a), uniq_id(:z))
188
+ # cb.prepend(uniq_id(:a) => "aaa", uniq_id(:z) => "xxx")
189
+ # assert_equal ["aaabbb", "xxxyyy"], cb.get(uniq_id(:a), uniq_id(:z))
205
190
 
206
- # connection.append(uniq_id(:a) => "ccc", uniq_id(:z) => "zzz")
207
- # assert_equal ["aaabbbccc", "xxxyyyzzz"], connection.get(uniq_id(:a), uniq_id(:z))
191
+ # cb.append(uniq_id(:a) => "ccc", uniq_id(:z) => "zzz")
192
+ # assert_equal ["aaabbbccc", "xxxyyyzzz"], cb.get(uniq_id(:a), uniq_id(:z))
208
193
 
209
- # connection.replace(uniq_id(:a) => "foo", uniq_id(:z) => "bar")
210
- # assert_equal ["foo", "bar"], connection.get(uniq_id(:a), uniq_id(:z))
194
+ # cb.replace(uniq_id(:a) => "foo", uniq_id(:z) => "bar")
195
+ # assert_equal ["foo", "bar"], cb.get(uniq_id(:a), uniq_id(:z))
211
196
 
212
- res = connection.set(uniq_id(:a) => "bar", uniq_id(:z) => "foo")
213
- assert_equal ["bar", "foo"], connection.get(uniq_id(:a), uniq_id(:z))
197
+ res = cb.set(uniq_id(:a) => "bar", uniq_id(:z) => "foo")
198
+ assert_equal ["bar", "foo"], cb.get(uniq_id(:a), uniq_id(:z))
214
199
  assert res.is_a?(Hash)
200
+ ensure
201
+ cb.default_format = :document
215
202
  end
216
203
  end
data/test/test_timer.rb CHANGED
@@ -19,23 +19,15 @@ require File.join(File.dirname(__FILE__), 'setup')
19
19
 
20
20
  class TestTimer < MiniTest::Test
21
21
 
22
- def setup
23
- @mock = start_mock
24
- end
25
-
26
- def teardown
27
- stop_mock(@mock)
28
- end
29
-
30
22
  def test_initialization
31
- connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
23
+ skip
32
24
  num = 0
33
- connection.run do
25
+ cb.run do
34
26
  assert Couchbase::Timer.new(connection, 100) { num += 1}
35
- assert connection.create_timer(100) { num += 1}
27
+ assert cb.create_timer(100) { num += 1}
36
28
 
37
29
  assert Couchbase::Timer.new(connection, 100, :periodic => true) {|t| num += 1; t.cancel}
38
- assert connection.create_periodic_timer(100) {|t| num += 1; t.cancel}
30
+ assert cb.create_periodic_timer(100) {|t| num += 1; t.cancel}
39
31
  end
40
32
  assert_equal 4, num
41
33
  end
data/test/test_touch.rb CHANGED
@@ -19,79 +19,72 @@ require File.join(File.dirname(__FILE__), 'setup')
19
19
 
20
20
  class TestTouch < MiniTest::Test
21
21
 
22
- def setup
23
- @mock = start_mock
24
- end
25
-
26
- def teardown
27
- stop_mock(@mock)
28
- end
29
-
30
22
  def test_trivial_touch
31
- connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
32
- connection.set(uniq_id, "bar", :ttl => 1)
33
- connection.touch(uniq_id, :ttl => 2)
23
+ cb.set(uniq_id, "bar", :ttl => 1)
24
+ cb.touch(uniq_id, :ttl => 2)
34
25
  sleep(1)
35
- assert connection.get(uniq_id)
26
+ assert cb.get(uniq_id)
36
27
  sleep(2)
37
28
  assert_raises(Couchbase::Error::NotFound) do
38
- connection.get(uniq_id)
29
+ cb.get(uniq_id)
39
30
  end
40
31
  end
41
32
 
42
33
  def test_multi_touch
43
- connection = Couchbase.new(:port => @mock.port)
44
- connection.set(uniq_id(1), "bar")
45
- connection.set(uniq_id(2), "baz")
46
- ret = connection.touch(uniq_id(1) => 1, uniq_id(2) => 1)
34
+ cb.set(uniq_id(1), "bar")
35
+ cb.set(uniq_id(2), "baz")
36
+ ret = cb.touch(uniq_id(1) => 1, uniq_id(2) => 1)
47
37
  assert ret[uniq_id(1)]
48
38
  assert ret[uniq_id(2)]
49
39
  sleep(2)
50
40
  assert_raises(Couchbase::Error::NotFound) do
51
- connection.get(uniq_id(1))
41
+ cb.get(uniq_id(1))
52
42
  end
53
43
  assert_raises(Couchbase::Error::NotFound) do
54
- connection.get(uniq_id(2))
44
+ cb.get(uniq_id(2))
55
45
  end
56
46
  end
57
47
 
58
48
  def test_it_uses_default_ttl_for_touch
59
- connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port, :default_ttl => 1)
60
- connection.set(uniq_id, "bar", :ttl => 10)
61
- connection.touch(uniq_id)
49
+ cb.default_ttl = 1
50
+ cb.set(uniq_id, "bar", :ttl => 10)
51
+ cb.touch(uniq_id)
62
52
  sleep(2)
63
53
  assert_raises(Couchbase::Error::NotFound) do
64
- connection.get(uniq_id)
54
+ cb.get(uniq_id)
65
55
  end
56
+ ensure
57
+ cb.default_ttl = 0
66
58
  end
67
59
 
68
60
  def test_it_accepts_ttl_for_get_command
69
- connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
70
- connection.set(uniq_id, "bar", :ttl => 10)
71
- val = connection.get(uniq_id, :ttl => 1)
61
+ cb.set(uniq_id, "bar", :ttl => 10)
62
+ val = cb.get(uniq_id, :ttl => 1)
72
63
  assert_equal "bar", val
73
64
  sleep(2)
74
65
  assert_raises(Couchbase::Error::NotFound) do
75
- connection.get(uniq_id)
66
+ cb.get(uniq_id)
76
67
  end
77
68
  end
78
69
 
79
70
  def test_missing_in_quiet_mode
80
- connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port, :quiet => true)
81
- cas1 = connection.set(uniq_id(1), "foo1")
82
- cas2 = connection.set(uniq_id(2), "foo2")
71
+ cb.quiet = true
72
+ cas1 = cb.set(uniq_id(1), "foo1")
73
+ cas2 = cb.set(uniq_id(2), "foo2")
83
74
 
84
75
  assert_raises(Couchbase::Error::NotFound) do
85
- connection.touch(uniq_id(:missing), :quiet => false)
76
+ cb.touch(uniq_id(:missing), :quiet => false)
86
77
  end
87
78
 
88
- val = connection.touch(uniq_id(:missing))
79
+ val = cb.touch(uniq_id(:missing))
89
80
  refute(val)
90
81
 
91
- ret = connection.touch(uniq_id(1), uniq_id(:missing), uniq_id(2))
82
+ ret = cb.touch(uniq_id(1), uniq_id(:missing), uniq_id(2))
92
83
  assert_equal true, ret[uniq_id(1)]
93
84
  assert_equal false, ret[uniq_id(:missing)]
94
85
  assert_equal true, ret[uniq_id(2)]
86
+ ensure
87
+ cb.quiet = false
95
88
  end
96
89
 
97
90
  end
data/test/test_unlock.rb CHANGED
@@ -19,101 +19,70 @@ require File.join(File.dirname(__FILE__), 'setup')
19
19
 
20
20
  class TestUnlock < MiniTest::Test
21
21
 
22
- def setup
23
- @mock = start_mock
24
- end
25
-
26
- def teardown
27
- stop_mock(@mock)
28
- end
29
-
30
22
  def test_trivial_unlock
31
- if @mock.real?
32
- connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
33
- connection.set(uniq_id, "foo")
34
- _, _, cas = connection.get(uniq_id, :lock => true, :extended => true)
35
- assert_raises Couchbase::Error::KeyExists do
36
- connection.set(uniq_id, "bar")
37
- end
38
- assert connection.unlock(uniq_id, :cas => cas)
39
- connection.set(uniq_id, "bar")
40
- else
41
- skip("GETL and UNL aren't implemented in CouchbaseMock.jar yet")
23
+ cb.set(uniq_id, "foo")
24
+ _, _, cas = cb.get(uniq_id, :lock => true, :extended => true)
25
+ assert_raises Couchbase::Error::KeyExists do
26
+ cb.set(uniq_id, "bar")
42
27
  end
28
+ assert cb.unlock(uniq_id, :cas => cas)
29
+ cb.set(uniq_id, "bar")
43
30
  end
44
31
 
45
32
  def test_alternative_syntax_for_single_key
46
- if @mock.real?
47
- connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
48
- connection.set(uniq_id, "foo")
49
- _, _, cas = connection.get(uniq_id, :lock => true, :extended => true)
50
- assert_raises Couchbase::Error::KeyExists do
51
- connection.set(uniq_id, "bar")
52
- end
53
- assert connection.unlock(uniq_id, cas)
54
- connection.set(uniq_id, "bar")
55
- else
56
- skip("GETL and UNL aren't implemented in CouchbaseMock.jar yet")
33
+ cb.set(uniq_id, "foo")
34
+ _, _, cas = cb.get(uniq_id, :lock => true, :extended => true)
35
+ assert_raises Couchbase::Error::KeyExists do
36
+ cb.set(uniq_id, "bar")
57
37
  end
38
+ assert cb.unlock(uniq_id, cas)
39
+ cb.set(uniq_id, "bar")
58
40
  end
59
41
 
60
42
  def test_multiple_unlock
61
- if @mock.real?
62
- connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
63
- connection.set(uniq_id(1), "foo")
64
- connection.set(uniq_id(2), "foo")
65
- info = connection.get(uniq_id(1), uniq_id(2), :lock => true, :extended => true)
66
- assert_raises Couchbase::Error::KeyExists do
67
- connection.set(uniq_id(1), "bar")
68
- end
69
- assert_raises Couchbase::Error::KeyExists do
70
- connection.set(uniq_id(2), "bar")
71
- end
72
- ret = connection.unlock(uniq_id(1) => info[uniq_id(1)][2],
73
- uniq_id(2) => info[uniq_id(2)][2])
74
- assert ret[uniq_id(1)]
75
- assert ret[uniq_id(2)]
76
- connection.set(uniq_id(1), "bar")
77
- connection.set(uniq_id(2), "bar")
78
- else
79
- skip("GETL and UNL aren't implemented in CouchbaseMock.jar yet")
43
+ skip
44
+ cb.set(uniq_id(1), "foo")
45
+ cb.set(uniq_id(2), "foo")
46
+ info = cb.get(uniq_id(1), uniq_id(2), :lock => true, :extended => true)
47
+ assert_raises Couchbase::Error::KeyExists do
48
+ cb.set(uniq_id(1), "bar")
49
+ end
50
+ assert_raises Couchbase::Error::KeyExists do
51
+ cb.set(uniq_id(2), "bar")
80
52
  end
53
+ ret = cb.unlock(uniq_id(1) => info[uniq_id(1)][2],
54
+ uniq_id(2) => info[uniq_id(2)][2])
55
+ assert ret[uniq_id(1)]
56
+ assert ret[uniq_id(2)]
57
+ cb.set(uniq_id(1), "bar")
58
+ cb.set(uniq_id(2), "bar")
81
59
  end
82
60
 
83
61
  def test_quiet_mode
84
- if @mock.real?
85
- connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
86
- connection.set(uniq_id, "foo")
87
- _, _, cas = connection.get(uniq_id, :lock => true, :extended => true)
88
- assert_raises Couchbase::Error::NotFound do
89
- connection.unlock(uniq_id(:missing), :cas => 0xdeadbeef)
90
- end
91
- keys = {
92
- uniq_id => cas,
93
- uniq_id(:missing) => 0xdeadbeef
94
- }
95
- ret = connection.unlock(keys, :quiet => true)
96
- assert ret[uniq_id]
97
- refute ret[uniq_id(:missing)]
98
- else
99
- skip("GETL and UNL aren't implemented in CouchbaseMock.jar yet")
62
+ skip
63
+ cb.set(uniq_id, "foo")
64
+ _, _, cas = cb.get(uniq_id, :lock => true, :extended => true)
65
+ assert_raises Couchbase::Error::NotFound do
66
+ cb.unlock(uniq_id(:missing), :cas => 0xdeadbeef)
100
67
  end
68
+ keys = {
69
+ uniq_id => cas,
70
+ uniq_id(:missing) => 0xdeadbeef
71
+ }
72
+ ret = cb.unlock(keys, :quiet => true)
73
+ assert ret[uniq_id]
74
+ refute ret[uniq_id(:missing)]
101
75
  end
102
76
 
103
77
  def test_tmp_failure
104
- if @mock.real?
105
- connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
106
- cas1 = connection.set(uniq_id(1), "foo")
107
- cas2 = connection.set(uniq_id(2), "foo")
108
- connection.get(uniq_id(1), :lock => true) # get with lock will update CAS
109
- assert_raises Couchbase::Error::TemporaryFail do
110
- connection.unlock(uniq_id(1), cas1)
111
- end
112
- assert_raises Couchbase::Error::TemporaryFail do
113
- connection.unlock(uniq_id(2), cas2)
114
- end
115
- else
116
- skip("GETL and UNL aren't implemented in CouchbaseMock.jar yet")
78
+ cas1 = cb.set(uniq_id(1), "foo")
79
+ cas2 = cb.set(uniq_id(2), "foo")
80
+ cb.get(uniq_id(1), :lock => true) # get with lock will update CAS
81
+ assert_raises Couchbase::Error::TemporaryFail do
82
+ cb.unlock(uniq_id(1), cas1)
83
+ end
84
+ assert_raises Couchbase::Error::TemporaryFail do
85
+ cb.unlock(uniq_id(2), cas2)
117
86
  end
118
87
  end
119
88
  end
data/test/test_utils.rb CHANGED
@@ -19,14 +19,6 @@ require File.join(File.dirname(__FILE__), 'setup')
19
19
 
20
20
  class TestUtils < MiniTest::Test
21
21
 
22
- def setup
23
- @mock = start_mock
24
- end
25
-
26
- def teardown
27
- stop_mock(@mock)
28
- end
29
-
30
22
  def test_complex_startkey
31
23
  assert_equal "all_docs?startkey=%5B%22Deadmau5%22%2C%22%22%5D", Couchbase::Utils.build_query("all_docs", :startkey => ["Deadmau5", ""])
32
24
  end
@@ -38,12 +30,11 @@ class TestUtils < MiniTest::Test
38
30
  raise ArgumentError, "cannot accept your object"
39
31
  end
40
32
  end
41
- connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
42
33
  assert_raises(Couchbase::Error::ValueFormat) do
43
- connection.set(uniq_id, "foo")
34
+ cb.set(uniq_id, "foo")
44
35
  end
45
36
  begin
46
- connection.set(uniq_id, "foo")
37
+ cb.set(uniq_id, "foo")
47
38
  rescue Couchbase::Error::ValueFormat => ex
48
39
  assert_match /cannot accept your object/, ex.to_s
49
40
  assert_instance_of ArgumentError, ex.inner_exception
data/test/test_version.rb CHANGED
@@ -19,31 +19,22 @@ require File.join(File.dirname(__FILE__), 'setup')
19
19
 
20
20
  class TestVersion < MiniTest::Test
21
21
 
22
- def setup
23
- @mock = start_mock
24
- end
25
-
26
- def teardown
27
- stop_mock(@mock)
28
- end
29
-
30
22
  def test_sync_version
31
- connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
32
- ver = connection.version
23
+ ver = cb.version
33
24
  assert ver.is_a?(Hash)
34
- assert_equal @mock.num_nodes, ver.size
25
+ assert_equal 1, ver.size
35
26
  end
36
27
 
37
28
  def test_async_version
38
- connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
29
+ skip
39
30
  ver = {}
40
- connection.run do |conn|
31
+ cb.run do |conn|
41
32
  conn.version do |ret|
42
33
  assert ret.success?
43
34
  ver[ret.node] = ret.value
44
35
  end
45
36
  end
46
- assert_equal @mock.num_nodes, ver.size
37
+ assert_equal 1, ver.size
47
38
  ver.each do |node, v|
48
39
  assert v.is_a?(String)
49
40
  end