Permalink
Browse files

*** empty log message ***

svn path=/bioperl-live/trunk/; revision=3587
  • Loading branch information...
1 parent cd16ee0 commit be794017c8716f65cc075e05b4d2839a0ae572b2 senger committed Mar 8, 2002
Showing with 64 additions and 30 deletions.
  1. +3 −2 Bio/Biblio.pm
  2. +61 −28 t/Biblio.t
View
@@ -310,11 +310,12 @@ sub _load_access_module {
eval {
require $load;
};
+
if ( $@ ) {
- print STDERR <<END;
+ Bio::Root::Root->throw (<<END);
$load: $access cannot be found or loaded
Exception $@
-For more information about the Biblio system please see the Biblio docs.
+For more information about the Biblio system please see the Bio::Biblio docs.
END
;
return;
View
@@ -33,15 +33,27 @@ my $verbose = 0;
## the print "1..x\n" in the BEGIN block to reflect the
## total number of tests that will be run.
-my $serror = 0;
+my $serror = 0; my $serror2 = 0;
my $ferror = 0; my $ferror2 = 0;
+my $xerror = 0;
my $format = '%-25s';
unless (eval "require SOAP::Lite; 1;") {
- print STDERR "SOAP::Lite not installed.\nThis means that Bio::Biblio module may not be usable. Skipping some tests.\n";
+ print STDERR "SOAP::Lite not installed. Skipping some tests.\n";
$serror = 1;
}
+unless (eval "require IO::String; 1;") {
+ print STDERR "IO::String not installed. Skipping some tests.\n";
+ $serror2 = 1;
+}
+
+unless (eval "require XML::Parser; 1;") {
+ print STDERR "XML::Parser not installed. Skipping some tests.\n";
+ $xerror = 1;
+}
+
+
use Bio::Root::IO;
my $testfile = Bio::Root::IO->catfile ('t','data','stress_test_medline.xml');
unless (-e $testfile) {
@@ -54,15 +66,18 @@ unless (-e $testfile2) {
$ferror2 = 1;
}
+
# check 'use ...'
eval { require Bio::Biblio };
print sprintf ($format, 'use Bio::Biblio'); ok (%Bio::Biblio::);
print $@ if $@;
# check 'new...'
my $biblio;
-print sprintf ($format, "new Bio::Biblio "); skip ($serror,
- defined ($biblio = new Bio::Biblio (-location => 'http://localhost:4567')));
+eval { $biblio = new Bio::Biblio (-location => 'http://localhost:4567'); };
+print sprintf ($format, "new Bio::Biblio "); skip ($serror, defined $biblio);
+print $@ if $@;
+
# check 'use ...IO...'
eval { require Bio::Biblio::IO };
@@ -72,25 +87,27 @@ my $io;
# check MEDLINE XML parser
print sprintf ($format, "new Bio::Biblio::IO (1)");
-skip ($ferror,
+skip ($ferror || $xerror,
defined (eval { $io = new Bio::Biblio::IO ('-format' => 'medlinexml',
'-file' => $testfile,
'-result' => 'raw') }));
+print $@ if $@;
+
print "Reading and parsing MEDLINE XML file...\n";
-print sprintf ($format, " citation 1 "); skip ($ferror, eval { $io->next_bibref->{'medlineID'} }, 'Text1');
-print sprintf ($format, " citation 2 "); skip ($ferror, eval { $io->next_bibref->{'medlineID'} }, 'Text248');
-print sprintf ($format, " citation 3 "); skip ($ferror, eval { $io->next_bibref->{'medlineID'} }, 'Text495');
+print sprintf ($format, " citation 1 "); skip ($ferror || $xerror, eval { $io->next_bibref->{'medlineID'} }, 'Text1');
+print sprintf ($format, " citation 2 "); skip ($ferror || $xerror, eval { $io->next_bibref->{'medlineID'} }, 'Text248');
+print sprintf ($format, " citation 3 "); skip ($ferror || $xerror, eval { $io->next_bibref->{'medlineID'} }, 'Text495');
print "Getting citations using callback...\n";
my (@ids) = ('Text1', 'Text248', 'Text495');
my $callback_used = 'no';
-unless ($ferror) {
+unless ($ferror || $xerror) {
$io = new Bio::Biblio::IO ('-format' => 'medlinexml',
'-file' => $testfile,
# '-result' => 'medline2ref', # this is default
'-callback' => \&callback);
}
-print sprintf ($format, " calling callback "); skip ($ferror, $callback_used, 'yes');
+print sprintf ($format, " calling callback "); skip ($ferror || $xerror, $callback_used, 'yes');
sub callback {
my $citation = shift;
@@ -99,8 +116,12 @@ sub callback {
}
print "Reading and parsing XML string...\n";
-$io = new Bio::Biblio::IO ('-format' => 'medlinexml',
- '-data' => <<XMLDATA,
+if ($xerror) {
+ print sprintf ($format, " citation 1 "); skip (1, 1);
+ print sprintf ($format, " citation 2 "); skip (1, 1);
+} else {
+ $io = new Bio::Biblio::IO ('-format' => 'medlinexml',
+ '-data' => <<XMLDATA,
<MedlineCitationSet>
<MedlineCitation>
<MedlineID>12345678</MedlineID>
@@ -112,14 +133,19 @@ $io = new Bio::Biblio::IO ('-format' => 'medlinexml',
</MedlineCitation>
</MedlineCitationSet>
XMLDATA
- '-result' => 'medline2ref',
- );
-print sprintf ($format, " citation 1 "); ok ($io->next_bibref->{'_identifier'}, '12345678');
-print sprintf ($format, " citation 2 "); ok ($io->next_bibref->{'_identifier'}, 'abcdefgh');
+ '-result' => 'medline2ref',
+ );
+ print sprintf ($format, " citation 1 "); ok ($io->next_bibref->{'_identifier'}, '12345678');
+ print sprintf ($format, " citation 2 "); ok ($io->next_bibref->{'_identifier'}, 'abcdefgh');
+}
print "Reading and parsing XML string handle...\n";
-use IO::String;
-my $data = <<XMLDATA;
+#use IO::String;
+if ($xerror || $serror2) {
+ print sprintf ($format, " citation 1 "); skip (1,1);
+ print sprintf ($format, " citation 2 "); skip (1,1);
+} else {
+ my $data = <<XMLDATA;
<MedlineCitationSet>
<MedlineCitation>
<MedlineID>87654321</MedlineID>
@@ -132,22 +158,29 @@ my $data = <<XMLDATA;
</MedlineCitationSet>
XMLDATA
-$io = new Bio::Biblio::IO ('-format' => 'medlinexml',
- '-fh' => IO::String->new ($data),
- );
-print sprintf ($format, " citation 1 "); ok ($io->next_bibref->identifier, '87654321');
-print sprintf ($format, " citation 2 "); ok ($io->next_bibref->identifier, 'hgfedcba');
+ $io = new Bio::Biblio::IO ('-format' => 'medlinexml',
+ '-fh' => IO::String->new ($data),
+ );
+ print sprintf ($format, " citation 1 "); ok (eval { $io->next_bibref->identifier }, '87654321');
+ print sprintf ($format, " citation 2 "); ok (eval { $io->next_bibref->identifier }, 'hgfedcba');
+}
# check PUBMED XML parser
print sprintf ($format, "new Bio::Biblio::IO (2)");
-skip ($ferror2,
+skip ($ferror2 || $xerror,
defined (eval { $io = new Bio::Biblio::IO ('-format' => 'pubmedxml',
'-file' => $testfile2,
'-result' => 'pubmed2ref') }));
print "Reading and parsing PUBMED XML file...\n";
-print sprintf ($format, " citation 1 "); skip ($ferror2, eval { $io->next_bibref->identifier }, '11223344');
-print sprintf ($format, " citation 2 "); skip ($ferror2, eval { $io->next_bibref->identifier }, '21583752');
-print sprintf ($format, " citation 3 "); skip ($ferror2, eval { $io->next_bibref->identifier }, '21465135');
-print sprintf ($format, " citation 4 "); skip ($ferror2, eval { $io->next_bibref->identifier }, '21138228');
+if ($xerror) {
+ foreach my $i (1..4) {
+ print sprintf ($format, " citation $i "); skip (1,1);
+ }
+} else {
+ print sprintf ($format, " citation 1 "); skip ($ferror2, eval { $io->next_bibref->identifier }, '11223344');
+ print sprintf ($format, " citation 2 "); skip ($ferror2, eval { $io->next_bibref->identifier }, '21583752');
+ print sprintf ($format, " citation 3 "); skip ($ferror2, eval { $io->next_bibref->identifier }, '21465135');
+ print sprintf ($format, " citation 4 "); skip ($ferror2, eval { $io->next_bibref->identifier }, '21138228');
+}
__END__

0 comments on commit be79401

Please sign in to comment.