File tree Expand file tree Collapse file tree 3 files changed +41
-0
lines changed Expand file tree Collapse file tree 3 files changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -181,6 +181,10 @@ def add_listener( listener )
181
181
182
182
def stream = ( source )
183
183
@source = SourceFactory . create_from ( source )
184
+ reset
185
+ end
186
+
187
+ def reset
184
188
@closed = nil
185
189
@have_root = false
186
190
@document_status = nil
Original file line number Diff line number Diff line change @@ -93,6 +93,10 @@ def pull
93
93
def unshift token
94
94
@my_stack . unshift token
95
95
end
96
+
97
+ def reset
98
+ @parser . reset
99
+ end
96
100
end
97
101
98
102
# A parsing event. The contents of the event are accessed as an +Array?,
Original file line number Diff line number Diff line change @@ -156,6 +156,39 @@ def test_peek
156
156
assert_equal ( 0 , names . length )
157
157
end
158
158
159
+ def test_reset
160
+ xml_chunks = [
161
+ "<message>First valid and complete message</message>" ,
162
+ "<message>Second valid and complete message</message>" ,
163
+ "<message>Third valid and complete message</message>"
164
+ ]
165
+
166
+ messages = [ ]
167
+
168
+ IO . pipe do |reader , writer |
169
+ xml_chunks . each do |chunk |
170
+ writer . write ( chunk )
171
+ end
172
+ writer . close
173
+
174
+ parser = REXML ::Parsers ::PullParser . new ( reader )
175
+ while parser . has_next?
176
+ parser . pull
177
+ message_text = parser . pull
178
+ messages << message_text [ 0 ]
179
+ parser . pull
180
+ parser . reset
181
+ end
182
+ end
183
+
184
+ assert_equal (
185
+ messages ,
186
+ [ "First valid and complete message" ,
187
+ "Second valid and complete message" ,
188
+ "Third valid and complete message" ]
189
+ )
190
+ end
191
+
159
192
class EntityExpansionLimitTest < Test ::Unit ::TestCase
160
193
class GeneralEntityTest < self
161
194
def test_have_value
You can’t perform that action at this time.
0 commit comments