couchbase 1.1.0-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,57 @@
1
+ # Author:: Couchbase <info@couchbase.com>
2
+ # Copyright:: 2011, 2012 Couchbase, Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ require File.join(File.dirname(__FILE__), 'setup')
19
+
20
+ class TestStats < MiniTest::Unit::TestCase
21
+
22
+ def setup
23
+ @mock = start_mock(:num_nodes => 4)
24
+ end
25
+
26
+ def teardown
27
+ stop_mock(@mock)
28
+ end
29
+
30
+ def test_trivial_stats_without_argument
31
+ connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
32
+ stats = connection.stats
33
+ assert stats.is_a?(Hash)
34
+ assert stats.has_key?("pid")
35
+ key, info = stats.first
36
+ assert key.is_a?(String)
37
+ assert info.is_a?(Hash)
38
+ assert_equal @mock.num_nodes, info.size
39
+ end
40
+
41
+ def test_stats_with_argument
42
+ if @mock.real?
43
+ connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
44
+ stats = connection.stats("memory")
45
+ assert stats.is_a?(Hash)
46
+ assert stats.has_key?("mem_used")
47
+ key, info = stats.first
48
+ assert key.is_a?(String)
49
+ assert info.is_a?(Hash)
50
+ assert_equal @mock.num_nodes, info.size
51
+ else
52
+ # FIXME
53
+ skip("make CouchbaseMock.jar STATS more real-life")
54
+ end
55
+ end
56
+
57
+ end
@@ -0,0 +1,186 @@
1
+ # Author:: Couchbase <info@couchbase.com>
2
+ # Copyright:: 2011, 2012 Couchbase, Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ require File.join(File.dirname(__FILE__), 'setup')
19
+
20
+ class TestStore < MiniTest::Unit::TestCase
21
+
22
+ def setup
23
+ @mock = start_mock
24
+ end
25
+
26
+ def teardown
27
+ stop_mock(@mock)
28
+ end
29
+
30
+ def test_trivial_set
31
+ connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
32
+ cas = connection.set(uniq_id, "bar")
33
+ assert(cas > 0)
34
+ end
35
+
36
+ def test_set_with_cas
37
+ connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
38
+
39
+ cas1 = connection.set(uniq_id, "bar1")
40
+ assert cas1 > 0
41
+
42
+ assert_raises(Couchbase::Error::KeyExists) do
43
+ connection.set(uniq_id, "bar2", :cas => cas1+1)
44
+ end
45
+
46
+ cas2 = connection.set(uniq_id, "bar2", :cas => cas1)
47
+ assert cas2 > 0
48
+ refute_equal cas2, cas1
49
+
50
+ cas3 = connection.set(uniq_id, "bar3")
51
+ assert cas3 > 0
52
+ refute_equal cas3, cas2
53
+ refute_equal cas3, cas1
54
+ end
55
+
56
+ def test_add
57
+ connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
58
+
59
+ cas1 = connection.add(uniq_id, "bar")
60
+ assert cas1 > 0
61
+
62
+ assert_raises(Couchbase::Error::KeyExists) do
63
+ connection.add(uniq_id, "bar")
64
+ end
65
+
66
+ assert_raises(Couchbase::Error::KeyExists) do
67
+ connection.add(uniq_id, "bar", :cas => cas1)
68
+ end
69
+ end
70
+
71
+ def test_replace
72
+ connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
73
+
74
+ assert_raises(Couchbase::Error::NotFound) do
75
+ connection.replace(uniq_id, "bar")
76
+ end
77
+
78
+ cas1 = connection.set(uniq_id, "bar")
79
+ assert cas1 > 0
80
+
81
+ connection.replace(uniq_id, "bar")
82
+ end
83
+
84
+ def test_acceptable_keys
85
+ connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
86
+
87
+ cas = connection.set(uniq_id.to_sym, "bar")
88
+ assert cas > 0
89
+
90
+ cas = connection.set(uniq_id.to_s, "bar")
91
+ assert cas > 0
92
+
93
+ assert_raises(TypeError) do
94
+ connection.set(nil, "bar")
95
+ end
96
+
97
+ obj = {:foo => "bar", :baz => 1}
98
+ assert_raises(TypeError) do
99
+ connection.set(obj, "bar")
100
+ end
101
+
102
+ class << obj
103
+ alias :to_str :to_s
104
+ end
105
+
106
+ connection.set(obj, "bar")
107
+ assert cas > 0
108
+ end
109
+
110
+ def test_asynchronous_set
111
+ connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
112
+ ret = nil
113
+ connection.run do |conn|
114
+ conn.set(uniq_id("1"), "foo1") {|res| ret = res}
115
+ conn.set(uniq_id("2"), "foo2") # ignore result
116
+ assert_equal 2, conn.seqno
117
+ end
118
+ assert ret.is_a?(Couchbase::Result)
119
+ assert ret.success?
120
+ assert_equal uniq_id("1"), ret.key
121
+ assert_equal :set, ret.operation
122
+ assert ret.cas.is_a?(Numeric)
123
+ end
124
+
125
+ def test_it_raises_error_when_appending_or_prepending_to_missing_key
126
+ connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
127
+
128
+ assert_raises(Couchbase::Error::NotStored) do
129
+ connection.append(uniq_id(:missing), "foo")
130
+ end
131
+
132
+ assert_raises(Couchbase::Error::NotStored) do
133
+ connection.prepend(uniq_id(:missing), "foo")
134
+ end
135
+ end
136
+
137
+ def test_append
138
+ connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port, :default_format => :plain)
139
+
140
+ cas1 = connection.set(uniq_id, "foo")
141
+ assert cas1 > 0
142
+ cas2 = connection.append(uniq_id, "bar")
143
+ assert cas2 > 0
144
+ refute_equal cas2, cas1
145
+
146
+ val = connection.get(uniq_id)
147
+ assert_equal "foobar", val
148
+ end
149
+
150
+ def test_prepend
151
+ connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port, :default_format => :plain)
152
+
153
+ cas1 = connection.set(uniq_id, "foo")
154
+ assert cas1 > 0
155
+ cas2 = connection.prepend(uniq_id, "bar")
156
+ assert cas2 > 0
157
+ refute_equal cas2, cas1
158
+
159
+ val = connection.get(uniq_id)
160
+ assert_equal "barfoo", val
161
+ end
162
+
163
+ ArbitraryData = Struct.new(:baz)
164
+
165
+ def test_set_using_brackets
166
+ connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
167
+
168
+ connection[uniq_id(1)] = "foo"
169
+ val = connection.get(uniq_id(1))
170
+ assert_equal "foo", val
171
+
172
+ if RUBY_VERSION =~ /^1\.9/
173
+ eval <<-EOC
174
+ connection[uniq_id(2), :flags => 0x1100] = "bar"
175
+ val, flags = connection.get(uniq_id(2), :extended => true)
176
+ assert_equal "bar", val
177
+ assert_equal 0x1100, flags
178
+
179
+ connection[uniq_id(3), :format => :marshal] = ArbitraryData.new("thing")
180
+ val = connection.get(uniq_id(3))
181
+ assert val.is_a?(ArbitraryData)
182
+ assert_equal "thing", val.baz
183
+ EOC
184
+ end
185
+ end
186
+ end
@@ -0,0 +1,69 @@
1
+ # Author:: Couchbase <info@couchbase.com>
2
+ # Copyright:: 2011, 2012 Couchbase, Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ require File.join(File.dirname(__FILE__), 'setup')
19
+
20
+ class TestTouch < MiniTest::Unit::TestCase
21
+
22
+ def setup
23
+ @mock = start_mock
24
+ end
25
+
26
+ def teardown
27
+ stop_mock(@mock)
28
+ end
29
+
30
+ 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)
34
+ sleep(1)
35
+ assert connection.get(uniq_id)
36
+ sleep(2)
37
+ refute connection.get(uniq_id)
38
+ end
39
+
40
+ def test_multi_touch
41
+ connection = Couchbase.new(:port => @mock.port)
42
+ connection.set(uniq_id(1), "bar")
43
+ connection.set(uniq_id(2), "baz")
44
+ ret = connection.touch(uniq_id(1) => 1, uniq_id(2) => 1)
45
+ assert ret[uniq_id(1)]
46
+ assert ret[uniq_id(2)]
47
+ sleep(2)
48
+ refute connection.get(uniq_id(1))
49
+ refute connection.get(uniq_id(2))
50
+ end
51
+
52
+ def test_it_uses_default_ttl_for_touch
53
+ connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port, :default_ttl => 1)
54
+ connection.set(uniq_id, "bar", :ttl => 10)
55
+ connection.touch(uniq_id)
56
+ sleep(2)
57
+ refute connection.get(uniq_id)
58
+ end
59
+
60
+ def test_it_accepts_ttl_for_get_command
61
+ connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
62
+ connection.set(uniq_id, "bar", :ttl => 10)
63
+ val = connection.get(uniq_id, :ttl => 1)
64
+ assert_equal "bar", val
65
+ sleep(2)
66
+ refute connection.get(uniq_id)
67
+ end
68
+
69
+ end
@@ -0,0 +1,52 @@
1
+ # Author:: Couchbase <info@couchbase.com>
2
+ # Copyright:: 2011, 2012 Couchbase, Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ require File.join(File.dirname(__FILE__), 'setup')
19
+
20
+ class TestVersion < MiniTest::Unit::TestCase
21
+
22
+ def setup
23
+ @mock = start_mock
24
+ end
25
+
26
+ def teardown
27
+ stop_mock(@mock)
28
+ end
29
+
30
+ def test_sync_version
31
+ connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
32
+ ver = connection.version
33
+ assert ver.is_a?(Hash)
34
+ assert_equal @mock.num_nodes, ver.size
35
+ end
36
+
37
+ def test_async_version
38
+ connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
39
+ ver = {}
40
+ connection.run do |conn|
41
+ conn.version do |ret|
42
+ assert ret.success?
43
+ ver[ret.node] = ret.value
44
+ end
45
+ end
46
+ assert_equal @mock.num_nodes, ver.size
47
+ ver.each do |node, v|
48
+ assert v.is_a?(String)
49
+ end
50
+ end
51
+
52
+ end
metadata ADDED
@@ -0,0 +1,197 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: couchbase
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.0
5
+ prerelease:
6
+ platform: x86-mingw32
7
+ authors:
8
+ - Couchbase
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-03-07 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: yajl-ruby
16
+ requirement: &12069760 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 1.1.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *12069760
25
+ - !ruby/object:Gem::Dependency
26
+ name: rake
27
+ requirement: &12068240 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 0.8.7
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *12068240
36
+ - !ruby/object:Gem::Dependency
37
+ name: minitest
38
+ requirement: &12067280 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *12067280
47
+ - !ruby/object:Gem::Dependency
48
+ name: rake-compiler
49
+ requirement: &12056580 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: 0.7.5
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *12056580
58
+ - !ruby/object:Gem::Dependency
59
+ name: rdiscount
60
+ requirement: &12055480 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *12055480
69
+ - !ruby/object:Gem::Dependency
70
+ name: yard
71
+ requirement: &12054260 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *12054260
80
+ - !ruby/object:Gem::Dependency
81
+ name: mini_portile
82
+ requirement: &12053280 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: *12053280
91
+ - !ruby/object:Gem::Dependency
92
+ name: ruby-debug19
93
+ requirement: &12052340 !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ type: :development
100
+ prerelease: false
101
+ version_requirements: *12052340
102
+ description: The official client library for use with Couchbase Server.
103
+ email: support@couchbase.com
104
+ executables: []
105
+ extensions: []
106
+ extra_rdoc_files: []
107
+ files:
108
+ - .gitignore
109
+ - .travis.yml
110
+ - .yardopts
111
+ - Gemfile
112
+ - HISTORY.markdown
113
+ - LICENSE
114
+ - README.markdown
115
+ - Rakefile
116
+ - couchbase.gemspec
117
+ - ext/couchbase_ext/couchbase_ext.c
118
+ - ext/couchbase_ext/extconf.rb
119
+ - lib/couchbase.rb
120
+ - lib/couchbase/bucket.rb
121
+ - lib/couchbase/version.rb
122
+ - tasks/benchmark.rake
123
+ - tasks/compile.rake
124
+ - tasks/doc.rake
125
+ - tasks/test.rake
126
+ - tasks/util.rake
127
+ - test/profile/.gitignore
128
+ - test/profile/Gemfile
129
+ - test/profile/benchmark.rb
130
+ - test/setup.rb
131
+ - test/test_arithmetic.rb
132
+ - test/test_async.rb
133
+ - test/test_bucket.rb
134
+ - test/test_cas.rb
135
+ - test/test_couchbase.rb
136
+ - test/test_delete.rb
137
+ - test/test_errors.rb
138
+ - test/test_flush.rb
139
+ - test/test_format.rb
140
+ - test/test_get.rb
141
+ - test/test_stats.rb
142
+ - test/test_store.rb
143
+ - test/test_touch.rb
144
+ - test/test_version.rb
145
+ - lib/couchbase/1.8/couchbase_ext.so
146
+ - lib/couchbase/1.9/couchbase_ext.so
147
+ - lib/couchbase_ext.rb
148
+ homepage: http://couchbase.org
149
+ licenses:
150
+ - ASL-2
151
+ post_install_message:
152
+ rdoc_options: []
153
+ require_paths:
154
+ - lib
155
+ required_ruby_version: !ruby/object:Gem::Requirement
156
+ none: false
157
+ requirements:
158
+ - - ! '>='
159
+ - !ruby/object:Gem::Version
160
+ version: '0'
161
+ segments:
162
+ - 0
163
+ hash: -2404392778258139925
164
+ required_rubygems_version: !ruby/object:Gem::Requirement
165
+ none: false
166
+ requirements:
167
+ - - ! '>='
168
+ - !ruby/object:Gem::Version
169
+ version: '0'
170
+ segments:
171
+ - 0
172
+ hash: -2404392778258139925
173
+ requirements: []
174
+ rubyforge_project:
175
+ rubygems_version: 1.8.10
176
+ signing_key:
177
+ specification_version: 3
178
+ summary: Couchbase ruby driver
179
+ test_files:
180
+ - test/profile/.gitignore
181
+ - test/profile/Gemfile
182
+ - test/profile/benchmark.rb
183
+ - test/setup.rb
184
+ - test/test_arithmetic.rb
185
+ - test/test_async.rb
186
+ - test/test_bucket.rb
187
+ - test/test_cas.rb
188
+ - test/test_couchbase.rb
189
+ - test/test_delete.rb
190
+ - test/test_errors.rb
191
+ - test/test_flush.rb
192
+ - test/test_format.rb
193
+ - test/test_get.rb
194
+ - test/test_stats.rb
195
+ - test/test_store.rb
196
+ - test/test_touch.rb
197
+ - test/test_version.rb