| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package WebService::Cmis::Test::Basics; |
|
2
|
1
|
|
|
1
|
|
6765
|
use base qw(WebService::Cmis::Test); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
687
|
|
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
use strict; |
|
5
|
|
|
|
|
|
|
use warnings; |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use Test::More; |
|
8
|
|
|
|
|
|
|
use Error qw(:try); |
|
9
|
|
|
|
|
|
|
use WebService::Cmis qw(:collections :utils :relations :namespaces :contenttypes); |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub test_getClient : Test(1) { |
|
12
|
|
|
|
|
|
|
my $this = shift; |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my $client = WebService::Cmis::getClient; |
|
15
|
|
|
|
|
|
|
is($client->toString, "CMIS client connection to "); |
|
16
|
|
|
|
|
|
|
} |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub test_getClient_2 : Test(1) { |
|
19
|
|
|
|
|
|
|
my $this = shift; |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my $client = $this->getClient; |
|
22
|
|
|
|
|
|
|
my $url = $this->{config}{url}; |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
is($client->toString, "CMIS client connection to $url"); |
|
25
|
|
|
|
|
|
|
} |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub test_repository_ClientException_40x : Test(4) { |
|
28
|
|
|
|
|
|
|
my $this = shift; |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
my $client = $this->getClient; |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my $doc; |
|
33
|
|
|
|
|
|
|
try { |
|
34
|
|
|
|
|
|
|
#$doc = $client->get("does_not_exist"); ... well this one should fail with a 404 as well but it doesnt on alfresco 4 |
|
35
|
|
|
|
|
|
|
$doc = $client->get("does/not/exist"); # anyway, this one fails with a 405 method not allowed on alfresco |
|
36
|
|
|
|
|
|
|
print STDERR "doc=".$doc->toString(1)."\n"; # never reach |
|
37
|
|
|
|
|
|
|
} catch WebService::Cmis::ClientException with { |
|
38
|
|
|
|
|
|
|
my $error = shift; |
|
39
|
|
|
|
|
|
|
ok(ref($error)); |
|
40
|
|
|
|
|
|
|
note("error=$error"); |
|
41
|
|
|
|
|
|
|
isa_ok($error, "WebService::Cmis::ClientException"); |
|
42
|
|
|
|
|
|
|
like($error, qr/^40\d/); |
|
43
|
|
|
|
|
|
|
}; |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
ok(!defined $doc); |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub test_repository_ClientExcepion_No_Access : Test(4) { |
|
49
|
|
|
|
|
|
|
my $this = shift; |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
my $result; |
|
52
|
|
|
|
|
|
|
my $error; |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
try { |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
my $badClient = WebService::Cmis::getClient( |
|
57
|
|
|
|
|
|
|
%{$this->{config}}, |
|
58
|
|
|
|
|
|
|
); |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
my $ticket = $badClient->login( |
|
61
|
|
|
|
|
|
|
user=>"foo", |
|
62
|
|
|
|
|
|
|
password=>"bar" |
|
63
|
|
|
|
|
|
|
); |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
$result = $badClient->get; |
|
66
|
|
|
|
|
|
|
} catch WebService::Cmis::ClientException with { |
|
67
|
|
|
|
|
|
|
$error = shift; |
|
68
|
|
|
|
|
|
|
}; |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
ok(ref($error)) || diag("there should be an error by now"); |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
note("error=$error"); |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
isa_ok($error, "WebService::Cmis::ClientException"); |
|
75
|
|
|
|
|
|
|
like($error, qr/^(401 Unauthorized)|(403 Forbidden|400)/); |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
ok(!defined $result); |
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub test_repository_ServerExceptio_500 : Test(4) { |
|
81
|
|
|
|
|
|
|
my $this = shift; |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
my $badClient = WebService::Cmis::getClient( |
|
84
|
|
|
|
|
|
|
url => "http://doesnotexist.local.foobar:8080/alfresco/service/cmis", |
|
85
|
|
|
|
|
|
|
user => "foo", |
|
86
|
|
|
|
|
|
|
password => "bar", |
|
87
|
|
|
|
|
|
|
); |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
my $result; |
|
90
|
|
|
|
|
|
|
try { |
|
91
|
|
|
|
|
|
|
$result = $badClient->get; |
|
92
|
|
|
|
|
|
|
} catch WebService::Cmis::ServerException with { |
|
93
|
|
|
|
|
|
|
my $error = shift; |
|
94
|
|
|
|
|
|
|
ok(ref($error)); |
|
95
|
|
|
|
|
|
|
isa_ok($error, "WebService::Cmis::ServerException"); |
|
96
|
|
|
|
|
|
|
#note("error=$error"); |
|
97
|
|
|
|
|
|
|
like($error, qr/^500 Can't connect/); |
|
98
|
|
|
|
|
|
|
}; |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
ok(!defined $result); |
|
101
|
|
|
|
|
|
|
} |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub test_repository_raw : Test(1) { |
|
104
|
|
|
|
|
|
|
my $this = shift; |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
my $client = $this->getClient; |
|
107
|
|
|
|
|
|
|
my $doc = $client->get; |
|
108
|
|
|
|
|
|
|
like($doc->toString, qr/^<\?xml version="1.0"( encoding="(utf|UTF)-8")?\?>.*/); |
|
109
|
|
|
|
|
|
|
} |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub test_Cmis_collectionTypes : Test(5) { |
|
112
|
|
|
|
|
|
|
my $this = shift; |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
is("query", QUERY_COLL); |
|
115
|
|
|
|
|
|
|
is("types",TYPES_COLL); |
|
116
|
|
|
|
|
|
|
is("checkedout",CHECKED_OUT_COLL); |
|
117
|
|
|
|
|
|
|
is("unfiled",UNFILED_COLL); |
|
118
|
|
|
|
|
|
|
is("root",ROOT_COLL,); |
|
119
|
|
|
|
|
|
|
} |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub test_getTestDocument : Test(1) { |
|
122
|
|
|
|
|
|
|
my $this = shift; |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
my $doc = $this->getTestDocument; |
|
125
|
|
|
|
|
|
|
ok(defined $doc); |
|
126
|
|
|
|
|
|
|
} |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
sub test_getTestFolder : Test(4) { |
|
129
|
|
|
|
|
|
|
my $this = shift; |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
my $folderName = $this->getTestFolderName; |
|
132
|
|
|
|
|
|
|
note("test folder at $folderName"); |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
my $folder = $this->getTestFolder; |
|
135
|
|
|
|
|
|
|
ok(defined $folder); |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
my $id = $folder->getId; |
|
138
|
|
|
|
|
|
|
note("folder id=$id"); |
|
139
|
|
|
|
|
|
|
ok(defined $id); |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
my $repo = $this->getRepository; |
|
142
|
|
|
|
|
|
|
my $folder1 = $repo->getObject($id); |
|
143
|
|
|
|
|
|
|
ok(defined $folder1); |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
my $id1 = $folder->getId; |
|
146
|
|
|
|
|
|
|
is($id, $id1); |
|
147
|
|
|
|
|
|
|
} |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
1; |