File: 01parse.t

package info (click to toggle)
libhttp-oai-perl 4.13-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 436 kB
  • sloc: perl: 2,599; xml: 224; makefile: 15
file content (33 lines) | stat: -rw-r--r-- 819 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use Test::More tests => 5;

use IO::File;
use HTTP::OAI;
use HTTP::OAI::Metadata::OAI_DC;
ok(1);

my $fh;

my $r = HTTP::OAI::GetRecord->new(handlers=>{
	metadata=>'HTTP::OAI::Metadata::OAI_DC'
});
$fh = IO::File->new('examples/getrecord.xml','r')
	or BAIL_OUT( "Failed to open examples/getrecord.xml: $!" );
$r->parse_file($fh);
$fh->close();

my $rec = $r->next;
ok($rec);
ok($rec->metadata->dc->{creator}->[0] eq 'Aspinwall, Paul S.');

my $dom = $rec->metadata->dom;
my $md = HTTP::OAI::Metadata::OAI_DC->new;
$md->metadata( $dom );
ok($md->dc->{creator}->[0] eq 'Aspinwall, Paul S.');

$r = HTTP::OAI::Identify->new();
$fh = IO::File->new('examples/identify.xml','r')
	or BAIL_OUT( "Failed to open examples/identify.xml: $!" );
$r->parse_file($fh);
$fh->close();

ok($r->repositoryName eq 'citebase.eprints.org');