1 #!/usr/bin/perl -w -Wall
4 use lib
"C:/Perl/site/lib/MOBY";
5 use MOBY
::Client
::Central
;
6 my $v = 1 if ($ARGV[0] && ($ARGV[0] eq "verbose"));
8 sub TEST
{ # test of Registration object
9 my ($reg, $test, $expect) = @_;
10 die "\a\a\aREG OBJECT MALFORMED" unless $reg;
11 if ($reg->success == $expect){
12 print "test $test\t\t[PASS] ", ($v?
($reg->message):""),"\n";
14 print "test $test\t\t[FAIL] ",$reg->message,"\n\n";
17 sub TEST2
{ # test of ServiceInstance object listref
18 my ($SI, $REG, $test, $expect) = @_;
19 die "\a\a\aServiceInstance Response MALFORMED" if ($SI && !(ref($SI) =~ /array/i));
20 if (defined($REG) && $expect){
21 print "test $test\t\t[FAIL]\n", $REG->message,"\n";
22 } elsif (($SI->[0] && $expect) || (!$SI->[0] && !$expect)) {
23 print "test $test\t\t[PASS]\n";
25 print "test $test\t\t[FAIL]\nExpected to find service; didn't find service\n";
29 my $URL = $ENV{MOBY_SERVER
}?
$ENV{MOBY_SERVER
}:'http://mobycentral.cbr.nrc.ca:8080/cgi-bin/MOBY05/testmobycentral.pl';
30 my $URI = $ENV{MOBY_URI
}?
$ENV{MOBY_URI
}:'http://mobycentral.cbr.nrc.ca:8080/MOBY/Central';
31 my $PROXY = $ENV{MOBY_PROXY
}?
$ENV{MOBY_PROXY
}:'No Proxy Server';
33 my $C = MOBY
::Client
::Central
->new(
35 mobycentral
=> {URL
=> $URL,
40 print "TESTING MOBY CLIENT with\n\tURL: $URL\n\tURI: $URI\n\tProxy: $PROXY\n\n";
43 #register with two ISA's -> should fail
44 TEST
($C->registerObjectClass(objectType
=> "HypotheticalObject1",
45 description
=> "a human-readable description of the object",
46 contactEmail
=> 'your@email.address',
47 authURI
=> "blah.blah.blah",
50 ['Object', 'article1'],
51 ['Object', 'articleName2']],
53 ['Object', 'articleName3']]}
56 #register with no ISA's -> should fail
57 TEST
($C->registerObjectClass(objectType
=> "HypotheticalObject1",
58 description
=> "a human-readable description of the object",
59 contactEmail
=> 'your@email.address',
60 authURI
=> "blah.blah.blah",
63 ['Object', 'articleName3']]}
66 #reg first object class with a single ISA -> should pass
67 TEST
($C->registerObjectClass(objectType
=> "HypotheticalObject1",
68 description
=> "a human-readable description of the object",
69 contactEmail
=> 'your@email.address',
70 authURI
=> "blah.blah.blah",
73 ['Object', 'articleName2']],
75 ['Object', 'articleName3']]}
78 #reg duplicate object class
79 TEST
($C->registerObjectClass(objectType
=> "HypotheticalObject1",
80 description
=> "a human-readable description of the object",
81 contactEmail
=> 'your@email.address',
82 authURI
=> "blah.blah.blah",
85 ['Object', 'article1']
88 ['Object', 'articleName3']]}
91 #reg second object class
92 TEST
($C->registerObjectClass(objectType
=> "HypotheticalObject2",
93 description
=> "a human-readable description of the object",
94 contactEmail
=> 'your@email.address',
95 authURI
=> "blah.blah.blah",
98 ['Object', 'articleName2']],
100 ['Object', 'articleName3']]}
103 TEST
($C->registerServiceType(serviceType
=> "HypotheticalService1",
104 description
=> "a human-readable description of the service",
105 contactEmail
=> 'your@email.address',
106 authURI
=> "blah.blah.blah",
108 ISA
=> ['Retrieval','Analysis']}
111 TEST
($C->registerServiceType(serviceType
=> "HypotheticalService1",
112 description
=> "a human-readable description of the service",
113 contactEmail
=> 'your@email.address',
114 authURI
=> "blah.blah.blah",
116 ISA
=> ['Retrieval','Analysis']}
119 TEST
($C->deregisterObjectClass(objectType
=> "HypotheticalObject1"), 6, 1);
120 TEST
($C->deregisterObjectClass(objectType
=> "HypotheticalObject1"), 7, 0);
121 TEST
($C->deregisterObjectClass(objectType
=> "HypotheticalObject2"), 8, 1);
122 TEST
($C->deregisterServiceType(serviceType
=> "HypotheticalService1"), 9, 1);
123 TEST
($C->deregisterServiceType(serviceType
=> "HypotheticalService1"), 10, 0);
124 TEST
($C->registerNamespace(
125 namespaceType
=>'HypotheticalNamespace1',
126 authURI
=> 'your.authority.URI',
127 description
=> "human readable description of namespace",
128 contactEmail
=> 'your@address.here'), 11, 1);
129 TEST
($C->registerNamespace(
130 namespaceType
=>'HypotheticalNamespace1',
131 authURI
=> 'your.authority.URI',
132 description
=> "human readable description of namespace",
133 contactEmail
=> 'your@address.here'), 12, 0);
134 TEST
($C->deregisterNamespace(namespaceType
=>'HypotheticalNamespace1'), 13, 1);
137 #reg first object class
138 TEST
($C->registerObjectClass(objectType
=> "HypotheticalObject1",
139 description
=> "a human-readable description of the object",
140 contactEmail
=> 'your@email.address',
141 authURI
=> "blah.blah.blah",
144 ['Object', 'article1']]}
147 #reg duplicate object class
148 TEST
($C->registerObjectClass(objectType
=> "HypotheticalObject2",
149 description
=> "a human-readable description of the object",
150 contactEmail
=> 'your@email.address',
151 authURI
=> "blah.blah.blah",
154 ['HypotheticalObject1', 'article1']]}
157 TEST
($C->deregisterObjectClass(objectType
=> "HypotheticalObject1"), 16, 0);
159 TEST
($C->registerNamespace(
160 namespaceType
=>'HypotheticalNamespace1',
161 authURI
=> 'your.authority.URI',
162 description
=> "human readable description of namespace",
163 contactEmail
=> 'your@address.here'), 17, 1);
165 TEST
($C->registerService(
166 serviceName
=> "myfirstservice",
167 serviceType
=> "Retrieval",
168 authURI
=> "www.illuminae.com",
169 contactEmail
=> 'your@mail.address',
170 description
=> "this is my first service",
172 URL
=> "http://illuminae/cgi-bin/service.pl",
174 ['articleName1', [Object
=> ['HypotheticalNamespace1']]], # Simple
177 ['articleName2', [String
=> ['HypotheticalNamespace1']]], # Simple
181 datatype
=> 'Integer',
185 enum
=> [-10, 10, 0]}}), 18, 1);
187 TEST
($C->registerService(
188 serviceName
=> "myfirstservice",
189 serviceType
=> "Retrieval",
190 authURI
=> "www.illuminae.com",
191 contactEmail
=> 'your@mail.address',
192 description
=> "this is my first service",
194 URL
=> "http://illuminae/cgi-bin/service.pl",
196 ['articleName1', [Object
=> ['HypotheticalNamespace1']]], # Simple
199 ['articleName2', [String
=> ['HypotheticalNamespace1']]], # Simple
203 TEST
($C->registerService(
204 serviceName
=> "myfirstservice2",
205 serviceType
=> "Retrieval",
206 authURI
=> "www.illuminae.com",
207 contactEmail
=> 'your@mail.address',
208 description
=> "this is my first service",
210 URL
=> "http://illuminae/cgi-bin/service.pl",
212 # ['articleName1', [[Object => ['HypotheticalNamespace1']]]], # Collection
213 ['articleName1', [Object
=> ['HypotheticalNamespace1']]], # Simple
216 ['articleName2', [String
=> ['HypotheticalNamespace1']]], # Simple
221 TEST2
($C->findService(
222 serviceName
=> "myfirstservice2",
223 serviceType
=> "Retrieval",
224 authURI
=> "www.illuminae.com",
232 TEST2
($C->findService(
233 serviceName
=> "myfirstservice2",
236 TEST2
($C->findService(
238 ["BlahObject"], # Simple
241 TEST2
($C->findService(
243 ["Object", ['HypotheticalNamespace1']], # Simple
246 my ($si, $reg) = $C->findService(
247 serviceName
=> "myfirstservice2"
251 my $wsdl = $C->retrieveService($si);
253 if ($wsdl && ($wsdl =~ /\<definitions/)){
254 print "test 25\t\t[PASS]\n";
256 print "test 25\t\t[FAIL]\tWSDL was not retrieved\n\n";
261 TEST
($C->deregisterService(
262 serviceName
=> "myfirstservice2",
263 authURI
=> "www.illuminae.com",
265 TEST
($C->deregisterService(
266 serviceName
=> "myfirstservice2",
267 authURI
=> "www.illuminae.com",
269 TEST
($C->deregisterService(
270 serviceName
=> "myfirstservice",
271 authURI
=> "www.illuminae.com",
273 #TEST($C->deregisterService(
274 # serviceName => "getDragonSimpleAnnotatedImages",
275 # authURI => "www.illuminae.com",
276 # ), 29, 0); # cant deregister a service with a signatureURL
278 TEST
($C->deregisterObjectClass(objectType
=> "HypotheticalObject2"), 30, 1);
279 TEST
($C->deregisterObjectClass(objectType
=> "HypotheticalObject1"), 31, 1);
280 TEST
($C->deregisterNamespace(namespaceType
=>'HypotheticalNamespace1'), 32, 1);