/[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 734 - (hide annotations)
Tue Aug 19 19:37:17 2008 UTC (12 years, 5 months ago) by richard.p.wagner
File size: 5114 byte(s)
working on listing nodes
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     array('location' => 'http://localhost/vos/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     function testGetProperties() {
35    
36     $response = $this->client->GetProperties();
37 richard.p.wagner 731 //print '<pre>';
38     //var_dump($response);
39     //print '</pre>';
40     //barf($this->client);
41    
42 richard.p.wagner 106 $accepts = $response->accepts;
43     $provides = $response->provides;
44     $contains = $response->contains;
45    
46     $this->assertNotNull($accepts);
47     $this->assertNotNull($provides);
48     $this->assertNotNull($contains);
49    
50     // hard coding the order to keep things simple
51     $this->assertEqual($provides->property[0]->uri,
52 richard.p.wagner 731 'ivo://net.ivoa.vospace/properties#size' );
53 richard.p.wagner 106 $this->assertEqual($provides->property[0]->readonly, True);
54    
55     $this->assertEqual($provides->property[1]->uri,
56 richard.p.wagner 731 'ivo://net.ivoa.vospace/properties#owner' );
57 richard.p.wagner 106 $this->assertEqual($provides->property[1]->readonly, True);
58    
59     $this->assertEqual($provides->property[2]->uri,
60 richard.p.wagner 731 'ivo://net.ivoa.vospace/properties#modificationdate' );
61 richard.p.wagner 106 $this->assertEqual($provides->property[2]->readonly, True);
62    
63     $this->assertEqual($provides->property[3]->uri,
64 richard.p.wagner 731 'ivo://net.ivoa.vospace/properties#creationdate' );
65 richard.p.wagner 106 $this->assertEqual($provides->property[3]->readonly, True);
66    
67 richard.p.wagner 731 // print '<pre>';
68 richard.p.wagner 106 // var_dump($provides);
69 richard.p.wagner 731 // print '</pre>';
70 richard.p.wagner 106 // barf($this->client);
71     }
72    
73    
74     function testNodeNotFound() {
75    
76     try {
77 richard.p.wagner 731 $response = $this->client->GetNode(array('target' => 'ivo://example.org!vospace/foo.txt'));
78 richard.p.wagner 106 }
79     catch (SoapFault $exp) {
80 richard.p.wagner 731 $this->assertEqual($exp->detail->NodeNotFoundFault->uri, 'ivo://example.org!vospace/foo.txt' );
81 richard.p.wagner 106 }
82    
83     }
84    
85     function testGetNode() {
86    
87 richard.p.wagner 731 $response = $this->client->GetNode(array('target' => 'ivo://example.org!vospace/128cubed_hierarchy.png'));
88 richard.p.wagner 106 $node = $response->node;
89     $properties = $response->properties;
90    
91 richard.p.wagner 731 $this->assertEqual($node->uri, 'ivo://example.org!vospace/128cubed_hierarchy.png' );
92 richard.p.wagner 106
93     $this->assertNotNull($node->properties);
94    
95     $this->assertEqual($node->properties->property[0]->uri,
96 richard.p.wagner 731 'ivo://net.ivoa.vospace/properties#size' );
97 richard.p.wagner 106 $this->assertEqual($node->properties->property[0]->readonly, True);
98    
99 richard.p.wagner 731 $this->assertEqual($node->properties->property[0]->_, '569516');
100 richard.p.wagner 106
101     $this->assertEqual($node->properties->property[1]->uri,
102 richard.p.wagner 731 'ivo://net.ivoa.vospace/properties#owner' );
103 richard.p.wagner 106 $this->assertEqual($node->properties->property[1]->readonly, True);
104    
105     $this->assertEqual($node->properties->property[2]->uri,
106 richard.p.wagner 731 'ivo://net.ivoa.vospace/properties#modificationdate' );
107 richard.p.wagner 106 $this->assertEqual($node->properties->property[2]->readonly, True);
108    
109     $this->assertEqual($node->properties->property[3]->uri,
110 richard.p.wagner 731 'ivo://net.ivoa.vospace/properties#creationdate' );
111 richard.p.wagner 106 $this->assertEqual($node->properties->property[3]->readonly, True);
112    
113     //barf_min($this->client);
114     }
115    
116 richard.p.wagner 731 function testPullFromNodeNotFound() {
117    
118     try {
119 richard.p.wagner 734 $response = $this->client->PullFromVoSpace(array('source' =>
120     'ivo://example.org!vospace/foo.txt',
121 richard.p.wagner 731 'transfer' => Null));
122     }
123     catch (SoapFault $exp) {
124     $this->assertEqual($exp->detail->NodeNotFoundFault->uri, 'ivo://example.org!vospace/foo.txt' );
125 richard.p.wagner 734 }
126 richard.p.wagner 731 }
127    
128 richard.p.wagner 734 function testPullFrom() {
129    
130     $view = array('uri' => 'ivo://net.ivoa.vospace/views#identity',
131     'original'=>True);
132     $protocol = array('uri' => 'ivo://net.ivoa.vospace/protocols#http-client');
133    
134     $request = array('source' =>
135     'ivo://example.org!vospace/bill_of_rights.txt',
136     'transfer' => array('view'=> $view,
137     'protocol' => $protocol));
138    
139     $response = $this->client->PullFromVoSpace($request);
140     $this->assertNotNull($response->transfer);
141    
142     $endpoint = $response->transfer->protocol->endpoint;
143    
144     // now we're going to check that the endpoint is
145     // really there
146     $this->assertTrue(url_exists($endpoint));
147 richard.p.wagner 106
148 richard.p.wagner 734 }
149    
150     function testListNodesNodeNotFound() {
151     $this->client->ListNodes();
152     $this->assertTrue(0);
153     }
154    
155     function testListNodesRoot() {
156     $this->client->ListNodes();
157     $this->assertTrue(0);
158     }
159    
160     // function testListNodesContainer() {
161 richard.p.wagner 731 // $this->client->ListNodes();
162     // }
163 richard.p.wagner 734
164     // function testListNodesSingleNode() {
165     // $this->client->ListNodes();
166     // }
167    
168     // function testListNodesWildcard() {
169     // $this->client->ListNodes();
170     // }
171    
172 richard.p.wagner 106 }
173    
174     $test = &new TestVOSpaceServiceEndpoint();
175     $test->run(new HtmlReporter());
176    
177     ?>

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