couchbase-jruby-client 0.1.7-java → 0.1.8-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.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/.ruby-version +1 -1
- data/.travis.yml +0 -8
- data/Rakefile +2 -6
- data/lib/couchbase/async/callback.rb +22 -3
- data/lib/couchbase/async.rb +3 -128
- data/lib/couchbase/bucket.rb +27 -224
- data/lib/couchbase/operations/arithmetic.rb +26 -54
- data/lib/couchbase/operations/delete.rb +25 -31
- data/lib/couchbase/operations/fetch.rb +3 -2
- data/lib/couchbase/operations/get.rb +5 -9
- data/lib/couchbase/operations/stats.rb +0 -1
- data/lib/couchbase/operations/store.rb +4 -33
- data/lib/couchbase/operations/touch.rb +5 -18
- data/lib/couchbase/operations/utils.rb +0 -4
- data/lib/couchbase/transcoder.rb +5 -3
- data/lib/couchbase/version.rb +1 -1
- data/lib/couchbase/view.rb +23 -12
- data/lib/couchbase/view_row.rb +4 -3
- data/lib/couchbase.rb +4 -2
- data/tasks/benchmark.rake +6 -0
- data/tasks/test.rake +34 -0
- data/tasks/util.rake +21 -0
- data/test/mock.rb +85 -0
- data/test/setup.rb +12 -7
- data/test/test_arithmetic.rb +1 -0
- data/test/test_async.rb +265 -262
- data/test/test_bucket.rb +12 -0
- data/test/test_delete.rb +16 -3
- data/test/test_design_docs.rb +5 -0
- data/test/test_errors.rb +1 -0
- data/test/test_format.rb +6 -15
- data/test/test_get.rb +14 -22
- data/test/test_stats.rb +2 -0
- data/test/test_store.rb +12 -6
- data/test/test_unlock.rb +1 -0
- data/test/test_view.rb +55 -14
- metadata +7 -3
- data/.coveralls.yml +0 -2
data/test/test_format.rb
CHANGED
@@ -30,7 +30,6 @@ class TestFormat < MiniTest::Test
|
|
30
30
|
assert_equal :document, cb.default_format
|
31
31
|
cb.set(uniq_id, orig_doc)
|
32
32
|
doc, flags, cas = cb.get(uniq_id, :extended => true)
|
33
|
-
# assert_equal 0x00, flags & 0x11
|
34
33
|
assert doc.is_a?(Hash)
|
35
34
|
assert_equal 'Twoflower', doc['name']
|
36
35
|
assert_equal 'The tourist', doc['role']
|
@@ -67,15 +66,13 @@ class TestFormat < MiniTest::Test
|
|
67
66
|
orig_doc = ArbitraryClass.new("Twoflower", "The tourist")
|
68
67
|
cb.set(uniq_id, orig_doc, :format => :marshal)
|
69
68
|
doc, flags, cas = cb.get(uniq_id, :extended => true)
|
70
|
-
# assert_equal Couchbase::Bucket::FMT_MARSHAL, flags & Couchbase::Bucket::FMT_MASK
|
71
69
|
assert doc.is_a?(ArbitraryClass)
|
72
70
|
assert_equal 'Twoflower', doc.name
|
73
71
|
assert_equal 'The tourist', doc.role
|
74
72
|
end
|
75
73
|
|
76
74
|
def test_it_accepts_only_string_in_plain_mode
|
77
|
-
|
78
|
-
connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port, :default_format => :plain)
|
75
|
+
cb.default_format = :plain
|
79
76
|
cb.set(uniq_id, "1")
|
80
77
|
|
81
78
|
assert_raises(Couchbase::Error::ValueFormat) do
|
@@ -85,25 +82,19 @@ class TestFormat < MiniTest::Test
|
|
85
82
|
assert_raises(Couchbase::Error::ValueFormat) do
|
86
83
|
cb.set(uniq_id, {:foo => "bar"})
|
87
84
|
end
|
85
|
+
ensure
|
86
|
+
cb.default_format = :document
|
88
87
|
end
|
89
88
|
|
90
89
|
def test_bignum_conversion
|
91
|
-
|
92
|
-
connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port, :default_format => :plain)
|
90
|
+
cb.default_format = :plain
|
93
91
|
cas = 0xffff_ffff_ffff_ffff
|
94
92
|
assert cas.is_a?(Bignum)
|
95
93
|
assert_raises(Couchbase::Error::NotFound) do
|
96
94
|
cb.delete(uniq_id => cas)
|
97
95
|
end
|
98
|
-
|
99
|
-
|
100
|
-
def test_it_allows_to_turn_off_transcoder
|
101
|
-
skip
|
102
|
-
connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port, :transcoder => nil)
|
103
|
-
cb.set(uniq_id, "value", :flags => 0xffff_ffff)
|
104
|
-
doc, flags, _ = cb.get(uniq_id, :extended => true)
|
105
|
-
assert_equal "value", doc
|
106
|
-
assert_equal 0xffff_ffff, flags
|
96
|
+
ensure
|
97
|
+
cb.default_format = :document
|
107
98
|
end
|
108
99
|
|
109
100
|
require 'zlib'
|
data/test/test_get.rb
CHANGED
@@ -152,31 +152,23 @@ class TestGet < MiniTest::Test
|
|
152
152
|
|
153
153
|
def test_asynchronous_get
|
154
154
|
cas = cb.set(uniq_id, "foo")
|
155
|
-
|
155
|
+
ret = nil
|
156
156
|
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
conn.get(uniq_id) {|ret| res << ret}
|
161
|
-
handler = lambda {|ret| res << ret}
|
162
|
-
conn.get(uniq_id, &handler)
|
163
|
-
end
|
157
|
+
future = cb.async_get(uniq_id) { |res| ret = res }
|
158
|
+
future.get
|
159
|
+
sleep 0.1
|
164
160
|
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
# assert_equal cas, r.cas TODO: GetFuture does not hold CAS
|
172
|
-
end
|
173
|
-
end
|
174
|
-
|
175
|
-
cb.run(&suite)
|
176
|
-
checks.call
|
161
|
+
assert ret.is_a?(Couchbase::Result)
|
162
|
+
assert ret.success?
|
163
|
+
assert_equal uniq_id, ret.key
|
164
|
+
assert_equal :get, ret.operation
|
165
|
+
assert_equal "foo", ret.value
|
166
|
+
end
|
177
167
|
|
178
|
-
|
179
|
-
|
168
|
+
def test_asynchronous_get_without_block
|
169
|
+
assert_raises ArgumentError do
|
170
|
+
cb.async_get(uniq_id)
|
171
|
+
end
|
180
172
|
end
|
181
173
|
|
182
174
|
def test_asynchronous_multi_get
|
data/test/test_stats.rb
CHANGED
data/test/test_store.rb
CHANGED
@@ -92,20 +92,26 @@ class TestStore < MiniTest::Test
|
|
92
92
|
|
93
93
|
def test_asynchronous_set
|
94
94
|
ret = nil
|
95
|
-
cb.
|
96
|
-
|
97
|
-
|
98
|
-
end
|
95
|
+
future = cb.async_set(uniq_id, "foo1") { |res| ret = res }
|
96
|
+
future.get
|
97
|
+
sleep 0.1
|
99
98
|
|
100
99
|
assert ret.is_a?(Couchbase::Result)
|
101
100
|
assert ret.success?
|
102
|
-
assert_equal uniq_id
|
101
|
+
assert_equal uniq_id, ret.key
|
103
102
|
assert_equal :set, ret.operation
|
104
103
|
assert ret.cas.is_a?(Numeric)
|
105
104
|
end
|
106
105
|
|
107
|
-
|
106
|
+
def test_asynchronous_set_wtihout_block
|
107
|
+
future = cb.async_set(uniq_id, 'fu')
|
108
|
+
future.get
|
109
|
+
sleep 0.1
|
108
110
|
|
111
|
+
assert_equal 'fu', cb.get(uniq_id)
|
112
|
+
end
|
113
|
+
|
114
|
+
def test_it_raises_error_when_appending_or_prepending_to_missing_key
|
109
115
|
assert_raises(Couchbase::Error::NotStored) do
|
110
116
|
cb.append(uniq_id(:missing), "foo")
|
111
117
|
end
|
data/test/test_unlock.rb
CHANGED
data/test/test_view.rb
CHANGED
@@ -20,27 +20,38 @@ require File.join(File.dirname(__FILE__), 'setup')
|
|
20
20
|
class TestView < MiniTest::Test
|
21
21
|
|
22
22
|
def setup
|
23
|
-
|
23
|
+
return unless $mock.real?
|
24
|
+
|
24
25
|
cb.save_design_doc(design_doc)
|
25
26
|
{ bob: 32, frank: 25, sam: 42, fred: 21 }.each_pair do |name, age|
|
26
27
|
cb.set(name, { type: 'user', name: name, age: age })
|
27
28
|
end
|
28
|
-
|
29
|
+
end
|
30
|
+
|
31
|
+
def view
|
32
|
+
@view ||= Couchbase::View.new(cb, '_design/users/_view/by_age')
|
33
|
+
end
|
34
|
+
|
35
|
+
def reduce_view
|
36
|
+
@reduce_view ||= Couchbase::View.new(cb, '_design/users/_view/all')
|
29
37
|
end
|
30
38
|
|
31
39
|
def test_initialize
|
32
|
-
|
33
|
-
assert_equal '
|
40
|
+
skip unless $mock.real?
|
41
|
+
assert_equal 'users', view.design_doc
|
42
|
+
assert_equal 'by_age', view.name
|
34
43
|
end
|
35
44
|
|
36
45
|
def test_simple_fetch
|
37
|
-
|
46
|
+
skip unless $mock.real?
|
47
|
+
assert results = view.fetch
|
38
48
|
assert results.is_a?(Couchbase::View::ArrayWithTotalRows)
|
39
49
|
end
|
40
50
|
|
41
51
|
def test_fetch_without_stale
|
42
|
-
|
43
|
-
assert results.
|
52
|
+
skip unless $mock.real?
|
53
|
+
assert results = view.fetch(stale: false)
|
54
|
+
assert_instance_of Couchbase::ViewRow, results.first
|
44
55
|
assert results.first.doc.nil?
|
45
56
|
assert_equal 4, results.total_rows
|
46
57
|
results.each do |result|
|
@@ -49,22 +60,44 @@ class TestView < MiniTest::Test
|
|
49
60
|
end
|
50
61
|
|
51
62
|
def test_fetch_with_docs
|
52
|
-
|
53
|
-
assert results.
|
54
|
-
|
63
|
+
skip unless $mock.real?
|
64
|
+
assert results = view.fetch(stale: false, include_docs: true)
|
65
|
+
assert_instance_of Couchbase::View::ArrayWithTotalRows, results
|
66
|
+
assert_instance_of Hash, results.first.doc
|
55
67
|
end
|
56
68
|
|
57
69
|
def test_fetch_with_block
|
58
|
-
|
59
|
-
|
70
|
+
skip unless $mock.real?
|
71
|
+
refute view.fetch(stale: false, include_docs: true) { |row|
|
72
|
+
assert_instance_of Couchbase::ViewRow, row
|
60
73
|
assert row.doc['name'].is_a?(String)
|
61
74
|
assert row.doc['age'].is_a?(Fixnum)
|
62
75
|
}
|
63
76
|
end
|
64
77
|
|
78
|
+
def test_fetch_reduce
|
79
|
+
skip unless $mock.real?
|
80
|
+
assert results = reduce_view.fetch(stale: false, include_docs: false)
|
81
|
+
assert_instance_of Couchbase::ViewRow, results.first
|
82
|
+
assert_equal 4, results.first.value
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_fetch_without_reduce
|
86
|
+
skip unless $mock.real?
|
87
|
+
assert results = reduce_view.fetch(stale: false, reduce: false)
|
88
|
+
assert_instance_of Couchbase::ViewRow, results.first
|
89
|
+
assert results.first.doc.nil?
|
90
|
+
assert_equal 4, results.total_rows
|
91
|
+
results.each do |result|
|
92
|
+
%w(bob frank sam fred).include?(result.key)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
65
96
|
def test_design_doc_access
|
97
|
+
skip unless $mock.real?
|
98
|
+
view.fetch(stale: false, include_docs: true)
|
66
99
|
assert results = cb.design_docs['users'].by_age.to_a
|
67
|
-
|
100
|
+
assert_instance_of Couchbase::ViewRow, results.first
|
68
101
|
end
|
69
102
|
|
70
103
|
def design_doc
|
@@ -79,9 +112,17 @@ class TestView < MiniTest::Test
|
|
79
112
|
emit(meta.id, doc.age);
|
80
113
|
}
|
81
114
|
JS
|
115
|
+
},
|
116
|
+
'all' => {
|
117
|
+
'reduce' => '_count',
|
118
|
+
'map' => <<-JS
|
119
|
+
function (doc, meta) {
|
120
|
+
if (doc.type && doc.type == 'user')
|
121
|
+
emit(meta.id, null);
|
122
|
+
}
|
123
|
+
JS
|
82
124
|
}
|
83
125
|
}
|
84
126
|
}
|
85
127
|
end
|
86
|
-
|
87
128
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: couchbase-jruby-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Mike Evans
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-12-
|
11
|
+
date: 2013-12-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multi_json
|
@@ -115,7 +115,6 @@ executables: []
|
|
115
115
|
extensions: []
|
116
116
|
extra_rdoc_files: []
|
117
117
|
files:
|
118
|
-
- .coveralls.yml
|
119
118
|
- .gitignore
|
120
119
|
- .jrubyrc
|
121
120
|
- .ruby-version
|
@@ -163,6 +162,10 @@ files:
|
|
163
162
|
- lib/jars/spymemcached-2.10.3-javadoc.jar
|
164
163
|
- lib/jars/spymemcached-2.10.3-sources.jar
|
165
164
|
- lib/jars/spymemcached-2.10.3.jar
|
165
|
+
- tasks/benchmark.rake
|
166
|
+
- tasks/test.rake
|
167
|
+
- tasks/util.rake
|
168
|
+
- test/mock.rb
|
166
169
|
- test/profile/.gitignore
|
167
170
|
- test/profile/.jrubyrc
|
168
171
|
- test/profile/Gemfile
|
@@ -216,6 +219,7 @@ signing_key:
|
|
216
219
|
specification_version: 4
|
217
220
|
summary: The unofficial jruby client library for use with Couchbase Server.
|
218
221
|
test_files:
|
222
|
+
- test/mock.rb
|
219
223
|
- test/profile/.gitignore
|
220
224
|
- test/profile/.jrubyrc
|
221
225
|
- test/profile/Gemfile
|
data/.coveralls.yml
DELETED