activeldap 1.0.0 → 1.0.1

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.
Files changed (137) hide show
  1. data/CHANGES +10 -0
  2. data/README +3 -2
  3. data/data/locale/en/LC_MESSAGES/active-ldap.mo +0 -0
  4. data/data/locale/ja/LC_MESSAGES/active-ldap.mo +0 -0
  5. data/examples/al-admin/po/en/al-admin.po +1 -1
  6. data/examples/al-admin/po/ja/al-admin.po +1 -1
  7. data/examples/al-admin/po/nl/al-admin.po +1 -1
  8. data/examples/al-admin/vendor/plugins/exception_notification/lib/exception_notifier.rb +7 -8
  9. data/examples/al-admin/vendor/plugins/exception_notification/lib/exception_notifier_helper.rb +2 -1
  10. data/examples/al-admin/vendor/plugins/exception_notification/views/exception_notifier/_environment.rhtml +1 -1
  11. data/examples/al-admin/vendor/plugins/exception_notification/views/exception_notifier/_request.rhtml +2 -1
  12. data/lib/active_ldap.rb +9 -3
  13. data/lib/active_ldap/action_controller/ldap_benchmarking.rb +36 -0
  14. data/lib/active_ldap/adapter/jndi.rb +1 -1
  15. data/lib/active_ldap/adapter/jndi_connection.rb +2 -1
  16. data/lib/active_ldap/association/belongs_to_many.rb +10 -2
  17. data/lib/active_ldap/association/collection.rb +10 -0
  18. data/lib/active_ldap/association/has_many_utils.rb +13 -9
  19. data/lib/active_ldap/association/has_many_wrap.rb +10 -2
  20. data/lib/active_ldap/associations.rb +3 -3
  21. data/lib/active_ldap/base.rb +95 -32
  22. data/lib/active_ldap/connection.rb +1 -1
  23. data/lib/active_ldap/distinguished_name.rb +3 -0
  24. data/lib/active_ldap/entry_attribute.rb +2 -2
  25. data/lib/active_ldap/ldif.rb +2 -2
  26. data/lib/active_ldap/operations.rb +7 -3
  27. data/lib/active_ldap/user_password.rb +0 -1
  28. data/lib/active_ldap/validations.rb +2 -0
  29. data/po/en/active-ldap.po +1 -1
  30. data/po/ja/active-ldap.po +1 -1
  31. data/rails/plugin/active_ldap/init.rb +3 -34
  32. data/test-unit/History.txt +32 -0
  33. data/test-unit/Manifest.txt +70 -0
  34. data/test-unit/README.txt +32 -0
  35. data/test-unit/Rakefile +22 -0
  36. data/test-unit/bin/testrb +5 -0
  37. data/test-unit/lib/test/unit.rb +280 -0
  38. data/test-unit/lib/test/unit/assertionfailederror.rb +14 -0
  39. data/test-unit/lib/test/unit/assertions.rb +722 -0
  40. data/test-unit/lib/test/unit/attribute.rb +125 -0
  41. data/test-unit/lib/test/unit/autorunner.rb +250 -0
  42. data/test-unit/lib/test/unit/collector.rb +43 -0
  43. data/test-unit/lib/test/unit/collector/descendant.rb +23 -0
  44. data/test-unit/lib/test/unit/collector/dir.rb +108 -0
  45. data/test-unit/lib/test/unit/collector/load.rb +135 -0
  46. data/test-unit/lib/test/unit/collector/objectspace.rb +34 -0
  47. data/test-unit/lib/test/unit/color.rb +61 -0
  48. data/test-unit/lib/test/unit/diff.rb +524 -0
  49. data/test-unit/lib/test/unit/error.rb +124 -0
  50. data/test-unit/lib/test/unit/exceptionhandler.rb +39 -0
  51. data/test-unit/lib/test/unit/failure.rb +110 -0
  52. data/test-unit/lib/test/unit/fixture.rb +185 -0
  53. data/test-unit/lib/test/unit/notification.rb +116 -0
  54. data/test-unit/lib/test/unit/omission.rb +129 -0
  55. data/test-unit/lib/test/unit/pending.rb +130 -0
  56. data/test-unit/lib/test/unit/priority.rb +146 -0
  57. data/test-unit/lib/test/unit/runner/console.rb +46 -0
  58. data/test-unit/lib/test/unit/runner/emacs.rb +8 -0
  59. data/test-unit/lib/test/unit/testcase.rb +174 -0
  60. data/test-unit/lib/test/unit/testresult.rb +89 -0
  61. data/test-unit/lib/test/unit/testsuite.rb +110 -0
  62. data/test-unit/lib/test/unit/ui/console/outputlevel.rb +14 -0
  63. data/test-unit/lib/test/unit/ui/console/testrunner.rb +195 -0
  64. data/test-unit/lib/test/unit/ui/emacs/testrunner.rb +49 -0
  65. data/test-unit/lib/test/unit/ui/testrunner.rb +20 -0
  66. data/test-unit/lib/test/unit/ui/testrunnermediator.rb +77 -0
  67. data/test-unit/lib/test/unit/ui/testrunnerutilities.rb +41 -0
  68. data/test-unit/lib/test/unit/util/backtracefilter.rb +41 -0
  69. data/test-unit/lib/test/unit/util/observable.rb +90 -0
  70. data/test-unit/lib/test/unit/util/procwrapper.rb +48 -0
  71. data/test-unit/lib/test/unit/version.rb +7 -0
  72. data/test-unit/sample/adder.rb +13 -0
  73. data/test-unit/sample/subtracter.rb +12 -0
  74. data/test-unit/sample/tc_adder.rb +18 -0
  75. data/test-unit/sample/tc_subtracter.rb +18 -0
  76. data/test-unit/sample/ts_examples.rb +7 -0
  77. data/test-unit/test/collector/test_descendant.rb +135 -0
  78. data/test-unit/test/collector/test_dir.rb +406 -0
  79. data/test-unit/test/collector/test_load.rb +333 -0
  80. data/test-unit/test/collector/test_objectspace.rb +98 -0
  81. data/test-unit/test/run-test.rb +13 -0
  82. data/test-unit/test/test_assertions.rb +693 -0
  83. data/test-unit/test/test_attribute.rb +86 -0
  84. data/{test-unit-ext → test-unit}/test/test_color.rb +3 -5
  85. data/{test-unit-ext → test-unit}/test/test_diff.rb +18 -16
  86. data/test-unit/test/test_emacs_runner.rb +60 -0
  87. data/test-unit/test/test_error.rb +26 -0
  88. data/test-unit/test/test_failure.rb +33 -0
  89. data/test-unit/test/test_fixture.rb +275 -0
  90. data/{test-unit-ext → test-unit}/test/test_notification.rb +7 -6
  91. data/test-unit/test/test_omission.rb +81 -0
  92. data/{test-unit-ext → test-unit}/test/test_pending.rb +15 -15
  93. data/{test-unit-ext → test-unit}/test/test_priority.rb +4 -3
  94. data/test-unit/test/test_testcase.rb +411 -0
  95. data/test-unit/test/test_testresult.rb +113 -0
  96. data/test-unit/test/test_testsuite.rb +129 -0
  97. data/test-unit/test/testunit_test_util.rb +12 -0
  98. data/test-unit/test/ui/test_testrunmediator.rb +20 -0
  99. data/test-unit/test/util/test_backtracefilter.rb +41 -0
  100. data/test-unit/test/util/test_observable.rb +102 -0
  101. data/test-unit/test/util/test_procwrapper.rb +36 -0
  102. data/test/al-test-utils.rb +4 -4
  103. data/test/command.rb +1 -1
  104. data/test/run-test.rb +5 -4
  105. data/test/test_associations.rb +143 -9
  106. data/test/test_base.rb +25 -1
  107. data/test/test_dn.rb +2 -0
  108. data/test/test_find.rb +8 -1
  109. data/test/test_ldif.rb +51 -114
  110. data/test/test_reflection.rb +4 -8
  111. data/test/test_usermod-lang-add.rb +2 -1
  112. data/test/test_validation.rb +4 -3
  113. metadata +76 -31
  114. data/test-unit-ext/NEWS.en +0 -28
  115. data/test-unit-ext/NEWS.ja +0 -28
  116. data/test-unit-ext/README.en +0 -247
  117. data/test-unit-ext/README.ja +0 -246
  118. data/test-unit-ext/Rakefile +0 -111
  119. data/test-unit-ext/lib/test-unit-ext.rb +0 -16
  120. data/test-unit-ext/lib/test-unit-ext/always-show-result.rb +0 -28
  121. data/test-unit-ext/lib/test-unit-ext/assertions.rb +0 -40
  122. data/test-unit-ext/lib/test-unit-ext/attributes.rb +0 -129
  123. data/test-unit-ext/lib/test-unit-ext/backtrace-filter.rb +0 -17
  124. data/test-unit-ext/lib/test-unit-ext/color.rb +0 -59
  125. data/test-unit-ext/lib/test-unit-ext/colorized-runner.rb +0 -111
  126. data/test-unit-ext/lib/test-unit-ext/diff.rb +0 -516
  127. data/test-unit-ext/lib/test-unit-ext/long-display-for-emacs.rb +0 -25
  128. data/test-unit-ext/lib/test-unit-ext/notification.rb +0 -79
  129. data/test-unit-ext/lib/test-unit-ext/omission.rb +0 -96
  130. data/test-unit-ext/lib/test-unit-ext/pending.rb +0 -97
  131. data/test-unit-ext/lib/test-unit-ext/priority.rb +0 -158
  132. data/test-unit-ext/lib/test-unit-ext/version.rb +0 -3
  133. data/test-unit-ext/lib/test-unit-ext/xml-report.rb +0 -224
  134. data/test-unit-ext/test/run-test.rb +0 -14
  135. data/test-unit-ext/test/test_attributes.rb +0 -139
  136. data/test-unit-ext/test/test_omission.rb +0 -64
  137. data/test-unit-ext/test/test_xml_report.rb +0 -161
