our
@doc
;
BEGIN {
@doc
= (
qw(
#document empty empty
#document html head title head body h1 body html
)
);
}
Wheel::ReadWrite
Driver::SysRW
)
;
plan
tests
=>
@doc
+ 1;
autoflush STDOUT 1;
my
$request_number
= 8;
my
$session
= POE::Session->create(
inline_states
=> {
_start
=> \
&start
,
input
=> \
&input
,
error
=> \
&error
,
},
);
POE::Kernel->run();
exit
;
sub
start {
my
(
$kernel
,
$heap
) =
@_
[KERNEL, HEAP];
sysseek
(DATA,
tell
(DATA), 0);
my
$builder
= XML::SAX::IncrementalBuilder::LibXML->new(
godepth
=> 2);
my
$filter
= Data::Transform::SAXBuilder->new(
handler
=>
$builder
);
my
$wheel
= POE::Wheel::ReadWrite->new (
Handle
=> \
*DATA
,
Driver
=> POE::Driver::SysRW->new (
BlockSize
=> 17),
InputFilter
=>
$filter
,
InputEvent
=>
'input'
,
ErrorEvent
=>
'error'
,
);
$heap
->{
'wheel'
} =
$wheel
;
}
sub
input {
my
(
$kernel
,
$heap
,
$data
) =
@_
[KERNEL, HEAP, ARG0];
my
$expected
=
shift
@doc
;
is(
$data
->nodeName,
$expected
,
"got correct element"
);
}
sub
error {
my
$heap
=
$_
[HEAP];
my
(
$type
,
$errno
,
$errmsg
,
$id
) =
@_
[ARG0..
$#_
];
is(
$errno
, 0,
"got EOF"
);
delete
$heap
->{wheel};
}