couchbase-jruby-client 0.1.7-java → 0.1.8-java

Sign up to get free protection for your applications and to get access to all the features.
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
- skip
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
- skip
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
- end
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
- res = []
155
+ ret = nil
156
156
 
157
- suite = lambda do |conn|
158
- res.clear
159
- conn.get(uniq_id) # ignore result
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
- checks = lambda do
166
- res.each do |r|
167
- assert r.is_a?(Couchbase::Result)
168
- assert r.success?
169
- assert_equal uniq_id, r.key
170
- assert_equal "foo", r.value
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
- cb.run{ suite.call(cb) }
179
- checks.call
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
@@ -30,6 +30,8 @@ class TestStats < MiniTest::Test
30
30
  end
31
31
 
32
32
  def test_stats_with_argument
33
+ skip unless $mock.real?
34
+
33
35
  stats = cb.stats("memory")
34
36
  assert stats.is_a?(Hash)
35
37
  assert stats.has_key?("mem_used")
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.run do |conn|
96
- conn.set(uniq_id("1"), "foo1") {|res| ret = res}
97
- conn.set(uniq_id("2"), "foo2") # ignore result
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("1"), ret.key
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
- def test_it_raises_error_when_appending_or_prepending_to_missing_key
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
@@ -75,6 +75,7 @@ class TestUnlock < MiniTest::Test
75
75
  end
76
76
 
77
77
  def test_tmp_failure
78
+ skip unless $mock.real?
78
79
  cas1 = cb.set(uniq_id(1), "foo")
79
80
  cas2 = cb.set(uniq_id(2), "foo")
80
81
  cb.get(uniq_id(1), :lock => true) # get with lock will update CAS
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
- @path = '_design/users/_view/by_age'
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
- @view = Couchbase::View.new(cb, @path)
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
- assert_equal 'users', @view.design_doc
33
- assert_equal 'by_age', @view.name
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
- assert results = @view.fetch
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
- assert results = @view.fetch(stale: false)
43
- assert results.first.is_a?(Couchbase::ViewRow)
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
- assert results = @view.fetch(stale: false, include_docs: true)
53
- assert results.is_a?(Array)
54
- assert results.first.doc.is_a?(Hash)
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
- refute @view.fetch(stale: false, include_docs: true) { |row|
59
- assert row.is_a?(Couchbase::ViewRow)
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
- assert results.first.is_a?(Couchbase::ViewRow)
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.7
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-10 00:00:00.000000000 Z
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
@@ -1,2 +0,0 @@
1
- service_name: travis-pro
2
- repo_token: YXFMm3Og960X2Ndrj3eome2KFIjlAlJ77