@@ -0,0 +1,116 @@
1
+ require 'test/unit/util/backtracefilter'
2
+
3
+ module Test
4
+ module Unit
5
+ class Notification
6
+ include Util::BacktraceFilter
7
+ attr_reader :test_name, :location, :message
8
+
9
+ SINGLE_CHARACTER = 'N'
10
+ LABEL = "Notification"
11
+
12
+ # Creates a new Notification with the given location and
13
+ # message.
14
+ def initialize(test_name, location, message)
15
+ @test_name = test_name
16
+ @location = location
17
+ @message = message
18
+ end
19
+
20
+ # Returns a single character representation of a notification.
21
+ def single_character_display
22
+ SINGLE_CHARACTER
23
+ end
24
+
25
+ def label
26
+ LABEL
27
+ end
28
+
29
+ # Returns a brief version of the error description.
30
+ def short_display
31
+ "#{@test_name}: #{@message.split("\n")[0]}"
32
+ end
33
+
34
+ # Returns a verbose version of the error description.
35
+ def long_display
36
+ backtrace = filter_backtrace(location).join("\n")
37
+ "#{label}: #{@message}\n#{@test_name}\n#{backtrace}"
38
+ end
39
+
40
+ # Overridden to return long_display.
41
+ def to_s
42
+ long_display
43
+ end
44
+ end
45
+
46
+ class NotifiedError < StandardError
47
+ end
48
+
49
+
50
+ module TestCaseNotificationSupport
51
+ class << self
52
+ def included(base)
53
+ base.class_eval do
54
+ include NotificationHandler
55
+ end
56
+ end
57
+ end
58
+
59
+ def notify(message, &block)
60
+ notification = Notification.new(name, filter_backtrace(caller), message)
61
+ add_notification(notification)
62
+ end
63
+
64
+ private
65
+ def add_notification(notification)
66
+ current_result.add_notification(notification)
67
+ end
68
+ end
69
+
70
+ module NotificationHandler
71
+ class << self
72
+ def included(base)
73
+ base.exception_handler(:handle_Notified_error)
74
+ end
75
+ end
76
+
77
+ private
78
+ def handle_Notified_error(exception)
79
+ return false unless exception.is_a?(NotifiedError)
80
+ notification = Notification.new(name,
81
+ filter_backtrace(exception.backtrace),
82
+ exception.message)
83
+ add_notification(notification)
84
+ true
85
+ end
86
+ end
87
+
88
+ module TestResultNotificationSupport
89
+ attr_reader :notifications
90
+
91
+ # Records a Test::Unit::Notification.
92
+ def add_notification(notification)
93
+ @notifications << notification
94
+ notify_fault(notification)
95
+ notify_changed
96
+ end
97
+
98
+ # Returns the number of notifications this TestResult has
99
+ # recorded.
100
+ def notification_count
101
+ @notifications.size
102
+ end
103
+
104
+ private
105
+ def initialize_containers
106
+ super
107
+ @notifications = []
108
+ @summary_generators << :notification_summary
109
+ end
110
+
111
+ def notification_summary
112
+ "#{notification_count} notifications"
113
+ end
114
+ end
115
+ end
116
+ end
@@ -0,0 +1,129 @@
1
+ require 'test/unit/util/backtracefilter'
2
+
3
+ module Test
4
+ module Unit
5
+ class Omission
6
+ include Util::BacktraceFilter
7
+ attr_reader :test_name, :location, :message
8
+
9
+ SINGLE_CHARACTER = 'O'
10
+ LABEL = "Omission"
11
+
12
+ # Creates a new Omission with the given location and
13
+ # message.
14
+ def initialize(test_name, location, message)
15
+ @test_name = test_name
16
+ @location = location
17
+ @message = message
18
+ end
19
+
20
+ # Returns a single character representation of a omission.
21
+ def single_character_display
22
+ SINGLE_CHARACTER
23
+ end
24
+
25
+ def label
26
+ LABEL
27
+ end
28
+
29
+ # Returns a brief version of the error description.
30
+ def short_display
31
+ "#{@test_name}: #{@message.split("\n")[0]}"
32
+ end
33
+
34
+ # Returns a verbose version of the error description.
35
+ def long_display
36
+ backtrace = filter_backtrace(location).join("\n")
37
+ "#{label}: #{@message}\n#{@test_name}\n#{backtrace}"
38
+ end
39
+
40
+ # Overridden to return long_display.
41
+ def to_s
42
+ long_display
43
+ end
44
+ end
45
+
46
+ class OmittedError < StandardError
47
+ end
48
+
49
+
50
+ module TestCaseOmissionSupport
51
+ class << self
52
+ def included(base)
53
+ base.class_eval do
54
+ include OmissionHandler
55
+ end
56
+ end
57
+ end
58
+
59
+ def omit(message=nil, &block)
60
+ message ||= "omitted."
61
+ if block_given?
62
+ omission = Omission.new(name, filter_backtrace(caller), message)
63
+ add_omission(omission)
64
+ else
65
+ raise OmittedError.new(message)
66
+ end
67
+ end
68
+
69
+ def omit_if(condition, *args, &block)
70
+ omit(*args, &block) if condition
71
+ end
72
+
73
+ def omit_unless(condition, *args, &block)
74
+ omit(*args, &block) unless condition
75
+ end
76
+
77
+ private
78
+ def add_omission(omission)
79
+ current_result.add_omission(omission)
80
+ end
81
+ end
82
+
83
+ module OmissionHandler
84
+ class << self
85
+ def included(base)
86
+ base.exception_handler(:handle_omitted_error)
87
+ end
88
+ end
89
+
90
+ private
91
+ def handle_omitted_error(exception)
92
+ return false unless exception.is_a?(OmittedError)
93
+ omission = Omission.new(name,
94
+ filter_backtrace(exception.backtrace),
95
+ exception.message)
96
+ add_omission(omission)
97
+ true
98
+ end
99
+ end
100
+
101
+ module TestResultOmissionSupport
102
+ attr_reader :omissions
103
+
104
+ # Records a Test::Unit::Omission.
105
+ def add_omission(omission)
106
+ @omissions << omission
107
+ notify_fault(omission)
108
+ notify_changed
109
+ end
110
+
111
+ # Returns the number of omissions this TestResult has
112
+ # recorded.
113
+ def omission_count
114
+ @omissions.size
115
+ end
116
+
117
+ private
118
+ def initialize_containers
119
+ super
120
+ @omissions = []
121
+ @summary_generators << :omission_summary
122
+ end
123
+
124
+ def omission_summary
125
+ "#{omission_count} omissions"
126
+ end
127
+ end
128
+ end
129
+ end
@@ -0,0 +1,130 @@
1
+ require 'test/unit/util/backtracefilter'
2
+
3
+ module Test
4
+ module Unit
5
+ class Pending
6
+ include Util::BacktraceFilter
7
+ attr_reader :test_name, :location, :message
8
+
9
+ SINGLE_CHARACTER = 'P'
10
+ LABEL = "Pending"
11
+
12
+ # Creates a new Pending with the given location and
13
+ # message.
14
+ def initialize(test_name, location, message)
15
+ @test_name = test_name
16
+ @location = location
17
+ @message = message
18
+ end
19
+
20
+ # Returns a single character representation of a pending.
21
+ def single_character_display
22
+ SINGLE_CHARACTER
23
+ end
24
+
25
+ def label
26
+ LABEL
27
+ end
28
+
29
+ # Returns a brief version of the error description.
30
+ def short_display
31
+ "#{@test_name}: #{@message.split("\n")[0]}"
32
+ end
33
+
34
+ # Returns a verbose version of the error description.
35
+ def long_display
36
+ backtrace = filter_backtrace(location).join("\n")
37
+ "#{label}: #{@message}\n#{@test_name}\n#{backtrace}"
38
+ end
39
+
40
+ # Overridden to return long_display.
41
+ def to_s
42
+ long_display
43
+ end
44
+ end
45
+
46
+ class PendedError < StandardError
47
+ end
48
+
49
+
50
+ module TestCasePendingSupport
51
+ class << self
52
+ def included(base)
53
+ base.class_eval do
54
+ include PendingHandler
55
+ end
56
+ end
57
+ end
58
+
59
+ def pend(message=nil, &block)
60
+ message ||= "pended."
61
+ if block_given?
62
+ pending = nil
63
+ begin
64
+ yield
65
+ rescue Exception
66
+ pending = Pending.new(name, filter_backtrace(caller), message)
67
+ add_pending(pending)
68
+ end
69
+ unless pending
70
+ flunk("Pending block should not be passed: #{message}")
71
+ end
72
+ else
73
+ raise PendedError.new(message)
74
+ end
75
+ end
76
+
77
+ private
78
+ def add_pending(pending)
79
+ problem_occurred
80
+ current_result.add_pending(pending)
81
+ end
82
+ end
83
+
84
+ module PendingHandler
85
+ class << self
86
+ def included(base)
87
+ base.exception_handler(:handle_pended_error)
88
+ end
89
+ end
90
+
91
+ private
92
+ def handle_pended_error(exception)
93
+ return false unless exception.is_a?(PendedError)
94
+ pending = Pending.new(name,
95
+ filter_backtrace(exception.backtrace),
96
+ exception.message)
97
+ add_pending(pending)
98
+ true
99
+ end
100
+ end
101
+
102
+ module TestResultPendingSupport
103
+ attr_reader :pendings
104
+
105
+ # Records a Test::Unit::Pending.
106
+ def add_pending(pending)
107
+ @pendings << pending
108
+ notify_fault(pending)
109
+ notify_changed
110
+ end
111
+
112
+ # Returns the number of pendings this TestResult has
113
+ # recorded.
114
+ def pending_count
115
+ @pendings.size
116
+ end
117
+
118
+ private
119
+ def initialize_containers
120
+ super
121
+ @pendings = []
122
+ @summary_generators << :pending_summary
123
+ end
124
+
125
+ def pending_summary
126
+ "#{pending_count} pendings"
127
+ end
128
+ end
129
+ end
130
+ end
@@ -0,0 +1,146 @@
1
+ require "fileutils"
2
+ require "tmpdir"
3
+
4
+ module Test
5
+ module Unit
6
+ module Priority
7
+ class << self
8
+ def included(base)
9
+ base.extend(ClassMethods)
10
+
11
+ base.class_eval do
12
+ setup :priority_setup, :before => :prepend
13
+ teardown :priority_teardown, :after => :append
14
+ end
15
+ end
16
+ end
17
+
18
+ class Checker
19
+ class << self
20
+ def have_priority?(name)
21
+ singleton_class = (class << self; self; end)
22
+ singleton_class.method_defined?(priority_check_method_name(name))
23
+ end
24
+
25
+ def need_to_run?(test)
26
+ priority = test[:priority] || :normal
27
+ if have_priority?(priority)
28
+ send(priority_check_method_name(priority), test)
29
+ else
30
+ true
31
+ end
32
+ end
33
+
34
+ def run_priority_must?(test)
35
+ true
36
+ end
37
+
38
+ def run_priority_important?(test)
39
+ rand > 0.1
40
+ end
41
+
42
+ def run_priority_high?(test)
43
+ rand > 0.3
44
+ end
45
+
46
+ def run_priority_normal?(test)
47
+ rand > 0.5
48
+ end
49
+
50
+ def run_priority_low?(test)
51
+ rand > 0.75
52
+ end
53
+
54
+ def run_priority_never?(test)
55
+ false
56
+ end
57
+
58
+ private
59
+ def priority_check_method_name(priority_name)
60
+ "run_priority_#{priority_name}?"
61
+ end
62
+ end
63
+
64
+ attr_reader :test
65
+ def initialize(test)
66
+ @test = test
67
+ end
68
+
69
+ def setup
70
+ FileUtils.rm_f(passed_file)
71
+ end
72
+
73
+ def teardown
74
+ if @test.send(:passed?)
75
+ FileUtils.touch(passed_file)
76
+ else
77
+ FileUtils.rm_f(passed_file)
78
+ end
79
+ end
80
+
81
+ def need_to_run?
82
+ !previous_test_success? or self.class.need_to_run?(@test)
83
+ end
84
+
85
+ private
86
+ def previous_test_success?
87
+ File.exist?(passed_file)
88
+ end
89
+
90
+ def result_dir
91
+ components = [".test-result",
92
+ @test.class.name || "AnonymousTestCase",
93
+ @test.method_name.to_s]
94
+ parent_directories = [File.dirname($0), Dir.pwd]
95
+ if Process.respond_to?(:uid)
96
+ parent_directories << File.join(Dir.tmpdir, Process.uid.to_s)
97
+ end
98
+ parent_directories.each do |parent_directory|
99
+ dir = File.expand_path(File.join(parent_directory, *components))
100
+ begin
101
+ FileUtils.mkdir_p(dir)
102
+ return dir
103
+ rescue Errno::EACCES
104
+ end
105
+ end
106
+
107
+ raise Errno::EACCES, parent_directories.join(", ")
108
+ end
109
+
110
+ def passed_file
111
+ File.join(result_dir, "passed")
112
+ end
113
+
114
+ def escaped_method_name
115
+ @method_name.to_s.gsub(/[!?=]$/) do |matched|
116
+ case matched
117
+ when "!"
118
+ ".destructive"
119
+ when "?"
120
+ ".predicate"
121
+ when "="
122
+ ".equal"
123
+ end
124
+ end
125
+ end
126
+ end
127
+
128
+ module ClassMethods
129
+ def priority(name, *tests)
130
+ unless Checker.have_priority?(name)
131
+ raise ArgumentError, "unknown priority: #{name}"
132
+ end
133
+ attribute(:priority, name, {:keep => true}, *tests)
134
+ end
135
+ end
136
+
137
+ def priority_setup
138
+ Checker.new(self).setup
139
+ end
140
+
141
+ def priority_teardown
142
+ Checker.new(self).teardown
143
+ end
144
+ end
145
+ end
146
+ end