You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by ja...@apache.org on 2005/12/03 16:51:07 UTC
svn commit: r351966 - /xerces/xerces-p/trunk/t/
Author: jasons
Date: Sat Dec 3 07:50:10 2005
New Revision: 351966
URL: http://svn.apache.org/viewcvs?rev=351966&view=rev
Log:
updated tests
Modified:
xerces/xerces-p/trunk/t/AttributeList.t
xerces/xerces-p/trunk/t/Attributes.t
xerces/xerces-p/trunk/t/DOMBuilder.t
xerces/xerces-p/trunk/t/DOMDocument.t
xerces/xerces-p/trunk/t/DOMElement.t
xerces/xerces-p/trunk/t/DOMException.t
xerces/xerces-p/trunk/t/DOMNodeIterator.t
xerces/xerces-p/trunk/t/DOMPrint.t
xerces/xerces-p/trunk/t/DOMTreeWalker.t
xerces/xerces-p/trunk/t/EntityResolver.t
xerces/xerces-p/trunk/t/MemBufInputSource.t
xerces/xerces-p/trunk/t/PerlErrorHandler.t
xerces/xerces-p/trunk/t/SAXException.t
xerces/xerces-p/trunk/t/TestUtils.pm
xerces/xerces-p/trunk/t/URLInputSource.t
xerces/xerces-p/trunk/t/XMLException.t
xerces/xerces-p/trunk/t/XMLUni.t
xerces/xerces-p/trunk/t/XercesDOMParser.t
xerces/xerces-p/trunk/t/actualCast.t
Modified: xerces/xerces-p/trunk/t/AttributeList.t
URL: http://svn.apache.org/viewcvs/xerces/xerces-p/trunk/t/AttributeList.t?rev=351966&r1=351965&r2=351966&view=diff
==============================================================================
--- xerces/xerces-p/trunk/t/AttributeList.t (original)
+++ xerces/xerces-p/trunk/t/AttributeList.t Sat Dec 3 07:50:10 2005
@@ -9,7 +9,7 @@
use Carp;
use blib;
use XML::Xerces;
-use Test::More tests => 8;
+use Test::More tests => 11;
use Config;
use lib 't';
@@ -22,6 +22,12 @@
######################### End of black magic.
+ # NOTICE: We must now explicitly call XMLPlatformUtils::Initialize()
+ # when the module is loaded. Xerces.pm no longer does this.
+ #
+ #
+XML::Xerces::XMLPlatformUtils::Initialize();
+
package MyDocumentHandler;
use strict;
use vars qw(@ISA);
@@ -64,7 +70,8 @@
eval {$SAX->parse($is)};
XML::Xerces::error($@) if $@;
-ok($DOCUMENT_HANDLER->{test} == 3);
+ok($DOCUMENT_HANDLER->{test} == 3,
+ "getLength");
$DOCUMENT_HANDLER->{test} = '';
# we want to avoid a bunch of warnings about redefining
@@ -80,7 +87,8 @@
};
$DOCUMENT_HANDLER->{test} = '';
$SAX->parse($is);
-ok($DOCUMENT_HANDLER->{test} eq "$ns:$local");
+ok($DOCUMENT_HANDLER->{test} eq "$ns:$local",
+ "getName");
# test getValue
*MyDocumentHandler::start_element = sub {
@@ -91,7 +99,8 @@
};
$DOCUMENT_HANDLER->{test} = '';
$SAX->parse($is);
-ok($DOCUMENT_HANDLER->{test} eq $value);
+ok($DOCUMENT_HANDLER->{test} eq $value,
+ "getValue - string");
# test overloaded getValue
*MyDocumentHandler::start_element = sub {
@@ -104,7 +113,8 @@
$SAX->parse($is);
# print STDERR "<$DOCUMENT_HANDLER->{test}>" , "\n";
# print STDERR "<$value>" , "\n";
-ok($DOCUMENT_HANDLER->{test} eq $value);
+ok($DOCUMENT_HANDLER->{test} eq $value,
+ "getValue - int");
# test to_hash()
*MyDocumentHandler::start_element = sub {
@@ -116,12 +126,15 @@
$DOCUMENT_HANDLER->{test} = '';
$SAX->parse($is);
my $hash_ref = $DOCUMENT_HANDLER->{test};
-ok(ref($hash_ref) eq 'HASH'
- && keys %{$hash_ref} == 3
- && $hash_ref->{"$ns:$local"} eq $value);
+isa_ok($hash_ref, 'HASH',
+ "to_hash()");
+is(keys %{$hash_ref}, 3,
+ "to_hash()");
+is($hash_ref->{"$ns:$local"}, $value,
+ "to_hash()");
-$document = qq[<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<!DOCTYPE bar SYSTEM "foo.dtd" [
+my $document2 = qq[<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!DOCTYPE bar [
<!ELEMENT bar (foo)>
<!ELEMENT foo EMPTY>
<!ATTLIST foo id ID #REQUIRED>
@@ -146,7 +159,8 @@
}
package main;
-my $is2 = XML::Xerces::MemBufInputSource->new($document);
+my $is2 = eval{XML::Xerces::MemBufInputSource->new($document2)};
+XML::Xerces::error($@) if $@;
$SAX->setEntityResolver(MyEntityResolver->new());
# test overloaded getType
@@ -157,8 +171,10 @@
}
};
$DOCUMENT_HANDLER->{test} = '';
+
$SAX->parse($is2);
-ok($DOCUMENT_HANDLER->{test} eq 'ID');
+is($DOCUMENT_HANDLER->{test}, 'ID',
+ "getType - int");
# test getType
*MyDocumentHandler::start_element = sub {
@@ -169,4 +185,33 @@
};
$DOCUMENT_HANDLER->{test} = '';
$SAX->parse($is2);
-ok($DOCUMENT_HANDLER->{test} eq 'ID');
+is($DOCUMENT_HANDLER->{test}, 'ID',
+ "getType");
+
+my $document3 = qq[<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!DOCTYPE bar SYSTEM "foo.dtd" [
+<!ELEMENT bar (foo)>
+<!ELEMENT foo EMPTY>
+<!ATTLIST foo id ID #REQUIRED>
+<!ATTLIST foo role CDATA #REQUIRED>
+]>
+<bar>
+ <foo id='baz' role="manager"/>
+</bar>];
+
+$is2 = eval{XML::Xerces::MemBufInputSource->new($document3)};
+
+TODO : {
+ todo_skip "blank documents segfault the entity resolver", 1;
+
+ $SAX->parse($is2);
+ pass("blank document does not segfault the entity resolver");
+}
+
+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();
+}
Modified: xerces/xerces-p/trunk/t/Attributes.t
URL: http://svn.apache.org/viewcvs/xerces/xerces-p/trunk/t/Attributes.t?rev=351966&r1=351965&r2=351966&view=diff
==============================================================================
--- xerces/xerces-p/trunk/t/Attributes.t (original)
+++ xerces/xerces-p/trunk/t/Attributes.t Sat Dec 3 07:50:10 2005
@@ -12,7 +12,7 @@
use Carp;
use blib;
use XML::Xerces;
-use Test::More tests => 14;
+use Test::More tests => 19;
use Config;
use lib 't';
@@ -70,7 +70,8 @@
my $is = XML::Xerces::MemBufInputSource->new($document);
$CONTENT_HANDLER->{test} = '';
$SAX2->parse($is);
-ok($CONTENT_HANDLER->{test} == 2);
+is($CONTENT_HANDLER->{test}, 2,
+ "getLength");
$CONTENT_HANDLER->{test} = '';
# we want to avoid a bunch of warnings about redefining
@@ -86,7 +87,8 @@
};
$CONTENT_HANDLER->{test} = '';
$SAX2->parse($is);
-ok($CONTENT_HANDLER->{test} eq $url);
+is($CONTENT_HANDLER->{test}, $url,
+ "getURI");
# test getLocalName
*MyContentHandler::start_element = sub {
@@ -97,7 +99,8 @@
};
$CONTENT_HANDLER->{test} = '';
$SAX2->parse($is);
-ok($CONTENT_HANDLER->{test} eq $local);
+is($CONTENT_HANDLER->{test}, $local,
+ "getLocalName");
# test getQName
*MyContentHandler::start_element = sub {
@@ -108,7 +111,8 @@
};
$CONTENT_HANDLER->{test} = '';
$SAX2->parse($is);
-ok($CONTENT_HANDLER->{test} eq "$ns:$local");
+is($CONTENT_HANDLER->{test}, "$ns:$local",
+ "getQName");
# test getIndex
*MyContentHandler::start_element = sub {
@@ -119,7 +123,8 @@
};
$CONTENT_HANDLER->{test} = '';
$SAX2->parse($is);
-ok($CONTENT_HANDLER->{test} == 1);
+is($CONTENT_HANDLER->{test}, 1,
+ "getIndex");
# test getValue
*MyContentHandler::start_element = sub {
@@ -130,7 +135,8 @@
};
$CONTENT_HANDLER->{test} = '';
$SAX2->parse($is);
-ok($CONTENT_HANDLER->{test} eq $value);
+is($CONTENT_HANDLER->{test}, $value,
+ "getValue(url,localname)");
# test overloaded getValue
*MyContentHandler::start_element = sub {
@@ -141,7 +147,8 @@
};
$CONTENT_HANDLER->{test} = '';
$SAX2->parse($is);
-ok($CONTENT_HANDLER->{test} eq $value);
+is($CONTENT_HANDLER->{test}, $value,
+ "getValue(int)");
# test overloaded getValue
*MyContentHandler::start_element = sub {
@@ -152,7 +159,8 @@
};
$CONTENT_HANDLER->{test} = '';
$SAX2->parse($is);
-ok($CONTENT_HANDLER->{test} eq $value);
+is($CONTENT_HANDLER->{test}, $value,
+ "getValue");
# test to_hash()
*MyContentHandler::start_element = sub {
@@ -164,14 +172,16 @@
$CONTENT_HANDLER->{test} = '';
$SAX2->parse($is);
my $hash_ref = $CONTENT_HANDLER->{test};
-ok(ref($hash_ref) eq 'HASH'
- && keys %{$hash_ref} == 2
- && $hash_ref->{"$ns:$local"}{value} eq $value
- && $hash_ref->{"$ns:$local"}{URI} eq $url
- );
+isa_ok($hash_ref, 'HASH');
+is(keys %{$hash_ref}, 2,
+ "found all attrs");
+is($hash_ref->{"$ns:$local"}{value}, $value,
+ "found attr value");
+is($hash_ref->{"$ns:$local"}{URI}, $url,
+ "found attr url");
$document = qq[<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<!DOCTYPE bar SYSTEM "foo.dtd" [
+<!DOCTYPE bar [
<!ELEMENT bar (foo)>
<!ELEMENT foo EMPTY>
<!ATTLIST foo id ID #REQUIRED>
@@ -192,6 +202,7 @@
sub resolve_entity {
my ($self,$pub,$sys) = @_;
+print STDERR "resolving entity, pub: $pub, sys: $sys\n";
return XML::Xerces::MemBufInputSource->new('');
}
@@ -208,7 +219,8 @@
};
$CONTENT_HANDLER->{test} = '';
$SAX2->parse($is2);
-ok($CONTENT_HANDLER->{test} eq 'ID');
+is($CONTENT_HANDLER->{test}, 'ID',
+ "getType(int)");
# test overloaded getType
*MyContentHandler::start_element = sub {
@@ -219,7 +231,8 @@
};
$CONTENT_HANDLER->{test} = '';
$SAX2->parse($is2);
-ok($CONTENT_HANDLER->{test} eq 'ID');
+is($CONTENT_HANDLER->{test}, 'ID',
+ "getType(uri,local)");
# test getType
*MyContentHandler::start_element = sub {
@@ -230,7 +243,8 @@
};
$CONTENT_HANDLER->{test} = '';
$SAX2->parse($is2);
-ok($CONTENT_HANDLER->{test} eq 'ID');
+is($CONTENT_HANDLER->{test}, 'ID',
+ "getType");
# test type field of to_hash()
*MyContentHandler::start_element = sub {
@@ -242,8 +256,9 @@
$CONTENT_HANDLER->{test} = '';
$SAX2->parse($is2);
$hash_ref = $CONTENT_HANDLER->{test};
-ok(ref($hash_ref) eq 'HASH'
- && keys %{$hash_ref} == 2
- && $hash_ref->{id}{type} eq 'ID'
- );
+isa_ok($hash_ref, 'HASH');
+is(keys %{$hash_ref}, 2,
+ "to_hash() found all attrs");
+is($hash_ref->{id}{type}, 'ID',
+ "to_hash() found correct type");
Modified: xerces/xerces-p/trunk/t/DOMBuilder.t
URL: http://svn.apache.org/viewcvs/xerces/xerces-p/trunk/t/DOMBuilder.t?rev=351966&r1=351965&r2=351966&view=diff
==============================================================================
--- xerces/xerces-p/trunk/t/DOMBuilder.t (original)
+++ xerces/xerces-p/trunk/t/DOMBuilder.t Sat Dec 3 07:50:10 2005
@@ -74,6 +74,7 @@
is(scalar @persons, 6,'getting <person>s');
# test parse with an input source
+# my $sax_is;
my $dom_is;
eval{
my $sax_is = XML::Xerces::LocalFileInputSource->new($PERSONAL_FILE_NAME);
@@ -81,6 +82,7 @@
};
ok((not $@),'Creating InputSource wrapper')
or diag(XML::Xerces::error($@));
+# isa_ok($sax_is,'XML::Xerces::LocalFileInputSource');
isa_ok($dom_is,'XML::Xerces::Wrapper4InputSource');
$doc = eval{$DOM->parse($dom_is)}
Modified: xerces/xerces-p/trunk/t/DOMDocument.t
URL: http://svn.apache.org/viewcvs/xerces/xerces-p/trunk/t/DOMDocument.t?rev=351966&r1=351965&r2=351966&view=diff
==============================================================================
--- xerces/xerces-p/trunk/t/DOMDocument.t (original)
+++ xerces/xerces-p/trunk/t/DOMDocument.t Sat Dec 3 07:50:10 2005
@@ -11,10 +11,10 @@
use Carp;
-# use blib;
+use blib;
use utf8;
use XML::Xerces;
-use Test::More tests => 35125;
+use Test::More tests => 11;
use Config;
use lib 't';
@@ -26,10 +26,6 @@
######################### 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):
-
# Create a couple of identical test documents
my $document = q[<?xml version="1.0" encoding="UTF-8"?>
<contributors>
@@ -47,215 +43,97 @@
</person>
</contributors>];
-my $DOM1 = new XML::Xerces::XercesDOMParser;
-my $ERROR_HANDLER = XML::Xerces::PerlErrorHandler->new();
-$DOM1->setErrorHandler($ERROR_HANDLER);
-$DOM1->parse(XML::Xerces::MemBufInputSource->new($document));
-
-my $DOM2 = new XML::Xerces::XercesDOMParser;
-$DOM2->setErrorHandler($ERROR_HANDLER);
-$DOM2->parse(XML::Xerces::MemBufInputSource->new($document, 'foo'));
-
-my $doc1 = $DOM1->getDocument();
-my $doc2 = $DOM2->getDocument();
-
-my $root1 = $doc1->getDocumentElement();
-my @persons1 = $doc1->getElementsByTagName('person');
-my @names1 = $doc1->getElementsByTagName('name');
-my $root2 = $doc2->getDocumentElement();
-my @persons2 = $doc2->getElementsByTagName('person');
-my @names2 = $doc1->getElementsByTagName('name');
+my ($DOM1, $ERROR_HANDLER, $DOM2);
+my ($doc1, $doc2);
+my ($root1, @persons1, $name1, $root2, @persons2, $name2);
+
+sub refresh {
+ $DOM1 = new XML::Xerces::XercesDOMParser;
+ $ERROR_HANDLER = XML::Xerces::PerlErrorHandler->new();
+ $DOM1->setErrorHandler($ERROR_HANDLER);
+ my $is = eval{XML::Xerces::MemBufInputSource->new($document)};
+ XML::Xerces::error($@) if $@;
+ eval{$DOM1->parse($is)};
+ XML::Xerces::error($@) if $@;
+
+ $DOM2 = new XML::Xerces::XercesDOMParser;
+ $DOM2->setErrorHandler($ERROR_HANDLER);
+ eval {$DOM2->parse($is)};
+ XML::Xerces::error($@) if $@;
+
+ $doc1 = $DOM1->getDocument();
+ $doc2 = $DOM2->getDocument();
+
+ $root1 = $doc1->getDocumentElement();
+ @persons1 = $root1->getChildNodes();
+ $name1 = ($persons1[1]->getChildNodes())[1];
+ $root2 = $doc2->getDocumentElement();
+ @persons2 = $root2->getChildNodes();
+ $name2 = ($persons2[1]->getChildNodes())[1];
+}
+
+refresh();
# importing a child from a different document
eval {
- my $copy = $doc1->importNode($persons1[0],0);
+ my $copy = $doc1->importNode($persons1[0], 0);
$root1->appendChild($copy);
};
-ok(!$@ &&
- scalar @persons1 < scalar ($root1->getElementsByTagName('person'))
- );
+ok(!$@ && scalar @persons1 < scalar ($root1->getElementsByTagName('person')),
+ "importing a child from a different document");
+
+refresh();
# check that creating an element with an illegal charater
eval {
my $el = $doc1->createElement('?');
};
-ok($@
- && $@->{code} == $XML::Xerces::DOMException::INVALID_CHARACTER_ERR
- );
+my $error = $@;
+ok($error,'creating document with illegal raises exception');
-# check that an element can't start with a digit
-eval {
- my $el = $doc1->createElement('9');
-};
-ok($@
- && $@->{code} == $XML::Xerces::DOMException::INVALID_CHARACTER_ERR
- );
+my $isa = "XML::Xerces::DOMException";
+isa_ok($error,$isa)
+ or diag($error);
+
+my $expect = "$XML::Xerces::DOMException::INVALID_CHARACTER_ERR";
+ok(UNIVERSAL::isa($error,$isa)
+ && $error->getCode == $expect,
+ "received correct error code")
+ || diag("found code: $error->{code}, expected code: $expect");
-# check that getElementById() doesn't segfault on undef ID
-eval {
- $doc1->getElementById(undef);
-};
-ok($@);
+refresh();
-# check that an element can have a digit if a valid character comes first
-eval {
- $DOM1->parse('t/letter.xml');
-};
-if ($@) {
- if (ref($@)) {
- if ($@->isa('XML::Xerces::XMLException')) {
- die "Couldn't open letter.xml: ", $@->getMessage();
- } elsif ($@->isa('XML::Xerces::DOMException')) {
- die "Couldn't open letter.xml: msg=<$...@->{msg}>, code=$@->{code}";
- }
- }
-}
-
-$doc1 = $DOM1->getDocument();
-my ($digit_node) = $doc1->getElementsByTagName('digit');
-my @digits;
-foreach my $range_node ($digit_node->getElementsByTagName('range')) {
- my $low = hex($range_node->getAttribute('low'));
- my $high = hex($range_node->getAttribute('high'));
- push(@digits,$low..$high);
-}
-foreach my $single_node ($digit_node->getElementsByTagName('single')) {
- my $value = hex($single_node->getAttribute('value'));
- push(@digits,$value);
-}
-@digits = map {chr($_)} @digits;
-foreach my $char (@digits) {
- eval {
- my $el = $doc1->createElement("_$char");
- };
- if ($@) {
- if (ref $@) {
- print STDERR "Error code: $@->{code}\n";
- } else {
- print STDERR $@;
- }
- }
- ok(!$@) || printf("char: <0x%.4X>\n",ord($char));
-}
-
-my ($extender_node) = $doc1->getElementsByTagName('extender');
-my @extenders;
-foreach my $range_node ($extender_node->getElementsByTagName('range')) {
- my $low = hex($range_node->getAttribute('low'));
- my $high = hex($range_node->getAttribute('high'));
- push(@extenders,$low..$high);
-}
-foreach my $single_node ($extender_node->getElementsByTagName('single')) {
- my $value = hex($single_node->getAttribute('value'));
- push(@extenders,$value);
-}
-@extenders = map {chr($_)} @extenders;
-foreach my $char (@extenders) {
- eval {
- my $el = $doc1->createElement("_$char");
- };
- if ($@) {
- if (ref $@) {
- print STDERR "Error code: $@->{code}\n";
- } else {
- print STDERR $@;
- }
- }
- ok(!$@) || printf("char: <0x%.4X>\n",ord($char));
-}
-
-my ($combining_char_node) = $doc1->getElementsByTagName('combiningchar');
-my @combining_chars;
-foreach my $range_node ($combining_char_node->getElementsByTagName('range')) {
- my $low = hex($range_node->getAttribute('low'));
- my $high = hex($range_node->getAttribute('high'));
- push(@combining_chars,$low..$high);
-}
-foreach my $single_node ($combining_char_node->getElementsByTagName('single')) {
- my $value = hex($single_node->getAttribute('value'));
- push(@combining_chars,$value);
-}
-@combining_chars = map {chr($_)} @combining_chars;
-foreach my $char (@combining_chars) {
- eval {
- my $el = $doc1->createElement("_$char");
- };
- if ($@) {
- if (ref $@) {
- print STDERR "Error code: $@->{code}\n";
- } else {
- print STDERR $@;
- }
- }
- ok(!$@) || printf("char: <0x%.4X>\n",ord($char));
-}
-
-my ($letter_node) = $doc1->getElementsByTagName('letter');
-my @letters;
-foreach my $range_node ($letter_node->getElementsByTagName('range')) {
- my $low = hex($range_node->getAttribute('low'));
- my $high = hex($range_node->getAttribute('high'));
- push(@letters,$low..$high);
-}
-foreach my $single_node ($letter_node->getElementsByTagName('single')) {
- my $value = hex($single_node->getAttribute('value'));
- push(@letters,$value);
-}
-@letters = map {chr($_)} @letters;
-# $XML::Xerces::DEBUG_UTF8_IN = 1;
-# $XML::Xerces::DEBUG_UTF8_OUT = 1;
-foreach my $char (@letters) {
- eval {
- my $el = $doc1->createElement("$char");
- };
- if ($@) {
- if (ref $@) {
- print STDERR "Error code: $@->{code}\n";
- } else {
- print STDERR $@;
- }
- }
- ok(!$@) || printf("char: <0x%.4X>\n",ord($char));
-}
-
-my ($ideograph_node) = $doc1->getElementsByTagName('ideographic');
-my @ideographs;
-foreach my $range_node ($ideograph_node->getElementsByTagName('range')) {
- my $low = hex($range_node->getAttribute('low'));
- my $high = hex($range_node->getAttribute('high'));
- push(@ideographs,$low..$high);
-}
-foreach my $single_node ($ideograph_node->getElementsByTagName('single')) {
- my $value = hex($single_node->getAttribute('value'));
- push(@ideographs,$value);
-}
-@ideographs = map {chr($_)} @ideographs;
-# $XML::Xerces::DEBUG_UTF8_IN = 1;
-# $XML::Xerces::DEBUG_UTF8_OUT = 1;
-foreach my $char (@ideographs) {
- eval {
- my $el = $doc1->createElement("$char");
- };
- if ($@) {
- if (ref $@) {
- print STDERR "Error code: $@->{code}\n";
- } else {
- print STDERR $@;
- }
- }
- ok(!$@) || printf("char: <0x%.4X>\n",ord($char));
-}
-$XML::Xerces::DEBUG_UTF8_IN = 0;
-$XML::Xerces::DEBUG_UTF8_OUT = 0;
+# check that an element can't start with a digit
+my $el = eval {$doc1->createElement('9')};
+$error = $@;
+ok($error,'creating an element that starts with a digit raises exception');
+
+isa_ok($error,$isa)
+ or diag($error);
+
+ok((UNIVERSAL::isa($error,$isa)
+ && $error->getCode == $expect),
+ "received correct error code")
+ || diag("found code: $error->{code}, expected code: $expect");
# check that an element can start with an underscore
eval {
my $el = $doc1->createElement('_');
};
-ok(!$@);
+ok(!$@,
+ "element can start with underscore");
# check that an element can start with an colon
eval {
my $el = $doc1->createElement(':');
};
-ok(!$@);
+ok(!$@,
+ "element cannot start with colon");
+
+# check that getElementById() doesn't segfault on undef ID
+eval {
+ $doc1->getElementById(undef);
+};
+ok($@,
+ "calling getElementById with null string causes exception");
+
Modified: xerces/xerces-p/trunk/t/DOMElement.t
URL: http://svn.apache.org/viewcvs/xerces/xerces-p/trunk/t/DOMElement.t?rev=351966&r1=351965&r2=351966&view=diff
==============================================================================
--- xerces/xerces-p/trunk/t/DOMElement.t (original)
+++ xerces/xerces-p/trunk/t/DOMElement.t Sat Dec 3 07:50:10 2005
@@ -7,8 +7,9 @@
END {ok(0) unless $loaded;}
use Carp;
+use blib;
use XML::Xerces;
-use Test::More tests => 4;
+use Test::More tests => 20;
use lib 't';
use TestUtils qw($DOM $PERSONAL_FILE_NAME);
@@ -27,11 +28,98 @@
my @persons = $doc->getElementsByTagName('person');
my @names = $doc->getElementsByTagName('name');
+# try to set an Attribute, 'bar', to a constant string
+eval{$persons[0]->setAttribute('bar',"a nice happy attribute value")};
+ok(!$@,
+ "setAttribute - string value succeeds");
+ok(($persons[0]->getAttribute('bar') eq "a nice happy attribute value"),
+ "setAttribute - string constant value has proper value");
+
+# try to set an Attribute, 'bar', to a variable string
+my $value = "a nice happy attribute value";
+eval{$persons[0]->setAttribute('bar',$value)};
+ok(!$@,
+ "setAttribute - string value succeeds");
+ok(($persons[0]->getAttribute('bar') eq $value),
+ "setAttribute - string variable value has proper value");
+
+# try to set an Attribute, 'bar', to a constant int
+eval{$persons[0]->setAttribute('bar', 42)};
+ok(!$@,
+ "setAttribute - constant int value succeeds");
+ok(($persons[0]->getAttribute('bar') eq 42),
+ "setAttribute - constant int value has proper value");
+
+# try to set an Attribute, 'bar', to an int variable
+$value = 42;
+eval{$persons[0]->setAttribute('bar', $value)};
+ok(!$@,
+ "setAttribute - int variable value succeeds");
+ok(($persons[0]->getAttribute('bar') eq $value),
+ "setAttribute - int variable value has proper value");
+
+# try to set an Attribute, 'bar', to a constant double
+eval{$persons[0]->setAttribute('bar', 42.0)};
+ok(!$@,
+ "setAttribute - double value succeeds");
+ok(($persons[0]->getAttribute('bar') eq 42.0),
+ "setAttribute - constant double value has proper value");
+
+# try to set an Attribute, 'bar', to an double variable
+$value = 42.0;
+eval{$persons[0]->setAttribute('bar', $value)};
+ok(!$@,
+ "setAttribute - double variable value succeeds");
+ok(($persons[0]->getAttribute('bar') eq $value),
+ "setAttribute - double variable value has proper value");
+
# try to set an Attribute, 'foo', to undef
-ok(!$persons[0]->setAttribute('foo',undef));
+eval{$persons[0]->setAttribute('foo',undef)};
+ok($@,
+ "setAttribute - undef value fails");
# try to set an Attribute, undef, to 'foo'
-ok(!$persons[0]->setAttribute(undef,'foo'));
+eval{$persons[0]->setAttribute(undef,'foo')};
+ok($@,
+ "setAttribute - undef name fails");
# ensure that actual_cast() is being called
-ok(ref $persons[0] eq 'XML::Xerces::DOMElement');
+isa_ok($persons[0],'XML::Xerces::DOMElement');
+
+#
+# Test the DOM Level 2 methods
+#
+my $uri = 'http://www.foo.bar/';
+my $document = <<EOT;
+<list xmlns:qs="$uri">
+ <element qs:one='1' qs:two='2' qs:three='3' one='27'/>
+</list>
+EOT
+
+$DOM->setDoNamespaces(1);
+$DOM->parse(XML::Xerces::MemBufInputSource->new($document));
+$doc = $DOM->getDocument();
+
+# get the single <element> node
+my ($element) = $doc->getElementsByTagName('element');
+
+# try to set an Attribute, 'foo', to 'foo'
+$element->setAttributeNS($uri,'foo','foo');
+ok($element->getAttributeNS($uri,'foo') eq 'foo',
+ "setAttributeNS - correct value")
+ or diag("found attributes [" . $element->serialize() . "]");
+
+# try to set an Attribute, 'foo', to undef
+eval{$element->setAttributeNS($uri,'foo',undef)};
+ok($@,
+ "setAttributeNS - undef value fails");
+
+# try to set an Attribute, undef, to 'foo'
+eval{$element->setAttributeNS($uri,undef,'foo')};
+ok($@,
+ "setAttributeNS - undef qname fails");
+
+# try to set an Attribute, with uri == undef
+eval{$element->setAttributeNS(undef,'foo','foo')};
+ok($@,
+ "setAttributeNS - undef uri fails");
Modified: xerces/xerces-p/trunk/t/DOMException.t
URL: http://svn.apache.org/viewcvs/xerces/xerces-p/trunk/t/DOMException.t?rev=351966&r1=351965&r2=351966&view=diff
==============================================================================
--- xerces/xerces-p/trunk/t/DOMException.t (original)
+++ xerces/xerces-p/trunk/t/DOMException.t Sat Dec 3 07:50:10 2005
@@ -12,7 +12,7 @@
use Carp;
# use blib;
use XML::Xerces;
-use Test::More tests => 7;
+use Test::More tests => 19;
use Config;
use lib 't';
@@ -29,6 +29,12 @@
# of the test code):
+ # NOTICE: We must now explicitly call XMLPlatformUtils::Initialize()
+ # when the module is loaded. Xerces.pm no longer does this.
+ #
+ #
+XML::Xerces::XMLPlatformUtils::Initialize();
+
my $impl = XML::Xerces::DOMImplementation::getImplementation();
my $dt = $impl->createDocumentType('Foo', 'foo', 'Foo.dtd');
my $doc = $impl->createDocument('Foo', 'foo',$dt);
@@ -36,10 +42,12 @@
$impl->createDocument('Bar', 'bar',$dt);
};
my $error = $@;
-ok($error &&
- UNIVERSAL::isa($error,'XML::Xerces::DOMException') &&
- $error->{code} == $XML::Xerces::DOMException::WRONG_DOCUMENT_ERR
- );
+ok($error,
+ "creating doc with DocumentType from another doc raises exception");
+isa_ok($error,'XML::Xerces::DOMException');
+
+is($error->{code}, $XML::Xerces::DOMException::WRONG_DOCUMENT_ERR,
+ "got correct error code");
# Create a couple of identical test documents
my $document = q[<?xml version="1.0" encoding="UTF-8"?>
@@ -58,68 +66,84 @@
</person>
</contributors>];
-my $DOM1 = new XML::Xerces::XercesDOMParser;
-my $ERROR_HANDLER = XML::Xerces::PerlErrorHandler->new();
-$DOM1->setErrorHandler($ERROR_HANDLER);
-my $is = eval{XML::Xerces::MemBufInputSource->new($document)};
-XML::Xerces::error($@) if $@;
-eval{$DOM1->parse($is)};
-XML::Xerces::error($@) if $@;
-
-my $DOM2 = new XML::Xerces::XercesDOMParser;
-$DOM2->setErrorHandler($ERROR_HANDLER);
-eval {$DOM2->parse($is)};
-XML::Xerces::error($@) if $@;
-
-my $doc1 = $DOM1->getDocument();
-my $doc2 = $DOM2->getDocument();
-
-my $root1 = $doc1->getDocumentElement();
-my @persons1 = $root1->getChildNodes();
-my $name1 = ($persons1[1]->getChildNodes())[1];
-my $root2 = $doc2->getDocumentElement();
-my @persons2 = $root2->getChildNodes();
-my $name2 = ($persons2[1]->getChildNodes())[1];
+my ($DOM1, $ERROR_HANDLER, $DOM2);
+my ($doc1, $doc2);
+my ($root1, @persons1, $name1, $root2, @persons2, $name2);
+
+sub refresh {
+ $DOM1 = new XML::Xerces::XercesDOMParser;
+ $ERROR_HANDLER = XML::Xerces::PerlErrorHandler->new();
+ $DOM1->setErrorHandler($ERROR_HANDLER);
+ my $is = eval{XML::Xerces::MemBufInputSource->new($document)};
+ XML::Xerces::error($@) if $@;
+ eval{$DOM1->parse($is)};
+ XML::Xerces::error($@) if $@;
+
+ $DOM2 = new XML::Xerces::XercesDOMParser;
+ $DOM2->setErrorHandler($ERROR_HANDLER);
+ eval {$DOM2->parse($is)};
+ XML::Xerces::error($@) if $@;
+
+ $doc1 = $DOM1->getDocument();
+ $doc2 = $DOM2->getDocument();
+
+ $root1 = $doc1->getDocumentElement();
+ @persons1 = $root1->getChildNodes();
+ $name1 = ($persons1[1]->getChildNodes())[1];
+ $root2 = $doc2->getDocumentElement();
+ @persons2 = $root2->getChildNodes();
+ $name2 = ($persons2[1]->getChildNodes())[1];
+}
+
+refresh();
# Trying to append to a DOMDocument node gives a hierarchy error
eval {
$doc1->appendChild($root2);
};
$error = $@;
-ok($error &&
- UNIVERSAL::isa($error,'XML::Xerces::DOMException') &&
- $error->{code} == $XML::Xerces::DOMException::HIERARCHY_REQUEST_ERR
- );
+ok($error,
+ "Trying to append to a DOMDocument node gives a hierarchy error");
+isa_ok($error,'XML::Xerces::DOMException');
+
+is($error->{code}, $XML::Xerces::DOMException::HIERARCHY_REQUEST_ERR,
+ "got correct error code");
+
+refresh();
# Trying to append to a different DOMDocument gives a wrong doc error
eval {
$root1->appendChild($root2);
};
$error = $@;
-ok($error &&
- UNIVERSAL::isa($error,'XML::Xerces::DOMException') &&
- $error->{code} == $XML::Xerces::DOMException::WRONG_DOCUMENT_ERR
- );
+ok($error,
+ "Trying to append to a different DOMDocument gives a wrong doc error");
+isa_ok($error,'XML::Xerces::DOMException');
+
+is($error->{code}, $XML::Xerces::DOMException::WRONG_DOCUMENT_ERR,
+ "got correct error code");
# Trying to insert to a different DOMDocument gives a wrong doc error
eval {
$persons1[1]->insertBefore($persons2[1],$persons1[1]);
};
$error = $@;
-ok($error &&
- UNIVERSAL::isa($error,'XML::Xerces::DOMException') &&
- $error->{code} == $XML::Xerces::DOMException::WRONG_DOCUMENT_ERR
- );
+ok($error,
+ "Trying to insert to a different DOMDocument gives a wrong doc error");
+isa_ok($error,'XML::Xerces::DOMException');
+is($error->{code}, $XML::Xerces::DOMException::WRONG_DOCUMENT_ERR,
+ "got correct error code");
# Trying to insert to a DOMDocument node gives a wrong doc error
eval {
$doc1->insertBefore($persons2[1],$root1);
};
$error = $@;
-ok($error &&
- UNIVERSAL::isa($error,'XML::Xerces::DOMException') &&
- $error->{code} == $XML::Xerces::DOMException::HIERARCHY_REQUEST_ERR
- );
+ok($error,
+ "Trying to insert to a DOMDocument node gives a hierarchy error");
+isa_ok($error,'XML::Xerces::DOMException');
+is($error->{code}, $XML::Xerces::DOMException::HIERARCHY_REQUEST_ERR,
+ "got correct error code");
# Trying to insert before a node that is not a subnode of the calling node
# gives a not found error
@@ -127,11 +151,17 @@
$persons1[1]->insertBefore($name1,$persons1[3]);
};
$error = $@;
-ok($error &&
- UNIVERSAL::isa($error,'XML::Xerces::DOMException') &&
- $error->{code} == $XML::Xerces::DOMException::NOT_FOUND_ERR
- );
-
-# print STDERR "Code = $code\n";
-# print STDERR "Eval = $@\n";
-# print STDERR "Error = $error\n";
+ok($error,
+ "Trying to insert before a node that is not a subnode of the calling node gives a not found error");
+isa_ok($error,'XML::Xerces::DOMException');
+
+is($error->{code}, $XML::Xerces::DOMException::NOT_FOUND_ERR,
+ "got correct error code");
+
+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();
+}
Modified: xerces/xerces-p/trunk/t/DOMNodeIterator.t
URL: http://svn.apache.org/viewcvs/xerces/xerces-p/trunk/t/DOMNodeIterator.t?rev=351966&r1=351965&r2=351966&view=diff
==============================================================================
--- xerces/xerces-p/trunk/t/DOMNodeIterator.t (original)
+++ xerces/xerces-p/trunk/t/DOMNodeIterator.t Sat Dec 3 07:50:10 2005
@@ -10,7 +10,7 @@
use blib;
use XML::Xerces;
-use Test::More tests => 5;
+use Test::More tests => 7;
use Config;
use vars qw($loaded);
@@ -55,15 +55,17 @@
$DOM->parse(XML::Xerces::MemBufInputSource->new($document));
my $doc = $DOM->getDocument();
+isa_ok($doc,'XML::Xerces::DOMDocumentTraversal');
my $root = $doc->getDocumentElement();
my $filter = MyNodeFilter->new();
+isa_ok($filter,'XML::Xerces::PerlNodeFilter');
my $what = $XML::Xerces::DOMNodeFilter::SHOW_ELEMENT;
my $iterator = $doc->createNodeIterator($root,$what,$filter,1);
-ok(defined $iterator &&
- UNIVERSAL::isa($iterator,'XML::Xerces::DOMNodeIterator'));
+isa_ok($iterator,'XML::Xerces::DOMNodeIterator');
# test that nextNode() returns the first node in the set
-ok($iterator->nextNode() == $root);
+ok($iterator->nextNode() == $root,
+ "first node is root");
my $success = 1;
my $count = 0;
@@ -72,7 +74,9 @@
$success = 0 unless $node->isa('XML::Xerces::DOMElement');
}
# test that we only got elements
-ok($success);
+ok($success,
+ "TreeWalker returns only DOMElements");
#test that we got all the elements
-ok($count == 9);
+ok($count == 9,
+ "TreeWalker traverses all elements in tree");
Modified: xerces/xerces-p/trunk/t/DOMPrint.t
URL: http://svn.apache.org/viewcvs/xerces/xerces-p/trunk/t/DOMPrint.t?rev=351966&r1=351965&r2=351966&view=diff
==============================================================================
--- xerces/xerces-p/trunk/t/DOMPrint.t (original)
+++ xerces/xerces-p/trunk/t/DOMPrint.t Sat Dec 3 07:50:10 2005
@@ -59,8 +59,7 @@
$perl =~ s/^\#!//;
my $output = `$perl -Mblib $SAMPLE_DIR/DOMPrint.pl $file 2>/dev/null`;
-ok($document eq $output);
-diag("Found [$output]\n")
- unless $document eq $output;
+ok($document eq $output)
+ or diag("Expected: [$document]\nFound: [$output]\n");
END {unlink $file;}
Modified: xerces/xerces-p/trunk/t/DOMTreeWalker.t
URL: http://svn.apache.org/viewcvs/xerces/xerces-p/trunk/t/DOMTreeWalker.t?rev=351966&r1=351965&r2=351966&view=diff
==============================================================================
--- xerces/xerces-p/trunk/t/DOMTreeWalker.t (original)
+++ xerces/xerces-p/trunk/t/DOMTreeWalker.t Sat Dec 3 07:50:10 2005
@@ -12,7 +12,7 @@
use Carp;
# use blib;
use XML::Xerces;
-use Test::More tests => 5;
+use Test::More tests => 7;
use Config;
use lib 't';
@@ -63,18 +63,20 @@
XML::Xerces::error($@) if $@;
my $doc = $DOM->getDocument();
+isa_ok($doc,'XML::Xerces::DOMDocumentTraversal');
my $root = $doc->getDocumentElement();
my $filter = MyNodeFilter->new();
+isa_ok($filter,'XML::Xerces::PerlNodeFilter');
my $what = $XML::Xerces::DOMNodeFilter::SHOW_ELEMENT;
my $walker = eval{$doc->createTreeWalker($root,$what,$filter,1)};
XML::Xerces::error($@) if $@;
-ok(defined $walker &&
- UNIVERSAL::isa($walker,'XML::Xerces::DOMTreeWalker'));
+isa_ok($walker,'XML::Xerces::DOMTreeWalker');
# test parentNode
$walker->nextNode();
-ok($walker->parentNode() == $root);
+ok($walker->parentNode() == $root,
+ "first node is root");
my $success = 1;
my $count = 0;
@@ -83,7 +85,9 @@
$success = 0 unless $node->isa('XML::Xerces::DOMElement');
}
# test that we only got elements
-ok($success);
+ok($success,
+ "TreeWalker returns only DOMElements");
#test that we got all the elements
-ok($count == 9);
+ok($count == 9,
+ "TreeWalker traverses all elements in tree");
Modified: xerces/xerces-p/trunk/t/EntityResolver.t
URL: http://svn.apache.org/viewcvs/xerces/xerces-p/trunk/t/EntityResolver.t?rev=351966&r1=351965&r2=351966&view=diff
==============================================================================
--- xerces/xerces-p/trunk/t/EntityResolver.t (original)
+++ xerces/xerces-p/trunk/t/EntityResolver.t Sat Dec 3 07:50:10 2005
@@ -9,7 +9,7 @@
use Carp;
# use blib;
use XML::Xerces;
-use Test::More tests => 10;
+use Test::More tests => 11;
use Cwd;
use lib 't';
@@ -148,3 +148,38 @@
die $@;
}
ok(1);
+
+package MyEntityResolver;
+use strict;
+use vars qw(@ISA);
+@ISA = qw(XML::Xerces::PerlEntityResolver);
+
+sub new {
+ return bless {}, shift;
+}
+
+sub resolve_entity {
+ my ($self,$pub,$sys) = @_;
+ return undef;
+}
+
+package main;
+my $document2 = qq[<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!DOCTYPE bar SYSTEM "foo.dtd" [
+<!ELEMENT bar (foo)>
+<!ELEMENT foo EMPTY>
+<!ATTLIST foo id ID #REQUIRED>
+<!ATTLIST foo role CDATA #REQUIRED>
+]>
+<bar>
+ <foo id='baz' role="manager"/>
+</bar>];
+
+my $is2 = eval{XML::Xerces::MemBufInputSource->new($document2)};
+XML::Xerces::error($@) if $@;
+$DOM->setEntityResolver(MyEntityResolver->new());
+eval {$DOM->parse($is2)};
+my $error = $@;
+ok($error,
+ "entity resolver which returns NULL for DTD resolution raises exception");
+
Modified: xerces/xerces-p/trunk/t/MemBufInputSource.t
URL: http://svn.apache.org/viewcvs/xerces/xerces-p/trunk/t/MemBufInputSource.t?rev=351966&r1=351965&r2=351966&view=diff
==============================================================================
--- xerces/xerces-p/trunk/t/MemBufInputSource.t (original)
+++ xerces/xerces-p/trunk/t/MemBufInputSource.t Sat Dec 3 07:50:10 2005
@@ -9,7 +9,7 @@
use Carp;
# use blib;
use XML::Xerces;
-use Test::More tests => 4;
+use Test::More tests => 5;
use lib 't';
use TestUtils qw($DOM $PERSONAL_NO_DOCTYPE);
@@ -36,3 +36,11 @@
$is = eval{XML::Xerces::MemBufInputSource->new($PERSONAL_NO_DOCTYPE)};
XML::Xerces::error($@) if $@;
ok($is->getSystemId() eq 'FAKE_SYSTEM_ID');
+
+# test that a blank document does not segfault
+$is = eval{XML::Xerces::MemBufInputSource->new('')};
+XML::Xerces::error($@) if $@;
+eval {$DOM->parse($is)};
+ok($@,
+ "blank document does not segfault")
+ or diag($@);
Modified: xerces/xerces-p/trunk/t/PerlErrorHandler.t
URL: http://svn.apache.org/viewcvs/xerces/xerces-p/trunk/t/PerlErrorHandler.t?rev=351966&r1=351965&r2=351966&view=diff
==============================================================================
--- xerces/xerces-p/trunk/t/PerlErrorHandler.t (original)
+++ xerces/xerces-p/trunk/t/PerlErrorHandler.t Sat Dec 3 07:50:10 2005
@@ -110,10 +110,11 @@
my $expected_error = <<EOE;
FATAL ERROR:
LINE: 22
-COLUMN: 11
+COLUMN: 5
MESSAGE: Expected end of tag 'foo'
EOE
- ok($expected_error eq $error);
+ ok($expected_error eq $error)
+ or diag("Expected error: [$expected_error]\nFound error: [$error]\n");
}
Modified: xerces/xerces-p/trunk/t/SAXException.t
URL: http://svn.apache.org/viewcvs/xerces/xerces-p/trunk/t/SAXException.t?rev=351966&r1=351965&r2=351966&view=diff
==============================================================================
--- xerces/xerces-p/trunk/t/SAXException.t (original)
+++ xerces/xerces-p/trunk/t/SAXException.t Sat Dec 3 07:50:10 2005
@@ -10,7 +10,7 @@
# use blib;
use XML::Xerces;
-use Test::More tests => 6;
+use Test::More tests => 17;
use Config;
use lib 't';
@@ -25,41 +25,75 @@
# test that we get an SAXNotRecognizedException
my $parser = XML::Xerces::XMLReaderFactory::createXMLReader();
+isa_ok($parser,"XML::Xerces::SAX2XMLReader");
+
+my $feature = "http://xml.org/sax/features/foospaces";
eval {
- $parser->setFeature("http://xml.org/sax/features/foospaces", 0);
+ $parser->setFeature($feature, 0);
};
my $error = $@;
-ok($error &&
- UNIVERSAL::isa($error,'XML::Xerces::SAXNotRecognizedException') &&
- $error->getMessage()
- );
+my $skip = 0;
+unless (ok($error,"setFeature: $feature")) {
+ $skip = 1;
+}
+
+TODO: {
+ todo_skip "setFeature didn't raise an exception", 2, if $skip;
+
+ isa_ok($error,'XML::Xerces::SAXNotRecognizedException');
+ ok($error->getMessage(),"message");
+}
+
+$skip = 0;
eval {
- $parser->getFeature('http://xml.org/sax/features/foospaces');
+ $parser->getFeature($feature);
};
$error = $@;
-ok($error &&
- UNIVERSAL::isa($error,'XML::Xerces::SAXNotRecognizedException') &&
- $error->getMessage()
- );
+unless (ok($error,"getFeature: $feature")){
+ $skip = 1;
+}
+
+TODO: {
+ todo_skip "setFeature didn't raise an exception", 2, if $skip;
+
+ isa_ok($error,'XML::Xerces::SAXNotRecognizedException');
+ ok($error->getMessage(),"message");
+}
+
+$skip = 0;
eval {
- $parser->getProperty('http://xml.org/sax/features/foospaces');
+ $parser->getProperty($feature);
};
$error = $@;
-ok($error &&
- UNIVERSAL::isa($error,'XML::Xerces::SAXNotRecognizedException') &&
- $error->getMessage()
- );
+unless (ok($error,"getProperty: $feature")) {
+ $skip = 1;
+}
+
+TODO: {
+ todo_skip "setFeature didn't raise an exception", 2, if $skip;
+
+ isa_ok($error,'XML::Xerces::SAXNotRecognizedException');
+ ok($error->getMessage(),"message");
+}
+
+$skip = 0;
eval {
- $parser->setProperty('http://xml.org/sax/features/foospaces', $parser);
+ $parser->setProperty($feature, $parser);
};
$error = $@;
-ok($error &&
- UNIVERSAL::isa($error,'XML::Xerces::SAXNotRecognizedException') &&
- $error->getMessage()
- );
+unless (ok($error,"setProperty: $feature")){
+ $skip = 1;
+}
+
+TODO: {
+ todo_skip "setFeature didn't raise an exception", 2, if $skip;
+
+ isa_ok($error,'XML::Xerces::SAXNotRecognizedException');
+ ok($error->getMessage(),"message");
+}
# test that modifying a feature during a parse raises a not supported exception
package MyHandler;
@@ -70,7 +104,6 @@
sub start_element {
my ($self,$name,$attrs) = @_;
$parser->setProperty('http://xml.org/sax/features/namespaces', $parser);
- print STDERR "Got it!!";
}
sub end_element {
}
@@ -86,12 +119,13 @@
$parser->parse(XML::Xerces::LocalFileInputSource->new($PERSONAL_FILE_NAME));
};
$error = $@;
-ok($error &&
- UNIVERSAL::isa($error,'XML::Xerces::SAXNotSupportedException') &&
- $error->getMessage()
- );
-
-# print STDERR "MessageNS = $messageNS\n";
-# print STDERR "MessageNR = $messageNR\n";
-# print STDERR "Error = $error\n";
-# print STDERR "Eval = $@\n";
+unless (ok($error,"setting a feature during parse")) {
+ $skip = 1;
+}
+
+TODO: {
+ todo_skip "modifying a feature during a parse didn't raise a not supported exception", 2, if $skip;
+
+ isa_ok($error,'XML::Xerces::SAXNotSupportedException');
+ ok($error->getMessage(),"message");
+}
Modified: xerces/xerces-p/trunk/t/TestUtils.pm
URL: http://svn.apache.org/viewcvs/xerces/xerces-p/trunk/t/TestUtils.pm?rev=351966&r1=351965&r2=351966&view=diff
==============================================================================
--- xerces/xerces-p/trunk/t/TestUtils.pm (original)
+++ xerces/xerces-p/trunk/t/TestUtils.pm Sat Dec 3 07:50:10 2005
@@ -46,6 +46,13 @@
BEGIN {
# turn off annoying warnings
$SIG{__WARN__} = 'IGNORE';
+}
+
+ # NOTICE: We must now explicitly call XMLPlatformUtils::Initialize()
+ # when the module is loaded. Xerces.pm no longer does this.
+ #
+ #
+XML::Xerces::XMLPlatformUtils::Initialize();
$DOM = XML::Xerces::XercesDOMParser->new();
@@ -86,6 +93,13 @@
$/ = undef;
$PERSONAL_NO_XMLDECL = <PERSONAL>;
close PERSONAL;
+
+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();
}
sub error {
@@ -145,5 +159,7 @@
if ref $@;
print STDERR "$msg $@\n";
}
+
+ $is->DISOWN();
return $is;
}
Modified: xerces/xerces-p/trunk/t/URLInputSource.t
URL: http://svn.apache.org/viewcvs/xerces/xerces-p/trunk/t/URLInputSource.t?rev=351966&r1=351965&r2=351966&view=diff
==============================================================================
--- xerces/xerces-p/trunk/t/URLInputSource.t (original)
+++ xerces/xerces-p/trunk/t/URLInputSource.t Sat Dec 3 07:50:10 2005
@@ -26,45 +26,49 @@
my $file_name = '/home/user/test.xml';
my $URL = "file:$file_name";
my $xml_url = XML::Xerces::XMLURL->new($URL);
-ok(UNIVERSAL::isa($xml_url, 'XML::Xerces::XMLURL'));
+isa_ok($xml_url, 'XML::Xerces::XMLURL');
my $is = eval{XML::Xerces::URLInputSource->new($xml_url)};
XML::Xerces::error($@) if $@;
-ok(UNIVERSAL::isa($is,'XML::Xerces::URLInputSource'));
+isa_ok($is,'XML::Xerces::URLInputSource');
# now test the overloaded constructors
$is = eval{XML::Xerces::URLInputSource->new('file:/',"$file_name")};
XML::Xerces::error($@) if $@;
-ok(UNIVERSAL::isa($is,'XML::Xerces::URLInputSource'));
+isa_ok($is,'XML::Xerces::URLInputSource');
$is = eval{XML::Xerces::URLInputSource->new('file:/',"$file_name", 'foo')};
XML::Xerces::error($@) if $@;
-ok($is->getPublicId() eq 'foo');
+ok($is->getPublicId() eq 'foo',
+ "PUBLIC Id properly set");
# test that a baseId with no '/' causes a relative URL exception
$is = eval{XML::Xerces::URLInputSource->new('file:',$file_name,'foo')};
my $error = $@;
-ok($error &&
+ok(($error &&
UNIVERSAL::isa($error,'XML::Xerces::XMLException') &&
$error->getCode() == $XML::Xerces::XMLExcepts::URL_RelativeBaseURL
- );
+ ),
+ "baseId with no '/' causes a relative URL exception");
# test that a bad protocol
eval {
$is = XML::Xerces::URLInputSource->new('blorphl:/xs/./foo.html', 'foo');
};
$error = $@;
-ok($error &&
+ok(($error &&
UNIVERSAL::isa($error,'XML::Xerces::XMLException') &&
$error->getCode() == $XML::Xerces::XMLExcepts::URL_UnsupportedProto1
- );
+ ),
+ "bad protocol causes exception");
# test a non-existent protocol
$is = eval{XML::Xerces::URLInputSource->new('foo','', 'foo')};
$error = $@;
# printf STDERR "Got error code: %d\n", $error->getCode();
-ok($error &&
+ok(($error &&
UNIVERSAL::isa($error,'XML::Xerces::XMLException') &&
$error->getCode() == $XML::Xerces::XMLExcepts::URL_NoProtocolPresent
- );
+ ),
+ "non-existent protocol causes exception");
Modified: xerces/xerces-p/trunk/t/XMLException.t
URL: http://svn.apache.org/viewcvs/xerces/xerces-p/trunk/t/XMLException.t?rev=351966&r1=351965&r2=351966&view=diff
==============================================================================
--- xerces/xerces-p/trunk/t/XMLException.t (original)
+++ xerces/xerces-p/trunk/t/XMLException.t Sat Dec 3 07:50:10 2005
@@ -10,9 +10,11 @@
# use blib;
use XML::Xerces;
-use Test::More tests => 1;
+use Test::More tests => 4;
use Config;
+use lib 't';
+use TestUtils qw($PERSONAL_FILE_NAME);
use vars qw($loaded $error);
use strict;
@@ -21,14 +23,15 @@
######################### End of black magic.
-# test that we get an exception object
-# 2003-06-10 JES: it seems that this has changed for 2.3 and
-# now a fatal error is thrown at parse time instead
-#
-# eval {
-# XML::Xerces::LocalFileInputSource->new('../I/AM/NOT/A/FILE');
-# };
-# my $error = $@;
-# ok($error &&
-# UNIVERSAL::isa($error,'XML::Xerces::XMLException') &&
-# $error->getCode() == $XML::Xerces::XMLExcepts::File_CouldNotGetBasePathName);
+my $uri = eval{XML::Xerces::XMLUri->new(undef,"")};
+my $error = $@;
+ok($error,
+ "exception when XMLUri constructor called with NULL baseUri, and empty uriSpec");
+isa_ok($error,'XML::Xerces::XMLException');
+
+my $expected = $XML::Xerces::XMLExcepts::XMLNUM_URI_Component_Empty;
+my $code = $error->getCode();
+is($code, $expected,
+ "got correct error code")
+ or diag("Expected: $XML::Xerces::XMLExcepts::CODES[$expected], Found: $XML::Xerces::XMLExcepts::CODES[$code]");
+
Modified: xerces/xerces-p/trunk/t/XMLUni.t
URL: http://svn.apache.org/viewcvs/xerces/xerces-p/trunk/t/XMLUni.t?rev=351966&r1=351965&r2=351966&view=diff
==============================================================================
--- xerces/xerces-p/trunk/t/XMLUni.t (original)
+++ xerces/xerces-p/trunk/t/XMLUni.t Sat Dec 3 07:50:10 2005
@@ -8,7 +8,7 @@
use Carp;
-# use blib;
+use blib;
use XML::Xerces;
use Test::More tests => 4;
@@ -25,10 +25,9 @@
ok($XML::Xerces::XMLUni::fgPCDATAString eq '#PCDATA');
ok($XML::Xerces::XMLUni::fgPubIDString eq 'PUBLIC');
-TODO: {
- local $TODO = "SWIG string check not checking magic";
- my $impl = XML::Xerces::DOMImplementationRegistry::getDOMImplementation('LS');
- my $writer = $impl->createDOMWriter();
- eval{$writer->setFeature($XML::Xerces::XMLUni::fgDOMWRTFormatPrettyPrint,1)};
- ok(!$@);
-}
+my $impl = XML::Xerces::DOMImplementationRegistry::getDOMImplementation('LS');
+my $writer = $impl->createDOMWriter();
+eval{$writer->setFeature($XML::Xerces::XMLUni::fgDOMWRTFormatPrettyPrint,1)};
+ok(!$@,
+ "Xerces method arguments now handle magic stringify")
+ or diag(XML::Xerces::error($@));
Modified: xerces/xerces-p/trunk/t/XercesDOMParser.t
URL: http://svn.apache.org/viewcvs/xerces/xerces-p/trunk/t/XercesDOMParser.t?rev=351966&r1=351965&r2=351966&view=diff
==============================================================================
--- xerces/xerces-p/trunk/t/XercesDOMParser.t (original)
+++ xerces/xerces-p/trunk/t/XercesDOMParser.t Sat Dec 3 07:50:10 2005
@@ -8,8 +8,8 @@
use Carp;
# use blib;
-use XML::Xerces;
use Test::More tests => 8;
+use XML::Xerces;
use lib 't';
use TestUtils qw($PERSONAL_FILE_NAME $PERSONAL_NO_DOCTYPE $PERSONAL $DOM);
@@ -19,6 +19,12 @@
$loaded = 1;
ok($loaded, "module loaded");
+ # NOTICE: We must now explicitly call XMLPlatformUtils::Initialize()
+ # when the module is loaded. Xerces.pm no longer does this.
+ #
+ #
+XML::Xerces::XMLPlatformUtils::Initialize();
+
######################### End of black magic.
my $document = q[<?xml version="1.0" encoding="UTF-8"?>
@@ -81,3 +87,11 @@
# now check that we do *not* get whitespace nodes
my @nodes = $DOM->getDocument->getDocumentElement->getChildNodes();
ok(scalar @nodes == 6);
+
+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();
+}
Modified: xerces/xerces-p/trunk/t/actualCast.t
URL: http://svn.apache.org/viewcvs/xerces/xerces-p/trunk/t/actualCast.t?rev=351966&r1=351965&r2=351966&view=diff
==============================================================================
--- xerces/xerces-p/trunk/t/actualCast.t (original)
+++ xerces/xerces-p/trunk/t/actualCast.t Sat Dec 3 07:50:10 2005
@@ -34,6 +34,8 @@
# test that it really is a subclass
isa_ok($name,'XML::Xerces::DOMElement');
+SKIP: {
+ skip "Grammars not yet re-implemented", 4 if 0;
# now test the grammars
my $grammar = $DOM->getRootGrammar();
isa_ok($grammar,'XML::Xerces::Grammar');
@@ -47,6 +49,7 @@
$grammar = $DOM->getRootGrammar();
isa_ok($grammar,'XML::Xerces::Grammar');
isa_ok($grammar,'XML::Xerces::SchemaGrammar');
+}
# now test the CallbackHandler's
SKIP: {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org