xunch 0.0.6 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,53 +1,56 @@
1
1
  $:.unshift File.expand_path("../../lib", __FILE__)
2
+ $:.unshift File.expand_path("../../test", __FILE__)
2
3
  require "test/unit"
3
4
  require "xunch"
4
- require 'active_record'
5
-
6
- class HashObject < ActiveRecord::Base
7
- attr_accessor :a,:b,:c,:d
8
- TYPE_MAP = {}
9
- def initialize
10
- @a = 1
11
- @b = 2
12
- @c = 3
13
- end
14
-
15
- def setA(a)
16
- @a = a
17
- end
18
-
19
- def setB(b)
20
- @b = b
21
- end
22
-
23
- def setC(c)
24
- @c = c
25
- end
26
-
27
- def setD(d)
28
- @d = d
29
- end
30
-
31
- def to_s
32
- "{a=#{@a},b=#{@b},c=#{@c},d=#{@d}}"
33
- end
34
- end
5
+ require "track_record_origin"
6
+ require "test_helper"
35
7
 
36
8
  class HashCodecTest < Test::Unit::TestCase
37
9
  include Test::Unit::Assertions
38
10
  def setup
39
11
  super
40
- @codec = Xunch::HashCodec.new(HashObject)
12
+ fields = ["createdAt","trackUploadSource","uploadSource","nickname","opType","uid",
13
+ "trackId","trackUid","updatedAt","approvedAt","isCrawler","isPublic","mp3size",
14
+ "longitude","trackId","playPath","title","intro","id","duration"]
15
+ @codec = Xunch::HashCodec.new(TrackRecordOrigin,fields)
41
16
  puts "setup"
42
17
  end
43
18
 
44
19
  def test_codec
45
- json_object = HashObject.new
46
- hash = @codec.encode(json_object)
47
- puts hash
48
- json_hash = @codec.decode(hash)
49
- puts json_hash.class
50
- puts json_hash.instance_variable_get(:@a)
20
+ puts "HashCodecTest test_codec method start"
21
+ root = File.expand_path("../..", __FILE__)
22
+ object_file = File.join(root, 'test/object')
23
+ expect_hash_object = Marshal.load(IO.read(object_file))
24
+ hash = @codec.encode(expect_hash_object)
25
+ # file = File.new("hash_codec_test_resource","w+")
26
+ # file.write(Marshal.dump(hash))
27
+ # file.close
28
+ test_resource_file = File.join(root, 'test/hash_codec_test_resource')
29
+ expect_hash = Marshal.load(IO.read(test_resource_file))
30
+ expect_hash.each{ |k, v|
31
+ assert_equal(v,hash[k])
32
+ }
33
+ hash_object = @codec.decode(hash)
34
+ assert_equal(expect_hash_object.track_id,hash_object.track_id)
35
+ assert_equal(expect_hash_object.track_uid,hash_object.track_uid)
36
+ assert_equal(expect_hash_object.track_upload_source,hash_object.track_upload_source)
37
+ assert_equal(expect_hash_object.op_type,hash_object.op_type)
38
+ assert_equal(expect_hash_object.is_public,hash_object.is_public)
39
+ assert_equal(expect_hash_object.upload_source,hash_object.upload_source)
40
+ assert_equal(expect_hash_object.uid,hash_object.uid)
41
+ assert_equal(expect_hash_object.nickname,hash_object.nickname)
42
+ assert_equal(expect_hash_object.title,hash_object.title)
43
+ assert_equal(expect_hash_object.intro,hash_object.intro)
44
+ assert_equal(expect_hash_object.play_path,hash_object.play_path)
45
+ assert_equal(expect_hash_object.is_crawler,hash_object.is_crawler)
46
+ assert_equal(expect_hash_object.approved_at,hash_object.approved_at)
47
+ assert_equal(expect_hash_object.mp3size,hash_object.mp3size)
48
+ assert_equal(expect_hash_object.updated_at,hash_object.updated_at)
49
+ assert_equal(expect_hash_object.created_at,hash_object.created_at)
50
+ assert_equal(expect_hash_object.id,hash_object.id)
51
+ assert_equal(expect_hash_object.longitude,hash_object.longitude)
52
+ assert_equal(expect_hash_object.duration,hash_object.duration)
53
+ puts "HashCodecTest test_codec method stop"
51
54
  end
