/[volute]/trunk/projects/grid/vospace/php_endpoint/tests/test_endpoint.php
ViewVC logotype

Contents of /trunk/projects/grid/vospace/php_endpoint/tests/test_endpoint.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 737 - (show annotations)
Thu Aug 21 19:31:18 2008 UTC (12 years, 2 months ago) by richard.p.wagner
File size: 8174 byte(s)
WS-Security header capturing
1 <?php
2
3 include('../config.inc');
4
5 require_once(SIMPLE_TEST . 'unit_tester.php');
6 require_once(SIMPLE_TEST . 'reporter.php');
7
8 require_once('debug_funcs.php');
9
10 class TestVOSpaceServiceEndpoint extends UnitTestCase {
11
12 function setUp(){
13 $this->client = new
14 SoapClient(
15 '../vospace.wsdl',
16 array('location' => 'http://localhost/vospace/vospace_endpoint.php',
17 'uri' => 'http://www.ivoa.net/xml/VOSpaceContract-v1.1rc1',
18 'trace' => 1,
19 'exceptions' => 1));
20
21 }
22
23 function testNewServiceEndpoint() {
24
25 $this->assertNotNull($this->client);
26 }
27
28 function testFunctionsList() {
29
30 $function_list = $this->client->__getFunctions();
31 $this->assertEqual(count($function_list), 15);
32 }
33
34
35 function testGetProtocols() {
36
37 $response = $this->client->GetProtocols();
38
39 $accepts = $response->accepts;
40 $provides = $response->provides;
41
42 $this->assertNotNull($accepts);
43 $this->assertNotNull($provides);
44
45 $this->assertEqual($provides->protocol[0]->uri,
46 'ivo://net.ivoa.vospace/protocols#http-client');
47 $this->assertEqual($accepts->protocol[1]->uri,
48 'ivo://net.ivoa.vospace/protocols#http-server');
49 }
50
51
52 function testGetViews() {
53
54 $response = $this->client->GetViews();
55
56 $accepts = $response->accepts;
57 $provides = $response->provides;
58
59 $this->assertNotNull($accepts);
60 $this->assertNotNull($provides);
61
62 // the 'view' array only has a single element,
63 // so there's no indexing on it
64 $this->assertEqual($provides->view->uri,
65 'ivo://net.ivoa.vospace/views#identity');
66 $this->assertEqual($accepts->view->uri,
67 'ivo://net.ivoa.vospace/views#identity');
68 }
69
70 function testGetProperties() {
71
72 $response = $this->client->GetProperties();
73
74 $accepts = $response->accepts;
75 $provides = $response->provides;
76 $contains = $response->contains;
77
78 $this->assertNotNull($accepts);
79 $this->assertNotNull($provides);
80 $this->assertNotNull($contains);
81
82 // hard coding the order to keep things simple
83 $this->assertEqual($provides->property[0]->uri,
84 'ivo://net.ivoa.vospace/properties#size' );
85 $this->assertEqual($provides->property[0]->readonly, True);
86
87 $this->assertEqual($provides->property[1]->uri,
88 'ivo://net.ivoa.vospace/properties#owner' );
89 $this->assertEqual($provides->property[1]->readonly, True);
90
91 $this->assertEqual($provides->property[2]->uri,
92 'ivo://net.ivoa.vospace/properties#modificationdate' );
93 $this->assertEqual($provides->property[2]->readonly, True);
94
95 $this->assertEqual($provides->property[3]->uri,
96 'ivo://net.ivoa.vospace/properties#creationdate' );
97 $this->assertEqual($provides->property[3]->readonly, True);
98
99 // print '<pre>';
100 // var_dump($provides);
101 // print '</pre>';
102 // barf($this->client);
103 }
104
105
106 function testNodeNotFound() {
107
108 try {
109 $response = $this->client->GetNode(array('target' => 'ivo://example.org!vospace/foo.txt'));
110 $this->assertTrue(0, "Should have thrown NodeNotFound");
111 }
112 catch (SoapFault $exp) {
113 $this->assertEqual($exp->detail->NodeNotFoundFault->uri, 'ivo://example.org!vospace/foo.txt' );
114 }
115
116 }
117
118 function testGetNode() {
119
120 $response = $this->client->GetNode(array('target' => 'ivo://example.org!vospace/128cubed_hierarchy.png'));
121 $node = $response->node;
122 $properties = $response->properties;
123
124 $this->assertEqual($node->uri, 'ivo://example.org!vospace/128cubed_hierarchy.png' );
125
126 $this->assertNotNull($node->properties);
127
128 $this->assertEqual($node->properties->property[0]->uri,
129 'ivo://net.ivoa.vospace/properties#size' );
130 $this->assertEqual($node->properties->property[0]->readonly, True);
131
132 $this->assertEqual($node->properties->property[0]->_, '569516');
133
134 $this->assertEqual($node->properties->property[1]->uri,
135 'ivo://net.ivoa.vospace/properties#owner' );
136 $this->assertEqual($node->properties->property[1]->readonly, True);
137
138 $this->assertEqual($node->properties->property[2]->uri,
139 'ivo://net.ivoa.vospace/properties#modificationdate' );
140 $this->assertEqual($node->properties->property[2]->readonly, True);
141
142 $this->assertEqual($node->properties->property[3]->uri,
143 'ivo://net.ivoa.vospace/properties#creationdate' );
144 $this->assertEqual($node->properties->property[3]->readonly, True);
145
146 //barf_min($this->client);
147 }
148
149 function testPullFromNodeNotFound() {
150
151 try {
152 $response = $this->client->PullFromVoSpace(array('source' =>
153 'ivo://example.org!vospace/foo.txt',
154 'transfer' => Null));
155 $this->assertTrue(0, "Should have thrown NodeNotFound");
156 }
157 catch (SoapFault $exp) {
158 $this->assertEqual($exp->detail->NodeNotFoundFault->uri, 'ivo://example.org!vospace/foo.txt' );
159 }
160 }
161
162 function testPullFrom() {
163
164 $view = array('uri' => 'ivo://net.ivoa.vospace/views#identity',
165 'original'=>True);
166 $protocol = array('uri' => 'ivo://net.ivoa.vospace/protocols#http-client');
167
168 $request = array('source' =>
169 'ivo://example.org!vospace/bill_of_rights.txt',
170 'transfer' => array('view'=> $view,
171 'protocol' => $protocol));
172
173 $response = $this->client->PullFromVoSpace($request);
174 $this->assertNotNull($response->transfer);
175
176 $endpoint = $response->transfer->protocol->endpoint;
177
178 // now we're going to check that the endpoint is
179 // really there
180 $this->assertTrue(url_exists($endpoint));
181
182 }
183
184 function testListNodesNodeNotFound() {
185 $request = array('request' =>
186 array('detail' => 'min',
187 'nodes' =>
188 array(array('uri' => 'ivo://example.org!vospace/moo'))));
189
190 try {
191 $response = $this->client->ListNodes($request);
192 $this->assertTrue(0, "Should have thrown NodeNotFound");
193 } catch (SoapFault $exp) {
194 $this->assertEqual($exp->detail->NodeNotFoundFault->uri, 'ivo://example.org!vospace/moo' );
195 }
196
197 }
198
199 function testListNodes() {
200
201 $request = array('request' =>
202 array('detail' => 'min',
203 'nodes' =>
204 array(array('uri' => 'ivo://example.org!vospace'))));
205
206 $response = $this->client->ListNodes($request);
207 // crazy example of how to march down the object
208 // the name of the array is actually "node"
209 // barf_var($response);
210 // barf_var($response->response);
211 // barf_var($response->response->nodes);
212 // barf_var($response->response->nodes->node);
213 //barf_var($response->response->nodes->node[0]);
214
215 $this->assertEqual(count($response->response->nodes->node), 4);
216 }
217
218 function testListNodesContainer() {
219 $request = array('request' =>
220 array('detail' => 'min',
221 'nodes' =>
222 array(array('uri' => 'ivo://example.org!vospace/images'))));
223
224 $response = $this->client->ListNodes($request);
225
226 $this->assertEqual(count($response->response->nodes->node), 3);
227
228 }
229
230 function testListNodesSingleNode() {
231 $request = array('request' =>
232 array('detail' => 'min',
233 'nodes' =>
234 array(array('uri' => 'ivo://example.org!vospace/images/cl0041_0000_2_lxt_l7_pz.png'))));
235
236 $response = $this->client->ListNodes($request);
237
238 $this->assertEqual(count($response->response->nodes->node), 1);
239 $this->assertEqual($response->response->nodes->node->uri,
240 'ivo://example.org!vospace/images/cl0041_0000_2_lxt_l7_pz.png');
241
242 }
243
244 function testListNodesWildcard() {
245 $request = array('request' =>
246 array('detail' => 'min',
247 'nodes' =>
248 array(array('uri' => 'ivo://example.org!vospace/parameters/*0'))));
249
250 $response = $this->client->ListNodes($request);
251
252 $this->assertEqual(count($response->response->nodes->node), 2);
253
254 }
255
256 function testPushFrom() {
257
258 try {
259 $response = $this->client->PushFromVoSpace();
260 $this->assertTrue(0, "Should have thrown InternalFault - Not implemented");
261 } catch (SoapFault $exp) {
262 $this->assertEqual($exp->InternalFault, "");
263 }
264
265 }
266
267 }
268
269 $test = new TestVOSpaceServiceEndpoint();
270 $test->run(new HtmlReporter());
271
272 ?>

msdemlei@ari.uni-heidelberg.de
ViewVC Help
Powered by ViewVC 1.1.26