rims 0.2.4 → 0.2.5

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.
@@ -194,6 +194,12 @@ Hello Joe, do you think we can meet at 3:30 tomorrow?
194
194
  assert_equal([ 'A003', 'APPEND', 'saved-messages', "foo\nbody[]\nbar\n" ],
195
195
  @reader.parse([ 'A003', 'APPEND', 'saved-messages', "foo\nbody[]\nbar\n" ]))
196
196
 
197
+ error = assert_raise(RIMS::SyntaxError) { @reader.parse([ '*', 'OK', '['.intern, 'UNSEEN', '12' ]) }
198
+ assert_match(/not found a terminator/, error.message)
199
+
200
+ error = assert_raise(RIMS::SyntaxError) { @reader.parse([ '*', 'LIST', '('.intern, '\Noselect' ]) }
201
+ assert_match(/not found a terminator/, error.message)
202
+
197
203
  assert_equal('', @output.string)
198
204
  end
199
205
 
@@ -6,6 +6,8 @@ require 'time'
6
6
 
7
7
  module RIMS::Test
8
8
  class ProtocolSearchParserTest < Test::Unit::TestCase
9
+ include ProtocolFetchMailSample
10
+
9
11
  def setup
10
12
  @kv_store = {}
11
13
  @kvs_open = proc{|path| RIMS::Hash_KeyValueStore.new(@kv_store[path] = {}) }
@@ -54,7 +56,7 @@ module RIMS::Test
54
56
 
55
57
  def make_search_parser(charset: nil)
56
58
  yield
57
- @folder = @mail_store.select_mbox(@inbox_id).reload
59
+ @folder = @mail_store.open_folder(@inbox_id, read_only: true).reload
58
60
  @parser = RIMS::Protocol::SearchParser.new(@mail_store, @folder)
59
61
  @parser.charset = charset if charset
60
62
  nil
@@ -675,6 +677,30 @@ Content-Type: text/html
675
677
  assert_search_syntax_error([ 'TEXT', [ :group, 'foo'] ], /search string expected as <String> but was/)
676
678
  end
677
679
 
680
+ def test_parse_text_multipart
681
+ make_mail_multipart
682
+ make_search_parser{
683
+ add_msg(@mpart_mail.raw_source)
684
+ assert_msg_uid(1)
685
+ }
686
+
687
+ parse_search_key([ 'TEXT', 'Subject: multipart test' ]) {
688
+ assert_search_cond(0, true)
689
+ }
690
+ parse_search_key([ 'TEXT', 'Subject: inner multipart' ]) {
691
+ assert_search_cond(0, true)
692
+ }
693
+ parse_search_key([ 'TEXT', 'Hello world.' ]) {
694
+ assert_search_cond(0, true)
695
+ }
696
+ parse_search_key([ 'TEXT', 'HALO' ]) {
697
+ assert_search_cond(0, true)
698
+ }
699
+ parse_search_key([ 'TEXT', 'detarame' ]) {
700
+ assert_search_cond(0, false)
701
+ }
702
+ end
703
+
678
704
  def test_parse_to