52
55
 
53
56
  def teardown
@@ -1,53 +1,98 @@
1
1
  $:.unshift File.expand_path("../../lib", __FILE__)
2
+ $:.unshift File.expand_path("../../test", __FILE__)
2
3
  require "test/unit"
3
4
  require "xunch"
4
- require 'active_record'
5
-
6
- class JsonObject < ActiveRecord::Base
7
- attr_accessor :a,:b,:c,:d
8
-
9
- def initialize
10
- @a = 1
11
- @b = 2
12
- @c = 3
13
- end
14
-
15
- def setA(a)
16
- @a = a
17
- end
18
-
19
- def setB(b)
20
- @b = b
21
- end
22
-
23
- def setC(c)
24
- @c = c
25
- end
26
-
27
- def setD(d)
28
- @d = d
29
- end
30
-
31
- def to_s
32
- "{a=#{@a},b=#{@b},c=#{@c},d=#{@d}}"
33
- end
34
- end
5
+ require "track_record_origin"
6
+ require "test_helper"
35
7
 
36
8
  class JsonCodecTest < Test::Unit::TestCase
37
9
  include Test::Unit::Assertions
38
10
  def setup
39
11
  super
40
- @codec = Xunch::JsonCodec.new(JsonObject)
12
+ @codec = Xunch::JsonCodec.new(TrackRecordOrigin)
41
13
  puts "setup"
42
14
  end
43
15
 
44
16
  def test_codec
