#!/usr/bin/perl
########################################################################
# Test the XML loader for stange behavior. While api.t checks that
# propely formed stuff is loaded okay, this test checks that if you do
# random things with a Froody::API::XML class you get the right errors
########################################################################
use strict;
use warnings;
use Test::Exception;
# start the tests
use Test::More tests => 24;
use_ok("Froody::API::XML");
use Froody::Error qw(err);
#### bad calls to methods ####
dies_ok
{ Froody::API::XML->load_method("Foo"); }
"try random text in 'load_method'";
ok(err("perl.methodcall.param"), "right error thrown");
dies_ok
{ Froody::API::XML->load_errortype("Foo"); }
"try random text in 'load_error'";
ok(err("perl.methodcall.param"), "right error thrown");
dies_ok
{ Froody::API::XML->load_method(bless {}, "wibble"); }
"try random object in 'load_method'";
ok(err("perl.methodcall.param"), "right error thrown");
dies_ok
{ Froody::API::XML->load_errortype(bless {}, "wibble"); }
"try random object in 'load_errortype'";
ok(err("perl.methodcall.param"), "right error thrown");
### bad xml ###
throws_ok {
Froody::API::XML->load_spec();
} qr{No xml passed to load_spec}, "passing nothing";
ok(err("perl.methodcall.param"), "right error thrown")
or diag $@->code;
throws_ok {
Froody::API::XML->load_spec("");
} qr{No xml passed to load_spec}, "parsing empty string";
ok(err("perl.methodcall.param"), "right error thrown")
or diag $@->code;
throws_ok {
Froody::API::XML->load_spec("not xml");
} qr{Invalid}, "something not xml";
ok(err("froody.xml.invalid"), "right error thrown")
or diag $@->code;
throws_ok {
Froody::API::XML->load_spec("");
} qr{Invalid}, "badly formed";
ok(err("froody.xml.invalid"), "right error thrown")
or diag $@->code;
throws_ok {
Froody::API::XML->load_spec("");
} qr{no methods found in spec!}, "missing ";
ok(err("froody.xml.nomethods"), "right error thrown")
or diag $@->code;
throws_ok {
Froody::API::XML->load_spec("");
} qr{no methods found in spec!}, "missing ";
ok(err("froody.xml.nomethods"), "right error thrown")
or diag $@->code;
throws_ok {
Froody::API::XML->load_spec("");
} qr{Can't find the attribute 'name'}, "missing 'name' on methods";
ok(err("froody.xml"), "right error thrown")
or diag $@->code;
lives_ok {
Froody::API::XML->load_spec(<<'XML');
XML.com
http://xml.com/pub
XML.com features a rich mix of information and services
for the XML community.
XML.com
http://www.xml.com
http://xml.com/universal/images/xml_tiny.gifProcessing Inclusions with XSLT
http://xml.com/pub/2000/08/09/xslt/xslt.html
Processing document inclusions with general XML tools can be
problematic. This article proposes a way of preserving inclusion
information through SAX-based processing.
Putting RDF to Work
http://xml.com/pub/2000/08/09/rdfdb/index.html
Tool and API support for the Resource Description Framework
is slowly coming of age. Edd Dumbill takes a look at RDFDB,
one of the most exciting new RDF toolkits.
Search XML.comSearch XML.com's XML collections
http://search.xml.com
XML
};