higgs 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +50 -0
- data/Rakefile +1 -2
- data/bin/higgs_backup +47 -29
- data/lib/higgs/block.rb +5 -4
- data/lib/higgs/dbm.rb +39 -3
- data/lib/higgs/index.rb +11 -8
- data/lib/higgs/jlog.rb +5 -5
- data/lib/higgs/storage.rb +64 -45
- data/lib/higgs/store.rb +30 -3
- data/lib/higgs/utils/bman.rb +149 -51
- data/lib/higgs/version.rb +4 -4
- data/mkrdoc.rb +5 -2
- data/test/test_block.rb +59 -1
- data/test/test_cache.rb +17 -3
- data/test/test_dbm.rb +163 -0
- data/test/test_index.rb +28 -5
- data/test/test_online_backup.rb +2 -2
- data/test/test_storage.rb +120 -53
- data/test/test_storage_init_opts.rb +27 -1
- data/test/test_store.rb +45 -6
- data/test/test_tman.rb +62 -2
- data/test/test_utils_bman.rb +257 -39
- metadata +3 -2
data/test/test_index.rb
CHANGED
@@ -10,7 +10,7 @@ module Higgs::Test
|
|
10
10
|
include Higgs
|
11
11
|
|
12
12
|
# for ident(1)
|
13
|
-
CVS_ID = '$Id: test_index.rb
|
13
|
+
CVS_ID = '$Id: test_index.rb 589 2007-09-30 05:54:30Z toki $'
|
14
14
|
|
15
15
|
def setup
|
16
16
|
@idx = Index.new
|
@@ -45,7 +45,7 @@ module Higgs::Test
|
|
45
45
|
include Higgs
|
46
46
|
|
47
47
|
# for ident(1)
|
48
|
-
CVS_ID = '$Id: test_index.rb
|
48
|
+
CVS_ID = '$Id: test_index.rb 589 2007-09-30 05:54:30Z toki $'
|
49
49
|
|
50
50
|
def setup
|
51
51
|
@idx = Index.new
|
@@ -91,7 +91,7 @@ module Higgs::Test
|
|
91
91
|
include Higgs
|
92
92
|
|
93
93
|
# for ident(1)
|
94
|
-
CVS_ID = '$Id: test_index.rb
|
94
|
+
CVS_ID = '$Id: test_index.rb 589 2007-09-30 05:54:30Z toki $'
|
95
95
|
|
96
96
|
def setup
|
97
97
|
@idx = Index.new
|
@@ -164,7 +164,7 @@ module Higgs::Test
|
|
164
164
|
include Higgs
|
165
165
|
|
166
166
|
# for ident(1)
|
167
|
-
CVS_ID = '$Id: test_index.rb
|
167
|
+
CVS_ID = '$Id: test_index.rb 589 2007-09-30 05:54:30Z toki $'
|
168
168
|
|
169
169
|
def setup
|
170
170
|
@idx = Index.new
|
@@ -173,6 +173,8 @@ module Higgs::Test
|
|
173
173
|
def test_identity
|
174
174
|
@idx[:foo] = 0
|
175
175
|
assert_equal('foo', @idx.identity(:foo))
|
176
|
+
@idx[:foo] = 1 # overwrite index entry
|
177
|
+
assert_equal('foo', @idx.identity(:foo))
|
176
178
|
end
|
177
179
|
|
178
180
|
def test_identity_not_defined
|
@@ -194,6 +196,8 @@ module Higgs::Test
|
|
194
196
|
@idx.delete(:foo)
|
195
197
|
assert_equal(nil, @idx.identity(:foo))
|
196
198
|
assert_equal('foo.a', @idx.identity('foo'))
|
199
|
+
@idx['foo'] = 2 # overwrite index entry
|
200
|
+
assert_equal('foo.a', @idx.identity('foo'))
|
197
201
|
end
|
198
202
|
end
|
199
203
|
|
@@ -201,7 +205,7 @@ module Higgs::Test
|
|
201
205
|
include Higgs
|
202
206
|
|
203
207
|
# for ident(1)
|
204
|
-
CVS_ID = '$Id: test_index.rb
|
208
|
+
CVS_ID = '$Id: test_index.rb 589 2007-09-30 05:54:30Z toki $'
|
205
209
|
|
206
210
|
def setup
|
207
211
|
@path = 'test.idx'
|
@@ -249,6 +253,25 @@ module Higgs::Test
|
|
249
253
|
assert_equal(0, i[:foo])
|
250
254
|
assert_equal('foo', i.identity(:foo))
|
251
255
|
end
|
256
|
+
|
257
|
+
def test_migration_RuntimeError_unsupported_version
|
258
|
+
index_data_1_0 = {
|
259
|
+
:version => [ 1, 0 ],
|
260
|
+
:change_number => 0,
|
261
|
+
:eoa => 1024,
|
262
|
+
:free_lists => { 512 => [ 512 ] },
|
263
|
+
:index => { :foo => 0 }
|
264
|
+
}
|
265
|
+
File.open(@path, 'w') {|w|
|
266
|
+
w.binmode
|
267
|
+
Block.block_write(w, Index::MAGIC_SYMBOL, Marshal.dump(index_data_1_0))
|
268
|
+
}
|
269
|
+
|
270
|
+
i = Index.new
|
271
|
+
assert_raise(RuntimeError) {
|
272
|
+
i.load(@path)
|
273
|
+
}
|
274
|
+
end
|
252
275
|
end
|
253
276
|
end
|
254
277
|
|
data/test/test_online_backup.rb
CHANGED
@@ -30,7 +30,7 @@ module Higgs::Test
|
|
30
30
|
include OnlineBackupParams
|
31
31
|
|
32
32
|
# for ident(1)
|
33
|
-
CVS_ID = '$Id: test_online_backup.rb
|
33
|
+
CVS_ID = '$Id: test_online_backup.rb 584 2007-09-29 15:05:15Z toki $'
|
34
34
|
|
35
35
|
def setup
|
36
36
|
srand(0)
|
@@ -75,7 +75,7 @@ module Higgs::Test
|
|
75
75
|
FileUtils.touch(@start_latch)
|
76
76
|
until (File.exist? @stop_latch)
|
77
77
|
write_list = []
|
78
|
-
ope = [ :write, :system_properties, :custom_properties, :delete ][rand(
|
78
|
+
ope = [ :write, :system_properties, :custom_properties, :delete ][rand(4)]
|
79
79
|
key = rand(STORAGE_ITEMS)
|
80
80
|
case (ope)
|
81
81
|
when :write
|
data/test/test_storage.rb
CHANGED
@@ -6,14 +6,14 @@ require 'logger'
|
|
6
6
|
require 'test/unit'
|
7
7
|
|
8
8
|
module Higgs::Test
|
9
|
-
|
9
|
+
module StorageTestCase
|
10
10
|
include Higgs
|
11
11
|
|
12
12
|
# for ident(1)
|
13
|
-
CVS_ID = '$Id: test_storage.rb
|
13
|
+
CVS_ID = '$Id: test_storage.rb 609 2007-10-04 16:27:39Z toki $'
|
14
14
|
|
15
15
|
def setup
|
16
|
-
srand(0) # preset for rand
|
16
|
+
srand(0) # preset for rand
|
17
17
|
@test_dir = 'st_test'
|
18
18
|
FileUtils.rm_rf(@test_dir) # for debug
|
19
19
|
FileUtils.mkdir_p(@test_dir)
|
@@ -23,13 +23,25 @@ module Higgs::Test
|
|
23
23
|
logger.level = Logger::DEBUG
|
24
24
|
logger
|
25
25
|
}
|
26
|
-
@st =
|
26
|
+
@st = new_storage
|
27
27
|
end
|
28
28
|
|
29
29
|
def teardown
|
30
30
|
@st.shutdown unless @st.shutdown?
|
31
31
|
FileUtils.rm_rf(@test_dir) unless $DEBUG
|
32
32
|
end
|
33
|
+
end
|
34
|
+
|
35
|
+
class StorageTest < Test::Unit::TestCase
|
36
|
+
include StorageTestCase
|
37
|
+
|
38
|
+
# for ident(1)
|
39
|
+
CVS_ID = '$Id: test_storage.rb 609 2007-10-04 16:27:39Z toki $'
|
40
|
+
|
41
|
+
def new_storage
|
42
|
+
Storage.new(@name, :logger => @logger)
|
43
|
+
end
|
44
|
+
private :new_storage
|
33
45
|
|
34
46
|
def test_raw_write_and_commit
|
35
47
|
write_list = [
|
@@ -45,54 +57,6 @@ module Higgs::Test
|
|
45
57
|
@st.raw_write_and_commit(write_list)
|
46
58
|
end
|
47
59
|
|
48
|
-
def test_recover
|
49
|
-
@st.shutdown
|
50
|
-
@st = Storage.new(@name,
|
51
|
-
:data_cksum_type => :MD5,
|
52
|
-
:jlog_rotate_max => 0, # unlimited rotation
|
53
|
-
:logger => @logger)
|
54
|
-
|
55
|
-
loop_count = 100
|
56
|
-
data_count = 10
|
57
|
-
|
58
|
-
loop_count.times do
|
59
|
-
write_list = []
|
60
|
-
ope = [ :write, :delete ][rand(2)]
|
61
|
-
key = rand(data_count)
|
62
|
-
case (ope)
|
63
|
-
when :write
|
64
|
-
type = [ :a, :b ][rand(2)]
|
65
|
-
value = rand(256).chr * rand(5120)
|
66
|
-
write_list << [ ope, key, type, key.to_s, value ]
|
67
|
-
when :delete
|
68
|
-
next unless (@st.key? key)
|
69
|
-
write_list << [ ope, key ]
|
70
|
-
else
|
71
|
-
raise "unknown operation: #{ope}"
|
72
|
-
end
|
73
|
-
@st.raw_write_and_commit(write_list)
|
74
|
-
end
|
75
|
-
|
76
|
-
3.times do
|
77
|
-
@st.rotate_journal_log(false)
|
78
|
-
end
|
79
|
-
3.times do
|
80
|
-
@st.rotate_journal_log(true)
|
81
|
-
end
|
82
|
-
|
83
|
-
@st.shutdown
|
84
|
-
|
85
|
-
other_name = File.join(@test_dir, 'bar')
|
86
|
-
for name in Storage.rotate_entries("#{@name}.jlog")
|
87
|
-
name =~ /\.jlog.*$/ or raise 'mismatch'
|
88
|
-
FileUtils.cp(name, other_name + $&)
|
89
|
-
end
|
90
|
-
Storage.recover(other_name)
|
91
|
-
|
92
|
-
assert(FileUtils.cmp("#{@name}.tar", "#{other_name}.tar"), 'tar')
|
93
|
-
assert(FileUtils.cmp("#{@name}.idx", "#{other_name}.idx"), 'idx')
|
94
|
-
end
|
95
|
-
|
96
60
|
def test_write_and_commit
|
97
61
|
write_list = [
|
98
62
|
[ :write, :foo, '' ],
|
@@ -404,11 +368,114 @@ module Higgs::Test
|
|
404
368
|
end
|
405
369
|
end
|
406
370
|
|
371
|
+
class StorageRecoveryTest < Test::Unit::TestCase
|
372
|
+
include StorageTestCase
|
373
|
+
|
374
|
+
# for ident(1)
|
375
|
+
CVS_ID = '$Id: test_storage.rb 609 2007-10-04 16:27:39Z toki $'
|
376
|
+
|
377
|
+
def new_storage
|
378
|
+
Storage.new(@name,
|
379
|
+
:jlog_rotate_max => 0, # unlimited rotation
|
380
|
+
:logger => @logger)
|
381
|
+
end
|
382
|
+
private :new_storage
|
383
|
+
|
384
|
+
def write_data(loop_count=100, data_count=10, data_max_size=1024*5)
|
385
|
+
loop_count.times do
|
386
|
+
write_list = []
|
387
|
+
ope = [ :write, :delete ][rand(2)]
|
388
|
+
key = rand(data_count)
|
389
|
+
case (ope)
|
390
|
+
when :write
|
391
|
+
type = [ :a, :b ][rand(2)]
|
392
|
+
value = rand(256).chr * rand(data_max_size)
|
393
|
+
write_list << [ ope, key, type, key.to_s, value ]
|
394
|
+
when :delete
|
395
|
+
next unless (@st.key? key)
|
396
|
+
write_list << [ ope, key ]
|
397
|
+
else
|
398
|
+
raise "unknown operation: #{ope}"
|
399
|
+
end
|
400
|
+
@st.raw_write_and_commit(write_list)
|
401
|
+
end
|
402
|
+
end
|
403
|
+
private :write_data
|
404
|
+
|
405
|
+
def test_manual_recovery
|
406
|
+
write_data
|
407
|
+
|
408
|
+
3.times do
|
409
|
+
@st.rotate_journal_log(false)
|
410
|
+
end
|
411
|
+
3.times do
|
412
|
+
@st.rotate_journal_log(true)
|
413
|
+
end
|
414
|
+
|
415
|
+
@st.shutdown
|
416
|
+
|
417
|
+
other_name = File.join(@test_dir, 'bar')
|
418
|
+
for name in Storage.rotate_entries("#{@name}.jlog")
|
419
|
+
name =~ /\.jlog.*$/ or raise 'mismatch'
|
420
|
+
FileUtils.cp(name, other_name + $&, :preserve => true)
|
421
|
+
end
|
422
|
+
Storage.recover(other_name)
|
423
|
+
|
424
|
+
assert(FileUtils.cmp("#{@name}.tar", "#{other_name}.tar"), 'tar')
|
425
|
+
assert(FileUtils.cmp("#{@name}.idx", "#{other_name}.idx"), 'idx')
|
426
|
+
end
|
427
|
+
|
428
|
+
def test_auto_recovery
|
429
|
+
write_data
|
430
|
+
@st.rotate_journal_log(true)
|
431
|
+
|
432
|
+
other_name = File.join(@test_dir, 'bar')
|
433
|
+
FileUtils.cp("#{@name}.tar", "#{other_name}.tar", :preserve => true)
|
434
|
+
FileUtils.cp("#{@name}.idx", "#{other_name}.idx", :preserve => true)
|
435
|
+
|
436
|
+
# write_data(10 * 10 * 256) < jlog_rotate_size(256 * 1024)
|
437
|
+
write_data(10, 10, 256)
|
438
|
+
|
439
|
+
# not closed journal log for other storage.
|
440
|
+
FileUtils.cp("#{@name}.jlog", "#{other_name}.jlog", :preserve => true)
|
441
|
+
|
442
|
+
@st.shutdown
|
443
|
+
|
444
|
+
# auto-recovery for other storage
|
445
|
+
st2 = Storage.new(other_name, :logger => @logger)
|
446
|
+
st2.shutdown
|
447
|
+
|
448
|
+
assert(FileUtils.cmp("#{@name}.tar", "#{other_name}.tar"), 'tar')
|
449
|
+
assert(FileUtils.cmp("#{@name}.idx", "#{other_name}.idx"), 'idx')
|
450
|
+
assert(FileUtils.cmp("#{@name}.jlog", "#{other_name}.jlog"), 'jlog')
|
451
|
+
end
|
452
|
+
|
453
|
+
def test_lost_journal_log_error
|
454
|
+
write_data
|
455
|
+
@st.rotate_journal_log(true)
|
456
|
+
|
457
|
+
other_name = File.join(@test_dir, 'bar')
|
458
|
+
FileUtils.cp("#{@name}.tar", "#{other_name}.tar", :preserve => true)
|
459
|
+
FileUtils.cp("#{@name}.idx", "#{other_name}.idx", :preserve => true)
|
460
|
+
|
461
|
+
write_data
|
462
|
+
@st.rotate_journal_log(true)
|
463
|
+
write_data
|
464
|
+
|
465
|
+
FileUtils.cp("#{@name}.jlog", "#{other_name}.jlog", :preserve => true)
|
466
|
+
|
467
|
+
assert_raise(Storage::PanicError) {
|
468
|
+
st2 = Storage.new(other_name, :logger => @logger)
|
469
|
+
}
|
470
|
+
end
|
471
|
+
end
|
472
|
+
|
407
473
|
class ReadOnlyStorageFirstOpenTest < Test::Unit::TestCase
|
408
474
|
include Higgs
|
409
475
|
|
410
476
|
# for ident(1)
|
411
|
-
CVS_ID = '$Id: test_storage.rb
|
477
|
+
CVS_ID = '$Id: test_storage.rb 609 2007-10-04 16:27:39Z toki $'
|
478
|
+
|
412
479
|
def setup
|
413
480
|
@test_dir = 'st_test'
|
414
481
|
FileUtils.rm_rf(@test_dir) # for debug
|
@@ -6,7 +6,7 @@ require 'test/unit'
|
|
6
6
|
module Higgs::Test
|
7
7
|
class StorageInitOptionsTest < Test::Unit::TestCase
|
8
8
|
# for ident(1)
|
9
|
-
CVS_ID = '$Id: test_storage_init_opts.rb
|
9
|
+
CVS_ID = '$Id: test_storage_init_opts.rb 590 2007-09-30 06:13:54Z toki $'
|
10
10
|
|
11
11
|
include Higgs::Storage::InitOptions
|
12
12
|
|
@@ -17,6 +17,8 @@ module Higgs::Test
|
|
17
17
|
assert_equal(2, @number_of_read_io)
|
18
18
|
assert_equal(2, self.number_of_read_io)
|
19
19
|
assert_instance_of(Higgs::LRUCache, @properties_cache) # auto: require 'higgs/cache'
|
20
|
+
assert_equal(:MD5, self.data_hash_type)
|
21
|
+
assert_equal(:MD5, @data_hash_type)
|
20
22
|
assert_equal(false, @jlog_sync)
|
21
23
|
assert_equal(false, self.jlog_sync)
|
22
24
|
assert_equal(1024 * 256, @jlog_rotate_size)
|
@@ -51,6 +53,18 @@ module Higgs::Test
|
|
51
53
|
assert_equal(:dummy_cache, @properties_cache)
|
52
54
|
end
|
53
55
|
|
56
|
+
def test_data_hash_type
|
57
|
+
init_options(:data_hash_type => :SHA512)
|
58
|
+
assert_equal(:SHA512, @data_hash_type)
|
59
|
+
assert_equal(:SHA512, self.data_hash_type)
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_data_hash_type_ArgumentError_unknown_data_hash_type
|
63
|
+
assert_raise(ArgumentError) {
|
64
|
+
init_options(:data_hash_type => :UNKNOWN)
|
65
|
+
}
|
66
|
+
end
|
67
|
+
|
54
68
|
def test_jlog_sync_true
|
55
69
|
init_options(:jlog_sync => true)
|
56
70
|
assert_equal(true, @jlog_sync)
|
@@ -63,6 +77,18 @@ module Higgs::Test
|
|
63
77
|
assert_equal(false, self.jlog_sync)
|
64
78
|
end
|
65
79
|
|
80
|
+
def test_jlog_hash_type
|
81
|
+
init_options(:jlog_hash_type => :SHA512)
|
82
|
+
assert_equal(:SHA512, @jlog_hash_type)
|
83
|
+
assert_equal(:SHA512, self.jlog_hash_type)
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_jlog_hash_type_ArgumentError_unknown_journal_log_hash_type
|
87
|
+
assert_raise(ArgumentError) {
|
88
|
+
init_options(:jlog_hash_type => :UNKNOWN)
|
89
|
+
}
|
90
|
+
end
|
91
|
+
|
66
92
|
def test_jlog_rotate_size
|
67
93
|
init_options(:jlog_rotate_size => 1024**2)
|
68
94
|
assert_equal(1024**2, @jlog_rotate_size)
|
data/test/test_store.rb
CHANGED
@@ -10,7 +10,7 @@ module Higgs::Test
|
|
10
10
|
include Higgs
|
11
11
|
|
12
12
|
# for ident(1)
|
13
|
-
CVS_ID = '$Id: test_store.rb
|
13
|
+
CVS_ID = '$Id: test_store.rb 596 2007-10-01 15:18:10Z toki $'
|
14
14
|
|
15
15
|
def setup
|
16
16
|
@test_dir = 'store_test'
|
@@ -147,11 +147,9 @@ module Higgs::Test
|
|
147
147
|
}
|
148
148
|
|
149
149
|
@st.transaction{|tx|
|
150
|
-
|
151
|
-
|
152
|
-
assert_equal(
|
153
|
-
assert_equal(%w[ apple banana ], fruits)
|
154
|
-
tx[:foo] = fruits
|
150
|
+
assert_equal(%w[ apple banana orange ], tx[:foo])
|
151
|
+
tx.update(:foo) {|fruits| fruits.pop }
|
152
|
+
assert_equal(%w[ apple banana ], tx[:foo])
|
155
153
|
tx.rollback
|
156
154
|
assert_equal(%w[ apple banana orange ], tx[:foo])
|
157
155
|
}
|
@@ -201,6 +199,47 @@ module Higgs::Test
|
|
201
199
|
end
|
202
200
|
assert_equal([], expected_keys)
|
203
201
|
}
|
202
|
+
|
203
|
+
@st.transaction{|tx|
|
204
|
+
expected_keys = [ :foo, :bar, :baz ]
|
205
|
+
tx.each_key do |key|
|
206
|
+
assert((expected_keys.include? key), key)
|
207
|
+
expected_keys.delete(key)
|
208
|
+
end
|
209
|
+
assert_equal([], expected_keys)
|
210
|
+
}
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
class StoreOpenTest < Test::Unit::TestCase
|
215
|
+
include Higgs
|
216
|
+
|
217
|
+
# for ident(1)
|
218
|
+
CVS_ID = '$Id: test_store.rb 596 2007-10-01 15:18:10Z toki $'
|
219
|
+
|
220
|
+
def setup
|
221
|
+
@test_dir = 'store_test'
|
222
|
+
FileUtils.rm_rf(@test_dir) # for debug
|
223
|
+
FileUtils.mkdir_p(@test_dir)
|
224
|
+
@name = File.join(@test_dir, 'foo')
|
225
|
+
end
|
226
|
+
|
227
|
+
def teardown
|
228
|
+
FileUtils.rm_rf(@test_dir) unless $DEBUG
|
229
|
+
end
|
230
|
+
|
231
|
+
def test_open
|
232
|
+
Store.open(@name) {|st|
|
233
|
+
st.transaction{|tx|
|
234
|
+
tx[:foo] = :apple
|
235
|
+
}
|
236
|
+
}
|
237
|
+
|
238
|
+
Store.open(@name, :read_only => true) {|st|
|
239
|
+
st.transaction{|tx|
|
240
|
+
assert_equal(:apple, tx[:foo])
|
241
|
+
}
|
242
|
+
}
|
204
243
|
end
|
205
244
|
end
|
206
245
|
end
|
data/test/test_tman.rb
CHANGED
@@ -11,7 +11,7 @@ module Higgs::Test
|
|
11
11
|
include Higgs
|
12
12
|
|
13
13
|
# for ident(1)
|
14
|
-
CVS_ID = '$Id: test_tman.rb
|
14
|
+
CVS_ID = '$Id: test_tman.rb 599 2007-10-01 15:54:00Z toki $'
|
15
15
|
|
16
16
|
def setup
|
17
17
|
@test_dir = 'st_test'
|
@@ -43,6 +43,32 @@ module Higgs::Test
|
|
43
43
|
assert_equal(1, count)
|
44
44
|
end
|
45
45
|
|
46
|
+
def test_transaction_RuntimeError_nested_transaction_forbidden
|
47
|
+
@tman.transaction(true) {|tx|
|
48
|
+
assert_raise(RuntimeError) {
|
49
|
+
@tman.transaction(true) {|tx2|
|
50
|
+
flunk('not to reach.')
|
51
|
+
}
|
52
|
+
}
|
53
|
+
}
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_in_transaction?
|
57
|
+
assert_equal(false, TransactionManager.in_transaction?)
|
58
|
+
@tman.transaction{|tx|
|
59
|
+
assert_equal(true, TransactionManager.in_transaction?)
|
60
|
+
}
|
61
|
+
assert_equal(false, TransactionManager.in_transaction?)
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_current_transaction
|
65
|
+
assert_equal(nil, TransactionManager.current_transaction)
|
66
|
+
@tman.transaction{|tx|
|
67
|
+
assert_equal(tx, TransactionManager.current_transaction)
|
68
|
+
}
|
69
|
+
assert_equal(nil, TransactionManager.current_transaction)
|
70
|
+
end
|
71
|
+
|
46
72
|
def test_fetch_and_store
|
47
73
|
@tman.transaction{|tx|
|
48
74
|
assert_equal(nil, tx[:foo])
|
@@ -442,6 +468,40 @@ module Higgs::Test
|
|
442
468
|
}
|
443
469
|
end
|
444
470
|
|
471
|
+
def test_set_property_IndexError_not_exist_properties_at_key
|
472
|
+
@tman.transaction{|tx|
|
473
|
+
assert_raise(IndexError) {
|
474
|
+
tx.set_property(:foo, 'bar', 'baz')
|
475
|
+
}
|
476
|
+
assert_raise(IndexError) {
|
477
|
+
tx.delete_property(:foo, 'bar')
|
478
|
+
}
|
479
|
+
assert_raise(IndexError) {
|
480
|
+
tx.each_property(:foo) do |name, value|
|
481
|
+
flunk('not to reach.')
|
482
|
+
end
|
483
|
+
}
|
484
|
+
}
|
485
|
+
end
|
486
|
+
|
487
|
+
def test_property_TypeError_cant_convert_to_Symbol_or_String
|
488
|
+
@tman.transaction{|tx|
|
489
|
+
tx[:foo] = ''
|
490
|
+
assert_raise(TypeError) {
|
491
|
+
tx.property(:foo, 0)
|
492
|
+
}
|
493
|
+
assert_raise(TypeError) {
|
494
|
+
tx.set_property(:foo, 'a'..'z', 'bar')
|
495
|
+
}
|
496
|
+
assert_raise(TypeError) {
|
497
|
+
tx.delete_property(:foo, 3.141592)
|
498
|
+
}
|
499
|
+
assert_raise(TypeError) {
|
500
|
+
tx.property? :foo, /bar/
|
501
|
+
}
|
502
|
+
}
|
503
|
+
end
|
504
|
+
|
445
505
|
def test_system_properties
|
446
506
|
@tman.transaction{|tx|
|
447
507
|
tx[:foo] = 'apple'
|
@@ -854,7 +914,7 @@ module Higgs::Test
|
|
854
914
|
|
855
915
|
class TransactionManagerTest_with_SecondaryCache < TransactionManagerTest
|
856
916
|
# for ident(1)
|
857
|
-
CVS_ID = '$Id: test_tman.rb
|
917
|
+
CVS_ID = '$Id: test_tman.rb 599 2007-10-01 15:54:00Z toki $'
|
858
918
|
|
859
919
|
def setup
|
860
920
|
super
|