45
- json_object = JsonObject.new
46
- json_string = @codec.encode(json_object)
47
- puts json_string
48
- json_hash = @codec.decode(json_string)
49
- puts json_hash.class
50
- puts json_hash.instance_variable_get(:@a)
17
+ puts "JsonCodecTest test_codec method start"
18
+ root = File.expand_path("../..", __FILE__)
19
+ object_file = File.join(root, 'test/object')
20
+ expect_json_object = Marshal.load(IO.read(object_file))
21
+ json_string = @codec.encode(expect_json_object)
22
+ test_resource_file = File.join(root, 'test/json_codec_test_resource')
23
+ expect_json_string = IO.read(test_resource_file)
24
+ assert_equal(expect_json_string,json_string)
25
+ json_object = @codec.decode(json_string)
26
+ assert_equal(expect_json_object.track_id,json_object.track_id)
27
+ assert_equal(expect_json_object.track_uid,json_object.track_uid)
28
+ assert_equal(expect_json_object.track_upload_source,json_object.track_upload_source)
29
+ assert_equal(expect_json_object.op_type,json_object.op_type)
30
+ assert_equal(expect_json_object.is_publish,json_object.is_publish)
31
+ assert_equal(expect_json_object.upload_source,json_object.upload_source)
32
+ assert_equal(expect_json_object.uid,json_object.uid)
33
+ assert_equal(expect_json_object.nickname,json_object.nickname)
34
+ assert_equal(expect_json_object.avatar_path,json_object.avatar_path)
35
+ assert_equal(expect_json_object.is_v,json_object.is_v)
36
+ assert_equal(expect_json_object.human_category_id,json_object.human_category_id)
37
+ assert_equal(expect_json_object.title,json_object.title)
38
+ assert_equal(expect_json_object.intro,json_object.intro)
39
+ assert_equal(expect_json_object.user_source,json_object.user_source)
40
+ assert_equal(expect_json_object.category_id,json_object.category_id)
41
+ assert_equal(expect_json_object.duration,json_object.duration)
42
+ assert_equal(expect_json_object.play_path,json_object.play_path)
43
+ assert_equal(expect_json_object.play_path_32,json_object.play_path_32)
44
+ assert_equal(expect_json_object.play_path_64,json_object.play_path_64)
45
+ assert_equal(expect_json_object.play_path_128,json_object.play_path_128)
46
+ assert_equal(expect_json_object.transcode_state,json_object.transcode_state)
47
+ assert_equal(expect_json_object.download_path,json_object.download_path)
48
+ assert_equal(expect_json_object.cover_path,json_object.cover_path)
49
+ assert_equal(expect_json_object.album_id,json_object.album_id)
50
+ assert_equal(expect_json_object.album_title,json_object.album_title)
51
+ assert_equal(expect_json_object.album_cover_path,json_object.album_cover_path)
52
+ assert_equal(expect_json_object.tags,json_object.tags)
53
+ assert_equal(expect_json_object.ignore_tags,json_object.ignore_tags)
54
+ assert_equal(expect_json_object.extra_tags,json_object.extra_tags)
55
+ assert_equal(expect_json_object.singer,json_object.singer)
56
+ assert_equal(expect_json_object.singer_category,json_object.singer_category)
57
+ assert_equal(expect_json_object.author,json_object.author)
58
+ assert_equal(expect_json_object.composer,json_object.composer)
59
+ assert_equal(expect_json_object.arrangement,json_object.arrangement)
60
+ assert_equal(expect_json_object.post_production,json_object.post_production)
61
+ assert_equal(expect_json_object.lyric_path,json_object.lyric_path)
62
+ assert_equal(expect_json_object.language,json_object.language)
63
+ assert_equal(expect_json_object.lyric,json_object.lyric)
64
+ assert_equal(expect_json_object.resinger,json_object.resinger)
65
+ assert_equal(expect_json_object.announcer,json_object.announcer)
66
+ assert_equal(expect_json_object.is_public,json_object.is_public)
67
+ assert_equal(expect_json_object.access_password,json_object.access_password)
68
+ assert_equal(expect_json_object.allow_download,json_object.allow_download)
69
+ assert_equal(expect_json_object.allow_comment,json_object.allow_comment)
70
+ assert_equal(expect_json_object.is_crawler,json_object.is_crawler)
71
+ assert_equal(expect_json_object.inet_aton_ip,json_object.inet_aton_ip)
72
+ assert_equal(expect_json_object.longitude,json_object.longitude)
73
+ assert_equal(expect_json_object.latitude,json_object.latitude)
74
+ assert_equal(expect_json_object.music_category,json_object.music_category)
75
+ assert_equal(expect_json_object.order_num,json_object.order_num)
76
+ assert_equal(expect_json_object.is_pick,json_object.is_pick)
77
+ assert_equal(expect_json_object.rich_intro,json_object.rich_intro)
78
+ assert_equal(expect_json_object.short_intro,json_object.short_intro)
79
+ assert_equal(expect_json_object.comment_content,json_object.comment_content)
80
+ assert_equal(expect_json_object.comment_id,json_object.comment_id)
81
+ assert_equal(expect_json_object.dig_status,json_object.dig_status)
82
+ assert_equal(expect_json_object.approved_at,json_object.approved_at)
83
+ assert_equal(expect_json_object.is_deleted,json_object.is_deleted)
84
+ assert_equal(expect_json_object.mp3size,json_object.mp3size)
85
+ assert_equal(expect_json_object.mp3size_32,json_object.mp3size_32)
86
+ assert_equal(expect_json_object.mp3size_64,json_object.mp3size_64)
87
+ assert_equal(expect_json_object.waveform,json_object.waveform)
88
+ assert_equal(expect_json_object.upload_id,json_object.upload_id)
89
+ assert_equal(expect_json_object.updated_at,json_object.updated_at)
90
+ assert_equal(expect_json_object.created_at,json_object.created_at)
91
+ assert_equal(expect_json_object.source_url,json_object.source_url)
92
+ assert_equal(expect_json_object.status,json_object.status)
93
+ assert_equal(expect_json_object.explore_height,json_object.explore_height)
94
+ assert_equal(expect_json_object.id,json_object.id)
95
+ puts "JsonCodecTest test_codec method stop"
51
96
  end
