Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

converted to Test::Class

  • Loading branch information...
commit e62da2c5c2fcc21d68ac8070af72baa95834e047 1 parent bcea93b
@MichaelDaum authored
View
1  .gitignore
@@ -3,3 +3,4 @@ Makefile
blib/
inc/
pm_to_blib
+MYMETA.yml
View
13 MANIFEST
@@ -4,9 +4,22 @@ Makefile.PL
README
META.yml
t/00-load.t
+t/01-basics.t
+t/02-client.t
+t/03-object.t
+t/04-atom-feed.t
+t/05-object-type.t
+t/06-property.t
+t/07-repository.t
+t/08-acl.t
+t/09-folder.t
+t/10-document.t
+t/boilerplate.t
t/manifest.t
t/pod-coverage.t
t/pod.t
+t/data/free.jpg
+lib/REST/Client.pm
lib/WebService/Cmis/ACE.pm
lib/WebService/Cmis/ACL.pm
lib/WebService/Cmis/AtomEntry.pm
View
2  Makefile.PL
@@ -5,7 +5,7 @@ all_from 'lib/WebService/Cmis.pm';
author q{Michael Daum <daum@michaeldaumconsulting.com>};
license 'perl';
-build_requires 'Test::More';
+build_requires 'Test::Class';
auto_install;
View
556 lib/REST/Client.pm
@@ -0,0 +1,556 @@
+package REST::Client;
+
+=head1 NAME
+
+REST::Client - A simple client for interacting with RESTful http/https resources
+
+=head1 SYNOPSIS
+
+ use REST::Client;
+
+ #The basic use case
+ my $client = REST::Client->new();
+ $client->GET('http://example.com/dir/file.xml');
+ print $client->responseContent();
+
+ #A host can be set for convienience
+ $client->setHost('http://example.com');
+ $client->PUT('/dir/file.xml', '<example>new content</example>');
+ if( $client->responseCode() eq '200' ){
+ print "Updated\n";
+ }
+
+ #custom request headers may be added
+ $client->addHeader('CustomHeader', 'Value');
+
+ #response headers may be gathered
+ print $client->responseHeader('ResponseHeader');
+
+ #X509 client authentication
+ $client->setCert('/path/to/ssl.crt');
+ $client->setKey('/path/to/ssl.key');
+
+ #add a CA to verify server certificates
+ $client->setCa('/path/to/ca.file');
+
+ #you may set a timeout on requests, in seconds
+ $client->setTimeout(10);
+
+ #options may be passed as well as set
+ $client = REST::Client->new({
+ host => 'https://example.com',
+ cert => '/path/to/ssl.crt',
+ key => '/path/to/ssl.key',
+ ca => '/path/to/ca.file',
+ timeout => 10,
+ });
+ $client->GET('/dir/file', {CustomHeader => 'Value'});
+
+ # Requests can be specificed directly as well
+ $client->request('GET', '/dir/file', 'request body content', {CustomHeader => 'Value'});
+
+ # Requests can optionally automatically follow redirects and auth, defaults to
+ # false
+ $client->setFollow(1);
+
+ #It is possible to access the L<LWP::UserAgent> object REST::Client is using to
+ #make requests, and set advanced options on it, for instance:
+ $client->getUseragent()->proxy(['http'], 'http://proxy.example.com/');
+
+=head1 DESCRIPTION
+
+REST::Client provides a simple way to interact with HTTP RESTful resources.
+
+=cut
+
+=head1 METHODS
+
+=cut
+
+use strict;
+use warnings;
+use 5.008_000;
+
+use constant TRUE => 1;
+use constant FALSE => 0;
+
+our ($VERSION) = ('$Rev: 171 $' =~ /(\d+)/);
+
+use URI;
+use LWP::UserAgent;
+use Carp qw(croak carp);
+use Crypt::SSLeay;
+
+=head2 Construction and setup
+
+=head3 new ( [%$config] )
+
+Construct a new REST::Client. Takes an optional hash or hash reference or
+config flags. Each config flag also has get/set accessors of the form
+getHost/setHost, getUseragent/setUseragent, etc. These can be called on the
+instantiated object to change or check values.
+
+The config flags are:
+
+=over 4
+
+=item host
+
+A default host that will be prepended to all requests. Allows you to just
+specify the path when making requests.
+
+The default is undef - you must include the host in your requests.
+
+=item timeout
+
+A timeout in seconds for requests made with the client. After the timeout the
+client will return a 500.
+
+The default is 5 minutes.
+
+=item cert
+
+The path to a X509 certificate file to be used for client authentication.
+
+The default is to not use a certificate/key pair.
+
+=item key
+
+The path to a X509 key file to be used for client authentication.
+
+The default is to not use a certificate/key pair.
+
+=item ca
+
+The path to a certificate authority file to be used to verify host
+certificates.
+
+The default is to not use a certificates authority.
+
+=item pkcs12
+
+The path to a PKCS12 certificate to be used for client authentication.
+
+=item pkcs12password
+
+The password for the PKCS12 certificate specified with 'pkcs12'.
+
+=item follow
+
+Boolean that determins whether REST::Client attempts to automatically follow
+redirects/authentication.
+
+The default is false.
+
+=item useragent
+
+An L<LWP::UserAgent> object, ready to make http requests.
+
+REST::Client will provide a default for you if you do not set this.
+
+=back
+
+=cut
+
+sub new {
+ my $class = shift;
+ my $config;
+
+ $class->_buildAccessors();
+
+ if(ref $_[0] eq 'HASH'){
+ $config = shift;
+ }elsif(scalar @_ && scalar @_ % 2 == 0){
+ $config = {@_};
+ }else{
+ $config = {};
+ }
+
+ my $self = bless({}, $class);
+ $self->{'_config'} = $config;
+
+ $self->_buildUseragent();
+
+ return $self;
+}
+
+=head3 addHeader ( $header_name, $value )
+
+Add a custom header to any requests made by this client.
+
+=cut
+
+sub addHeader {
+ my $self = shift;
+ my $header = shift;
+ my $value = shift;
+
+ my $headers = $self->{'_headers'} || {};
+ $headers->{$header} = $value;
+ $self->{'_headers'} = $headers;
+ return;
+}
+
+=head3 buildQuery ( [...] )
+
+A convienience wrapper around URI::query_form for building query strings from a
+variety of data structures. See L<URI>
+
+Returns a scalar query string for use in URLs.
+
+=cut
+
+sub buildQuery {
+ my $self = shift;
+
+ my $uri = URI->new();
+ $uri->query_form(@_);
+ return $uri->as_string();
+}
+
+
+
+=head2 Request Methods
+
+Each of these methods makes an HTTP request, sets the internal state of the
+object, and returns the object.
+
+They can be combined with the response methods, such as:
+
+ print $client->GET('/search/?q=foobar')->responseContent();
+
+=head3 GET ( $url, [%$headers] )
+
+Preform an HTTP GET to the resource specified. Takes an optional hashref of custom request headers.
+
+=cut
+
+sub GET {
+ my $self = shift;
+ my $url = shift;
+ my $headers = shift;
+ return $self->request('GET', $url, undef, $headers);
+}
+
+=head3 PUT ($url, [$body_content, %$headers] )
+
+Preform an HTTP PUT to the resource specified. Takes an optional body content and hashref of custom request headers.
+
+=cut
+
+sub PUT {
+ my $self = shift;
+ return $self->request('PUT', @_);
+}
+
+=head3 POST ( $url, [$body_content, %$headers] )
+
+Preform an HTTP POST to the resource specified. Takes an optional body content and hashref of custom request headers.
+
+=cut
+
+sub POST {
+ my $self = shift;
+ return $self->request('POST', @_);
+}
+
+=head3 DELETE ( $url, [%$headers] )
+
+Preform an HTTP DELETE to the resource specified. Takes an optional hashref of custom request headers.
+
+=cut
+
+sub DELETE {
+ my $self = shift;
+ my $url = shift;
+ my $headers = shift;
+ return $self->request('DELETE', $url, undef, $headers);
+}
+
+=head3 OPTIONS ( $url, [%$headers] )
+
+Preform an HTTP OPTIONS to the resource specified. Takes an optional hashref of custom request headers.
+
+=cut
+
+sub OPTIONS {
+ my $self = shift;
+ my $url = shift;
+ my $headers = shift;
+ return $self->request('OPTIONS', $url, undef, $headers);
+}
+
+=head3 HEAD ( $url, [%$headers] )
+
+Preform an HTTP HEAD to the resource specified. Takes an optional hashref of custom request headers.
+
+=cut
+
+sub HEAD {
+ my $self = shift;
+ my $url = shift;
+ my $headers = shift;
+ return $self->request('HEAD', $url, undef, $headers);
+}
+
+=head3 request ( $method, $url, [$body_content, %$headers] )
+
+Issue a custom request, providing all possible values.
+
+=cut
+
+sub request {
+ my $self = shift;
+ my $method = shift;
+ my $url = shift;
+ my $content = shift;
+ my $headers = shift;
+
+ $self->{'_res'} = undef;
+ $self->_buildUseragent();
+
+
+ #error check
+ croak "REST::Client exception: First argument to request must be one of GET, PUT, POST, DELETE, OPTIONS, HEAD" unless $method =~ /^(get|put|post|delete|options|head)$/i;
+ croak "REST::Client exception: Must provide a url to $method" unless $url;
+ croak "REST::Client exception: headers must be presented as a hashref" if $headers && ref $headers ne 'HASH';
+
+
+ $url = $self->_prepareURL($url);
+
+ #to ensure we use our desired SSL lib
+ my $tmp_socket_ssl_version = $IO::Socket::SSL::VERSION;
+ $IO::Socket::SSL::VERSION = undef;
+
+ my $ua = $self->getUseragent();
+ if(defined $self->getTimeout()){
+ $ua->timeout($self->getTimeout);
+ }else{
+ $ua->timeout(300);
+ }
+ my $req = HTTP::Request->new( $method => $url );
+
+ #build headers
+ if($content){
+ $req->content($content);
+ $req->header('Content-Length', length($content));
+ }else{
+ $req->header('Content-Length', 0);
+ }
+
+ my $custom_headers = $self->{'_headers'} || {};
+ for my $header (keys %$custom_headers){
+ $req->header($header, $custom_headers->{$header});
+ }
+
+ for my $header (keys %$headers){
+ $req->header($header, $headers->{$header});
+ }
+
+ #prime LWP with ssl certfile if we have values
+ if($self->getCert){
+ carp "REST::Client exception: Certs defined but not using https" unless $url =~ /^https/;
+ croak "REST::Client exception: Cannot read cert and key file" unless -f $self->getCert && -f $self->getKey;
+
+ $ENV{'HTTPS_CERT_FILE'} = $self->getCert;
+ $ENV{'HTTPS_KEY_FILE'} = $self->getKey;
+ if(my $ca = $self->getCa){
+ croak "REST::Client exception: Cannot read CA file" unless -f $ca;
+ $ENV{'HTTPS_CA_FILE'} = $ca
+ }
+ }
+
+ #prime LWP with PKCS12 certificate if we have one
+ if($self->getPkcs12){
+ carp "REST::Client exception: PKCS12 cert defined but not using https" unless $url =~ /^https/;
+ croak "REST::Client exception: Cannot read PKCS12 cert" unless -f $self->getPkcs12;
+
+ $ENV{HTTPS_PKCS12_FILE} = $self->getPkcs12;
+ if($self->getPkcs12password){
+ $ENV{HTTPS_PKCS12_PASSWORD} = $self->getPkcs12password;
+ }
+ }
+
+ my $res = $self->getFollow ? $ua->request($req) : $ua->simple_request($req);
+ $IO::Socket::SSL::VERSION = $tmp_socket_ssl_version;
+
+ $self->{_res} = $res;
+
+ return $self;
+}
+
+=head2 Response Methods
+
+Use these methods to gather information about the last requset
+performed.
+
+=head3 responseCode ()
+
+Return the HTTP response code of the last request
+
+=cut
+
+sub responseCode {
+ my $self = shift;
+ return $self->{_res}->code;
+}
+
+=head3 responseStatusLine
+
+Return the HTTP response status in clear text of the last request
+
+=cut
+
+sub responseStatusLine {
+ my $self = shift;
+ return $self->{_res}->status_line;
+}
+
+=head3 responseBase
+
+Return the base URL of the last request
+
+=cut
+
+sub responseBase {
+ my $self = shift;
+ return $self->{_res}->base;
+}
+
+=head3 responseContent ()
+
+Return the response body content of the last request
+
+=cut
+
+sub responseContent {
+ my $self = shift;
+ return $self->{_res}->content;
+}
+
+=head3 responseHeaders()
+
+Returns a list of HTTP header names from the last response
+
+=cut
+
+sub responseHeaders {
+ my $self = shift;
+ return $self->{_res}->headers()->header_field_names();
+}
+
+=head3 responseHeader ( $header )
+
+Return a HTTP header from the last response
+
+=cut
+
+sub responseHeader {
+ my $self = shift;
+ my $header = shift;
+ croak "REST::Client exception: no header provided to responseHeader" unless $header;
+ return $self->{_res}->header($header);
+}
+
+=head3 responseXpath ()
+
+A convienience wrapper that returns a L<XML::LibXML> xpath context for the body content. Assumes the content is XML.
+
+=cut
+
+sub responseXpath {
+ my $self = shift;
+
+ require XML::LibXML;
+
+ my $xml= XML::LibXML->new();
+ $xml->load_ext_dtd(0);
+
+ if($self->responseHeader('Content-type') =~ /html/){
+ return XML::LibXML::XPathContext->new($xml->parse_html_string( $self->responseContent() ));
+ }else{
+ return XML::LibXML::XPathContext->new($xml->parse_string( $self->responseContent() ));
+ }
+}
+
+# Private methods
+
+sub _prepareURL {
+ my $self = shift;
+ my $url = shift;
+
+ my $host = $self->getHost;
+ if($host){
+ $url = '/'.$url unless $url =~ /^\//;
+ $url = $host . $url;
+ }
+ unless($url =~ /^\w+:\/\//){
+ $url = ($self->getCert ? 'https://' : 'http://') . $url;
+ }
+
+ return $url;
+}
+
+sub _buildUseragent {
+ my $self = shift;
+
+ return if $self->getUseragent();
+
+ my $ua = LWP::UserAgent->new;
+ $ua->agent("REST::Client/$VERSION");
+ $self->setUseragent($ua);
+
+ return;
+}
+
+sub _buildAccessors {
+ my $self = shift;
+
+ return if $self->can('setHost');
+
+ my @attributes = qw(Host Key Cert Ca Timeout Follow Useragent Pkcs12 Pkcs12password);
+
+ for my $attribute (@attributes){
+ my $set_method = "
+ sub {
+ my \$self = shift;
+ \$self->{'_config'}{lc('$attribute')} = shift;
+ return \$self->{'_config'}{lc('$attribute')};
+ }";
+
+ my $get_method = "
+ sub {
+ my \$self = shift;
+ return \$self->{'_config'}{lc('$attribute')};
+ }";
+
+
+ {
+ no strict 'refs';
+ *{'REST::Client::set'.$attribute} = eval $set_method ;
+ *{'REST::Client::get'.$attribute} = eval $get_method ;
+ }
+
+ }
+
+ return;
+}
+
+1;
+
+
+=head1 TODO
+
+Caching, content-type negotiation, readable handles for body content.
+
+=head1 AUTHOR
+
+Miles Crawford, E<lt>mcrawfor@cpan.orgE<gt>
+
+=head1 COPYRIGHT
+
+Copyright 2008 - 2010 by Miles Crawford.
+
+This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
+
+=cut
View
9 lib/WebService/Cmis/ACL.pm
@@ -59,7 +59,14 @@ return a string representation of this object
=cut
sub toString {
- return $_[0]->getId();
+ my $this = shift;
+
+ my @result = ();
+ foreach my $ace ($this->getEntries) {
+ push @result, $ace->toString;
+ }
+
+ return join("\n", @result);
}
=item addEntry($ace)
View
20 lib/WebService/Cmis/AtomFeed.pm
@@ -24,6 +24,7 @@ our $CMIS_XPATH_TITLE = new XML::LibXML::XPathExpression('./*[local-name() = "ti
our $CMIS_XPATH_UPDATED = new XML::LibXML::XPathExpression('./*[local-name() = "updated" and namespace-uri() ="'.ATOM_NS.'"]');
our $CMIS_XPATH_GENERATOR = new XML::LibXML::XPathExpression('./*[local-name() = "generator" and namespace-uri() ="'.ATOM_NS.'"]');
our $CMIS_XPATH_NUMITEMS = new XML::LibXML::XPathExpression('./*[local-name() = "numItems" and namespace-uri() ="'.CMISRA_NS.'"]');
+our $CMIS_XPATH_PAGESIZE = new XML::LibXML::XPathExpression('./*[local-name() = "itemsPerPage" and namespace-uri() ="'.OPENSEARCH_NS.'"]');
our $CMIS_XPATH_TOTALRESULTS = new XML::LibXML::XPathExpression('./*[local-name() = "totalResults" and namespace-uri() ="'.OPENSEARCH_NS.'"]');
=head1 METHODS
@@ -57,6 +58,7 @@ sub _initData {
undef $this->{updated};
undef $this->{generator};
undef $this->{totalResults};
+ undef $this->{pageSize};
}
=item DESTROY
@@ -309,6 +311,24 @@ sub getSize {
return $this->{totalResults};
}
+=item getPageSize -> $integer
+
+returns the size of a page in the result set. this should equal the maxItem value if set in a query
+
+=cut
+
+sub getPageSize {
+ my $this = shift;
+
+ unless (defined $this->{pageSize}) {
+ $this->{pageSize} =
+ $this->{xmlDoc}->documentElement->findvalue($CMIS_XPATH_PAGESIZE) ||
+ scalar(@{$this->_getPageEntries});
+ }
+
+ return $this->{pageSize};
+}
+
=item toString()
View
63 lib/WebService/Cmis/Property/DateTime.pm
@@ -38,12 +38,12 @@ sub parse {
if ($isoDate =~ /(\d\d\d\d)(?:-(\d\d)(?:-(\d\d))?)?(?:T(\d\d)(?::(\d\d)(?::(\d\d(?:\.\d+)?))?)?)?(Z|[-+]\d\d(?::\d\d)?)?/) {
my ($Y, $M, $D, $h, $m, $s, $tz) = ($1, $2 || 1, $3 || 1, $4 || 0, $5 || 0, $6 || 0, $7 || '');
- $M--;
- $Y -= 1900 if ($Y > 1900);
+ # strip milliseconds
+ $s =~ s/\.\d+$//;
- #print STDERR "parsing hour=$h\n";
+ $M--;
- return Time::Local::timegm($s, $m, $h, $D, $M, $Y);
+ return Time::Local::timegm($s, $m, $h, $D, $M, $Y).$tz;
}
# format does not match
@@ -61,39 +61,35 @@ sub unparse {
$value = $this->{value} if ref($this) && !defined $value;
- $value =~ s/[^\d]//g;
+ my $milliseconds;
+ if ($value =~ s/(\.\d+)$//) {
+ $milliseconds = $1;
+ }
return 'none' if !defined $value || $value eq '';
- my ($sec, $min, $hour, $day, $mon, $year, $wday, $yday) = gmtime($value);
+ my $tz;
+ if ($value =~ /^(\d+)(Z|[-+]\d\d(?::\d\d)?)?$/) {
+ $value = $1;
+ $tz = $2 || '';
+ } else {
+ return 'none';
+ }
+
+ my ($sec, $min, $hour, $day, $mon, $year, $wday, $yday, $isdst) = gmtime($value);
#print STDERR "unparsing hour=$hour\n";
+ #print STDERR "isdst=$isdst\n";
my $formatString = '$year-$mo-$dayT$hour:$min:$sec$isotz';
+ $formatString =~ s/\$m(illi)?seco?n?d?s?/sprintf('%.3u',$sec)/gei;
$formatString =~ s/\$seco?n?d?s?/sprintf('%.2u',$sec)/gei;
$formatString =~ s/\$minu?t?e?s?/sprintf('%.2u',$min)/gei;
$formatString =~ s/\$hour?s?/sprintf('%.2u',$hour)/gei;
$formatString =~ s/\$day/sprintf('%.2u',$day)/gei;
$formatString =~ s/\$mo/sprintf('%.2u',$mon+1)/gei;
$formatString =~ s/\$year?/sprintf('%.4u',$year + 1900)/gei;
-
- if ($formatString =~ /\$isotz/) {
-
- # time zone designator (+hh:mm or -hh:mm)
- unless (defined $TZSTRING) {
- my $offset = _tzOffset();
- my $sign = ($offset < 0) ? '-' : '+';
- $offset = abs($offset);
- my $hours = int($offset / 3600);
- my $mins = int(($offset - $hours * 3600) / 60);
- if ($hours || $mins) {
- $TZSTRING = sprintf("$sign%02d:%02d", $hours, $mins);
- } else {
- $TZSTRING = 'Z';
- }
- }
- $formatString =~ s/\$isotz/$TZSTRING/g;
- }
+ $formatString =~ s/\$isotz/$tz/g;
return $formatString;
}
@@ -103,6 +99,25 @@ sub unparse {
# any copyright and puts his contribution to this module in the public
# domain."
# Note that unit tests rely on this function being here.
+sub getTZSTRING {
+
+ # time zone designator (+hh:mm or -hh:mm)
+ unless (defined $TZSTRING) {
+ my $offset = _tzOffset();
+ my $sign = ($offset < 0) ? '-' : '+';
+ $offset = abs($offset);
+ my $hours = int($offset / 3600);
+ my $mins = int(($offset - $hours * 3600) / 60);
+ if ($hours || $mins) {
+ $TZSTRING = sprintf("$sign%02d:%02d", $hours, $mins);
+ } else {
+ $TZSTRING = 'Z';
+ }
+ }
+
+ return $TZSTRING;
+}
+
sub _tzOffset {
my $time = time();
my @l = localtime($time);
View
3  lib/WebService/Cmis/Repository.pm
@@ -964,7 +964,7 @@ sub query {
my $result = $this->{client}->post($queryUrl, $xmlDoc->toString, CMIS_QUERY_TYPE);
# return the result set
- require WebService::Cmis::AtomFeed;
+ require WebService::Cmis::AtomFeed::Objects;
return new WebService::Cmis::AtomFeed::Objects(repository=>$this, xmlDoc=>$result);
}
@@ -983,7 +983,6 @@ sub _getQueryXmlDoc {
my $xmlDoc = new XML::LibXML::Document('1.0', 'UTF-8');
my $queryElement = $xmlDoc->createElementNS(CMIS_NS, "query");
- #$queryElement->addChild($xmlDoc->createAttribute('xmlns', CMIS_NS));
$xmlDoc->setDocumentElement($queryElement);
View
7 t/01-basics.t
@@ -0,0 +1,7 @@
+#!perl -T
+
+use WebService::Cmis::Test::Basics;
+
+Test::Class->runtests;
+
+1;
View
7 t/02-client.t
@@ -0,0 +1,7 @@
+#!perl -T
+
+use WebService::Cmis::Test::Client;
+
+Test::Class->runtests;
+
+1;
View
7 t/03-object.t
@@ -0,0 +1,7 @@
+#!perl -T
+
+use WebService::Cmis::Test::Object;
+
+Test::Class->runtests;
+
+1;
View
7 t/04-atom-feed.t
@@ -0,0 +1,7 @@
+#!perl -T
+
+use WebService::Cmis::Test::AtomFeed;
+
+Test::Class->runtests;
+
+1;
View
7 t/05-object-type.t
@@ -0,0 +1,7 @@
+#!perl -T
+
+use WebService::Cmis::Test::ObjectType;
+
+Test::Class->runtests;
+
+1;
View
7 t/06-property.t
@@ -0,0 +1,7 @@
+#!perl -T
+
+use WebService::Cmis::Test::Property;
+
+Test::Class->runtests;
+
+1;
View
7 t/07-repository.t
@@ -0,0 +1,7 @@
+#!perl -T
+
+use WebService::Cmis::Test::Repository;
+
+Test::Class->runtests;
+
+1;
View
7 t/08-acl.t
@@ -0,0 +1,7 @@
+#!perl -T
+
+use WebService::Cmis::Test::ACL;
+
+Test::Class->runtests;
+
+1;
View
7 t/09-folder.t
@@ -0,0 +1,7 @@
+#!perl -T
+
+use WebService::Cmis::Test::Folder;
+
+Test::Class->runtests;
+
+1;
View
7 t/10-document.t
@@ -0,0 +1,7 @@
+#!perl -T
+
+use WebService::Cmis::Test::Document;
+
+Test::Class->runtests;
+
+1;
View
17 t/AlfrescoDemoSite.pm
@@ -1,17 +0,0 @@
-# Tests using a public test alfresco
-package AlfrescoPreview;
-
-use CmisBase;
-our @ISA = (CmisBase);
-
-sub new {
- my $class = shift;
-
- return $class->SUPER::new({
- url => "http://cmis.alfresco.com/service/cmis",
- user => "admin",
- password => "admin",
- });
-}
-
-1;
View
17 t/AlfrescoLocalhost.pm
@@ -1,17 +0,0 @@
-# Tests using an alfresco installed on localhost
-package AlfrescoLocalhost;
-
-use CmisBase;
-our @ISA = (CmisBase);
-
-sub new {
- my $class = shift;
-
- return $class->SUPER::new({
- url => "http://alfresco/alfresco/service/cmis",
- user => "admin",
- password => "admin",
- });
-}
-
-1;
View
0  t/Client.pm
No changes.
View
2,333 t/CmisBase.pm
@@ -1,2333 +0,0 @@
-# Base tests for Cmis tests
-package CmisBase;
-
-use strict;
-use warnings;
-binmode(STDERR, ":utf8");
-binmode(STDOUT, ":utf8");
-
-use Unit::TestCase;
-use WebService::Cmis qw(:collections :utils :relations :namespaces :contenttypes);
-use XML::LibXML qw(:libxml);
-use Exporter qw(import);
-use Cache::FileCache ();
-use File::Temp ();
-use Error qw(:try);
-use WebService::Cmis::ClientException;
-use WebService::Cmis::NotSupportedException;
-
-our @ISA = qw( Exporter Unit::TestCase );
-our @EXPORT;
-
-foreach my $symbol (keys %CmisBase::) {
- next unless $symbol =~ /^test_/;
- push @EXPORT, $symbol;
- #print "exporting $symbol\n";
-}
-
-sub new {
- my $class = shift;
- my $connection = shift;
- my $this = $class->SUPER::new(@_);
-
- die "ERROR: no connection" unless defined $connection;
- die "ERROR: no url in connection" unless defined $connection->{url};
- #print STDERR "connection=$connection->{url}\n";
-
- $this->{connection} = $connection;
- return $this;
-}
-
-sub DESTROY {
- my $this = shift;
-
- #print STDERR "DESTROY\n";
-
- foreach my $key (keys %{$this->{testDocuments}}) {
- $this->deleteTestDocument($key);;
- }
-
- foreach my $key (keys %{$this->{testFolders}}) {
- $this->deleteTestFolder($key);;
- }
-}
-
-sub saveFile {
- my ($name, $text) = @_;
- my $FILE;
- unless (open($FILE, '>', $name)) {
- die "Can't create file $name - $!\n";
- }
- print $FILE $text;
- close($FILE);
-}
-
-sub getClient {
- my $this = shift;
-
- unless (defined $this->{client}) {
- my $tempDir = File::Temp::tempdir(CLEANUP => 1);
- #print STDERR "temporary cache in $tempDir\n";
- my $cache = Cache::FileCache->new({
- cache_root => $tempDir
- }
- );
- $this->{client} = WebService::Cmis::getClient(
- %{$this->{connection}},
- #cache => $cache
- );
- }
-
- return $this->{client};
-}
-
-sub getRepository {
- return $_[0]->getClient->getRepository;
-}
-
-sub getTestFolderName {
- my $this = shift;
- my $key = shift;
-
- $key ||= 'default';
- $this->{testFolderNames} = {} unless defined $this->{testFolderNames};
-
- unless (defined $this->{testFolderNames}{$key}) {
- $this->{testFolderNames}{$key} = "WebService_Cmis_TestFolder_".$key."_".time;
- }
-
- return $this->{testFolderNames}{$key};
-}
-
-sub deleteTestFolder {
- my $this = shift;
- my $key = shift;
-
- $key ||= 'default';
- $this->{testFolders} = {} unless defined $this->{testFolders};
-
- #print STDERR "called deleteTestFolder\n";
-
-
- if (defined $this->{testFolders}{$key}) {
- $this->{testFolders}{$key}->delete;
- }
-
- delete $this->{testFolders}{$key};
-}
-
-sub getTestFolder {
- my $this = shift;
- my $key = shift;
-
- $key ||= 'default';
- $this->{testFolders} = {} unless defined $this->{testFolders};
-
- unless (defined $this->{testFolders}{$key}) {
- my $name = $this->getTestFolderName($key);
- #print STDERR "creating a test folder $name\n";
- $this->assert_matches('^WebService_Cmis_.*$', $name);
-
- my $repo = $this->getRepository;
- my $root = $repo->getRootFolder;
-
- #print STDERR "creating folder /$name\n";
- $this->{testFolders}{$key} = $root->createFolder($name, summary=>"this is a test folder used by WebService::Cmis' testsuite");
- if ($this->{testFolders}{$key}->getId eq $root->getId) {
- print STDERR "ERROR: don't use root as test folder\n\n";
- exit; #emergency
- }
-
- $this->assert_not_null($this->{testFolders}{$key}, "ERROR: can't create test folder $name\n\n");
- }
-
- return $this->{testFolders}{$key};
-}
-
-sub deleteTestDocument {
- my $this = shift;
- my $key = shift;
-
- $key ||= 'default';
- $this->{testDocuments} = {} unless defined $this->{testDocuments};
-
- try {
- if (defined $this->{testDocuments}{$key}) {
- #print STDERR "deleting test document\n";
- my $pwc = $this->{testDocuments}{$key}->getPrivateWorkingCopy;
- $pwc->cancelCheckOut if $pwc;
- $this->{testDocuments}{$key}->delete;
- delete $this->{testDocuments}{$key};
- }
- } catch WebService::Cmis::ClientException with {
- my $error = shift;
- #print STDERR "ERROR in deleteTestDocument: $error\n";
- # ignore
- };
-}
-
-sub getTestDocument {
- my $this = shift;
- my $key = shift;
-
- $key ||= 'default';
-
- #print STDERR "called getTestDocument($key)\n";
- $this->{testDocuments} = {} unless defined $this->{testDocuments};
-
- unless (defined $this->{testDocuments}{$key}) {
- my $folder = $this->getTestFolder($key);
- my $repo = $this->getRepository;
-
- my $testFile = "./CmisPlugin/data/free.jpg";
- $this->assert(-e $testFile, "ERROR: testFile=$testFile not found\n\n");
-
- # first delete it if it exists
- my $path = "/".$this->getTestFolderName($key)."/free.jpg";
- #print STDERR "path=$path\n";
-
- my $document = $repo->getObjectByPath($path);
- return $document if defined $document;
-
- #print STDERR "uploading $testFile to $path\n";
- $document = $folder->createDocument(
- "free.jpg",
- contentFile=>$testFile
- );
-
- $this->assert_not_null($document, "ERROR: can't upload document\n\n");
-
- $this->{testDocuments}{$key} = $document;
- }
-
- return $this->{testDocuments}{$key};
-}
-
-sub test_getClient {
- my $this = shift;
-
- my $client = WebService::Cmis::getClient;
- $this->assert_str_equals( "CMIS client connection to ", $client->toString );
-}
-
-sub test_getClient_2 {
- my $this = shift;
-
- my $client = $this->getClient;
- my $url = $this->{connection}{url};
-
- $this->assert_str_equals( "CMIS client connection to $url", $client->toString );
-}
-
-sub test_repository_ClientException_404 {
- my $this = shift;
-
- my $client = $this->getClient;
-
- my $doc;
- try {
- $doc = $client->get("fooBar");
- } catch WebService::Cmis::ClientException with {
- my $error = shift;
- $this->assert(ref($error));
- $this->assert_str_equals("WebService::Cmis::ClientException", ref($error));
- $this->assert_matches("^404 Not Found", $error);
- };
-
- $this->assert_null($doc);
-}
-
-sub test_repository_ClientException_401 {
- my $this = shift;
-
- my $badClient = WebService::Cmis::getClient(
- %{$this->{connection}},
- user => "foo",
- password => "bar",
- );
-
- my $result;
- try {
- $result = $badClient->get;
- } catch WebService::Cmis::ClientException with {
- my $error = shift;
- $this->assert(ref($error));
- $this->assert_str_equals("WebService::Cmis::ClientException", ref($error));
- $this->assert_matches("^401 Unauthorized", $error);
- };
-
- $this->assert_null($result);
-}
-
-sub test_repository_ServerExceptio_500 {
- my $this = shift;
-
- my $badClient = WebService::Cmis::getClient(
- url => "http://doesnotexist.local.foobar:8080/alfresco/service/cmis",
- user => "foo",
- password => "bar",
- );
-
- my $result;
- try {
- $result = $badClient->get;
- } catch WebService::Cmis::ServerException with {
- my $error = shift;
- $this->assert(ref($error));
- $this->assert_str_equals("WebService::Cmis::ServerException", ref($error));
- #print STDERR "error=$error\n";
- $this->assert_matches("^500 Can't connect", $error);
- };
-
- $this->assert_null($result);
-
-}
-
-sub test_repository_raw {
- my $this = shift;
-
- my $client = $this->getClient;
- my $doc = $client->get;
- $this->assert_matches('^<\?xml version="1.0"( encoding="(utf|UTF)-8")?\?>.*', $doc->toString);
-}
-
-sub test_Client_getRepositories {
- my $this = shift;
-
- my $client = $this->getClient;
- my $repositories = $client->getRepositories;
-
- my $nrRepos = scalar(keys %$repositories);
- #print STDERR "found $nrRepos repository(ies)\n";
- $this->assert(scalar($nrRepos) > 0, "ERROR: can't find at least one repository\n\n");
-
- foreach my $repo (values %$repositories) {
- my $info = $repo->getRepositoryInfo;
-
- # SMELL: what's the absolute minimum?
- foreach my $key qw(repositoryName repositoryId) {
- #print STDERR "$key=$info->{$key}\n";
- $this->assert_not_null($info->{$key});
- }
- }
-}
-
-sub test_Client_getDefaultRepository {
- my $this = shift;
-
- my $repo = $this->getRepository;
-
- $this->assert_not_null($repo, "ERROR: can't find default repository\n\n");
- $this->assert_str_equals("WebService::Cmis::Repository", ref($repo));
-}
-
-sub test_Repository_getRepositoryName {
- my $this = shift;
-
- my $repo = $this->getRepository;
- my $name = $repo->getRepositoryName;
-
- #print STDERR "name=$name\n";
- $this->assert_not_null($name);
-}
-
-sub test_Repository_getRepositoryId {
- my $this = shift;
-
- my $repo = $this->getRepository;
- my $id1 = $repo->getRepositoryId;
-
- #print STDERR "id1=$id1\n";
- $this->assert_not_null($id1);
-
- my $repo2 = $this->getRepository($id1);
- my $id2 = $repo2->getRepositoryId;
- $this->assert_not_null($id2);
- #print STDERR "id2=$id2\n";
-
- $this->assert_str_equals($id1, $id2);
-}
-
-sub test_Repository_getRepository_unknown {
- my $this = shift;
- my $client = $this->getClient;
- my $repo = $client->getRepository("foobarbaz");
- $this->assert_null($repo);
-}
-
-sub test_Repository_getRepositoryInfo {
- my $this = shift;
-
- my $repo = $this->getRepository;
-
- my $info = $repo->getRepositoryInfo;
-
- $this->assert_null($info->{capabilities}, "ERROR: capabilities should not be listed in repository info\n\n");
- $this->assert_null($info->{aclCapability}, "ERROR: aclCapabilities should not be listed in repository info\n\n" );
-
- #print STDERR "repositoryInfo :\n".join("\n", map(" ".$_.'='.$info->{$_}, keys %$info))."\n";
-
- # include
- # SMELL: what's the absolute minimum?
- foreach my $key qw(repositoryName repositoryId) {
- #print STDERR "$key=$info->{$key}\n";
- $this->assert_not_null($info->{$key});
- }
-}
-
-sub test_Repository_getCapabilities {
- my $this = shift;
-
- my $repo = $this->getRepository;
-
- my $caps = $repo->getCapabilities;
-
- # no capabilities at all
- return unless scalar keys %$caps;
-
- #print STDERR "caps:\n".join("\n", map(" ".$_.'='.$caps->{$_}, keys %$caps))."\n";
-
- foreach my $key qw( Renditions Multifiling ContentStreamUpdatability Unfiling
- GetFolderTree AllVersionsSearchable Changes Join ACL Query PWCSearchable
- PWCUpdatable VersionSpecificFiling GetDescendants) {
- my $val = $caps->{$key};
- $this->assert_not_null($val, "ERROR: $key capability not found\n\n");
- $this->assert_matches('^(0|1)$', $val);
- }
-}
-
-sub test_Repository_getSupportedPermissions {
- my $this = shift;
-
- my $repo = $this->getRepository;
- my $perms;
- my $exceptionOk = 0;
-
- try {
- $perms = $repo->getSupportedPermissions;
- } catch WebService::Cmis::NotSupportedException with {
- my $error = shift;
- $this->assert_str_equals("This repository does not support ACLs", $error);
- $exceptionOk = 1;
- };
- return if $exceptionOk;
-
- #print STDERR "perms='$perms'\n";
-
- $this->assert_matches('^(basic|repository|both)$', $perms);
-}
-
-sub test_Repository_getPermissionDefinitions {
- my $this = shift;
-
- my $repo = $this->getRepository;
-
- my $permDefs;
- my $exceptionOk = 0;
-
- try {
- $permDefs = $repo->getPermissionDefinitions;
- } catch WebService::Cmis::NotSupportedException with {
- my $error = shift;
- $this->assert_str_equals("This repository does not support ACLs", $error);
- $exceptionOk = 1;
- };
- return if $exceptionOk;
-
- $this->assert_not_null($permDefs, "ERROR: no permission definitions found\n");
-
- my $foundCmisRead;
- my $foundCmisWrite;
- foreach my $key (keys %$permDefs) {
- #print STDERR "$key = $permDefs->{$key}\n";# if $key =~ /^cmis:/;
- $this->assert_matches('{http://|cmis:', $key);
-
- # SMELL: nuxeo calls the basic cmis permissions "basic"... oh well
- $foundCmisRead = 1 if $key =~ /cmis:(read|basic)/;
- $foundCmisWrite = 1 if $key =~ /cmis:(write|basic)/;
- }
- $this->assert_not_null($foundCmisRead, "ERROR: cmis:read not found in permission definition\n\n");
- $this->assert_not_null($foundCmisWrite, "ERROR: cmis:write not found in permission definition\n\n");
-}
-
-sub test_Repository_getPermissionMap {
- my $this = shift;
-
- my $repo = $this->getRepository;
- my $permMap;
- my $exceptionOk = 0;
-
- try {
- $permMap = $repo->getPermissionMap;
- } catch WebService::Cmis::NotSupportedException with {
- my $error = shift;
- $this->assert_str_equals("This repository does not support ACLs", $error);
- $exceptionOk = 1;
- };
- return if $exceptionOk;
-
- $this->assert_not_null($permMap, "ERRROR: no permission map found\n\n");
-
- #print STDERR "perms=".join(' ', keys %$permMap)."\n";
- foreach my $perm (keys %$permMap) {
- #print STDERR "To do this: $perm, you must have one of permissions ".join(', ', @{$permMap->{$perm}})."\n";
- }
-
- # SMELL: which of these are standard, which are nice to have?
- foreach my $perm qw(canSetContent.Document canDeleteTree.Folder
- canAddPolicy.Object canAddPolicy.Policy canGetChildren.Folder
- canGetAllVersions.VersionSeries canCancelCheckout.Document canApplyACL.Object
- canMove.Target canGetDescendents.Folder canRemovePolicy.Policy
- canCreateFolder.Folder canGetParents.Folder canGetFolderParent.Object
- canGetAppliedPolicies.Object canUpdateProperties.Object canMove.Object
- canDeleteContent.Document canCheckout.Document canDelete.Object
- canRemoveFromFolder.Object canCreateDocument.Folder canGetProperties.Object
- canAddToFolder.Folder canRemovePolicy.Object canCheckin.Document
- canAddToFolder.Object canGetACL.Object canViewContent.Object) {
-
- $this->assert_not_null($permMap->{$perm}, "ERROR: permission $perm not defined\n\n");
- }
-}
-
-sub test_Repository_getPropagation {
- my $this = shift;
-
- my $repo = $this->getRepository;
- my $prop;
- my $exceptionOk = 0;
-
- try {
- $prop = $repo->getPropagation;
- } catch WebService::Cmis::NotSupportedException with {
- my $error = shift;
- $this->assert_str_equals("This repository does not support ACLs", $error);
- $exceptionOk = 1;
- };
- return if $exceptionOk;
-
- #print STDERR "prop=$prop\n";
- $this->assert_matches('objectonly|propagate|repositorydetermined', $prop);
-}
-
-sub test_Repository_getRootFolderId {
- my $this = shift;
-
- my $repo = $this->getRepository;
-
- my $rootFolderId = $repo->getRepositoryInfo->{'rootFolderId'};
-
- #print STDERR "rootFolderId=$rootFolderId\n";
-
- $this->assert_not_null($rootFolderId, "ERROR: no rootFolder found\n\n");
-}
-
-sub test_Repository_getUriTemplates {
- my $this = shift;
-
- my $repo = $this->getRepository;
-
- my $uriTemplates = $repo->getUriTemplates;
-
- #print STDERR "types=".join(' ', keys %$uriTemplates)."\n";
-
- foreach my $type qw(objectbypath query objectbyid typebyid) {
- $this->assert_not_null($uriTemplates->{$type}, "ERROR: no uri template for $type\n\n");
- #print "type=$type, mediatype=$uriTemplates->{$type}{mediatype}, template=$uriTemplates->{$type}{template}\n";
- }
-}
-
-sub test_Repository_getUriTemplate {
- my $this = shift;
-
- my $repo = $this->getRepository;
-
- foreach my $type qw(objectbypath query objectbyid typebyid) {
- my $template = $repo->getUriTemplate($type);
- $this->assert_not_null($template, "ERROR: no uri template for $type\n\n");
- }
-}
-
-sub test_Repository_getCollectionLink {
- my $this = shift;
-
- my $repo = $this->getRepository;
-
- my $href = $this->{connection}{url};
- $href =~ s/^(http:\/\/[^\/]+?):80\//$1\//g; # remove bogus :80 port
-
- # UNFILED_COLL not supported by all repositories;
- # SMELL: test for unfiled capability
- foreach my $collectionType (QUERY_COLL, TYPES_COLL, CHECKED_OUT_COLL, ROOT_COLL) {
- my $link = $repo->getCollectionLink($collectionType);
- #print "type=$collectionType, link=".($link||'')."\n";
- $this->assert_not_null($link);
- $link =~ s/^(http:\/\/[^\/]+?):80\//$1\//g; # remove bogus :80 port
- $this->assert_matches("^$href", $link);
- }
-}
-
-sub test_Repository_getCollection {
- my $this = shift;
-
- my $repo = $this->getRepository;
-
- # QUERY_COLL
- my $error;
-
- try {
- $repo->getCollection(QUERY_COLL);
- } catch Error::Simple with {
- $error = shift;
- $this->assert_matches('^query collection not supported', $error);
- };
- $this->assert_not_null($error);
-
- # TYPES_COLL
- my $typeDefs = $repo->getCollection(TYPES_COLL);
- $this->assert_str_equals('WebService::Cmis::AtomFeed::ObjectTypes', ref($typeDefs));
- while (my $typeDef = $typeDefs->getNext) {
- $this->assert_str_equals('WebService::Cmis::ObjectType', ref($typeDef));
- #print "typeDef=".$typeDef->toString."\n";
- }
-
- # other collections
- # SMELL: nuxeo throws a 405 on CHECKED_OUT
- foreach my $collectionType (CHECKED_OUT_COLL, UNFILED_COLL, ROOT_COLL) {
- my $result = $repo->getCollection($collectionType);
- #print STDERR "collectionType=$collectionType, result=$result, nrObjects=".$result->getSize."\n";
- $this->assert_not_null($result);
- }
-}
-
-sub test_Repository_getTypeDefinition {
- my $this = shift;
-
- my $repo = $this->getRepository;
- my $objectType = $repo->getTypeDefinition('cmis:folder');
-
- #print "id=".$objectType->getId.", displayName=".$objectType->getDisplayName.", description=".$objectType->getDescription.", link=".$objectType->getLink."\n";
-
- $this->assert_not_null($objectType->getId);
- $this->assert_not_null($objectType->getDisplayName);
- $this->assert_not_null($objectType->getQueryName);
- $this->assert_not_null($objectType->{xmlDoc});
-
- $this->assert_str_equals('cmis:folder', $objectType->toString);
-}
-
-
-sub test_ObjectType {
- my $this = shift;
-
- my $repo = $this->getRepository;
-
- my $typeDefs = $repo->getTypeDefinitions;
- $this->assert_str_equals('WebService::Cmis::AtomFeed::ObjectTypes', ref($typeDefs));
-
- while (my $objectType = $typeDefs->getNext) {
- $this->assert_str_equals('WebService::Cmis::ObjectType', ref($objectType));
-
- #print STDERR "attributes=".join(", ", keys %{$objectType->getAttributes})."\n";
-
- my $id = $objectType->getId;
- my $displayName = $objectType->getDisplayName;
- my $description = $objectType->getDescription;
- my $link = $objectType->getLink;
- my $baseId = $objectType->getBaseId;
- my $localName = $objectType->getLocalName;
- my $localNamespace = $objectType->getLocalNamespace;
- my $queryName = $objectType->getQueryName;
- my $contentStreamAllowed = $objectType->getContentStreamAllowed || '';
-
- my $isCreatable = $objectType->isCreatable;
- my $isFileable = $objectType->isFileable;
- my $isQueryable = $objectType->isQueryable;
- my $isFulltextIndexed = $objectType->isFulltextIndexed;
- my $isIncludedInSupertypeQuery = $objectType->isIncludedInSupertypeQuery;
- my $isControllablePolicy = $objectType->isControllablePolicy;
- my $isControllableACL = $objectType->isControllableACL;
- my $isVersionable = $objectType->isVersionable;
-
-# print STDERR "id=$id ($objectType->{attributes}{id})\n";
-# print STDERR " displayName=$displayName\n";
-# print STDERR " description=$description\n";
-# print STDERR " link=$link\n";
-# print STDERR " baseId=$baseId\n";
-# print STDERR " localName=$localName\n";
-# print STDERR " localNamespace=$localNamespace\n";
-# print STDERR " queryName=$queryName\n";
-# print STDERR " contentStreamAllowed=$contentStreamAllowed\n";
-#
-# print STDERR " isCreatable=$isCreatable\n";
-# print STDERR " isFileable=$isFileable\n";
-# print STDERR " isQueryable=$isQueryable\n";
-# print STDERR " isFulltextIndexed=$isFulltextIndexed\n";
-# print STDERR " isIncludedInSupertypeQuery=$isIncludedInSupertypeQuery\n";
-# print STDERR " isControllablePolicy=$isControllablePolicy\n";
-# print STDERR " isControllableACL=$isControllableACL\n";
-# print STDERR " isVersionable=$isVersionable\n";
-
- $objectType->reload;
- #print STDERR "2 - id=".$objectType->getId.", displayName=".$objectType->getDisplayName.", description=".$objectType->getDescription.", link=".$objectType->getLink."\n";
-
- $this->assert_str_equals($id, $objectType->getId);
- $this->assert_str_equals($displayName, $objectType->getDisplayName);
- $this->assert_str_equals($description, $objectType->getDescription);
- $this->assert_str_equals($link, $objectType->getLink);
- $this->assert_str_equals($baseId, $objectType->getBaseId);
- $this->assert_str_equals($localName, $objectType->getLocalName);
- $this->assert_str_equals($localNamespace, $objectType->getLocalNamespace);
- $this->assert_str_equals($queryName, $objectType->getQueryName);
- $this->assert_str_equals($contentStreamAllowed, ($objectType->getContentStreamAllowed||''));
-
- $this->assert_str_equals($isCreatable, $objectType->isCreatable);
- $this->assert_str_equals($isFileable, $objectType->isFileable);
- $this->assert_str_equals($isQueryable, $objectType->isQueryable);
- $this->assert_str_equals($isFulltextIndexed, $objectType->isFulltextIndexed);
- $this->assert_str_equals($isIncludedInSupertypeQuery, $objectType->isIncludedInSupertypeQuery);
- $this->assert_str_equals($isControllablePolicy, $objectType->isControllablePolicy);
- $this->assert_str_equals($isControllableACL, $objectType->isControllableACL);
- $this->assert_str_equals($isVersionable, $objectType->isVersionable);
- }
-}
-
-sub test_PropertyType {
- my $this = shift;
-
- my $repo = $this->getRepository;
-
- my $typeDefs = $repo->getTypeDefinitions;
- $this->assert_str_equals('WebService::Cmis::AtomFeed::ObjectTypes', ref($typeDefs));
-
- while(my $objectType = $typeDefs->getNext) {
-
- # type attributes
- #print STDERR "### objectType=".$objectType->toString."\n";
- my $objAttrs = $objectType->getAttributes;
- $this->assert_not_null($objAttrs);
-
- foreach my $key (keys %$objAttrs) {
- #print STDERR " * $key=$objAttrs->{$key}\n";
- }
-
- # type property definitions
- my $propDefs = $objectType->getPropertyDefinitions;
- $this->assert_not_null($propDefs);
-
- foreach my $propDef (values %$propDefs) {
- #print STDERR "|-> propDef=".$propDef->toString."\n";
-
- my $attrs = $propDef->getAttributes;
- $this->assert_not_null($attrs);
- foreach my $key (keys %$attrs) {
- #print STDERR " $key=$attrs->{$key}\n";
- }
- }
- }
-}
-
-sub test_Cmis_collectionTypes {
- my $this = shift;
-
- $this->assert_equals(QUERY_COLL, "query");
- $this->assert_equals(TYPES_COLL, "types");
- $this->assert_equals(CHECKED_OUT_COLL, "checkedout");
- $this->assert_equals(UNFILED_COLL, "unfiled");
- $this->assert_equals(ROOT_COLL, "root");
-}
-
-sub test_PropertyBoolean_parse {
- my $this = shift;
-
- require WebService::Cmis::Property;
- $this->assert_num_equals(0, WebService::Cmis::Property::parseBoolean(''));
- $this->assert_num_equals(0, WebService::Cmis::Property::parseBoolean(' '));
- $this->assert_num_equals(1, WebService::Cmis::Property::parseBoolean('x'));
- $this->assert_num_equals(0, WebService::Cmis::Property::parseBoolean(0));
- $this->assert_num_equals(1, WebService::Cmis::Property::parseBoolean(1));
- $this->assert_num_equals(0, WebService::Cmis::Property::parseBoolean('0')); # argh
- $this->assert_num_equals(1, WebService::Cmis::Property::parseBoolean('1'));
- $this->assert_num_equals(1, WebService::Cmis::Property::parseBoolean('on'));
- $this->assert_num_equals(1, WebService::Cmis::Property::parseBoolean('ON'));
- $this->assert_num_equals(0, WebService::Cmis::Property::parseBoolean('off'));
- $this->assert_num_equals(0, WebService::Cmis::Property::parseBoolean('OFF'));
- $this->assert_num_equals(1, WebService::Cmis::Property::parseBoolean('true'));
- $this->assert_num_equals(1, WebService::Cmis::Property::parseBoolean('True'));
- $this->assert_num_equals(1, WebService::Cmis::Property::parseBoolean('TRUE'));
- $this->assert_num_equals(0, WebService::Cmis::Property::parseBoolean('false'));
- $this->assert_num_equals(0, WebService::Cmis::Property::parseBoolean('False'));
- $this->assert_num_equals(0, WebService::Cmis::Property::parseBoolean('False'));
- $this->assert_num_equals(1, WebService::Cmis::Property::parseBoolean('yes'));
- $this->assert_num_equals(0, WebService::Cmis::Property::parseBoolean('no'));
-}
-
-sub test_PropertyBoolean_unparse {
- my $this = shift;
-
- require WebService::Cmis::Property;
-
- $this->assert_str_equals('false', WebService::Cmis::Property::formatBoolean(0));
- $this->assert_str_equals('false', WebService::Cmis::Property::formatBoolean('0'));
- $this->assert_str_equals('true', WebService::Cmis::Property::formatBoolean('1'));
- $this->assert_str_equals('true', WebService::Cmis::Property::formatBoolean(1));
- $this->assert_str_equals('foobar', WebService::Cmis::Property::formatBoolean('foobar'));
- $this->assert_str_equals('none', WebService::Cmis::Property::formatBoolean());
-}
-
-sub test_PropertyId_parse {
- my $this = shift;
-
- require WebService::Cmis::Property;
- $this->assert_str_equals('123', WebService::Cmis::Property::parseId('123'));
- $this->assert_num_equals(123, WebService::Cmis::Property::parseId(123));
-}
-
-sub test_PropertyInteger_parse {
- my $this = shift;
-
- require WebService::Cmis::Property;
- $this->assert_num_equals(123, WebService::Cmis::Property::parseInteger(123));
- $this->assert_num_equals(123, WebService::Cmis::Property::parseInteger('123 '));
- $this->assert_num_equals(123, WebService::Cmis::Property::parseInteger(123));
- $this->assert_num_equals(123, WebService::Cmis::Property::parseInteger(123.456));
-}
-
-sub test_PropertyDecimal_parse {
- my $this = shift;
-
- require WebService::Cmis::Property;
- $this->assert_num_equals(123.456, WebService::Cmis::Property::parseDecimal(123.456, 'propertyDecimal'));
- $this->assert_num_equals(123.456, WebService::Cmis::Property::parseDecimal('123.456 foobar', 'propertyDecimal'));
-}
-
-sub test_Property_parseDateTime {
- my $this = shift;
-
- require WebService::Cmis::Property;
-
- $this->assert_num_equals(1295363154, WebService::Cmis::Property::parseDateTime('2011-01-18T15:05:54.951+01:00'));
- $this->assert_num_equals(1295363154, WebService::Cmis::Property::parseDateTime('foo 2011-01-18T15:05:54.951+01:00 bar'));
- $this->assert_null(WebService::Cmis::Property::DateTime->parse('foo'));
-}
-
-sub test_Property_parseDateTime_self {
- my $this = shift;
-
- require WebService::Cmis::Property;
-
- my $testDateString = "2011-01-25T13:22:28+01:00";
- my $epochSeconds = WebService::Cmis::Property::parseDateTime($testDateString);
- #print STDERR "epochSeconds=$epochSeconds\n";
-
- my $dateString = WebService::Cmis::Property::formatDateTime($epochSeconds);
- #print STDERR "dateString=$dateString\n";
-
- $this->assert_str_equals($testDateString, $dateString);
-}
-
-sub test_Property_formatDateTime {
- my $this = shift;
-
- require WebService::Cmis::Property;
-
- $this->assert_str_equals('2011-01-18T15:05:54+01:00', WebService::Cmis::Property::formatDateTime(1295363154));
- $this->assert_str_equals('none', WebService::Cmis::Property::formatDateTime('foo'));
- $this->assert_str_equals('1970-01-01T00:00:00+01:00', WebService::Cmis::Property::formatDateTime(0));
-}
-
-sub test_Object_getProperties {
- my $this = shift;
-
- my $repo = $this->getRepository;
- my $obj = $repo->getRootFolder;
-
- my $props = $obj->getProperties;
- #print STDERR "props:\n".join("\n", map(" ".$_->toString, values %$props))."\n";
-
- $this->assert_not_null($props->{"cmis:baseTypeId"}, "ERROR: no baseTypeId found\n\n");
- $this->assert_not_null($props->{"cmis:objectId"}, "ERROR: no objectId found\n\n");
- $this->assert_not_null($props->{"cmis:name"}, "ERROR: no name found\n\n");
-
- foreach my $key (sort keys %$props) {
- my $val = $props->{$key}->getValue || '';
- #print STDERR "$key = $val\n";
- }
-}
-
-sub test_Object_getProperty {
- my $this = shift;
-
- require WebService::Cmis::Object;
-
- my $repo = $this->getRepository;
- my $obj = $repo->getRootFolder;
- my $props = $obj->getProperties;
- my $name = $obj->getProperty("cmis:name");
- #print STDERR "name=$name\n";
- $this->assert_str_equals($props->{"cmis:name"}->getValue, $name);
-}
-
-sub test_Object_getPropertiesFiltered {
- my $this = shift;
-
- require WebService::Cmis::Object;
- my $repo = $this->getRepository;
-
- # SMELL: the root folder doesn't have a creator for some repos
-
- my $obj = $repo->getRootFolder;
- $this->assert_not_null($obj, "ERROR: no root folder found\n\n");
-
- ##### 1rst call
- my $props1 = $obj->getProperties("lastModifiedBy");
- #print STDERR "found ".scalar(keys %$props1)." property\n";
-
- $this->assert_num_equals(1, scalar(keys %$props1));
-
- my $prop1 = $props1->{"cmis:lastModifiedBy"}->getValue;
- $this->assert_not_null($prop1);
-
- ##### 2nd call
- my $props2 = $obj->getProperties("cmis:objectTypeId");
- #print STDERR "found ".scalar(keys %$props2)." property\n";
-
- $this->assert_num_equals(1, scalar(keys %$props2));
-
- my $prop2 = $props2->{"cmis:objectTypeId"}->getValue;
- $this->assert_not_null($prop2);
-
- ##### 3nd call
- my $props3 = $obj->getProperties("cmis:createdBy, cmis:creationDate");
- #print STDERR "found ".scalar(keys %$props3)." property\n";
- #print STDERR "props3=".join(', ', keys %$props3)."\n";
-
- $this->assert_num_equals(2, scalar(keys %$props3));
-
- # SMELL: fails on nuxeo
- my $prop3 = $props3->{"cmis:createdBy"}->getValue;
- #print STDERR "prop3=$prop3\n";
- $this->assert_not_null($prop3);
-
- # SMELL: fails on nuxeo
- my $prop4 = $props3->{"cmis:creationDate"}->getValue;
- $this->assert_not_null($prop4);
-
-}
-
-sub test_Object_getParents_root {
- my $this = shift;
-
- my $repo = $this->getRepository;
- my $root = $repo->getRootFolder;
- $this->assert_not_null($root, "ERROR: no root folder found\n\n");
-
- my $parents;
- try {
- $parents = $root->getObjectParents;
- } catch WebService::Cmis::NotSupportedException with {
- my $error = shift;
- $this->assert(ref($error), "WebService::Cmis::NotSupportedException");
- $this->assert_matches('^object does not support getObjectParents', $error);
- };
-
- $this->assert_null($parents, "ERROR: root doesn't have a parent\n\n");
-}
-
-sub test_Object_getParents_children {
- my $this = shift;
-
- my $repo = $this->getRepository;
- my $root = $repo->getRootFolder;
- $this->assert_not_null($root, "ERROR: no root folder found\n\n");
- #print STDERR "root=".$root->getId."\n";
-
- my $children = $root->getChildren;
- #print STDERR "found ".$children->getSize." children in root folder\n";
-
- while (my $obj = $children->getNext) {
- my $parents = $obj->getObjectParents;
- $this->assert_not_null($parents);
-
- my $parent;
- if ($parents->isa("WebService::Cmis::AtomFeed")) {
- $this->assert_num_equals(1, $parents->getSize);
- $parent = $parents->getNext;
- } else {
- $parent = $parents;
- }
-
- #print STDERR "object=".$obj->getName."\n";
- #print STDERR "parent=".$parent->getId."\n";
-
- $this->assert_str_equals($root->getId, $parent->getId, "ERROR: child doesn't point back to its parent\n\n");
- }
-}
-
-sub test_Object_getParents_subchildren {
- my $this = shift;
- my $repo = $this->getRepository;
- my $root = $repo->getRootFolder;
- $this->assert_not_null($root, "ERROR: no root folder found\n\n");
-
- my $children = $root->getChildren;
- #print STDERR "found ".$children->getSize." children in root folder\n";
-
- # get first folder
- my $folder;
- while(my $obj = $children->getNext) {
- if ($obj->getTypeId eq 'cmis:folder') {
- $folder = $obj;
- last;
- }
- }
- return unless $folder;
-
- $children = $folder->getChildren;
- #print STDERR "found ".$children->getSize." children in sub folder ".$folder->getId.", url=".$folder->getSelfLink."\n";
-
- while(my $obj = $children->getNext) {
- my $parents = $obj->getObjectParents;
- #print STDERR "obj=$obj, name=".$obj->getName."\n";
- #print STDERR "parents=$parents, ref=".ref($parents)."\n";
- my $parent;
- if ($parents->isa("WebService::Cmis::AtomFeed")) {
- $this->assert_num_equals(1, $parents->getSize);
- $parent = $parents->getNext;
- } else {
- $parent = $parents;
- }
- $this->assert($parent->isa("WebService::Cmis::Object"));
- }
-}
-
-sub test_Object_getAppliedPolicies {
- my $this = shift;
-
- my $repo = $this->getRepository;
- my $rootCollection = $repo->getCollection(ROOT_COLL);
- $this->assert_not_null($rootCollection, "ERROR: can't fetch root collection\n\n");
-
- while(my $child = $rootCollection->getNext) {
- my $policies;
- my $exceptionOkay = 0;
-
- try {
- $policies = $child->getAppliedPolicies;
- } catch WebService::Cmis::NotSupportedException with {
- my $error = shift;
- $this->assert_str_equals('This object has canGetAppliedPolicies set to false', $error, "ERROR: unexpected error: ".$error."\n\n");
- $exceptionOkay = 1;
- };
- next if $exceptionOkay;
-
- $this->assert_not_null($policies);
- #print STDERR "found ".$policies->getSize." policies for".$child->getName."\n";
- while(my $obj = $policies->getNext) {
- $this->assert_str_equals('WebServices::Cmis::Policy', ref($obj));
- #print STDERR "obj=".$obj->getName."\n";
- }
- }
-}
-
-# SMELL: fails on nuxeo
-sub test_Object_getRelations {
- my $this = shift;
-
- my $repo = $this->getRepository;
- my $rootCollection = $repo->getCollection(ROOT_COLL);
- $this->assert_not_null($rootCollection, "ERROR: can't fetch root collection\n\n");
-
- while(my $child = $rootCollection->getNext) {
- my $rels = $child->getRelationships;
- $this->assert_not_null($rels);
- #print STDERR "found ".$rels->getSize." relations for".$child->getName."\n";
- while(my $obj = $rels->getNext) {
- $this->assert_str_equals('WebServices::Cmis::Policy', ref($obj));
- #print STDERR "obj=".$obj->getName."\n";
- }
- }
-}
-
-sub test_Repository_getRootFolder {
- my $this = shift;
-
- my $repo = $this->getRepository;
- my $obj = $repo->getRootFolder;
-
- $this->assert_not_null($obj, "ERROR: can't fetch root folder\n\n");
- #print STDERR "obj=".$obj->toString." ($obj)\n";
-
- my $props = $obj->getProperties;
- #print STDERR $props->{"cmis:path"}{displayName}."=".$props->{"cmis:path"}->getValue."\n";
- $this->assert_str_equals("/", $props->{"cmis:path"}->getValue);
- $this->assert_str_equals("", $props->{"cmis:parentId"}->getValue||"");
-}
-
-sub test_Repository_getObjectByPath {
- my $this = shift;
-
- my $repo = $this->getRepository;
- my $root = $repo->getRootFolder;
- my $obj = $repo->getObjectByPath;
-
- $this->assert_not_null($root, "ERROR: no root folder found\n\n");
- #print STDERR "obj=".$obj->getId.", name=".$obj->getName.", path=".$obj->getPath."\n";
-
- $this->assert_str_equals($root->getId, $obj->getId);
-}
-
-sub test_Repository_getObjectByPath_Sites {
- my $this = shift;
- my $repo = $this->getRepository;
-
- # TODO: /Sites only available in default alfresco; use another example path
- my $examplePath = '/Sites';
- my $obj = $repo->getObjectByPath($examplePath);
-
- #print STDERR "obj=".$obj->getId.", name=".$obj->getName.", path=".$obj->getPath."\n";
- $this->assert_not_null($obj, "ERROR: $examplePath not found\n\n");
- $this->assert_str_equals($examplePath, $obj->getPath);
-}
-
-sub test_Repository_getObjectByPath_Unknown {
- my $this = shift;
- my $repo = $this->getRepository;
-
- my $obj;
-
- try {
- $obj = $repo->getObjectByPath('/This/Folder/Does/Not/Exist');
- } catch WebService::Cmis::ClientException with {
- my $error = shift;
- $this->assert_not_null($error);
- $this->assert_matches('^404 Not Found', $error);
- $this->assert_null($obj);
- };
-
-}
-
-sub test_Object_getAllowableActions {
- my $this = shift;
-
- my $repo = $this->getRepository;
- my $obj = $this->getTestDocument;
-
- my $allowableActions = $obj->getAllowableActions;
- $this->assert_not_null($allowableActions, "ERROR: can't get allowable actions\n\n");
- foreach my $action (keys %$allowableActions) {
- #print STDERR "$action=$allowableActions->{$action}\n";
- $this->assert_matches('^can', $action);
- $this->assert_matches('^(0|1)$', $allowableActions->{$action});
- }
-}
-
-sub test_Repository_getObject {
- my $this = shift;
-
- my $repo = $this->getRepository;
- my $root = $repo->getRootFolder;
-
- my $obj = $repo->getObject($root->getId);
- $this->assert_str_equals($root->getId, $obj->getId);
-}
-
-sub test_Object_getObject {
- my $this = shift;
-
- require WebService::Cmis::Object;
-
- my $repo = $this->getRepository;
-
- my $rootFolderId = $repo->getRepositoryInfo->{'rootFolderId'};
- my $obj = new WebService::Cmis::Object(repository=>$repo, id => $rootFolderId);
-
- $this->assert_not_null($obj, "ERROR: can't create an Object\n\n");
- #print STDERR "obj=$obj\n";
-}
-
-
-sub test_Object_getName {
- my $this = shift;
-
- my $repo = $this->getRepository;
- my $obj = $repo->getRootFolder;
-
- my $props = $obj->getProperties;
- my $name = $props->{"cmis:name"}->getValue;
- $this->assert_not_null($name);
- #print STDERR "cmis:name=$title\n";
- $this->assert_str_equals($name, $obj->getProperty("cmis:name"));
-}
-
-
-sub test_Object_getSummary {
- my $this = shift;
-
- my $repo = $this->getRepository;
- my $root = $repo->getRootFolder;
-
- my $summary = $root->getSummary;
- $this->assert_not_null($summary);
- #print STDERR "summary=$summary\n";
-}
-
-sub test_Object_getPublished {
- my $this = shift;
-
- my $repo = $this->getRepository;
- my $root = $repo->getRootFolder;
-
- my $published = $root->getPublished;
- $this->assert_not_null($published);
- $this->assert_matches('^\d+', $published);
-
-
- #require WebService::Cmis::Property;
- #print STDERR "published=".WebService::Cmis::Property::formatDateTime($published)." ($published)\n";
-}
-
-
-sub test_Object_getTitle {
- my $this = shift;
-
- my $repo = $this->getRepository;
- my $root = $repo->getRootFolder;
-
- my $title = $root->getTitle;
- $this->assert_not_null($title);
- #print STDERR "title=$title\n";
-}
-
-
-sub test_Object_getLinkFirst {
- my $this = shift;
-
- my $repo = $this->getRepository;
- my $obj = $repo->getRootFolder;
-
- my $href = $obj->getLink('*');
- $this->assert_not_null($href);
- #print STDERR "href=$href\n";
-
- $href =~ s/^(http:\/\/[^\/]+?):80\//$1\//g; # remove bogus :80 port
- $this->assert_matches('^'.$this->{connection}{url}, $href);
-}
-
-sub test_Object_getLink {
- my $this = shift;
-
- my $repo = $this->getRepository;
- my $obj = $repo->getRootFolder;
-
- my $href = $obj->getLink(ACL_REL);
- #print STDERR "href=$href\n";
- $this->assert_not_null($href);
-
- $href =~ s/^(http:\/\/[^\/]+?):80\//$1\//g; # remove bogus :80 port
- $this->assert_matches('^'.$this->{connection}{url}.'.*acl', $href);
-}
-
-sub test_Object_getLinkFiltered {
- my $this = shift;
-
- my $repo = $this->getRepository;
- my $obj = $repo->getRootFolder;
-
- my $href = $obj->getLink(DOWN_REL, ATOM_XML_FEED_TYPE_P);
- $this->assert_not_null($href);
-
- $href =~ s/^(http:\/\/[^\/]+?):80\//$1\//g; # remove bogus :80 port
- $this->assert_matches('^'.$this->{connection}{url}.'.*children', $href);
-
-}
-
-sub test_Object_getSelfLink {
- my $this = shift;
-
- my $repo = $this->getRepository;
- my $obj = $repo->getRootFolder;
-
- my $href = $obj->getSelfLink;
- $this->assert_not_null($href);
- $this->assert_not_null($href);
-
- $href =~ s/^(http:\/\/[^\/]+?):80\//$1\//g; # remove bogus :80 port
- $this->assert_matches('^'.$this->{connection}{url}, $href);
-}
-
-sub test_Object_getACL {
- my $this = shift;
-
- my $repo = $this->getRepository;
- my $obj = $repo->getRootFolder;
-
- my $acl;
- my $exceptionOk = 0;
- try {
- $acl = $obj->getACL;
- } catch WebService::Cmis::NotSupportedException with {
- my $error = shift;
- $this->assert_str_equals("This repository does not support ACLs", $error);
- $exceptionOk = 1;
- };
- return if $exceptionOk;
-
- $this->assert_not_null($acl);
-
- #print STDERR $acl->{xmlDoc}->toString."\n";
-
- foreach my $ace ($acl->getEntries) {
- $this->assert_str_equals("WebService::Cmis::ACE", ref($ace));
- #print STDERR $ace->toString."\n";
- }
-
- # SMELL: add some asserts that make sense
-}
-
-sub test_ACL_getXmlDoc {
- my $this = shift;
-
- my $origString = <<'HERE';
-<?xml version="1.0" encoding="UTF-8"?>
-<cmis:acl xmlns:cmis="http://docs.oasis-open.org/ns/cmis/core/200908/">
- <cmis:permission>
- <cmis:principal>
- <cmis:principalId>GROUP_EVERYONE</cmis:principalId>
- </cmis:principal>
- <cmis:direct>false</cmis:direct>
- <cmis:permission>cmis:read</cmis:permission>
- </cmis:permission>
- <cmis:permission>
- <cmis:principal>
- <cmis:principalId>GROUP_EVERYONE</cmis:principalId>
- </cmis:principal>
- <cmis:direct>false</cmis:direct>
- <cmis:permission>{http://www.alfresco.org/model/content/1.0}cmobject.Consumer</cmis:permission>
- </cmis:permission>
-</cmis:acl>
-HERE
-
- require WebService::Cmis::ACL;
- my $xmlDoc = XML::LibXML->load_xml(string => $origString);
-
- my $acl = new WebService::Cmis::ACL(xmlDoc=>$xmlDoc);
- my $newString = $acl->getXmlDoc->toString(1);
-
- #print STDERR "orig:\n$origString\n";
- #print STDERR "new:\n$newString\n";
-
- $this->assert_str_equals($origString, $newString);
-}
-
-sub test_Repository_getLink {
- my $this = shift;
-
- my $repo = $this->getRepository;
-# $repo->reload unless defined $repo->{xmlDoc};
-# my $linkNodes = $repo->{xmlDoc}->findnodes('//atom:link');
-# print STDERR "found ".$linkNodes->size." links\n";
-# print STDERR $_->toString."\n", foreach $linkNodes->get_nodelist;
-# print STDERR "\n";
-
- my $repoUrl = $this->{connection}{url};
- $repoUrl =~ s/^(http:\/\/[^\/]+?):80\//$1\//g; # remove bogus :80 port
-
- # SMELL: check capabilities
- foreach my $rel (FOLDER_TREE_REL, ROOT_DESCENDANTS_REL, TYPE_DESCENDANTS_REL, CHANGE_LOG_REL) {
- my $href = $repo->getLink($rel);
- $href =~ s/^(http:\/\/[^\/]+?):80\//$1\//g; # remove bogus :80 port
- $this->assert_not_null($href, "ERROR: link for $rel not found\n\n");
- $this->assert_matches("^$repoUrl", $href);
- #print STDERR "found rel=$rel, href=$href\n";
- }
-}
-
-sub test_Repository_getLink_unknown {
- my $this = shift;
-
- my $repo = $this->getRepository;
- my $href = $repo->getLink("foobar");
- $this->assert_null($href);
-}
-
-sub test_AtomFeed {
- my $this = shift;
-
- my $repo = $this->getRepository;
-
- my $resultSet = $repo->getCollection(ROOT_COLL);
- my $nrResults = $resultSet->getSize;
- $this->assert($nrResults > 0, "ERROR: no objects in root collection\n\n");
- #print STDERR "found $nrResults results\n";
-
- while(my $obj = $resultSet->getNext) {
- $this->assert($obj->isa("WebService::Cmis::Object"), "ERROR: not a cmis object\n\n");
- #print STDERR "name=".$obj->getName." type=".$obj->getTypeId." path=".($obj->getPath||'')."\n";
- #print STDERR "toString=".$obj->toString."\n";
- $this->assert_not_null($obj->getName);
- $this->assert_not_null($obj->getTypeId);
- $this->assert_not_null($obj->toString);
- if ($obj->isa("WebService::Cmis::Folder")) {
- $this->assert_not_null($obj->getPath);
- $this->assert_matches("^/", $obj->getPath);
- $this->assert_matches($obj->getName.'$', $obj->getPath);
- }
- $this->assert(!ref($obj->toString), "ERROR: illegal objectId\n\n");
- }
-}
-
-# self link on xCmis broken
-sub test_AtomFeed_rewind {
- my $this = shift;
-
- my $repo = $this->getRepository;
-
- my $resultSet = $repo->getCollection(ROOT_COLL);
- my $size1 = $resultSet->getSize;
- #print STDERR "resultSet1=".$resultSet->{xmlDoc}->toString(1)."\n";
-
- $resultSet->rewind;
- #print STDERR "resultSet2=".$resultSet->{xmlDoc}->toString(1)."\n";
-
- my $size2 = $resultSet->getSize;
-
- #print STDERR "size1=$size1, size2=$size2\n";
-
- $this->assert_num_equals($size1, $size2);
-}
-
-sub test_AtomFeed_getSelfLinks_RootCollection {
- my $this = shift;
- my $repo = $this->getRepository;
- my $collection = $repo->getCollection(ROOT_COLL);
- my $nrEntries = $collection->getSize;
- #print STDERR "found $nrEntries objects in root collection\n";
- #print STDERR "self url of collection=".$collection->getLink(SELF_REL)."\n";
-
- my $index = 0;
- if ($collection->getSize > 0) {
- my $obj = $collection->getNext;
- $this->assert_not_null($obj, "ERROR: no object found in non-zero feed\n");
- do {