@@ -5,11 +5,6 @@ class ResumptionTokenFunctionalTest < Test::Unit::TestCase
5
5
6
6
def setup
7
7
@provider = ComplexProvider . new
8
- @provider . model . instance_variable_set ( :@limit , 120 )
9
- end
10
-
11
- def teardown
12
- @provider . model . instance_variable_set ( :@limit , 100 )
13
8
end
14
9
15
10
def test_resumption_tokens
@@ -26,28 +21,31 @@ def test_resumption_tokens
26
21
end
27
22
28
23
def test_from_and_until_with_resumption_tokens
29
- # Should return 300 records broken into 3 groups of 120, 120, and 60.
24
+ # Should return 550 records broken into 5 groups of 100, and a final group of 50.
25
+ # checked elements under ListRecords are limit + 1, accounting for the resumptionToken element
30
26
assert_nothing_raised do
31
27
Document . new ( @provider . list_records ( :metadata_prefix => 'oai_dc' ) )
32
28
end
33
29
doc = Document . new (
34
30
@provider . list_records (
35
31
:metadata_prefix => 'oai_dc' ,
36
32
:from => Time . parse ( "September 1 2004" ) ,
37
- :until => Time . parse ( "November 30 2004 " ) )
33
+ :until => Time . parse ( "December 25 2005 " ) )
38
34
)
39
35
assert_equal ( @provider . model . limit + 1 ) , doc . elements [ "/OAI-PMH/ListRecords" ] . to_a . size
40
36
assert_not_nil doc . elements [ "/OAI-PMH/ListRecords/resumptionToken" ]
41
37
token = doc . elements [ "/OAI-PMH/ListRecords/resumptionToken" ] . text
42
38
43
- doc = Document . new ( @provider . list_records ( :resumption_token => token ) )
44
- assert_not_nil doc . elements [ "/OAI-PMH/ListRecords/resumptionToken" ]
45
- assert_equal ( @provider . model . limit + 1 ) , doc . elements [ "/OAI-PMH/ListRecords" ] . to_a . size
46
- token = doc . elements [ "/OAI-PMH/ListRecords/resumptionToken" ] . text
39
+ 4 . times do
40
+ doc = Document . new ( @provider . list_records ( :resumption_token => token ) )
41
+ assert_not_nil doc . elements [ "/OAI-PMH/ListRecords/resumptionToken" ]
42
+ assert_equal ( @provider . model . limit + 1 ) , doc . elements [ "/OAI-PMH/ListRecords" ] . to_a . size
43
+ token = doc . elements [ "/OAI-PMH/ListRecords/resumptionToken" ] . text
44
+ end
47
45
48
46
doc = Document . new ( @provider . list_records ( :resumption_token => token ) )
49
47
# assert that ListRecords includes remaining records and an empty resumption token
50
- assert_equal ( 301 % @provider . model . limit ) , doc . elements [ "/OAI-PMH/ListRecords" ] . to_a . size
48
+ assert_equal ( 551 % @provider . model . limit ) , doc . elements [ "/OAI-PMH/ListRecords" ] . to_a . size
51
49
assert_not_nil doc . elements [ "/OAI-PMH/ListRecords/resumptionToken" ]
52
50
assert_nil doc . elements [ "/OAI-PMH/ListRecords/resumptionToken" ] . text
53
51
end
0 commit comments