52
97
 
53
98
  def teardown
@@ -3,10 +3,9 @@ $:.unshift File.expand_path("../../test", __FILE__)
3
3
  require "test/unit"
4
4
  require "xunch"
5
5
  require 'yaml'
6
- require 'track_record_origin'
6
+ require 'test_helper'
7
7
 
8
-
9
- class ObjectCacheTest < Test::Unit::TestCase
8
+ class ListFieldObjectCacheTest < Test::Unit::TestCase
10
9
  include Test::Unit::Assertions
11
10
  def setup
12
11
  super
@@ -14,87 +13,15 @@ class ObjectCacheTest < Test::Unit::TestCase
14
13
  file = File.join(root, 'test/xunch.yaml')
15
14
  caches = Xunch::CacheBuilder.build(file)
16
15
  @list_object_cache = caches["fieldtracklist"]
17
- @cache_object = TrackRecordOrigin.find(1)
18
- @cache_objects = [@cache_object]
19
- @keys = [1]
20
- for i in 2 .. 100 do
21
- new_cache_object = TrackRecordOrigin.new
22
- new_cache_object.track_id = @cache_object.track_id
23
- new_cache_object.track_uid = @cache_object.track_uid
24
- new_cache_object.track_upload_source = @cache_object.track_upload_source
25
- new_cache_object.op_type = @cache_object.op_type
26
- new_cache_object.is_publish = @cache_object.is_publish
27
- new_cache_object.upload_source = @cache_object.upload_source
28
- new_cache_object.uid = @cache_object.uid
29
- new_cache_object.nickname = @cache_object.nickname
30
- new_cache_object.avatar_path = @cache_object.avatar_path
31
- new_cache_object.is_v = @cache_object.is_v
32
- new_cache_object.human_category_id = @cache_object.human_category_id
33
- new_cache_object.title = @cache_object.title
34
- new_cache_object.intro = @cache_object.intro
35
- new_cache_object.user_source = @cache_object.user_source
36
- new_cache_object.category_id = @cache_object.category_id
37
- new_cache_object.duration = @cache_object.duration
38
- new_cache_object.play_path = @cache_object.play_path
39
- new_cache_object.play_path_32 = @cache_object.play_path_32
40
- new_cache_object.play_path_64 = @cache_object.play_path_64
41
- new_cache_object.play_path_128 = @cache_object.play_path_128
42
- new_cache_object.transcode_state = @cache_object.transcode_state
43
- new_cache_object.download_path = @cache_object.download_path
44
- new_cache_object.cover_path = @cache_object.cover_path
45
- new_cache_object.album_id = @cache_object.album_id
46
- new_cache_object.album_title = @cache_object.album_title
47
- new_cache_object.album_cover_path = @cache_object.album_cover_path
48
- new_cache_object.tags = @cache_object.tags
49
- new_cache_object.ignore_tags = @cache_object.ignore_tags
50
- new_cache_object.extra_tags = @cache_object.extra_tags
51
- new_cache_object.singer = @cache_object.singer
52
- new_cache_object.singer_category = @cache_object.singer_category
53
- new_cache_object.author = @cache_object.author
54
- new_cache_object.composer = @cache_object.composer
55
- new_cache_object.arrangement = @cache_object.arrangement
56
- new_cache_object.post_production = @cache_object.post_production
57
- new_cache_object.lyric_path = @cache_object.lyric_path
58
- new_cache_object.lyric = @cache_object.lyric
59
- new_cache_object.language = @cache_object.language
60
- new_cache_object.resinger = @cache_object.resinger
61
- new_cache_object.announcer = @cache_object.announcer
62
- new_cache_object.is_public = @cache_object.is_public
63
- new_cache_object.access_password = @cache_object.access_password
64
- new_cache_object.allow_download = @cache_object.allow_download
65
- new_cache_object.allow_comment = @cache_object.allow_comment
66
- new_cache_object.is_crawler = @cache_object.is_crawler
67
- new_cache_object.inet_aton_ip = @cache_object.inet_aton_ip
68
- new_cache_object.longitude = @cache_object.longitude
69
- new_cache_object.latitude = @cache_object.latitude
70
- new_cache_object.music_category = @cache_object.music_category
71
- new_cache_object.order_num = @cache_object.order_num
72
- new_cache_object.is_pick = @cache_object.is_pick
73
- new_cache_object.rich_intro = @cache_object.rich_intro
74
- new_cache_object.short_intro = @cache_object.short_intro
75
- new_cache_object.comment_content = @cache_object.comment_content
76
- new_cache_object.comment_id = @cache_object.comment_id
77
- new_cache_object.dig_status = @cache_object.dig_status
78
- new_cache_object.approved_at = @cache_object.approved_at
79
- new_cache_object.is_deleted = @cache_object.is_deleted
80
- new_cache_object.mp3size = @cache_object.mp3size
81
- new_cache_object.mp3size_32 = @cache_object.mp3size_32
82
- new_cache_object.mp3size_64 = @cache_object.mp3size_64
83
- new_cache_object.waveform = @cache_object.waveform
84
- new_cache_object.upload_id = @cache_object.upload_id
85
- new_cache_object.updated_at = @cache_object.updated_at
86
- new_cache_object.created_at = @cache_object.created_at
87
- new_cache_object.source_url = @cache_object.source_url
88
- new_cache_object.status = @cache_object.status
89
- new_cache_object.explore_height = @cache_object.explore_height
90
- new_cache_object.id = i
91
- @cache_objects.push new_cache_object
92
- @keys.push new_cache_object.id
93
- end
16
+ hash = TestHelper.build_objects
17
+ @cache_object = hash["object"]
18
+ @cache_objects = hash["objects"]
19
+ @keys = hash["keys"]
94
20
  puts "setup"