679
705
  make_search_parser{
680
706
  add_msg("To: foo\r\n" +
@@ -565,6 +565,38 @@ module RIMS::Test
565
565
  assert_equal(expected_value, @c.accept_polling_timeout_seconds)
566
566
  end
567
567
 
568
+ data('default' => [ 0, {} ],
569
+ 'config' => [ 4, { server: { process_num: 4 } } ])
570
+ def test_process_num(data)
571
+ expected_value, config = data
572
+ @c.load(config)
573
+ assert_equal(expected_value, @c.process_num)
574
+ end
575
+
576
+ data('default' => [ 20, {} ],
577
+ 'config' => [ 30, { server: { process_queue_size: 30 } } ])
578
+ def test_process_queue_size(data)
579
+ expected_value, config = data
580
+ @c.load(config)
581
+ assert_equal(expected_value, @c.process_queue_size)
582
+ end
583
+
584
+ data('default' => [ 0.1, {} ],
585
+ 'config' => [ 1, { server: { process_queue_polling_timeout_seconds: 1 } } ])
586
+ def test_process_queue_polling_timeout_seconds(data)
587
+ expected_value, config = data
588
+ @c.load(config)
589
+ assert_equal(expected_value, @c.process_queue_polling_timeout_seconds)
590
+ end
591
+
592
+ data('default' => [ 0.1, {} ],
593
+ 'config' => [ 1, { server: { process_send_io_polling_timeout_seconds: 1 } } ])
594
+ def test_process_send_io_polling_timeout_seconds(data)
595
+ expected_value, config = data
596
+ @c.load(config)
597
+ assert_equal(expected_value, @c.process_send_io_polling_timeout_seconds)
598
+ end
599
+
568
600
  data('default' => [ 20, {} ],
569
601
  'config' => [ 30, { server: { thread_num: 30 } } ])
570
602
  def test_thread_num(data)
@@ -677,11 +709,50 @@ module RIMS::Test
677
709
  assert_equal(expected_values, limits.to_h)
678
710
  end
679
711
 
712
+ data('default' => [ 0, {} ],
713
+ 'config' => [ 4,
714
+ { drb_services: {
715
+ process_num: 4
716
+ }
717
+ }
718
+ ])
719
+ def test_drb_process_num(data)
720
+ expected_value, config = data
721
+ @c.load(config)
722
+ assert_equal(expected_value, @c.drb_process_num)
723
+ end
724
+
725
+ data('default' => [ 100, {} ],
726
+ 'config' => [ 1024,
727
+ { drb_services: {
728
+ engine: {
729
+ bulk_response_count: 1024
730
+ }
731
+ }
732
+ }
733
+ ])
734
+ def test_bulk_response_count(data)
735
+ expected_value, config = data
736
+ @c.load(config)
737
+ assert_equal(expected_value, @c.bulk_response_count)
738
+ end
739
+
680
740
  data('default' => [ 30, {} ],
681
- 'config' => [ 15, { lock: { read_lock_timeout_seconds: 15 } } ],
741
+ 'config' => [ 15,
742
+ { drb_services: {
743
+ engine: {
744
+ read_lock_timeout_seconds: 15
745
+ }
746
+ }
747
+ }
748
+ ],
682
749
  'compat' => [ 15, { read_lock_timeout_seconds: 15 } ],
683
750
  'priority' => [ 15,
684
- { lock: { read_lock_timeout_seconds: 15 },
751
+ { drb_services: {
752
+ engine: {
753
+ read_lock_timeout_seconds: 15
754
+ }
755
+ },
685
756
  read_lock_timeout_seconds: 20
686
757
  }
687
758
  ])
@@ -692,10 +763,21 @@ module RIMS::Test
692
763
  end
693
764
 
694
765
  data('default' => [ 30, {} ],
695
- 'config' => [ 15, { lock: { write_lock_timeout_seconds: 15 } } ],
766
+ 'config' => [ 15,
767
+ { drb_services: {
768
+ engine: {
769
+ write_lock_timeout_seconds: 15
770
+ }
771
+ }
772
+ }
773
+ ],
696
774
  'compat' => [ 15, { write_lock_timeout_seconds: 15 } ],
697
775
  'priority' => [ 15,
698
- { lock: { write_lock_timeout_seconds: 15 },
776
+ { drb_services: {
777
+ engine: {
778
+ write_lock_timeout_seconds: 15
779
+ }
780
+ },
699
781
  write_lock_timeout_seconds: 20,
700
782
  }
701
783
  ])
@@ -706,10 +788,21 @@ module RIMS::Test
706
788
  end
707
789
 
708
790
  data('default' => [ 1, {} ],
709
- 'config' => [ 3, { lock: { cleanup_write_lock_timeout_seconds: 3 } } ],
791
+ 'config' => [ 3,
792
+ { drb_services: {
793
+ engine: {
794
+ cleanup_write_lock_timeout_seconds: 3
795
+ }
796
+ }
797
+ }
798
+ ],
710
799
  'compat' => [ 3, { cleanup_write_lock_timeout_seconds: 3 } ],
711
800
  'priority' => [ 3,
712
- { lock: { cleanup_write_lock_timeout_seconds: 3 },
801
+ { drb_services: {
802
+ engine: {
803
+ cleanup_write_lock_timeout_seconds: 3
804
+ }
805
+ },
713
806
  cleanup_write_lock_timeout_seconds: 5
714
807
  }
715
808
  ])
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rims
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - TOKI Yoshinori
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-25 00:00:00.000000000 Z
11
+ date: 2019-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: riser
@@ -126,7 +126,6 @@ files:
126
126
  - lib/rims/lock.rb
127
127
  - lib/rims/mail_store.rb
128
128
  - lib/rims/passwd.rb
129
- - lib/rims/pool.rb
130
129
  - lib/rims/protocol.rb
131
130
  - lib/rims/protocol/connection.rb
132
131
  - lib/rims/protocol/decoder.rb
@@ -1,85 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- module RIMS
4
- class ObjectPool
5
- class ObjectHolder
6
- def initialize(object_pool, object_key)
7
- @object_pool = object_pool
8
- @object_key = object_key
9
- end
10
-
11
- attr_reader :object_key
12
-
13
- def object_destroy
14
- end
15
-
16
- # optional block is called when a mail store is closed.
17
- def return_pool(&block) # yields:
18
- @object_pool.put(self, &block)
19
- nil
20
- end
21
- end
22
-
23
- class ReferenceCount
24
- def initialize(count, object_holder)
25
- @count = count
26
- @object_holder = object_holder
27
- end
28
-
29
- attr_accessor :count
30
- attr_reader :object_holder
31
-
32
- def object_destroy
33
- @object_holder.object_destroy
34
- end
35
- end
36
-
37
- def initialize(&object_factory) # yields: object_pool, object_key, object_lock
38
- @mutex = Thread::Mutex.new
39
- @object_factory = object_factory
40
- @pool = {}
41
- end
42
-
43
- def empty?
44
- @mutex.synchronize{ @pool.empty? }
45
- end
46
-
47
- # optional block is called when a new object is added to an object pool.
48
- def get(object_key) # yields:
49
- @mutex.synchronize{
50
- if (@pool.key? object_key) then
51
- ref_count = @pool[object_key]
52
- else
53
- yield if block_given?
54
- object_holder = @object_factory.call(self, object_key)
55
- ref_count = ReferenceCount.new(0, object_holder)
56
- @pool[object_key] = ref_count
57
- end
58
- ref_count.count >= 0 or raise 'internal error'
59
- ref_count.count += 1
60
- ref_count.object_holder
61
- }
62
- end
63
-
64
- # optional block is called when an object is deleted from an object pool.
65
- def put(object_holder) # yields:
66
- @mutex.synchronize{
67
- ref_count = @pool[object_holder.object_key] or raise 'internal error'
68
- ref_count.object_holder.equal? object_holder or raise 'internal error'
69
- ref_count.count > 0 or raise 'internal error'
70
- ref_count.count -= 1
71
- if (ref_count.count == 0) then
72
- @pool.delete(object_holder.object_key)
73
- ref_count.object_destroy
74
- yield if block_given?
75
- end
76
- }
77
- nil
78
- end
79
- end
80
- end
81
-
82
- # Local Variables:
83
- # mode: Ruby
84
- # indent-tabs-mode: nil
85
- # End: