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 2001/10/10 22:02:50 UTC
cvs commit: xml-xerces/perl/t Schema.t
jasons 01/10/10 13:02:50
Modified: perl/t Schema.t
Log:
* t/Schema.t (Repository):
Direct testing of schema with valid and invalid files
Revision Changes Path
1.3 +27 -11 xml-xerces/perl/t/Schema.t
Index: Schema.t
===================================================================
RCS file: /home/cvs/xml-xerces/perl/t/Schema.t,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Schema.t 2001/09/06 04:30:32 1.2
+++ Schema.t 2001/10/10 20:02:50 1.3
@@ -7,7 +7,7 @@
# Change 1..1 below to 1..last_test_to_print .
# (It may become useful if the test is moved to ./t subdirectory.)
-BEGIN { $| = 1; print "1..5\n"; }
+BEGIN { $| = 1; print "1..3\n"; }
END {print "not ok 1\n" unless $loaded;}
use Carp;
# use blib;
@@ -28,13 +28,29 @@
# (correspondingly "not ok 13") depending on the success of chunk 13
# of the test code):
-my @output = split(/\n/,`perl -Mblib ./samples/SAXCount.pl -v=auto -s $PERSONAL_SCHEMA_FILE_NAME 2>/dev/null`);
-
-$output[1] =~ /\s(\d+)/;
-result($1 == 37);
-$output[2] =~ /\b(\d+)\b/;
-result($1 == 0);
-$output[3] =~ /\b(\d+)\b/;
-result($1 == 0);
-$output[4] =~ /\b(\d+)\b/;
-result($1 == 268);
+my $dom = XML::Xerces::DOMParser->new();
+my $handler = XML::Xerces::PerlErrorHandler->new();
+$dom->setDoSchema(1);
+$dom->setDoNamespaces(1);
+$dom->setErrorHandler($handler);
+
+# test a valid file
+eval {
+ $dom->parse($PERSONAL_SCHEMA_FILE_NAME);
+};
+result(!$@);
+
+# test an invalid file
+open(IN,$PERSONAL_SCHEMA_FILE_NAME)
+ or die "Couldn't open $PERSONAL_SCHEMA_FILE_NAME for reading";
+my $buf;
+while (<IN>) {
+ if (/<personnel>/) {
+ s/<personnel>/<foo>/;
+ }
+ $buf .= $_;
+}
+eval {
+ $dom->parse(XML::Xerces::MemBufInputSource->new($buf));
+};
+result($@);
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org