95
21
  end
96
22
 
97
23
  def test_put_get
24
+ puts "ListFieldObjectCacheTest test_put_get method start"
98
25
  result = @list_object_cache.put("1",@cache_objects)
99
26
  hash = @list_object_cache.get("1",1,100)
100
27
  keys = hash["keys"]
@@ -183,10 +110,12 @@ class ObjectCacheTest < Test::Unit::TestCase
183
110
  # assert_equal(@cache_objects[i].status,objects[i].status)
184
111
  # assert_equal(@cache_objects[i].explore_height,objects[i].explore_height)
185
112
  end
113
+ puts "ListFieldObjectCacheTest test_put_get method stop"
186
114
  end
187
115
 
188
116
  def test_put_get_benchmark
189
- times = 1000
117
+ puts "ListFieldObjectCacheTest test_put_get_benchmark method start"
118
+ times = TestHelper::TIMES
190
119
  start = Time.now
191
120
  for i in 1 .. times do
192
121
  result = @list_object_cache.put("1",@cache_objects)
@@ -201,6 +130,7 @@ class ObjectCacheTest < Test::Unit::TestCase
201
130
  stop = Time.now
202
131
  use = stop - start
203
132
  puts "#{times} times get operations total use #{use} seconds"
133
+ puts "ListFieldObjectCacheTest test_put_get_benchmark method stop"
204
134
  end
205
135
 
206
136
  def teardown
