]> git.pond.sub.org Git - eow/blob - static/dojo-release-1.1.1/dojox/data/tests/stores/HtmlStore.js
add Dojo 1.1.1
[eow] / static / dojo-release-1.1.1 / dojox / data / tests / stores / HtmlStore.js
1 if(!dojo._hasResource["dojox.data.tests.stores.HtmlStore"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
2 dojo._hasResource["dojox.data.tests.stores.HtmlStore"] = true;
3 dojo.provide("dojox.data.tests.stores.HtmlStore");
4 dojo.require("dojox.data.HtmlStore");
5 dojo.require("dojo.data.api.Read");
6 dojo.require("dojo.data.api.Identity");
7
8
9 dojox.data.tests.stores.HtmlStore.getBooks3Store = function(){
10         return new dojox.data.HtmlStore({url: dojo.moduleUrl("dojox.data.tests", "stores/books3.html").toString(), dataId: "books3"});
11 };
12
13 dojox.data.tests.stores.HtmlStore.getBooks2Store = function(){
14         return new dojox.data.HtmlStore({url: dojo.moduleUrl("dojox.data.tests", "stores/books2.html").toString(), dataId: "books2"});
15 };
16
17 dojox.data.tests.stores.HtmlStore.getBooksStore = function(){
18         return new dojox.data.HtmlStore({url: dojo.moduleUrl("dojox.data.tests", "stores/books.html").toString(), dataId: "books"});
19 };
20
21 doh.register("dojox.data.tests.stores.HtmlStore", 
22         [
23 /***************************************
24      dojo.data.api.Read API
25 ***************************************/
26                 function testReadAPI_fetch_all_table(t){
27                         //      summary: 
28                         //              Simple test of fetching all xml items through an XML element called isbn
29                         //      description:
30                         //              Simple test of fetching all xml items through an XML element called isbn
31                         var store = dojox.data.tests.stores.HtmlStore.getBooksStore();
32
33                         var d = new doh.Deferred();
34                         function onComplete(items, request) {
35                                 t.assertEqual(20, items.length);
36                                 d.callback(true);
37                         }
38                         function onError(error, request) {
39                                 d.errback(error);
40                         }
41                         store.fetch({query:{isbn:"*"}, onComplete: onComplete, onError: onError});
42                         return d; //Object
43                 },
44                 function testReadAPI_fetch_all_list(t){
45                         //      summary: 
46                         //              Simple test of fetching all xml items through an XML element called isbn
47                         //      description:
48                         //              Simple test of fetching all xml items through an XML element called isbn
49                         var store = dojox.data.tests.stores.HtmlStore.getBooks3Store();
50
51                         var d = new doh.Deferred();
52                         function onComplete(items, request) {
53                                 t.assertEqual(5, items.length);
54                                 d.callback(true);
55                         }
56                         function onError(error, request) {
57                                 d.errback(error);
58                         }
59                         store.fetch({query:{name:"*"}, onComplete: onComplete, onError: onError});
60                         return d; //Object
61                 },
62                 function testReadAPI_fetch_one_table(t){
63                         //      summary: 
64                         //              Simple test of fetching one xml items through an XML element called isbn
65                         //      description:
66                         //              Simple test of fetching one xml items through an XML element called isbn
67                         var store = dojox.data.tests.stores.HtmlStore.getBooks2Store();
68
69                         var d = new doh.Deferred();
70                         function onComplete(items, request) {
71                                 t.assertEqual(1, items.length);
72                                 d.callback(true);
73                         }
74                         function onError(error, request) {
75                                 d.errback(error);
76                         }
77                         store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError});
78                         return d; //Object
79                 },
80                 function testReadAPI_fetch_one_list(t){
81                         //      summary: 
82                         //              Simple test of fetching one xml items through an XML element called isbn
83                         //      description:
84                         //              Simple test of fetching one xml items through an XML element called isbn
85                         var store = dojox.data.tests.stores.HtmlStore.getBooks3Store();
86
87                         var d = new doh.Deferred();
88                         function onComplete(items, request) {
89                                 t.assertEqual(1, items.length);
90                                 d.callback(true);
91                         }
92                         function onError(error, request) {
93                                 d.errback(error);
94                         }
95                         store.fetch({query:{name:"A9B57C - Title of 1 - Author of 1"}, onComplete: onComplete, onError: onError});
96                         return d; //Object
97                 },
98                 function testReadAPI_fetch_paging(t){
99                         //      summary: 
100                         //              Simple test of fetching one xml items through an XML element called isbn
101                         //      description:
102                         //              Simple test of fetching one xml items through an XML element called isbn
103                         var store = dojox.data.tests.stores.HtmlStore.getBooksStore();
104                         
105                         var d = new doh.Deferred();
106                         function dumpFirstFetch(items, request){
107                                 t.assertEqual(5, items.length);
108                                 request.start = 3;
109                                 request.count = 1;
110                                 request.onComplete = dumpSecondFetch;
111                                 store.fetch(request);
112                         }
113
114                         function dumpSecondFetch(items, request){
115                                 t.assertEqual(1, items.length);
116                                 request.start = 0;
117                                 request.count = 5;
118                                 request.onComplete = dumpThirdFetch;
119                                 store.fetch(request);
120                         }
121
122                         function dumpThirdFetch(items, request){
123                                 t.assertEqual(5, items.length);
124                                 request.start = 2;
125                                 request.count = 20;
126                                 request.onComplete = dumpFourthFetch;
127                                 store.fetch(request);
128                         }
129
130                         function dumpFourthFetch(items, request){
131                                 t.assertEqual(18, items.length);
132                                 request.start = 9;
133                                 request.count = 100;
134                                 request.onComplete = dumpFifthFetch;
135                                 store.fetch(request);
136                         }
137
138                         function dumpFifthFetch(items, request){
139                                 t.assertEqual(11, items.length);
140                                 request.start = 2;
141                                 request.count = 20;
142                                 request.onComplete = dumpSixthFetch;
143                                 store.fetch(request);
144                         }
145
146                         function dumpSixthFetch(items, request){
147                                 t.assertEqual(18, items.length);
148                                 d.callback(true);
149                         }
150
151                         function completed(items, request){
152                                 t.assertEqual(20, items.length);
153                                 request.start = 1;
154                                 request.count = 5;
155                                 request.onComplete = dumpFirstFetch;
156                                 store.fetch(request);
157                         }
158
159                         function error(errData, request){
160                                 d.errback(errData);
161                         }
162
163                         store.fetch({onComplete: completed, onError: error});
164                         return d; //Object
165                 },
166                 function testReadAPI_fetch_pattern0(t){
167                         //      summary: 
168                         //              Simple test of fetching one xml items through an XML element called isbn with ? pattern match
169                         //      description:
170                         //              Simple test of fetching one xml items through an XML element called isbn with ? pattern match
171                         var store = dojox.data.tests.stores.HtmlStore.getBooks2Store();
172                         var d = new doh.Deferred();                                                             
173                         function onComplete(items, request) {
174                                 t.assertEqual(1, items.length);
175                                 d.callback(true);
176                         }
177                         function onError(error, request) {
178                                 d.errback(error);
179                         }
180                         store.fetch({query:{isbn:"?9B574"}, onComplete: onComplete, onError: onError});
181                         return d; //Object
182                 },
183                 function testReadAPI_fetch_pattern1(t){
184                         //      summary: 
185                         //              Simple test of fetching one xml items through an XML element called isbn with ? pattern match
186                         //      description:
187                         //              Simple test of fetching one xml items through an XML element called isbn with ? pattern match
188                         var store = dojox.data.tests.stores.HtmlStore.getBooks2Store();
189                         var d = new doh.Deferred();
190                         function onComplete(items, request) {
191                                 t.assertEqual(4, items.length);
192                                 d.callback(true);
193                         }
194                         function onError(error, request) {
195                                 d.errback(error);
196                         }
197                         store.fetch({query:{isbn:"A9B57?"}, onComplete: onComplete, onError: onError});
198                         return d; //Object
199                 },
200                 function testReadAPI_fetch_pattern2(t){
201                         //      summary: 
202                         //              Simple test of fetching one xml items through an XML element called isbn with * pattern match
203                         //      description:
204                         //              Simple test of fetching one xml items through an XML element called isbn with * pattern match
205                         var store = dojox.data.tests.stores.HtmlStore.getBooks2Store();
206                         var d = new doh.Deferred();
207                         function onComplete(items, request) {
208                                 t.assertEqual(5, items.length);
209                                 d.callback(true);
210                         }
211                         function onError(error, request) {
212                                 d.errback(error);
213                         }
214                         store.fetch({query:{isbn:"A9*"}, onComplete: onComplete, onError: onError});
215                         return d; //Object
216                 },
217                 function testReadAPI_fetch_pattern_caseInsensitive(t){
218                         //      summary: 
219                         //              Simple test of fetching one xml items through an XML element called isbn with ? pattern match and in case insensitive mode.
220                         //      description:
221                         //              Simple test of fetching one xml items through an XML element called isbn with ? pattern match and in case insensitive mode.
222                         var store = dojox.data.tests.stores.HtmlStore.getBooks2Store();
223                         var d = new doh.Deferred();                                                             
224                         function onComplete(items, request) {
225                                 t.assertEqual(1, items.length);
226                                 d.callback(true);
227                         }
228                         function onError(error, request) {
229                                 d.errback(error);
230                         }
231                         store.fetch({query:{isbn:"?9b574"}, queryOptions: {ignoreCase: true}, onComplete: onComplete, onError: onError});
232                         return d; //Object
233                 },
234                 function testReadAPI_fetch_pattern_caseSensitive(t){
235                         //      summary: 
236                         //              Simple test of fetching one xml items through an XML element called isbn with ? pattern match and in case sensitive mode.
237                         //      description:
238                         //              Simple test of fetching one xml items through an XML element called isbn with ? pattern match and in case sensitive mode.
239                         var store = dojox.data.tests.stores.HtmlStore.getBooks2Store();
240                         var d = new doh.Deferred();                                                             
241                         function onComplete(items, request) {
242                                 t.assertEqual(1, items.length);
243                                 d.callback(true);
244                         }
245                         function onError(error, request) {
246                                 d.errback(error);
247                         }
248                         store.fetch({query:{isbn:"?9B574"}, queryOptions: {ignoreCase: false}, onComplete: onComplete, onError: onError});
249                         return d; //Object
250                 },
251                 function testReadAPI_getLabel_table(t){
252                         //      summary: 
253                         //              Simple test of the getLabel function against a store set that has a label defined.
254                         //      description:
255                         //              Simple test of the getLabel function against a store set that has a label defined.
256
257                         var store = dojox.data.tests.stores.HtmlStore.getBooks2Store();
258                         
259                         var d = new doh.Deferred();
260                         function onComplete(items, request){
261                                 t.assertEqual(items.length, 1);
262                                 var label = store.getLabel(items[0]);
263                                 t.assertTrue(label !== null);
264                                 t.assertEqual("Item #4", label);
265                                 d.callback(true);
266                         }
267                         function onError(error, request) {
268                                 d.errback(error);
269                         }
270                         store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError});
271                         return d;
272                 },
273                 function testReadAPI_getLabel_list(t){
274                         //      summary: 
275                         //              Simple test of the getLabel function against a store set that has a label defined.
276                         //      description:
277                         //              Simple test of the getLabel function against a store set that has a label defined.
278
279                         var store = dojox.data.tests.stores.HtmlStore.getBooks3Store();
280                         
281                         var d = new doh.Deferred();
282                         function onComplete(items, request){
283                                 t.assertEqual(items.length, 1);
284                                 var label = store.getLabel(items[0]);
285                                 t.assertTrue(label !== null);
286                                 t.assertEqual("A9B57C - Title of 1 - Author of 1", label);
287                                 d.callback(true);
288                         }
289                         function onError(error, request) {
290                                 d.errback(error);
291                         }
292                         store.fetch({query:{name:"A9B57C - Title of 1 - Author of 1"}, onComplete: onComplete, onError: onError});
293                         return d;
294                 },
295                 function testReadAPI_getLabelAttributes(t){
296                         //      summary: 
297                         //              Simple test of the getLabelAttributes function against a store set that has a label defined.
298                         //      description:
299                         //              Simple test of the getLabelAttributes function against a store set that has a label defined.
300
301                         var store = dojox.data.tests.stores.HtmlStore.getBooks2Store();
302                         
303                         var d = new doh.Deferred();
304                         function onComplete(items, request){
305                                 t.assertEqual(items.length, 1);
306                                 var labelList = store.getLabelAttributes(items[0]);
307                                 t.assertTrue(labelList === null);
308                                 d.callback(true);
309                         }
310                         function onError(error, request) {
311                                 d.errback(error);
312                         }
313                         store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError});
314                         return d;
315                 },
316
317                 function testReadAPI_getValue(t){
318                          //     summary: 
319                          //             Simple test of the getValue API
320                          //     description:
321                          //             Simple test of the getValue API
322                          var store = dojox.data.tests.stores.HtmlStore.getBooks2Store();
323
324                          var d = new doh.Deferred();
325                          function onComplete(items, request) {
326                                  t.assertEqual(1, items.length);
327                                  var item = items[0];
328                                  t.assertTrue(store.hasAttribute(item,"isbn"));
329                                  t.assertEqual(store.getValue(item,"isbn"), "A9B574");
330                                  d.callback(true);
331                          }
332                          function onError(error, request) {
333                                  d.errback(error);
334                          }
335                          store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError});
336                          return d; //Object
337                 },
338                 function testReadAPI_getValues(t){
339                          //     summary: 
340                          //             Simple test of the getValues API
341                          //     description:
342                          //             Simple test of the getValues API
343                          var store = dojox.data.tests.stores.HtmlStore.getBooks2Store();
344
345                          var d = new doh.Deferred();
346                          function onComplete(items, request) {
347                                  t.assertEqual(1, items.length);
348                                  var item = items[0];
349                                  t.assertTrue(store.hasAttribute(item,"isbn"));
350                                  var values = store.getValues(item,"isbn");
351                                  t.assertEqual(1,values.length);
352                                  t.assertEqual("A9B574", values[0]);
353                                  d.callback(true);
354                          }
355                          function onError(error, request) {
356                                  d.errback(error);
357                          }
358                          store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError});
359                          return d; //Object
360                 },
361                 function testReadAPI_isItem(t){
362                          //     summary: 
363                          //             Simple test of the isItem API
364                          //     description:
365                          //             Simple test of the isItem API
366                          var store = dojox.data.tests.stores.HtmlStore.getBooks2Store();
367
368                          var d = new doh.Deferred();
369                          function onComplete(items, request) {
370                                 t.assertEqual(1, items.length);
371                                 var item = items[0];
372                                 t.assertTrue(store.isItem(item));
373                                 t.assertTrue(!store.isItem({}));
374                                 t.assertTrue(!store.isItem("Foo"));
375                                 t.assertTrue(!store.isItem(1));
376                                 d.callback(true);
377                          }
378                          function onError(error, request) {
379                                  d.errback(error);
380                          }
381                          store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError});
382                          return d; //Object
383                 },
384                 function testReadAPI_isItem_multistore(t){
385                         //      summary: 
386                         //              Simple test of the isItem API across multiple store instances.
387                         //      description:
388                         //              Simple test of the isItem API across multiple store instances.
389                         var store1 = dojox.data.tests.stores.HtmlStore.getBooksStore();
390                         var store2 = dojox.data.tests.stores.HtmlStore.getBooks2Store();
391
392                         var d = new doh.Deferred();
393                         function onComplete1(items, request) {
394                                 t.assertEqual(1, items.length);
395                                 var item1 = items[0];
396                                 t.assertTrue(store1.isItem(item1));
397
398                                 function onComplete2(items, request) {
399                                         t.assertEqual(1, items.length);
400                                         var item2 = items[0];
401                                         t.assertTrue(store2.isItem(item2));
402                                         t.assertTrue(!store1.isItem(item2));
403                                         t.assertTrue(!store2.isItem(item1));
404                                         d.callback(true);
405                                 }
406                                 store2.fetch({query:{isbn:"A9B574"}, onComplete: onComplete2, onError: onError});
407                         }
408                         function onError(error, request) {
409                                 d.errback(error);
410                         }
411                         store1.fetch({query:{isbn:"1"}, onComplete: onComplete1, onError: onError});
412                         return d; //Object
413                 },
414                 function testReadAPI_hasAttribute(t){
415                         //      summary: 
416                         //              Simple test of the hasAttribute API
417                         //      description:
418                         //              Simple test of the hasAttribute API
419                         var store = dojox.data.tests.stores.HtmlStore.getBooks2Store();
420
421                         var d = new doh.Deferred();
422                         function onComplete(items, request) {
423                                 t.assertEqual(1, items.length);
424                                 var item = items[0];
425                                 t.assertTrue(store.hasAttribute(item,"isbn"));
426                                 t.assertTrue(!store.hasAttribute(item,"bob"));
427                                 d.callback(true);
428                         }
429                         function onError(error, request) {
430                                 d.errback(error);
431                         }
432                         store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError});
433                         return d; //Object
434                 },
435                 function testReadAPI_containsValue(t){
436                         //      summary: 
437                         //              Simple test of the containsValue API
438                         //      description:
439                         //              Simple test of the containsValue API
440                         var store = dojox.data.tests.stores.HtmlStore.getBooks2Store();
441
442                         var d = new doh.Deferred();
443                         function onComplete(items, request) {
444                                 t.assertEqual(1, items.length);
445                                 var item = items[0];
446                                 t.assertTrue(store.containsValue(item,"isbn", "A9B574"));
447                                 t.assertTrue(!store.containsValue(item,"isbn", "bob"));
448                                 d.callback(true);
449                         }
450                         function onError(error, request) {
451                                 d.errback(error);
452                         }
453                         store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError});
454                         return d; //Object
455                 },
456                 function testReadAPI_sortDescending(t){
457                         //      summary: 
458                         //              Simple test of the sorting API in descending order.
459                         //      description:
460                         //              Simple test of the sorting API in descending order.
461                         var store = dojox.data.tests.stores.HtmlStore.getBooksStore();
462
463                         //Comparison is done as a string type (toString comparison), so the order won't be numeric
464                         //So have to compare in 'alphabetic' order.
465                         var order = [9,8,7,6,5,4,3,20,2,19,18,17,16,15,14,13,12,11,10,1];
466                         
467                         var d = new doh.Deferred();
468                         function onComplete(items, request) {
469                                 t.assertEqual(20, items.length);
470
471                                 for(var i = 0; i < items.length; i++){
472                                         t.assertEqual(order[i], store.getValue(items[i],"isbn").toString());
473                                 }
474                                 d.callback(true);
475                         }
476                         function onError(error, request) {
477                                 d.errback(error);
478                         }
479
480                         var sortAttributes = [{attribute: "isbn", descending: true}];
481                         store.fetch({query:{isbn:"*"}, sort: sortAttributes, onComplete: onComplete, onError: onError});
482                         return d; //Object
483                 },
484                 function testReadAPI_sortAscending(t){
485                         //      summary: 
486                         //              Simple test of the sorting API in ascending order.
487                         //      description:
488                         //              Simple test of the sorting API in ascending order.
489                         var store = dojox.data.tests.stores.HtmlStore.getBooksStore();
490
491                         //Comparison is done as a string type (toString comparison), so the order won't be numeric
492                         //So have to compare in 'alphabetic' order.
493                         var order = [1,10,11,12,13,14,15,16,17,18,19,2,20,3,4,5,6,7,8,9];
494                                                 
495                         var d = new doh.Deferred();
496                         function onComplete(items, request) {
497                                 t.assertEqual(20, items.length);
498                                 var itemId = 1;
499                                 for(var i = 0; i < items.length; i++){
500                                         t.assertEqual(order[i], store.getValue(items[i],"isbn").toString());
501                                 }
502                                 d.callback(true);
503                         }
504                         function onError(error, request) {
505                                 d.errback(error);
506                         }
507
508                         var sortAttributes = [{attribute: "isbn"}];
509                         store.fetch({query:{isbn:"*"}, sort: sortAttributes, onComplete: onComplete, onError: onError});
510                         return d; //Object
511                 },
512                 function testReadAPI_sortDescendingNumeric(t){
513                         //      summary: 
514                         //              Simple test of the sorting API in descending order using a numeric comparator.
515                         //      description:
516                         //              Simple test of the sorting API in descending order using a numeric comparator.
517                         var store = dojox.data.tests.stores.HtmlStore.getBooksStore();
518
519                         //isbn should be treated as a numeric, not as a string comparison
520                         store.comparatorMap = {};
521                         store.comparatorMap["isbn"] = function(a, b){
522                                 var ret = 0;
523                                 if(parseInt(a.toString()) > parseInt(b.toString())){
524                                         ret = 1;
525                                 }else if(parseInt(a.toString()) < parseInt(b.toString())){
526                                         ret = -1;
527                                 }
528                                 return ret; //int, {-1,0,1}
529                         };
530
531                         var d = new doh.Deferred();
532                         function onComplete(items, request) {
533                                 t.assertEqual(20, items.length);
534                                 var itemId = 20;
535                                 for(var i = 0; i < items.length; i++){
536                                         t.assertEqual(itemId, store.getValue(items[i],"isbn").toString());
537                                         itemId--;
538                                 }
539                                 d.callback(true);
540                         }
541                         function onError(error, request) {
542                                 d.errback(error);
543                         }
544
545                         var sortAttributes = [{attribute: "isbn", descending: true}];
546                         store.fetch({query:{isbn:"*"}, sort: sortAttributes, onComplete: onComplete, onError: onError});
547                         return d; //Object
548                 },
549                 function testReadAPI_sortAscendingNumeric(t){
550                         //      summary: 
551                         //              Simple test of the sorting API in ascending order using a numeric comparator.
552                         //      description:
553                         //              Simple test of the sorting API in ascending order using a numeric comparator.
554                         var store = dojox.data.tests.stores.HtmlStore.getBooksStore();
555
556                         //isbn should be treated as a numeric, not as a string comparison
557                         store.comparatorMap = {};
558                         store.comparatorMap["isbn"] = function(a, b){
559                                 var ret = 0;
560                                 if(parseInt(a.toString()) > parseInt(b.toString())){
561                                         ret = 1;
562                                 }else if(parseInt(a.toString()) < parseInt(b.toString())){
563                                         ret = -1;
564                                 }
565                                 return ret; //int, {-1,0,1}
566                         };
567
568                         var d = new doh.Deferred();
569                         function onComplete(items, request) {
570                                 t.assertEqual(20, items.length);
571                                 var itemId = 1;
572                                 for(var i = 0; i < items.length; i++){
573                                         t.assertEqual(itemId, store.getValue(items[i],"isbn").toString());
574                                         itemId++;
575                                 }
576                                 d.callback(true);
577                         }
578                         function onError(error, request) {
579                                 d.errback(error);
580                         }
581
582                         var sortAttributes = [{attribute: "isbn"}];
583                         store.fetch({query:{isbn:"*"}, sort: sortAttributes, onComplete: onComplete, onError: onError});
584                         return d; //Object
585                 },
586                 function testReadAPI_isItemLoaded(t){
587                         //      summary: 
588                         //              Simple test of the isItemLoaded API
589                         //      description:
590                         //              Simple test of the isItemLoaded API
591                         var store = dojox.data.tests.stores.HtmlStore.getBooks2Store();
592
593                         var d = new doh.Deferred();
594                         function onComplete(items, request) {
595                                 t.assertEqual(1, items.length);
596                                 var item = items[0];
597                                 t.assertTrue(store.isItemLoaded(item));
598                                 d.callback(true);
599                         }
600                         function onError(error, request) {
601                                 d.errback(error);
602                         }
603                         store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError});
604                         return d; //Object
605                 },
606                 function testReadAPI_getFeatures(t){
607                         //      summary: 
608                         //              Simple test of the getFeatures function of the store
609                         //      description:
610                         //              Simple test of the getFeatures function of the store
611
612                         var store = dojox.data.tests.stores.HtmlStore.getBooks2Store();
613                         var features = store.getFeatures(); 
614                         var count = 0;
615                         for(i in features){
616                                 t.assertTrue((i === "dojo.data.api.Read" || i === "dojo.data.api.Identity"));
617                                 count++;
618                         }
619                         t.assertEqual(2, count);
620                 },
621                 function testReadAPI_getAttributes(t){
622                         //      summary: 
623                         //              Simple test of the getAttributes API
624                         //      description:
625                         //              Simple test of the getAttributes API
626                         var store = dojox.data.tests.stores.HtmlStore.getBooks2Store();
627
628                         var d = new doh.Deferred();
629                         function onComplete(items, request) {
630                                 t.assertEqual(1, items.length);
631                                 var item = items[0];
632                                 var attributes = store.getAttributes(item);
633                                 t.assertEqual(3,attributes.length);
634                                 for(var i=0; i<attributes.length; i++){
635                                         t.assertTrue((attributes[i] === "isbn" || attributes[i] === "title" || attributes[i] === "author"));
636                                 }
637                                 d.callback(true);
638                         }
639                         function onError(error, request) {
640                                 d.errback(error);
641                         }
642                         store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError});
643                         return d; //Object
644                 },
645                 function testReadAPI_functionConformance(t){
646                         //      summary: 
647                         //              Simple test read API conformance.  Checks to see all declared functions are actual functions on the instances.
648                         //      description:
649                         //              Simple test read API conformance.  Checks to see all declared functions are actual functions on the instances.
650
651                         var testStore = dojox.data.tests.stores.HtmlStore.getBooksStore();
652                         var readApi = new dojo.data.api.Read();
653                         var passed = true;
654
655                         for(i in readApi){
656                                 var member = readApi[i];
657                                 //Check that all the 'Read' defined functions exist on the test store.
658                                 if(typeof member === "function"){
659                                         var testStoreMember = testStore[i];
660                                         if(!(typeof testStoreMember === "function")){
661                                                 console.log("Problem with function: [" + i + "]");
662                                                 passed = false;
663                                                 break;
664                                         }
665                                 }
666                         }
667                         t.assertTrue(passed);
668                 },
669 /***************************************
670      dojo.data.api.Identity API
671 ***************************************/
672                 function testIdentityAPI_getIdentity_table(t){
673                         //      summary: 
674                         //              Simple test of the getAttributes API
675                         //      description:
676                         //              Simple test of the getAttributes API
677                         var store = dojox.data.tests.stores.HtmlStore.getBooks2Store();
678
679                         var d = new doh.Deferred();
680                         function onComplete(items, request) {
681                                 t.assertEqual(1, items.length);
682                                 var item = items[0];
683                                 t.assertEqual(4,store.getIdentity(item));
684                                 d.callback(true);
685                         }
686                         function onError(error, request) {
687                                 d.errback(error);
688                         }
689                         store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError});
690                         return d; //Object
691                 },
692                 function testIdentityAPI_getIdentity_list(t){
693                         //      summary: 
694                         //              Simple test of the getAttributes API
695                         //      description:
696                         //              Simple test of the getAttributes API
697                         var store = dojox.data.tests.stores.HtmlStore.getBooks3Store();
698
699                         var d = new doh.Deferred();
700                         function onComplete(items, request) {
701                                 t.assertEqual(1, items.length);
702                                 var item = items[0];
703                                 t.assertEqual("A9B57C - Title of 1 - Author of 1",store.getIdentity(item));
704                                 d.callback(true);
705                         }
706                         function onError(error, request) {
707                                 d.errback(error);
708                         }
709                         store.fetch({query:{name:"A9B57C - Title of 1 - Author of 1"}, onComplete: onComplete, onError: onError});
710                         return d; //Object
711                 },
712                 function testIdentityAPI_getIdentityAttributes(t){
713                         //      summary: 
714                         //              Simple test of the getAttributes API
715                         //      description:
716                         //              Simple test of the getAttributes API
717                         var store = dojox.data.tests.stores.HtmlStore.getBooks2Store();
718
719                         var d = new doh.Deferred();
720                         function onComplete(items, request) {
721                                 t.assertEqual(1, items.length);
722                                 var item = items[0];
723                                 //Should have none, as it's not a public attribute.
724                                 var attributes = store.getIdentityAttributes(item);
725                                 t.assertEqual(null, attributes);
726                                 d.callback(true);
727                         }
728                         function onError(error, request) {
729                                 d.errback(error);
730                         }
731                         store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError});
732                         return d; //Object
733                 },
734                 function testIdentityAPI_fetchItemByIdentity_table(t){
735                         //      summary: 
736                         //              Simple test of the fetchItemByIdentity API
737                         //      description:
738                         //              Simple test of the fetchItemByIdentity API
739                         var store = dojox.data.tests.stores.HtmlStore.getBooks2Store();
740
741                         var d = new doh.Deferred();
742                         function onItem(item, request) {
743                                 t.assertTrue(item !== null);
744                                 t.assertTrue(store.isItem(item));
745                                 t.assertEqual("A9B574", store.getValue(item, "isbn"));
746                                 d.callback(true);
747                         }
748                         function onError(error, request) {
749                                 d.errback(error);
750                         }
751                         store.fetchItemByIdentity({identity: 4, onItem: onItem, onError: onError});
752                         return d; //Object
753                 },
754                 function testIdentityAPI_fetchItemByIdentity_list(t){
755                         //      summary: 
756                         //              Simple test of the fetchItemByIdentity API
757                         //      description:
758                         //              Simple test of the fetchItemByIdentity API
759                         var store = dojox.data.tests.stores.HtmlStore.getBooks3Store();
760
761                         var d = new doh.Deferred();
762                         function onItem(item, request) {
763                                 t.assertTrue(item !== null);
764                                 t.assertTrue(store.isItem(item));
765                                 t.assertEqual("A9B57C - Title of 1 - Author of 1", store.getValue(item, "name"));
766                                 d.callback(true);
767                         }
768                         function onError(error, request) {
769                                 d.errback(error);
770                         }
771                         store.fetchItemByIdentity({identity: "A9B57C - Title of 1 - Author of 1", onItem: onItem, onError: onError});
772                         return d; //Object
773                 },
774                 function testIdentityAPI_functionConformance(t){
775                         //      summary: 
776                         //              Simple test identity API conformance.  Checks to see all declared functions are actual functions on the instances.
777                         //      description:
778                         //              Simple test identity API conformance.  Checks to see all declared functions are actual functions on the instances.
779
780                         var testStore = dojox.data.tests.stores.HtmlStore.getBooksStore();
781                         var identityApi = new dojo.data.api.Identity();
782                         var passed = true;
783
784                         for(i in identityApi){
785                                 var member = identityApi[i];
786                                 //Check that all the 'Read' defined functions exist on the test store.
787                                 if(typeof member === "function"){
788                                         var testStoreMember = testStore[i];
789                                         if(!(typeof testStoreMember === "function")){
790                                                 console.log("Problem with function: [" + i + "]");
791                                                 passed = false;
792                                                 break;
793                                         }
794                                 }
795                         }
796                         t.assertTrue(passed);
797                 }
798         ]
799 );
800
801 //Register the remote tests ... when they work.
802 //doh.registerUrl("dojox.data.tests.stores.HtmlStore.remote", dojo.moduleUrl("dojox.data.tests", "ml/test_HtmlStore_declaratively.html"));
803
804 }