line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WebSercice::Cmis::Test::Property; |
2
|
1
|
|
|
1
|
|
655
|
use base qw(WebService::Cmis::Test); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
586
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
use strict; |
5
|
|
|
|
|
|
|
use warnings; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use Test::More; |
9
|
|
|
|
|
|
|
use Error qw(:try); |
10
|
|
|
|
|
|
|
use POSIX qw(strtod setlocale LC_NUMERIC); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
setlocale LC_NUMERIC, "en_US.UTF-8"; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub test_PropertyType : Tests { |
15
|
|
|
|
|
|
|
my $this = shift; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
my $repo = $this->getRepository; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my $typeDefs = $repo->getTypeDefinitions; |
20
|
|
|
|
|
|
|
isa_ok($typeDefs, 'WebService::Cmis::AtomFeed::ObjectTypes'); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
while(my $objectType = $typeDefs->getNext) { |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# type attributes |
25
|
|
|
|
|
|
|
note("objectType=".$objectType->toString); |
26
|
|
|
|
|
|
|
my $objAttrs = $objectType->getAttributes; |
27
|
|
|
|
|
|
|
ok(defined $objAttrs); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
foreach my $key (keys %$objAttrs) { |
30
|
|
|
|
|
|
|
note(" * $key=$objAttrs->{$key}"); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# type property definitions |
34
|
|
|
|
|
|
|
my $propDefs = $objectType->getPropertyDefinitions; |
35
|
|
|
|
|
|
|
ok(defined $propDefs); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
foreach my $propDef (values %$propDefs) { |
38
|
|
|
|
|
|
|
note(" propDef=".$propDef->toString); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
my $attrs = $propDef->getAttributes; |
41
|
|
|
|
|
|
|
ok(defined $attrs); |
42
|
|
|
|
|
|
|
foreach my $key (keys %$attrs) { |
43
|
|
|
|
|
|
|
ok(defined $attrs->{$key}); |
44
|
|
|
|
|
|
|
#note(" | $key=$attrs->{$key}"); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub test_PropertyBoolean_parse : Test(19) { |
51
|
|
|
|
|
|
|
my $this = shift; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
require WebService::Cmis::Property; |
54
|
|
|
|
|
|
|
is(0, WebService::Cmis::Property::parseBoolean('')); |
55
|
|
|
|
|
|
|
is(0, WebService::Cmis::Property::parseBoolean(' ')); |
56
|
|
|
|
|
|
|
is(1, WebService::Cmis::Property::parseBoolean('x')); |
57
|
|
|
|
|
|
|
is(0, WebService::Cmis::Property::parseBoolean(0)); |
58
|
|
|
|
|
|
|
is(1, WebService::Cmis::Property::parseBoolean(1)); |
59
|
|
|
|
|
|
|
is(0, WebService::Cmis::Property::parseBoolean('0')); # argh |
60
|
|
|
|
|
|
|
is(1, WebService::Cmis::Property::parseBoolean('1')); |
61
|
|
|
|
|
|
|
is(1, WebService::Cmis::Property::parseBoolean('on')); |
62
|
|
|
|
|
|
|
is(1, WebService::Cmis::Property::parseBoolean('ON')); |
63
|
|
|
|
|
|
|
is(0, WebService::Cmis::Property::parseBoolean('off')); |
64
|
|
|
|
|
|
|
is(0, WebService::Cmis::Property::parseBoolean('OFF')); |
65
|
|
|
|
|
|
|
is(1, WebService::Cmis::Property::parseBoolean('true')); |
66
|
|
|
|
|
|
|
is(1, WebService::Cmis::Property::parseBoolean('True')); |
67
|
|
|
|
|
|
|
is(1, WebService::Cmis::Property::parseBoolean('TRUE')); |
68
|
|
|
|
|
|
|
is(0, WebService::Cmis::Property::parseBoolean('false')); |
69
|
|
|
|
|
|
|
is(0, WebService::Cmis::Property::parseBoolean('False')); |
70
|
|
|
|
|
|
|
is(0, WebService::Cmis::Property::parseBoolean('False')); |
71
|
|
|
|
|
|
|
is(1, WebService::Cmis::Property::parseBoolean('yes')); |
72
|
|
|
|
|
|
|
is(0, WebService::Cmis::Property::parseBoolean('no')); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub test_PropertyBoolean_unparse : Test(6) { |
76
|
|
|
|
|
|
|
my $this = shift; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
require WebService::Cmis::Property; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
is('false', WebService::Cmis::Property::formatBoolean(0)); |
81
|
|
|
|
|
|
|
is('false', WebService::Cmis::Property::formatBoolean('0')); |
82
|
|
|
|
|
|
|
is('true', WebService::Cmis::Property::formatBoolean('1')); |
83
|
|
|
|
|
|
|
is('true', WebService::Cmis::Property::formatBoolean(1)); |
84
|
|
|
|
|
|
|
is('foobar', WebService::Cmis::Property::formatBoolean('foobar')); |
85
|
|
|
|
|
|
|
is('none', WebService::Cmis::Property::formatBoolean()); |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub test_PropertyId_parse : Test(2) { |
89
|
|
|
|
|
|
|
my $this = shift; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
require WebService::Cmis::Property; |
92
|
|
|
|
|
|
|
is('123', WebService::Cmis::Property::parseId('123')); |
93
|
|
|
|
|
|
|
is(123, WebService::Cmis::Property::parseId(123)); |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub test_PropertyInteger_parse : Test(4) { |
97
|
|
|
|
|
|
|
my $this = shift; |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
require WebService::Cmis::Property; |
100
|
|
|
|
|
|
|
is(123, WebService::Cmis::Property::parseInteger(123)); |
101
|
|
|
|
|
|
|
is(123, WebService::Cmis::Property::parseInteger('123 ')); |
102
|
|
|
|
|
|
|
is(123, WebService::Cmis::Property::parseInteger(123)); |
103
|
|
|
|
|
|
|
is(123, WebService::Cmis::Property::parseInteger("123.456")); |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub test_PropertyDecimal_parse : Test(2) { |
107
|
|
|
|
|
|
|
my $this = shift; |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
require WebService::Cmis::Property; |
110
|
|
|
|
|
|
|
is(WebService::Cmis::Property::parseDecimal(123.456, 'propertyDecimal'), 123.456); |
111
|
|
|
|
|
|
|
is(WebService::Cmis::Property::parseDecimal('123.456 foobar', 'propertyDecimal'), "123.456"); |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub test_Property_parseDateTime : Test(5) { |
115
|
|
|
|
|
|
|
my $this = shift; |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
require WebService::Cmis::Property; |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
is("1234567890+00:00", WebService::Cmis::Property::parseDateTime('2009-02-13T23:31:30+00:00')); |
120
|
|
|
|
|
|
|
is("1234567890Z", WebService::Cmis::Property::parseDateTime('2009-02-13T23:31:30Z')); |
121
|
|
|
|
|
|
|
is("1295363154+01:00", WebService::Cmis::Property::parseDateTime('2011-01-18T15:05:54.951+01:00')); |
122
|
|
|
|
|
|
|
is("1295363154+01:00", WebService::Cmis::Property::parseDateTime('2011-01-18T15:05:54+01:00')); |
123
|
|
|
|
|
|
|
ok(!defined WebService::Cmis::Property::DateTime->parse('foo')); |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
sub test_Property_DateTime_unparse : Test(2) { |
127
|
|
|
|
|
|
|
my $this = shift; |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
require WebService::Cmis::Property::DateTime; |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
my $string = WebService::Cmis::Property::DateTime->unparse("1234567890+00:00"); |
132
|
|
|
|
|
|
|
is("2009-02-13T23:31:30+00:00", $string); |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
$string = WebService::Cmis::Property::DateTime->unparse("1234567890Z"); |
135
|
|
|
|
|
|
|
is("2009-02-13T23:31:30Z", $string); |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
sub test_Property_DateTime_toString : Test { |
139
|
|
|
|
|
|
|
my $this = shift; |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
require WebService::Cmis::Property::DateTime; |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
my $dateTime = WebService::Cmis::Property::newDateTime( |
144
|
|
|
|
|
|
|
id=>"test", |
145
|
|
|
|
|
|
|
value=>WebService::Cmis::Property::parseDateTime("2011-01-25T13:22:28+01:00"), |
146
|
|
|
|
|
|
|
); |
147
|
|
|
|
|
|
|
note("dateTime=".$dateTime->toString); |
148
|
|
|
|
|
|
|
is("test=1295961748+01:00", $dateTime->toString); |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
sub test_Property_parseDateTime_format : Test { |
152
|
|
|
|
|
|
|
my $this = shift; |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
require WebService::Cmis::Property; |
155
|
|
|
|
|
|
|
require WebService::Cmis::Property::DateTime; |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
my $testDateString = "2011-01-25T13:22:28+01:00"; |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
my $result = WebService::Cmis::Property::parseDateTime($testDateString); |
160
|
|
|
|
|
|
|
#print STDERR "result=$result\n"; |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
my $dateString = WebService::Cmis::Property::formatDateTime($result); |
163
|
|
|
|
|
|
|
#print STDERR "dateString=$dateString\n"; |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
is($testDateString, $dateString); |
166
|
|
|
|
|
|
|
} |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
sub test_Property_formatDateTime : Test(5) { |
169
|
|
|
|
|
|
|
my $this = shift; |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
require WebService::Cmis::Property; |
172
|
|
|
|
|
|
|
require WebService::Cmis::Property::DateTime; |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
is("2011-01-18T15:05:54+01:00", WebService::Cmis::Property::formatDateTime("1295363154+01:00")); |
175
|
|
|
|
|
|
|
is("2011-01-18T15:05:54+01", WebService::Cmis::Property::formatDateTime("1295363154+01")); |
176
|
|
|
|
|
|
|
is("2011-01-18T15:05:54", WebService::Cmis::Property::formatDateTime("1295363154")); |
177
|
|
|
|
|
|
|
is('none', WebService::Cmis::Property::formatDateTime('foo')); |
178
|
|
|
|
|
|
|
is("1970-01-01T00:00:00", WebService::Cmis::Property::formatDateTime(0)); |
179
|
|
|
|
|
|
|
} |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
1; |