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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 737 - (hide annotations)
Thu Aug 21 19:31:18 2008 UTC (12 years, 10 months ago) by richard.p.wagner
File size: 8174 byte(s)
WS-Security header capturing
1 richard.p.wagner 106 <?php
2    
3     include('../config.inc');
4    
5     require_once(SIMPLE_TEST . 'unit_tester.php');
6     require_once(SIMPLE_TEST . 'reporter.php');
7    
8 richard.p.wagner 731 require_once('debug_funcs.php');
9 richard.p.wagner 106
10     class TestVOSpaceServiceEndpoint extends UnitTestCase {
11    
12     function setUp(){
13     $this->client = new
14     SoapClient(
15 richard.p.wagner 731 '../vospace.wsdl',
16 richard.p.wagner 737 array('location' => 'http://localhost/vospace/vospace_endpoint.php',
17 richard.p.wagner 106 'uri' => 'http://www.ivoa.net/xml/VOSpaceContract-v1.1rc1',
18 richard.p.wagner 731 'trace' => 1,
19     'exceptions' => 1));
20 richard.p.wagner 106
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 richard.p.wagner 735
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 richard.p.wagner 106 function testGetProperties() {
71    
72     $response = $this->client->GetProperties();
73 richard.p.wagner 731
74 richard.p.wagner 106 $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 richard.p.wagner 731 'ivo://net.ivoa.vospace/properties#size' );
85 richard.p.wagner 106 $this->assertEqual($provides->property[0]->readonly, True);
86    
87     $this->assertEqual($provides->property[1]->uri,
88 richard.p.wagner 731 'ivo://net.ivoa.vospace/properties#owner' );
89 richard.p.wagner 106 $this->assertEqual($provides->property[1]->readonly, True);
90    
91     $this->assertEqual($provides->property[2]->uri,
92 richard.p.wagner 731 'ivo://net.ivoa.vospace/properties#modificationdate' );
93 richard.p.wagner 106 $this->assertEqual($provides->property[2]->readonly, True);
94    
95     $this->assertEqual($provides->property[3]->uri,
96 richard.p.wagner 731 'ivo://net.ivoa.vospace/properties#creationdate' );
97 richard.p.wagner 106 $this->assertEqual($provides->property[3]->readonly, True);
98    
99 richard.p.wagner 731 // print '<pre>';
100 richard.p.wagner 106 // var_dump($provides);
101 richard.p.wagner 731 // print '</pre>';
102 richard.p.wagner 106 // barf($this->client);
103     }
104    
105    
106     function testNodeNotFound() {
107    
108     try {
109 richard.p.wagner 731 $response = $this->client->GetNode(array('target' => 'ivo://example.org!vospace/foo.txt'));
110 richard.p.wagner 735 $this->assertTrue(0, "Should have thrown NodeNotFound");
111 richard.p.wagner 106 }
112     catch (SoapFault $exp) {
113 richard.p.wagner 731 $this->assertEqual($exp->detail->NodeNotFoundFault->uri, 'ivo://example.org!vospace/foo.txt' );
114 richard.p.wagner 106 }
115    
116     }
117    
118     function testGetNode() {
119    
120 richard.p.wagner 731 $response = $this->client->GetNode(array('target' => 'ivo://example.org!vospace/128cubed_hierarchy.png'));
121 richard.p.wagner 106 $node = $response->node;
122     $properties = $response->properties;
123    
124 richard.p.wagner 731 $this->assertEqual($node->uri, 'ivo://example.org!vospace/128cubed_hierarchy.png' );
125 richard.p.wagner 106
126     $this->assertNotNull($node->properties);
127    
128     $this->assertEqual($node->properties->property[0]->uri,
129 richard.p.wagner 731 'ivo://net.ivoa.vospace/properties#size' );
130 richard.p.wagner 106 $this->assertEqual($node->properties->property[0]->readonly, True);
131    
132 richard.p.wagner 731 $this->assertEqual($node->properties->property[0]->_, '569516');
133 richard.p.wagner 106
134     $this->assertEqual($node->properties->property[1]->uri,
135 richard.p.wagner 731 'ivo://net.ivoa.vospace/properties#owner' );
136 richard.p.wagner 106 $this->assertEqual($node->properties->property[1]->readonly, True);
137    
138     $this->assertEqual($node->properties->property[2]->uri,
139 richard.p.wagner 731 'ivo://net.ivoa.vospace/properties#modificationdate' );
140 richard.p.wagner 106 $this->assertEqual($node->properties->property[2]->readonly, True);
141    
142     $this->assertEqual($node->properties->property[3]->uri,
143 richard.p.wagner 731 'ivo://net.ivoa.vospace/properties#creationdate' );
144 richard.p.wagner 106 $this->assertEqual($node->properties->property[3]->readonly, True);
145    
146     //barf_min($this->client);
147     }
148    
149 richard.p.wagner 731 function testPullFromNodeNotFound() {
150    
151     try {
152 richard.p.wagner 734 $response = $this->client->PullFromVoSpace(array('source' =>
153     'ivo://example.org!vospace/foo.txt',
154 richard.p.wagner 731 'transfer' => Null));
155 richard.p.wagner 735 $this->assertTrue(0, "Should have thrown NodeNotFound");
156 richard.p.wagner 731 }
157     catch (SoapFault $exp) {
158     $this->assertEqual($exp->detail->NodeNotFoundFault->uri, 'ivo://example.org!vospace/foo.txt' );
159 richard.p.wagner 734 }
160 richard.p.wagner 731 }
161    
162 richard.p.wagner 734 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 richard.p.wagner 106
182 richard.p.wagner 734 }
183    
184 richard.p.wagner 735 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 richard.p.wagner 734 }
198    
199 richard.p.wagner 735 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 richard.p.wagner 734 }
217    
218 richard.p.wagner 735 function testListNodesContainer() {
219     $request = array('request' =>
220     array('detail' => 'min',
221     'nodes' =>
222     array(array('uri' => 'ivo://example.org!vospace/images'))));
223 richard.p.wagner 734
224 richard.p.wagner 735 $response = $this->client->ListNodes($request);
225    
226     $this->assertEqual(count($response->response->nodes->node), 3);
227 richard.p.wagner 734
228 richard.p.wagner 735 }
229 richard.p.wagner 734
230 richard.p.wagner 735 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 richard.p.wagner 106 }
268    
269 richard.p.wagner 735 $test = new TestVOSpaceServiceEndpoint();
270 richard.p.wagner 106 $test->run(new HtmlReporter());
271    
272     ?>

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