activeldap 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -1,25 +0,0 @@
1
- require 'test/unit/failure'
2
- require 'test/unit/error'
3
-
4
- module Test
5
- module Unit
6
- BACKTRACE_INFO_RE = /.+:\d+:in `.+?'/
7
- class Failure
8
- alias_method :original_long_display, :long_display
9
- def long_display
10
- extract_backtraces_re =
11
- /^ \[(#{BACKTRACE_INFO_RE}(?:\n #{BACKTRACE_INFO_RE})+)\]:$/
12
- original_long_display.gsub(extract_backtraces_re) do |backtraces|
13
- $1.gsub(/^ (#{BACKTRACE_INFO_RE})/, '\1') + ':'
14
- end
15
- end
16
- end
17
-
18
- class Error
19
- alias_method :original_long_display, :long_display
20
- def long_display
21
- original_long_display.gsub(/^ (#{BACKTRACE_INFO_RE})/, '\1')
22
- end
23
- end
24
- end
25
- end
@@ -1,79 +0,0 @@
1
- module Test
2
- module Unit
3
- class TestResult
4
- attr_reader :notifications
5
-
6
- alias_method(:initialize_without_notifications, :initialize)
7
- def initialize
8
- initialize_without_notifications
9
- @notifications = []
10
- end
11
-
12
- def add_notification(notification)
13
- @notifications << notification
14
- notify_listeners(FAULT, notification)
15
- notify_listeners(CHANGED, self)
16
- end
17
-
18
- def notification_count
19
- @notifications.size
20
- end
21
-
22
- alias_method(:to_s_without_notifications, :to_s)
23
- def to_s
24
- to_s_without_notifications + ", #{notification_count} notifications"
25
- end
26
- end
27
-
28
- class Notification
29
- include Util::BacktraceFilter
30
- attr_reader :test_name, :location, :message
31
-
32
- SINGLE_CHARACTER = 'N'
33
-
34
- # Creates a new Notification with the given location and
35
- # message.
36
- def initialize(test_name, location, message)
37
- @test_name = test_name
38
- @location = location
39
- @message = message
40
- end
41
-
42
- # Returns a single character representation of a notification.
43
- def single_character_display
44
- SINGLE_CHARACTER
45
- end
46
-
47
- # Returns a brief version of the error description.
48
- def short_display
49
- "#@test_name: #{@message.split("\n")[0]}"
50
- end
51
-
52
- # Returns a verbose version of the error description.
53
- def long_display
54
- location_display = filter_backtrace(location)[0]
55
- location_display = location_display.sub(/\A(.+:\d+).*/, ' [\\1]')
56
- "Notification:\n#{@test_name}#{location_display}:\n#{@message}"
57
- end
58
-
59
- # Overridden to return long_display.
60
- def to_s
61
- long_display
62
- end
63
- end
64
-
65
- class NotifiedError < StandardError
66
- end
67
-
68
- module AssertionsWithNotify
69
- def notify(message)
70
- notification = Notification.new(name, caller[0, 1], message)
71
- @_result.add_notification(notification)
72
- end
73
- end
74
-
75
- class TestCase
76
- include AssertionsWithNotify
77
- end
78
- end
79
- end
@@ -1,96 +0,0 @@
1
- module Test
2
- module Unit
3
- class TestResult
4
- attr_reader :omissions
5
-
6
- alias_method(:initialize_without_omissions, :initialize)
7
- def initialize
8
- initialize_without_omissions
9
- @omissions = []
10
- end
11
-
12
- def add_omission(omission)
13
- @omissions << omission
14
- notify_listeners(FAULT, omission)
15
- notify_listeners(CHANGED, self)
16
- end
17
-
18
- def omission_count
19
- @omissions.size
20
- end
21
-
22
- alias_method(:to_s_without_omissions, :to_s)
23
- def to_s
24
- to_s_without_omissions + ", #{omission_count} omissions"
25
- end
26
- end
27
-
28
- class Omission
29
- include Util::BacktraceFilter
30
- attr_reader :test_name, :location, :message
31
-
32
- SINGLE_CHARACTER = 'O'
33
-
34
- # Creates a new Omission with the given location and
35
- # message.
36
- def initialize(test_name, location, message)
37
- @test_name = test_name
38
- @location = location
39
- @message = message
40
- end
41
-
42
- # Returns a single character representation of a omission.
43
- def single_character_display
44
- SINGLE_CHARACTER
45
- end
46
-
47
- # Returns a brief version of the error description.
48
- def short_display
49
- "#@test_name: #{@message.split("\n")[0]}"
50
- end
51
-
52
- # Returns a verbose version of the error description.
53
- def long_display
54
- backtrace = filter_backtrace(location).join("\n")
55
- "Omission:\n#{@test_name}\n#{@message}\n#{backtrace}"
56
- end
57
-
58
- # Overridden to return long_display.
59
- def to_s
60
- long_display
61
- end
62
- end
63
-
64
- class OmittedError < StandardError
65
- end
66
-
67
- module AssertionsWithOmit
68
- def omit(message="Omitted", &block)
69
- if block_given?
70
- begin
71
- yield
72
- rescue Exception
73
- raise OmittedError, message, $!.backtrace
74
- end
75
- flunk("Omission block should not be passed: #{message}")
76
- else
77
- raise OmittedError.new(message)
78
- end
79
- end
80
- end
81
-
82
- class TestCase
83
- include AssertionsWithOmit
84
-
85
- alias_method(:add_error_without_omission, :add_error)
86
- def add_error(exception)
87
- if exception.is_a?(OmittedError)
88
- omission = Omission.new(name, exception.backtrace, exception.message)
89
- @_result.add_omission(omission)
90
- else
91
- add_error_without_omission(exception)
92
- end
93
- end
94
- end
95
- end
96
- end
@@ -1,97 +0,0 @@
1
- module Test
2
- module Unit
3
- class TestResult
4
- attr_reader :pendings
5
-
6
- alias_method(:initialize_without_pendings, :initialize)
7
- def initialize
8
- initialize_without_pendings
9
- @pendings = []
10
- end
11
-
12
- def add_pending(pending)
13
- @pendings << pending
14
- notify_listeners(FAULT, pending)
15
- notify_listeners(CHANGED, self)
16
- end
17
-
18
- def pending_count
19
- @pendings.size
20
- end
21
-
22
- alias_method(:to_s_without_pendings, :to_s)
23
- def to_s
24
- to_s_without_pendings + ", #{pending_count} pendings"
25
- end
26
- end
27
-
28
- class Pending
29
- include Util::BacktraceFilter
30
- attr_reader :test_name, :location, :message
31
-
32
- SINGLE_CHARACTER = 'P'
33
-
34
- # Creates a new Pending with the given location and
35
- # message.
36
- def initialize(test_name, location, message)
37
- @test_name = test_name
38
- @location = location
39
- @message = message
40
- end
41
-
42
- # Returns a single character representation of a pending.
43
- def single_character_display
44
- SINGLE_CHARACTER
45
- end
46
-
47
- # Returns a brief version of the error description.
48
- def short_display
49
- "#@test_name: #{@message.split("\n")[0]}"
50
- end
51
-
52
- # Returns a verbose version of the error description.
53
- def long_display
54
- location_display = filter_backtrace(location)[0]
55
- location_display = location_display.sub(/\A(.+:\d+).*/, ' [\\1]')
56
- "Pending:\n#{@test_name}#{location_display}:\n#{@message}"
57
- end
58
-
59
- # Overridden to return long_display.
60
- def to_s
61
- long_display
62
- end
63
- end
64
-
65
- class PendedError < StandardError
66
- end
67
-
68
- module AssertionsWithPend
69
- def pend(message="Pended", &block)
70
- if block_given?
71
- begin
72
- yield
73
- rescue Exception
74
- raise PendedError, message, $!.backtrace
75
- end
76
- flunk("Pending block should not be passed: #{message}")
77
- else
78
- raise PendedError.new(message)
79
- end
80
- end
81
- end
82
-
83
- class TestCase
84
- include AssertionsWithPend
85
-
86
- alias_method(:add_error_without_pending, :add_error)
87
- def add_error(exception)
88
- if exception.is_a?(PendedError)
89
- pending = Pending.new(name, exception.backtrace, exception.message)
90
- @_result.add_pending(pending)
91
- else
92
- add_error_without_pending(exception)
93
- end
94
- end
95
- end
96
- end
97
- end
@@ -1,158 +0,0 @@
1
- require "test/unit"
2
-
3
- require "fileutils"
4
- require "tmpdir"
5
-
6
- require "test-unit-ext/attributes"
7
-
8
- module Test
9
- module Unit
10
- class TestCase
11
- class << self
12
- def priority(name, *tests)
13
- singleton_class = (class << self; self; end)
14
- priority_check_method = priority_check_method_name(name)
15
- unless singleton_class.private_method_defined?(priority_check_method)
16
- raise ArgumentError, "unknown priority: #{name}"
17
- end
18
- attribute(:priority, name, {:keep => true}, *tests)
19
- end
20
-
21
- def need_to_run?(test_name)
22
- priority = (attributes(test_name) || {})[:priority] || :normal
23
- __send__(priority_check_method_name(priority), test_name)
24
- end
25
-
26
- private
27
- def priority_check_method_name(priority_name)
28
- "run_priority_#{priority_name}?"
29
- end
30
-
31
- def set_priority(name, priority=@current_priority)
32
- @priority_table[normalize_test_name(name)] = priority
33
- end
34
-
35
- def run_priority_must?(test_name)
36
- true
37
- end
38
-
39
- def run_priority_important?(test_name)
40
- rand > 0.1
41
- end
42
-
43
- def run_priority_high?(test_name)
44
- rand > 0.3
45
- end
46
-
47
- def run_priority_normal?(test_name)
48
- rand > 0.5
49
- end
50
-
51
- def run_priority_low?(test_name)
52
- rand > 0.75
53
- end
54
-
55
- def run_priority_never?(test_name)
56
- false
57
- end
58
- end
59
-
60
- def need_to_run?
61
- !previous_test_success? or self.class.need_to_run?(@method_name)
62
- end
63
-
64
- alias_method :run_without_priority, :run
65
- def run(result, &block)
66
- run_without_priority(result, &block)
67
- ensure
68
- if passed?
69
- FileUtils.touch(passed_file)
70
- else
71
- FileUtils.rm_f(passed_file)
72
- end
73
- end
74
-
75
- private
76
- def previous_test_success?
77
- File.exist?(passed_file)
78
- end
79
-
80
- def result_dir
81
- components = [".test-result", self.class.name, @method_name.to_s]
82
- parent_directories = [File.dirname($0),
83
- File.join(File.dirname(__FILE__), ".."),
84
- Dir.pwd]
85
- if Process.respond_to?(:uid)
86
- parent_directories << File.join(Dir.tmpdir, Process.uid.to_s)
87
- end
88
- parent_directories.each do |parent_directory|
89
- dir = File.expand_path(File.join(parent_directory, *components))
90
- begin
91
- FileUtils.mkdir_p(dir)
92
- return dir
93
- rescue Errno::EACCES
94
- end
95
- end
96
-
97
- raise Errno::EACCES, parent_directories.join(", ")
98
- end
99
-
100
- def passed_file
101
- File.join(result_dir, "passed")
102
- end
103
-
104
- def escaped_method_name
105
- @method_name.to_s.gsub(/[!?]$/) do |matched|
106
- case matched
107
- when "!"
108
- ".destructive"
109
- when "?"
110
- ".predicate"
111
- end
112
- end
113
- end
114
- end
115
-
116
- class TestSuite
117
- @@priority_mode = false
118
-
119
- class << self
120
- def priority_mode=(bool)
121
- @@priority_mode = bool
122
- end
123
- end
124
-
125
- alias_method :run_without_priority_support, :run
126
- def run(*args, &block)
127
- priority_mode = @@priority_mode
128
- if priority_mode
129
- @original_tests = @tests
130
- apply_priority
131
- end
132
- run_without_priority_support(*args, &block)
133
- ensure
134
- @tests = @original_tests if priority_mode
135
- end
136
-
137
- def apply_priority
138
- @tests = @tests.reject {|test| !test.need_to_run?}
139
- end
140
-
141
- def need_to_run?
142
- apply_priority
143
- !@tests.empty?
144
- end
145
- end
146
-
147
- class AutoRunner
148
- alias_method :options_without_priority, :options
149
- def options
150
- opts = options_without_priority
151
- opts.on("--[no-]priority", "use priority mode") do |bool|
152
- TestSuite.priority_mode = bool
153
- end
154
- opts
155
- end
156
- end
157
- end
158
- end