@@ -0,0 +1,75 @@
1
+ $:.unshift File.expand_path("../../lib", __FILE__)
2
+ $:.unshift File.expand_path("../../test", __FILE__)
3
+ require "test/unit"
4
+ require "xunch"
5
+ require 'yaml'
6
+ require 'test_helper'
7
+
8
+ class ListIdCacheTest < Test::Unit::TestCase
9
+ include Test::Unit::Assertions
10
+ def setup
11
+ super
12
+ root = File.expand_path("../..", __FILE__)
13
+ file = File.join(root, 'test/xunch.yaml')
14
+ caches = Xunch::CacheBuilder.build(file)
15
+ @list_id_cache = caches["trackidlist"]
16
+ hash = TestHelper.build_objects
17
+ @cache_object = hash["object"]
18
+ @cache_objects = hash["objects"]
19
+ @keys = hash["keys"]
20
+ puts "setup"
21
+ end
22
+
23
+ def test_put_get
24
+ puts "ListIdCacheTest test_put_get method start"
25
+ result = @list_id_cache.put("idlist",@keys)
26
+ puts result
27
+ keys = @list_id_cache.get("idlist",1,100)
28
+ assert_equal(@keys.length, keys.length)
29
+ assert_raise{
30
+ @list_id_cache.get("idlist",1,101)
31
+ }
32
+ assert_raise{
33
+ @list_id_cache.get("idlist",nil,31)
34
+ }
35
+ size = @list_id_cache.size("idlist");
36
+ assert_equal(100,size)
37
+ flags = @list_id_cache.remove("idlist",["1","2","99","100","101"])
38
+ assert_equal([1,1,1,1,0],flags)
39
+ size = @list_id_cache.size("idlist");
40
+ assert_equal(96,size)
41
+ flag = @list_id_cache.evict("idlist")
42
+ assert_equal(1,flag)
43
+ keys = @list_id_cache.get("idlist",1,100)
44
+ assert_equal(0,keys.length)
45
+ size = @list_id_cache.size("idlist");
46
+ assert_equal(0,size)
47
+ puts "ListIdCacheTest test_put_get method stop"
48
+ end
49
+
50
+ def test_put_get_benchmark
51
+ puts "ListIdCacheTest test_put_get_benchmark method start"
52
+ times = TestHelper::TIMES
53
+ start = Time.now
54
+ for i in 1 .. times do
55
+ result = @list_id_cache.put("idlist",@keys)
56
+ end
57
+ stop = Time.now
58
+ use = stop - start
59
+ puts "#{times} times put operations total use #{use} seconds"
60
+ start = Time.now
61
+ for i in 1 .. times do
62
+ result = @list_id_cache.get("1",1,100)
63
+ end
64
+ stop = Time.now
65
+ use = stop - start
66
+ puts "#{times} times get operations total use #{use} seconds"
67
+ puts "ListIdCacheTest test_put_get_benchmark method stop"
68
+ end
69
+
70
+ def teardown
71
+ super
72
+ puts "teardown"
73
+ end
74
+ end
75
+
@@ -3,10 +3,9 @@ $:.unshift File.expand_path("../../test", __FILE__)
3
3
  require "test/unit"
4
4
  require "xunch"
5
5
  require 'yaml'
6
- require 'track_record_origin'
6
+ require 'test_helper'
7
7
 
8
-
9
- class ObjectCacheTest < Test::Unit::TestCase
8
+ class ListObjectCacheTest < Test::Unit::TestCase
10
9
  include Test::Unit::Assertions
11
10
  def setup
12
11
  super
@@ -14,87 +13,15 @@ class ObjectCacheTest < Test::Unit::TestCase
14
13
  file = File.join(root, 'test/xunch.yaml')
15
14
  caches = Xunch::CacheBuilder.build(file)
16
15
  @list_object_cache = caches["tracklist"]
