rscm-accurev 0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +25 -0
- data/README +9 -0
- data/Rakefile +137 -0
- data/STATUS +63 -0
- data/TODO +43 -0
- data/apitest.rb +21 -0
- data/bumprelease.sh +13 -0
- data/lib/rscm/accurev.rb +18 -0
- data/lib/rscm/scm/accurev/api.rb +411 -0
- data/lib/rscm/scm/accurev/api.rb.mine +382 -0
- data/lib/rscm/scm/accurev/api.rb.r263 +364 -0
- data/lib/rscm/scm/accurev/api.rb.r265 +393 -0
- data/lib/rscm/scm/accurev/command.rb +151 -0
- data/lib/rscm/scm/accurev/exception.rb +38 -0
- data/lib/rscm/scm/accurev/filterio.rb +57 -0
- data/lib/rscm/scm/accurev/xml.rb +224 -0
- data/lib/test/unit/ui/xml/testrunner.rb +165 -0
- data/lib/test/unit/ui/xml/xmltestrunner.xslt +79 -0
- data/test/acreplay.rb +22 -0
- data/test/coverage/analyzer.rb +127 -0
- data/test/coverage/c_loader.rb +34 -0
- data/test/coverage/cover.rb +91 -0
- data/test/coverage/coverage_loader.rb +21 -0
- data/test/coverage/coveragetask.rb +38 -0
- data/test/coverage/index_tmpl.html +42 -0
- data/test/coverage/template.html +36 -0
- data/test/eg/ac-files.xml +172 -0
- data/test/eg/ac-pop.txt +195 -0
- data/test/eg/files-various-states.xml +188 -0
- data/test/eg/hist-oneweek-all.xml +1483 -0
- data/test/eg/hist-oneweek-external.xml +246 -0
- data/test/eg/hist-oneweek-promotes.xml +1092 -0
- data/test/eg/info.txt +14 -0
- data/test/eg/stat-a-various.xml +1789 -0
- data/test/eg/stat-m.xml +13 -0
- data/test/eg/stat-overlap.xml +13 -0
- data/test/eg/stat-x.xml +20 -0
- data/test/eg/update-i-mods-and-updates-and-overlap.xml +73 -0
- data/test/eg/update-i-nochanges.xml +8 -0
- data/test/eg/update-i-stale.xml +0 -0
- data/test/eg/update-i-updates.xml +125 -0
- data/test/eg/update-newwksp.xml +183 -0
- data/test/eg/update-nochanges.xml +7 -0
- data/test/eg/update-stale.xml +12 -0
- data/test/eg/update-updates.xml +147 -0
- data/test/t_api.rb +163 -0
- data/test/t_command.rb +85 -0
- data/test/t_filterio.rb +60 -0
- data/test/t_load.rb +11 -0
- data/test/t_scrubio.rb +117 -0
- data/test/t_xmlmapper.rb +75 -0
- metadata +106 -0
@@ -0,0 +1,12 @@
|
|
1
|
+
<acResponse
|
2
|
+
command="update"Scanning entire workspace for files touched since last scan - ok
|
3
|
+
ok
|
4
|
+
>
|
5
|
+
<message
|
6
|
+
error="true">
|
7
|
+
Some of the elements in your workspace have been modified
|
8
|
+
and are not in your default group. Use 'accurev stat -n' to
|
9
|
+
get a list of these files. Then resolve all modifications
|
10
|
+
with anchor, keep, or purge before trying update again.
|
11
|
+
</message>
|
12
|
+
</acResponse>
|
@@ -0,0 +1,147 @@
|
|
1
|
+
<acResponse
|
2
|
+
command="update"Scanning entire workspace for files touched since last scan - ok
|
3
|
+
>
|
4
|
+
<progress
|
5
|
+
phase="Calculating changes"
|
6
|
+
increment="100"/>
|
7
|
+
<progress
|
8
|
+
phase="results"
|
9
|
+
number="23"/>
|
10
|
+
<message>Removing "src/java/com/orbitz/dc/service/hc/HcItinerary.java" .
|
11
|
+
</message>
|
12
|
+
<element
|
13
|
+
location="src/java/com/orbitz/dc/service/hc/HcItinerary.java"/>
|
14
|
+
<checkpoint/>
|
15
|
+
<message>Content (1 K) of "src/java/com/orbitz/dc/core/Pricing.java" - ok
|
16
|
+
</message>
|
17
|
+
<element
|
18
|
+
location="src/java/com/orbitz/dc/core/Pricing.java"
|
19
|
+
size="1398"/>
|
20
|
+
<checkpoint/>
|
21
|
+
<message>Content (1 K) of "src/java/com/orbitz/dc/service/hc/HcSearchRequest.java" - ok
|
22
|
+
</message>
|
23
|
+
<element
|
24
|
+
location="src/java/com/orbitz/dc/service/hc/HcSearchRequest.java"
|
25
|
+
size="793"/>
|
26
|
+
<checkpoint/>
|
27
|
+
<message>Content (1 K) of "src/java/com/orbitz/dc/service/hc/HcCreateReservationRequest.java" - ok
|
28
|
+
</message>
|
29
|
+
<element
|
30
|
+
location="src/java/com/orbitz/dc/service/hc/HcCreateReservationRequest.java"
|
31
|
+
size="1712"/>
|
32
|
+
<checkpoint/>
|
33
|
+
<message>Content (3 K) of "src/java/com/orbitz/dc/core/HcJourney.java" - ok
|
34
|
+
</message>
|
35
|
+
<element
|
36
|
+
location="src/java/com/orbitz/dc/core/HcJourney.java"
|
37
|
+
size="3846"/>
|
38
|
+
<checkpoint/>
|
39
|
+
<message>Content (1 K) of "src/java/com/orbitz/dc/service/hc/HcCreateReservationResponse.java" - ok
|
40
|
+
</message>
|
41
|
+
<element
|
42
|
+
location="src/java/com/orbitz/dc/service/hc/HcCreateReservationResponse.java"
|
43
|
+
size="849"/>
|
44
|
+
<checkpoint/>
|
45
|
+
<message>Content (3 K) of "src/java/com/orbitz/dc/service/hc/HcCancelReservationRequest.java" - ok
|
46
|
+
</message>
|
47
|
+
<element
|
48
|
+
location="src/java/com/orbitz/dc/service/hc/HcCancelReservationRequest.java"
|
49
|
+
size="3046"/>
|
50
|
+
<checkpoint/>
|
51
|
+
<message>Content (1 K) of "src/java/com/orbitz/dc/service/hc/HcCancelReservationResponse.java" - ok
|
52
|
+
</message>
|
53
|
+
<element
|
54
|
+
location="src/java/com/orbitz/dc/service/hc/HcCancelReservationResponse.java"
|
55
|
+
size="756"/>
|
56
|
+
<checkpoint/>
|
57
|
+
<message>Content (1 K) of "src/java/com/orbitz/dc/service/hc/HcModifyReservationResponse.java" - ok
|
58
|
+
</message>
|
59
|
+
<element
|
60
|
+
location="src/java/com/orbitz/dc/service/hc/HcModifyReservationResponse.java"
|
61
|
+
size="849"/>
|
62
|
+
<checkpoint/>
|
63
|
+
<message>Content (1 K) of "src/java/com/orbitz/dc/service/hc/HcModifyReservationRequest.java" - ok
|
64
|
+
</message>
|
65
|
+
<element
|
66
|
+
location="src/java/com/orbitz/dc/service/hc/HcModifyReservationRequest.java"
|
67
|
+
size="1806"/>
|
68
|
+
<checkpoint/>
|
69
|
+
<message>Content (3 K) of "src/java/com/orbitz/dc/core/RateInfo.java" - ok
|
70
|
+
</message>
|
71
|
+
<element
|
72
|
+
location="src/java/com/orbitz/dc/core/RateInfo.java"
|
73
|
+
size="3495"/>
|
74
|
+
<checkpoint/>
|
75
|
+
<message>Content (2 K) of "src/java/com/orbitz/dc/core/VariableRateInfo.java" - ok
|
76
|
+
</message>
|
77
|
+
<element
|
78
|
+
location="src/java/com/orbitz/dc/core/VariableRateInfo.java"
|
79
|
+
size="2523"/>
|
80
|
+
<checkpoint/>
|
81
|
+
<message>Content (2 K) of "src/java/com/orbitz/dc/core/RATE_CATEGORY.java" - ok
|
82
|
+
</message>
|
83
|
+
<element
|
84
|
+
location="src/java/com/orbitz/dc/core/RATE_CATEGORY.java"
|
85
|
+
size="2513"/>
|
86
|
+
<checkpoint/>
|
87
|
+
<message>Content (2 K) of "src/java/com/orbitz/dc/core/RATE_COVERAGE.java" - ok
|
88
|
+
</message>
|
89
|
+
<element
|
90
|
+
location="src/java/com/orbitz/dc/core/RATE_COVERAGE.java"
|
91
|
+
size="2537"/>
|
92
|
+
<checkpoint/>
|
93
|
+
<message>Content (1 K) of "src/java/com/orbitz/dc/core/FlatRateInfo.java" - ok
|
94
|
+
</message>
|
95
|
+
<element
|
96
|
+
location="src/java/com/orbitz/dc/core/FlatRateInfo.java"
|
97
|
+
size="975"/>
|
98
|
+
<checkpoint/>
|
99
|
+
<message>Content (2 K) of "src/java/com/orbitz/dc/core/HcItinerary.java" - ok
|
100
|
+
</message>
|
101
|
+
<element
|
102
|
+
location="src/java/com/orbitz/dc/core/HcItinerary.java"
|
103
|
+
size="2707"/>
|
104
|
+
<checkpoint/>
|
105
|
+
<message>Content (1 K) of "src/java/com/orbitz/dc/service/hc/HcSearch.java" - ok
|
106
|
+
</message>
|
107
|
+
<element
|
108
|
+
location="src/java/com/orbitz/dc/service/hc/HcSearch.java"
|
109
|
+
size="1123"/>
|
110
|
+
<checkpoint/>
|
111
|
+
<message>Content (1 K) of "src/java/com/orbitz/dc/service/hc/HcCreateReservation.java" - ok
|
112
|
+
</message>
|
113
|
+
<element
|
114
|
+
location="src/java/com/orbitz/dc/service/hc/HcCreateReservation.java"
|
115
|
+
size="1146"/>
|
116
|
+
<checkpoint/>
|
117
|
+
<message>Content (1 K) of "src/java/com/orbitz/dc/service/hc/HcModifyReservation.java" - ok
|
118
|
+
</message>
|
119
|
+
<element
|
120
|
+
location="src/java/com/orbitz/dc/service/hc/HcModifyReservation.java"
|
121
|
+
size="1156"/>
|
122
|
+
<checkpoint/>
|
123
|
+
<message>Content (1 K) of "src/java/com/orbitz/dc/service/hc/HcCancelReservation.java" - ok
|
124
|
+
</message>
|
125
|
+
<element
|
126
|
+
location="src/java/com/orbitz/dc/service/hc/HcCancelReservation.java"
|
127
|
+
size="1150"/>
|
128
|
+
<checkpoint/>
|
129
|
+
<message>Content (1 K) of "src/java/com/orbitz/dc/service/hc/HcRetrieveItinerary.java" - ok
|
130
|
+
</message>
|
131
|
+
<element
|
132
|
+
location="src/java/com/orbitz/dc/service/hc/HcRetrieveItinerary.java"
|
133
|
+
size="1150"/>
|
134
|
+
<checkpoint/>
|
135
|
+
<message>Content (1 K) of "src/java/com/orbitz/dc/service/hc/HcRetrieveItineraryRequest.java" - ok
|
136
|
+
</message>
|
137
|
+
<element
|
138
|
+
location="src/java/com/orbitz/dc/service/hc/HcRetrieveItineraryRequest.java"
|
139
|
+
size="1477"/>
|
140
|
+
<checkpoint/>
|
141
|
+
<message>Content (1 K) of "src/java/com/orbitz/dc/service/hc/HcRetrieveItineraryResponse.java" - ok
|
142
|
+
</message>
|
143
|
+
<element
|
144
|
+
location="src/java/com/orbitz/dc/service/hc/HcRetrieveItineraryResponse.java"
|
145
|
+
size="756"/>
|
146
|
+
<checkpoint/>
|
147
|
+
</acResponse>
|
data/test/t_api.rb
ADDED
@@ -0,0 +1,163 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'rubygems'
|
5
|
+
require 'rscm/accurev'
|
6
|
+
require 'fileutils'
|
7
|
+
require 'tmpdir'
|
8
|
+
include RSCM::Accurev
|
9
|
+
|
10
|
+
class AccurevAPITest < Test::Unit::TestCase
|
11
|
+
|
12
|
+
#def test_deduce_backing_workspace_streams()
|
13
|
+
# flunk( "XXX implement me" )
|
14
|
+
#end
|
15
|
+
|
16
|
+
def test_ac_hist()
|
17
|
+
Command.instance do |cmd|
|
18
|
+
cmd.accurev_bin = "./acreplay.rb eg/hist-oneweek-promotes.xml"
|
19
|
+
end
|
20
|
+
api = API.new( "test" )
|
21
|
+
# test array returns
|
22
|
+
txns = api.ac_hist( Time.utc(1980) ) # bound don't matter for this test
|
23
|
+
txns.each do |t|
|
24
|
+
assert_not_nil( t['version'], "Txn #{t} has no versions" )
|
25
|
+
end
|
26
|
+
assert_equal( txns.length, 9 )
|
27
|
+
# block yield
|
28
|
+
txncount = 0
|
29
|
+
api.ac_hist( Time.utc(1974) ) do |txn|
|
30
|
+
txncount+=1
|
31
|
+
assert_not_nil( txn['version'], "Txn #{txn} has no versions" )
|
32
|
+
end
|
33
|
+
assert_equal( txncount, 9 )
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_ac_files()
|
37
|
+
Command.instance do |cmd|
|
38
|
+
cmd.accurev_bin = "./acreplay.rb eg/ac-files.xml"
|
39
|
+
end
|
40
|
+
api = API.new( "test", "test-bogus-depot", "test-bogus-depot-0-impl" )
|
41
|
+
# test array returns
|
42
|
+
files = api.ac_files( "." )
|
43
|
+
assert( files.length > 0, "Should get some stat-ed files" )
|
44
|
+
assert_equal( files.length, 23 )
|
45
|
+
files.each do |fd|
|
46
|
+
assert( fd.respond_to?( :location ) )
|
47
|
+
end
|
48
|
+
# test block yield
|
49
|
+
count = 0
|
50
|
+
api.ac_files( "." ) do |fd|
|
51
|
+
assert( fd.respond_to?( :location ) )
|
52
|
+
count += 1
|
53
|
+
end
|
54
|
+
assert_equal( count, 23 )
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_update_stale()
|
58
|
+
Command.instance do |cmd|
|
59
|
+
cmd.accurev_bin = "./acreplay.rb eg/update-stale.xml"
|
60
|
+
end
|
61
|
+
api = API.new( "test", "test-bogus-depot", "test-bogus-depot-0-impl" )
|
62
|
+
begin
|
63
|
+
u_elements = api.update()
|
64
|
+
flunk( "Simulated update with stale data should throw exception" )
|
65
|
+
rescue StaleWorkspaceException => e
|
66
|
+
assert( true, "Caught expected exception" )
|
67
|
+
assert( e.error_msg =~ /workspace have been modified/ )
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_update_nochanges()
|
72
|
+
Command.instance do |cmd|
|
73
|
+
cmd.accurev_bin = "./acreplay.rb eg/update-nochanges.xml"
|
74
|
+
end
|
75
|
+
api = API.new( "test", "test-bogus-depot", "test-bogus-depot-0-impl" )
|
76
|
+
u_elements = api.update()
|
77
|
+
assert_not_nil( u_elements )
|
78
|
+
assert( u_elements.size == 0 )
|
79
|
+
end
|
80
|
+
|
81
|
+
def test_update_newwksp()
|
82
|
+
Command.instance do |cmd|
|
83
|
+
cmd.accurev_bin = "./acreplay.rb eg/update-newwksp.xml"
|
84
|
+
end
|
85
|
+
api = API.new( "test", "test-bogus-depot", "test-bogus-depot-0-impl" )
|
86
|
+
u_elements = api.update()
|
87
|
+
assert_not_nil( u_elements )
|
88
|
+
assert_equal( 44, u_elements.length )
|
89
|
+
u_elements.each do |location|
|
90
|
+
# api.update returns a list of relative filenames
|
91
|
+
assert( location =~ /^[^\/]/, "Location '#{location}' should be a relpath" )
|
92
|
+
end
|
93
|
+
# test yield and array return XXX
|
94
|
+
updated = 0
|
95
|
+
api.update().each do |location|
|
96
|
+
updated += 1
|
97
|
+
assert( location =~ /^[^\/]/, "Location '#{location}' should be a relpath" )
|
98
|
+
end
|
99
|
+
assert_equal( 44, updated )
|
100
|
+
end
|
101
|
+
|
102
|
+
# update-updates.xml - update with updated files
|
103
|
+
def test_update_updates()
|
104
|
+
Command.instance do |cmd|
|
105
|
+
cmd.accurev_bin = "./acreplay.rb eg/update-updates.xml"
|
106
|
+
end
|
107
|
+
api = API.new( "test", "test-bogus-depot", "test-bogus-depot-0-impl" )
|
108
|
+
# XXX elements in elements list are just "modified" -
|
109
|
+
# may have been removed!
|
110
|
+
# XXX update() should return only filenames, right? eliminate dirs
|
111
|
+
ue = api.update()
|
112
|
+
assert_not_nil( ue )
|
113
|
+
assert_equal( 23, ue.length )
|
114
|
+
ue.each do |location|
|
115
|
+
assert( location =~ /^[^\/]/, "Location '#{location}' should be a relpath" )
|
116
|
+
end
|
117
|
+
# yielding behavior
|
118
|
+
updated = 0
|
119
|
+
api.update().each do |location|
|
120
|
+
updated += 1
|
121
|
+
assert( location =~ /^[^\/]/, "Location '#{location}' should be a relpath" )
|
122
|
+
end
|
123
|
+
assert_equal( 23, updated )
|
124
|
+
end
|
125
|
+
|
126
|
+
def test_info()
|
127
|
+
Command.instance do |cmd|
|
128
|
+
cmd.accurev_bin = "./acreplay.rb eg/info.txt"
|
129
|
+
end
|
130
|
+
api = API.new( "test", "depot", "stream" )
|
131
|
+
info = api.ac_info()
|
132
|
+
assert( info.size == 13 )
|
133
|
+
# some crap
|
134
|
+
assert_equal( "gfast", info['Principal'] )
|
135
|
+
assert_equal( "5050", info['port'] )
|
136
|
+
assert_equal( "/usr/local/accurev/bin", info['ACCUREV_BIN'] )
|
137
|
+
# the interesting stuff:
|
138
|
+
# - depot name
|
139
|
+
assert_equal( "orbitz-api-hiredcar", info['Depot'] )
|
140
|
+
# - workspace or reference stream name
|
141
|
+
assert_equal( "orbitz-api-hiredcar-0-rc-testing_gfast", info['ws/ref'] )
|
142
|
+
# - basis stream name
|
143
|
+
assert_equal( "orbitz-api-hiredcar-1-rc", info['Basis'] )
|
144
|
+
# - workspace checkout location
|
145
|
+
assert_equal( "/home/gfast/dev/orbitz-api-hirdcar-0-rc", info['Top'] )
|
146
|
+
end
|
147
|
+
|
148
|
+
def test_pop()
|
149
|
+
pwd = FileUtils.pwd
|
150
|
+
# want to use a tempdir since checkout_pop does a mkdir
|
151
|
+
tmpdir = "#{Dir.tmpdir}/#{$$}.test"
|
152
|
+
Command.instance do |cmd|
|
153
|
+
cmd.accurev_bin = "#{pwd}/test/acreplay.rb #{pwd}/test/eg/ac-pop.txt"
|
154
|
+
end
|
155
|
+
api = API.new( tmpdir, "depot" )
|
156
|
+
files = api.checkout_pop()
|
157
|
+
assert_equal( 162, files.size() )
|
158
|
+
files.each do |f|
|
159
|
+
assert( !(f =~ /^\//), "Location '#{f}' should not start with '/'" )
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
end
|
data/test/t_command.rb
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
require 'rubygems'
|
4
|
+
require 'rscm/accurev'
|
5
|
+
|
6
|
+
include RSCM::Accurev
|
7
|
+
|
8
|
+
class CommandTest < Test::Unit::TestCase
|
9
|
+
|
10
|
+
def test_command_line_subs
|
11
|
+
Command.discard
|
12
|
+
cmd = Command.instance
|
13
|
+
|
14
|
+
s = cmd.accurev_cmdline( "foo", "bar" )
|
15
|
+
assert_equal( "accurev foo bar", s )
|
16
|
+
|
17
|
+
cmd.accurev_bin = "xyzzy"
|
18
|
+
|
19
|
+
s = cmd.accurev_cmdline( "foo", "bar" )
|
20
|
+
assert_equal( "xyzzy foo bar", s )
|
21
|
+
|
22
|
+
Command.discard
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_a_e
|
26
|
+
cmd = Command.instance
|
27
|
+
## cmd.working_dir = "test"
|
28
|
+
cmd.debug = true
|
29
|
+
cmd.debug_to = File.open( "/tmp/testing.log", "w" )
|
30
|
+
cmd.accurev_bin = "./acreplay.rb eg/update-newwksp.xml"
|
31
|
+
# test listy output
|
32
|
+
with_working_dir( "test" ) do
|
33
|
+
acresponse = cmd.accurev( "files" )
|
34
|
+
assert_not_nil( acresponse )
|
35
|
+
assert( acresponse.kind_of?( AcResponseData ) )
|
36
|
+
assert( acresponse['element'].size == 44 )
|
37
|
+
assert( acresponse['message'].size == 44 )
|
38
|
+
acresponse['element'].each do |e|
|
39
|
+
assert( e.kind_of?( ElementData ) )
|
40
|
+
end
|
41
|
+
end
|
42
|
+
Command.discard
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_threadlocal_private_new
|
46
|
+
begin
|
47
|
+
cmd = Command.new
|
48
|
+
flunk( "Command.new() should be private" )
|
49
|
+
rescue
|
50
|
+
assert( true )
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_threadlocal
|
55
|
+
# instance returns this thread's Command object
|
56
|
+
begin
|
57
|
+
cmd = Command.instance
|
58
|
+
cmd.accurev_bin = "/bin/bash"
|
59
|
+
assert_equal( cmd.accurev_bin, "/bin/bash" )
|
60
|
+
end
|
61
|
+
# and calling it again returns the same object
|
62
|
+
begin
|
63
|
+
cmd = Command.instance
|
64
|
+
assert_equal( cmd.accurev_bin, "/bin/bash" )
|
65
|
+
end
|
66
|
+
# but instance in another thread should be different
|
67
|
+
Thread.new do
|
68
|
+
cmd = Command.instance
|
69
|
+
assert_not_equal( cmd.accurev_bin, "/bin/bash" )
|
70
|
+
end.join()
|
71
|
+
# ...and calling it *again* returns the same object
|
72
|
+
begin
|
73
|
+
cmd = Command.instance
|
74
|
+
assert_equal( cmd.accurev_bin, "/bin/bash" )
|
75
|
+
end
|
76
|
+
# but discard tosses this thread's object:
|
77
|
+
Command.discard
|
78
|
+
begin
|
79
|
+
cmd = Command.instance
|
80
|
+
assert_not_equal( cmd.accurev_bin, "/bin/bash" )
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
data/test/t_filterio.rb
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
require 'rubygems'
|
3
|
+
require 'stringio'
|
4
|
+
require 'rscm/scm/accurev/filterio'
|
5
|
+
require 'rexml/document'
|
6
|
+
require 'test/unit'
|
7
|
+
|
8
|
+
BUSTED_DOC = <<-EOF
|
9
|
+
<?xml version="1.0"?>
|
10
|
+
<acResponse
|
11
|
+
command="update"Accurev XML Sucks Beans
|
12
|
+
>
|
13
|
+
<element location="/./foo.txt" />
|
14
|
+
<message>Argh.</message>
|
15
|
+
</acResponse>
|
16
|
+
EOF
|
17
|
+
|
18
|
+
include REXML
|
19
|
+
include RSCM::Accurev
|
20
|
+
|
21
|
+
class TestStackIO < Test::Unit::TestCase
|
22
|
+
|
23
|
+
# test that the unfiltered doc actually fails as expected
|
24
|
+
def test_unfiltered_breakage
|
25
|
+
begin
|
26
|
+
doc = Document.new( StringIO.new( BUSTED_DOC ) )
|
27
|
+
flunk( "String not parseable, should have thrown exception" )
|
28
|
+
rescue
|
29
|
+
assert( true, "Expected to throw exception" )
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# test that the stackio filters out the unwanted cruft
|
34
|
+
def test_filtered
|
35
|
+
sio = FilterIO.new( StringIO.new( BUSTED_DOC ) ) do |string|
|
36
|
+
x = string.gsub( /command="update".*$/, 'command="update"' )
|
37
|
+
x
|
38
|
+
end
|
39
|
+
assert( sio.respond_to?( :read ) )
|
40
|
+
str = sio.read()
|
41
|
+
assert( str =~ /acResponse/ )
|
42
|
+
assert( ! (str =~ /Sucks/) )
|
43
|
+
end
|
44
|
+
|
45
|
+
# test that the stackio filters out the unwanted cruft
|
46
|
+
def test_filtered_doc
|
47
|
+
sio = FilterIO.new( StringIO.new( BUSTED_DOC ) ) do |string|
|
48
|
+
string.gsub( /command="update".*$/, 'command="update"' )
|
49
|
+
end
|
50
|
+
assert( sio.respond_to?( :read ) )
|
51
|
+
|
52
|
+
doc = Document.new( sio )
|
53
|
+
assert( true, "Document should now be parseable" )
|
54
|
+
assert_equal( "acResponse", doc.root.name )
|
55
|
+
# assert_equal( 1, doc.elements.each( "/acResponse/element" ).length )
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
|