diff --git a/swig/perl/t/00basic.t b/swig/perl/t/00basic.t index 45f26baa0e9973afd21544f49910a44171fceaa5..c31d814f690165d6b7b97080f6374ed81dfe913f 100644 --- a/swig/perl/t/00basic.t +++ b/swig/perl/t/00basic.t @@ -1,13 +1,22 @@ +# Before `make install' is performed this script should be runnable +# with `make test'. After `make install' it should work as `perl +# 00basic.t' + +######################### Begin module loading + # use blib; -use XML::Xerces; -use Cwd; -use Test::More tests => 19; + +use Test::More tests => 20; +BEGIN { use_ok(XML::Xerces::DOM) }; + use lib 't'; -use TestUtils qw( - $SYSTEM_RESOLVER_FILE_NAME +use TestUtils qw($SYSTEM_RESOLVER_FILE_NAME $SAMPLE_DIR + $PERSONAL_FILE_NAME + $PERSONAL_INVALID_FILE_NAME + $PERSONAL_NOT_WELL_FORMED_FILE_NAME ); -pass("loaded"); +######################### Begin Test # NOTICE: We must now explicitly call XMLPlatformUtils::Initialize() # when the module is loaded. Xerces.pm no longer does this. @@ -25,12 +34,10 @@ $parser->setErrorHandler($ERROR_HANDLER); my $tmp = $parser->getErrorHandler(); isa_ok($tmp,'XML::Xerces::ErrorHandler'); -my $cwd = cwd(); -$cwd =~ s|/t/?$||; -my $SAMPLE_DIR = "$cwd/samples"; -my $PERSONAL_FILE_NAME = "$SAMPLE_DIR/personal.xml"; -my $PERSONAL_INVALID_FILE_NAME = "$SAMPLE_DIR/personal-invalid.xml"; -my $PERSONAL_NOT_WELL_FORMED_FILE_NAME = "$SAMPLE_DIR/personal-not-well-formed.xml"; +my $resolver = XML::Xerces::PerlEntityResolver->new(); +$parser->setEntityResolver($resolver); +$tmp = $parser->getEntityResolver(); +isa_ok($tmp,'XML::Xerces::EntityResolver'); $parser->setValidationScheme($XML::Xerces::AbstractDOMParser::Val_Never); $tmp = $parser->getValidationScheme(); diff --git a/swig/perl/t/01utf8.t b/swig/perl/t/01utf8.t index bbd4ed2e81b6ffff594a671253c8d7ccadb5c117..5c968e628970b2addfacba289c4471a159a20941 100644 --- a/swig/perl/t/01utf8.t +++ b/swig/perl/t/01utf8.t @@ -12,7 +12,7 @@ use utf8; use lib 't'; use TestUtils qw($PERSONAL_NO_DOCTYPE); -BEGIN { use_ok("XML::Xerces") }; +BEGIN { use_ok("XML::Xerces::SAX") }; use strict; diff --git a/swig/perl/t/AttributeList.t b/swig/perl/t/AttributeList.t index 75d7ca9ab06fc99f4d5f72377bcd3373a4b06f12..a219b0974e2a0d65894d4fa76258f90aac44001a 100644 --- a/swig/perl/t/AttributeList.t +++ b/swig/perl/t/AttributeList.t @@ -2,25 +2,17 @@ # with `make test'. After `make install' it should work as `perl # AttributeList.t' -######################### We start with some black magic to print on failure. +######################### Begin module loading -END {fail() unless $loaded;} - -use Carp; -use blib; -use XML::Xerces; +#use blib; use Test::More tests => 11; -use Config; +BEGIN {use_ok("XML::Xerces::SAX")}; use lib 't'; use TestUtils qw($PERSONAL_FILE_NAME); -use vars qw($loaded); use strict; -$loaded = 1; -pass("module loaded"); - -######################### End of black magic. +######################### Begin test # NOTICE: We must now explicitly call XMLPlatformUtils::Initialize() # when the module is loaded. Xerces.pm no longer does this. diff --git a/swig/perl/t/Attributes.t b/swig/perl/t/Attributes.t index 0e423ae774c42c5d2d8610ea35e7b00ce5789559..56edd7ea2df3d04fd47dafa6197b4aa75d13b03f 100644 --- a/swig/perl/t/Attributes.t +++ b/swig/perl/t/Attributes.t @@ -6,7 +6,7 @@ # use blib; use Test::More tests => 19; -BEGIN { use_ok("XML::Xerces") }; +BEGIN { use_ok("XML::Xerces::SAX") }; use strict; diff --git a/swig/perl/t/DOMConfig.t b/swig/perl/t/DOMConfig.t index 6b0cebbc51023b8f30d9e9a302fb677cfded4c40..b1485ab9d5170cf1197ddb68fa2d09abc1742abb 100644 --- a/swig/perl/t/DOMConfig.t +++ b/swig/perl/t/DOMConfig.t @@ -4,8 +4,8 @@ ######################### Begin module loading -# use blib; -use Test::More tests => 20; +use blib; +use Test::More tests => 106; BEGIN{use_ok('XML::Xerces::DOM')}; @@ -16,6 +16,12 @@ use strict; ######################### Begin Test + # NOTICE: We must now explicitly call XMLPlatformUtils::Initialize() + # when the module is loaded. Xerces.pm no longer does this. + # + # +XML::Xerces::XMLPlatformUtils::Initialize(); + my $document = q[<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <contributors> <person Role="manager"> @@ -37,29 +43,165 @@ my $DOM = $impl->createLSParser($XML::Xerces::DOMImplementationLS::MODE_SYNCHRON my $conf = $DOM->getDomConfig(); isa_ok($conf, 'XML::Xerces::DOMConfiguration'); -my @param_names = ($XML::Xerces::XMLUni::fgDOMErrorHandler, - $XML::Xerces::XMLUni::fgDOMSchemaType, - $XML::Xerces::XMLUni::fgDOMSchemaLocation, - $XML::Xerces::XMLUni::fgDOMCanonicalForm, - $XML::Xerces::XMLUni::fgDOMCDATASections, - $XML::Xerces::XMLUni::fgDOMComments, - $XML::Xerces::XMLUni::fgDOMDatatypeNormalization, - $XML::Xerces::XMLUni::fgDOMWRTDiscardDefaultContent, - $XML::Xerces::XMLUni::fgDOMEntities, - $XML::Xerces::XMLUni::fgDOMInfoset, - $XML::Xerces::XMLUni::fgDOMNamespaces, - $XML::Xerces::XMLUni::fgDOMNamespaceDeclarations, - $XML::Xerces::XMLUni::fgDOMNormalizeCharacters, - $XML::Xerces::XMLUni::fgDOMSplitCDATASections, - $XML::Xerces::XMLUni::fgDOMValidate, - $XML::Xerces::XMLUni::fgDOMValidateIfSchema, - $XML::Xerces::XMLUni::fgDOMElementContentWhitespace); +my @other_param_names = ($XML::Xerces::XMLUni::fgDOMErrorHandler, + $XML::Xerces::XMLUni::fgXercesEntityResolver, + $XML::Xerces::XMLUni::fgDOMResourceResolver, + $XML::Xerces::XMLUni::fgXercesSecurityManager, + $XML::Xerces::XMLUni::fgXercesScannerName, + $XML::Xerces::XMLUni::fgXercesSchemaExternalSchemaLocation, + $XML::Xerces::XMLUni::fgXercesSchemaExternalNoNameSpaceSchemaLocation, + $XML::Xerces::XMLUni::fgXercesParserUseDocumentFromImplementation, + ); + +my @false_bool_param_names = ( + $XML::Xerces::XMLUni::fgDOMSupportedMediatypesOnly, +); + +my @true_bool_param_names = ( + $XML::Xerces::XMLUni::fgDOMNamespaceDeclarations, + $XML::Xerces::XMLUni::fgDOMWellFormed, + $XML::Xerces::XMLUni::fgDOMInfoset, + $XML::Xerces::XMLUni::fgDOMCharsetOverridesXMLEncoding, + $XML::Xerces::XMLUni::fgDOMNamespaces, + $XML::Xerces::XMLUni::fgDOMValidate, + $XML::Xerces::XMLUni::fgDOMValidateIfSchema, + $XML::Xerces::XMLUni::fgDOMComments, + $XML::Xerces::XMLUni::fgDOMDatatypeNormalization, + $XML::Xerces::XMLUni::fgDOMElementContentWhitespace, + $XML::Xerces::XMLUni::fgDOMEntities, + $XML::Xerces::XMLUni::fgXercesSchema, + $XML::Xerces::XMLUni::fgXercesSchemaFullChecking, + $XML::Xerces::XMLUni::fgXercesUserAdoptsDOMDocument, + $XML::Xerces::XMLUni::fgXercesLoadExternalDTD, + $XML::Xerces::XMLUni::fgXercesContinueAfterFatalError, + $XML::Xerces::XMLUni::fgXercesValidationErrorAsFatal, + $XML::Xerces::XMLUni::fgXercesCacheGrammarFromParse, + $XML::Xerces::XMLUni::fgXercesUseCachedGrammarInParse, + $XML::Xerces::XMLUni::fgXercesCalculateSrcOfs, + $XML::Xerces::XMLUni::fgXercesStandardUriConformant, + $XML::Xerces::XMLUni::fgXercesDOMHasPSVIInfo, + $XML::Xerces::XMLUni::fgXercesGenerateSyntheticAnnotations, + $XML::Xerces::XMLUni::fgXercesValidateAnnotations, + $XML::Xerces::XMLUni::fgXercesIdentityConstraintChecking, + $XML::Xerces::XMLUni::fgXercesIgnoreCachedDTD, + $XML::Xerces::XMLUni::fgXercesIgnoreAnnotations, + $XML::Xerces::XMLUni::fgXercesDisableDefaultEntityResolution, + $XML::Xerces::XMLUni::fgXercesSkipDTDValidation); + +my @todo_param_names = ($XML::Xerces::XMLUni::fgDOMSchemaLocation, + $XML::Xerces::XMLUni::fgDOMSchemaType, + $XML::Xerces::XMLUni::fgDOMDisallowDoctype, + $XML::Xerces::XMLUni::fgDOMCanonicalForm, + $XML::Xerces::XMLUni::fgDOMIgnoreUnknownCharacterDenormalization, + $XML::Xerces::XMLUni::fgDOMCDATASections, + $XML::Xerces::XMLUni::fgDOMCheckCharacterNormalization, + $XML::Xerces::XMLUni::fgDOMNormalizeCharacters, + $XML::Xerces::XMLUni::fgDOMSplitCDATASections, + ); + +my @bool_param_names = (@true_bool_param_names, @false_bool_param_names); + +my @ls_param_names = (@bool_param_names, @other_param_names, @todo_param_names); my @accepted_param_names = $conf->getParameterNames(); ok(scalar @accepted_param_names, "got parameter name list"); -my %param_names = map {$_=>1} @param_names; -foreach my $param_name (@param_names) { - ok(exists $param_names{$param_name}, "can set $param_name"); +my %accepted_param_names = map {$_=>1} @accepted_param_names; +foreach my $param_name (@ls_param_names) { + ok(exists $accepted_param_names{$param_name}, "$param_name in param list"); +} + +# test bool value +foreach my $param_name (@true_bool_param_names) { + ok($conf->canSetParameter($param_name, 1), + "setting bool value: $param_name"); +} + +foreach my $param_name (@false_bool_param_names) { + ok($conf->canSetParameter($param_name, 0), + "setting bool value: $param_name"); +} + +TODO: { + local $TODO = "unimplemented params"; + + foreach my $param_name (@todo_param_names) { + ok($conf->canSetParameter($param_name, 0), + "todo param: $param_name"); + } +} + +# +# test setting object values +# +my $handler; + +$handler = XML::Xerces::PerlErrorHandler->new(); +ok($conf->canSetParameter($XML::Xerces::XMLUni::fgDOMErrorHandler, undef), + 'can set error handler'); + +eval {XML::Xercesc::DOMConfiguration_canSetParameter($conf, $XML::Xerces::XMLUni::fgXercesEntityResolver, $handler)}; +ok($@, + 'can set with bad value causes exception'); + +$handler = XML::Xerces::PerlEntityResolver->new(); +ok($conf->canSetParameter($XML::Xerces::XMLUni::fgXercesEntityResolver, undef), + 'can set entity resolver'); + +eval {$conf->setParameter($XML::Xerces::XMLUni::fgDGXMLScanner, $handler)}; +ok($@, + 'setParameter with bad value causes exception'); +isa_ok($@, "XML::Xerces::DOMException"); + +$handler = XML::Xerces::PerlDOMErrorHandler->new(); +isa_ok($handler, "XML::Xerces::DOMErrorHandler", + 'error handler to set'); +eval {$conf->setParameter($XML::Xerces::XMLUni::fgDOMErrorHandler, $handler)}; +ok((not $@), + 'setting error handler') + or XML::Xerces::error($@); + +isa_ok($conf->getParameter($XML::Xerces::XMLUni::fgDOMErrorHandler), "XML::Xerces::DOMErrorHandler", + 'getParameter'); + +eval {$conf->setParameter($XML::Xerces::XMLUni::fgDOMErrorHandler, undef)}; +ok((not $@), + 'setting null error handler') + or XML::Xerces::error($@); + +ok((not defined $conf->getParameter($XML::Xerces::XMLUni::fgDOMErrorHandler)), + 'getting null error handler'); + +$handler = XML::Xerces::PerlEntityResolver->new(); +isa_ok($handler, "XML::Xerces::XMLEntityResolver", + 'handler to set'); +eval {$conf->setParameter($XML::Xerces::XMLUni::fgXercesEntityResolver, $handler)}; +ok((not $@), + 'setting XMLEntityResolver') + or XML::Xerces::error($@); + +isa_ok($conf->getParameter($XML::Xerces::XMLUni::fgXercesEntityResolver), "XML::Xerces::XMLEntityResolver", + 'getParameter'); + +eval {$conf->setParameter($XML::Xerces::XMLUni::fgXercesEntityResolver, undef)}; +ok((not $@), + 'setting null XMLEntityResolver') + or XML::Xerces::error($@); + +ok((not defined $conf->getParameter($XML::Xerces::XMLUni::fgXercesEntityResolver)), + 'getting null XMLEntityResolver'); + +eval {$conf->setParameter($XML::Xerces::XMLUni::fgDOMResourceResolver, $handler)}; +ok((not $@), + 'setting DOMLSResourceResolver') + or XML::Xerces::error($@); + +isa_ok($conf->getParameter($XML::Xerces::XMLUni::fgDOMResourceResolver), "XML::Xerces::DOMLSResourceResolver"); + +END { + # NOTICE: We must now explicitly call XMLPlatformUtils::Terminate() + # when the module is unloaded. Xerces.pm no longer does this for us + # + # + XML::Xerces::XMLPlatformUtils::Terminate(); } -my $handler = XML::Xerces::PerlErrorHandler->new(); diff --git a/swig/perl/t/DOMDocument.t b/swig/perl/t/DOMDocument.t index 5d5d40643cafe3d52cbaacc549b87ba40a4d09e1..d7ac345503070ef52fb3bda43f8fcf2184c15049 100644 --- a/swig/perl/t/DOMDocument.t +++ b/swig/perl/t/DOMDocument.t @@ -83,7 +83,7 @@ my $isa = "XML::Xerces::DOMException"; isa_ok($error,$isa) or diag($error); -my $expect = "$XML::Xerces::DOMException::INVALID_CHARACTER_ERR"; +my $expect = $XML::Xerces::DOMException::INVALID_CHARACTER_ERR; ok(UNIVERSAL::isa($error,$isa) && $error->getCode == $expect, "received correct error code") @@ -105,23 +105,16 @@ ok((UNIVERSAL::isa($error,$isa) || diag("found code: $error->{code}, expected code: $expect"); # check that an element can start with an underscore -eval { - my $el = $doc1->createElement('_'); -}; +$el = eval{$doc1->createElement('_')}; ok(!$@, "element can start with underscore"); # check that an element can start with an colon -eval { - my $el = $doc1->createElement(':'); -}; +$el = eval {$doc1->createElement(':')}; ok(!$@, - "element cannot start with colon"); + "element can start with colon"); # check that getElementById() doesn't segfault on undef ID -eval { - $doc1->getElementById(undef); -}; -ok($@, - "calling getElementById with null string causes exception"); - +$el = eval {$doc1->getElementById(undef)}; +ok((not defined $el), + "calling getElementById with undef returns undef"); diff --git a/swig/perl/t/DOMElement.t b/swig/perl/t/DOMElement.t index 6687fc222cbdc924e0336be62aedad2a98b8b173..d1e3179c90d70e95525e76d5d27beb60ec0f71c1 100644 --- a/swig/perl/t/DOMElement.t +++ b/swig/perl/t/DOMElement.t @@ -4,7 +4,7 @@ ######################### Begin module loading -use blib; +# use blib; use Test::More tests => 23; BEGIN { use_ok("XML::Xerces::DOM") }; @@ -68,8 +68,8 @@ ok(($persons[0]->getAttribute('bar') eq $value), # try to set an Attribute, 'foo', to undef eval{$persons[0]->setAttribute('foo',undef)}; -ok($@, - "setAttribute - undef value fails"); +ok(!$@, + "setAttribute - undef value succeeds"); # try to set an Attribute, undef, to 'foo' eval{$persons[0]->setAttribute(undef,'foo')}; @@ -104,8 +104,8 @@ is($element->getAttributeNS($uri,'foo'), 'foo', # try to set an Attribute, 'foo', to undef eval{$element->setAttributeNS($uri,'foo',undef)}; -ok($@, - "setAttributeNS - undef value fails"); +ok(!$@, + "setAttributeNS - undef value succeeds"); # try to set an Attribute, undef, to 'foo' eval{$element->setAttributeNS($uri,undef,'foo')}; @@ -114,8 +114,8 @@ ok($@, # try to set an Attribute, with uri == undef eval{$element->setAttributeNS(undef,'foo','foo')}; -ok($@, - "setAttributeNS - undef uri fails"); +ok(!$@, + "setAttributeNS - undef uri succeeds"); $uri = 'http://example.org/'; $document = <<XML; diff --git a/swig/perl/t/DOMImplementation.t b/swig/perl/t/DOMImplementation.t index 0879784aae6c1eb65634209e3435b44a399ecf7f..79cebed87dd4d347144f373a10e717a0ad1e83c0 100644 --- a/swig/perl/t/DOMImplementation.t +++ b/swig/perl/t/DOMImplementation.t @@ -4,8 +4,8 @@ ######################### Begin module loading -# use blib; -use Test::More tests => 6; +use blib; +use Test::More tests => 26; BEGIN { use_ok("XML::Xerces::DOM") }; use lib 't'; @@ -22,32 +22,104 @@ XML::Xerces::XMLPlatformUtils::Initialize(); my $domImpl = XML::Xerces::DOMImplementationRegistry::getDOMImplementation('LS'); isa_ok($domImpl,"XML::Xerces::DOMImplementation"); +isa_ok($domImpl,"XML::Xerces::DOMImplementationLS"); my $dt = eval{$domImpl->createDocumentType('x', 'x', 'x')}; XML::Xerces::error($@) if $@; isa_ok($dt,"XML::Xerces::DOMDocumentType"); +$dt = eval{$domImpl->createDocumentType(undef, 'x', 'x')}; +ok($@, + 'exception with undef as qualified name'); + +$dt = eval{$domImpl->createDocumentType('x', undef, 'x')}; +ok(!$@, + 'no exception with undef as public id'); + +$dt = eval{$domImpl->createDocumentType('x', 'x', undef)}; +ok(!$@, + 'no exception with undef as system id'); + +# test exceptions +$dt = eval{$domImpl->createDocumentType('!', 'x', 'x')}; +ok($@, + 'exception with invalid char in qualified name'); +isa_ok($@,"XML::Xerces::DOMException"); +is($@->getCode(),$XML::Xerces::DOMException::INVALID_CHARACTER_ERR, + 'invalid char exception code is returned'); + +TODO: { + local $TODO = 'NAMESPACE_ERR not thrown'; + $dt = eval{$domImpl->createDocumentType('!malformed', 'x', 'x')}; + is($@->getCode(),$XML::Xerces::DOMException::NAMESPACE_ERR, + 'exception in qualified name'); +} + +my $mode_synch = $XML::Xerces::DOMImplementationLS::MODE_SYNCHRONOUS; +is($mode_synch,1, + 'mode synchronous'); +my $mode_asynch = $XML::Xerces::DOMImplementationLS::MODE_ASYNCHRONOUS; +is($mode_asynch,2, + 'mode asynchronous'); + +my $dtd_type = $XML::Xerces::XMLUni::fgDOMDTDType; +is($dtd_type, 'http://www.w3.org/TR/REC-xml', + 'dtd type'); +my $schema_type = $XML::Xerces::XMLUni::fgDOMXMLSchemaType; +is($schema_type, 'http://www.w3.org/2001/XMLSchema', + 'schema type'); + +TODO: { + local $TODO = 'asynchronous mode not supported'; + my $parser = eval {$domImpl->createLSParser($mode_asynch, $dtd_type)}; + ok((not $@), + 'asynch mode, dtd type'); + $parser = eval {$domImpl->createLSParser($mode_asynch, $schema_type)}; + ok((not $@), + 'asynch mode, schema type'); +} + +my $parser = eval {$domImpl->createLSParser($mode_synch, $dtd_type)}; +XML::Xerces::error($@) + if $@; +ok((not $@), + 'synch mode, dtd type'); +isa_ok($parser,"XML::Xerces::DOMLSParser"); + +$parser = eval {$domImpl->createLSParser($mode_synch, $schema_type)}; +XML::Xerces::error($@) + if $@; +ok((not $@), + 'synch mode, schema type'); +isa_ok($parser,"XML::Xerces::DOMLSParser"); + +my $writer = $domImpl->createLSSerializer(); +isa_ok($writer,"XML::Xerces::DOMLSSerializer"); + +my $input = $domImpl->createLSInput(); +isa_ok($input,"XML::Xerces::DOMLSInput"); + +my $output = $domImpl->createLSOutput(); +isa_ok($output,"XML::Xerces::DOMLSOutput"); + my $doc = $domImpl->createDocument('myns', 'HISTORY', $dt); isa_ok($doc,"XML::Xerces::DOMDocument"); ok(keys %XML::Xerces::DOMDocument::OWNER == 0, "DOMDocument not owned after creation"); -$doc->getDocumentElement->setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:myns", 'myns'); +# test exceptions +my $domImpl2 = XML::Xerces::DOMImplementationRegistry::getDOMImplementation('LS'); +my $doc2 = eval{$domImpl2->createDocument('myns', 'BAR', $dt)}; +XML::Xerces::error($@) if $@; -for (my $i = 0; $i < 10; $i++) { - my $record = $doc->createElement('RECORD'); - $doc->getDocumentElement->appendChild($record); - $record->setAttribute('ID', '0'); - $record->setAttribute('PRICE', '1.1'); - $record->setAttribute('VOl', '10'); -} -my @elements = $doc->getElementsByTagName('*'); -ok(scalar @elements == 11, - "Found all created elements") - or diag("Found only " . scalar @elements . " elements"); -$doc->release(); +my $doc3 = eval{$domImpl->createDocument('myns', '!', $dt)}; +ok($@, + 'exception with invalid char in qualified name'); +isa_ok($@,"XML::Xerces::DOMException"); +is($@->getCode(),$XML::Xerces::DOMException::INVALID_CHARACTER_ERR, + 'invalid char exception code is returned'); END { # NOTICE: We must now explicitly call XMLPlatformUtils::Terminate() diff --git a/swig/perl/t/DOMBuilder.t b/swig/perl/t/DOMLSParser.t similarity index 63% rename from swig/perl/t/DOMBuilder.t rename to swig/perl/t/DOMLSParser.t index ba2147691117720deb84b5ee5089caecbac6c153..9b3433b890ca3d00f5d99cbc7179cbd3445a33d5 100644 --- a/swig/perl/t/DOMBuilder.t +++ b/swig/perl/t/DOMLSParser.t @@ -5,12 +5,12 @@ ######################### Begin module loading # use blib; -use Test::More tests => 12; +use Test::More tests => 16; BEGIN{use_ok('XML::Xerces::DOM')}; use lib 't'; -use TestUtils qw($PERSONAL_FILE_NAME); +use TestUtils qw($PERSONAL_FILE_NAME $PERSONAL_DTD_NAME $PERSONAL_SCHEMA_NAME); use vars qw($error); use strict; @@ -70,3 +70,34 @@ isa_ok($doc,'XML::Xerces::DOMDocument'); @persons = $doc->getElementsByTagName('person'); is(scalar @persons, 6,'getting <person>s'); +my $grammar = $DOM->loadGrammar($PERSONAL_DTD_NAME, + $XML::Xerces::Grammar::DTDGrammarType, + my $to_cache = 1); +isa_ok($grammar, "XML::Xerces::DTDGrammar", + 'loadGrammar(path)'); + +eval{ + my $sax_is = XML::Xerces::LocalFileInputSource->new($PERSONAL_DTD_NAME); + $dom_is = XML::Xerces::Wrapper4InputSource->new($sax_is); +}; +$grammar = $DOM->loadGrammar($dom_is, + $XML::Xerces::Grammar::DTDGrammarType, + $to_cache = 1); +isa_ok($grammar, "XML::Xerces::DTDGrammar", + 'loadGrammar(is)'); + +$grammar = $DOM->loadGrammar($PERSONAL_SCHEMA_NAME, + $XML::Xerces::Grammar::SchemaGrammarType, + my $to_cache = 1); +isa_ok($grammar, "XML::Xerces::SchemaGrammar", + 'loadGrammar(path)'); + +eval{ + my $sax_is = XML::Xerces::LocalFileInputSource->new($PERSONAL_SCHEMA_NAME); + $dom_is = XML::Xerces::Wrapper4InputSource->new($sax_is); +}; +$grammar = $DOM->loadGrammar($dom_is, + $XML::Xerces::Grammar::SchemaGrammarType, + $to_cache = 1); +isa_ok($grammar, "XML::Xerces::SchemaGrammar", + 'loadGrammar(is)'); diff --git a/swig/perl/t/DOMParser.t b/swig/perl/t/DOMParser.t index 78bc07350f79d35fb508098f3161f9d39e191d01..b3c3b49fc98239c301e6f25e8869af2ef73de69c 100644 --- a/swig/perl/t/DOMParser.t +++ b/swig/perl/t/DOMParser.t @@ -4,8 +4,8 @@ ######################### Begin module loading -# use blib; -use Test::More tests => 11; +use blib; +use Test::More tests => 13; BEGIN { use_ok("XML::Xerces::DOM") }; use lib 't'; @@ -38,7 +38,23 @@ $DOM->setValidationScheme ($XML::Xerces::AbstractDOMParser::Val_Always); eval{$DOM->parse(XML::Xerces::MemBufInputSource->new($document, 'foo'))}; ok($@,'no dtd'); -$DOM = XML::Xerces::XercesDOMParser->new(); +# this is stupid!! We should be able to reset the parser +# after a fatal error - FIXME +TODO: { + local $TODO = "cannot reuse parser after fatal error"; + $DOM = XML::Xerces::XercesDOMParser->new(); + fail("reset parser"); +} + +# ensure we can unset the error handler using undef +$DOM->setErrorHandler(undef); +$DOM->setValidationScheme ($XML::Xerces::AbstractDOMParser::Val_Always); +eval{$DOM->parse(XML::Xerces::MemBufInputSource->new($document))}; +ok((not $@),'unsetting error handler') + or XML::Xerces::error($@); + +# no validation allows skipping the DTD +$DOM->setValidationScheme ($XML::Xerces::AbstractDOMParser::Val_Never); $DOM->setErrorHandler(XML::Xerces::PerlErrorHandler->new()); eval{$DOM->parse(XML::Xerces::MemBufInputSource->new($document, 'foo'))}; @@ -123,8 +139,10 @@ eval { while ($DOM->parseNext($token)) { } }; -ok($::error,'fatal error in progressive parse') - or diag("Here's the error: $@"); +ok($::error, + 'fatal error in progressive parse') + or XML::Xerces::error($@); + my $doc = $DOM->getDocument(); ok($doc,'doc'); my $root = $doc->getDocumentElement(); diff --git a/swig/perl/t/DOMStringList.t b/swig/perl/t/DOMStringList.t index cc0e221d4bcf8392b02d0767572152e4ed3652cb..ce555c0cb42dc147c4ed21c5121cbd5d23ce54ec 100644 --- a/swig/perl/t/DOMStringList.t +++ b/swig/perl/t/DOMStringList.t @@ -5,7 +5,7 @@ ######################### Begin module loading # use blib; -use Test::More tests => 20; +use Test::More tests => 52; BEGIN{use_ok('XML::Xerces::DOM')}; @@ -18,23 +18,54 @@ my $DOM = $impl->createLSParser($XML::Xerces::DOMImplementationLS::MODE_SYNCHRON my $conf = $DOM->getDomConfig(); isa_ok($conf, 'XML::Xerces::DOMConfiguration'); -my @param_names = ($XML::Xerces::XMLUni::fgDOMErrorHandler, - $XML::Xerces::XMLUni::fgDOMSchemaType, - $XML::Xerces::XMLUni::fgDOMSchemaLocation, - $XML::Xerces::XMLUni::fgDOMCanonicalForm, - $XML::Xerces::XMLUni::fgDOMCDATASections, - $XML::Xerces::XMLUni::fgDOMComments, - $XML::Xerces::XMLUni::fgDOMDatatypeNormalization, - $XML::Xerces::XMLUni::fgDOMWRTDiscardDefaultContent, - $XML::Xerces::XMLUni::fgDOMEntities, - $XML::Xerces::XMLUni::fgDOMInfoset, - $XML::Xerces::XMLUni::fgDOMNamespaces, - $XML::Xerces::XMLUni::fgDOMNamespaceDeclarations, - $XML::Xerces::XMLUni::fgDOMNormalizeCharacters, - $XML::Xerces::XMLUni::fgDOMSplitCDATASections, - $XML::Xerces::XMLUni::fgDOMValidate, - $XML::Xerces::XMLUni::fgDOMValidateIfSchema, - $XML::Xerces::XMLUni::fgDOMElementContentWhitespace); +my @ls_param_names = ( + $XML::Xerces::XMLUni::fgDOMResourceResolver, + $XML::Xerces::XMLUni::fgDOMErrorHandler, + $XML::Xerces::XMLUni::fgXercesEntityResolver, + $XML::Xerces::XMLUni::fgXercesSchemaExternalSchemaLocation, + $XML::Xerces::XMLUni::fgXercesSchemaExternalNoNameSpaceSchemaLocation, + $XML::Xerces::XMLUni::fgXercesSecurityManager, + $XML::Xerces::XMLUni::fgXercesScannerName, + $XML::Xerces::XMLUni::fgXercesParserUseDocumentFromImplementation, + $XML::Xerces::XMLUni::fgDOMCharsetOverridesXMLEncoding, + $XML::Xerces::XMLUni::fgDOMDisallowDoctype, + $XML::Xerces::XMLUni::fgDOMIgnoreUnknownCharacterDenormalization, + $XML::Xerces::XMLUni::fgDOMNamespaces, + $XML::Xerces::XMLUni::fgDOMSupportedMediatypesOnly, + $XML::Xerces::XMLUni::fgDOMValidate, + $XML::Xerces::XMLUni::fgDOMValidateIfSchema, + $XML::Xerces::XMLUni::fgDOMWellFormed, + $XML::Xerces::XMLUni::fgDOMCanonicalForm, + $XML::Xerces::XMLUni::fgDOMCDATASections, + $XML::Xerces::XMLUni::fgDOMCheckCharacterNormalization, + $XML::Xerces::XMLUni::fgDOMComments, + $XML::Xerces::XMLUni::fgDOMDatatypeNormalization, + $XML::Xerces::XMLUni::fgDOMElementContentWhitespace, + $XML::Xerces::XMLUni::fgDOMEntities, + $XML::Xerces::XMLUni::fgDOMNamespaceDeclarations, + $XML::Xerces::XMLUni::fgDOMNormalizeCharacters, + $XML::Xerces::XMLUni::fgDOMSchemaLocation, + $XML::Xerces::XMLUni::fgDOMSchemaType, + $XML::Xerces::XMLUni::fgDOMSplitCDATASections, + $XML::Xerces::XMLUni::fgDOMInfoset, + $XML::Xerces::XMLUni::fgXercesSchema, + $XML::Xerces::XMLUni::fgXercesSchemaFullChecking, + $XML::Xerces::XMLUni::fgXercesUserAdoptsDOMDocument, + $XML::Xerces::XMLUni::fgXercesLoadExternalDTD, + $XML::Xerces::XMLUni::fgXercesContinueAfterFatalError, + $XML::Xerces::XMLUni::fgXercesValidationErrorAsFatal, + $XML::Xerces::XMLUni::fgXercesCacheGrammarFromParse, + $XML::Xerces::XMLUni::fgXercesUseCachedGrammarInParse, + $XML::Xerces::XMLUni::fgXercesCalculateSrcOfs, + $XML::Xerces::XMLUni::fgXercesStandardUriConformant, + $XML::Xerces::XMLUni::fgXercesDOMHasPSVIInfo, + $XML::Xerces::XMLUni::fgXercesGenerateSyntheticAnnotations, + $XML::Xerces::XMLUni::fgXercesValidateAnnotations, + $XML::Xerces::XMLUni::fgXercesIdentityConstraintChecking, + $XML::Xerces::XMLUni::fgXercesIgnoreCachedDTD, + $XML::Xerces::XMLUni::fgXercesIgnoreAnnotations, + $XML::Xerces::XMLUni::fgXercesDisableDefaultEntityResolution, + $XML::Xerces::XMLUni::fgXercesSkipDTDValidation); my @accepted_param_names = $conf->getParameterNames(); ok(scalar @accepted_param_names, "StringList to_list()"); @@ -46,8 +77,8 @@ is($accepted_params_list->getLength(), scalar @accepted_param_names, 'StringList length equal overload list length') or diag("Found items: " . join(':', @accepted_param_names)); -my %param_names = map {$_=>1} @param_names; -foreach my $param_name (@param_names) { +my %param_names = map {$_=>1} @ls_param_names; +foreach my $param_name (@ls_param_names) { ok($accepted_params_list->contains($param_name), "can set $param_name"); } diff --git a/swig/perl/t/DOMWriter.t b/swig/perl/t/DOMWriter.t deleted file mode 100644 index 7f762501265843a74633c7dc92ba84f1a087817a..0000000000000000000000000000000000000000 --- a/swig/perl/t/DOMWriter.t +++ /dev/null @@ -1,73 +0,0 @@ -# Before `make install' is performed this script should be runnable -# with `make test'. After `make install' it should work as `perl -# DOMWriter.t' - -######################### Begin module loading - -# use blib; -use Test::More tests => 6; -BEGIN { use_ok("XML::Xerces::DOM") }; - -use strict; - -######################### Begin Test - -# Create a couple of identical test documents -my $document = q[<?xml version="1.0" encoding="UTF-8" standalone="no" ?><contributors> - <person Role="manager"> - <name>Mike Pogue</name> - <email>mpogue@us.ibm.com</email> - </person> - <person Role="developer"> - <name>Tom Watson</name> - <email>rtwatson@us.ibm.com</email> - </person> - <person Role="tech writer"> - <name>Susan Hardenbrook</name> - <email>susanhar@us.ibm.com</email> - </person> -</contributors>]; - -my $dom = XML::Xerces::XercesDOMParser->new(); -my $handler = XML::Xerces::PerlErrorHandler->new(); -$dom->setErrorHandler($handler); -eval{$dom->parse(XML::Xerces::MemBufInputSource->new($document))}; -XML::Xerces::error($@) if $@; - -my $doc = $dom->getDocument(); -my $impl = XML::Xerces::DOMImplementationRegistry::getDOMImplementation('LS'); -my $writer = $impl->createLSSerializer(); - -my $output = $writer->writeToString($doc); - -# change the encoding string -$output =~ s/UTF-16/UTF-8/; - -ok($output, "output written"); -is($output, $document, "got expected document") - or diag("Found: $output"); - -my $file = 'foo.xml'; -my $rc = eval {$writer->writeToURI($doc, $file)}; -XML::Xerces::error($@) if $@; - -ok($rc, - 'writeToURI'); - -SKIP: { - skip "Couldn't open $file for reading", 2, unless open(TEST, $file); - -# slurp the whole file in - local $/; - $output = <TEST>; - - # change the encoding string - $output =~ s/UTF-16/UTF-8/; - - ok($output, "output written"); - is($output, $document, "got expected document") - or diag("Found: $output"); - - unlink($file); -} - diff --git a/swig/perl/t/Grammar.t b/swig/perl/t/Grammar.t index 37446441a118317cf68f4ff7c36c2a94f0734f88..3d1c00ebfd818107d439af508c953c98a95c8791 100644 --- a/swig/perl/t/Grammar.t +++ b/swig/perl/t/Grammar.t @@ -2,27 +2,64 @@ # with `make test'. After `make install' it should work as `perl # Grammar.t' -######################### We start with some black magic to print on failure. +######################### Begin module loading -END {fail() unless $loaded;} - -use Carp; # use blib; -use XML::Xerces; -use Test::More tests => 2; +use Test::More tests => 13; +BEGIN { use_ok(XML::Xerces::DOM) }; use lib 't'; -use TestUtils qw($DOM $PERSONAL_FILE_NAME); -use vars qw($loaded); -use strict; +use TestUtils qw($DOM $PERSONAL_FILE_NAME $PERSONAL_SCHEMA_FILE_NAME $SAMPLE_DIR); -$loaded = 1; -pass("module loaded"); +use strict; -######################### End of black magic. +######################### Begin Test +$DOM->setValidationScheme($XML::Xerces::AbstractDOMParser::Val_Auto); $DOM->parse($PERSONAL_FILE_NAME); # test that we can fetch the grammar -my $grammar = $DOM->getValidator->getGrammar->getGrammarType(); -ok($grammar == $XML::Xerces::Grammar::DTDGrammarType); +my $grammar = $DOM->getValidator->getGrammar(); +isa_ok($grammar, "XML::Xerces::DTDGrammar", + 'DTD grammar'); +is($grammar->getGrammarType, $XML::Xerces::Grammar::DTDGrammarType, + 'getGrammarType - DTD'); + +ok($grammar->getValidated(), + 'grammar validated'); + +my $desc = $grammar->getGrammarDescription(); +isa_ok($desc, "XML::Xerces::XMLGrammarDescription", + 'grammar description'); +isa_ok($desc, "XML::Xerces::XMLDTDDescription", + 'grammar description'); + +$DOM->setDoNamespaces(1); +$DOM->setDoSchema(1); +$DOM->parse($PERSONAL_SCHEMA_FILE_NAME); + +$grammar = $DOM->getValidator->getGrammar(); +isa_ok($grammar, "XML::Xerces::SchemaGrammar", + 'schema grammar'); +is($grammar->getGrammarType, $XML::Xerces::Grammar::SchemaGrammarType, + 'getGrammarType - Schema'); +ok($grammar->getValidated(), + 'grammar validated'); + +my $impl = XML::Xerces::DOMImplementationRegistry::getDOMImplementation('LS'); +my $DOM = $impl->createLSParser($XML::Xerces::DOMImplementationLS::MODE_SYNCHRONOUS,''); +$grammar = $DOM->loadGrammar("$SAMPLE_DIR/SecondSchema.xsd", + $XML::Xerces::Grammar::SchemaGrammarType, + my $to_cache = 0); + +is($grammar->getTargetNamespace, 'http://www.secondSchema', + 'target namespace'); +ok((not $grammar->getValidated()), + 'grammar loaded, not validated'); + +$desc = $grammar->getGrammarDescription(); +isa_ok($desc, "XML::Xerces::XMLGrammarDescription", + 'getGrammarDescription'); +isa_ok($desc, "XML::Xerces::XMLSchemaDescription", + 'getGrammarDescription'); + diff --git a/swig/perl/t/SAX2Count.t b/swig/perl/t/SAX2Count.t index b5f448ec1b81e8f1e12294d5df1aa3be904606c5..814c333bee8392d8e567f77ee965b30fd3c86abc 100644 --- a/swig/perl/t/SAX2Count.t +++ b/swig/perl/t/SAX2Count.t @@ -1,35 +1,32 @@ # Before `make install' is performed this script should be runnable # with `make test'. After `make install' it should work as `perl -# SAX2Count.t +# SAX2Count.t` -######################### We start with some black magic to print on failure. +######################### Begin module loading -END {fail() unless $loaded;} - -use Carp; # use blib; -use XML::Xerces; use Test::More tests => 5; -use Config; +BEGIN { use_ok("XML::Xerces::SAX") }; use lib 't'; use TestUtils qw($PERSONAL_FILE_NAME $SAMPLE_DIR); -use vars qw($loaded $file); use strict; +use Config; -$loaded = 1; -pass("module loaded"); - -######################### End of black magic. +######################### Begin Test my $perl = $Config{startperl}; $perl =~ s/^\#!//; my @output = split(/\n/,`$perl -Mblib $SAMPLE_DIR/SAX2Count.pl $PERSONAL_FILE_NAME 2>/dev/null`); $output[1] =~ /\s(\d+)/; -ok($1 == 37); +is($1, 37, + 'elems'); $output[2] =~ /\b(\d+)\b/; -ok($1 == 12); +is($1, 12, + 'attrs'); $output[3] =~ /\b(\d+)\b/; -ok($1 == 134); +is($1, 134, + 'whitespace'); $output[4] =~ /\b(\d+)\b/; -ok($1 == 134); +is($1, 134, + 'characters'); diff --git a/swig/perl/t/SAX2XMLReader.t b/swig/perl/t/SAX2XMLReader.t index 76a24d0545631955ab11b1b38be2b693bf611a1e..21ab4e203c1ab25a99844a76b38dca1973258757 100644 --- a/swig/perl/t/SAX2XMLReader.t +++ b/swig/perl/t/SAX2XMLReader.t @@ -6,9 +6,8 @@ # use blib; use Test::More tests => 26; -BEGIN { use_ok("XML::Xerces") }; +BEGIN { use_ok("XML::Xerces::SAX") }; -use Carp; use lib 't'; use TestUtils qw($PERSONAL_FILE_NAME $SCHEMA_FILE_NAME $PERSONAL_SCHEMA_INVALID_FILE_NAME); use vars qw($error); diff --git a/swig/perl/t/SAXCount.t b/swig/perl/t/SAXCount.t index 7af97a6beb7e98ed93443468483b4c24b899ceaa..886c36740156e9cda1cf89cb6470d1c8898874f0 100644 --- a/swig/perl/t/SAXCount.t +++ b/swig/perl/t/SAXCount.t @@ -1,35 +1,32 @@ # Before `make install' is performed this script should be runnable # with `make test'. After `make install' it should work as `perl -# SAXCount.t +# SAXCount.t` -######################### We start with some black magic to print on failure. +######################### Begin module loading -END {fail() unless $loaded;} - -use Carp; # use blib; -use XML::Xerces; use Test::More tests => 5; -use Config; +BEGIN { use_ok("XML::Xerces::SAX") }; use lib 't'; use TestUtils qw($PERSONAL_FILE_NAME $SAMPLE_DIR); -use vars qw($loaded $file); use strict; +use Config; -$loaded = 1; -pass("module loaded"); - -######################### End of black magic. +######################### Begin Test my $perl = $Config{startperl}; $perl =~ s/^\#!//; my @output = split(/\n/,`$perl -Mblib $SAMPLE_DIR/SAXCount.pl $PERSONAL_FILE_NAME 2>/dev/null`); $output[1] =~ /\s(\d+)/; -ok($1 == 37); +is($1, 37, + 'elems'); $output[2] =~ /\b(\d+)\b/; -ok($1 == 12); +is($1, 12, + 'attrs'); $output[3] =~ /\b(\d+)\b/; -ok($1 == 134); +is($1, 134, + 'whitespace'); $output[4] =~ /\b(\d+)\b/; -ok($1 == 134); +is($1, 134, + 'characters'); diff --git a/swig/perl/t/SAXException.t b/swig/perl/t/SAXException.t index ce02de3d9ec61b6ad4b70f68c34824cfb28dcee2..4208f08d4472a23521c0d52280db0c7f8780ce04 100644 --- a/swig/perl/t/SAXException.t +++ b/swig/perl/t/SAXException.t @@ -6,14 +6,12 @@ # use blib; use Test::More tests => 17; -BEGIN { use_ok("XML::Xerces") }; +BEGIN { use_ok("XML::Xerces::SAX") }; use lib 't'; -# use TestUtils qw($PERSONAL_FILE_NAME); +use TestUtils qw($PERSONAL_FILE_NAME); use strict; -my $PERSONAL_FILE_NAME = 'samples/personal.xml'; - ######################### Begin Test # test that we get an SAXNotRecognizedException @@ -30,18 +28,26 @@ SKIP: { skip "setFeature didn't raise an exception", 2, if not $error; - isa_ok($error,'XML::Xerces::SAXNotRecognizedException'); + my $skip = 0; + isa_ok($error,'XML::Xerces::SAXNotRecognizedException') + or $skip = 1; + + skip "bad exception: $error", 1, if $skip; ok($error->getMessage(),"message"); } -SKSIP: { +SKIP: { eval {$parser->getFeature($feature)}; $error = $@; ok($error,"getFeature: $feature"); skip "setFeature didn't raise an exception", 2, if not $error; - isa_ok($error,'XML::Xerces::SAXNotRecognizedException'); + my $skip = 0; + isa_ok($error,'XML::Xerces::SAXNotRecognizedException') + or $skip = 1; + + skip "bad exception: $error", 1, if $skip; ok($error->getMessage(),"message"); } @@ -52,7 +58,11 @@ SKIP: { skip "setFeature didn't raise an exception", 2, if not $@; - isa_ok($error,'XML::Xerces::SAXNotRecognizedException'); + my $skip = 0; + isa_ok($error,'XML::Xerces::SAXNotRecognizedException') + or $skip = 1; + + skip "bad exception: $error", 1, if $skip; ok($error->getMessage(),"message"); } @@ -63,7 +73,11 @@ SKIP: { skip "setFeature didn't raise an exception", 2, if not $error; - isa_ok($error,'XML::Xerces::SAXNotRecognizedException'); + my $skip = 0; + isa_ok($error,'XML::Xerces::SAXNotRecognizedException') + or $skip = 1; + + skip "bad exception: $error", 1, if $skip; ok($error->getMessage(),"message"); } @@ -98,6 +112,10 @@ SKIP: { skip "modifying a feature during a parse didn't raise a not supported exception", 2, if not $error; - isa_ok($error,'XML::Xerces::SAXNotSupportedException'); + my $skip = 0; + isa_ok($error,'XML::Xerces::SAXNotSupportedException') + or $skip = 1; + + skip "bad exception: $error", 1, if $skip; ok($error->getMessage(),"message"); } diff --git a/swig/perl/t/SAXParser.t b/swig/perl/t/SAXParser.t index 16e5be545975bf17cf7e9a27c03718a1302b6a89..d76ab4d58fd839ad1838c65b53a3dfa192944770 100644 --- a/swig/perl/t/SAXParser.t +++ b/swig/perl/t/SAXParser.t @@ -5,8 +5,8 @@ ######################### Begin module loading # use blib; -use Test::More tests => 12; -BEGIN { use_ok("XML::Xerces") }; +use Test::More tests => 13; +BEGIN { use_ok("XML::Xerces::SAX") }; use lib 't'; use TestUtils qw($PERSONAL_FILE_NAME); @@ -85,7 +85,8 @@ while ($SAX->parseNext($token)) { # do nothing } pass('successful progressive parse'); -ok($DOCUMENT_HANDLER->{elements} == 37, 'element count after progressive parse'); +ok($DOCUMENT_HANDLER->{elements} == 37, + 'element count after progressive parse'); # reset the counts $DOCUMENT_HANDLER->reset_document(); @@ -175,8 +176,13 @@ ok($::error,'fatal error in progressive parse') # reset the state for a new parse $::error = ''; $SAX->parseReset($token); -$SAX->setErrorHandler(XML::Xerces::PerlErrorHandler->new()); +$SAX->setErrorHandler(undef); +eval {$SAX->parse(XML::Xerces::MemBufInputSource->new($document))}; +ok((not $@),'unset error handler') + or XML::Xerces::error($@); + +$SAX->setErrorHandler(XML::Xerces::PerlErrorHandler->new()); eval {$SAX->parse($PERSONAL_FILE_NAME)}; ok((not $@),'successful parse after fatal error'); diff --git a/swig/perl/t/TestUtils.pm b/swig/perl/t/TestUtils.pm index fe4e74919839c366a72444ad48d8d9b26457881a..3ea6df40b5f3397a05c83e6552ec8dcbaf42b954 100644 --- a/swig/perl/t/TestUtils.pm +++ b/swig/perl/t/TestUtils.pm @@ -14,12 +14,19 @@ use vars qw($VERSION $PERSONAL_SCHEMA_FILE_NAME $SCHEMA_FILE_NAME $SAMPLE_DIR + $PERSONAL_INVALID_FILE_NAME + $PERSONAL_NOT_WELL_FORMED_FILE_NAME $PERSONAL_FILE_NAME $PERSONAL_DTD_NAME + $PERSONAL_SCHEMA_NAME $PERSONAL_NO_DOCTYPE $PERSONAL_NO_DOCTYPE_FILE_NAME $PERSONAL_NO_XMLDECL_FILE_NAME $PERSONAL_NO_XMLDECL + $TYPEINFO_NAME + $TYPEINFO_NO_DTD_NAME + $TYPEINFO_COMBINED_NAME + $TYPEINFO_JUST_DTD_NAME ); use Carp; use Cwd; @@ -32,12 +39,19 @@ require Exporter; $DOM $CATALOG $PERSONAL_FILE_NAME + $PERSONAL_INVALID_FILE_NAME + $PERSONAL_NOT_WELL_FORMED_FILE_NAME $PUBLIC_RESOLVER_FILE_NAME $SYSTEM_RESOLVER_FILE_NAME $SCHEMA_FILE_NAME $PERSONAL_SCHEMA_FILE_NAME $PERSONAL_SCHEMA_INVALID_FILE_NAME $PERSONAL_DTD_NAME + $PERSONAL_SCHEMA_NAME + $TYPEINFO_NAME + $TYPEINFO_NO_DTD_NAME + $TYPEINFO_COMBINED_NAME + $TYPEINFO_JUST_DTD_NAME $PERSONAL_NO_DOCTYPE_FILE_NAME $PERSONAL_NO_DOCTYPE $PERSONAL_NO_XMLDECL_FILE_NAME @@ -56,20 +70,30 @@ BEGIN { # XML::Xerces::XMLPlatformUtils::Initialize(); - $DOM = XML::Xerces::XercesDOMParser->new(); +$DOM = XML::Xerces::XercesDOMParser->new(); - my $ERROR_HANDLER = XML::Xerces::PerlErrorHandler->new(); - $DOM->setErrorHandler($ERROR_HANDLER); +my $ERROR_HANDLER = XML::Xerces::PerlErrorHandler->new(); +$DOM->setErrorHandler($ERROR_HANDLER); + +my $cwd = cwd(); +$cwd =~ s|/t/?$||; +$SAMPLE_DIR = "$cwd/samples"; +$PERSONAL_FILE_NAME = "$SAMPLE_DIR/personal.xml"; +$PERSONAL_NO_DOCTYPE_FILE_NAME = "$SAMPLE_DIR/personal-no-doctype.xml"; +$PERSONAL_NO_XMLDECL_FILE_NAME = "$SAMPLE_DIR/personal-no-xmldecl.xml"; +$PERSONAL_FILE_NAME = "$SAMPLE_DIR/personal.xml"; +$PERSONAL_INVALID_FILE_NAME = "$SAMPLE_DIR/personal-invalid.xml"; +$PERSONAL_NOT_WELL_FORMED_FILE_NAME = "$SAMPLE_DIR/personal-not-well-formed.xml"; - my $cwd = cwd(); - $cwd =~ s|/t/?$||; - $SAMPLE_DIR = "$cwd/samples"; - $PERSONAL_FILE_NAME = "$SAMPLE_DIR/personal.xml"; - $PERSONAL_NO_DOCTYPE_FILE_NAME = "$SAMPLE_DIR/personal-no-doctype.xml"; - $PERSONAL_NO_XMLDECL_FILE_NAME = "$SAMPLE_DIR/personal-no-xmldecl.xml"; +$TYPEINFO_NAME = "$SAMPLE_DIR/TypeInfo.xml"; +$TYPEINFO_NO_DTD_NAME = "$SAMPLE_DIR/TypeInfoNoDTD.xml"; +$TYPEINFO_COMBINED_NAME = "$SAMPLE_DIR/TypeInfoCombined.xml"; +$TYPEINFO_JUST_DTD_NAME = "$SAMPLE_DIR/TypeInfoJustDTD.xml"; $PERSONAL_DTD_NAME = $PERSONAL_FILE_NAME; $PERSONAL_DTD_NAME =~ s/\.xml/\.dtd/; + $PERSONAL_SCHEMA_NAME = $PERSONAL_FILE_NAME; + $PERSONAL_SCHEMA_NAME =~ s/\.xml/\.xsd/; $PERSONAL_SCHEMA_FILE_NAME = $PERSONAL_FILE_NAME; $PERSONAL_SCHEMA_FILE_NAME =~ s/\.xml/-schema.xml/; $PERSONAL_SCHEMA_INVALID_FILE_NAME = $PERSONAL_SCHEMA_FILE_NAME; diff --git a/swig/perl/t/URLInputSource.t b/swig/perl/t/URLInputSource.t index 8de5ac55d2204563b9082893576a419e5c14d9c1..242d7bb406b64fc2a4a8ea677ce6655ef61be3b3 100644 --- a/swig/perl/t/URLInputSource.t +++ b/swig/perl/t/URLInputSource.t @@ -2,22 +2,16 @@ # with `make test'. After `make install' it should work as `perl # URLInputSource.t' -######################### We start with some black magic to print on failure. +######################### Begin module loading -END {fail() unless $loaded;} - -use Carp; # use blib; -use XML::Xerces; -use Test::More tests => 8; +use Test::More tests => 9; +BEGIN { use_ok("XML::Xerces") }; +BEGIN { use_ok("XML::Xerces::IO") }; -use vars qw($loaded $error); use strict; -$loaded = 1; -pass("module loaded"); - -######################### End of black magic. +######################### Begin Test # Insert your test code below (better if it prints "ok 13" # (correspondingly "not ok 13") depending on the success of chunk 13 diff --git a/swig/perl/t/XMLUni.t b/swig/perl/t/XMLUni.t index deb7fd5bf2f981c2b74b479321dc9af8fbb5b222..f573a7303d12c741d4ecaea5cd18b4a337629a55 100644 --- a/swig/perl/t/XMLUni.t +++ b/swig/perl/t/XMLUni.t @@ -4,15 +4,26 @@ ######################################### # use blib; -use Test::More tests => 5; +use Test::More tests => 8; BEGIN {use_ok("XML::Xerces::DOM")}; +BEGIN {use_ok("XML::Xerces::SAX")}; use strict; # once the unicode constants were not being properly exported # these tests guard against that happening again -is($XML::Xerces::XMLUni::fgPCDATAString, '#PCDATA', 'XMLUni constants exported'); -is($XML::Xerces::XMLUni::fgPubIDString, 'PUBLIC', 'XMLUni constants exported'); +is($XML::Xerces::XMLUni::fgPCDATAString, '#PCDATA', + 'XMLUni constants exported'); +is($XML::Xerces::XMLUni::fgPubIDString, 'PUBLIC', + 'XMLUni constants exported'); + +TODO: { + local $TODO = 'SWIG is exporting all class variables into top-level namespace'; + ok((not defined $XML::Xerces::XMLUni_fgPCDATAString), + 'XMLUni constants not in XML::Xerces namespace'); + ok((not defined $XML::Xerces::XMLUni_fgPubIDString), + 'XMLUni constants not in XML::Xerces namespace'); +} eval { my $parser = XML::Xerces::XMLReaderFactory::createXMLReader(); diff --git a/swig/perl/t/actualCast.t b/swig/perl/t/actualCast.t index bd326327500fac4b3a38bad00bcfbfe40d46f12f..c14fe521c5ef7b30bb1ce573d26463e9418e6513 100644 --- a/swig/perl/t/actualCast.t +++ b/swig/perl/t/actualCast.t @@ -2,28 +2,17 @@ # with `make test'. After `make install' it should work as `perl # actualCast.t' -######################### We start with some black magic to print on failure. +######################### Begin module loading -END {fail() unless $loaded;} - -use Carp; # use blib; -use XML::Xerces; use Test::More tests => 9; +BEGIN { use_ok("XML::Xerces::SAX") }; use lib 't'; use TestUtils qw($DOM $PERSONAL $PERSONAL_FILE_NAME $PERSONAL_SCHEMA_FILE_NAME); -use vars qw($loaded); use strict; -$loaded = 1; -pass("module loaded"); - -######################### End of black magic. - -# Insert your test code below (better if it prints "ok 13" -# (correspondingly "not ok 13") depending on the success of chunk 13 -# of the test code): +######################### Begin Test $DOM->parse($PERSONAL_FILE_NAME);