17
- @cache_object = TrackRecordOrigin.find(1)
18
- @cache_objects = [@cache_object]
19
- @keys = [1]
20
- for i in 2 .. 100 do
21
- new_cache_object = TrackRecordOrigin.new
22
- new_cache_object.track_id = @cache_object.track_id
23
- new_cache_object.track_uid = @cache_object.track_uid
24
- new_cache_object.track_upload_source = @cache_object.track_upload_source
25
- new_cache_object.op_type = @cache_object.op_type
26
- new_cache_object.is_publish = @cache_object.is_publish
27
- new_cache_object.upload_source = @cache_object.upload_source
28
- new_cache_object.uid = @cache_object.uid
29
- new_cache_object.nickname = @cache_object.nickname
30
- new_cache_object.avatar_path = @cache_object.avatar_path
31
- new_cache_object.is_v = @cache_object.is_v
32
- new_cache_object.human_category_id = @cache_object.human_category_id
33
- new_cache_object.title = @cache_object.title
34
- new_cache_object.intro = @cache_object.intro
35
- new_cache_object.user_source = @cache_object.user_source
36
- new_cache_object.category_id = @cache_object.category_id
37
- new_cache_object.duration = @cache_object.duration
38
- new_cache_object.play_path = @cache_object.play_path
39
- new_cache_object.play_path_32 = @cache_object.play_path_32
40
- new_cache_object.play_path_64 = @cache_object.play_path_64
41
- new_cache_object.play_path_128 = @cache_object.play_path_128
42
- new_cache_object.transcode_state = @cache_object.transcode_state
43
- new_cache_object.download_path = @cache_object.download_path
44
- new_cache_object.cover_path = @cache_object.cover_path
45
- new_cache_object.album_id = @cache_object.album_id
46
- new_cache_object.album_title = @cache_object.album_title
47
- new_cache_object.album_cover_path = @cache_object.album_cover_path
48
- new_cache_object.tags = @cache_object.tags
49
- new_cache_object.ignore_tags = @cache_object.ignore_tags
50
- new_cache_object.extra_tags = @cache_object.extra_tags
51
- new_cache_object.singer = @cache_object.singer
52
- new_cache_object.singer_category = @cache_object.singer_category
53
- new_cache_object.author = @cache_object.author
54
- new_cache_object.composer = @cache_object.composer
55
- new_cache_object.arrangement = @cache_object.arrangement
56
- new_cache_object.post_production = @cache_object.post_production
57
- new_cache_object.lyric_path = @cache_object.lyric_path
58
- new_cache_object.lyric = @cache_object.lyric
59
- new_cache_object.language = @cache_object.language
60
- new_cache_object.resinger = @cache_object.resinger
61
- new_cache_object.announcer = @cache_object.announcer
62
- new_cache_object.is_public = @cache_object.is_public
63
- new_cache_object.access_password = @cache_object.access_password
64
- new_cache_object.allow_download = @cache_object.allow_download
65
- new_cache_object.allow_comment = @cache_object.allow_comment
66
- new_cache_object.is_crawler = @cache_object.is_crawler
67
- new_cache_object.inet_aton_ip = @cache_object.inet_aton_ip
68
- new_cache_object.longitude = @cache_object.longitude
69
- new_cache_object.latitude = @cache_object.latitude
70
- new_cache_object.music_category = @cache_object.music_category
71
- new_cache_object.order_num = @cache_object.order_num
72
- new_cache_object.is_pick = @cache_object.is_pick
73
- new_cache_object.rich_intro = @cache_object.rich_intro
74
- new_cache_object.short_intro = @cache_object.short_intro
75
- new_cache_object.comment_content = @cache_object.comment_content
76
- new_cache_object.comment_id = @cache_object.comment_id
77
- new_cache_object.dig_status = @cache_object.dig_status
78
- new_cache_object.approved_at = @cache_object.approved_at
79
- new_cache_object.is_deleted = @cache_object.is_deleted
80
- new_cache_object.mp3size = @cache_object.mp3size
81
- new_cache_object.mp3size_32 = @cache_object.mp3size_32
82
- new_cache_object.mp3size_64 = @cache_object.mp3size_64
83
- new_cache_object.waveform = @cache_object.waveform
84
- new_cache_object.upload_id = @cache_object.upload_id
85
- new_cache_object.updated_at = @cache_object.updated_at
86
- new_cache_object.created_at = @cache_object.created_at
87
- new_cache_object.source_url = @cache_object.source_url
88
- new_cache_object.status = @cache_object.status
89
- new_cache_object.explore_height = @cache_object.explore_height
90
- new_cache_object.id = i
91
- @cache_objects.push new_cache_object
92
- @keys.push new_cache_object.id
93
- end
16
+ hash = TestHelper.build_objects
17
+ @cache_object = hash["object"]
18
+ @cache_objects = hash["objects"]
19
+ @keys = hash["keys"]
94
20
  puts "setup"
