1<\\/v>\s*<\\/root>)
$/',
'Check result serialization');
is($dsd->errstr, undef, 'Still no error');
ok($dsd = $rayapp->load_dsd_string('
'), 'Loading DSD with hashes with idattr');
is($rayapp->errstr, undef, 'Checking that there was no error');
is($dsd->uri, 'md5:05b830d5221596387afbf1f8a81bc4c7',
'Checking URI/MD5 of the DSD');
$out_content = <<'EOF';
EOF
is($dsd->out_content, $out_content, 'Checking the current content');
is($dsd->serialize_data({
'r' => { -1 => 1, -2 => 2 },
'v' => { 'a' => 1, 'b' => 2 },
}, { RaiseError => 0, validate => 1 }),
'
2
1
1
2
',
'Check serialization');
is($rayapp->errstr, undef, 'No error');
ok($dsd = $rayapp->load_dsd_string('
'), 'Loading DSD with hashes with conditions');
is($rayapp->errstr, undef, 'Checking that there was no error');
is($dsd->uri, 'md5:01676d650f6fdcf25fafc775a24446a5',
'Checking URI/MD5 of the DSD');
$out_content = <<'EOF';
EOF
is($dsd->out_content, $out_content, 'Checking the current content');
is($dsd->serialize_data({
a => 1, ma => 9,
b => 1, mb => 9,
c => 1, mc => 9,
d => 1, md => 9,
}, { RaiseError => 0, validate => 1 }),
'
9
9
',
'Check serialization with 1');
is($rayapp->errstr, undef, 'Checking that there was no error');
is($dsd->serialize_data({
a => undef, ma => 9,
b => undef, mb => 9,
c => undef, mc => 9,
d => undef, md => 9,
}, { RaiseError => 0, validate => 1 }),
'
9
9
',
'Check serialization with undef');
is($rayapp->errstr, undef, 'Checking that there was no error');
is($dsd->serialize_data({
a => 0, ma => 9,
b => 0, mb => 9,
c => 0, mc => 9,
d => 0, md => 9,
}, { RaiseError => 0, validate => 1 }),
'
9
9
',
'Check serialization with zero');
is($rayapp->errstr, undef, 'Checking that there was no error');
ok($dsd = $rayapp->load_dsd_string('
'), 'Loading DSD with hashes with namespaces');
is($rayapp->errstr, undef, 'Checking that there was no error');
is($dsd->uri, 'md5:170ef84d02264e6c7b0b8169365e31d5',
'Checking URI/MD5 of the DSD');
is($dsd->out_content, '
', 'Checking the current content');
is($dsd->serialize_data({
'html:b' => 'X',
s => { mb => 34 },
}, { RaiseError => 0, validate => 1 }),
'
X
34
', 'Serialization with data with colons');
is($rayapp->errstr, undef, 'No error still?');
ok($dsd = $rayapp->load_dsd('create_domain.dsd'),
'Loading DSD for CZ-NIC create domain command');
is($rayapp->errstr, undef, 'Check errstr');
is($dsd->serialize_data({
'dsdDomain:name' => 'asdf.cz',
'dsdDomain:description' => 'The ASDF is core of it all',
'dsdDomain:idadm' => 'ASDF',
'dsdDomain:idtech' => 'ASDF',
'dsdDomain:period' => 2,
'dsdDomain:nserver' => [
[ 'ns.asdf.cz', [ '111.111.111.111', '222.222.222.222' ], 'P' ],
[ 'ns.server.cz', undef, 'S' ],
],
'clTRID' => 'Ticket-1',
}, { RaiseError => 0, validate => 1 }),
'
asdf.cz
The ASDF is core of it all
ASDF
ASDF
2
ns.asdf.cz
111.111.111.111
222.222.222.222
P
ns.server.cz
S
Ticket-1
', 'Serialization with domain data');
is($rayapp->errstr, undef, 'No error still?');
ok($dsd = $rayapp->load_dsd('create_domain.dsd'),
'Loading DSD for CZ-NIC create domain command');
ok($dsd = $rayapp->load_uri('nonxml.xml'),
'Loading file which is not DSD and should not be processed as one');
is($rayapp->errstr, undef, 'Check errstr');
is($dsd->content, "This file is not XML.\n", 'Test the text content');
is(scalar keys %{ $rayapp->{uris} }, 37,
'Total number of distinct URIs processed');
ok($dsd = $rayapp->load_dsd('script1.dsd'), 'Loading correct DSD from string');
is($rayapp->errstr, undef, 'Checking that there was no error');
is($dsd->md5_hex, '113833fe853620287de9005698e3066a',
'Checking MD5 of the DSD');
like($dsd->application_name, '/t\/script1\.pl/', 'Checking application name');
my $appretval = $rayapp->execute_application_handler($dsd);
ok($appretval, 'Executing the application -- checking true return value');
ok(ref $appretval,
'Executing the application -- checking that the return is a reference');
my $outxml = $dsd->serialize_data($appretval,
{ RaiseError => 0, validate => 1 });
is ($outxml, '
Peter
Wolf
Brian
Fox
Leslie
Child
Barbara
Bailey
Russell
King
Michael
Johnson
Michael
Shell
Tim
Jasmine
1523
8234B
Šílené laně
', 'Checking that the output values are correct by serializing');
is($dsd->errstr, undef, 'No errstr');
$outxml = $dsd->serialize_data_dom($appretval,
{ RaiseError => 0, validate => 1 });
ok($outxml, 'Checking that the serialization to DOM is also OK.');
is(ref $outxml, 'XML::LibXML::Document', 'Checking that the ref is correct.');
is($dsd->errstr, undef, 'No errstr?');
use XML::LibXSLT;
my $xslt = new XML::LibXSLT;
ok($xslt, 'Checking that the XML::LibXSLT parser was created OK.');
my $style = $xslt->parse_stylesheet_file('script1.xsl');
ok($style, 'Loading the t/script1.xsl stylesheet');
my $results = $style->transform($outxml);
ok($results, 'Running transformation');
is($results->toString, '
A list of students
Study program:
Šílené laně
(8234B)
- Wolf Peter
- Fox Brian
- Child Leslie
- Bailey Barbara
- King Russell
- Johnson Michael
- Shell Michael
- Jasmine Tim
', 'Checking the output HTML');
TODO: {
todo_skip 'No Storable thingies', 5;
$appretval = $rayapp->execute_application_process_storable($dsd);
ok($appretval, 'Executing the application -- checking true return value');
ok(ref $appretval,
'Executing the application -- checking that the return is a reference');
$outxml = $dsd->serialize_data($appretval, { RaiseError => 0, validate => 1 });
is($outxml, '
Peter
Wolf
Brian
Fox
Leslie
Child
Barbara
Bailey
Russell
King
Michael
Johnson
Michael
Shell
Tim
Jasmine
1523
8234B
Biology
', 'Checking that the output values are correct by serializing');
is($dsd->errstr, undef, 'Check no error message appeared');
$outxml = $dsd->serialize_data_dom($appretval,
{ RaiseError => 0, validate => 1 });
ok($outxml, 'Checking that the serialization to DOM is also OK.');
is(ref $outxml, 'XML::LibXML::Document', 'Checking that the ref is correct.');
is($dsd->errstr, undef, 'Look at errstr');
$results = $style->transform($outxml);
ok($results, 'Running transformation');
is($results->toString, '
A list of students
Study program:
Biology
(8234B)
- Wolf Peter
- Fox Brian
- Child Leslie
- Bailey Barbara
- King Russell
- Johnson Michael
- Shell Michael
- Jasmine Tim
', 'Checking the output HTML');
}
$appretval = $rayapp->execute_application_handler_reuse($dsd);
ok($appretval, 'Executing the application -- checking true return value');
ok(ref $appretval,
'Executing the application -- checking that the return is a reference');
$outxml = $dsd->serialize_data_dom($appretval,
{ RaiseError => 0, validate => 1 });
ok($outxml, 'Checking that the serialization to DOM is also OK.');
is(ref $outxml, 'XML::LibXML::Document', 'Checking that the ref is correct.');
is($dsd->errstr, undef, 'No errstr?');
$results = $style->transform($outxml);
ok($results, 'Running transformation');
is(Encode::decode('utf-8', $results->toString),
'
A list of students
Study program:
Šílené laně
(8234B)
- Wolf Peter
- Fox Brian
- Child Leslie
- Bailey Barbara
- King Russell
- Johnson Michael
- Shell Michael
- Jasmine Tim
', 'Checking the output HTML');
$appretval = $rayapp->execute_application_handler_reuse($dsd);
ok($appretval, 'Executing the application -- checking true return value');
ok(ref $appretval,
'Executing the application -- checking that the return is a reference');
$outxml = $dsd->serialize_data_dom($appretval,
{ RaiseError => 0, validate => 1 });
ok($outxml, 'Checking that the serialization to DOM is also OK.');
is(ref $outxml, 'XML::LibXML::Document', 'Checking that the ref is correct.');
is($dsd->errstr, undef, 'Expected clear error message');
$results = $style->transform($outxml);
ok($results, 'Running transformation');
is(Encode::decode('utf-8', $results->toString),
'
A list of students
Study program:
Šílené laně
(8234B)
- Wolf Peter
- Fox Brian
- Child Leslie
- Bailey Barbara
- King Russell
- Johnson Michael
- Shell Michael
- Jasmine Tim
', 'Checking the output HTML');
my $out = $dsd->serialize_style(
{
program => [ 2534, 'X' ],
students => [ [ 'A', 'B' ] ],
}, {}, 'script1.xsl');
is($out, '
A list of students
Study program:
(X)
', 'Serializing and styling');
is($dsd->errstr, undef, 'Check errstr');
=comment
TODO: {
local $TODO = 'rayapp_cgi_wrapper not ready for prime time yet';
$ENV{RAYAPP_DIRECTORY} = Cwd::getcwd();
if (${^TAINT}) {
$^X =~ /^(.+)$/ and $^X = $1;
delete @ENV{'PATH', 'ENV'};
}
my $extout = `$^X ../../bin/rayapp_cgi_wrapper script2.xml`;
is($extout, 'Pragma: no-cache
Cache-control: no-cache
Status: 200
Content-Type: text/xml; charset=UTF-8
Peter
Wolf
Brian
Fox
Leslie
Child
Barbara
Bailey
Russell
King
Michael
Johnson
Michael
Shell
Tim
Jasmine
1523
8234B
Šílené laně
', 'Running rayapp_cgi_wrapper');
$extout = `../../bin/rayapp_cgi_wrapper script2.xml`;
is($extout, 'Pragma: no-cache
Cache-control: no-cache
Status: 200
Content-Type: text/xml
Peter
Wolf
Brian
Fox
Leslie
Child
Barbara
Bailey
Russell
King
Michael
Johnson
Michael
Shell
Tim
Jasmine
1523
8234B
Šílené laně
', 'Running RayApp::CGI without stylesheets');
$ENV{RAYAPP_HTML_STYLESHEETS} = 'script1.xsl';
$extout = `../../bin/rayapp_cgi_wrapper script1.html`;
utf8::encode($extout);
is($extout, 'Pragma: no-cache
Cache-control: no-cache
Status: 200
Content-Type: text/html; charset=UTF-8
A list of students
Study program:
Šílené laně
(8234B)
- Wolf Peter
- Fox Brian
- Child Leslie
- Bailey Barbara
- King Russell
- Johnson Michael
- Shell Michael
- Jasmine Tim
', 'Running RayApp::CGI with implicit stylesheet');
$extout = `../../bin/rayapp_cgi_wrapper script2.html`;
is($extout, 'Pragma: no-cache
Cache-control: no-cache
Status: 200
Content-Type: text/html; charset=UTF-8
A list of students
Study program:
Šílené laně
(8234B)
- Wolf Peter
- Fox Brian
- Child Leslie
- Bailey Barbara
- King Russell
- Johnson Michael
- Shell Michael
- Jasmine Tim
', 'Running RayApp::CGI with a stylesheet');
}
=cut