95
21
  end
96
22
 
97
23
  def test_put_get
24
+ puts "ListObjectCacheTest test_put_get method start"
98
25
  result = @list_object_cache.put("1",@cache_objects)
99
26
  hash = @list_object_cache.get("1",1,100)
100
27
  keys = hash["keys"]
@@ -183,10 +110,12 @@ class ObjectCacheTest < Test::Unit::TestCase
183
110
  assert_equal(@cache_objects[i].explore_height,objects[i].explore_height)
184
111
  assert_equal(@cache_objects[i].id,objects[i].id)
185
112
  end
113
+ puts "ListObjectCacheTest test_put_get method stop"
186
114
  end
187
115
 
188
116
  def test_put_get_benchmark
189
- times = 1000
117
+ puts "ListObjectCacheTest test_put_get_benchmark method start"
118
+ times = TestHelper::TIMES
190
119
  start = Time.now
191
120
  for i in 1 .. times do
192
121
  result = @list_object_cache.put("1",@cache_objects)
@@ -201,6 +130,7 @@ class ObjectCacheTest < Test::Unit::TestCase
201
130
  stop = Time.now
202
131
  use = stop - start
203
132
  puts "#{times} times get operations total use #{use} seconds"
133
+ puts "ListObjectCacheTest test_put_get_benchmark method stop"
204
134
  end
205
135
 
206
136
  def teardown
@@ -11,6 +11,7 @@ class NginxCacheHelperTest < Test::Unit::TestCase
11
11
  end
12
12
 
13
13
  def test_evict
14
+ puts "NginxCacheHelperTest test_evict method start"
14
15
  assert_true(@helper.evict("/1000001/"))
15
16
  assert_true(@helper.evict("/1000002/"))
16
17
  assert_true(@helper.evict("/1000003/"))
@@ -22,9 +23,11 @@ class NginxCacheHelperTest < Test::Unit::TestCase
22
23
  assert_true(@helper.evict("/1000009/"))
23
24
  assert_true(@helper.evict("/1000010/"))
24
25
  assert_false(@helper.cache("/1000010"))
26
+ puts "NginxCacheHelperTest test_evict method stop"
25
27
  end
26
28
 
27
29
  def test_cache
30
+ puts "NginxCacheHelperTest test_cache method start"
28
31
  assert_true(@helper.cache("/1000001/"))
29
32
  assert_true(@helper.cache("/1000002/"))
30
33
  assert_true(@helper.cache("/1000003/"))
@@ -36,6 +39,7 @@ class NginxCacheHelperTest < Test::Unit::TestCase
36
39
  assert_true(@helper.cache("/1000009/"))
37
40
  assert_true(@helper.cache("/1000010/"))
38
41
  assert_false(@helper.cache("/1000010"))
42
+ puts "NginxCacheHelperTest test_cache method stop"
39
43
  end
40
44
 
41
45
  def teardown