From 1c5685d68f1b73270fb814fe04cbb490eb90ba5f Mon Sep 17 00:00:00 2001 From: mensonge Date: Fri, 14 Nov 2008 15:39:19 +0000 Subject: Minor fix: Remove DOJO library (60Mo) replaced by link to Google CDN (online DOJO library) git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@159 b3834d28-1941-0410-a4f8-b48e95affb8f --- .../js/dojox/data/tests/stores/AtomReadStore.js | 641 ----------- includes/js/dojox/data/tests/stores/CsvStore.js | 1127 -------------------- .../js/dojox/data/tests/stores/FlickrRestStore.js | 476 --------- includes/js/dojox/data/tests/stores/FlickrStore.js | 410 ------- includes/js/dojox/data/tests/stores/HtmlStore.js | 804 -------------- .../js/dojox/data/tests/stores/HtmlTableStore.js | 702 ------------ .../js/dojox/data/tests/stores/KeyValueStore.js | 1002 ----------------- includes/js/dojox/data/tests/stores/OpmlStore.js | 1075 ------------------- .../js/dojox/data/tests/stores/QueryReadStore.js | 442 -------- .../js/dojox/data/tests/stores/QueryReadStore.php | 114 -- .../js/dojox/data/tests/stores/SnapLogicStore.js | 438 -------- includes/js/dojox/data/tests/stores/XmlStore.js | 881 --------------- includes/js/dojox/data/tests/stores/atom1.xml | 848 --------------- includes/js/dojox/data/tests/stores/books.html | 118 -- includes/js/dojox/data/tests/stores/books.xml | 103 -- includes/js/dojox/data/tests/stores/books2.html | 43 - includes/js/dojox/data/tests/stores/books2.xml | 28 - includes/js/dojox/data/tests/stores/books3.html | 14 - includes/js/dojox/data/tests/stores/books3.xml | 31 - .../js/dojox/data/tests/stores/books_isbnAttr.xml | 23 - .../js/dojox/data/tests/stores/books_isbnAttr2.xml | 23 - includes/js/dojox/data/tests/stores/geography.xml | 51 - .../tests/stores/geography_withspeciallabel.xml | 51 - .../js/dojox/data/tests/stores/jsonPathStore.js | 604 ----------- includes/js/dojox/data/tests/stores/movies.csv | 9 - includes/js/dojox/data/tests/stores/movies2.csv | 9 - includes/js/dojox/data/tests/stores/patterns.csv | 11 - includes/js/dojox/data/tests/stores/properties.js | 10 - .../js/dojox/data/tests/stores/snap_pipeline.php | 72 -- 29 files changed, 10160 deletions(-) delete mode 100644 includes/js/dojox/data/tests/stores/AtomReadStore.js delete mode 100644 includes/js/dojox/data/tests/stores/CsvStore.js delete mode 100644 includes/js/dojox/data/tests/stores/FlickrRestStore.js delete mode 100644 includes/js/dojox/data/tests/stores/FlickrStore.js delete mode 100644 includes/js/dojox/data/tests/stores/HtmlStore.js delete mode 100644 includes/js/dojox/data/tests/stores/HtmlTableStore.js delete mode 100644 includes/js/dojox/data/tests/stores/KeyValueStore.js delete mode 100644 includes/js/dojox/data/tests/stores/OpmlStore.js delete mode 100644 includes/js/dojox/data/tests/stores/QueryReadStore.js delete mode 100644 includes/js/dojox/data/tests/stores/QueryReadStore.php delete mode 100644 includes/js/dojox/data/tests/stores/SnapLogicStore.js delete mode 100644 includes/js/dojox/data/tests/stores/XmlStore.js delete mode 100644 includes/js/dojox/data/tests/stores/atom1.xml delete mode 100644 includes/js/dojox/data/tests/stores/books.html delete mode 100644 includes/js/dojox/data/tests/stores/books.xml delete mode 100644 includes/js/dojox/data/tests/stores/books2.html delete mode 100644 includes/js/dojox/data/tests/stores/books2.xml delete mode 100644 includes/js/dojox/data/tests/stores/books3.html delete mode 100644 includes/js/dojox/data/tests/stores/books3.xml delete mode 100644 includes/js/dojox/data/tests/stores/books_isbnAttr.xml delete mode 100644 includes/js/dojox/data/tests/stores/books_isbnAttr2.xml delete mode 100644 includes/js/dojox/data/tests/stores/geography.xml delete mode 100644 includes/js/dojox/data/tests/stores/geography_withspeciallabel.xml delete mode 100644 includes/js/dojox/data/tests/stores/jsonPathStore.js delete mode 100644 includes/js/dojox/data/tests/stores/movies.csv delete mode 100644 includes/js/dojox/data/tests/stores/movies2.csv delete mode 100644 includes/js/dojox/data/tests/stores/patterns.csv delete mode 100644 includes/js/dojox/data/tests/stores/properties.js delete mode 100644 includes/js/dojox/data/tests/stores/snap_pipeline.php (limited to 'includes/js/dojox/data/tests/stores') diff --git a/includes/js/dojox/data/tests/stores/AtomReadStore.js b/includes/js/dojox/data/tests/stores/AtomReadStore.js deleted file mode 100644 index 1df9493..0000000 --- a/includes/js/dojox/data/tests/stores/AtomReadStore.js +++ /dev/null @@ -1,641 +0,0 @@ -if(!dojo._hasResource["dojox.data.tests.stores.AtomReadStore"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. -dojo._hasResource["dojox.data.tests.stores.AtomReadStore"] = true; -dojo.provide("dojox.data.tests.stores.AtomReadStore"); -dojo.require("dojox.data.AtomReadStore"); -dojo.require("dojo.data.api.Read"); - -dojox.data.tests.stores.AtomReadStore.getBlog1Store = function(){ - return new dojox.data.AtomReadStore({url: dojo.moduleUrl("dojox.data.tests", "stores/atom1.xml").toString()}); - //return new dojox.data.AtomReadStore({url: "/sos/feeds/blog.php"}); -}; -/* -dojox.data.tests.stores.AtomReadStore.getBlog2Store = function(){ - return new dojox.data.AtomReadStore({url: dojo.moduleUrl("dojox.data.tests", "stores/atom2.xml").toString()}); -}; -*/ -dojox.data.tests.stores.AtomReadStore.error = function(t, d, errData){ - // summary: - // The error callback function to be used for all of the tests. - //console.log("In here."); - //console.trace(); - d.errback(errData); -} - -doh.register("dojox.data.tests.stores.AtomReadStore", - [ - { - name: "ReadAPI: Fetch_One", - timeout: 5000, //1 second - runTest: function(t) { - // summary: - // Simple test of a basic fetch on AtomReadStore of a single item. - // description: - // Simple test of a basic fetch on AtomReadStore of a single item. - - var atomStore = dojox.data.tests.stores.AtomReadStore.getBlog1Store(); - - var d = new doh.Deferred(); - function onComplete(items, request){ - t.is(1, items.length); - d.callback(true); - } - atomStore.fetch({ - query: { - }, - count: 1, - onComplete: onComplete, - onError: dojo.partial(dojox.data.tests.stores.AtomReadStore.error, doh, d) - }); - return d; //Object - } - }, - { - name: "ReadAPI: Fetch_5_Streaming", - timeout: 5000, //1 second. - runTest: function(t) { - // summary: - // Simple test of a basic fetch on AtomReadStore. - // description: - // Simple test of a basic fetch on AtomReadStore. - var atomStore = dojox.data.tests.stores.AtomReadStore.getBlog1Store(); - - var d = new doh.Deferred(); - var count = 0; - - function onItem(item, requestObj){ - t.assertTrue(atomStore.isItem(item)); - count++; - } - function onComplete(items, request){ - t.is(5, count); - - t.is(null, items); - d.callback(true); - } - //Get everything... - atomStore.fetch({ - query: { - }, - onBegin: null, - count: 5, - onItem: onItem, - onComplete: onComplete, - onError: dojo.partial(dojox.data.tests.stores.AtomReadStore.error, t, d) - }); - return d; //Object - } - }, - { - name: "ReadAPI: Fetch_Paging", - timeout: 5000, //1 second. - runTest: function(t) { - // summary: - // Test of multiple fetches on a single result. Paging, if you will. - // description: - // Test of multiple fetches on a single result. Paging, if you will. - - var atomStore = dojox.data.tests.stores.AtomReadStore.getBlog1Store(); - var d = new doh.Deferred(); - - function dumpFirstFetch(items, request){ - t.is(5, items.length); - request.start = 3; - request.count = 1; - request.onComplete = dumpSecondFetch; - atomStore.fetch(request); - } - - function dumpSecondFetch(items, request){ - console.log("dumpSecondFetch: got "+items.length); - t.is(1, items.length); - request.start = 0; - request.count = 5; - request.onComplete = dumpThirdFetch; - atomStore.fetch(request); - } - - function dumpThirdFetch(items, request){ - console.log("dumpThirdFetch: got "+items.length); - t.is(5, items.length); - request.start = 2; - request.count = 18; - request.onComplete = dumpFourthFetch; - atomStore.fetch(request); - } - - function dumpFourthFetch(items, request){ - console.log("dumpFourthFetch: got "+items.length); - t.is(18, items.length); - request.start = 5; - request.count = 11; - request.onComplete = dumpFifthFetch; - atomStore.fetch(request); - } - - function dumpFifthFetch(items, request){ - console.log("dumpFifthFetch: got "+items.length); - t.is(11, items.length); - request.start = 4; - request.count = 16; - request.onComplete = dumpSixthFetch; - atomStore.fetch(request); - } - - function dumpSixthFetch(items, request){ - console.log("dumpSixthFetch: got "+items.length); - t.is(16, items.length); - d.callback(true); - } - - function completed(items, request){ - t.is(7, items.length); - request.start = 1; - request.count = 5; - request.onComplete = dumpFirstFetch; - atomStore.fetch(request); - } - atomStore.fetch({ - query: { - }, - count: 7, - onComplete: completed, - onError: dojo.partial(dojox.data.tests.stores.AtomReadStore.error, t, d) - }); - return d; //Object - } - }, - { - name: "ReadAPI: getLabel", - timeout: 5000, //1 second. - runTest: function(t) { - // summary: - // Simple test of the getLabel function against a store set that has a label defined. - // description: - // Simple test of the getLabel function against a store set that has a label defined. - - var atomStore = dojox.data.tests.stores.AtomReadStore.getBlog1Store(); - - var d = new doh.Deferred(); - function onComplete(items, request){ - t.assertEqual(items.length, 1); - var label = atomStore.getLabel(items[0]); - t.assertTrue(label !== null); - d.callback(true); - } - atomStore.fetch({ - query: { - }, - count: 1, - onComplete: onComplete, - onError: dojo.partial(dojox.data.tests.stores.AtomReadStore.error, t, d) - }); - return d; - } - }, - { - name: "ReadAPI: getLabelAttributes", - timeout: 5000, //1 second - runTest: function(t) { - // summary: - // Simple test of the getLabelAttributes function against a store set that has a label defined. - // description: - // Simple test of the getLabelAttributes function against a store set that has a label defined. - - var atomStore = dojox.data.tests.stores.AtomReadStore.getBlog1Store(); - - var d = new doh.Deferred(); - function onComplete(items, request){ - t.assertEqual(items.length, 1); - var labelList = atomStore.getLabelAttributes(items[0]); - t.assertTrue(dojo.isArray(labelList)); - t.assertEqual("title", labelList[0]); - d.callback(true); - } - atomStore.fetch({ - query: { - }, - count: 1, - onComplete: onComplete, - onError: dojo.partial(dojox.data.tests.stores.AtomReadStore.error, t, d) - }); - return d; - - } - }, - { - name: "ReadAPI: getValue", - timeout: 5000, //1 second - runTest: function(t) { - // summary: - // Simple test of the getValue function of the store. - // description: - // Simple test of the getValue function of the store. - var atomStore = dojox.data.tests.stores.AtomReadStore.getBlog1Store(); - - var d = new doh.Deferred(); - function completedAll(items){ - t.is(1, items.length); - t.assertTrue(atomStore.getValue(items[0], "summary") !== null); - t.assertTrue(atomStore.getValue(items[0], "content") !== null); - t.assertTrue(atomStore.getValue(items[0], "published") !== null); - t.assertTrue(atomStore.getValue(items[0], "updated") !== null); - console.log("typeof updated = "+typeof(atomStore.getValue(items[0], "updated"))); - t.assertTrue(atomStore.getValue(items[0], "updated").getFullYear); - d.callback(true); - } - - //Get one item and look at it. - atomStore.fetch({ - query: { - }, - count: 1, - onComplete: completedAll, - onError: dojo.partial(dojox.data.tests.stores.AtomReadStore.error, t, d)}); - return d; //Object - } - }, - { - name: "ReadAPI: getValue_Failure", - timeout: 5000, //1 second - runTest: function(t) { - // summary: - // Simple test of the getValue function of the store. - // description: - // Simple test of the getValue function of the store. - var atomStore = dojox.data.tests.stores.AtomReadStore.getBlog1Store(); - var passed = false; - try{ - var value = store.getValue("NotAnItem", foo); - }catch(e){ - passed = true; - } - t.assertTrue(passed); - } - }, - { - name: "ReadAPI: getValues", - timeout: 5000, //1 second - runTest: function(t) { - // summary: - // Simple test of the getValue function of the store. - // description: - // Simple test of the getValue function of the store. - var atomStore = dojox.data.tests.stores.AtomReadStore.getBlog1Store(); - - var d = new doh.Deferred(); - function completedAll(items){ - t.is(1, items.length); - var summary = atomStore.getValues(items[0], "summary"); - t.assertTrue(dojo.isArray(summary)); - - var content = atomStore.getValues(items[0], "content"); - t.assertTrue(dojo.isArray(content)); - - var published = atomStore.getValues(items[0], "published"); - t.assertTrue(dojo.isArray(published)); - - var updated = atomStore.getValues(items[0], "updated"); - t.assertTrue(dojo.isArray(updated)); - d.callback(true); - } - //Get one item and look at it. - atomStore.fetch({ - query: { - }, - count: 1, - onComplete: completedAll, - onError: dojo.partial(dojox.data.tests.stores.AtomReadStore.error, - t, - d) - }); - return d; //Object - } - }, - { - name: "ReadAPI: getValues_Failure", - timeout: 5000, //1 second - runTest: function(t) { - // summary: - // Simple test of the getValue function of the store. - // description: - // Simple test of the getValue function of the store. - var atomStore = dojox.data.tests.stores.AtomReadStore.getBlog1Store(); - var passed = false; - try{ - var value = store.getValues("NotAnItem", foo); - }catch(e){ - passed = true; - } - t.assertTrue(passed); - } - }, - { - name: "ReadAPI: isItem", - timeout: 5000, //1 second - runTest: function(t) { - // summary: - // Simple test of the isItem function of the store - // description: - // Simple test of the isItem function of the store - var atomStore = dojox.data.tests.stores.AtomReadStore.getBlog1Store(); - - var d = new doh.Deferred(); - function completedAll(items){ - t.is(5, items.length); - for(var i=0; i < items.length; i++){ - t.assertTrue(atomStore.isItem(items[i])); - } - d.callback(true); - } - - //Get everything... - atomStore.fetch({ - query: { - }, - count: 5, - onComplete: completedAll, - onError: dojo.partial(dojox.data.tests.stores.AtomReadStore.error, t, d) - }); - return d; //Object - } - }, - { - name: "ReadAPI: hasAttribute", - timeout: 5000, //1 second - runTest: function(t) { - // summary: - // Simple test of the hasAttribute function of the store - // description: - // Simple test of the hasAttribute function of the store - - var atomStore = dojox.data.tests.stores.AtomReadStore.getBlog1Store(); - - var d = new doh.Deferred(); - function onComplete(items){ - t.is(1, items.length); - t.assertTrue(items[0] !== null); - var count = 0; - console.log("hasAttribute"); - t.assertTrue(atomStore.hasAttribute(items[0], "author")); - t.assertTrue(atomStore.hasAttribute(items[0], "published")); - t.assertTrue(atomStore.hasAttribute(items[0], "updated")); - t.assertTrue(atomStore.hasAttribute(items[0], "category")); - t.assertTrue(atomStore.hasAttribute(items[0], "id")); - t.assertTrue(!atomStore.hasAttribute(items[0], "foo")); - t.assertTrue(!atomStore.hasAttribute(items[0], "bar")); - - - t.assertTrue(atomStore.hasAttribute(items[0], "summary")); - t.assertTrue(atomStore.hasAttribute(items[0], "content")); - t.assertTrue(atomStore.hasAttribute(items[0], "title")); - - - var summary = atomStore.getValue(items[0], "summary"); - var content = atomStore.getValue(items[0], "content"); - var title = atomStore.getValue(items[0], "title"); - - t.assertTrue(summary && summary.text && summary.type == "html"); - t.assertTrue(content && content.text && content.type == "html"); - t.assertTrue(title && title.text && title.type == "html"); - - //Test that null attributes throw an exception - try{ - atomStore.hasAttribute(items[0], null); - t.assertTrue(false); - }catch (e){ - - } - d.callback(true); - } - - //Get one item... - atomStore.fetch({ - query: { - }, - count: 1, - onComplete: onComplete, - onError: dojo.partial(dojox.data.tests.stores.AtomReadStore.error, t, d) - }); - return d; //Object - } - }, - { - name: "ReadAPI: containsValue", - timeout: 5000, //1 second - runTest: function(t) { - // summary: - // Simple test of the containsValue function of the store - // description: - // Simple test of the containsValue function of the store - - var atomStore = dojox.data.tests.stores.AtomReadStore.getBlog1Store(); - - var d = new doh.Deferred(); - function onComplete(items){ - t.is(1, items.length); - - t.assertTrue(atomStore.containsValue(items[0], "id","http://shaneosullivan.wordpress.com/2008/01/22/using-aol-hosted-dojo-with-your-custom-code/")); - - d.callback(true); - } - - //Get one item... - atomStore.fetch({ - query: { - }, - count: 1, - onComplete: onComplete, - onError: dojo.partial(dojox.data.tests.stores.AtomReadStore.error, t, d) - }); - return d; //Object - } - }, - { - name: "ReadAPI: getAttributes", - timeout: 5000, //1 second - runTest: function(t) { - // summary: - // Simple test of the getAttributes function of the store - // description: - // Simple test of the getAttributes function of the store - - var atomStore = dojox.data.tests.stores.AtomReadStore.getBlog1Store(); - - var d = new doh.Deferred(); - function onComplete(items){ - t.is(1, items.length); - t.assertTrue(atomStore.isItem(items[0])); - - var attributes = atomStore.getAttributes(items[0]); - console.log("getAttributes 4: "+attributes.length); - t.is(10, attributes.length); - d.callback(true); - } - - //Get everything... - atomStore.fetch({ - query: { - }, - count: 1, - onComplete: onComplete, - onError: dojo.partial(dojox.data.tests.stores.AtomReadStore.error, t, d) - }); - return d; //Object - } - }, - { - name: "ReadAPI: fetch_Category", - timeout: 5000, //1 second. - runTest: function(t) { - // summary: - // Retrieve items from the store by category - // description: - // Simple test of the getAttributes function of the store - - var atomStore = dojox.data.tests.stores.AtomReadStore.getBlog1Store(); - - var d = new doh.Deferred(); - function onComplete(items){ - t.is(2, items.length); - t.assertTrue(atomStore.isItem(items[0])); - t.assertTrue(atomStore.isItem(items[1])); - - var categories = atomStore.getValues(items[0], "category"); - t.assertTrue(dojo.some(categories, function(category){ - return category.term == "aol"; - })); - categories = atomStore.getValues(items[1], "category"); - t.assertTrue(dojo.some(categories, function(category){ - return category.term == "aol"; - })); - - d.callback(true); - } - - //Get everything... - atomStore.fetch({ - query: { - category: "aol" - }, - onComplete: onComplete, - onError: dojo.partial(dojox.data.tests.stores.AtomReadStore.error, t, d) - }); - return d; //Object - } - }, - { - name: "ReadAPI: fetch_byID", - timeout: 5000, //1 second. - runTest: function(t) { - // summary: - // Retrieve items from the store by category - // description: - // Simple test of the getAttributes function of the store - - var atomStore = dojox.data.tests.stores.AtomReadStore.getBlog1Store(); - - var d = new doh.Deferred(); - function onComplete(items){ - console.log("getById: items.length="+items.length) - t.is(1, items.length); - t.assertTrue(atomStore.isItem(items[0])); - - var title = atomStore.getValue(items[0], "title"); - console.log("getById: title.text="+title.text) - t.assertTrue(title.text == "Dojo Grid has landed"); - - d.callback(true); - } - - //Get everything... - atomStore.fetch({ - query: { - id: "http://shaneosullivan.wordpress.com/2007/10/05/dojo-grid-has-landed/" - }, - onComplete: onComplete, - onError: dojo.partial(dojox.data.tests.stores.AtomReadStore.error, t, d) - }); - return d; //Object - } - }, - { - name: "ReadAPI: fetch_alternate", - timeout: 5000, //1 second. - runTest: function(t) { - // summary: - // Retrieve items from the store by category - // description: - // Simple test of the getAttributes function of the store - - var atomStore = dojox.data.tests.stores.AtomReadStore.getBlog1Store(); - - var d = new doh.Deferred(); - function onComplete(items){ - t.is(1, items.length); - t.assertTrue(atomStore.isItem(items[0])); - - var alternate = atomStore.getValue(items[0], "alternate"); - t.assertEqual(alternate.href, "http://shaneosullivan.wordpress.com/2007/10/05/dojo-grid-has-landed/"); - - d.callback(true); - } - - //Get everything... - atomStore.fetch({ - query: { - id: "http://shaneosullivan.wordpress.com/2007/10/05/dojo-grid-has-landed/" - }, - onComplete: onComplete, - onError: dojo.partial(dojox.data.tests.stores.AtomReadStore.error, t, d) - }); - return d; //Object - } - }, - function testReadAPI_getFeatures(t){ - // summary: - // Simple test of the getFeatures function of the store - // description: - // Simple test of the getFeatures function of the store - - var atomStore = dojox.data.tests.stores.AtomReadStore.getBlog1Store(); - - var features = atomStore.getFeatures(); - var count = 0; - for(i in features){ - t.assertTrue((i === "dojo.data.api.Read")); - count++; - } - t.assertTrue(count === 1); - }, - function testReadAPI_functionConformance(t){ - // summary: - // Simple test read API conformance. Checks to see all declared functions are actual functions on the instances. - // description: - // Simple test read API conformance. Checks to see all declared functions are actual functions on the instances. - - var testStore = dojox.data.tests.stores.AtomReadStore.getBlog1Store(); - var readApi = new dojo.data.api.Read(); - var passed = true; - - for(i in readApi){ - if(i.toString().charAt(0) !== '_') - { - var member = readApi[i]; - //Check that all the 'Read' defined functions exist on the test store. - if(typeof member === "function"){ - console.log("Looking at function: [" + i + "]"); - var testStoreMember = testStore[i]; - if(!(typeof testStoreMember === "function")){ - console.log("Problem with function: [" + i + "]. Got value: " + testStoreMember); - passed = false; - break; - } - } - } - } - t.assertTrue(passed); - } - ] -); - -} diff --git a/includes/js/dojox/data/tests/stores/CsvStore.js b/includes/js/dojox/data/tests/stores/CsvStore.js deleted file mode 100644 index c1bad11..0000000 --- a/includes/js/dojox/data/tests/stores/CsvStore.js +++ /dev/null @@ -1,1127 +0,0 @@ -if(!dojo._hasResource["dojox.data.tests.stores.CsvStore"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. -dojo._hasResource["dojox.data.tests.stores.CsvStore"] = true; -dojo.provide("dojox.data.tests.stores.CsvStore"); -dojo.require("dojox.data.CsvStore"); -dojo.require("dojo.data.api.Read"); -dojo.require("dojo.data.api.Identity"); - -dojox.data.tests.stores.CsvStore.getDatasource = function(filepath){ - // summary: - // A simple helper function for getting the sample data used in each of the tests. - // description: - // A simple helper function for getting the sample data used in each of the tests. - - var dataSource = {}; - if(dojo.isBrowser){ - dataSource.url = dojo.moduleUrl("dojox.data.tests", filepath).toString(); - }else{ - // When running tests in Rhino, xhrGet is not available, - // so we have the file data in the code below. - switch(filepath){ - case "stores/movies.csv": - var csvData = ""; - csvData += "Title, Year, Producer\n"; - csvData += "City of God, 2002, Katia Lund\n"; - csvData += "Rain,, Christine Jeffs\n"; - csvData += "2001: A Space Odyssey, 1968, Stanley Kubrick\n"; - csvData += '"This is a ""fake"" movie title", 1957, Sidney Lumet\n'; - csvData += "Alien, 1979 , Ridley Scott\n"; - csvData += '"The Sequel to ""Dances With Wolves.""", 1982, Ridley Scott\n'; - csvData += '"Caine Mutiny, The", 1954, "Dymtryk ""the King"", Edward"\n'; - break; - case "stores/movies2.csv": - var csvData = ""; - csvData += "Title, Year, Producer\n"; - csvData += "City of God, 2002, Katia Lund\n"; - csvData += "Rain,\"\", Christine Jeffs\n"; - csvData += "2001: A Space Odyssey, 1968, Stanley Kubrick\n"; - csvData += '"This is a ""fake"" movie title", 1957, Sidney Lumet\n'; - csvData += "Alien, 1979 , Ridley Scott\n"; - csvData += '"The Sequel to ""Dances With Wolves.""", 1982, Ridley Scott\n'; - csvData += '"Caine Mutiny, The", 1954, "Dymtryk ""the King"", Edward"\n'; - break; - case "stores/books.csv": - var csvData = ""; - csvData += "Title, Author\n"; - csvData += "The Transparent Society, David Brin\n"; - csvData += "The First Measured Century, Theodore Caplow\n"; - csvData += "Maps in a Mirror, Orson Scott Card\n"; - csvData += "Princess Smartypants, Babette Cole\n"; - csvData += "Carfree Cities, Crawford J.H.\n"; - csvData += "Down and Out in the Magic Kingdom, Cory Doctorow\n"; - csvData += "Tax Shift, Alan Thein Durning\n"; - csvData += "The Sneetches and other stories, Dr. Seuss\n"; - csvData += "News from Tartary, Peter Fleming\n"; - break; - case "stores/patterns.csv": - var csvData = ""; - csvData += "uniqueId, value\n"; - csvData += "9, jfq4@#!$!@Rf14r14i5u\n"; - csvData += "6, BaBaMaSaRa***Foo\n"; - csvData += "2, bar*foo\n"; - csvData += "8, 123abc\n"; - csvData += "4, bit$Bite\n"; - csvData += "3, 123abc\n"; - csvData += "10, 123abcdefg\n"; - csvData += "1, foo*bar\n"; - csvData += "7, \n"; - csvData += "5, 123abc\n" - break; - } - dataSource.data = csvData; - } - return dataSource; //Object -} - -dojox.data.tests.stores.CsvStore.verifyItems = function(csvStore, items, attribute, compareArray){ - // summary: - // A helper function for validating that the items array is ordered - // the same as the compareArray - if(items.length != compareArray.length){ return false; } - for(var i = 0; i < items.length; i++){ - if(!(csvStore.getValue(items[i], attribute) === compareArray[i])){ - return false; //Boolean - } - } - return true; //Boolean -} - -dojox.data.tests.stores.CsvStore.error = function(t, d, errData){ - // summary: - // The error callback function to be used for all of the tests. - for (i in errData) { - console.log(errData[i]); - } - d.errback(errData); -} - -doh.register("dojox.data.tests.stores.CsvStore", - [ - function testReadAPI_fetch_all(t){ - // summary: - // Simple test of a basic fetch on CsvStore. - // description: - // Simple test of a basic fetch on CsvStore. - - var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/movies.csv"); - var csvStore = new dojox.data.CsvStore(args); - - var d = new doh.Deferred(); - function completedAll(items){ - t.assertTrue((items.length === 7)); - d.callback(true); - } - - //Get everything... - csvStore.fetch({ onComplete: completedAll, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)}); - return d; //Object - }, - function testReadAPI_fetch_all_withEmptyStringField(t){ - // summary: - // Simple test of a basic fetch on CsvStore. - // description: - // Simple test of a basic fetch on CsvStore. - - var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/movies2.csv"); - var csvStore = new dojox.data.CsvStore(args); - - var d = new doh.Deferred(); - function completedAll(items){ - t.assertTrue((items.length === 7)); - d.callback(true); - } - - //Get everything... - csvStore.fetch({ onComplete: completedAll, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)}); - return d; //Object - }, - function testReadAPI_fetch_one(t){ - // summary: - // Simple test of a basic fetch on CsvStore of a single item. - // description: - // Simple test of a basic fetch on CsvStore of a single item. - - var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/movies.csv"); - var csvStore = new dojox.data.CsvStore(args); - - var d = new doh.Deferred(); - function onComplete(items, request){ - t.is(1, items.length); - d.callback(true); - } - csvStore.fetch({ query: {Title: "*Sequel*"}, - onComplete: onComplete, - onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d) - }); - return d; //Object - }, - function testReadAPI_fetch_Multiple(t){ - // summary: - // Simple test of a basic fetch on CsvStore of a single item. - // description: - // Simple test of a basic fetch on CsvStore of a single item. - - var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/movies.csv"); - var csvStore = new dojox.data.CsvStore(args); - - var d = new doh.Deferred(); - - var done = [false, false]; - - function onCompleteOne(items, request){ - done[0] = true; - t.is(1, items.length); - if(done[0] && done[1]){ - d.callback(true); - } - } - - function onCompleteTwo(items, request){ - done[1] = true; - t.is(1, items.length); - if(done[0] && done[1]){ - d.callback(true); - } - } - - try - { - csvStore.fetch({ query: {Title: "*Sequel*"}, - onComplete: onCompleteOne, - onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d) - }); - csvStore.fetch({ query: {Title: "2001:*"}, - onComplete: onCompleteTwo, - onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d) - }); - } - catch(e) - { - for (i in e) { - console.log(e[i]); - } - } - - return d; //Object - }, - function testReadAPI_fetch_MultipleMixed(t){ - // summary: - // Simple test of a basic fetch on CsvStore of a single item. - // description: - // Simple test of a basic fetch on CsvStore of a single item. - - var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/movies.csv"); - var csvStore = new dojox.data.CsvStore(args); - - var d = new doh.Deferred(); - - var done = [false, false]; - function onComplete(items, request){ - done[0] = true; - t.is(1, items.length); - if(done[0] && done[1]){ - d.callback(true); - } - } - - function onItem(item){ - done[1] = true; - t.assertTrue(item !== null); - t.is('Dymtryk "the King", Edward', csvStore.getValue(item,"Producer")); - t.is('Caine Mutiny, The', csvStore.getValue(item,"Title")); - if(done[0] && done[1]){ - d.callback(true); - } - } - - csvStore.fetch({ query: {Title: "*Sequel*"}, - onComplete: onComplete, - onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d) - }); - - csvStore.fetchItemByIdentity({identity: "6", onItem: onItem, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)}); - return d; //Object - }, - function testReadAPI_fetch_all_streaming(t){ - // summary: - // Simple test of a basic fetch on CsvStore. - // description: - // Simple test of a basic fetch on CsvStore. - - var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/movies.csv"); - var csvStore = new dojox.data.CsvStore(args); - - var d = new doh.Deferred(); - count = 0; - - function onBegin(size, requestObj){ - t.assertTrue(size === 7); - } - function onItem(item, requestObj){ - t.assertTrue(csvStore.isItem(item)); - count++; - } - function onComplete(items, request){ - t.is(7, count); - t.is(null, items); - d.callback(true); - } - - //Get everything... - csvStore.fetch({ onBegin: onBegin, - onItem: onItem, - onComplete: onComplete, - onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d) - }); - return d; //Object - }, - function testReadAPI_fetch_paging(t){ - // summary: - // Test of multiple fetches on a single result. Paging, if you will. - // description: - // Test of multiple fetches on a single result. Paging, if you will. - - var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/movies.csv"); - var csvStore = new dojox.data.CsvStore(args); - - var d = new doh.Deferred(); - function dumpFirstFetch(items, request){ - t.is(5, items.length); - request.start = 3; - request.count = 1; - request.onComplete = dumpSecondFetch; - csvStore.fetch(request); - } - - function dumpSecondFetch(items, request){ - t.is(1, items.length); - request.start = 0; - request.count = 5; - request.onComplete = dumpThirdFetch; - csvStore.fetch(request); - } - - function dumpThirdFetch(items, request){ - t.is(5, items.length); - request.start = 2; - request.count = 20; - request.onComplete = dumpFourthFetch; - csvStore.fetch(request); - } - - function dumpFourthFetch(items, request){ - t.is(5, items.length); - request.start = 9; - request.count = 100; - request.onComplete = dumpFifthFetch; - csvStore.fetch(request); - } - - function dumpFifthFetch(items, request){ - t.is(0, items.length); - request.start = 2; - request.count = 20; - request.onComplete = dumpSixthFetch; - csvStore.fetch(request); - } - - function dumpSixthFetch(items, request){ - t.is(5, items.length); - d.callback(true); - } - - function completed(items, request){ - t.is(7, items.length); - request.start = 1; - request.count = 5; - request.onComplete = dumpFirstFetch; - csvStore.fetch(request); - } - - csvStore.fetch({onComplete: completed, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)}); - return d; //Object - - }, - - function testReadAPI_getLabel(t){ - // summary: - // Simple test of the getLabel function against a store set that has a label defined. - // description: - // Simple test of the getLabel function against a store set that has a label defined. - - var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/movies.csv"); - args.label = "Title"; - var csvStore = new dojox.data.CsvStore(args); - - var d = new doh.Deferred(); - function onComplete(items, request){ - t.assertEqual(items.length, 1); - var label = csvStore.getLabel(items[0]); - t.assertTrue(label !== null); - t.assertEqual("The Sequel to \"Dances With Wolves.\"", label); - d.callback(true); - } - csvStore.fetch({ query: {Title: "*Sequel*"}, - onComplete: onComplete, - onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d) - }); - return d; - }, - function testReadAPI_getLabelAttributes(t){ - // summary: - // Simple test of the getLabelAttributes function against a store set that has a label defined. - // description: - // Simple test of the getLabelAttributes function against a store set that has a label defined. - - var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/movies.csv"); - args.label = "Title"; - var csvStore = new dojox.data.CsvStore(args); - - var d = new doh.Deferred(); - function onComplete(items, request){ - t.assertEqual(items.length, 1); - var labelList = csvStore.getLabelAttributes(items[0]); - t.assertTrue(dojo.isArray(labelList)); - t.assertEqual("Title", labelList[0]); - d.callback(true); - } - csvStore.fetch({ query: {Title: "*Sequel*"}, - onComplete: onComplete, - onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d) - }); - return d; - }, - function testReadAPI_getValue(t){ - // summary: - // Simple test of the getValue function of the store. - // description: - // Simple test of the getValue function of the store. - - var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/movies.csv"); - var csvStore = new dojox.data.CsvStore(args); - - var d = new doh.Deferred(); - function onItem(item){ - t.assertTrue(item !== null); - t.is('Dymtryk "the King", Edward', csvStore.getValue(item,"Producer")); - t.is('Caine Mutiny, The', csvStore.getValue(item,"Title")); - d.callback(true); - } - csvStore.fetchItemByIdentity({identity: "6", onItem: onItem, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)}); - return d; - }, - function testReadAPI_getValue_2(t){ - // summary: - // Simple test of the getValue function of the store. - // description: - // Simple test of the getValue function of the store. - - var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/movies.csv"); - var csvStore = new dojox.data.CsvStore(args); - - var d = new doh.Deferred(); - function onItem(item){ - t.assertTrue(item !== null); - t.is("City of God", csvStore.getValue(item,"Title")); - t.is("2002", csvStore.getValue(item,"Year")); - d.callback(true); - } - csvStore.fetchItemByIdentity({identity: "0", onItem: onItem, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)}); - return d; - }, - function testReadAPI_getValue_3(t){ - // summary: - // Simple test of the getValue function of the store. - // description: - // Simple test of the getValue function of the store. - - var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/movies.csv"); - var csvStore = new dojox.data.CsvStore(args); - - var d = new doh.Deferred(); - function onItem(item){ - t.assertTrue(item !== null); - t.is("1979", csvStore.getValue(item,"Year")); - t.is("Alien", csvStore.getValue(item,"Title")); - d.callback(true); - } - csvStore.fetchItemByIdentity({identity: "4", onItem: onItem, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)}); - return d; - }, - function testReadAPI_getValue_4(t){ - // summary: - // Simple test of the getValue function of the store. - // description: - // Simple test of the getValue function of the store. - - var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/movies.csv"); - var csvStore = new dojox.data.CsvStore(args); - - var d = new doh.Deferred(); - function onItem(item){ - t.assertTrue(item !== null); - t.is("2001: A Space Odyssey", csvStore.getValue(item,"Title")); - t.is("Stanley Kubrick", csvStore.getValue(item,"Producer")); - d.callback(true); - } - csvStore.fetchItemByIdentity({identity: "2", onItem: onItem, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)}); - return d; - }, - - function testReadAPI_getValues(t){ - // summary: - // Simple test of the getValues function of the store. - // description: - // Simple test of the getValues function of the store. - - var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/movies.csv"); - var csvStore = new dojox.data.CsvStore(args); - - var d = new doh.Deferred(); - function onItem(item){ - t.assertTrue(item !== null); - var names = csvStore.getValues(item,"Title"); - t.assertTrue(dojo.isArray(names)); - t.is(1, names.length); - t.is("Rain", names[0]); - d.callback(true); - } - csvStore.fetchItemByIdentity({identity: "1", onItem: onItem, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)}); - return d; - }, - function testIdentityAPI_fetchItemByIdentity(t){ - // summary: - // Simple test of the fetchItemByIdentity function of the store. - // description: - // Simple test of the fetchItemByIdentity function of the store. - - var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/movies.csv"); - var csvStore = new dojox.data.CsvStore(args); - - var d = new doh.Deferred(); - function onItem(item){ - t.assertTrue(item !== null); - d.callback(true); - } - csvStore.fetchItemByIdentity({identity: "1", onItem: onItem, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)}); - return d; - }, - - function testIdentityAPI_fetchItemByIdentity_bad1(t){ - // summary: - // Simple test of the fetchItemByIdentity function of the store. - // description: - // Simple test of the fetchItemByIdentity function of the store. - - var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/movies.csv"); - var csvStore = new dojox.data.CsvStore(args); - - var d = new doh.Deferred(); - function onItem(item){ - t.assertTrue(item === null); - d.callback(true); - } - csvStore.fetchItemByIdentity({identity: "7", onItem: onItem, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)}); - return d; - }, - function testIdentityAPI_fetchItemByIdentity_bad2(t){ - // summary: - // Simple test of the fetchItemByIdentity function of the store. - // description: - // Simple test of the fetchItemByIdentity function of the store. - - var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/movies.csv"); - var csvStore = new dojox.data.CsvStore(args); - var d = new doh.Deferred(); - function onItem(item){ - t.assertTrue(item === null); - d.callback(true); - } - csvStore.fetchItemByIdentity({identity: "-1", onItem: onItem, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)}); - return d; - }, - function testIdentityAPI_fetchItemByIdentity_bad3(t){ - // summary: - // Simple test of the fetchItemByIdentity function of the store. - // description: - // Simple test of the fetchItemByIdentity function of the store. - - var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/movies.csv"); - var csvStore = new dojox.data.CsvStore(args); - var d = new doh.Deferred(); - function onItem(item){ - t.assertTrue(item === null); - d.callback(true); - } - csvStore.fetchItemByIdentity({identity: "999999", onItem: onItem, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)}); - return d; - }, - function testIdentityAPI_getIdentity(t){ - // summary: - // Simple test of the fetchItemByIdentity function of the store. - // description: - // Simple test of the fetchItemByIdentity function of the store. - - var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/movies.csv"); - var csvStore = new dojox.data.CsvStore(args); - - var d = new doh.Deferred(); - function completed(items, request){ - t.is(7, items.length); - var passed = true; - for(var i = 0; i < items.length; i++){ - if(!(csvStore.getIdentity(items[i]) === i)){ - passed=false; - break; - } - } - t.assertTrue(passed); - d.callback(true); - } - - //Get everything... - csvStore.fetch({ onComplete: completed, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)}); - return d; //Object - }, - function testIdentityAPI_getIdentityAttributes(t){ - // summary: - // Simple test of the getIdentityAttributes - // description: - // Simple test of the fetchItemByIdentity function of the store. - - var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/movies.csv"); - var csvStore = new dojox.data.CsvStore(args); - - var d = new doh.Deferred(); - function onItem(item){ - t.assertTrue(csvStore.isItem(item)); - t.assertEqual(null, csvStore.getIdentityAttributes(item)); - d.callback(true); - } - csvStore.fetchItemByIdentity({identity: "1", onItem: onItem, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)}); - return d; - }, - function testReadAPI_isItem(t){ - // summary: - // Simple test of the isItem function of the store - // description: - // Simple test of the isItem function of the store - - var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/movies.csv"); - var csvStore = new dojox.data.CsvStore(args); - - var d = new doh.Deferred(); - function onItem(item){ - t.assertTrue(csvStore.isItem(item)); - t.assertTrue(!csvStore.isItem({})); - t.assertTrue(!csvStore.isItem({ item: "not an item" })); - t.assertTrue(!csvStore.isItem("not an item")); - t.assertTrue(!csvStore.isItem(["not an item"])); - d.callback(true); - } - csvStore.fetchItemByIdentity({identity: "1", onItem: onItem, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)}); - return d; - }, - function testReadAPI_hasAttribute(t){ - // summary: - // Simple test of the hasAttribute function of the store - // description: - // Simple test of the hasAttribute function of the store - - var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/movies.csv"); - var csvStore = new dojox.data.CsvStore(args); - - var d = new doh.Deferred(); - function onItem(item){ - t.assertTrue(item !== null); - t.assertTrue(csvStore.hasAttribute(item, "Title")); - t.assertTrue(csvStore.hasAttribute(item, "Producer")); - t.assertTrue(!csvStore.hasAttribute(item, "Year")); - t.assertTrue(!csvStore.hasAttribute(item, "Nothing")); - t.assertTrue(!csvStore.hasAttribute(item, "title")); - - //Test that null attributes throw an exception - var passed = false; - try{ - csvStore.hasAttribute(item, null); - }catch (e){ - passed = true; - } - t.assertTrue(passed); - d.callback(true); - } - csvStore.fetchItemByIdentity({identity: "1", onItem: onItem, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)}); - return d; - }, - function testReadAPI_containsValue(t){ - // summary: - // Simple test of the containsValue function of the store - // description: - // Simple test of the containsValue function of the store - - var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/movies.csv"); - var csvStore = new dojox.data.CsvStore(args); - - var d = new doh.Deferred(); - function onItem(item){ - t.assertTrue(item !== null); - t.assertTrue(csvStore.containsValue(item, "Title", "Alien")); - t.assertTrue(csvStore.containsValue(item, "Year", "1979")); - t.assertTrue(csvStore.containsValue(item, "Producer", "Ridley Scott")); - t.assertTrue(!csvStore.containsValue(item, "Title", "Alien2")); - t.assertTrue(!csvStore.containsValue(item, "Year", "1979 ")); - t.assertTrue(!csvStore.containsValue(item, "Title", null)); - - //Test that null attributes throw an exception - var passed = false; - try{ - csvStore.containsValue(item, null, "foo"); - }catch (e){ - passed = true; - } - t.assertTrue(passed); - d.callback(true); - } - csvStore.fetchItemByIdentity({identity: "4", onItem: onItem, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)}); - return d; - }, - function testReadAPI_getAttributes(t){ - // summary: - // Simple test of the getAttributes function of the store - // description: - // Simple test of the getAttributes function of the store - - var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/movies.csv"); - var csvStore = new dojox.data.CsvStore(args); - - var d = new doh.Deferred(); - function onItem(item){ - t.assertTrue(item !== null); - t.assertTrue(csvStore.isItem(item)); - - var attributes = csvStore.getAttributes(item); - t.is(3, attributes.length); - for(var i = 0; i < attributes.length; i++){ - t.assertTrue((attributes[i] === "Title" || attributes[i] === "Year" || attributes[i] === "Producer")); - } - d.callback(true); - } - csvStore.fetchItemByIdentity({identity: "4", onItem: onItem, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)}); - return d; - }, - - function testReadAPI_getAttributes_onlyTwo(t){ - // summary: - // Simple test of the getAttributes function of the store - // description: - // Simple test of the getAttributes function of the store - - var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/movies.csv"); - var csvStore = new dojox.data.CsvStore(args); - - var d = new doh.Deferred(); - function onItem(item){ - // Test an item that does not have all of the attributes - t.assertTrue(item !== null); - t.assertTrue(csvStore.isItem(item)); - - var attributes = csvStore.getAttributes(item); - t.assertTrue(attributes.length === 2); - t.assertTrue(attributes[0] === "Title"); - t.assertTrue(attributes[1] === "Producer"); - d.callback(true); - } - csvStore.fetchItemByIdentity({identity: "1", onItem: onItem, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)}); - return d; - }, - - function testReadAPI_getFeatures(t){ - // summary: - // Simple test of the getFeatures function of the store - // description: - // Simple test of the getFeatures function of the store - - var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/movies.csv"); - var csvStore = new dojox.data.CsvStore(args); - - var features = csvStore.getFeatures(); - var count = 0; - for(i in features){ - t.assertTrue((i === "dojo.data.api.Read" || i === "dojo.data.api.Identity")); - count++; - } - t.assertTrue(count === 2); - }, - function testReadAPI_fetch_patternMatch0(t){ - // summary: - // Function to test pattern matching of everything starting with lowercase e - // description: - // Function to test pattern matching of everything starting with lowercase e - - var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/movies.csv"); - var csvStore = new dojox.data.CsvStore(args); - - var d = new doh.Deferred(); - function completed(items, request){ - t.is(2, items.length); - var valueArray = [ "Alien", "The Sequel to \"Dances With Wolves.\""]; - t.assertTrue(dojox.data.tests.stores.CsvStore.verifyItems(csvStore, items, "Title", valueArray)); - d.callback(true); - } - - csvStore.fetch({query: {Producer: "* Scott"}, onComplete: completed, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)}); - return d; //Object - }, - function testReadAPI_fetch_patternMatch1(t){ - // summary: - // Function to test pattern matching of everything with $ in it. - // description: - // Function to test pattern matching of everything with $ in it. - - var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/patterns.csv"); - var csvStore = new dojox.data.CsvStore(args); - - var d = new doh.Deferred(); - function completed(items, request){ - t.assertTrue(items.length === 2); - var valueArray = [ "jfq4@#!$!@Rf14r14i5u", "bit$Bite"]; - t.assertTrue(dojox.data.tests.stores.CsvStore.verifyItems(csvStore, items, "value", valueArray)); - d.callback(true); - } - - csvStore.fetch({query: {value: "*$*"}, onComplete: completed, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)}); - return d; //Object - }, - function testReadAPI_fetch_patternMatch2(t){ - // summary: - // Function to test exact pattern match - // description: - // Function to test exact pattern match - - var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/patterns.csv"); - var csvStore = new dojox.data.CsvStore(args); - - var d = new doh.Deferred(); - function completed(items, request){ - t.is(1, items.length); - t.assertTrue(csvStore.getValue(items[0], "value") === "bar*foo"); - d.callback(true); - } - - csvStore.fetch({query: {value: "bar\*foo"}, onComplete: completed, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)}); - return d; //Object - }, - function testReadAPI_fetch_patternMatch_caseInsensitive(t){ - // summary: - // Function to test exact pattern match with case insensitivity set. - // description: - // Function to test exact pattern match with case insensitivity set. - - var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/patterns.csv"); - var csvStore = new dojox.data.CsvStore(args); - - var d = new doh.Deferred(); - function completed(items, request){ - t.is(1, items.length); - t.assertTrue(csvStore.getValue(items[0], "value") === "bar*foo"); - d.callback(true); - } - - csvStore.fetch({query: {value: "BAR\\*foo"}, queryOptions: {ignoreCase: true}, onComplete: completed, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)}); - return d; //Object - }, - function testReadAPI_fetch_patternMatch_caseSensitive(t){ - // summary: - // Function to test exact pattern match with case insensitivity set. - // description: - // Function to test exact pattern match with case insensitivity set. - - var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/patterns.csv"); - var csvStore = new dojox.data.CsvStore(args); - - var d = new doh.Deferred(); - function completed(items, request){ - t.is(0, items.length); - d.callback(true); - } - - csvStore.fetch({query: {value: "BAR\\*foo"}, queryOptions: {ignoreCase: false}, onComplete: completed, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)}); - return d; //Object - }, - function testReadAPI_fetch_sortNumeric(t){ - // summary: - // Function to test sorting numerically. - // description: - // Function to test sorting numerically. - - var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/patterns.csv"); - var csvStore = new dojox.data.CsvStore(args); - - var d = new doh.Deferred(); - function completed(items, request){ - t.assertTrue(items.length === 10); - // TODO: CsvStore treats everything like a string, so these numbers will be sorted lexicographically. - var orderedArray = [ "1", "10", "2", "3", "4", "5", "6", "7", "8", "9" ]; - t.assertTrue(dojox.data.tests.stores.CsvStore.verifyItems(csvStore, items, "uniqueId", orderedArray)); - d.callback(true); - } - - var sortAttributes = [{attribute: "uniqueId"}]; - csvStore.fetch({onComplete: completed, - onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d), - sort: sortAttributes}); - return d; //Object - }, - function testReadAPI_fetch_sortNumericDescending(t){ - // summary: - // Function to test sorting numerically. - // description: - // Function to test sorting numerically. - - var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/patterns.csv"); - var csvStore = new dojox.data.CsvStore(args); - - var d = new doh.Deferred(); - function completed(items, request){ - t.is(10, items.length); - // TODO: CsvStore treats everything like a string, so these numbers will be sorted lexicographically. - var orderedArray = [ "9", "8", "7", "6", "5", "4", "3", "2", "10", "1" ]; - t.assertTrue(dojox.data.tests.stores.CsvStore.verifyItems(csvStore, items, "uniqueId", orderedArray)); - d.callback(true); - } - - var sortAttributes = [{attribute: "uniqueId", descending: true}]; - csvStore.fetch({ sort: sortAttributes, onComplete: completed, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)}); - return d; //Object - }, - function testReadAPI_fetch_sortNumericWithCount(t){ - // summary: - // Function to test sorting numerically in descending order, returning only a specified number of them. - // description: - // Function to test sorting numerically in descending order, returning only a specified number of them. - - var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/patterns.csv"); - var csvStore = new dojox.data.CsvStore(args); - - var d = new doh.Deferred(); - function completed(items, request){ - t.is(5, items.length); - // TODO: CsvStore treats everything like a string, so these numbers will be sorted lexicographically. - var orderedArray = [ "9", "8", "7", "6", "5" ]; - t.assertTrue(dojox.data.tests.stores.CsvStore.verifyItems(csvStore, items, "uniqueId", orderedArray)); - d.callback(true); - } - - var sortAttributes = [{attribute: "uniqueId", descending: true}]; - csvStore.fetch({sort: sortAttributes, - count: 5, - onComplete: completed, - onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)}); - return d; //Object - }, - function testReadAPI_fetch_sortAlphabetic(t){ - // summary: - // Function to test sorting alphabetic ordering. - // description: - // Function to test sorting alphabetic ordering. - - var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/patterns.csv"); - var csvStore = new dojox.data.CsvStore(args); - - var d = new doh.Deferred(); - function completed(items, request){ - //Output should be in this order... - var orderedArray = [ "123abc", - "123abc", - "123abc", - "123abcdefg", - "BaBaMaSaRa***Foo", - "bar*foo", - "bit$Bite", - "foo*bar", - "jfq4@#!$!@Rf14r14i5u", - undefined - ]; - t.is(10, items.length); - t.assertTrue(dojox.data.tests.stores.CsvStore.verifyItems(csvStore, items, "value", orderedArray)); - d.callback(true); - } - - var sortAttributes = [{attribute: "value"}]; - csvStore.fetch({sort: sortAttributes, onComplete: completed, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)}); - return d; //Object - }, - function testReadAPI_fetch_sortAlphabeticDescending(t){ - // summary: - // Function to test sorting alphabetic ordering in descending mode. - // description: - // Function to test sorting alphabetic ordering in descending mode. - - var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/patterns.csv"); - var csvStore = new dojox.data.CsvStore(args); - - var d = new doh.Deferred(); - function completed(items, request){ - //Output should be in this order... - var orderedArray = [ undefined, - "jfq4@#!$!@Rf14r14i5u", - "foo*bar", - "bit$Bite", - "bar*foo", - "BaBaMaSaRa***Foo", - "123abcdefg", - "123abc", - "123abc", - "123abc" - ]; - t.is(10, items.length); - t.assertTrue(dojox.data.tests.stores.CsvStore.verifyItems(csvStore, items, "value", orderedArray)); - d.callback(true); - } - - var sortAttributes = [{attribute: "value", descending: true}]; - csvStore.fetch({sort: sortAttributes, onComplete: completed, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)}); - return d; //Object - }, - function testReadAPI_fetch_sortMultiple(t){ - // summary: - // Function to test sorting on multiple attributes. - // description: - // Function to test sorting on multiple attributes. - - var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/patterns.csv"); - var csvStore = new dojox.data.CsvStore(args); - - var d = new doh.Deferred(); - function completed(items, request){ - var orderedArray0 = [ "8", "5", "3", "10", "6", "2", "4", "1", "9", "7" ]; - var orderedArray1 = [ "123abc", - "123abc", - "123abc", - "123abcdefg", - "BaBaMaSaRa***Foo", - "bar*foo", - "bit$Bite", - "foo*bar", - "jfq4@#!$!@Rf14r14i5u", - undefined - ]; - t.is(10, items.length); - t.assertTrue(dojox.data.tests.stores.CsvStore.verifyItems(csvStore, items, "uniqueId", orderedArray0)); - t.assertTrue(dojox.data.tests.stores.CsvStore.verifyItems(csvStore, items, "value", orderedArray1)); - d.callback(true); - } - - var sortAttributes = [{ attribute: "value"}, { attribute: "uniqueId", descending: true}]; - csvStore.fetch({sort: sortAttributes, onComplete: completed, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)}); - return d; //Object - }, - function testReadAPI_fetch_sortMultipleSpecialComparator(t){ - // summary: - // Function to test sorting on multiple attributes with a custom comparator. - // description: - // Function to test sorting on multiple attributes with a custom comparator. - - var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/movies.csv"); - var csvStore = new dojox.data.CsvStore(args); - - csvStore.comparatorMap = {}; - csvStore.comparatorMap["Producer"] = function(a,b){ - var ret = 0; - // We want to sort authors alphabetical by their last name - function lastName(name){ - if(typeof name === "undefined"){ return undefined; } - - var matches = name.match(/\s*(\S+)$/); // Grab the last word in the string. - return matches ? matches[1] : name; // Strings with only whitespace will not match. - } - var lastNameA = lastName(a); - var lastNameB = lastName(b); - if(lastNameA > lastNameB || typeof lastNameA === "undefined"){ - ret = 1; - }else if(lastNameA < lastNameB || typeof lastNameB === "undefined"){ - ret = -1; - } - return ret; - }; - - var sortAttributes = [{attribute: "Producer", descending: true}, { attribute: "Title", descending: true}]; - - var d = new doh.Deferred(); - function completed(items, findResult){ - var orderedArray = [5,4,0,3,2,1,6]; - t.assertTrue(items.length === 7); - var passed = true; - for(var i = 0; i < items.length; i++){ - if(!(csvStore.getIdentity(items[i]) === orderedArray[i])){ - passed=false; - break; - } - } - t.assertTrue(passed); - d.callback(true); - } - - csvStore.fetch({sort: sortAttributes, onComplete: completed, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)}); - return d; //Object - }, - function testReadAPI_functionConformance(t){ - // summary: - // Simple test read API conformance. Checks to see all declared functions are actual functions on the instances. - // description: - // Simple test read API conformance. Checks to see all declared functions are actual functions on the instances. - - var testStore = new dojox.data.CsvStore(dojox.data.tests.stores.CsvStore.getDatasource("stores/movies.csv")); - var readApi = new dojo.data.api.Read(); - var passed = true; - - for(i in readApi){ - if(i.toString().charAt(0) !== '_') - { - var member = readApi[i]; - //Check that all the 'Read' defined functions exist on the test store. - if(typeof member === "function"){ - console.log("Looking at function: [" + i + "]"); - var testStoreMember = testStore[i]; - if(!(typeof testStoreMember === "function")){ - console.log("Problem with function: [" + i + "]. Got value: " + testStoreMember); - passed = false; - break; - } - } - } - } - t.assertTrue(passed); - }, - function testIdentityAPI_functionConformance(t){ - // summary: - // Simple test identity API conformance. Checks to see all declared functions are actual functions on the instances. - // description: - // Simple test identity API conformance. Checks to see all declared functions are actual functions on the instances. - - var testStore = new dojox.data.CsvStore(dojox.data.tests.stores.CsvStore.getDatasource("stores/movies.csv")); - var identityApi = new dojo.data.api.Identity(); - var passed = true; - - for(i in identityApi){ - if(i.toString().charAt(0) !== '_') - { - var member = identityApi[i]; - //Check that all the 'Read' defined functions exist on the test store. - if(typeof member === "function"){ - console.log("Looking at function: [" + i + "]"); - var testStoreMember = testStore[i]; - if(!(typeof testStoreMember === "function")){ - passed = false; - break; - } - } - } - } - t.assertTrue(passed); - } - ] -); - - -} diff --git a/includes/js/dojox/data/tests/stores/FlickrRestStore.js b/includes/js/dojox/data/tests/stores/FlickrRestStore.js deleted file mode 100644 index 23320ec..0000000 --- a/includes/js/dojox/data/tests/stores/FlickrRestStore.js +++ /dev/null @@ -1,476 +0,0 @@ -if(!dojo._hasResource["dojox.data.tests.stores.FlickrRestStore"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. -dojo._hasResource["dojox.data.tests.stores.FlickrRestStore"] = true; -dojo.provide("dojox.data.tests.stores.FlickrRestStore"); -dojo.require("dojox.data.FlickrRestStore"); -dojo.require("dojo.data.api.Read"); - - -dojox.data.tests.stores.FlickrRestStore.error = function(t, d, errData){ - // summary: - // The error callback function to be used for all of the tests. - d.errback(errData); -} - -doh.register("dojox.data.tests.stores.FlickrRestStore", - [ - { - name: "ReadAPI: Fetch_One", - timeout: 10000, //10 seconds. Flickr can sometimes be slow. - runTest: function(t) { - // summary: - // Simple test of a basic fetch on FlickrRestStore of a single item. - // description: - // Simple test of a basic fetch on FlickrRestStore of a single item. - - var flickrStore = new dojox.data.FlickrRestStore(); - - var d = new doh.Deferred(); - function onComplete(items, request){ - t.is(1, items.length); - d.callback(true); - } - flickrStore.fetch({ - query: { - userid: "44153025@N00", - apikey: "8c6803164dbc395fb7131c9d54843627" - }, - count: 1, - onComplete: onComplete, - onError: dojo.partial(dojox.data.tests.stores.FlickrRestStore.error, doh, d) - }); - return d; //Object - } - }, - { - name: "ReadAPI: Fetch_20_Streaming", - timeout: 10000, //10 seconds. Flickr can sometimes be slow. - runTest: function(t) { - // summary: - // Simple test of a basic fetch on FlickrRestStore. - // description: - // Simple test of a basic fetch on FlickrRestStore. - var flickrStore = new dojox.data.FlickrRestStore(); - - var d = new doh.Deferred(); - var count = 0; - - function onItem(item, requestObj){ - t.assertTrue(flickrStore.isItem(item)); - count++; - } - function onComplete(items, request){ - t.is(5, count); - - t.is(null, items); - d.callback(true); - } - //Get everything... - flickrStore.fetch({ - query: { - userid: "44153025@N00", - apikey: "8c6803164dbc395fb7131c9d54843627" - }, - onBegin: null, - count: 5, - onItem: onItem, - onComplete: onComplete, - onError: dojo.partial(dojox.data.tests.stores.FlickrRestStore.error, t, d) - }); - return d; //Object - } - }, - { - name: "ReadAPI: Fetch_Paging", - timeout: 30000, //30 seconds. Flickr can sometimes be slow. - runTest: function(t) { - // summary: - // Test of multiple fetches on a single result. Paging, if you will. - // description: - // Test of multiple fetches on a single result. Paging, if you will. - - var flickrStore = new dojox.data.FlickrRestStore(); - - var d = new doh.Deferred(); - function dumpFirstFetch(items, request){ - t.is(5, items.length); - request.start = 3; - request.count = 1; - request.onComplete = dumpSecondFetch; - flickrStore.fetch(request); - } - - function dumpSecondFetch(items, request){ - t.is(1, items.length); - request.start = 0; - request.count = 5; - request.onComplete = dumpThirdFetch; - flickrStore.fetch(request); - } - - function dumpThirdFetch(items, request){ - t.is(5, items.length); - request.start = 2; - request.count = 18; - request.onComplete = dumpFourthFetch; - flickrStore.fetch(request); - } - - function dumpFourthFetch(items, request){ - t.is(18, items.length); - request.start = 9; - request.count = 11; - request.onComplete = dumpFifthFetch; - flickrStore.fetch(request); - } - - function dumpFifthFetch(items, request){ - t.is(11, items.length); - request.start = 4; - request.count = 16; - request.onComplete = dumpSixthFetch; - flickrStore.fetch(request); - } - - function dumpSixthFetch(items, request){ - t.is(16, items.length); - d.callback(true); - } - - function completed(items, request){ - t.is(7, items.length); - request.start = 1; - request.count = 5; - request.onComplete = dumpFirstFetch; - flickrStore.fetch(request); - } - flickrStore.fetch({ - query: { - userid: "44153025@N00", - apikey: "8c6803164dbc395fb7131c9d54843627" - }, - count: 7, - onComplete: completed, - onError: dojo.partial(dojox.data.tests.stores.FlickrRestStore.error, t, d) - }); - return d; //Object - } - }, - { - name: "ReadAPI: getLabel", - timeout: 10000, //10 seconds. Flickr can sometimes be slow. - runTest: function(t) { - // summary: - // Simple test of the getLabel function against a store set that has a label defined. - // description: - // Simple test of the getLabel function against a store set that has a label defined. - - var flickrStore = new dojox.data.FlickrRestStore(); - - var d = new doh.Deferred(); - function onComplete(items, request){ - t.assertEqual(items.length, 1); - var label = flickrStore.getLabel(items[0]); - t.assertTrue(label !== null); - d.callback(true); - } - flickrStore.fetch({ - query: { - userid: "44153025@N00", - apikey: "8c6803164dbc395fb7131c9d54843627" - }, - count: 1, - onComplete: onComplete, - onError: dojo.partial(dojox.data.tests.stores.FlickrRestStore.error, t, d) - }); - return d; - } - }, - { - name: "ReadAPI: getLabelAttributes", - timeout: 10000, //10 seconds. Flickr can sometimes be slow. - runTest: function(t) { - // summary: - // Simple test of the getLabelAttributes function against a store set that has a label defined. - // description: - // Simple test of the getLabelAttributes function against a store set that has a label defined. - - var flickrStore = new dojox.data.FlickrRestStore(); - - var d = new doh.Deferred(); - function onComplete(items, request){ - t.assertEqual(items.length, 1); - var labelList = flickrStore.getLabelAttributes(items[0]); - t.assertTrue(dojo.isArray(labelList)); - t.assertEqual("title", labelList[0]); - d.callback(true); - } - flickrStore.fetch({ - query: { - userid: "44153025@N00", - apikey: "8c6803164dbc395fb7131c9d54843627" - }, - count: 1, - onComplete: onComplete, - onError: dojo.partial(dojox.data.tests.stores.FlickrRestStore.error, t, d) - }); - return d; - } - }, - { - name: "ReadAPI: getValue", - timeout: 10000, //10 seconds. Flickr can sometimes be slow. - runTest: function(t) { - // summary: - // Simple test of the getValue function of the store. - // description: - // Simple test of the getValue function of the store. - var flickrStore = new dojox.data.FlickrRestStore(); - - var d = new doh.Deferred(); - function completedAll(items){ - t.is(1, items.length); - t.assertTrue(flickrStore.getValue(items[0], "title") !== null); - t.assertTrue(flickrStore.getValue(items[0], "imageUrl") !== null); - t.assertTrue(flickrStore.getValue(items[0], "imageUrlSmall") !== null); - t.assertTrue(flickrStore.getValue(items[0], "imageUrlMedium") !== null); - d.callback(true); - } - - //Get one item and look at it. - flickrStore.fetch({ - query: { - userid: "44153025@N00", - apikey: "8c6803164dbc395fb7131c9d54843627" - }, - count: 1, - onComplete: completedAll, - onError: dojo.partial(dojox.data.tests.stores.FlickrRestStore.error, t, d)}); - return d; //Object - } - }, - { - name: "ReadAPI: getValues", - timeout: 10000, //10 seconds. Flickr can sometimes be slow. - runTest: function(t) { - // summary: - // Simple test of the getValue function of the store. - // description: - // Simple test of the getValue function of the store. - var flickrStore = new dojox.data.FlickrRestStore(); - - var d = new doh.Deferred(); - function completedAll(items){ - t.is(1, items.length); - var title = flickrStore.getValues(items[0], "title"); - t.assertTrue(title instanceof Array); - - var imgUrl = flickrStore.getValues(items[0], "imageUrl"); - t.assertTrue(imgUrl instanceof Array); - - var imgUrlSmall = flickrStore.getValues(items[0], "imageUrlSmall"); - t.assertTrue(imgUrlSmall instanceof Array); - - var imgUrlMedium = flickrStore.getValues(items[0], "imageUrlMedium"); - t.assertTrue(imgUrlMedium instanceof Array); - d.callback(true); - } - //Get one item and look at it. - flickrStore.fetch({ - query: { - userid: "44153025@N00", - apikey: "8c6803164dbc395fb7131c9d54843627" - }, - count: 1, - onComplete: completedAll, - onError: dojo.partial(dojox.data.tests.stores.FlickrRestStore.error, - t, - d)}); - return d; //Object - } - }, - { - name: "ReadAPI: isItem", - timeout: 10000, //10 seconds. Flickr can sometimes be slow. - runTest: function(t) { - // summary: - // Simple test of the isItem function of the store - // description: - // Simple test of the isItem function of the store - var flickrStore = new dojox.data.FlickrRestStore(); - - var d = new doh.Deferred(); - function completedAll(items){ - t.is(5, items.length); - for(var i=0; i < items.length; i++){ - t.assertTrue(flickrStore.isItem(items[i])); - } - d.callback(true); - } - - //Get everything... - flickrStore.fetch({ - query: { - userid: "44153025@N00", - apikey: "8c6803164dbc395fb7131c9d54843627" - }, - count: 5, - onComplete: completedAll, - onError: dojo.partial(dojox.data.tests.stores.FlickrRestStore.error, t, d) - }); - return d; //Object - } - }, - { - name: "ReadAPI: hasAttribute", - timeout: 10000, //10 seconds. Flickr can sometimes be slow. - runTest: function(t) { - // summary: - // Simple test of the hasAttribute function of the store - // description: - // Simple test of the hasAttribute function of the store - - var flickrStore = new dojox.data.FlickrRestStore(); - - var d = new doh.Deferred(); - function onComplete(items){ - t.is(1, items.length); - t.assertTrue(items[0] !== null); - t.assertTrue(flickrStore.hasAttribute(items[0], "title")); - t.assertTrue(flickrStore.hasAttribute(items[0], "author")); - t.assertTrue(!flickrStore.hasAttribute(items[0], "Nothing")); - t.assertTrue(!flickrStore.hasAttribute(items[0], "Text")); - - //Test that null attributes throw an exception - var passed = false; - try{ - flickrStore.hasAttribute(items[0], null); - }catch (e){ - passed = true; - } - t.assertTrue(passed); - d.callback(true); - } - - //Get one item... - flickrStore.fetch({ - query: { - userid: "44153025@N00", - apikey: "8c6803164dbc395fb7131c9d54843627" - }, - count: 1, - onComplete: onComplete, - onError: dojo.partial(dojox.data.tests.stores.FlickrRestStore.error, t, d) - }); - return d; //Object - } - }, - { - name: "ReadAPI: containsValue", - timeout: 10000, //10 seconds. Flickr can sometimes be slow. - runTest: function(t) { - // summary: - // Simple test of the containsValue function of the store - // description: - // Simple test of the containsValue function of the store - - var flickrStore = new dojox.data.FlickrRestStore(); - - var d = new doh.Deferred(); - function onComplete(items){ - t.is(1, items.length); - d.callback(true); - } - - //Get one item... - flickrStore.fetch({ - query: { - userid: "44153025@N00", - apikey: "8c6803164dbc395fb7131c9d54843627" - }, - count: 1, - onComplete: onComplete, - onError: dojo.partial(dojox.data.tests.stores.FlickrRestStore.error, t, d) - }); - return d; //Object - } - }, - { - name: "ReadAPI: getAttributes", - timeout: 10000, //10 seconds. Flickr can sometimes be slow. - runTest: function(t) { - // summary: - // Simple test of the getAttributes function of the store - // description: - // Simple test of the getAttributes function of the store - - var flickrStore = new dojox.data.FlickrRestStore(); - - var d = new doh.Deferred(); - function onComplete(items){ - t.is(1, items.length); - t.assertTrue(flickrStore.isItem(items[0])); - - var attributes = flickrStore.getAttributes(items[0]); - t.is(9, attributes.length); - d.callback(true); - } - - //Get everything... - flickrStore.fetch({ - query: { - userid: "44153025@N00", - apikey: "8c6803164dbc395fb7131c9d54843627" - }, - count: 1, - onComplete: onComplete, - onError: dojo.partial(dojox.data.tests.stores.FlickrRestStore.error, t, d) - }); - return d; //Object - } - }, - function testReadAPI_getFeatures(t){ - // summary: - // Simple test of the getFeatures function of the store - // description: - // Simple test of the getFeatures function of the store - - var flickrStore = new dojox.data.FlickrRestStore(); - - var features = flickrStore.getFeatures(); - var count = 0; - for(i in features){ - t.assertTrue((i === "dojo.data.api.Read")); - count++; - } - t.assertTrue(count === 1); - }, - function testReadAPI_functionConformance(t){ - // summary: - // Simple test read API conformance. Checks to see all declared functions are actual functions on the instances. - // description: - // Simple test read API conformance. Checks to see all declared functions are actual functions on the instances. - - var testStore = new dojox.data.FlickrRestStore(); - var readApi = new dojo.data.api.Read(); - var passed = true; - - for(i in readApi){ - if(i.toString().charAt(0) !== '_') - { - var member = readApi[i]; - //Check that all the 'Read' defined functions exist on the test store. - if(typeof member === "function"){ - var testStoreMember = testStore[i]; - if(!(typeof testStoreMember === "function")){ - passed = false; - break; - } - } - } - } - } - ] -); - - -} diff --git a/includes/js/dojox/data/tests/stores/FlickrStore.js b/includes/js/dojox/data/tests/stores/FlickrStore.js deleted file mode 100644 index 3ed8c6c..0000000 --- a/includes/js/dojox/data/tests/stores/FlickrStore.js +++ /dev/null @@ -1,410 +0,0 @@ -if(!dojo._hasResource["dojox.data.tests.stores.FlickrStore"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. -dojo._hasResource["dojox.data.tests.stores.FlickrStore"] = true; -dojo.provide("dojox.data.tests.stores.FlickrStore"); -dojo.require("dojox.data.FlickrStore"); -dojo.require("dojo.data.api.Read"); - - -dojox.data.tests.stores.FlickrStore.error = function(t, d, errData){ - // summary: - // The error callback function to be used for all of the tests. - d.errback(errData); -} - -doh.register("dojox.data.tests.stores.FlickrStore", - [ - { - name: "ReadAPI: Fetch_One", - timeout: 10000, //10 seconds. Flickr can sometimes be slow. - runTest: function(t) { - // summary: - // Simple test of a basic fetch on FlickrStore of a single item. - // description: - // Simple test of a basic fetch on FlickrStore of a single item. - - var flickrStore = new dojox.data.FlickrStore(); - - var d = new doh.Deferred(); - function onComplete(items, request){ - t.is(1, items.length); - d.callback(true); - } - flickrStore.fetch({ query: {tags: "animals"}, - count: 1, - onComplete: onComplete, - onError: dojo.partial(dojox.data.tests.stores.FlickrStore.error, doh, d) - }); - return d; //Object - } - }, - { - name: "ReadAPI: Fetch_20_Streaming", - timeout: 10000, //10 seconds. Flickr can sometimes be slow. - runTest: function(t) { - // summary: - // Simple test of a basic fetch on FlickrStore. - // description: - // Simple test of a basic fetch on FlickrStore. - var flickrStore = new dojox.data.FlickrStore(); - - var d = new doh.Deferred(); - count = 0; - - function onBegin(size, requestObj){ - t.is(20, size); - } - function onItem(item, requestObj){ - t.assertTrue(flickrStore.isItem(item)); - count++; - } - function onComplete(items, request){ - t.is(20, count); - t.is(null, items); - d.callback(true); - } - - //Get everything... - flickrStore.fetch({ onBegin: onBegin, - count: 20, - onItem: onItem, - onComplete: onComplete, - onError: dojo.partial(dojox.data.tests.stores.FlickrStore.error, t, d) - }); - return d; //Object - } - }, - { - name: "ReadAPI: Fetch_Paging", - timeout: 30000, //30 seconds. Flickr can sometimes be slow. - runTest: function(t) { - // summary: - // Test of multiple fetches on a single result. Paging, if you will. - // description: - // Test of multiple fetches on a single result. Paging, if you will. - - var flickrStore = new dojox.data.FlickrStore(); - - var d = new doh.Deferred(); - function dumpFirstFetch(items, request){ - t.is(5, items.length); - request.start = 3; - request.count = 1; - request.onComplete = dumpSecondFetch; - flickrStore.fetch(request); - } - - function dumpSecondFetch(items, request){ - t.is(1, items.length); - request.start = 0; - request.count = 5; - request.onComplete = dumpThirdFetch; - flickrStore.fetch(request); - } - - function dumpThirdFetch(items, request){ - t.is(5, items.length); - request.start = 2; - request.count = 20; - request.onComplete = dumpFourthFetch; - flickrStore.fetch(request); - } - - function dumpFourthFetch(items, request){ - t.is(18, items.length); - request.start = 9; - request.count = 100; - request.onComplete = dumpFifthFetch; - flickrStore.fetch(request); - } - - function dumpFifthFetch(items, request){ - t.is(11, items.length); - request.start = 2; - request.count = 20; - request.onComplete = dumpSixthFetch; - flickrStore.fetch(request); - } - - function dumpSixthFetch(items, request){ - t.is(18, items.length); - d.callback(true); - } - - function completed(items, request){ - t.is(7, items.length); - request.start = 1; - request.count = 5; - request.onComplete = dumpFirstFetch; - flickrStore.fetch(request); - } - flickrStore.fetch({count: 7, onComplete: completed, onError: dojo.partial(dojox.data.tests.stores.FlickrStore.error, t, d)}); - return d; //Object - } - }, - { - name: "ReadAPI: getLabel", - timeout: 10000, //10 seconds. Flickr can sometimes be slow. - runTest: function(t) { - // summary: - // Simple test of the getLabel function against a store set that has a label defined. - // description: - // Simple test of the getLabel function against a store set that has a label defined. - - var flickrStore = new dojox.data.FlickrStore(); - - var d = new doh.Deferred(); - function onComplete(items, request){ - t.assertEqual(items.length, 1); - var label = flickrStore.getLabel(items[0]); - t.assertTrue(label !== null); - d.callback(true); - } - flickrStore.fetch({ query: {tags: "animals"}, - count: 1, - onComplete: onComplete, - onError: dojo.partial(dojox.data.tests.stores.FlickrStore.error, t, d) - }); - return d; - } - }, - { - name: "ReadAPI: getLabelAttributes", - timeout: 10000, //10 seconds. Flickr can sometimes be slow. - runTest: function(t) { - // summary: - // Simple test of the getLabelAttributes function against a store set that has a label defined. - // description: - // Simple test of the getLabelAttributes function against a store set that has a label defined. - - var flickrStore = new dojox.data.FlickrStore(); - - var d = new doh.Deferred(); - function onComplete(items, request){ - t.assertEqual(items.length, 1); - var labelList = flickrStore.getLabelAttributes(items[0]); - t.assertTrue(dojo.isArray(labelList)); - t.assertEqual("title", labelList[0]); - d.callback(true); - } - flickrStore.fetch({ query: {tags: "animals"}, - count: 1, - onComplete: onComplete, - onError: dojo.partial(dojox.data.tests.stores.FlickrStore.error, t, d) - }); - return d; - } - }, - { - name: "ReadAPI: getValue", - timeout: 10000, //10 seconds. Flickr can sometimes be slow. - runTest: function(t) { - // summary: - // Simple test of the getValue function of the store. - // description: - // Simple test of the getValue function of the store. - var flickrStore = new dojox.data.FlickrStore(); - - var d = new doh.Deferred(); - function completedAll(items){ - t.is(1, items.length); - t.assertTrue(flickrStore.getValue(items[0], "title") !== null); - t.assertTrue(flickrStore.getValue(items[0], "imageUrl") !== null); - t.assertTrue(flickrStore.getValue(items[0], "imageUrlSmall") !== null); - t.assertTrue(flickrStore.getValue(items[0], "imageUrlMedium") !== null); - d.callback(true); - } - - //Get one item and look at it. - flickrStore.fetch({ count: 1, onComplete: completedAll, onError: dojo.partial(dojox.data.tests.stores.FlickrStore.error, t, d)}); - return d; //Object - } - }, - { - name: "ReadAPI: getValues", - timeout: 10000, //10 seconds. Flickr can sometimes be slow. - runTest: function(t) { - // summary: - // Simple test of the getValue function of the store. - // description: - // Simple test of the getValue function of the store. - var flickrStore = new dojox.data.FlickrStore(); - - var d = new doh.Deferred(); - function completedAll(items){ - t.is(1, items.length); - t.assertTrue(flickrStore.getValues(items[0], "title") instanceof Array); - t.assertTrue(flickrStore.getValues(items[0], "description") instanceof Array); - t.assertTrue(flickrStore.getValues(items[0], "imageUrl") instanceof Array); - t.assertTrue(flickrStore.getValues(items[0], "imageUrlSmall") instanceof Array); - t.assertTrue(flickrStore.getValues(items[0], "imageUrlMedium") instanceof Array); - d.callback(true); - } - //Get one item and look at it. - flickrStore.fetch({ count: 1, onComplete: completedAll, onError: dojo.partial(dojox.data.tests.stores.FlickrStore.error, t, d)}); - return d; //Object - } - }, - { - name: "ReadAPI: isItem", - timeout: 10000, //10 seconds. Flickr can sometimes be slow. - runTest: function(t) { - // summary: - // Simple test of the isItem function of the store - // description: - // Simple test of the isItem function of the store - var flickrStore = new dojox.data.FlickrStore(); - - var d = new doh.Deferred(); - function completedAll(items){ - t.is(5, items.length); - for(var i=0; i < items.length; i++){ - t.assertTrue(flickrStore.isItem(items[i])); - } - d.callback(true); - } - - //Get everything... - flickrStore.fetch({ count: 5, onComplete: completedAll, onError: dojo.partial(dojox.data.tests.stores.FlickrStore.error, t, d)}); - return d; //Object - } - }, - { - name: "ReadAPI: hasAttribute", - timeout: 10000, //10 seconds. Flickr can sometimes be slow. - runTest: function(t) { - // summary: - // Simple test of the hasAttribute function of the store - // description: - // Simple test of the hasAttribute function of the store - - var flickrStore = new dojox.data.FlickrStore(); - - var d = new doh.Deferred(); - function onComplete(items){ - t.is(1, items.length); - t.assertTrue(items[0] !== null); - t.assertTrue(flickrStore.hasAttribute(items[0], "title")); - t.assertTrue(flickrStore.hasAttribute(items[0], "description")); - t.assertTrue(flickrStore.hasAttribute(items[0], "author")); - t.assertTrue(!flickrStore.hasAttribute(items[0], "Nothing")); - t.assertTrue(!flickrStore.hasAttribute(items[0], "Text")); - - //Test that null attributes throw an exception - var passed = false; - try{ - flickrStore.hasAttribute(items[0], null); - }catch (e){ - passed = true; - } - t.assertTrue(passed); - d.callback(true); - } - - //Get one item... - flickrStore.fetch({ query: {tags: "animals"}, - count: 1, - onComplete: onComplete, - onError: dojo.partial(dojox.data.tests.stores.FlickrStore.error, t, d) - }); - return d; //Object - } - }, - { - name: "ReadAPI: containsValue", - timeout: 10000, //10 seconds. Flickr can sometimes be slow. - runTest: function(t) { - // summary: - // Simple test of the containsValue function of the store - // description: - // Simple test of the containsValue function of the store - - var flickrStore = new dojox.data.FlickrStore(); - - var d = new doh.Deferred(); - function onComplete(items){ - t.is(1, items.length); - d.callback(true); - } - - //Get one item... - flickrStore.fetch({ query: {tags: "animals"}, - count: 1, - onComplete: onComplete, - onError: dojo.partial(dojox.data.tests.stores.FlickrStore.error, t, d) - }); - return d; //Object - } - }, - { - name: "ReadAPI: getAttributes", - timeout: 10000, //10 seconds. Flickr can sometimes be slow. - runTest: function(t) { - // summary: - // Simple test of the getAttributes function of the store - // description: - // Simple test of the getAttributes function of the store - - var flickrStore = new dojox.data.FlickrStore(); - - var d = new doh.Deferred(); - function onComplete(items){ - t.is(1, items.length); - t.assertTrue(flickrStore.isItem(items[0])); - - var attributes = flickrStore.getAttributes(items[0]); - t.is(10, attributes.length); - d.callback(true); - } - - //Get everything... - flickrStore.fetch({ count: 1, onComplete: onComplete, onError: dojo.partial(dojox.data.tests.stores.FlickrStore.error, t, d)}); - return d; //Object - } - }, - function testReadAPI_getFeatures(t){ - // summary: - // Simple test of the getFeatures function of the store - // description: - // Simple test of the getFeatures function of the store - - var flickrStore = new dojox.data.FlickrStore(); - - var features = flickrStore.getFeatures(); - var count = 0; - for(i in features){ - t.assertTrue((i === "dojo.data.api.Read")); - count++; - } - t.assertTrue(count === 1); - }, - function testReadAPI_functionConformance(t){ - // summary: - // Simple test read API conformance. Checks to see all declared functions are actual functions on the instances. - // description: - // Simple test read API conformance. Checks to see all declared functions are actual functions on the instances. - - var testStore = new dojox.data.FlickrStore(); - var readApi = new dojo.data.api.Read(); - var passed = true; - - for(i in readApi){ - if(i.toString().charAt(0) !== '_') - { - var member = readApi[i]; - //Check that all the 'Read' defined functions exist on the test store. - if(typeof member === "function"){ - var testStoreMember = testStore[i]; - if(!(typeof testStoreMember === "function")){ - passed = false; - break; - } - } - } - } - t.assertTrue(passed); - } - ] -); - - -} diff --git a/includes/js/dojox/data/tests/stores/HtmlStore.js b/includes/js/dojox/data/tests/stores/HtmlStore.js deleted file mode 100644 index 648dd06..0000000 --- a/includes/js/dojox/data/tests/stores/HtmlStore.js +++ /dev/null @@ -1,804 +0,0 @@ -if(!dojo._hasResource["dojox.data.tests.stores.HtmlStore"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. -dojo._hasResource["dojox.data.tests.stores.HtmlStore"] = true; -dojo.provide("dojox.data.tests.stores.HtmlStore"); -dojo.require("dojox.data.HtmlStore"); -dojo.require("dojo.data.api.Read"); -dojo.require("dojo.data.api.Identity"); - - -dojox.data.tests.stores.HtmlStore.getBooks3Store = function(){ - return new dojox.data.HtmlStore({url: dojo.moduleUrl("dojox.data.tests", "stores/books3.html").toString(), dataId: "books3"}); -}; - -dojox.data.tests.stores.HtmlStore.getBooks2Store = function(){ - return new dojox.data.HtmlStore({url: dojo.moduleUrl("dojox.data.tests", "stores/books2.html").toString(), dataId: "books2"}); -}; - -dojox.data.tests.stores.HtmlStore.getBooksStore = function(){ - return new dojox.data.HtmlStore({url: dojo.moduleUrl("dojox.data.tests", "stores/books.html").toString(), dataId: "books"}); -}; - -doh.register("dojox.data.tests.stores.HtmlStore", - [ -/*************************************** - dojo.data.api.Read API -***************************************/ - function testReadAPI_fetch_all_table(t){ - // summary: - // Simple test of fetching all xml items through an XML element called isbn - // description: - // Simple test of fetching all xml items through an XML element called isbn - var store = dojox.data.tests.stores.HtmlStore.getBooksStore(); - - var d = new doh.Deferred(); - function onComplete(items, request) { - t.assertEqual(20, items.length); - d.callback(true); - } - function onError(error, request) { - d.errback(error); - } - store.fetch({query:{isbn:"*"}, onComplete: onComplete, onError: onError}); - return d; //Object - }, - function testReadAPI_fetch_all_list(t){ - // summary: - // Simple test of fetching all xml items through an XML element called isbn - // description: - // Simple test of fetching all xml items through an XML element called isbn - var store = dojox.data.tests.stores.HtmlStore.getBooks3Store(); - - var d = new doh.Deferred(); - function onComplete(items, request) { - t.assertEqual(5, items.length); - d.callback(true); - } - function onError(error, request) { - d.errback(error); - } - store.fetch({query:{name:"*"}, onComplete: onComplete, onError: onError}); - return d; //Object - }, - function testReadAPI_fetch_one_table(t){ - // summary: - // Simple test of fetching one xml items through an XML element called isbn - // description: - // Simple test of fetching one xml items through an XML element called isbn - var store = dojox.data.tests.stores.HtmlStore.getBooks2Store(); - - var d = new doh.Deferred(); - function onComplete(items, request) { - t.assertEqual(1, items.length); - d.callback(true); - } - function onError(error, request) { - d.errback(error); - } - store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError}); - return d; //Object - }, - function testReadAPI_fetch_one_list(t){ - // summary: - // Simple test of fetching one xml items through an XML element called isbn - // description: - // Simple test of fetching one xml items through an XML element called isbn - var store = dojox.data.tests.stores.HtmlStore.getBooks3Store(); - - var d = new doh.Deferred(); - function onComplete(items, request) { - t.assertEqual(1, items.length); - d.callback(true); - } - function onError(error, request) { - d.errback(error); - } - store.fetch({query:{name:"A9B57C - Title of 1 - Author of 1"}, onComplete: onComplete, onError: onError}); - return d; //Object - }, - function testReadAPI_fetch_paging(t){ - // summary: - // Simple test of fetching one xml items through an XML element called isbn - // description: - // Simple test of fetching one xml items through an XML element called isbn - var store = dojox.data.tests.stores.HtmlStore.getBooksStore(); - - var d = new doh.Deferred(); - function dumpFirstFetch(items, request){ - t.assertEqual(5, items.length); - request.start = 3; - request.count = 1; - request.onComplete = dumpSecondFetch; - store.fetch(request); - } - - function dumpSecondFetch(items, request){ - t.assertEqual(1, items.length); - request.start = 0; - request.count = 5; - request.onComplete = dumpThirdFetch; - store.fetch(request); - } - - function dumpThirdFetch(items, request){ - t.assertEqual(5, items.length); - request.start = 2; - request.count = 20; - request.onComplete = dumpFourthFetch; - store.fetch(request); - } - - function dumpFourthFetch(items, request){ - t.assertEqual(18, items.length); - request.start = 9; - request.count = 100; - request.onComplete = dumpFifthFetch; - store.fetch(request); - } - - function dumpFifthFetch(items, request){ - t.assertEqual(11, items.length); - request.start = 2; - request.count = 20; - request.onComplete = dumpSixthFetch; - store.fetch(request); - } - - function dumpSixthFetch(items, request){ - t.assertEqual(18, items.length); - d.callback(true); - } - - function completed(items, request){ - t.assertEqual(20, items.length); - request.start = 1; - request.count = 5; - request.onComplete = dumpFirstFetch; - store.fetch(request); - } - - function error(errData, request){ - d.errback(errData); - } - - store.fetch({onComplete: completed, onError: error}); - return d; //Object - }, - function testReadAPI_fetch_pattern0(t){ - // summary: - // Simple test of fetching one xml items through an XML element called isbn with ? pattern match - // description: - // Simple test of fetching one xml items through an XML element called isbn with ? pattern match - var store = dojox.data.tests.stores.HtmlStore.getBooks2Store(); - var d = new doh.Deferred(); - function onComplete(items, request) { - t.assertEqual(1, items.length); - d.callback(true); - } - function onError(error, request) { - d.errback(error); - } - store.fetch({query:{isbn:"?9B574"}, onComplete: onComplete, onError: onError}); - return d; //Object - }, - function testReadAPI_fetch_pattern1(t){ - // summary: - // Simple test of fetching one xml items through an XML element called isbn with ? pattern match - // description: - // Simple test of fetching one xml items through an XML element called isbn with ? pattern match - var store = dojox.data.tests.stores.HtmlStore.getBooks2Store(); - var d = new doh.Deferred(); - function onComplete(items, request) { - t.assertEqual(4, items.length); - d.callback(true); - } - function onError(error, request) { - d.errback(error); - } - store.fetch({query:{isbn:"A9B57?"}, onComplete: onComplete, onError: onError}); - return d; //Object - }, - function testReadAPI_fetch_pattern2(t){ - // summary: - // Simple test of fetching one xml items through an XML element called isbn with * pattern match - // description: - // Simple test of fetching one xml items through an XML element called isbn with * pattern match - var store = dojox.data.tests.stores.HtmlStore.getBooks2Store(); - var d = new doh.Deferred(); - function onComplete(items, request) { - t.assertEqual(5, items.length); - d.callback(true); - } - function onError(error, request) { - d.errback(error); - } - store.fetch({query:{isbn:"A9*"}, onComplete: onComplete, onError: onError}); - return d; //Object - }, - function testReadAPI_fetch_pattern_caseInsensitive(t){ - // summary: - // Simple test of fetching one xml items through an XML element called isbn with ? pattern match and in case insensitive mode. - // description: - // Simple test of fetching one xml items through an XML element called isbn with ? pattern match and in case insensitive mode. - var store = dojox.data.tests.stores.HtmlStore.getBooks2Store(); - var d = new doh.Deferred(); - function onComplete(items, request) { - t.assertEqual(1, items.length); - d.callback(true); - } - function onError(error, request) { - d.errback(error); - } - store.fetch({query:{isbn:"?9b574"}, queryOptions: {ignoreCase: true}, onComplete: onComplete, onError: onError}); - return d; //Object - }, - function testReadAPI_fetch_pattern_caseSensitive(t){ - // summary: - // Simple test of fetching one xml items through an XML element called isbn with ? pattern match and in case sensitive mode. - // description: - // Simple test of fetching one xml items through an XML element called isbn with ? pattern match and in case sensitive mode. - var store = dojox.data.tests.stores.HtmlStore.getBooks2Store(); - var d = new doh.Deferred(); - function onComplete(items, request) { - t.assertEqual(1, items.length); - d.callback(true); - } - function onError(error, request) { - d.errback(error); - } - store.fetch({query:{isbn:"?9B574"}, queryOptions: {ignoreCase: false}, onComplete: onComplete, onError: onError}); - return d; //Object - }, - function testReadAPI_getLabel_table(t){ - // summary: - // Simple test of the getLabel function against a store set that has a label defined. - // description: - // Simple test of the getLabel function against a store set that has a label defined. - - var store = dojox.data.tests.stores.HtmlStore.getBooks2Store(); - - var d = new doh.Deferred(); - function onComplete(items, request){ - t.assertEqual(items.length, 1); - var label = store.getLabel(items[0]); - t.assertTrue(label !== null); - t.assertEqual("Item #4", label); - d.callback(true); - } - function onError(error, request) { - d.errback(error); - } - store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError}); - return d; - }, - function testReadAPI_getLabel_list(t){ - // summary: - // Simple test of the getLabel function against a store set that has a label defined. - // description: - // Simple test of the getLabel function against a store set that has a label defined. - - var store = dojox.data.tests.stores.HtmlStore.getBooks3Store(); - - var d = new doh.Deferred(); - function onComplete(items, request){ - t.assertEqual(items.length, 1); - var label = store.getLabel(items[0]); - t.assertTrue(label !== null); - t.assertEqual("A9B57C - Title of 1 - Author of 1", label); - d.callback(true); - } - function onError(error, request) { - d.errback(error); - } - store.fetch({query:{name:"A9B57C - Title of 1 - Author of 1"}, onComplete: onComplete, onError: onError}); - return d; - }, - function testReadAPI_getLabelAttributes(t){ - // summary: - // Simple test of the getLabelAttributes function against a store set that has a label defined. - // description: - // Simple test of the getLabelAttributes function against a store set that has a label defined. - - var store = dojox.data.tests.stores.HtmlStore.getBooks2Store(); - - var d = new doh.Deferred(); - function onComplete(items, request){ - t.assertEqual(items.length, 1); - var labelList = store.getLabelAttributes(items[0]); - t.assertTrue(labelList === null); - d.callback(true); - } - function onError(error, request) { - d.errback(error); - } - store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError}); - return d; - }, - - function testReadAPI_getValue(t){ - // summary: - // Simple test of the getValue API - // description: - // Simple test of the getValue API - var store = dojox.data.tests.stores.HtmlStore.getBooks2Store(); - - var d = new doh.Deferred(); - function onComplete(items, request) { - t.assertEqual(1, items.length); - var item = items[0]; - t.assertTrue(store.hasAttribute(item,"isbn")); - t.assertEqual(store.getValue(item,"isbn"), "A9B574"); - d.callback(true); - } - function onError(error, request) { - d.errback(error); - } - store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError}); - return d; //Object - }, - function testReadAPI_getValues(t){ - // summary: - // Simple test of the getValues API - // description: - // Simple test of the getValues API - var store = dojox.data.tests.stores.HtmlStore.getBooks2Store(); - - var d = new doh.Deferred(); - function onComplete(items, request) { - t.assertEqual(1, items.length); - var item = items[0]; - t.assertTrue(store.hasAttribute(item,"isbn")); - var values = store.getValues(item,"isbn"); - t.assertEqual(1,values.length); - t.assertEqual("A9B574", values[0]); - d.callback(true); - } - function onError(error, request) { - d.errback(error); - } - store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError}); - return d; //Object - }, - function testReadAPI_isItem(t){ - // summary: - // Simple test of the isItem API - // description: - // Simple test of the isItem API - var store = dojox.data.tests.stores.HtmlStore.getBooks2Store(); - - var d = new doh.Deferred(); - function onComplete(items, request) { - t.assertEqual(1, items.length); - var item = items[0]; - t.assertTrue(store.isItem(item)); - t.assertTrue(!store.isItem({})); - t.assertTrue(!store.isItem("Foo")); - t.assertTrue(!store.isItem(1)); - d.callback(true); - } - function onError(error, request) { - d.errback(error); - } - store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError}); - return d; //Object - }, - function testReadAPI_isItem_multistore(t){ - // summary: - // Simple test of the isItem API across multiple store instances. - // description: - // Simple test of the isItem API across multiple store instances. - var store1 = dojox.data.tests.stores.HtmlStore.getBooksStore(); - var store2 = dojox.data.tests.stores.HtmlStore.getBooks2Store(); - - var d = new doh.Deferred(); - function onComplete1(items, request) { - t.assertEqual(1, items.length); - var item1 = items[0]; - t.assertTrue(store1.isItem(item1)); - - function onComplete2(items, request) { - t.assertEqual(1, items.length); - var item2 = items[0]; - t.assertTrue(store2.isItem(item2)); - t.assertTrue(!store1.isItem(item2)); - t.assertTrue(!store2.isItem(item1)); - d.callback(true); - } - store2.fetch({query:{isbn:"A9B574"}, onComplete: onComplete2, onError: onError}); - } - function onError(error, request) { - d.errback(error); - } - store1.fetch({query:{isbn:"1"}, onComplete: onComplete1, onError: onError}); - return d; //Object - }, - function testReadAPI_hasAttribute(t){ - // summary: - // Simple test of the hasAttribute API - // description: - // Simple test of the hasAttribute API - var store = dojox.data.tests.stores.HtmlStore.getBooks2Store(); - - var d = new doh.Deferred(); - function onComplete(items, request) { - t.assertEqual(1, items.length); - var item = items[0]; - t.assertTrue(store.hasAttribute(item,"isbn")); - t.assertTrue(!store.hasAttribute(item,"bob")); - d.callback(true); - } - function onError(error, request) { - d.errback(error); - } - store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError}); - return d; //Object - }, - function testReadAPI_containsValue(t){ - // summary: - // Simple test of the containsValue API - // description: - // Simple test of the containsValue API - var store = dojox.data.tests.stores.HtmlStore.getBooks2Store(); - - var d = new doh.Deferred(); - function onComplete(items, request) { - t.assertEqual(1, items.length); - var item = items[0]; - t.assertTrue(store.containsValue(item,"isbn", "A9B574")); - t.assertTrue(!store.containsValue(item,"isbn", "bob")); - d.callback(true); - } - function onError(error, request) { - d.errback(error); - } - store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError}); - return d; //Object - }, - function testReadAPI_sortDescending(t){ - // summary: - // Simple test of the sorting API in descending order. - // description: - // Simple test of the sorting API in descending order. - var store = dojox.data.tests.stores.HtmlStore.getBooksStore(); - - //Comparison is done as a string type (toString comparison), so the order won't be numeric - //So have to compare in 'alphabetic' order. - var order = [9,8,7,6,5,4,3,20,2,19,18,17,16,15,14,13,12,11,10,1]; - - var d = new doh.Deferred(); - function onComplete(items, request) { - t.assertEqual(20, items.length); - - for(var i = 0; i < items.length; i++){ - t.assertEqual(order[i], store.getValue(items[i],"isbn").toString()); - } - d.callback(true); - } - function onError(error, request) { - d.errback(error); - } - - var sortAttributes = [{attribute: "isbn", descending: true}]; - store.fetch({query:{isbn:"*"}, sort: sortAttributes, onComplete: onComplete, onError: onError}); - return d; //Object - }, - function testReadAPI_sortAscending(t){ - // summary: - // Simple test of the sorting API in ascending order. - // description: - // Simple test of the sorting API in ascending order. - var store = dojox.data.tests.stores.HtmlStore.getBooksStore(); - - //Comparison is done as a string type (toString comparison), so the order won't be numeric - //So have to compare in 'alphabetic' order. - var order = [1,10,11,12,13,14,15,16,17,18,19,2,20,3,4,5,6,7,8,9]; - - var d = new doh.Deferred(); - function onComplete(items, request) { - t.assertEqual(20, items.length); - var itemId = 1; - for(var i = 0; i < items.length; i++){ - t.assertEqual(order[i], store.getValue(items[i],"isbn").toString()); - } - d.callback(true); - } - function onError(error, request) { - d.errback(error); - } - - var sortAttributes = [{attribute: "isbn"}]; - store.fetch({query:{isbn:"*"}, sort: sortAttributes, onComplete: onComplete, onError: onError}); - return d; //Object - }, - function testReadAPI_sortDescendingNumeric(t){ - // summary: - // Simple test of the sorting API in descending order using a numeric comparator. - // description: - // Simple test of the sorting API in descending order using a numeric comparator. - var store = dojox.data.tests.stores.HtmlStore.getBooksStore(); - - //isbn should be treated as a numeric, not as a string comparison - store.comparatorMap = {}; - store.comparatorMap["isbn"] = function(a, b){ - var ret = 0; - if(parseInt(a.toString()) > parseInt(b.toString())){ - ret = 1; - }else if(parseInt(a.toString()) < parseInt(b.toString())){ - ret = -1; - } - return ret; //int, {-1,0,1} - }; - - var d = new doh.Deferred(); - function onComplete(items, request) { - t.assertEqual(20, items.length); - var itemId = 20; - for(var i = 0; i < items.length; i++){ - t.assertEqual(itemId, store.getValue(items[i],"isbn").toString()); - itemId--; - } - d.callback(true); - } - function onError(error, request) { - d.errback(error); - } - - var sortAttributes = [{attribute: "isbn", descending: true}]; - store.fetch({query:{isbn:"*"}, sort: sortAttributes, onComplete: onComplete, onError: onError}); - return d; //Object - }, - function testReadAPI_sortAscendingNumeric(t){ - // summary: - // Simple test of the sorting API in ascending order using a numeric comparator. - // description: - // Simple test of the sorting API in ascending order using a numeric comparator. - var store = dojox.data.tests.stores.HtmlStore.getBooksStore(); - - //isbn should be treated as a numeric, not as a string comparison - store.comparatorMap = {}; - store.comparatorMap["isbn"] = function(a, b){ - var ret = 0; - if(parseInt(a.toString()) > parseInt(b.toString())){ - ret = 1; - }else if(parseInt(a.toString()) < parseInt(b.toString())){ - ret = -1; - } - return ret; //int, {-1,0,1} - }; - - var d = new doh.Deferred(); - function onComplete(items, request) { - t.assertEqual(20, items.length); - var itemId = 1; - for(var i = 0; i < items.length; i++){ - t.assertEqual(itemId, store.getValue(items[i],"isbn").toString()); - itemId++; - } - d.callback(true); - } - function onError(error, request) { - d.errback(error); - } - - var sortAttributes = [{attribute: "isbn"}]; - store.fetch({query:{isbn:"*"}, sort: sortAttributes, onComplete: onComplete, onError: onError}); - return d; //Object - }, - function testReadAPI_isItemLoaded(t){ - // summary: - // Simple test of the isItemLoaded API - // description: - // Simple test of the isItemLoaded API - var store = dojox.data.tests.stores.HtmlStore.getBooks2Store(); - - var d = new doh.Deferred(); - function onComplete(items, request) { - t.assertEqual(1, items.length); - var item = items[0]; - t.assertTrue(store.isItemLoaded(item)); - d.callback(true); - } - function onError(error, request) { - d.errback(error); - } - store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError}); - return d; //Object - }, - function testReadAPI_getFeatures(t){ - // summary: - // Simple test of the getFeatures function of the store - // description: - // Simple test of the getFeatures function of the store - - var store = dojox.data.tests.stores.HtmlStore.getBooks2Store(); - var features = store.getFeatures(); - var count = 0; - for(i in features){ - t.assertTrue((i === "dojo.data.api.Read" || i === "dojo.data.api.Identity")); - count++; - } - t.assertEqual(2, count); - }, - function testReadAPI_getAttributes(t){ - // summary: - // Simple test of the getAttributes API - // description: - // Simple test of the getAttributes API - var store = dojox.data.tests.stores.HtmlStore.getBooks2Store(); - - var d = new doh.Deferred(); - function onComplete(items, request) { - t.assertEqual(1, items.length); - var item = items[0]; - var attributes = store.getAttributes(item); - t.assertEqual(3,attributes.length); - for(var i=0; i parseInt(b.toString())){ - ret = 1; - }else if(parseInt(a.toString()) < parseInt(b.toString())){ - ret = -1; - } - return ret; //int, {-1,0,1} - }; - - var d = new doh.Deferred(); - function onComplete(items, request) { - t.assertEqual(20, items.length); - var itemId = 20; - for(var i = 0; i < items.length; i++){ - t.assertEqual(itemId, store.getValue(items[i],"isbn").toString()); - itemId--; - } - d.callback(true); - } - function onError(error, request) { - d.errback(error); - } - - var sortAttributes = [{attribute: "isbn", descending: true}]; - store.fetch({query:{isbn:"*"}, sort: sortAttributes, onComplete: onComplete, onError: onError}); - return d; //Object - }, - function testReadAPI_sortAscendingNumeric(t){ - // summary: - // Simple test of the sorting API in ascending order using a numeric comparator. - // description: - // Simple test of the sorting API in ascending order using a numeric comparator. - var store = dojox.data.tests.stores.HtmlTableStore.getBooksStore(); - - //isbn should be treated as a numeric, not as a string comparison - store.comparatorMap = {}; - store.comparatorMap["isbn"] = function(a, b){ - var ret = 0; - if(parseInt(a.toString()) > parseInt(b.toString())){ - ret = 1; - }else if(parseInt(a.toString()) < parseInt(b.toString())){ - ret = -1; - } - return ret; //int, {-1,0,1} - }; - - var d = new doh.Deferred(); - function onComplete(items, request) { - t.assertEqual(20, items.length); - var itemId = 1; - for(var i = 0; i < items.length; i++){ - t.assertEqual(itemId, store.getValue(items[i],"isbn").toString()); - itemId++; - } - d.callback(true); - } - function onError(error, request) { - d.errback(error); - } - - var sortAttributes = [{attribute: "isbn"}]; - store.fetch({query:{isbn:"*"}, sort: sortAttributes, onComplete: onComplete, onError: onError}); - return d; //Object - }, - function testReadAPI_isItemLoaded(t){ - // summary: - // Simple test of the isItemLoaded API - // description: - // Simple test of the isItemLoaded API - var store = dojox.data.tests.stores.HtmlTableStore.getBooks2Store(); - - var d = new doh.Deferred(); - function onComplete(items, request) { - t.assertEqual(1, items.length); - var item = items[0]; - t.assertTrue(store.isItemLoaded(item)); - d.callback(true); - } - function onError(error, request) { - d.errback(error); - } - store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError}); - return d; //Object - }, - function testReadAPI_getFeatures(t){ - // summary: - // Simple test of the getFeatures function of the store - // description: - // Simple test of the getFeatures function of the store - - var store = dojox.data.tests.stores.HtmlTableStore.getBooks2Store(); - var features = store.getFeatures(); - var count = 0; - for(i in features){ - t.assertTrue((i === "dojo.data.api.Read" || i === "dojo.data.api.Identity")); - count++; - } - t.assertEqual(2, count); - }, - function testReadAPI_getAttributes(t){ - // summary: - // Simple test of the getAttributes API - // description: - // Simple test of the getAttributes API - var store = dojox.data.tests.stores.HtmlTableStore.getBooks2Store(); - - var d = new doh.Deferred(); - function onComplete(items, request) { - t.assertEqual(1, items.length); - var item = items[0]; - var attributes = store.getAttributes(item); - t.assertEqual(3,attributes.length); - for(var i=0; i lastCharB || typeof lastCharA === "undefined"){ - ret = 1; - }else if(lastCharA < lastCharB || typeof lastCharB === "undefined"){ - ret = -1; - } - return ret; - }; - - var sortAttributes = [{attribute: "key", descending: true}, { attribute: "value", descending: true}]; - - var d = new doh.Deferred(); - function completed(items, findResult){ - var orderedArray = [5,4,0,3,2,1,6]; - var orderedArray = [ "day", "nday", "weekOfYear", "dayOfYear", "year", "month", "nmonth" ]; - t.assertTrue(items.length === 7); - var passed = true; - for(var i = 0; i < items.length; i++){ - if(!(keyStore.getIdentity(items[i]) === orderedArray[i])){ - passed=false; - break; - } - } - t.assertTrue(passed); - d.callback(true); - } - - keyStore.fetch({sort: sortAttributes, onComplete: completed, onError: dojo.partial(dojox.data.tests.stores.KeyValueStore.error, t, d)}); - return d; //Object - }, - function testReadAPI_functionConformance(t){ - // summary: - // Simple test read API conformance. Checks to see all declared functions are actual functions on the instances. - // description: - // Simple test read API conformance. Checks to see all declared functions are actual functions on the instances. - - var testStore = new dojox.data.KeyValueStore(dojox.data.tests.stores.KeyValueStore.getDatasource("stores/movies.csv")); - var readApi = new dojo.data.api.Read(); - var passed = true; - - for(i in readApi){ - if(i.toString().charAt(0) !== '_') - { - var member = readApi[i]; - //Check that all the 'Read' defined functions exist on the test store. - if(typeof member === "function"){ - console.log("Looking at function: [" + i + "]"); - var testStoreMember = testStore[i]; - if(!(typeof testStoreMember === "function")){ - console.log("Problem with function: [" + i + "]. Got value: " + testStoreMember); - passed = false; - break; - } - } - } - } - t.assertTrue(passed); - }, - function testIdentityAPI_functionConformance(t){ - // summary: - // Simple test identity API conformance. Checks to see all declared functions are actual functions on the instances. - // description: - // Simple test identity API conformance. Checks to see all declared functions are actual functions on the instances. - - var testStore = new dojox.data.KeyValueStore(dojox.data.tests.stores.KeyValueStore.getDatasource("stores/movies.csv")); - var identityApi = new dojo.data.api.Identity(); - var passed = true; - - for(i in identityApi){ - if(i.toString().charAt(0) !== '_') - { - var member = identityApi[i]; - //Check that all the 'Read' defined functions exist on the test store. - if(typeof member === "function"){ - console.log("Looking at function: [" + i + "]"); - var testStoreMember = testStore[i]; - if(!(typeof testStoreMember === "function")){ - passed = false; - break; - } - } - } - } - t.assertTrue(passed); - } - ] -); - - -} diff --git a/includes/js/dojox/data/tests/stores/OpmlStore.js b/includes/js/dojox/data/tests/stores/OpmlStore.js deleted file mode 100644 index 4fe7be4..0000000 --- a/includes/js/dojox/data/tests/stores/OpmlStore.js +++ /dev/null @@ -1,1075 +0,0 @@ -if(!dojo._hasResource["dojox.data.tests.stores.OpmlStore"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. -dojo._hasResource["dojox.data.tests.stores.OpmlStore"] = true; -dojo.provide("dojox.data.tests.stores.OpmlStore"); -dojo.require("dojox.data.OpmlStore"); -dojo.require("dojo.data.api.Read"); - -dojox.data.tests.stores.OpmlStore.getDatasource = function(filepath){ - // summary: - // A simple helper function for getting the sample data used in each of the tests. - // description: - // A simple helper function for getting the sample data used in each of the tests. - - var dataSource = {}; - if(dojo.isBrowser){ - dataSource.url = dojo.moduleUrl("dojox.data.tests", filepath).toString(); - }else{ - // When running tests in Rhino, xhrGet is not available, - // so we have the file data in the code below. - switch(filepath){ - case "stores/geography.xml": - var opmlData = ""; - opmlData += '\n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' geography.opml\n'; - opmlData += ' 2006-11-10\n'; - opmlData += ' 2006-11-13\n'; - opmlData += ' Magellan, Ferdinand\n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - break; - case "stores/geography_withspeciallabel.xml": - var opmlData = ""; - opmlData += '\n'; - opmlData += '\n'; - opmlData += ' \n'; - opmlData += ' geography.opml\n'; - opmlData += ' 2006-11-10\n'; - opmlData += ' 2006-11-13\n'; - opmlData += ' Magellan, Ferdinand\n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += ' \n'; - opmlData += '\n'; - break; - } - dataSource.data = opmlData; - } - return dataSource; //Object -} - -dojox.data.tests.stores.OpmlStore.verifyItems = function(opmlStore, items, attribute, compareArray){ - // summary: - // A helper function for validating that the items array is ordered - // the same as the compareArray - if(items.length != compareArray.length){ return false; } - for(var i = 0; i < items.length; i++){ - if(!(opmlStore.getValue(items[i], attribute) === compareArray[i])){ - return false; //Boolean - } - } - return true; //Boolean -} - -dojox.data.tests.stores.OpmlStore.error = function(t, d, errData){ - // summary: - // The error callback function to be used for all of the tests. - d.errback(errData); -} - -doh.register("dojox.data.tests.stores.OpmlStore", - [ - function testReadAPI_fetch_all(t){ - // summary: - // Simple test of a basic fetch on OpmlStore. - // description: - // Simple test of a basic fetch on OpmlStore. - - var args = dojox.data.tests.stores.OpmlStore.getDatasource("stores/geography.xml"); - var opmlStore = new dojox.data.OpmlStore(args); - - var d = new doh.Deferred(); - function completedAll(items){ - t.is(6, items.length); - d.callback(true); - } - - //Get everything... - opmlStore.fetch({ onComplete: completedAll, onError: dojo.partial(dojox.data.tests.stores.OpmlStore.error, t, d)}); - return d; //Object - }, - function testReadAPI_fetch_one(t){ - // summary: - // Simple test of a basic fetch on OpmlStore of a single item. - // description: - // Simple test of a basic fetch on OpmlStore of a single item. - - var args = dojox.data.tests.stores.OpmlStore.getDatasource("stores/geography.xml"); - var opmlStore = new dojox.data.OpmlStore(args); - - var d = new doh.Deferred(); - function onComplete(items, request){ - t.is(1, items.length); - d.callback(true); - } - opmlStore.fetch({ query: {text: "Asia"}, - onComplete: onComplete, - onError: dojo.partial(dojox.data.tests.stores.OpmlStore.error, t, d) - }); - return d; //Object - }, - - function testReadAPI_fetch_one_Multiple(t){ - // summary: - // Simple test of a basic fetch on OpmlStore of a single item. - // description: - // Simple test of a basic fetch on OpmlStore of a single item. - - var args = dojox.data.tests.stores.OpmlStore.getDatasource("stores/geography.xml"); - var opmlStore = new dojox.data.OpmlStore(args); - - var d = new doh.Deferred(); - var done = [false,false]; - function onCompleteOne(items, request){ - done[0] = true; - t.is(1, items.length); - if(done[0] && done[1]){ - d.callback(true); - } - } - function onCompleteTwo(items, request){ - done[1] = true; - t.is(1, items.length); - if(done[0] && done[1]){ - d.callback(true); - } - } - - opmlStore.fetch({ query: {text: "Asia"}, - onComplete: onCompleteOne, - onError: dojo.partial(dojox.data.tests.stores.OpmlStore.error, t, d) - }); - - opmlStore.fetch({ query: {text: "North America"}, - onComplete: onCompleteTwo, - onError: dojo.partial(dojox.data.tests.stores.OpmlStore.error, t, d) - }); - - return d; //Object - }, - - function testReadAPI_fetch_one_MultipleMixed(t){ - // summary: - // Simple test of a basic fetch on OpmlStore of a single item mixing two fetch types. - // description: - // Simple test of a basic fetch on Cpmltore of a single item mixing two fetch types. - - var args = dojox.data.tests.stores.OpmlStore.getDatasource("stores/geography.xml"); - var opmlStore = new dojox.data.OpmlStore(args); - - var d = new doh.Deferred(); - - var done = [false, false]; - function onComplete(items, request){ - done[0] = true; - t.is(1, items.length); - console.log("Found item: " + opmlStore.getValue(items[0],"text") + " with identity: " + opmlStore.getIdentity(items[0])); - t.is(0, opmlStore.getIdentity(items[0])); - if(done[0] && done[1]){ - d.callback(true); - } - } - - function onItem(item){ - done[1] = true; - t.assertTrue(item !== null); - console.log("Found item: " + opmlStore.getValue(item,"text")); - t.is('Egypt', opmlStore.getValue(item,"text")); //Should be the second node parsed, ergo id 1, first node is id 0. - t.is(1, opmlStore.getIdentity(item)); - if(done[0] && done[1]){ - d.callback(true); - } - } - - opmlStore.fetch({ query: {text: "Africa"}, - onComplete: onComplete, - onError: dojo.partial(dojox.data.tests.stores.OpmlStore.error, t, d) - }); - - opmlStore.fetchItemByIdentity({identity: "1", onItem: onItem, onError: dojo.partial(dojox.data.tests.stores.OpmlStore.error, t, d)}); - - return d; //Object - }, - - function testReadAPI_fetch_one_deep(t){ - // summary: - // Simple test of a basic fetch on OpmlStore of a single item that's nested down as a child item. - // description: - // Simple test of a basic fetch on OpmlStore of a single item that's nested down as a child item. - - var args = dojox.data.tests.stores.OpmlStore.getDatasource("stores/geography.xml"); - var opmlStore = new dojox.data.OpmlStore(args); - - var d = new doh.Deferred(); - function onComplete(items, request){ - t.is(1, items.length); - d.callback(true); - } - opmlStore.fetch({ query: {text: "Mexico City"}, - queryOptions: {deep:true}, - onComplete: onComplete, - onError: dojo.partial(dojox.data.tests.stores.OpmlStore.error, t, d) - }); - return d; //Object - }, - - function testReadAPI_fetch_one_deep_off(t){ - // summary: - // Simple test of a basic fetch on OpmlStore of a single item that's nested down as a child item. - // description: - // Simple test of a basic fetch on OpmlStore of a single item that's nested down as a child item. - - var args = dojox.data.tests.stores.OpmlStore.getDatasource("stores/geography.xml"); - var opmlStore = new dojox.data.OpmlStore(args); - - var d = new doh.Deferred(); - function onComplete(items, request){ - //Nothing should be found. - t.is(0, items.length); - d.callback(true); - } - opmlStore.fetch({ query: {text: "Mexico City"}, - onComplete: onComplete, - onError: dojo.partial(dojox.data.tests.stores.OpmlStore.error, t, d) - }); - return d; //Object - }, - - function testReadAPI_fetch_all_streaming(t){ - // summary: - // Simple test of a basic fetch on OpmlStore. - // description: - // Simple test of a basic fetch on OpmlStore. - - var args = dojox.data.tests.stores.OpmlStore.getDatasource("stores/geography.xml"); - var opmlStore = new dojox.data.OpmlStore(args); - - var d = new doh.Deferred(); - count = 0; - - function onBegin(size, requestObj){ - t.is(6, size); - } - function onItem(item, requestObj){ - t.assertTrue(opmlStore.isItem(item)); - count++; - } - function onComplete(items, request){ - t.is(6, count); - t.is(null, items); - d.callback(true); - } - - //Get everything... - opmlStore.fetch({ onBegin: onBegin, - onItem: onItem, - onComplete: onComplete, - onError: dojo.partial(dojox.data.tests.stores.OpmlStore.error, t, d) - }); - return d; //Object - }, - function testReadAPI_fetch_paging(t){ - // summary: - // Test of multiple fetches on a single result. Paging, if you will. - // description: - // Test of multiple fetches on a single result. Paging, if you will. - - var args = dojox.data.tests.stores.OpmlStore.getDatasource("stores/geography.xml"); - var opmlStore = new dojox.data.OpmlStore(args); - - var d = new doh.Deferred(); - function dumpFirstFetch(items, request){ - t.is(5, items.length); - request.start = 3; - request.count = 1; - request.onComplete = dumpSecondFetch; - opmlStore.fetch(request); - } - - function dumpSecondFetch(items, request){ - t.is(1, items.length); - request.start = 0; - request.count = 5; - request.onComplete = dumpThirdFetch; - opmlStore.fetch(request); - } - - function dumpThirdFetch(items, request){ - t.is(5, items.length); - request.start = 2; - request.count = 20; - request.onComplete = dumpFourthFetch; - opmlStore.fetch(request); - } - - function dumpFourthFetch(items, request){ - t.is(4, items.length); - request.start = 9; - request.count = 100; - request.onComplete = dumpFifthFetch; - opmlStore.fetch(request); - } - - function dumpFifthFetch(items, request){ - t.is(0, items.length); - request.start = 2; - request.count = 20; - request.onComplete = dumpSixthFetch; - opmlStore.fetch(request); - } - - function dumpSixthFetch(items, request){ - t.is(4, items.length); - d.callback(true); - } - - function completed(items, request){ - t.is(6, items.length); - request.start = 1; - request.count = 5; - request.onComplete = dumpFirstFetch; - opmlStore.fetch(request); - } - - opmlStore.fetch({onComplete: completed, onError: dojo.partial(dojox.data.tests.stores.OpmlStore.error, t, d)}); - return d; //Object - - }, - function testReadAPI_getLabel(t){ - // summary: - // Simple test of the getLabel function against a store set that has a label defined. - // description: - // Simple test of the getLabel function against a store set that has a label defined. - - var args = dojox.data.tests.stores.OpmlStore.getDatasource("stores/geography.xml"); - var opmlStore = new dojox.data.OpmlStore(args); - - var d = new doh.Deferred(); - function onComplete(items, request){ - t.assertEqual(items.length, 1); - var label = opmlStore.getLabel(items[0]); - t.assertTrue(label !== null); - t.assertEqual("Asia", label); - d.callback(true); - } - opmlStore.fetch({ query: {text: "Asia"}, - onComplete: onComplete, - onError: dojo.partial(dojox.data.tests.stores.OpmlStore.error, t, d) - }); - return d; - }, - function testReadAPI_getLabelAttributes(t){ - // summary: - // Simple test of the getLabelAttributes function against a store set that has a label defined. - // description: - // Simple test of the getLabelAttributes function against a store set that has a label defined. - - var args = dojox.data.tests.stores.OpmlStore.getDatasource("stores/geography.xml"); - var opmlStore = new dojox.data.OpmlStore(args); - - var d = new doh.Deferred(); - function onComplete(items, request){ - t.assertEqual(items.length, 1); - var labelList = opmlStore.getLabelAttributes(items[0]); - t.assertTrue(dojo.isArray(labelList)); - t.assertEqual("text", labelList[0]); - d.callback(true); - } - opmlStore.fetch({ query: {text: "Asia"}, - onComplete: onComplete, - onError: dojo.partial(dojox.data.tests.stores.OpmlStore.error, t, d) - }); - return d; - }, - - function testReadAPI_getLabel_nondefault(t){ - // summary: - // Simple test of the getLabel function against a store set that has a label defined. - // description: - // Simple test of the getLabel function against a store set that has a label defined. - - var args = dojox.data.tests.stores.OpmlStore.getDatasource("stores/geography_withspeciallabel.xml"); - args.label="label"; - var opmlStore = new dojox.data.OpmlStore(args); - - var d = new doh.Deferred(); - function onComplete(items, request){ - t.assertEqual(items.length, 1); - var label = opmlStore.getLabel(items[0]); - t.assertTrue(label !== null); - t.assertEqual("Continent/Asia", label); - d.callback(true); - } - opmlStore.fetch({ query: {text: "Asia"}, - onComplete: onComplete, - onError: dojo.partial(dojox.data.tests.stores.OpmlStore.error, t, d) - }); - return d; - }, - function testReadAPI_getLabelAttributes_nondefault(t){ - // summary: - // Simple test of the getLabelAttributes function against a store set that has a label defined. - // description: - // Simple test of the getLabelAttributes function against a store set that has a label defined. - - var args = dojox.data.tests.stores.OpmlStore.getDatasource("stores/geography_withspeciallabel.xml"); - args.label="label"; - var opmlStore = new dojox.data.OpmlStore(args); - - var d = new doh.Deferred(); - function onComplete(items, request){ - t.assertEqual(items.length, 1); - var labelList = opmlStore.getLabelAttributes(items[0]); - t.assertTrue(dojo.isArray(labelList)); - t.assertEqual("label", labelList[0]); - d.callback(true); - } - opmlStore.fetch({ query: {text: "Asia"}, - onComplete: onComplete, - onError: dojo.partial(dojox.data.tests.stores.OpmlStore.error, t, d) - }); - return d; - }, - - function testReadAPI_getValue(t){ - // summary: - // Simple test of the getValue function of the store. - // description: - // Simple test of the getValue function of the store. - - var args = dojox.data.tests.stores.OpmlStore.getDatasource("stores/geography.xml"); - var opmlStore = new dojox.data.OpmlStore(args); - - var d = new doh.Deferred(); - function completedAll(items){ - t.is(6, items.length); - - t.is("Africa", opmlStore.getValue(items[0],"text")); - t.is("Asia", opmlStore.getValue(items[1],"text")); - t.is("Australia", opmlStore.getValue(items[2],"text")); - t.is("Europe", opmlStore.getValue(items[3],"text")); - t.is("North America", opmlStore.getValue(items[4],"text")); - t.is("South America", opmlStore.getValue(items[5],"text")); - - t.is("continent", opmlStore.getValue(items[1],"type")); - t.is("21 million", opmlStore.getValue(items[2],"population")); - - var firstChild = opmlStore.getValue(items[4],"children"); - t.assertTrue(opmlStore.isItem(firstChild)); - t.is("Mexico", opmlStore.getValue(firstChild,"text")); - t.is("country", opmlStore.getValue(firstChild,"type")); - t.is("108 million", opmlStore.getValue(firstChild,"population")); - t.is("1,972,550 sq km", opmlStore.getValue(firstChild,"area")); - - firstChild = opmlStore.getValue(firstChild,"children"); - t.assertTrue(opmlStore.isItem(firstChild)); - t.is("Mexico City", opmlStore.getValue(firstChild,"text")); - t.is("city", opmlStore.getValue(firstChild,"type")); - t.is("19 million", opmlStore.getValue(firstChild,"population")); - t.is("-6 UTC", opmlStore.getValue(firstChild,"timezone")); - - d.callback(true); - } - - //Get everything... - opmlStore.fetch({ onComplete: completedAll, onError: dojo.partial(dojox.data.tests.stores.OpmlStore.error, t, d)}); - return d; //Object - }, - function testReadAPI_getValues(t){ - // summary: - // Simple test of the getValues function of the store. - // description: - // Simple test of the getValues function of the store. - - var args = dojox.data.tests.stores.OpmlStore.getDatasource("stores/geography.xml"); - var opmlStore = new dojox.data.OpmlStore(args); - - var d = new doh.Deferred(); - function completed(items){ - t.is(1, items.length); - - var children = opmlStore.getValues(items[0],"children"); - t.is(3, children.length); - for(var i=0; iAlabama", store.getValue(item, "label")); - t.assertEqual("AL", store.getValue(item, "abbreviation")); - // Test the defaultValue cases (the third paramter). - t.assertEqual("default value", store.getValue(item, "NAME", "default value")); - // TODO Test for null somehow ... - // Read api says: Returns null if and only if null was explicitly set as the attribute value. - - // According to Read-API getValue() an exception is thrown when - // the item is not an item or when the attribute is not a string. - t.assertError(Error, store, "getValue", ["not an item", "NOT THERE"]); - t.assertError(Error, store, "getValue", [item, {}]); - - d.callback(true); - } - store.fetch({query:{q:"Alabama"}, onComplete: onComplete}); - return d; //Object - }, - - function testReadApi_getValues(t){ - // summary: - // description: - var store = dojox.data.tests.stores.QueryReadStore.getStore(); - - var d = new doh.Deferred(); - function onComplete(items, request){ - var item = items[0]; - // The good cases. - t.assertEqual(["Alabama"], store.getValues(item, "name")); - t.assertEqual(["Alabama"], store.getValues(item, "label")); - t.assertEqual(["AL"], store.getValues(item, "abbreviation")); - // TODO Test for null somehow ... - // Read api says: Returns null if and only if null was explicitly set as the attribute value. - - // Test for not-existing attributes without defaultValues and invalid items. - // TODO - t.assertEqual([], store.getValues(item, "NOT THERE")); - var errThrown = false; - try{ - //Should throw an exception. - var values = store.getValues("not an item", "NOT THERE"); - }catch (e){ - errThrown = true; - } - t.assertTrue(errThrown); - d.callback(true); - } - store.fetch({query:{q:"Alabama"}, onComplete: onComplete}); - return d; //Object - }, - - function testReadApi_getAttributes(t){ - // summary: - // description: - var store = dojox.data.tests.stores.QueryReadStore.getStore(); - - var d = new doh.Deferred(); - function onComplete(items, request){ - var item = items[0]; - // The good case(s). - t.assertEqual(['id', 'name', 'label', 'abbreviation', 'capital'], store.getAttributes(item)); - t.assertError(Error, store, "getAttributes", [{}]); - - d.callback(true); - } - store.fetch({query:{q:"Alabama"}, onComplete: onComplete}); - return d; //Object - }, - - function testReadApi_getLabel(t){ - var store = dojox.data.tests.stores.QueryReadStore.getStore(); - var d = new doh.Deferred(); - function onComplete(items, request){ - var item = items[0]; - // The good cases. - t.assertEqual(["Alabama"], store.getLabel(item)); - d.callback(true); - } - store.fetch({query:{q:"Alabama"}, onComplete: onComplete}); - return d; //Object - }, - - function testReadApi_hasAttribute(t){ - // summary: - // description: - var store = dojox.data.tests.stores.QueryReadStore.getStore(); - - var d = new doh.Deferred(); - function onComplete(items, request){ - var item = items[0]; - // The positive cases. - t.assertEqual(true, store.hasAttribute(item, "name")); - t.assertEqual(true, store.hasAttribute(item, "label")); - t.assertEqual(true, store.hasAttribute(item, "abbreviation")); - // Make sure attribute case doesnt matter. - t.assertEqual(false, store.hasAttribute(item, "NAME")); - t.assertEqual(false, store.hasAttribute(item, "Name")); - t.assertEqual(false, store.hasAttribute(item, "Label")); - // Pass in an invalid item. - t.assertEqual(false, store.hasAttribute({}, "abbreviation")); - // pass in something that looks like the item with the attribute. - t.assertEqual(false, store.hasAttribute({name:"yo"}, "name")); - - d.callback(true); - } - store.fetch({query:{q:"Alaska"}, onComplete: onComplete}); - return d; //Object - }, - - function testReadApi_containsValue(t){ - // summary: - // description: - var store = dojox.data.tests.stores.QueryReadStore.getStore(); - - var d = new doh.Deferred(); - function onComplete(items, request){ - var item = items[0]; - t.assertTrue(store.containsValue(item, "name", "Alaska")); - d.callback(true); - } - store.fetch({query:{q:"Alaska"}, onComplete: onComplete}); - return d; //Object - }, - - function testReadApi_isItem(t){ - // summary: - // description: - var store = dojox.data.tests.stores.QueryReadStore.getStore(); - - var d = new doh.Deferred(); - function onComplete(items, request){ - // The good case. - t.assertEqual(true, store.isItem(items[0])); - // Try a pure object. - t.assertEqual(false, store.isItem({})); - // Try to look like an item. - t.assertEqual(false, store.isItem({name:"Alaska", label:"Alaska", abbreviation:"AK"})); - d.callback(true); - } - store.fetch({query:{q:"Alaska"}, onComplete: onComplete}); - return d; //Object - }, - - function testReadApi_isItemLoaded(t){ - // summary: - // description: - var store = dojox.data.tests.stores.QueryReadStore.getStore(); - - var d = new doh.Deferred(); - function onComplete(items, request){ - var item = items[0]; - // The good case(s). - t.assertTrue(store.isItemLoaded(item)); - - d.callback(true); - } - store.fetch({query:{q:"Alabama"}, onComplete: onComplete}); - return d; //Object - }, - - //function testReadApi_loadItem(t){ - // // summary: - // // description: - // t.assertTrue(false); - //}, - - function testReadApi_fetch_all(t){ - // summary: - // Simple test of fetching all items. - // description: - // Simple test of fetching all items. - var store = dojox.data.tests.stores.QueryReadStore.getStore(); - - var d = new doh.Deferred(); - function onComplete(items, request) { - t.assertEqual(8, items.length); - d.callback(true); - } - function onError(error, request) { - d.errback(error); - } - store.fetch({query:{q:"m"}, onComplete: onComplete, onError: onError}); - return d; //Object - }, - - function testReadApi_fetch_onBegin(t){ - // summary: - // Simple test of fetching items, checking that onBegin size is all items matched, and page is just the items asked for. - // description: - // Simple test of fetching items, checking that onBegin size is all items matched, and page is just the items asked for. - var store = dojox.data.tests.stores.QueryReadStore.getStore(); - - var d = new doh.Deferred(); - var passed = false; - function onBegin(size, request){ - t.assertEqual(8, size); - passed = true; - } - function onComplete(items, request) { - t.assertEqual(5, items.length); - if(passed){ - d.callback(true); - }else{ - d.errback(new Error("Store did not return proper number of rows, regardless of page size")); - } - } - function onError(error, request) { - d.errback(error); - } - store.fetch({query:{q:"m"}, start: 0, count: 5, onBegin: onBegin, onComplete: onComplete, onError: onError}); - return d; //Object - }, - - function testReadApi_fetch_onBegin_ServersidePaging(t){ - // summary: - // Simple test of fetching items, checking that onBegin size is all items matched, and page is just the items asked for. - // description: - // Simple test of fetching items, checking that onBegin size is all items matched, and page is just the items asked for. - var store = dojox.data.tests.stores.QueryReadStore.getStore(); - - var d = new doh.Deferred(); - var passed = false; - function onBegin(size, request){ - t.assertEqual(8, size); - passed = true; - } - function onComplete(items, request) { - t.assertEqual(3, items.length); - if(passed){ - d.callback(true); - }else{ - d.errback(new Error("Store did not return proper number of rows, regardless of page size")); - } - } - function onError(error, request) { - d.errback(error); - } - store.fetch({query:{q:"m"}, start: 5, count: 5, onBegin: onBegin, onComplete: onComplete, onError: onError}); - return d; //Object - }, - - function testReadApi_fetch_onBegin_ClientsidePaging(t){ - // summary: - // Simple test of fetching items, checking that onBegin size is all items matched, and page is just the items asked for. - // description: - // Simple test of fetching items, checking that onBegin size is all items matched, and page is just the items asked for. - var store = dojox.data.tests.stores.QueryReadStore.getStore(); - store.doClientPaging = true; - - var d = new doh.Deferred(); - var passed = false; - function onBegin(size, request){ - t.assertEqual(8, size); - passed = true; - } - function onComplete(items, request) { - t.assertEqual(5, items.length); - if(passed){ - d.callback(true); - }else{ - d.errback(new Error("Store did not return proper number of rows, regardless of page size")); - } - } - function onError(error, request) { - d.errback(error); - } - store.fetch({query:{q:"m"}, start: 0, count: 5, onBegin: onBegin, onComplete: onComplete, onError: onError}); - return d; //Object - }, - - function testReadApi_fetch_one(t){ - // summary: - // description: - var store = dojox.data.tests.stores.QueryReadStore.getStore(); - - var d = new doh.Deferred(); - function onComplete(items, request){ - t.assertEqual(1, items.length); - d.callback(true); - } - function onError(error, request) { - d.errback(error); - } - store.fetch({query:{q:"Alaska"}, onComplete: onComplete, onError: onError}); - return d; //Object - }, - - function testReadApi_fetch_client_paging(t){ - // summary: - // Lets test that paging on the same request does not trigger - // server requests. - // description: - var store = dojox.data.tests.stores.QueryReadStore.getStore(); - store.doClientPaging = true; - - var lastRequestHash = null; - var firstItems = []; - var d = new doh.Deferred(); - function onComplete(items, request) { - t.assertEqual(5, items.length); - lastRequestHash = store.lastRequestHash; - firstItems = items; - - // Do the next request AFTER the previous one, so we are sure its sequential. - // We need to be sure so we can compare to the data from the first request. - function onComplete1(items, request) { - t.assertEqual(5, items.length); - t.assertEqual(lastRequestHash, store.lastRequestHash); - t.assertEqual(firstItems[1], items[0]); - d.callback(true); - } - req.start = 1; - req.onComplete = onComplete1; - store.fetch(req); - } - function onError(error, request) { - d.errback(error); - } - var req = {query:{q:"m"}, start:0, count:5, - onComplete: onComplete, onError: onError}; - store.fetch(req); - return d; //Object - }, - - function testReadApi_fetch_server_paging(t) { - // Verify that the paging on the server side does work. - // This is the test for http://trac.dojotoolkit.org/ticket/4761 - // - // How? We request 10 items from the server, start=0, count=10. - // The second request requests 5 items: start=5, count=5 and those - // 5 items should have the same values as the last 5 of the first - // request. - // This tests if the server side paging does work. - var store = dojox.data.tests.stores.QueryReadStore.getStore(); - - var lastRequestHash = null; - var d = new doh.Deferred(); - function onComplete(items, request) { - t.assertEqual(10, items.length); - lastRequestHash = store.lastRequestHash; - firstItems = items; - - // Do the next request AFTER the previous one, so we are sure its sequential. - // We need to be sure so we can compare to the data from the first request. - function onComplete1(items, request) { - t.assertEqual(5, items.length); - // Compare the hash of the last request, they must be different, - // since another server request was issued. - t.assertTrue(lastRequestHash!=store.lastRequestHash); - t.assertEqual(store.getValue(firstItems[5], "name"), store.getValue(items[0], "name")); - t.assertEqual(store.getValue(firstItems[6], "name"), store.getValue(items[1], "name")); - t.assertEqual(store.getValue(firstItems[7], "name"), store.getValue(items[2], "name")); - t.assertEqual(store.getValue(firstItems[8], "name"), store.getValue(items[3], "name")); - t.assertEqual(store.getValue(firstItems[9], "name"), store.getValue(items[4], "name")); - d.callback(true); - } - // Init a new store, or it will use the old data, since the query has not changed. - store.doClientPaging = false; - store.fetch({start:5, count:5, onComplete: onComplete1, onError: onError}); - } - function onError(error, request) { - d.errback(error); - } - store.fetch({query:{}, start:0, count:10, onComplete: onComplete, onError: onError}); - return d; //Object - }, - - function testReadApi_getFeatures(t) { - var store = dojox.data.tests.stores.QueryReadStore.getStore(); - var features = store.getFeatures(); - t.assertTrue(features["dojo.data.api.Read"]); - t.assertTrue(features["dojo.data.api.Identity"]); - var count = 0; - for (i in features){ - count++; - } - t.assertEqual(2, count); - }, - function testReadAPI_functionConformance(t){ - // summary: - // Simple test read API conformance. Checks to see all declared functions are actual functions on the instances. - // description: - // Simple test read API conformance. Checks to see all declared functions are actual functions on the instances. - - var testStore = dojox.data.tests.stores.QueryReadStore.getStore(); - var readApi = new dojo.data.api.Read(); - var passed = true; - - for(i in readApi){ - var member = readApi[i]; - //Check that all the 'Read' defined functions exist on the test store. - if(typeof member === "function"){ - var testStoreMember = testStore[i]; - if(!(typeof testStoreMember === "function")){ - console.log("Problem with function: [" + i + "]"); - passed = false; - break; - } - } - } - t.assertTrue(passed); - } - ] -); - -} diff --git a/includes/js/dojox/data/tests/stores/QueryReadStore.php b/includes/js/dojox/data/tests/stores/QueryReadStore.php deleted file mode 100644 index 26fbcde..0000000 --- a/includes/js/dojox/data/tests/stores/QueryReadStore.php +++ /dev/null @@ -1,114 +0,0 @@ -0, 'name'=>"Alabama", 'label'=>"Alabama", 'abbreviation'=>"AL", 'capital'=>'Montgomery'), - array('id'=>1, 'name'=>"Alaska", 'label'=>"Alaska", 'abbreviation'=>"AK", 'capital'=>'Juneau'), - //array('id'=>2, 'name'=>"American Samoa", 'label'=>"American Samoa", 'abbreviation'=>"AS", 'capital'=>''), - array('id'=>3, 'name'=>"Arizona", 'label'=>"Arizona", 'abbreviation'=>"AZ", 'capital'=>'Phoenix'), - array('id'=>4, 'name'=>"Arkansas", 'label'=>"Arkansas", 'abbreviation'=>"AR", 'capital'=>'Little Rock'), - //array('id'=>5, 'name'=>"Armed Forces Europe", 'label'=>"Armed Forces Europe", 'abbreviation'=>"AE", 'capital'=>''), - //array('id'=>6, 'name'=>"Armed Forces Pacific", 'label'=>"Armed Forces Pacific", 'abbreviation'=>"AP", 'capital'=>''), - //array('id'=>7, 'name'=>"Armed Forces the Americas", 'label'=>"Armed Forces the Americas", 'abbreviation'=>"AA", 'capital'=>''), - array('id'=>8, 'name'=>"California", 'label'=>"California", 'abbreviation'=>"CA", 'capital'=>'Sacramento'), - array('id'=>9, 'name'=>"Colorado", 'label'=>"Colorado", 'abbreviation'=>"CO", 'capital'=>'Denver'), - array('id'=>10, 'name'=>"Connecticut", 'label'=>"Connecticut", 'abbreviation'=>"CT", 'capital'=>'Hartford'), - array('id'=>11, 'name'=>"Delaware", 'label'=>"Delaware", 'abbreviation'=>"DE", 'capital'=>'Dover'), - //array('id'=>12, 'name'=>"District of Columbia", 'label'=>"District of Columbia", 'abbreviation'=>"DC", 'capital'=>''), - //array('id'=>13, 'name'=>"Federated States of Micronesia", 'label'=>"Federated States of Micronesia", 'abbreviation'=>"FM", 'capital'=>''), - array('id'=>14, 'name'=>"Florida", 'label'=>"Florida", 'abbreviation'=>"FL", 'capital'=>'Tallahassee'), - array('id'=>15, 'name'=>"Georgia", 'label'=>"Georgia", 'abbreviation'=>"GA", 'capital'=>'Atlanta'), - //array('id'=>16, 'name'=>"Guam", 'label'=>"Guam", 'abbreviation'=>"GU", 'capital'=>''), - array('id'=>17, 'name'=>"Hawaii", 'label'=>"Hawaii", 'abbreviation'=>"HI", 'capital'=>'Honolulu'), - array('id'=>18, 'name'=>"Idaho", 'label'=>"Idaho", 'abbreviation'=>"ID", 'capital'=>'Boise'), - array('id'=>19, 'name'=>"Illinois", 'label'=>"Illinois", 'abbreviation'=>"IL", 'capital'=>'Springfield'), - array('id'=>20, 'name'=>"Indiana", 'label'=>"Indiana", 'abbreviation'=>"IN", 'capital'=>'Indianapolis'), - array('id'=>21, 'name'=>"Iowa", 'label'=>"Iowa", 'abbreviation'=>"IA", 'capital'=>'Des Moines'), - array('id'=>22, 'name'=>"Kansas", 'label'=>"Kansas", 'abbreviation'=>"KS", 'capital'=>'Topeka'), - array('id'=>23, 'name'=>"Kentucky", 'label'=>"Kentucky", 'abbreviation'=>"KY", 'capital'=>'Frankfort'), - array('id'=>24, 'name'=>"Louisiana", 'label'=>"Louisiana", 'abbreviation'=>"LA", 'capital'=>'Baton Rouge'), - array('id'=>25, 'name'=>"Maine", 'label'=>"Maine", 'abbreviation'=>"ME", 'capital'=>'Augusta'), - //array('id'=>26, 'name'=>"Marshall Islands", 'label'=>"Marshall Islands", 'abbreviation'=>"MH", 'capital'=>''), - array('id'=>27, 'name'=>"Maryland", 'label'=>"Maryland", 'abbreviation'=>"MD", 'capital'=>'Annapolis'), - array('id'=>28, 'name'=>"Massachusetts", 'label'=>"Massachusetts", 'abbreviation'=>"MA", 'capital'=>'Boston'), - array('id'=>29, 'name'=>"Michigan", 'label'=>"Michigan", 'abbreviation'=>"MI", 'capital'=>'Lansing'), - array('id'=>30, 'name'=>"Minnesota", 'label'=>"Minnesota", 'abbreviation'=>"MN", 'capital'=>'Saint Paul'), - array('id'=>31, 'name'=>"Mississippi", 'label'=>"Mississippi", 'abbreviation'=>"MS", 'capital'=>'Jackson'), - array('id'=>32, 'name'=>"Missouri", 'label'=>"Missouri", 'abbreviation'=>"MO", 'capital'=>'Jefferson City'), - array('id'=>33, 'name'=>"Montana", 'label'=>"Montana", 'abbreviation'=>"MT", 'capital'=>'Helena'), - array('id'=>34, 'name'=>"Nebraska", 'label'=>"Nebraska", 'abbreviation'=>"NE", 'capital'=>'Lincoln'), - array('id'=>35, 'name'=>"Nevada", 'label'=>"Nevada", 'abbreviation'=>"NV", 'capital'=>'Carson City'), - array('id'=>36, 'name'=>"New Hampshire", 'label'=>"New Hampshire", 'abbreviation'=>"NH", 'capital'=>'Concord'), - array('id'=>37, 'name'=>"New Jersey", 'label'=>"New Jersey", 'abbreviation'=>"NJ", 'capital'=>'Trenton'), - array('id'=>38, 'name'=>"New Mexico", 'label'=>"New Mexico", 'abbreviation'=>"NM", 'capital'=>'Santa Fe'), - array('id'=>39, 'name'=>"New York", 'label'=>"New York", 'abbreviation'=>"NY", 'capital'=>'Albany'), - array('id'=>40, 'name'=>"North Carolina", 'label'=>"North Carolina", 'abbreviation'=>"NC", 'capital'=>'Raleigh'), - array('id'=>41, 'name'=>"North Dakota", 'label'=>"North Dakota", 'abbreviation'=>"ND", 'capital'=>'Bismarck'), - //array('id'=>42, 'name'=>"Northern Mariana Islands", 'label'=>"Northern Mariana Islands", 'abbreviation'=>"MP", 'capital'=>''), - array('id'=>43, 'name'=>"Ohio", 'label'=>"Ohio", 'abbreviation'=>"OH", 'capital'=>'Columbus'), - array('id'=>44, 'name'=>"Oklahoma", 'label'=>"Oklahoma", 'abbreviation'=>"OK", 'capital'=>'Oklahoma City'), - array('id'=>45, 'name'=>"Oregon", 'label'=>"Oregon", 'abbreviation'=>"OR", 'capital'=>'Salem'), - array('id'=>46, 'name'=>"Pennsylvania", 'label'=>"Pennsylvania", 'abbreviation'=>"PA", 'capital'=>'Harrisburg'), - //array('id'=>47, 'name'=>"Puerto Rico", 'label'=>"Puerto Rico", 'abbreviation'=>"PR", 'capital'=>''), - array('id'=>48, 'name'=>"Rhode Island", 'label'=>"Rhode Island", 'abbreviation'=>"RI", 'capital'=>'Providence'), - array('id'=>49, 'name'=>"South Carolina", 'label'=>"South Carolina", 'abbreviation'=>"SC", 'capital'=>'Columbia'), - array('id'=>50, 'name'=>"South Dakota", 'label'=>"South Dakota", 'abbreviation'=>"SD", 'capital'=>'Pierre'), - array('id'=>51, 'name'=>"Tennessee", 'label'=>"Tennessee", 'abbreviation'=>"TN", 'capital'=>'Nashville'), - array('id'=>52, 'name'=>"Texas", 'label'=>"Texas", 'abbreviation'=>"TX", 'capital'=>'Austin'), - array('id'=>53, 'name'=>"Utah", 'label'=>"Utah", 'abbreviation'=>"UT", 'capital'=>'Salt Lake City'), - array('id'=>54, 'name'=>"Vermont", 'label'=>"Vermont", 'abbreviation'=>"VT", 'capital'=>'Montpelier'), - //array('id'=>55, 'name'=> "Virgin Islands, U.S.", 'label'=>"Virgin Islands, U.S.", 'abbreviation'=>"VI", 'capital'=>''), - array('id'=>56, 'name'=>"Virginia", 'label'=>"Virginia", 'abbreviation'=>"VA", 'capital'=>'Richmond'), - array('id'=>57, 'name'=>"Washington", 'label'=>"Washington", 'abbreviation'=>"WA", 'capital'=>'Olympia'), - array('id'=>58, 'name'=>"West Virginia", 'label'=>"West Virginia", 'abbreviation'=>"WV", 'capital'=>'Charleston'), - array('id'=>59, 'name'=>"Wisconsin", 'label'=>"Wisconsin", 'abbreviation'=>"WI", 'capital'=>'Madison'), - array('id'=>60, 'name'=>"Wyoming", 'label'=>"Wyoming", 'abbreviation'=>"WY", 'capital'=>'Cheyenne'), -); - -$q = ""; -if (array_key_exists("q", $_REQUEST)) { - $q = $_REQUEST['q']; -}else if (array_key_exists("name", $_REQUEST)) { - $q = $_REQUEST['name']; -} - -if (strlen($q) && $q[strlen($q)-1]=="*") { - $q = substr($q, 0, strlen($q)-1); -} -$ret = array(); -foreach ($allItems as $item) { - if (!$q || strpos(strtolower($item['name']), strtolower($q))===0) { - $ret[] = $item; - } -} - -// Handle sorting -if (array_key_exists("sort", $_REQUEST)) { - $sort = $_REQUEST['sort']; - // Check if $sort starts with "-" then we have a DESC sort. - $desc = strpos($sort, '-')===0 ? true : false; - $sort = strpos($sort, '-')===0 ? substr($sort, 1) : $sort; - if (in_array($sort, array_keys($ret[0]))) { - $toSort = array(); - foreach ($ret as $i) $toSort[$i[$sort]] = $i; - if ($desc) krsort($toSort); else ksort($toSort); - $newRet = array(); - foreach ($toSort as $i) $newRet[] = $i; - $ret = $newRet; - } -} - - -// Handle total number of matches as a return, regardless of page size, but taking the filtering into account (if taken place). -$numRows = count($ret); - -// Handle paging, if given. -if (array_key_exists("start", $_REQUEST)) { - $ret = array_slice($ret, $_REQUEST['start']); -} -if (array_key_exists("count", $_REQUEST)) { - $ret = array_slice($ret, 0, $_REQUEST['count']); -} - -print '/*'.json_encode(array('numRows'=>$numRows, 'items'=>$ret, 'identity'=>'id')).'*/'; diff --git a/includes/js/dojox/data/tests/stores/SnapLogicStore.js b/includes/js/dojox/data/tests/stores/SnapLogicStore.js deleted file mode 100644 index d544799..0000000 --- a/includes/js/dojox/data/tests/stores/SnapLogicStore.js +++ /dev/null @@ -1,438 +0,0 @@ -if(!dojo._hasResource["dojox.data.tests.stores.SnapLogicStore"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. -dojo._hasResource["dojox.data.tests.stores.SnapLogicStore"] = true; -dojo.provide("dojox.data.tests.stores.SnapLogicStore"); -dojo.require("dojox.data.SnapLogicStore"); -dojo.require("dojo.data.api.Read"); - -dojox.data.tests.stores.SnapLogicStore.pipelineUrl = dojo.moduleUrl("dojox.data.tests", "stores/snap_pipeline.php").toString(); -dojox.data.tests.stores.SnapLogicStore.pipelineSize = 14; -dojox.data.tests.stores.SnapLogicStore.attributes = ["empno", "ename", "job", "hiredate", "sal", "comm", "deptno"]; - -dojox.data.tests.stores.SnapLogicStore.error = function(t, d, errData){ - // summary: - // The error callback function to be used for all of the tests. - d.errback(errData); -} - -doh.register("dojox.data.tests.stores.SnapLogicStore", - [ - { - name: "ReadAPI: Fetch One", - timeout: 3000, //3 seconds. - runTest: function(t) { - // summary: - // Simple test of a basic fetch from a SnapLogic pipeline - // description: - // Simple test of a basic fetch from a SnapLogic pipeline - - var store = new dojox.data.SnapLogicStore({url: dojox.data.tests.stores.SnapLogicStore.pipelineUrl}); - - var d = new doh.Deferred(); - function onComplete(items, request){ - t.assertEqual(1, items.length); - d.callback(true); - } - store.fetch({ count: 1, - onComplete: onComplete, - onError: dojo.partial(dojox.data.tests.stores.SnapLogicStore.error, doh, d) - }); - return d; //Object - } - }, - { - name: "ReadAPI: Fetch_10_Streaming", - timeout: 3000, //3 seconds. - runTest: function(t) { - // summary: - // Simple test of a basic fetch on SnapLogic pipeline. - // description: - // Simple test of a basic fetch on SnapLogic pipeline. - - var store = new dojox.data.SnapLogicStore({url: dojox.data.tests.stores.SnapLogicStore.pipelineUrl}); - - var d = new doh.Deferred(); - count = 0; - - function onBegin(size, requestObj){ - t.assertEqual(dojox.data.tests.stores.SnapLogicStore.pipelineSize, size); - } - function onItem(item, requestObj){ - t.assertTrue(store.isItem(item)); - count++; - } - function onComplete(items, request){ - t.assertEqual(10, count); - t.assertTrue(items === null); - d.callback(true); - } - - //Get everything... - store.fetch({ onBegin: onBegin, - count: 10, - onItem: onItem, - onComplete: onComplete, - onError: dojo.partial(dojox.data.tests.stores.SnapLogicStore.error, t, d) - }); - return d; //Object - } - }, - { - name: "ReadAPI: Fetch Zero", - timeout: 3000, //3 seconds. - runTest: function(t) { - // summary: - // Try fetching 0 records. A count of the items in the pipeline should be returned. - // description: - // Try fetching 0 records. A count of the items in the pipeline should be returned. - - var store = new dojox.data.SnapLogicStore({url: dojox.data.tests.stores.SnapLogicStore.pipelineUrl}); - - var d = new doh.Deferred(); - function onBegin(count, request){ - t.assertEqual(dojox.data.tests.stores.SnapLogicStore.pipelineSize, count); - d.callback(true); - } - store.fetch({ count: 0, - onBegin: onBegin, - onError: dojo.partial(dojox.data.tests.stores.SnapLogicStore.error, doh, d) - }); - return d; //Object - } - }, - { - name: "ReadAPI: Fetch_Paging", - timeout: 3000, //3 seconds. - runTest: function(t) { - // summary: - // Test of multiple fetches on a single result. Paging, if you will. - // description: - // Test of multiple fetches on a single result. Paging, if you will. - - var store = new dojox.data.SnapLogicStore({url: dojox.data.tests.stores.SnapLogicStore.pipelineUrl}); - - var d = new doh.Deferred(); - function dumpFirstFetch(items, request){ - t.assertEqual(request.count, items.length); - request.start = dojox.data.tests.stores.SnapLogicStore.pipelineSize / 3; - request.count = 1; - request.onComplete = dumpSecondFetch; - store.fetch(request); - } - - function dumpSecondFetch(items, request){ - t.assertEqual(1, items.length); - request.start = 0; - request.count = dojox.data.tests.stores.SnapLogicStore.pipelineSize / 2; - request.onComplete = dumpThirdFetch; - store.fetch(request); - } - - function dumpThirdFetch(items, request){ - t.assertEqual(request.count, items.length); - request.count = dojox.data.tests.stores.SnapLogicStore.pipelineSize * 2; - request.onComplete = dumpFourthFetch; - store.fetch(request); - } - - function dumpFourthFetch(items, request){ - t.assertEqual(dojox.data.tests.stores.SnapLogicStore.pipelineSize, items.length); - request.start = Math.floor(3 * dojox.data.tests.stores.SnapLogicStore.pipelineSize / 4); - request.count = dojox.data.tests.stores.SnapLogicStore.pipelineSize; - request.onComplete = dumpFifthFetch; - store.fetch(request); - } - - function dumpFifthFetch(items, request){ - t.assertEqual(dojox.data.tests.stores.SnapLogicStore.pipelineSize - request.start, items.length); - request.start = 2; - request.count = dojox.data.tests.stores.SnapLogicStore.pipelineSize * 10; - request.onComplete = dumpSixthFetch; - store.fetch(request); - } - - function dumpSixthFetch(items, request){ - t.assertEqual(dojox.data.tests.stores.SnapLogicStore.pipelineSize - request.start, items.length); - d.callback(true); - } - - store.fetch({ count: 5, - onComplete: dumpFirstFetch, - onError: dojo.partial(dojox.data.tests.stores.SnapLogicStore.error, t, d)}); - return d; //Object - } - }, - { - name: "ReadAPI: getLabel", - timeout: 3000, //3 seconds - runTest: function(t) { - // summary: - // Test that the label function returns undefined since it's not supported. - // description: - // Test that the label function returns undefined since it's not supported. - - var store = new dojox.data.SnapLogicStore({url: dojox.data.tests.stores.SnapLogicStore.pipelineUrl}); - - var d = new doh.Deferred(); - function onComplete(items, request){ - t.assertEqual(items.length, 1); - var label = store.getLabel(items[0]); - t.assertTrue(label === undefined); - d.callback(true); - } - store.fetch({ count: 1, - onComplete: onComplete, - onError: dojo.partial(dojox.data.tests.stores.SnapLogicStore.error, t, d) - }); - return d; - } - }, - { - name: "ReadAPI: getLabelAttributes", - timeout: 3000, //3 seconds. - runTest: function(t) { - // summary: - // Simple test of the getLabelAttributes returns null since it's not supported. - // description: - // Simple test of the getLabelAttributes returns null since it's not supported. - - var store = new dojox.data.SnapLogicStore({url: dojox.data.tests.stores.SnapLogicStore.pipelineUrl}); - - var d = new doh.Deferred(); - function onComplete(items, request){ - t.assertEqual(items.length, 1); - var labelList = store.getLabelAttributes(items[0]); - t.assertTrue(labelList === null); - d.callback(true); - } - store.fetch({ count: 1, - onComplete: onComplete, - onError: dojo.partial(dojox.data.tests.stores.SnapLogicStore.error, t, d) - }); - return d; - } - }, - { - name: "ReadAPI: getValue", - timeout: 3000, //3 seconds. - runTest: function(t) { - // summary: - // Simple test of the getValue function of the store. - // description: - // Simple test of the getValue function of the store. - var store = new dojox.data.SnapLogicStore({url: dojox.data.tests.stores.SnapLogicStore.pipelineUrl}); - - var d = new doh.Deferred(); - function completedAll(items){ - t.assertEqual(1, items.length); - console.debug(items[0]); - t.assertTrue(store.getValue(items[0], "empno") === 7369); - t.assertTrue(store.getValue(items[0], "ename") === "SMITH,CLERK"); - console.debug(store.getValue(items[0], "sal")); - t.assertTrue(store.getValue(items[0], "sal") == 800.00); - console.debug(1); - t.assertTrue(store.getValue(items[0], "deptno") === 20); - d.callback(true); - } - - store.fetch({ count: 1, - onComplete: completedAll, - onError: dojo.partial(dojox.data.tests.stores.SnapLogicStore.error, t, d)}); - return d; - } - }, - { - name: "ReadAPI: getValues", - timeout: 3000, //3 seconds. - runTest: function(t) { - // summary: - // Simple test of the getValue function of the store. - // description: - // Simple test of the getValue function of the store. - var store = new dojox.data.SnapLogicStore({url: dojox.data.tests.stores.SnapLogicStore.pipelineUrl}); - - var d = new doh.Deferred(); - function completedAll(items){ - t.assertEqual(1, items.length); - for(var i = 0; i < dojox.data.tests.stores.SnapLogicStore.attributes.length; ++i){ - var values = store.getValues(items[0], dojox.data.tests.stores.SnapLogicStore.attributes[i]); - t.assertTrue(dojo.isArray(values)); - t.assertTrue(values[0] === store.getValue(items[0], dojox.data.tests.stores.SnapLogicStore.attributes[i])); - } - d.callback(true); - } - - store.fetch({ count: 1, - onComplete: completedAll, - onError: dojo.partial(dojox.data.tests.stores.SnapLogicStore.error, t, d)}); - return d; - } - }, - { - name: "ReadAPI: isItem", - timeout: 3000, //3 seconds. - runTest: function(t) { - // summary: - // Simple test of the isItem function of the store - // description: - // Simple test of the isItem function of the store - var store = new dojox.data.SnapLogicStore({url: dojox.data.tests.stores.SnapLogicStore.pipelineUrl}); - - var d = new doh.Deferred(); - function completedAll(items){ - t.assertEqual(5, items.length); - for(var i=0; i < items.length; i++){ - t.assertTrue(store.isItem(items[i])); - } - d.callback(true); - } - - //Get everything... - store.fetch({ count: 5, - onComplete: completedAll, - onError: dojo.partial(dojox.data.tests.stores.SnapLogicStore.error, t, d)}); - return d; //Object - } - }, - { - name: "ReadAPI: hasAttribute", - timeout: 3000, //3 seconds. - runTest: function(t) { - // summary: - // Simple test of the hasAttribute function of the store - // description: - // Simple test of the hasAttribute function of the store - - var store = new dojox.data.SnapLogicStore({url: dojox.data.tests.stores.SnapLogicStore.pipelineUrl}); - - var d = new doh.Deferred(); - function onComplete(items){ - t.assertEqual(1, items.length); - t.assertTrue(items[0] !== null); - for(var i = 0; i < dojox.data.tests.stores.SnapLogicStore.attributes.length; ++i){ - t.assertTrue(store.hasAttribute(items[0], dojox.data.tests.stores.SnapLogicStore.attributes[i])); - } - t.assertTrue(!store.hasAttribute(items[0], "Nothing")); - t.assertTrue(!store.hasAttribute(items[0], "Text")); - - //Test that null attributes throw an exception - var passed = false; - try{ - store.hasAttribute(items[0], null); - }catch (e){ - passed = true; - } - t.assertTrue(passed); - d.callback(true); - } - - //Get one item... - store.fetch({ count: 1, - onComplete: onComplete, - onError: dojo.partial(dojox.data.tests.stores.SnapLogicStore.error, t, d) - }); - return d; //Object - } - }, - { - name: "ReadAPI: containsValue", - timeout: 3000, //3 seconds. - runTest: function(t) { - // summary: - // Simple test of the containsValue function of the store - // description: - // Simple test of the containsValue function of the store - - var store = new dojox.data.SnapLogicStore({url: dojox.data.tests.stores.SnapLogicStore.pipelineUrl}); - - var d = new doh.Deferred(); - function onComplete(items){ - t.assertEqual(1, items.length); - var value = store.getValue(items[0], "LastName"); - t.assertTrue(store.containsValue(items[0], "LastName", value)); - d.callback(true); - } - - //Get one item... - store.fetch({ count: 1, - onComplete: onComplete, - onError: dojo.partial(dojox.data.tests.stores.SnapLogicStore.error, t, d) - }); - return d; //Object - } - }, - { - name: "ReadAPI: getAttributes", - timeout: 3000, //3 seconds. - runTest: function(t) { - // summary: - // Simple test of the getAttributes function of the store - // description: - // Simple test of the getAttributes function of the store - - var store = new dojox.data.SnapLogicStore({url: dojox.data.tests.stores.SnapLogicStore.pipelineUrl}); - - var d = new doh.Deferred(); - function onComplete(items){ - t.assertEqual(1, items.length); - - var itemAttributes = store.getAttributes(items[0]); - t.assertEqual(dojox.data.tests.stores.SnapLogicStore.attributes.length, itemAttributes.length); - for(var i = 0; i < dojox.data.tests.stores.SnapLogicStore.attributes.length; ++i){ - t.assertTrue(dojo.indexOf(itemAttributes, dojox.data.tests.stores.SnapLogicStore.attributes[i]) !== -1); - } - d.callback(true); - } - - //Get everything... - store.fetch({ count: 1, - onComplete: onComplete, - onError: dojo.partial(dojox.data.tests.stores.SnapLogicStore.error, t, d)}); - return d; //Object - } - }, - function testReadAPI_getFeatures(t){ - // summary: - // Simple test of the getFeatures function of the store - // description: - // Simple test of the getFeatures function of the store - - var store = new dojox.data.SnapLogicStore({url: dojox.data.tests.stores.SnapLogicStore.pipelineUrl}); - - var features = store.getFeatures(); - var count = 0; - for(var i in features){ - t.assertEqual(i, "dojo.data.api.Read"); - count++; - } - - t.assertEqual(count, 1); - }, - function testReadAPI_functionConformance(t){ - // summary: - // Simple test read API conformance. Checks to see all declared functions are actual functions on the instances. - // description: - // Simple test read API conformance. Checks to see all declared functions are actual functions on the instances. - - var testStore = new dojox.data.SnapLogicStore({url: dojox.data.tests.stores.SnapLogicStore.pipelineUrl}); - var readApi = new dojo.data.api.Read(); - var passed = true; - - for(var i in readApi){ - if(i.toString().charAt(0) !== '_'){ - var member = readApi[i]; - //Check that all the 'Read' defined functions exist on the test store. - if(typeof member === "function"){ - var testStoreMember = testStore[i]; - if(!(typeof testStoreMember === "function")){ - passed = false; - break; - } - } - } - } - t.assertTrue(passed); - } - ] -); - -} diff --git a/includes/js/dojox/data/tests/stores/XmlStore.js b/includes/js/dojox/data/tests/stores/XmlStore.js deleted file mode 100644 index 0c99732..0000000 --- a/includes/js/dojox/data/tests/stores/XmlStore.js +++ /dev/null @@ -1,881 +0,0 @@ -if(!dojo._hasResource["dojox.data.tests.stores.XmlStore"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. -dojo._hasResource["dojox.data.tests.stores.XmlStore"] = true; -dojo.provide("dojox.data.tests.stores.XmlStore"); -dojo.require("dojox.data.XmlStore"); -dojo.require("dojo.data.api.Read"); -dojo.require("dojo.data.api.Write"); - - -dojox.data.tests.stores.XmlStore.getBooks2Store = function(){ - return new dojox.data.XmlStore({url: dojo.moduleUrl("dojox.data.tests", "stores/books2.xml").toString(), label: "title"}); -}; - -dojox.data.tests.stores.XmlStore.getBooksStore = function(){ - return new dojox.data.XmlStore({url: dojo.moduleUrl("dojox.data.tests", "stores/books.xml").toString(), label: "title"}); -}; - -doh.register("dojox.data.tests.stores.XmlStore", - [ - function testReadAPI_fetch_all(t){ - // summary: - // Simple test of fetching all xml items through an XML element called isbn - // description: - // Simple test of fetching all xml items through an XML element called isbn - var store = dojox.data.tests.stores.XmlStore.getBooksStore(); - - var d = new doh.Deferred(); - function onComplete(items, request) { - t.assertEqual(20, items.length); - d.callback(true); - } - function onError(error, request) { - d.errback(error); - } - store.fetch({query:{isbn:"*"}, onComplete: onComplete, onError: onError}); - return d; //Object - }, - function testReadAPI_fetch_one(t){ - // summary: - // Simple test of fetching one xml items through an XML element called isbn - // description: - // Simple test of fetching one xml items through an XML element called isbn - var store = dojox.data.tests.stores.XmlStore.getBooks2Store(); - - var d = new doh.Deferred(); - function onComplete(items, request) { - t.assertEqual(1, items.length); - d.callback(true); - } - function onError(error, request) { - d.errback(error); - } - store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError}); - return d; //Object - }, - { - name: "testReadAPI_fetch_paging", - timeout: 10000, - runTest: function(t){ - // summary: - // Simple test of fetching one xml items through an XML element called isbn - // description: - // Simple test of fetching one xml items through an XML element called isbn - var store = dojox.data.tests.stores.XmlStore.getBooksStore(); - var d = new doh.Deferred(); - function dumpFirstFetch(items, request){ - t.assertEqual(5, items.length); - request.start = 3; - request.count = 1; - request.onComplete = dumpSecondFetch; - store.fetch(request); - } - - function dumpSecondFetch(items, request){ - t.assertEqual(1, items.length); - request.start = 0; - request.count = 5; - request.onComplete = dumpThirdFetch; - store.fetch(request); - } - - function dumpThirdFetch(items, request){ - t.assertEqual(5, items.length); - request.start = 2; - request.count = 20; - request.onComplete = dumpFourthFetch; - store.fetch(request); - } - - function dumpFourthFetch(items, request){ - t.assertEqual(18, items.length); - request.start = 9; - request.count = 100; - request.onComplete = dumpFifthFetch; - store.fetch(request); - } - - function dumpFifthFetch(items, request){ - t.assertEqual(11, items.length); - request.start = 2; - request.count = 20; - request.onComplete = dumpSixthFetch; - store.fetch(request); - } - - function dumpSixthFetch(items, request){ - t.assertEqual(18, items.length); - d.callback(true); - } - - function completed(items, request){ - t.assertEqual(20, items.length); - request.start = 1; - request.count = 5; - request.onComplete = dumpFirstFetch; - store.fetch(request); - } - - function error(errData, request){ - d.errback(errData); - } - - store.fetch({onComplete: completed, onError: error}); - return d; //Object - } - }, - function testReadAPI_fetch_pattern0(t){ - // summary: - // Simple test of fetching one xml items through an XML element called isbn with ? pattern match - // description: - // Simple test of fetching one xml items through an XML element called isbn with ? pattern match - var store = dojox.data.tests.stores.XmlStore.getBooks2Store(); - var d = new doh.Deferred(); - function onComplete(items, request) { - t.assertEqual(1, items.length); - d.callback(true); - } - function onError(error, request) { - d.errback(error); - } - store.fetch({query:{isbn:"?9B574"}, onComplete: onComplete, onError: onError}); - return d; //Object - }, - function testReadAPI_fetch_pattern1(t){ - // summary: - // Simple test of fetching one xml items through an XML element called isbn with ? pattern match - // description: - // Simple test of fetching one xml items through an XML element called isbn with ? pattern match - var store = dojox.data.tests.stores.XmlStore.getBooks2Store(); - var d = new doh.Deferred(); - function onComplete(items, request) { - t.assertEqual(4, items.length); - d.callback(true); - } - function onError(error, request) { - d.errback(error); - } - store.fetch({query:{isbn:"A9B57?"}, onComplete: onComplete, onError: onError}); - return d; //Object - }, - function testReadAPI_fetch_pattern2(t){ - // summary: - // Simple test of fetching one xml items through an XML element called isbn with * pattern match - // description: - // Simple test of fetching one xml items through an XML element called isbn with * pattern match - var store = dojox.data.tests.stores.XmlStore.getBooks2Store(); - var d = new doh.Deferred(); - function onComplete(items, request) { - t.assertEqual(5, items.length); - d.callback(true); - } - function onError(error, request) { - d.errback(error); - } - store.fetch({query:{isbn:"A9*"}, onComplete: onComplete, onError: onError}); - return d; //Object - }, - function testReadAPI_fetch_pattern_caseInsensitive(t){ - // summary: - // Simple test of fetching one xml items through an XML element called isbn with ? pattern match and in case insensitive mode. - // description: - // Simple test of fetching one xml items through an XML element called isbn with ? pattern match and in case insensitive mode. - var store = dojox.data.tests.stores.XmlStore.getBooks2Store(); - var d = new doh.Deferred(); - function onComplete(items, request) { - t.assertEqual(1, items.length); - d.callback(true); - } - function onError(error, request) { - d.errback(error); - } - store.fetch({query:{isbn:"?9b574"}, queryOptions: {ignoreCase: true}, onComplete: onComplete, onError: onError}); - return d; //Object - }, - function testReadAPI_fetch_pattern_caseSensitive(t){ - // summary: - // Simple test of fetching one xml items through an XML element called isbn with ? pattern match and in case sensitive mode. - // description: - // Simple test of fetching one xml items through an XML element called isbn with ? pattern match and in case sensitive mode. - var store = dojox.data.tests.stores.XmlStore.getBooks2Store(); - var d = new doh.Deferred(); - function onComplete(items, request) { - t.assertEqual(1, items.length); - d.callback(true); - } - function onError(error, request) { - d.errback(error); - } - store.fetch({query:{isbn:"?9B574"}, queryOptions: {ignoreCase: false}, onComplete: onComplete, onError: onError}); - return d; //Object - }, - function testReadAPI_fetch_all_rootItem(t){ - // summary: - // Simple test of fetching all xml items through an XML element called isbn - // description: - // Simple test of fetching all xml items through an XML element called isbn - var store = new dojox.data.XmlStore({url: dojo.moduleUrl("dojox.data.tests", "stores/books3.xml").toString(), - rootItem:"book"}); - - var d = new doh.Deferred(); - function onComplete(items, request) { - t.assertEqual(5, items.length); - d.callback(true); - } - function onError(error, request) { - d.errback(error); - } - store.fetch({query:{isbn:"*"}, onComplete: onComplete, onError: onError}); - return d; //Object - }, - function testReadAPI_fetch_withAttrMap_all(t){ - var store = new dojox.data.XmlStore({url: dojo.moduleUrl("dojox.data.tests", "stores/books_isbnAttr.xml").toString(), - attributeMap: {"book.isbn": "@isbn"}}); - - var d = new doh.Deferred(); - function onComplete(items, request) { - t.assertEqual(5, items.length); - d.callback(true); - } - function onError(error, request) { - console.debug(error); - d.errback(error); - } - store.fetch({query:{isbn:"*"}, onComplete: onComplete, onError: onError}); - return d; //Object - }, - function testReadAPI_fetch_withAttrMap_one(t){ - var store = new dojox.data.XmlStore({url: dojo.moduleUrl("dojox.data.tests", "stores/books_isbnAttr.xml").toString(), - attributeMap: {"book.isbn": "@isbn"}}); - - var d = new doh.Deferred(); - function onComplete(items, request) { - t.assertEqual(1, items.length); - d.callback(true); - } - function onError(error, request) { - console.debug(error); - d.errback(error); - } - store.fetch({query:{isbn:"2"}, onComplete: onComplete, onError: onError}); - return d; //Object - }, - function testReadAPI_fetch_withAttrMap_pattern0(t){ - // summary: - // Simple test of fetching one xml items through an XML element called isbn with ? pattern match - // description: - // Simple test of fetching one xml items through an XML element called isbn with ? pattern match - var store = new dojox.data.XmlStore({url: dojo.moduleUrl("dojox.data.tests", "stores/books_isbnAttr2.xml").toString(), - attributeMap: {"book.isbn": "@isbn"}}); - var d = new doh.Deferred(); - function onComplete(items, request) { - t.assertEqual(3, items.length); - d.callback(true); - } - function onError(error, request) { - d.errback(error); - } - store.fetch({query:{isbn:"ABC?"}, onComplete: onComplete, onError: onError}); - return d; //Object - }, - function testReadAPI_fetch_withAttrMap_pattern1(t){ - // summary: - // Simple test of fetching one xml items through an XML element called isbn with ? pattern match - // description: - // Simple test of fetching one xml items through an XML element called isbn with ? pattern match - var store = new dojox.data.XmlStore({url: dojo.moduleUrl("dojox.data.tests", "stores/books_isbnAttr2.xml").toString(), - attributeMap: {"book.isbn": "@isbn"}}); - var d = new doh.Deferred(); - function onComplete(items, request) { - t.assertEqual(5, items.length); - d.callback(true); - } - function onError(error, request) { - d.errback(error); - } - store.fetch({query:{isbn:"A*"}, onComplete: onComplete, onError: onError}); - return d; //Object - }, - function testReadAPI_fetch_withAttrMap_pattern2(t){ - // summary: - // Simple test of fetching one xml items through an XML element called isbn with ? pattern match - // description: - // Simple test of fetching one xml items through an XML element called isbn with ? pattern match - var store = new dojox.data.XmlStore({url: dojo.moduleUrl("dojox.data.tests", "stores/books_isbnAttr2.xml").toString(), - attributeMap: {"book.isbn": "@isbn"}}); - var d = new doh.Deferred(); - function onComplete(items, request) { - t.assertEqual(2, items.length); - d.callback(true); - } - function onError(error, request) { - d.errback(error); - } - store.fetch({query:{isbn:"?C*"}, onComplete: onComplete, onError: onError}); - return d; //Object - }, - - function testReadAPI_getLabel(t){ - // summary: - // Simple test of the getLabel function against a store set that has a label defined. - // description: - // Simple test of the getLabel function against a store set that has a label defined. - - var store = dojox.data.tests.stores.XmlStore.getBooks2Store(); - - var d = new doh.Deferred(); - function onComplete(items, request){ - t.assertEqual(items.length, 1); - var label = store.getLabel(items[0]); - t.assertTrue(label !== null); - t.assertEqual("Title of 4", label); - d.callback(true); - } - function onError(error, request) { - d.errback(error); - } - store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError}); - return d; - }, - function testReadAPI_getLabelAttributes(t){ - // summary: - // Simple test of the getLabelAttributes function against a store set that has a label defined. - // description: - // Simple test of the getLabelAttributes function against a store set that has a label defined. - - var store = dojox.data.tests.stores.XmlStore.getBooks2Store(); - - var d = new doh.Deferred(); - function onComplete(items, request){ - t.assertEqual(items.length, 1); - var labelList = store.getLabelAttributes(items[0]); - t.assertTrue(dojo.isArray(labelList)); - t.assertEqual("title", labelList[0]); - d.callback(true); - } - function onError(error, request) { - d.errback(error); - } - store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError}); - return d; - }, - - function testReadAPI_getValue(t){ - // summary: - // Simple test of the getValue API - // description: - // Simple test of the getValue API - var store = dojox.data.tests.stores.XmlStore.getBooks2Store(); - - var d = new doh.Deferred(); - function onComplete(items, request) { - t.assertEqual(1, items.length); - var item = items[0]; - t.assertTrue(store.hasAttribute(item,"isbn")); - t.assertEqual(store.getValue(item,"isbn"), "A9B574"); - d.callback(true); - } - function onError(error, request) { - d.errback(error); - } - store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError}); - return d; //Object - }, - function testReadAPI_getValues(t){ - // summary: - // Simple test of the getValues API - // description: - // Simple test of the getValues API - var store = dojox.data.tests.stores.XmlStore.getBooks2Store(); - - var d = new doh.Deferred(); - function onComplete(items, request) { - t.assertEqual(1, items.length); - var item = items[0]; - t.assertTrue(store.hasAttribute(item,"isbn")); - var values = store.getValues(item,"isbn"); - t.assertEqual(1,values.length); - t.assertEqual("A9B574", values[0]); - d.callback(true); - } - function onError(error, request) { - d.errback(error); - } - store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError}); - return d; //Object - }, - function testReadAPI_isItem(t){ - // summary: - // Simple test of the isItem API - // description: - // Simple test of the isItem API - var store = dojox.data.tests.stores.XmlStore.getBooks2Store(); - - var d = new doh.Deferred(); - function onComplete(items, request) { - t.assertEqual(1, items.length); - var item = items[0]; - t.assertTrue(store.isItem(item)); - t.assertTrue(!store.isItem({})); - t.assertTrue(!store.isItem("Foo")); - t.assertTrue(!store.isItem(1)); - d.callback(true); - } - function onError(error, request) { - d.errback(error); - } - store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError}); - return d; //Object - }, - function testReadAPI_isItem_multistore(t){ - // summary: - // Simple test of the isItem API across multiple store instances. - // description: - // Simple test of the isItem API across multiple store instances. - var store1 = dojox.data.tests.stores.XmlStore.getBooks2Store(); - var store2 = dojox.data.tests.stores.XmlStore.getBooks2Store(); - - var d = new doh.Deferred(); - function onComplete1(items, request) { - t.assertEqual(1, items.length); - var item1 = items[0]; - t.assertTrue(store1.isItem(item1)); - - function onComplete2(items, request) { - t.assertEqual(1, items.length); - var item2 = items[0]; - t.assertTrue(store2.isItem(item2)); - t.assertTrue(!store1.isItem(item2)); - t.assertTrue(!store2.isItem(item1)); - d.callback(true); - } - store2.fetch({query:{isbn:"A9B574"}, onComplete: onComplete2, onError: onError}); - } - function onError(error, request) { - d.errback(error); - } - store1.fetch({query:{isbn:"A9B574"}, onComplete: onComplete1, onError: onError}); - return d; //Object - }, - function testReadAPI_hasAttribute(t){ - // summary: - // Simple test of the hasAttribute API - // description: - // Simple test of the hasAttribute API - var store = dojox.data.tests.stores.XmlStore.getBooks2Store(); - - var d = new doh.Deferred(); - function onComplete(items, request) { - t.assertEqual(1, items.length); - var item = items[0]; - t.assertTrue(store.hasAttribute(item,"isbn")); - t.assertTrue(!store.hasAttribute(item,"bob")); - d.callback(true); - } - function onError(error, request) { - d.errback(error); - } - store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError}); - return d; //Object - }, - function testReadAPI_containsValue(t){ - // summary: - // Simple test of the containsValue API - // description: - // Simple test of the containsValue API - var store = dojox.data.tests.stores.XmlStore.getBooks2Store(); - - var d = new doh.Deferred(); - function onComplete(items, request) { - t.assertEqual(1, items.length); - var item = items[0]; - t.assertTrue(store.containsValue(item,"isbn", "A9B574")); - t.assertTrue(!store.containsValue(item,"isbn", "bob")); - d.callback(true); - } - function onError(error, request) { - d.errback(error); - } - store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError}); - return d; //Object - }, - function testReadAPI_sortDescending(t){ - // summary: - // Simple test of the sorting API in descending order. - // description: - // Simple test of the sorting API in descending order. - var store = dojox.data.tests.stores.XmlStore.getBooksStore(); - - //Comparison is done as a string type (toString comparison), so the order won't be numeric - //So have to compare in 'alphabetic' order. - var order = [9,8,7,6,5,4,3,20,2,19,18,17,16,15,14,13,12,11,10,1]; - - var d = new doh.Deferred(); - function onComplete(items, request) { - console.log("Number of items: " + items.length); - t.assertEqual(20, items.length); - - for(var i = 0; i < items.length; i++){ - t.assertEqual(order[i], store.getValue(items[i],"isbn").toString()); - } - d.callback(true); - } - function onError(error, request) { - d.errback(error); - } - - var sortAttributes = [{attribute: "isbn", descending: true}]; - store.fetch({query:{isbn:"*"}, sort: sortAttributes, onComplete: onComplete, onError: onError}); - return d; //Object - }, - function testReadAPI_sortAscending(t){ - // summary: - // Simple test of the sorting API in ascending order. - // description: - // Simple test of the sorting API in ascending order. - var store = dojox.data.tests.stores.XmlStore.getBooksStore(); - - //Comparison is done as a string type (toString comparison), so the order won't be numeric - //So have to compare in 'alphabetic' order. - var order = [1,10,11,12,13,14,15,16,17,18,19,2,20,3,4,5,6,7,8,9]; - - var d = new doh.Deferred(); - function onComplete(items, request) { - t.assertEqual(20, items.length); - var itemId = 1; - for(var i = 0; i < items.length; i++){ - t.assertEqual(order[i], store.getValue(items[i],"isbn").toString()); - } - d.callback(true); - } - function onError(error, request) { - d.errback(error); - } - - var sortAttributes = [{attribute: "isbn"}]; - store.fetch({query:{isbn:"*"}, sort: sortAttributes, onComplete: onComplete, onError: onError}); - return d; //Object - }, - function testReadAPI_sortDescendingNumeric(t){ - // summary: - // Simple test of the sorting API in descending order using a numeric comparator. - // description: - // Simple test of the sorting API in descending order using a numeric comparator. - var store = dojox.data.tests.stores.XmlStore.getBooksStore(); - - //isbn should be treated as a numeric, not as a string comparison - store.comparatorMap = {}; - store.comparatorMap["isbn"] = function(a, b){ - var ret = 0; - if(parseInt(a.toString()) > parseInt(b.toString())){ - ret = 1; - }else if(parseInt(a.toString()) < parseInt(b.toString())){ - ret = -1; - } - return ret; //int, {-1,0,1} - }; - - var d = new doh.Deferred(); - function onComplete(items, request) { - t.assertEqual(20, items.length); - var itemId = 20; - for(var i = 0; i < items.length; i++){ - t.assertEqual(itemId, store.getValue(items[i],"isbn").toString()); - itemId--; - } - d.callback(true); - } - function onError(error, request) { - d.errback(error); - } - - var sortAttributes = [{attribute: "isbn", descending: true}]; - store.fetch({query:{isbn:"*"}, sort: sortAttributes, onComplete: onComplete, onError: onError}); - return d; //Object - }, - function testReadAPI_sortAscendingNumeric(t){ - // summary: - // Simple test of the sorting API in ascending order using a numeric comparator. - // description: - // Simple test of the sorting API in ascending order using a numeric comparator. - var store = dojox.data.tests.stores.XmlStore.getBooksStore(); - - //isbn should be treated as a numeric, not as a string comparison - store.comparatorMap = {}; - store.comparatorMap["isbn"] = function(a, b){ - var ret = 0; - if(parseInt(a.toString()) > parseInt(b.toString())){ - ret = 1; - }else if(parseInt(a.toString()) < parseInt(b.toString())){ - ret = -1; - } - return ret; //int, {-1,0,1} - }; - - var d = new doh.Deferred(); - function onComplete(items, request) { - t.assertEqual(20, items.length); - var itemId = 1; - for(var i = 0; i < items.length; i++){ - t.assertEqual(itemId, store.getValue(items[i],"isbn").toString()); - itemId++; - } - d.callback(true); - } - function onError(error, request) { - d.errback(error); - } - - var sortAttributes = [{attribute: "isbn"}]; - store.fetch({query:{isbn:"*"}, sort: sortAttributes, onComplete: onComplete, onError: onError}); - return d; //Object - }, - function testReadAPI_isItemLoaded(t){ - // summary: - // Simple test of the isItemLoaded API - // description: - // Simple test of the isItemLoaded API - var store = dojox.data.tests.stores.XmlStore.getBooks2Store(); - - var d = new doh.Deferred(); - function onComplete(items, request) { - t.assertEqual(1, items.length); - var item = items[0]; - t.assertTrue(store.isItemLoaded(item)); - d.callback(true); - } - function onError(error, request) { - d.errback(error); - } - store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError}); - return d; //Object - }, - function testReadAPI_getFeatures(t){ - // summary: - // Simple test of the getFeatures function of the store - // description: - // Simple test of the getFeatures function of the store - - var store = dojox.data.tests.stores.XmlStore.getBooks2Store(); - var features = store.getFeatures(); - var count = 0; - for(i in features){ - t.assertTrue((i === "dojo.data.api.Read" || i === "dojo.data.api.Write")); - count++; - } - t.assertEqual(2, count); - }, - function testReadAPI_getAttributes(t){ - // summary: - // Simple test of the getAttributes API - // description: - // Simple test of the getAttributes API - var store = dojox.data.tests.stores.XmlStore.getBooks2Store(); - - var d = new doh.Deferred(); - function onComplete(items, request) { - t.assertEqual(1, items.length); - var item = items[0]; - var attributes = store.getAttributes(item); - - //Should be six, as all items should have tagName, childNodes, and text() special attributes - //in addition to any doc defined ones, which in this case are author, title, and isbn - //FIXME: Figure out why IE returns 5! Need to get firebug lite working in IE for that. - //Suspect it's childNodes, may not be defined if there are no child nodes. - for(var i = 0; i < attributes.length; i++){ - console.log("attribute found: " + attributes[i]); - } - if(dojo.isIE){ - t.assertEqual(5,attributes.length); - }else{ - t.assertEqual(6,attributes.length); - } - d.callback(true); - } - function onError(error, request) { - d.errback(error); - } - store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError}); - return d; //Object - }, - function testWriteAPI_setValue(t){ - // summary: - // Simple test of the setValue API - // description: - // Simple test of the setValue API - var store = dojox.data.tests.stores.XmlStore.getBooks2Store(); - - var d = new doh.Deferred(); - function onComplete(items, request) { - t.assertEqual(1, items.length); - var item = items[0]; - t.assertTrue(store.containsValue(item,"isbn", "A9B574")); - store.setValue(item, "isbn", "A9B574-new"); - t.assertEqual(store.getValue(item,"isbn").toString(), "A9B574-new"); - d.callback(true); - } - function onError(error, request) { - d.errback(error); - } - store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError}); - return d; //Object - }, - function testWriteAPI_setValues(t){ - // summary: - // Simple test of the setValues API - // description: - // Simple test of the setValues API - var store = dojox.data.tests.stores.XmlStore.getBooks2Store(); - - var d = new doh.Deferred(); - function onComplete(items, request) { - t.assertEqual(1, items.length); - var item = items[0]; - t.assertTrue(store.containsValue(item,"isbn", "A9B574")); - store.setValues(item, "isbn", ["A9B574-new1", "A9B574-new2"]); - var values = store.getValues(item,"isbn"); - t.assertEqual(values[0].toString(), "A9B574-new1"); - t.assertEqual(values[1].toString(), "A9B574-new2"); - store.setValues(values[0], "text()", ["A9B574", "-new3"]); - t.assertEqual(store.getValue(values[0],"text()").toString(), "A9B574-new3"); - d.callback(true); - } - function onError(error, request) { - d.errback(error); - } - store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError}); - return d; //Object - }, - function testWriteAPI_unsetAttribute(t){ - // summary: - // Simple test of the unsetAttribute API - // description: - // Simple test of the unsetAttribute API - var store = dojox.data.tests.stores.XmlStore.getBooks2Store(); - - var d = new doh.Deferred(); - function onComplete(items, request) { - t.assertEqual(1, items.length); - var item = items[0]; - t.assertTrue(store.containsValue(item,"isbn", "A9B574")); - store.unsetAttribute(item,"isbn"); - t.assertTrue(!store.hasAttribute(item,"isbn")); - t.assertTrue(store.isDirty(item)); - d.callback(true); - } - function onError(error, request) { - d.errback(error); - } - store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError}); - return d; //Object - }, - function testWriteAPI_isDirty(t){ - // summary: - // Simple test of the isDirty API - // description: - // Simple test of the isDirty API - var store = dojox.data.tests.stores.XmlStore.getBooks2Store(); - - var d = new doh.Deferred(); - function onComplete(items, request) { - t.assertEqual(1, items.length); - var item = items[0]; - t.assertTrue(store.containsValue(item,"isbn", "A9B574")); - store.setValue(item, "isbn", "A9B574-new"); - t.assertEqual(store.getValue(item,"isbn").toString(), "A9B574-new"); - t.assertTrue(store.isDirty(item)); - d.callback(true); - } - function onError(error, request) { - d.errback(error); - } - store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError}); - return d; //Object - }, - function testWriteAPI_revert(t){ - // summary: - // Simple test of the isDirty API - // description: - // Simple test of the isDirty API - var store = dojox.data.tests.stores.XmlStore.getBooks2Store(); - - var d = new doh.Deferred(); - function onComplete(items, request) { - t.assertEqual(1, items.length); - var item = items[0]; - t.assertTrue(store.containsValue(item,"isbn", "A9B574")); - t.assertTrue(!store.isDirty(item)); - store.setValue(item, "isbn", "A9B574-new"); - t.assertEqual(store.getValue(item,"isbn").toString(), "A9B574-new"); - t.assertTrue(store.isDirty(item)); - store.revert(); - - //Fetch again to see if it reset the state. - function onComplete1(items, request) { - t.assertEqual(1, items.length); - var item = items[0]; - t.assertTrue(store.containsValue(item,"isbn", "A9B574")); - d.callback(true); - } - store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete1, onError: onError}); - } - function onError(error, request) { - d.errback(error); - } - store.fetch({query:{isbn:"A9B574"}, onComplete: onComplete, onError: onError}); - return d; //Object - }, - function testReadAPI_functionConformance(t){ - // summary: - // Simple test read API conformance. Checks to see all declared functions are actual functions on the instances. - // description: - // Simple test read API conformance. Checks to see all declared functions are actual functions on the instances. - - var testStore = dojox.data.tests.stores.XmlStore.getBooksStore(); - var readApi = new dojo.data.api.Read(); - var passed = true; - - for(i in readApi){ - var member = readApi[i]; - //Check that all the 'Read' defined functions exist on the test store. - if(typeof member === "function"){ - var testStoreMember = testStore[i]; - if(!(typeof testStoreMember === "function")){ - console.log("Problem with function: [" + i + "]"); - passed = false; - break; - } - } - } - t.assertTrue(passed); - }, - function testWriteAPI_functionConformance(t){ - // summary: - // Simple test write API conformance. Checks to see all declared functions are actual functions on the instances. - // description: - // Simple test write API conformance. Checks to see all declared functions are actual functions on the instances. - - var testStore = dojox.data.tests.stores.XmlStore.getBooksStore(); - var writeApi = new dojo.data.api.Write(); - var passed = true; - - for(i in writeApi){ - var member = writeApi[i]; - //Check that all the 'Write' defined functions exist on the test store. - if(typeof member === "function"){ - var testStoreMember = testStore[i]; - if(!(typeof testStoreMember === "function")){ - passed = false; - break; - } - } - } - t.assertTrue(passed); - } - ] -); - - - - - -} diff --git a/includes/js/dojox/data/tests/stores/atom1.xml b/includes/js/dojox/data/tests/stores/atom1.xml deleted file mode 100644 index faff9aa..0000000 --- a/includes/js/dojox/data/tests/stores/atom1.xml +++ /dev/null @@ -1,848 +0,0 @@ - - SOS - ..where the wave finally broke, and rolled back.. Shane O'Sullivan's technical blog - - 2008-01-22T14:32:09Z - WordPress - - - http://shaneosullivan.wordpress.com/feed/atom/ - - - - - Shane O'Sullivan - http://shaneosullivan.wordpress.com/ - - <![CDATA[Using AOL hosted Dojo with your custom code]]> - - http://shaneosullivan.wordpress.com/2008/01/22/using-aol-hosted-dojo-with-your-custom-code/ - 2008-01-22T14:32:09Z - 2008-01-22T14:32:09Z - - - - - - - - -

The Dojo Ajax Toolkit is kindly hosted by AOL for the consumption of anyone at all. This has the advantage of

- -
    -
  • Reducing the load on your own server
  • -
  • Speeding up the delivery, as a Content Delivery Network (CDN) is used to ensure that the server is as close as possible to the client, and
  • -
  • The more people who use this the better, as the same Dojo files will be cached when users move from site to site, as they’ll all be downloading the AOL hosted files.
  • -
  • Gzip compression as standard, so the files are as small as possible
  • -
-

Additionally, since release 0.9 onwards, the main Dojo JavaScript file, dojo.js, is always exactly the same, whereas in previous released it changed for every developer who built it.

-

However, the problem comes in where you want to use your own custom code with the hosted Dojo code. This is because the hosted code uses Dojo’s loading system to dynamically load the resources needed on the page, and this will read the files from AOL, not your server (as you would expect - it knows nothing about your server). If you want to build custom layers to improve performance, the remotely hosted Dojo will not be able to find them.

- -

So, the solution I generally tend to use is to put the AOL dojo.js on every page, and tell Dojo to load any other required files from my own server. To do this, set the baseUrl parameter on the djConfig attribute for the JavaScript file to the folder where Dojo is stored on your server. E.g.

-

<script type=”text/javascript” src=”http://o.aolcdn.com/dojo/1.0.2/dojo/dojo.js” djConfig=”{baseUrl:’/js/dojo/’}”></script>

- -

Notice here that the file I load is dojo.js, the normal version, not dojo.xd.js, which is the cross domain version capable of loading files from AOL.

-

After doing this, you can then include whatever custom built layers you like onto an particular page. For example, if you have a layer built for the dojox.image.Gallery widget called /js/dojo/dojox/image/Gallery-layer.js, you can load it either dynamically:

-

<script type=”text/javascript”>dojo.require(”dojox.image.Gallery-layer.js”);</script>

- -

or include it via a script tag:

-

<script type=”text/javascript” src=”js/dojo/dojox/image/Gallery-layer.js”></script>

-

and it should work just as if you were using Dojo from your own server. Only of course you are not - AOL is serving up that file, and in many cases users will already have cached that file, speeding up your site quite nicely.

-

Another approach is to create a custom namespace, register it with Dojo, and put all your layers in there…. but that’s for another post :-)
- -Share this post:digg it|kick it|Email it|bookmark it|reddit|liveIt

- - ]]>
- - - 1 -
- - - Shane O'Sullivan - http://shaneosullivan.wordpress.com/ - - <![CDATA[Dojo Demo Engine Update]]> - - http://shaneosullivan.wordpress.com/2008/01/07/dojo-demo-engine-update/ - 2008-01-12T13:22:38Z - 2008-01-07T01:02:43Z - -

A short while ago I posted about the demo engine I’m writing for the Dojo Ajax Toolkit. Click here to read that post or go to http://www.skynet.ie/~sos/js/demo/dojo/dojoc/demos/featureexplorer.html to see it in action.

- -

Features

-

Since that post, quite a lot of work has gone into both the features and the content of the demo engine, and the development process has solidified nicely. Some of the features include:

-
    -
  • Tree navigation. A dijit.Tree widget, reading from a remote JSON data store is used to navigate the various demos.
  • -
  • Search feature. A dijit.form.ComboBox widget, reading from the same JSON data store as the tree, can be used to dynamically search for demos by matching any part of their name.
  • - -
  • Theme switcher. A dijit.form.ComboBox widget is used to switch between the CSS styles that Dojo provides.
  • -
  • URL addressability. Using a hash identifier (e.g. #Dojo_Query_By%20Class) in the URL of the demo engine causes it to open that demo when it has finished loading. For example, if you click this link, it will open the dojo.query demo showing you how to select nodes by class name. Opening any demo changes the URL in the browser to the URL for that demo, for easy bookmarking.
  • - -
  • Integrated build process. A simple build script is integrated with the Dojo build process. It builds a JSON data file listing all the existing demos and their respective files. It also builds files with URL links for each demo.
  • -
-

Content

-

To date, a lot of content has been added. Many, many widgets in Dijit and DojoX
-
have have been added, including the majority of the Form Controls.

- -

The latest, pretty cool additions have been the IO and dojo.query demos. These cover things such as:

-
    -
  • Performing a XMLHttpRequest request
  • -
  • Using an iFrame transport
  • -
  • Submitting a form asynchronously
  • -
  • Loading remote JavaScript files from another domain
  • -
  • Selecting nodes using CSS selectors with dojo.query
  • - -
  • Performing operations on the NodeList returned from dojo.query
  • -
  • Attaching events to the NodeList returned from dojo.query
  • -
-

File Naming Scheme
-A simple file naming scheme is used to add content to the demo framework. Each folder beneath the root folder represents a demo. Each file in a folder must be named the same as the folder, with five possible extensions. For example, given a folder with the name ‘Button‘, the possible files are:

-
    - -
  • Button.html - this contains the demo to be displayed. Any JavaScript code inside <script> tags is executed, and any <link type=”text/css”> and <style> tags have their CSS loaded. The executed code is shown in the View tab, and and the source code is shown in the XML tab. The <html>, <head> and <body> tags are not required.
  • - -
  • Button.js - this contains pure JavaScript code that performs the same operations as Button.html, if applicable. It is not executed however. It is shown in the JS tab.
  • -
  • Button.txt - this contains the text description of the demo. It is loaded above the tabs.
  • -
  • Button.links - this contains a JSON array of URL links. The build script transforms these links into HTML, and the result is loaded into the Links tab. One neat feature of this is that all links from sub folders are integrated with the parent folder and displayed in a nested structure. Do, for example, clicking on Dijit will show all the links for all widgets in the Dijit project.
  • - -
  • Button.full.html - this is standalone demo, that is designed to run outside the demo engine. The View tab provides a link to the external file.
  • -
  • sort.txt - this contains a comma separated list of the child folders contained in this folder. It specifies the order in which to display the child demos in the tree. If this file is not specified, then an alphabetical ordering is used.
  • -
-

All of these files are optional. If a file in a folder does not match this naming scheme, it is assumed to be some kind of resource that the demo needs, such as an image or a JSON data file. In this case, the file can be named whatever you like.

-

The tree structure in the demo engine mirrors the folder layout.

- -

Still To Do

-

There remains quite a lot of work ahead. There are a few bugs remaining, some more cross browser testing is needed, and of course more content is required, particularly the base Dojo package.

-

In the relatively near future this should be opened up to the public for development. The Dojo folks are setting up a source control server for community additions, and this demo engine should be part of that. Once that is done, people can start adding all sorts of cool stuff!
-Share this post:digg it|kick it|Email it|bookmark it|reddit|liveIt

- - ]]>
- - - 3 -
- - - Shane O'Sullivan - http://shaneosullivan.wordpress.com/ - - <![CDATA[Navigating in an IE Modal Dialog]]> - - http://shaneosullivan.wordpress.com/2007/12/31/navigating-in-an-ie-modal-dialog/ - 2007-12-31T16:36:21Z - 2007-12-31T16:36:21Z - -

Internet Explorer has a nice feature where a new window can be opened modally using the window.showModalDialog function, meaning that the page that opened it cannot be accessed until the new window is closed. This can be useful in many situations.

- -

However, the main limitation of IE Modal Dialogs (other than being non-standard), is that any hyperlink clicked in a modal dialog causes another, non modal, dialog to be opened, rather than opening the page linked to in the same window, as would happen in a normal pop up window.

-

The key to solving this problem is to note that a modal dialog only opens another window when a GET request is made, not when a POST request is made. However, an anchor tag automatically causes a GET request, so the solution is to:

-
    -
  1. Catch the click on each anchor tag, cancel it,
  2. -
  3. Submit a dynamically created FORM element, with it’s method set to ‘POST’ and it’s action set to the URL of the link clicked.
  4. - -
-

While it is possible to put a listener on each anchor tag to achieve this, such an approach will not scale well. Instead, place a listener on the body tag. The example below is done using methods from the Dojo Ajax Toolkit, since that the toolkit I use the most, but you can of course use whatever methods you like to achieve the same result:

-

<script type="text/javascript">
-dojo.addOnLoad(function(){
-dojo.connect(dojo.body(), “onclick”, function(evt) {
-if(evt.target.tagName != “A”) {return true;}
-dojo.stopEvent(evt);
-var form = document.createElement(”form”);
-form.setAttribute(”target”, window.name ? window.name : “SrPopUp”);
-form.setAttribute(”action”, url);
-form.setAttribute(”method”,”POST”);
-document.appendChild(form);
-form.submit();
-return false;
-});
-});
- -</script>

-

This method assumes that you have control over the content of the page being shown in the modal dialog. It would also make sense to add a similar listener to the body tag for key events, as a user can trigger an anchor tag by tabbing to it and hitting enter.

-

Thanks to Danny Goodman and Steiner Overbeck Cook for coming up with this solution.
-Share this post:digg it|kick it|Email it|bookmark it|reddit|liveIt

- - ]]>
- - - 1 -
- - - Shane O'Sullivan - http://shaneosullivan.wordpress.com/ - - <![CDATA[A new Demo engine for Dojo]]> - - http://shaneosullivan.wordpress.com/2007/12/04/a-new-demo-engine-for-dojo/ - 2008-01-12T13:23:15Z - 2007-12-04T09:29:16Z - -

A couple of weeks ago I saw a cool demo framework for an Ajax toolkit just released as open source. It’s a very slick implementation, with a tree listing all the various demos, and a tabbed area showing the implementation, and the widget in practice.

- -

So, I think to myself, this is exactly what the Dojo Ajax Toolkit is missing! Cut to today, and I’ve put the first rough cut at the demo framework on the web for people’s perusal. Check it out at http://www.skynet.ie/~sos/js/demo/dojo/dojoc/demos/featureexplorer.html .

-

Note: I have written a follow up post here.

-

Some of the features include:

-
    - -
  • Tree navigation for the demos. Demos can be nested as deep as required.
  • -
  • View tab. This shows the widgets in action.
  • -
  • HTML tab. This shows how to instantiate the widget using HTML markup.
  • -
  • JS tab. This shows how to instantiate the widget using JavaScript code.
  • -
  • Links tab. This shows various hyperlinks to alternate content for that demo, e.g. the Dojo Book.
  • -
  • Demo description. Gives a text description of the demo.
  • -
  • Theme selector. This allows you to change from one CSS theme to another
  • -
  • Ability to link to standalone demos that open in a new page. This is useful for large demos that show the integration of many widgets together, and may not fit well within the demo framework itself. See the Dijit/Mail demo for an example of this.
  • - -
  • A build system that takes a very simple naming scheme for the demos, and creates a JSON data store that the framework runs off of. So, whenever a user adds a new demo, they simply have to re-run the build step, and that’s it! No need for a server side script, so you can run this right off your hard drive.
  • -
-

This is still very much beta code, and there are a couple of errors floating around, but those will of course be hunted down. There are also some Internet Explorer issues that I’ll get to soon, so try this in Firefox for now (update Dec 05 2007 - most of these have been solved, with one or two small bugs remaining). I’m in discussions to get this into the Dojo toolkit, so that the community at large can start adding in demos. I’ve put in quite a few already, but it’s so easy to do that this could become a huge resource for the Dojo community.

-

If you have any suggestions, please let me know.

-

Demo Framework
- -Share this post:digg it|kick it|Email it|bookmark it|reddit|liveIt

- - ]]>
- - - 3 -
- - - Shane O'Sullivan - http://shaneosullivan.wordpress.com/ - - <![CDATA[Upgrading Ubuntu Feisty Fawn (7.04) to Gutsy Gibbon (7.10)]]> - - http://shaneosullivan.wordpress.com/2007/10/18/upgrading-ubuntu-feisty-fawn-704-to-gutsy-gibbon-710/ - 2008-01-12T10:26:42Z - 2007-10-18T16:11:37Z - -

Today I’ve begun the process of upgrading my Ubuntu installation of version 7.04 to version 7.10. To see my previous tutorial of getting Ubuntu installed on my IBM Thinkpad X41, see http://shaneosullivan.wordpress.com/2007/02/16/installing-ubuntu-edgy-on-a-thinkpad-x41-tablet/.

- -

This post lists whatever issues I found when upgrading, and my solutions to them. For the official instructions, see https://help.ubuntu.com/community/GutsyUpgrades.

-

Third Party software sources cause problems

-

My first problem was caused by having links to third party software distribution sites. When running the “update-manager -d” command, I received an error, saying the dbus couldn’t run.

-

This was caused by having third party software sources enabled that no longer existed, for whatever reason.

- -

To fix this:

-
    -
  1. click “System/Administration/Software Sources”
  2. -
  3. Click the “Third-Party Software” tab
  4. -
  5. Deselect any non-Ubuntu software sources. You can always reselect them after the upgrade
  6. - -
-

Modifying the software channels gets stuck

-

When the second step in the “Distribution Upgrade” application is running, that is, the “Modifying the software channels” step, it got stuck downloading files. It would say

-

Downloading file 36 of 97

-

and stay at that number for a long time. This was not a bandwidth issue, it simply stopped. To fix this

-
    -
  1. Click the “Cancel” button.
  2. - -
  3. Run the “update-manager -d” command again.
  4. -
  5. Repeat this each time it gets stuck downloading files. I had to do this four times for it to work completely.
  6. -
-

Dual monitors didn’t work correctly

-

When booted up with an external monitor plugged in, the desktop was fixed at 640 * 480 pixels resolution. I found someone else with a similar issue at http://ubuntuforums.org/showthread.php?t=566947 , but their solution didn’t work for me. I solved this by:

- -
    -
  1. Unplugging the monitor.
  2. -
  3. Restart the machine, and log in.
  4. -
  5. Click “System/Administration/Screens and Graphics
  6. -
  7. Click the “Graphics Card” tab.
  8. - -
  9. Click the “Driver” button
  10. -
  11. From the “Driver” dropdown list, choose “i810 - Intel Integrated Graphics Chipsets
  12. -
  13. Restart the machine.
  14. - -
-

Compiz has problems with dual monitors

-

Compiz (the 3D graphics stuff) causes problems and refuses to work at all if I am using dual monitors. Still working on this one.

-

Some Eclipse plug-ins no longer work

-

As a Java developer, I often use the Eclipse development platform. I include some non-standard plugins in the application, like plugins for Subversion support. However, when Ubuntu is upgraded to 7.10, the base Eclipse platform in upgraded, but not the non-standard plugins, which stops some of them from working.

-

Update: actually, this didn’t fix my Eclipse problems, please ignore :-)

- -

The solution is to upgrade the plugins in the usual Eclipse manner:

-
    -
  1. Open Eclipse
  2. -
  3. Click Help/Software Updates/Find and Install
  4. -
  5. Click Finish
  6. -
  7. Wait a while…
  8. -
- -

Running low on disk space after upgrade

-

My laptop was running out of disk space after the install, as it downloaded quite a few packages. I found a very good blog post on how to clean up your Ubuntu install at http://www.ubuntugeek.com/cleaning-up-all-unnecessary-junk-files-in-ubuntu.html.

-

Make sure to read comment #7 also, that alone saved me 1GB.

-

Some Thinkpad features no longer work

-

I found that some things didn’t work that did work before, for example the stylus pen and the middle ’scroller’ button of the mouse. If this happens, just reapply the settings I describe here, as the upgrade removed them. This solved the problems for me.

- -

Share this post:digg it|kick it|Email it|bookmark it|reddit|liveIt

- - ]]>
- - - 25 -
- - - Shane O'Sullivan - http://shaneosullivan.wordpress.com/ - - <![CDATA[Introducing the new Dojo Image Widgets]]> - - http://shaneosullivan.wordpress.com/2007/10/13/introducing-the-new-dojo-image-widgets/ - 2008-01-08T11:23:13Z - 2007-10-13T11:09:13Z - - - - - - - - - - - - - - - - -

In previous posts (here for the Dojo 0.4.3 version, here and here), I wrote how I wrote an image gallery for version 0.4.3 of the Dojo Ajax Toolkit, and how I was translating it for the latest version of the toolkit, version 1.0.

- -

Well, that work is now, finally, complete, and I have to say, I’m pretty damn happy with the results. The code is now part of the dojox.image project (dojox is the Dojo extensions project, for cool new code that may in the future make it into the core code base if enough people like/want it).

-

If you’d like to just see the gallery in action, have a look at the Photos page on my personal website, or see the links at the bottom of the post, otherwise, read on!

-

Update: changes have been made to the widgets since this post was written, resulting in some badly aligned images. This will be fixed in the next few days. (Oct 25th 2007)

-

Update: issue above has been fixed (Oct 29th 2007)

- -

All For One….

-

The gallery is composed of three widgets:

-
    -
  • dojox.image.ThumbnailPicker - a widget to list many small images in either a horizontal or vertical orientation, scroll through them, and attach click events that other widgets can listen to
  • -
  • dojox.image.SlideShow - a widget that displays one image at a time, and can run a slideshow, changing the images every ‘x’ seconds.
  • -
  • dojox.image.Gallery - A wrapper around the ThumbnailPicker, and SlideShow widgets.
  • - -
-

Both the ThumbnailPicker and Slideshow widgets can also be used on their own, and have no dependencies on each other.
-

-

Dojo Data Is Too Cool for School

-

One of the coolest features of all of these widgets is that they all feed off image data provided by the dojo.data API. What this basically means is that each widget can display images from any source, with no modification whatsoever. You simply pass it a Dojo data store, and is shows the pictures. Some of the data stores currently in the Dojo toolkit include:

-
    -
  • dojo.data.ItemFileReadStore - pull in simple JSON data in an array. You could use this if you simply have a directory of images on your own web server you would like to display
  • -
  • dojox.data.FlickrRestStore (demo) - query the Flickr photo sharing website for images. This is all done on the browser, with no need for any server-side redirects. This is another of my additions to the Dojo toolkit - I love Flickr, feel free to check out my photo stream here. I previously wrote another blog post on this data store here.
  • - -
  • dojox.data.PicasaStore (demo) - query Google’s Picasa image sharing website for images. As with the Flickr data store, this is done on the browser, with no need for server side support.
  • -
-

and many more….. You can also write your own data store if you so desire, but the ones included in the toolkit should cover almost everything you might need.

-

Gimme, Gimme, Gimme!

-

So, how can I get this, you ask! Well, you can:

- -

Update: Dojo 1.0 is now released. Get it at http://www.dojotoolkit.org/downloads
-As always, any and all feedback is welcome. Also, a big thanks to Peter Higgins, owner of the dojox.image project, and Jared Jurkiewicz, owner of the dojo.data project, for all their helpful ideas, and for reviewing/committing my code to the Dojo project.
-Share this post:digg it|kick it|Email it|bookmark it|reddit|liveIt

- - ]]>
- - - 46 -
- - - Shane O'Sullivan - http://shaneosullivan.wordpress.com/ - - <![CDATA[Dojo Grid has landed]]> - - http://shaneosullivan.wordpress.com/2007/10/05/dojo-grid-has-landed/ - 2007-10-14T21:46:03Z - 2007-10-05T13:23:17Z - -

The previously announced Dojo Grid has landed in source control, and is in the nightly builds. It has all sorts of fancy functionality, like support for lazy loading huge data sets, individual styling of rows and columns, inline editing etc.

- -

Check it out at http://archive.dojotoolkit.org/nightly/checkout/dojox/grid/tests/

-

Very cool stuff!

-

Update: The Sitepen guys have recently blogged about the grid at http://www.sitepen.com/blog/2007/10/13/dojo-grid-update/

-

Share this post:digg it|kick it|Email it|bookmark it|reddit|liveIt

- - ]]>
- - - 0 -
- - - Shane O'Sullivan - http://shaneosullivan.wordpress.com/ - - <![CDATA[A TortoiseSVN replacement for Ubuntu]]> - - http://shaneosullivan.wordpress.com/2007/10/04/a-tortoisesvn-replacement-for-ubuntu/ - 2007-10-04T15:50:50Z - 2007-10-04T15:50:50Z - -

I work on a number of open source projects, and many of them use the Subversion version control system to manage their code. Before my switch from Windows XP to Ubuntu Linux (which I am still ecstatically happy with btw), I became a big fan of TortoiseSVN, an extremely useful Subversion client that integrates itself directly into Windows Explorer.

- -

TortoiseSVN is simple to use, very intuitive, and does everything I need from it. You simply right click on a folder you want to store your checked out files in, give it the URL of the Subversion server, and it checks out the code, updates it, checks it back in (if you have permission), performs file diffs ….. basically everything you need to do is integrated right in with your file browser.

-

So, I miss this in Ubuntu, as TortoiseSVN is Windows only. However, I recently found a replacement, which integrates nicely with Nautilus, the Ubuntu file browser. While it is not as slick as TortoiseSVN, it works in a very similar way. You right click on a folder, and have a selection of SVN operations you can perform.

-

See http://marius.scurtescu.com/2005/08/24/nautilus_scripts_for_subversion for details.

-

Nautilus Subversion Menu

-

Nautilus Subversion Dialog

-

One thing that is missing from this is the display of icons in the file browser (Nautilus) to inform you of the state of a file - checked out, modified, not added to source control etc. Another person has developed a solution to this, which unfortunately I have not, yet, been able to get working, but perhaps you will have more luck.

- -

See http://www.kryogenix.org/days/2006/09/12/extremely-noddy-tortoisesvn-for-the-gnome-desktop for details on this.
-Share this post:digg it|kick it|Email it|bookmark it|reddit|liveIt

- - ]]>
- - - 3 -
- - - Shane O'Sullivan - http://shaneosullivan.wordpress.com/ - - <![CDATA[Querying Flickr with Dojo!]]> - - http://shaneosullivan.wordpress.com/2007/09/22/querying-flickr-with-dojo/ - 2007-09-22T18:26:51Z - 2007-09-22T16:10:05Z - -

I’ve recently submitted a new data store for the Dojo Ajax Toolkit that makes it very simple to query Flickr for your and other peoples images. For those not familiar with Flickr, it is a photo sharing website, one of the most popular on the net. However, what makes it quite special is the comprehensive public APIs that it exposes.

- -

While these APIs are extremely useful, however, they are also very complex, with a steep learning curve before you can even get started. In steps Dojo and their new Data API specification, whose stated aim is to have a single unified interface to all data sources, so that users of a data store won’t have to care if they’re reading from a database, from a XML or JSON file, or from some remote service like Flickr.

-

So, long story short, I’ve written an implementation of the Dojo Data APIs to query data from Flickr. It is part of the DojoX project, and is called dojox.data.FlickrRestStore. It provides quite a few methods of querying for photos:

-
    -
  • By one or more tags, matchine any or all of them
  • -
  • By user id
  • - -
  • By set id
  • -
  • Full text search
  • -
  • Sorting on date taken, date published or ‘interestingness’
  • -
-

FlickrRestStore also performs caching of image data, so if you request the data twice it won’t make a second remote request.

-

The store is also designed to be accessed by multiple clients simultaneously. If two clients request the same data, only one request is made, with both clients being notified of the identical results.

-

Examples

- -

I’ve put a fairly comprehensive set of examples in the Dojo book at http://dojotoolkit.org/book/dojo-book-0-9/part-3-programmatic-dijit-and-dojo
-/using-dojo-data/available-stores/flickr-rest-s#examples
.

-

You can see a Demo of it running at http://archive.dojotoolkit.org/nightly/dojotoolkit/dojox/data/demos/demo_FlickrRestStore.html .

-

The unit tests cover quite a few cases also, and you can see them at http://archive.dojotoolkit.org/nightly/dojotoolkit/dojox/data/tests/stores/FlickrRestStore.js

-

To get the code, you can:

- - -

Share this post:digg it|kick it|Email it|bookmark it|reddit|liveIt

- - ]]>
- - - 3 -
- - - Shane O'Sullivan - http://shaneosullivan.wordpress.com/ - - <![CDATA[Specifying the callback function with the Flickr JSON APIs]]> - - http://shaneosullivan.wordpress.com/2007/09/13/specifying-the-callback-function-with-the-flickr-json-apis/ - 2007-09-13T09:54:53Z - 2007-09-13T09:31:30Z - -

Flickr is a photo sharing website that has a very flexible set of APIs that other applications and websites can use to access the photos it stores. This post shows you how to specify a callback function that Flickr can call to pass your web application information on photos it stores.

- -

Quite a while ago I looked into the Flickr APIs for a website I was writing. Looking at the service that returns photo data in JSON (Javascript Object Notation), I noticed that it did so by calling a predefined function, jsonFlickrApi, passing in the data to that function. This seemed to be an obvious weak spot, since if more than one widget on a page were accessing the Flickr REST services, they would clash with each other, possibly receiving each others data. Obviously not a good thing.

-

Cut to today. I’ve been working on a JavaScript data store that operates against the Flickr REST services for the Dojo Ajax Toolkit, and had another look at the Flickr APIs. Now, whether I missed it before (doubtful, as I looked specifically for it), or the fine Flickr folk have listened to complaints (very likely), but there is now a parameter that can be passed to the Flickr API that specifies the callback function to use when the data is retrieved from Flickr.

-

All you have to do is pass a parameter jsoncallback to Flickr, with the name of the function you want to be called with the data, and thats it.

- -

E.g. if I had a function:

-

function myCallbackFunction(data) {

-

alert(”I received ” + data.photos.photo.length +” photos”);

-

}

-

I could then specify a <script> element in my HTML page to retrieve the data in a cross site manner (since you can’t make cross site XmlHttpRequest calls), like so:

- -

<SCRIPT type=”text/javascript” src=”http://www.flickr.com/services/rest/?format=json&jsoncallback=myCallbackFunction
-&method=flickr.people.getPublicPhotos
-&api_key=8c6803164dbc395fb7131c9d54843627
-&user_id=44153025%40N00&per_page=1″>

- -

</SCRIPT>

-

Note the jsoncallback parameter in the src attribute. This results in JavaScript similar to:

-

myCallbackFunction({”photos”:{”page”:1, “pages”:489, “perpage”:1, “total”:”489″, “photo”:[{”id”:”1352049918″, “owner”:”44153025@N00″, “secret”:”5636009306″, “server”:”1111″, “farm”:2, “title”:”The Liffey Panorama”, “ispublic”:1, “isfriend”:0, “isfamily”:0}]}, “stat”:”ok”});

- -

being called.

-

Thanks Flickr! Nice to see them listening, and continually improving. This will make web applications built on Flickr much more robust, without the need of ridiculous hackery to get around unnecessarily difficult APIs. See http://www.flickr.com/services/api/response.json.html for the offical info on JSON responses.

-

Keep an eye out for my dojox.data.FlickrRestStore being release some day soon!!
-Share this post:digg it|kick it|Email it|bookmark it|reddit|liveIt

- - ]]>
- - - 0 -
- - - Shane O'Sullivan - http://shaneosullivan.wordpress.com/ - - <![CDATA[Image Gallery, Slideshow, and Flickr data source for Dojo 0.9]]> - - http://shaneosullivan.wordpress.com/2007/09/04/image-gallery-slideshow-and-flickr-data-source-for-dojo-09/ - 2007-09-05T08:32:22Z - 2007-09-04T23:32:51Z - -

In a previous post (see here) I spoke about how I’d written an Image Gallery widget that worked with Dojo Ajax Toolkit version 0.4.2 and 0.4.3. I contacted the good folks at Dojo about updating it for the latest release, 0.9, and adding it to the toolkit.

- -

They were very receptive to the idea, with a few suggestions. Firstly, rather than having its own method of storing information, it should run off the dojo.data API, and secondly, it should go into the newly created dojox.image project.

-

Both of these suggestions were perfectly reasonable, so, cut to a few weeks later and I’ve finished my first pass at converting over the code from 0.4.3 to 0.9. As the Dojo APIs have changed drastically recently, this was no simple matter, but thats the subject of another blog post.

-

The code is not finished (or even checked in) yet, but you can see some examples of it running from test pages. There are two separate widgets:

-
    -
  • dojox.image.SlideShow - a simple widget that runs a slide show of images, with urls loaded from a dojo.data store.
  • -
  • dojox.image.ImageGallery - this wraps the SlideShow widget, adding thumbnail views. This is also loaded from a dojo.data store.
  • -
-

Finally, I’ve implemented a dojo.data store that reads from the Flickr REST APIs, to pull down lists of photos. This store is more complex than the existing Flickr store, as it does caching of results, as well as going against a much more flexible API, meaning that expanding its capabilities later is possible.

- -

Whether or not this goes into dojox or not is still undecided. However, you can see the widgets running using this data store.

-

See the test files at http://www.skynet.ie/~sos/js2/dojox/image/tests for examples of this working.

-

Note that this is NOT the final code. It may still be buggy, may look different in the future (it’s pretty basic now), and the code will be cleaned up. However, if you have any suggestions, please feel free to leave comments on this post.

-

Share this post:digg it|kick it|Email it|bookmark it|reddit|liveIt

- - ]]>
- - - 1 -
- - - Shane O'Sullivan - http://shaneosullivan.wordpress.com/ - - <![CDATA[Dojo event performance tip]]> - - http://shaneosullivan.wordpress.com/2007/08/23/dojo-event-performance-tip/ - 2007-08-23T12:38:36Z - 2007-08-23T12:29:08Z - -

When working with the Dojo Ajax Toolkit and using it’s dojo.event package to listen to DOM and custom events, the two most common approaches are:

- -
    -
  1. Listen for an event (or function call) to be triggered on an object, and when it is to run a custom function, e.g.
    - var alertFn = function() {alert(”widget is showing”);};
    -dojo.event.connect(myWidget, “onShow”, alertFn);
  2. -

    This basically says that when the “onShow” function is called on some widget, called myWidget, run a function that does a simple alert. Of course you can do whatever you like inside this function.

    - -
  3. Listen for an event (or function call) to be triggered on an object, and when it is to run a custom function defined in the scope of an object, e.g.
    - var myObj = {
    -alertFn: function() {alert(”widget is showing”);}
    -};
    -dojo.event.connect(myWidget, “onShow”,myObj, “alertFn”);

    -

    This is saying that I have an object called “myObj“, which has a function called “alertFn“, and when the “onShow” method on “myWidget” is called, call the “alertFn” function on “myObj“.

  4. - -
-

I’ve found that when working with Dojo version 0.4.2 and 0.4.3, using the second approach is far far quicker. It turns out that internally, if you simply pass an anonymous function to Dojo, it will add that function to an internal structure and do a brute force search on that internal structure to make sure that this function is unique. This can result in a very significant performance hit - I’ve seen it take up over 50% of the startup time of a page on one of our more JavaScript heavy applications.

-

So, the conclusion is that if you are dojo.event.connect, which is one of the most useful functions in the toolkit, make sure to use four arguments to the function (approach #2 above), rather than just three (approach #1 above). If necessary, place a simple wrapper around the function as I have shown.
-Share this post:digg it|kick it|Email it|bookmark it|reddit|liveIt

- - ]]>
- - - 0 -
- - - Shane O'Sullivan - http://shaneosullivan.wordpress.com/ - - <![CDATA[Dojo 0.9 released]]> - - http://shaneosullivan.wordpress.com/2007/08/22/dojo-09-released/ - 2007-09-04T15:23:50Z - 2007-08-22T10:24:51Z - -

The latest version of the Dojo Ajax Toolkit has just been released into the wild. Version 0.9 is a very streamlined progression of the toolkit, with many of the less essential features pushed out to another project, DojoX, and the Dojo widgets given their own project, Dijit.

- -

Another big change is the the main JavaScript file in Dojo, dojo.js, is no longer customisable. It now contains the most common features required by most web developers, and nothing more. As a result, it is far smaller than previous incarnations, down to ~24k when gzipped.

-

Some resources:

-

James Burke has written up a very informative post about what exactly is baked into the default build of dojo.js, which you can find at http://dojotoolkit.org/2007/08/22/dissecting-0-9s-dojo-js . Well worth a read.

-

Bill Keese wrote up a guided tour of 0.9 at http://dojotoolkit.org/2007/08/20/dijit-0-9-guided-tour.

-

The Dojo book for version 0.9 can be found at http://dojotoolkit.org/book/dojo-book-0-9-0. It’s almost finished (almost!) as of today, Aug 22 2007.

- -

The Ajaxian post on Dojo 0.9 can be read at http://ajaxian.com/archives/dojo-09-final-version-released.

-

Download the toolkit from http://build.dojotoolkit.org/0.9.0. This page gives some information on how you can use Dojo from AOL’s hosting servers, so you never have to download it at all.
-Share this post:digg it|kick it|Email it|bookmark it|reddit|liveIt

- - ]]>
- - - 2 -
- - - Shane O'Sullivan - http://shaneosullivan.wordpress.com/ - - <![CDATA[Dojo theme browser shows off Dijit widgets]]> - - http://shaneosullivan.wordpress.com/2007/08/17/dojo-theme-browser-shows-off-dijit-widgets/ - 2007-11-05T13:45:45Z - 2007-08-17T12:18:57Z - -

The Dojo/Dijit (Dojo’s widget project) toolkit has created a page where you can view many of their widgets using the four CSS themes written so far for Dojo. This is cool for a couple of reasons.

- -

Firstly, it showcases the excellent work the Dijit developers have put into new themeing skins. There are four themes completed so far, and changing the look of Dojo is now as simple as including a different CSS file on your web page. All Dijit widgets now run off a single CSS file, rather than each having their own CSS file.

-

Secondly, it shows the usage of many of Dijit’s widgets (say that five times in a row! :-) ). Many of the demos from the 0.4.* days are gone now, and this is about as comprehensive a demo of Dojo’s widgets as you’re likely to see for a while. And yes, they are very nice indeed.

-

Go to http://archive.dojotoolkit.org/nightly/dojotoolkit/dijit/themes/themeTester.html to see the default theme (tundra) in use. Click on the “Alternate Themes” tab at the bottom of the page to switch themes to one of the alternate themes.

- -

Enjoy!

-

Share this post:digg it|kick it|Email it|bookmark it|reddit|liveIt

- - ]]>
- - - 2 -
- - - Shane O'Sullivan - http://shaneosullivan.wordpress.com/ - - <![CDATA[Why is my web page slow? YSlow for Firebug can tell you.]]> - - http://shaneosullivan.wordpress.com/2007/07/25/why-is-my-web-page-slow-yslow-for-firebug-can-tell-you/ - 2007-07-26T08:28:03Z - 2007-07-25T15:08:30Z - -

Yahoo have released a very useful extension for Firebug, which is itself an extension for Firefox, which can be used to analyze a web page’s performance. The extension, called YSlow, appears as a separate pane in Firebug, and gives you a whole load of statistics about your page.

- -

However, in addition to the bare numbers, it also gives your page a ranking, from zero to a hundred, and offers tips in plain English on you can improve the performance of your page.

-

All in all, a very handy little addition to a web developer’s toolkit.

-

One caveat is that it is of course not perfect - I tried to use it on Gmail, and it gave the site a 98% mark (practically impossible to achieve in reality), as the initial page of the Gmail application simply loads a single JavaScript page and not much else. Therefore, YSlow seems to only analyze content sent down the wire to browser upon page load, and ignores generated content. However, this does not take away from the fact that it is perfectly suitable for the vast majority of websites out there.

-

More information available here, or read Ajaxian’s post here.
-Share this post:digg it|kick it|Email it|bookmark it|reddit|liveIt

- - ]]>
- - - 1 -
- - - Shane O'Sullivan - http://shaneosullivan.wordpress.com/ - - <![CDATA[Flickr and Dojo Image Gallery]]> - - http://shaneosullivan.wordpress.com/2007/07/03/flickr-and-dojo-image-gallery/ - 2007-07-19T10:44:19Z - 2007-07-03T15:53:33Z - -

I have created an Image Gallery widget built on Dojo 0.4.3 that integrates nicely with Flickr. The widget it written entirely using JavaScript and CSS as a standalone Dojo widget, and is released under the same open source license as Dojo, the Academic Free License.

- -

For more information, including the code and examples, see http://www.skynet.ie/~sos/ajax/imagegallery.php.

-

Some of the features of the widget include:

-
    -
  • Pages of thumbnails.
  • -
  • Intelligent pre-loading of images so the images you are looking at are loaded first.
  • -
  • Fade effects for transitioning of images
  • -
  • Populated using JSON data - any JSON data, not just Flickr.
  • -
  • Flickr integration - remotely load your Flickr images.
  • - -
  • Paging through a Flickr collection.
  • -
  • Slideshow
  • -
-

The widget can be instantiated from both HTML markup and programmatically in JavaScript.

-

To view your own Flickr pictures on the widget, without installing it on your own site, go to http://www.skynet.ie/~sos/ajax/yourpics.php .

-

There is a discussion thread in the Flickr API group at http://www.flickr.com/groups/api/discuss/72157600624623643.

-

So, why create this widget? Well, firstly I wanted a JavaScript image gallery that would list thumbnails and allow me to page through Flickr photos. Also, a slide show would have been nice. I was surprised to discover that I couldn’t find one that I liked in the twenty or so minutes I spent looking for one. I found a handy Flash based one, but I wanted a HTML and JavaScript only widget. So I grabbed Dojo 0.4.3 (my JavaScript library of choice right now) and wrote one.

- -

Here is a screen shot:

-


-Screenshot

-

The widget has all the features that I personally require at the moment, but will probably evolve as I think of new things to add. If you have any suggestions/bug reports, please comment on this post.

-

Share this post:digg it|kick it|Email it|bookmark it|reddit|liveIt

- - ]]>
- - - 7 -
- - - Shane O'Sullivan - http://shaneosullivan.wordpress.com/ - - <![CDATA[Is Dojo being ignored by developers?]]> - - http://shaneosullivan.wordpress.com/2007/06/19/is-dojo-being-ignored-by-developers/ - 2007-06-26T10:18:09Z - 2007-06-19T10:36:49Z - -

The two main areas of interest for me over the last year or two, blog-wise that is, have been the Dojo Ajax toolkit, one of the more popular open source JavaScript toolkits, and Ubuntu Linux, the very popular operating system that is seen by many as the best chance Linux has of succeeding on the desktop.

- -

Due to the fact that my blog is hosted on Wordpress.com, I am provided with very detailed statistics on which blog posts are more popular, what days they are accessed on etc. Looking at these, a very definite trend has become apparent

-

While the number of hits received by the Ubuntu blogs remains more or less steady, hits on Dojo blog posts falls dramatically on the weekend.

-

While this is not an exact measurement by any means, it points to a worrying possibility. People are obviously working with Ubuntu on their spare time, installing it, upgrading, adding applications and window managers etc, and need help doing this. They are personally interested in Ubuntu, not just professionally. This is one of the main reasons for Ubuntu’s success - people are excited and motivated by it. They want to work and play with it on their own time.

- -

This does not seem to be the case for Dojo.

-

Dojo has the backing of many large and small companies, including two I have worked for, my previous employer IBM, and my current employer Curam. Both of these are attracted to Dojo for a number of reasons, chief among them being it’s good design and wide range of features. The very large size of the toolkit is not a problem for them (and corporations in general) because it will be included in websites that employees will use to do their everyday work tasks (e.g. using a corporate installation of IBM WebSphere Portal), so the JavaScript is cached and the performance hit is avoided.

-

However, for hobbyists, this is not the case. A person might only visit a single page on their website, and a ~200KB overhead for perhaps something simple like a collapsible menu and some fading effects is simply not feasible. I’ve experienced this recently when writing a simple website for myself - all I wanted was some fading/sliding effects, but the huge overhead just wasn’t worth it. And I am a very big supporter of Dojo (I’ve contributed code even - here and here), and use it every day at work.

- -

The Dojo team are working hard on the 0.9 release, which is addressing many of these issues, bringing the base size down to a more manageable size (at time of writing dojo.js is down to 68KB). I look forward to the day when my site statistics change, when Dojo can stand on the shoulders of many thousands of enthusiastic hackers rather than being held up by a few big corporations. I really do.

-

However, this does not seem to be the case today. Version 0.9 has a lot of work to do.
-Share this post: digg it|kick it|Email it|bookmark it|reddit|liveIt

- - ]]>
- - - 5 -
- - - Shane O'Sullivan - http://shaneosullivan.wordpress.com/ - - <![CDATA[Dojo Charting example to show website statistics]]> - - http://shaneosullivan.wordpress.com/2007/06/15/dojo-charting-example-to-show-website-statistics-2/ - 2007-06-15T12:38:24Z - 2007-06-15T12:35:35Z - -

I’ve created an example usage of the Dojo Charting engine, which you can find at http://www.skynet.ie/~sos/pageStats.php. View the source to see how it works.
-It’s a modified version of the unit test available with the Dojo toolkit, but used in a specific scenario - in this case, to graph the page impressions for my personal website . The JSON data on the page is dynamically generated by PHP, however all other processing is done in JavaScript.

- -

You can filter the data to show info on any combination of pages, and also use a number of different chart types.

-

The code is well documented, so should be easy to follow.
-Some other good examples of using the Dojo Charting engine can be found here and here.
-Share this post:digg it|kick it|Email it|bookmark it|reddit|liveIt

- - ]]>
- - - 4 -
- - - Shane O'Sullivan - http://shaneosullivan.wordpress.com/ - - <![CDATA[GreaseMonkey script to add Digg-like links to posts]]> - - http://shaneosullivan.wordpress.com/2007/05/22/greasemonkey-script-to-add-digg-like-links-to-posts/ - 2007-05-23T14:56:07Z - 2007-05-22T16:57:02Z - -

I decided today that I wanted to put links at the bottom of each of my blog posts that would allow people to perform actions on the post, e.g:

- - -

My blog is on Wordpress.com which doesn’t seem to have a plugin that will allow me to do this. So, I got off my ass and wrote a GreaseMonkey Firefox script that’ll do it for me. You can download this script by going to http://userscripts.org/scripts/show/9421 and clicking the “Install This Script” button.

- -

The links that are inserted are at the bottom of this post. The script is open source (GPL license), so take it, play with it, whatever. If you find any bugs, please let me know by commenting on this post.
-Share this post:digg it|kick it|Email it|bookmark it|reddit|liveIt

- - ]]>
- - - 8 -
- - - Shane O'Sullivan - http://shaneosullivan.wordpress.com/ - - <![CDATA[Article on the square pegs and round holes of desktop and web applications]]> - - http://shaneosullivan.wordpress.com/2007/05/22/article-on-the-square-pegs-and-round-holes-of-desktop-and-web-applications/ - 2007-05-22T08:57:59Z - 2007-05-22T08:49:00Z - -

Bill Higgins of IBM has written a very well thought out article of why web applications should look and act like web applications, and not the desktop variety. Well worth a read - http://billhiggins.us/weblog/2007/05/17/the-uncanny-valley-of-user-interface-design

- - ]]>
- - - 0 -
-
- diff --git a/includes/js/dojox/data/tests/stores/books.html b/includes/js/dojox/data/tests/stores/books.html deleted file mode 100644 index 8535cec..0000000 --- a/includes/js/dojox/data/tests/stores/books.html +++ /dev/null @@ -1,118 +0,0 @@ - - - Books.html - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
isbntitleauthor
1Title of 1Author of 1
2Title of 2Author of 2
3Title of 3Author of 3
4Title of 4Author of 4
5Title of 5Author of 5
6Title of 6Author of 6
7Title of 7Author of 7
8Title of 8Author of 8
9Title of 9Author of 9
10Title of 10Author of 10
11Title of 11Author of 11
12Title of 12Author of 12
13Title of 13Author of 13
14Title of 14Author of 14
15Title of 15Author of 15
16Title of 16Author of 16
17Title of 17Author of 17
18Title of 18Author of 18
19Title of 19Author of 19
20Title of 20Author of 20
- - diff --git a/includes/js/dojox/data/tests/stores/books.xml b/includes/js/dojox/data/tests/stores/books.xml deleted file mode 100644 index 4c330e6..0000000 --- a/includes/js/dojox/data/tests/stores/books.xml +++ /dev/null @@ -1,103 +0,0 @@ - - - - 1 - Title of 1 - Author of 1 - - - 2 - Title of 2 - Author of 2 - - - 3 - Title of 3 - Author of 3 - - - 4 - Title of 4 - Author of 4 - - - 5 - Title of 5 - Author of 5 - - - 6 - Title of 6 - Author of 6 - - - 7 - Title of 7 - Author of 7 - - - 8 - Title of 8 - Author of 8 - - - 9 - Title of 9 - Author of 9 - - - 10 - Title of 10 - Author of 10 - - - 11 - Title of 11 - Author of 11 - - - 12 - Title of 12 - Author of 12 - - - 13 - Title of 13 - Author of 13 - - - 14 - Title of 14 - Author of 14 - - - 15 - Title of 15 - Author of 15 - - - 16 - Title of 16 - Author of 16 - - - 17 - Title of 17 - Author of 17 - - - 18 - Title of 18 - Author of 18 - - - 19 - Title of 19 - Author of 19 - - - 20 - Title of 20 - Author of 20 - - diff --git a/includes/js/dojox/data/tests/stores/books2.html b/includes/js/dojox/data/tests/stores/books2.html deleted file mode 100644 index c0b3550..0000000 --- a/includes/js/dojox/data/tests/stores/books2.html +++ /dev/null @@ -1,43 +0,0 @@ - - - Books2.html - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
isbntitleauthor
A9B57CTitle of 1Author of 1
A9B57FTitle of 2Author of 2
A9B577Title of 3Author of 3
A9B574Title of 4Author of 4
A9B5CCTitle of 5Author of 5
- - \ No newline at end of file diff --git a/includes/js/dojox/data/tests/stores/books2.xml b/includes/js/dojox/data/tests/stores/books2.xml deleted file mode 100644 index d1fa494..0000000 --- a/includes/js/dojox/data/tests/stores/books2.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - A9B57C - Title of 1 - Author of 1 - - - A9B57F - Title of 2 - Author of 2 - - - A9B577 - Title of 3 - Author of 3 - - - A9B574 - Title of 4 - Author of 4 - - - A9B5CC - Title of 5 - Author of 5 - - diff --git a/includes/js/dojox/data/tests/stores/books3.html b/includes/js/dojox/data/tests/stores/books3.html deleted file mode 100644 index 7d0f81d..0000000 --- a/includes/js/dojox/data/tests/stores/books3.html +++ /dev/null @@ -1,14 +0,0 @@ - - - Books2.html - - -
    -
  • A9B57C - Title of 1 - Author of 1
  • -
  • A9B57F - Title of 2 - Author of 2
  • -
  • A9B577 - Title of 3 - Author of 3
  • -
  • A9B574 - Title of 4 - Author of 4
  • -
  • A9B5CC - Title of 5 - Author of 5
  • -
- - \ No newline at end of file diff --git a/includes/js/dojox/data/tests/stores/books3.xml b/includes/js/dojox/data/tests/stores/books3.xml deleted file mode 100644 index c44b4c3..0000000 --- a/includes/js/dojox/data/tests/stores/books3.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - Category 1 - - 1 - Title of 1 - Author of 1 - - - 2 - Title of 2 - Author of 2 - - - 3 - Title of 3 - Author of 3 - - - 4 - Title of 4 - Author of 4 - - - 5 - Title of 5 - Author of 5 - - - diff --git a/includes/js/dojox/data/tests/stores/books_isbnAttr.xml b/includes/js/dojox/data/tests/stores/books_isbnAttr.xml deleted file mode 100644 index b9f3d27..0000000 --- a/includes/js/dojox/data/tests/stores/books_isbnAttr.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - Title of 1 - Author of 1 - - - Title of 2 - Author of 2 - - - Title of 3 - Author of 3 - - - Title of 4 - Author of 4 - - - Title of 5 - Author of 5 - - diff --git a/includes/js/dojox/data/tests/stores/books_isbnAttr2.xml b/includes/js/dojox/data/tests/stores/books_isbnAttr2.xml deleted file mode 100644 index a6ce005..0000000 --- a/includes/js/dojox/data/tests/stores/books_isbnAttr2.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - Title of 1 - Author of 1 - - - Title of 2 - Author of 2 - - - Title of 3 - Author of 3 - - - Title of 4 - Author of 4 - - - Title of 5 - Author of 5 - - diff --git a/includes/js/dojox/data/tests/stores/geography.xml b/includes/js/dojox/data/tests/stores/geography.xml deleted file mode 100644 index 070a8c1..0000000 --- a/includes/js/dojox/data/tests/stores/geography.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - - geography.opml - 2006-11-10 - 2006-11-13 - Magellan, Ferdinand - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/includes/js/dojox/data/tests/stores/geography_withspeciallabel.xml b/includes/js/dojox/data/tests/stores/geography_withspeciallabel.xml deleted file mode 100644 index 597c164..0000000 --- a/includes/js/dojox/data/tests/stores/geography_withspeciallabel.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - - geography.opml - 2006-11-10 - 2006-11-13 - Magellan, Ferdinand - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/includes/js/dojox/data/tests/stores/jsonPathStore.js b/includes/js/dojox/data/tests/stores/jsonPathStore.js deleted file mode 100644 index 9a42a18..0000000 --- a/includes/js/dojox/data/tests/stores/jsonPathStore.js +++ /dev/null @@ -1,604 +0,0 @@ -if(!dojo._hasResource["dojox.data.tests.stores.jsonPathStore"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. -dojo._hasResource["dojox.data.tests.stores.jsonPathStore"] = true; -dojo.provide("dojox.data.tests.stores.jsonPathStore"); -dojo.require("dojox.data.jsonPathStore"); - -dojox.data.tests.stores.jsonPathStore.error = function(t, d, errData){ - // summary: - // The error callback function to be used for all of the tests. - d.errback(errData); -} - -dojox.data.tests.testData=dojo.toJson({"store": {"book": [{"category": "reference", "author": "Nigel Rees", "title": "Sayings of the Century", "price": 8.95}, {"category": "fiction", "author": "Evelyn Waugh", "title": "Sword of Honour", "price": 12.99}, {"category": "fiction", "author": "Herman Melville", "title": "Moby Dick", "isbn": "0-553-21311-3", "price": 8.99}, {"category": "fiction", "author": "J. R. R. Tolkien", "title": "The Lord of the Rings", "isbn": "0-395-19395-8", "price": 22.99}], "bicycle": {"color": "red", "price": 19.95}}}); - -dojox.data.tests.test_ID_Data=dojo.toJson({"gadgetList": {"myId": "product", "1000": {"name": "Gadget", "type": "Junk", "myId": "1000", "price": "19.99"}, "1001": {"name": "Gadget2", "type": "Junk", "myId": "1010", "price": "17.99"}, "1003": {"name": "Gadget3", "type": "Junk", "myId": "1009", "price": "15.99"}, "1004": {"name": "Gadget4", "type": "Junk", "myId": "1008", "price": "13.99"}, "1005": {"name": "Gadget5", "type": "Junk", "myId": "1007", "price": "11.99"}, "1006": {"name": "Gadget6", "type": "Junk", "myId": "1006", "price": "9.99"}}, "testList": {"a": {"name": "test", "type": "Junk", "myId": "3000", "price": "19.99"}, "b": {"name": "test2", "type": "Junk", "myId": "3010", "price": "17.99"}, "c": {"name": "test3", "type": "Junk", "myId": "3009", "price": "15.99"}, "d": {"name": "test4", "type": "Junk", "myId": "3008", "price": "13.99"}, "e": {"name": "test5", "type": "Junk", "myId": "3007", "price": "11.99"}, "f": {"name": "test6", "type": "Junk", "myId": "3006", "price": "9.99"}}, "bricknbrack": [{"name": "BrickNBrack", "type": "Junk", "myId": "2000", "price": "19.99"}, {"name": "BrickNBrack2", "type": "Junk", "myId": "2010", "price": "17.99"}, {"name": "BrickNBrack3", "type": "Junk", "myId": "2009", "price": "15.99"}, {"name": "BrickNBrack4", "type": "Junk", "myId": "2008", "price": "13.99"}, {"name": "BrickNBrack5", "type": "Junk", "myId": "2007", "price": "11.99"}, {"name": "BrickNBrack6", "type": "Junk", "myId": "2006", "price": "9.99"}]}); - -doh.register("dojox.data.tests.stores.jsonPathStore", - [ - { - name: "Create, Index, Export: {clone: true, suppressExportMeta: true}", - options: {clone: true, suppressExportMeta: true}, - runTest: function(t) { - var original= dojox.data.tests.test_ID_Data; - var store= new dojox.data.jsonPathStore({ - data: original, - mode: dojox.data.SYNC_MODE, - idAttribute: "myId", - indexOnLoad: true - }); - - //snapshot of the store after creation; - var storeWithMeta = dojo.toJson(store._data); - var result = store.dump(this.options); - doh.assertEqual(storeWithMeta, result); - } - }, - { - name: "Create, Index, Export: {cleanMeta: true, clone: true}", - options: {cleanMeta: true, clone: true, suppressExportMeta: true}, - runTest: function(t) { - var original= dojox.data.tests.test_ID_Data; - var store= new dojox.data.jsonPathStore({ - data: original, - mode: dojox.data.SYNC_MODE, - idAttribute: "myId", - indexOnLoad: true - }); - - var result = store.dump(this.options); - doh.assertEqual(original, result); - } - }, - { - name: "Create, Index, Export: {suppressExportMeta: true}", - options: {suppressExportMeta: true}, - runTest: function(t) { - var original= dojox.data.tests.test_ID_Data; - var store= new dojox.data.jsonPathStore({ - data: original, - mode: dojox.data.SYNC_MODE, - idAttribute: "myId", - indexOnLoad: true - }); - - //snapshot of the store after creation; - var storeWithMeta = dojo.toJson(store._data); - var result = store.dump(this.options); - doh.assertEqual(storeWithMeta, result); - } - }, - { - name: "Create, Index, Export: {clone: true, type: 'raw', suppressExportMeta: true}", - options: {clone: true, type: "raw", suppressExportMeta: true}, - runTest: function(t) { - var original= dojox.data.tests.test_ID_Data; - var store= new dojox.data.jsonPathStore({ - data: original, - mode: dojox.data.SYNC_MODE, - idAttribute: "myId", - indexOnLoad: true - }); - - //snapshot of the store after creation; - var storeWithMeta = dojo.toJson(store._data); - var result = dojo.toJson(store.dump(this.options)); - doh.assertEqual(storeWithMeta, result); - } - }, - { - name: "Create, Index, Export: {clone: true, suppressExportMeta: true}", - options: {cleanMeta: true}, - runTest: function(t) { - var original= dojox.data.tests.test_ID_Data; - var store= new dojox.data.jsonPathStore({ - data: original, - mode: dojox.data.SYNC_MODE, - idAttribute: "myId", - indexOnLoad: true - }); - - //snapshot of the store after creation; - var result = store.dump(this.options); - doh.assertEqual(original, result); - } - }, - { - name: "Create, Index, Export: {type: raw}", - options: {type: "raw"}, - runTest: function(t) { - var original= dojox.data.tests.test_ID_Data; - var store= new dojox.data.jsonPathStore({ - data: original, - mode: dojox.data.SYNC_MODE, - idAttribute: "myId", - indexOnLoad: true - }); - - //snapshot of the store after creation; - var result = dojo.toJson(store.dump(this.options)); - var storeWithMeta = dojo.toJson(store._data); - doh.assertEqual(storeWithMeta, result); - } - }, - { - name: "ReadAPI: fetch() Empty Request Test [SYNC_MODE]", - runTest: function(t) { - var store= new dojox.data.jsonPathStore({data:dojox.data.tests.testData, mode: dojox.data.SYNC_MODE}); - var success = dojo.toJson([{"book": [{"category": "reference", "author": "Nigel Rees", "title": "Sayings of the Century", "price": 8.95, "_meta": {"path": "$['store']['book'][0]", "autoId": true, "referenceIds": ["_ref_1"]}, "_id": "_auto_3"}, {"category": "fiction", "author": "Evelyn Waugh", "title": "Sword of Honour", "price": 12.99, "_meta": {"path": "$['store']['book'][1]", "autoId": true, "referenceIds": ["_ref_2"]}, "_id": "_auto_4"}, {"category": "fiction", "author": "Herman Melville", "title": "Moby Dick", "isbn": "0-553-21311-3", "price": 8.99, "_meta": {"path": "$['store']['book'][2]", "autoId": true, "referenceIds": ["_ref_3"]}, "_id": "_auto_5"}, {"category": "fiction", "author": "J. R. R. Tolkien", "title": "The Lord of the Rings", "isbn": "0-395-19395-8", "price": 22.99, "_meta": {"path": "$['store']['book'][3]", "autoId": true, "referenceIds": ["_ref_4"]}, "_id": "_auto_6"}], "bicycle": {"color": "red", "price": 19.95, "_meta": {"path": "$['store']['bicycle']", "autoId": true, "referenceIds": ["_ref_5"]}, "_id": "_auto_2"}, "_meta": {"path": "$['store']", "autoId": true, "referenceIds": ["_ref_0"]}, "_id": "_auto_0"}, [{"category": "reference", "author": "Nigel Rees", "title": "Sayings of the Century", "price": 8.95, "_meta": {"path": "$['store']['book'][0]", "autoId": true, "referenceIds": ["_ref_1"]}, "_id": "_auto_3"}, {"category": "fiction", "author": "Evelyn Waugh", "title": "Sword of Honour", "price": 12.99, "_meta": {"path": "$['store']['book'][1]", "autoId": true, "referenceIds": ["_ref_2"]}, "_id": "_auto_4"}, {"category": "fiction", "author": "Herman Melville", "title": "Moby Dick", "isbn": "0-553-21311-3", "price": 8.99, "_meta": {"path": "$['store']['book'][2]", "autoId": true, "referenceIds": ["_ref_3"]}, "_id": "_auto_5"}, {"category": "fiction", "author": "J. R. R. Tolkien", "title": "The Lord of the Rings", "isbn": "0-395-19395-8", "price": 22.99, "_meta": {"path": "$['store']['book'][3]", "autoId": true, "referenceIds": ["_ref_4"]}, "_id": "_auto_6"}], {"color": "red", "price": 19.95, "_meta": {"path": "$['store']['bicycle']", "autoId": true, "referenceIds": ["_ref_5"]}, "_id": "_auto_2"}, {"category": "reference", "author": "Nigel Rees", "title": "Sayings of the Century", "price": 8.95, "_meta": {"path": "$['store']['book'][0]", "autoId": true, "referenceIds": ["_ref_1"]}, "_id": "_auto_3"}, {"category": "fiction", "author": "Evelyn Waugh", "title": "Sword of Honour", "price": 12.99, "_meta": {"path": "$['store']['book'][1]", "autoId": true, "referenceIds": ["_ref_2"]}, "_id": "_auto_4"}, {"category": "fiction", "author": "Herman Melville", "title": "Moby Dick", "isbn": "0-553-21311-3", "price": 8.99, "_meta": {"path": "$['store']['book'][2]", "autoId": true, "referenceIds": ["_ref_3"]}, "_id": "_auto_5"}, {"category": "fiction", "author": "J. R. R. Tolkien", "title": "The Lord of the Rings", "isbn": "0-395-19395-8", "price": 22.99, "_meta": {"path": "$['store']['book'][3]", "autoId": true, "referenceIds": ["_ref_4"]}, "_id": "_auto_6"}]); - var result = dojo.toJson(store.fetch()); - doh.assertEqual(success, result); - return true; - } - }, - - { - name: "ReadAPI: fetch('$.store.book[*]') test [SYNC_MODE]", - runTest: function(t) { - var store= new dojox.data.jsonPathStore({data:dojox.data.tests.testData, mode: dojox.data.SYNC_MODE}); - var success = dojo.toJson([{"category": "reference", "author": "Nigel Rees", "title": "Sayings of the Century", "price": 8.95, "_meta": {"path": "$['store']['book'][0]", "autoId": true, "referenceIds": ["_ref_1"]}, "_id": "_auto_3"}, {"category": "fiction", "author": "Evelyn Waugh", "title": "Sword of Honour", "price": 12.99, "_meta": {"path": "$['store']['book'][1]", "autoId": true, "referenceIds": ["_ref_2"]}, "_id": "_auto_4"}, {"category": "fiction", "author": "Herman Melville", "title": "Moby Dick", "isbn": "0-553-21311-3", "price": 8.99, "_meta": {"path": "$['store']['book'][2]", "autoId": true, "referenceIds": ["_ref_3"]}, "_id": "_auto_5"}, {"category": "fiction", "author": "J. R. R. Tolkien", "title": "The Lord of the Rings", "isbn": "0-395-19395-8", "price": 22.99, "_meta": {"path": "$['store']['book'][3]", "autoId": true, "referenceIds": ["_ref_4"]}, "_id": "_auto_6"}]); - var result = dojo.toJson(store.fetch({query:"$.store.book[*]"})); - doh.assertEqual(success, result); - return true; - } - }, - { - name: "ReadAPI: fetch('$.store.book[*]') test [ASYNC_MODE forced SYNC_MODE by string parameter]", - runTest: function(t) { - var store= new dojox.data.jsonPathStore({data:dojox.data.tests.testData, mode: dojox.data.ASYNC_MODE}); - var success = dojo.toJson([{"category": "reference", "author": "Nigel Rees", "title": "Sayings of the Century", "price": 8.95, "_meta": {"path": "$['store']['book'][0]", "autoId": true, "referenceIds": ["_ref_1"]}, "_id": "_auto_3"}, {"category": "fiction", "author": "Evelyn Waugh", "title": "Sword of Honour", "price": 12.99, "_meta": {"path": "$['store']['book'][1]", "autoId": true, "referenceIds": ["_ref_2"]}, "_id": "_auto_4"}, {"category": "fiction", "author": "Herman Melville", "title": "Moby Dick", "isbn": "0-553-21311-3", "price": 8.99, "_meta": {"path": "$['store']['book'][2]", "autoId": true, "referenceIds": ["_ref_3"]}, "_id": "_auto_5"}, {"category": "fiction", "author": "J. R. R. Tolkien", "title": "The Lord of the Rings", "isbn": "0-395-19395-8", "price": 22.99, "_meta": {"path": "$['store']['book'][3]", "autoId": true, "referenceIds": ["_ref_4"]}, "_id": "_auto_6"}]); - var result = dojo.toJson(store.fetch("$.store.book[*]")); - doh.assertEqual(success, result); - return true; - } - }, - { - name: "ReadAPI: fetch({query: '$.store.book[*]', start: 2})", - runTest: function(t) { - var store= new dojox.data.jsonPathStore({data:dojox.data.tests.testData, mode: dojox.data.SYNC_MODE}); - var success = dojo.toJson([{"category": "fiction", "author": "Herman Melville", "title": "Moby Dick", "isbn": "0-553-21311-3", "price": 8.99, "_meta": {"path": "$['store']['book'][2]", "autoId": true, "referenceIds": ["_ref_3"]}, "_id": "_auto_5"}, {"category": "fiction", "author": "J. R. R. Tolkien", "title": "The Lord of the Rings", "isbn": "0-395-19395-8", "price": 22.99, "_meta": {"path": "$['store']['book'][3]", "autoId": true, "referenceIds": ["_ref_4"]}, "_id": "_auto_6"}]); - var result = dojo.toJson(store.fetch({query: '$.store.book[*]', start: 2})); - doh.assertEqual(success, result); - return true; - } - }, - { - name: "ReadAPI: fetch({query: '$.store.book[*]', start: 2, count: 1})", - runTest: function(t) { - var store= new dojox.data.jsonPathStore({data:dojox.data.tests.testData, mode: dojox.data.SYNC_MODE}); - var result = store.fetch({query: "$.store.book[*]", start: 2, count: 1}); - doh.assertEqual(result[0].author, 'Herman Melville'); - return true; - } - }, - - { - name: "ReadAPI: fetch(query: '$.store.book[0]'...callbacks...) [ASYNC_MODE]", - runTest: function(datastore, t){ - var store= new dojox.data.jsonPathStore({data:dojox.data.tests.testData}); - var d = new doh.Deferred(); - function onBegin(count, args){ - doh.assertEqual(1, count); - } - function onItem(item){ - doh.assertTrue(store.isItem(item)); - } - - function onComplete(results){ - doh.assertEqual(1, results.length); - doh.assertEqual("Nigel Rees", results[0]["author"]); - d.callback(true); - } - - function onError(errData){ - t.assertTrue(false); - d.errback(errData); - } - - store.fetch({query: "$.store.book[0]", onBegin: onBegin, onItem: onItem, onError: onError, onComplete: onComplete}); - return d; // Deferred - } - }, - { - name: "ReadAPI: isItem() test", - runTest: function(t) { - var store= new dojox.data.jsonPathStore({data:dojox.data.tests.testData, mode: dojox.data.SYNC_MODE}); - var result = store.fetch("$.store.book[*].author"); - doh.assertFalse(store.isItem(result[0])); - result = store.fetch("$.store.book[*]"); - doh.assertTrue(store.isItem(result[0])); - return true; - } - }, - { - name: "ReadAPI: getValue() test", - runTest: function(t) { - var store= new dojox.data.jsonPathStore({data:dojox.data.tests.testData, mode: dojox.data.SYNC_MODE}); - var data = store.fetch("$.store.book[*]"); - var result = store.getValue(data[0], "author"); - doh.assertEqual("Nigel Rees", result); - return true; - } - }, - { - name: "ReadAPI: getValues() test", - runTest: function(t) { - var store= new dojox.data.jsonPathStore({data:dojox.data.tests.testData, mode: dojox.data.SYNC_MODE}); - var result = store.fetch("$.store.book[*]"); - doh.assertEqual(dojo.toJson(store.getValues(result[0], "author")),dojo.toJson(["Nigel Rees"])); - return true; - } - }, - { - name: "ReadAPI: getAttributes() test", - runTest: function(t) { - var store= new dojox.data.jsonPathStore({data:dojox.data.tests.testData, mode: dojox.data.SYNC_MODE}); - var result = store.fetch("$.store.book[*]"); - doh.assertEqual(dojo.toJson(store.getAttributes(result[0])),'["category","author","title","price","_meta","_id"]'); - return true; - } - }, - { - name: "ReadAPI: getAttributes() test [hideMetaAttributes]", - runTest: function(t) { - var store= new dojox.data.jsonPathStore({data:dojox.data.tests.testData, mode: dojox.data.SYNC_MODE, hideMetaAttributes: true}); - var result = store.fetch("$.store.book[*]"); - doh.assertEqual('["category","author","title","price","_id"]',dojo.toJson(store.getAttributes(result[0]))); - return true; - } - }, - { - name: "ReadAPI: hasAttribute() test", - runTest: function(t) { - var store= new dojox.data.jsonPathStore({data:dojox.data.tests.testData, mode: dojox.data.SYNC_MODE}); - var result = store.fetch("$.store.book[*]"); - doh.assertTrue(store.hasAttribute(result[0], "author")); - doh.assertFalse(store.hasAttribute(result[0],"_im_invalid_fooBar")); - return true; - } - }, - - { - name: "ReadAPI: containsValue() test", - runTest: function(t) { - var store= new dojox.data.jsonPathStore({data:dojox.data.tests.testData, mode: dojox.data.SYNC_MODE}); - var result = store.fetch("$.store.book[*]"); - doh.assertTrue(store.containsValue(result[0], "author", "Nigel Rees")); - doh.assertFalse(store.containsValue(result[0], "author", "_im_invalid_fooBar")); - return true; - } - }, - { - name: "ReadAPI: getFeatures() test", - runTest: function(t) { - var store= new dojox.data.jsonPathStore({data:dojox.data.tests.testData, mode: dojox.data.SYNC_MODE}); - //doh.debug("Store Features: ", dojo.toJson(store.getFeatures())); - var success='{"dojo.data.api.Read":true,"dojo.data.api.Identity":true,"dojo.data.api.Write":true,"dojo.data.api.Notification":true}'; - doh.assertEqual(success,dojo.toJson(store.getFeatures())); - return true; - } - }, - { - name: "ReadAPI: getLabel(item) test [multiple label attributes]", - runTest: function(t) { - var store= new dojox.data.jsonPathStore({data:dojox.data.tests.testData, mode: dojox.data.SYNC_MODE, labelAttribute: ["title", "author"]}); - var result = store.fetch("$.store.book[0]")[0]; - doh.assertEqual("Sayings of the Century Nigel Rees",store.getLabel(result)); - return true; - } - }, - { - name: "ReadAPI: getLabelAttributes(item) test [multiple label attributes]", - runTest: function(t) { - var store= new dojox.data.jsonPathStore({data:dojox.data.tests.testData, mode: dojox.data.SYNC_MODE, labelAttribute: ["title", "author"]}); - var result = store.fetch("$.store.book[0]")[0]; - doh.assertEqual('["title","author"]',dojo.toJson(store.getLabelAttributes(result))); - return true; - } - }, - { - name: "ReadAPI: getLabelAttributes(item) test [single label attribute]", - runTest: function(t) { - var store= new dojox.data.jsonPathStore({data:dojox.data.tests.testData, mode: dojox.data.SYNC_MODE, labelAttribute: ["title"]}); - var result = store.fetch("$.store.book[0]")[0]; - doh.assertEqual('["title"]',dojo.toJson(store.getLabelAttributes(result))); - return true; - } - }, - { - name: "jsonPathStore Feature: override createLabel", - runTest: function(t) { - var createLabel = function(item){ - return item[this.labelAttribute[0]] + " By " + item[this.labelAttribute[1]]; - }; - - var store= new dojox.data.jsonPathStore({data:dojox.data.tests.testData, mode: dojox.data.SYNC_MODE, labelAttribute: ["title", "author"], createLabel: createLabel}); - var result = store.fetch("$.store.book[0]")[0]; - doh.assertEqual('Sayings of the Century By Nigel Rees',store.getLabel(result)); - return true; - } - }, - { - name: "jsonPathStore Feature: autoIdentity", - runTest: function(t) { - var store= new dojox.data.jsonPathStore({data:dojox.data.tests.testData, mode: dojox.data.SYNC_MODE, idAttribute: "_id"}); - var result = dojo.toJson(store.fetch("$.store.book[0]")[0]); - var success=dojo.toJson( {"category": "reference", "author": "Nigel Rees", "title": "Sayings of the Century", "price": 8.95, "_meta": {"path": "$['store']['book'][0]", "autoId": true, "referenceIds": ["_ref_1"]}, "_id": "_auto_3"}); - doh.assertEqual(success,result); - return true; - } - }, - - { - name: "jsonPathStore Feature: autoIdentity [clean export removing added id attributes in addition to meta]", - runTest: function(t) { - var store= new dojox.data.jsonPathStore({data:dojox.data.tests.testData, mode: dojox.data.SYNC_MODE, idAttribute: "_id"}); - //do a search to popuplate some of the itesm with autoId data - var result = store.fetch("$.store.book[0]"); - result = store.dump({cleanMeta: true}); - doh.assertEqual(dojox.data.tests.testData,result); - return true; - } - }, - - { - name: "IdentityAPI: getIdentity(item)", - runTest: function(t) { - var store= new dojox.data.jsonPathStore({data:dojox.data.tests.testData, mode: dojox.data.SYNC_MODE, idAttribute: "_id"}); - var data= store.fetch("$.store.book[0]")[0]; - var result= store.getIdentity(data); - var success="_auto_3"; - doh.assertEqual(success,result); - return true; - } - }, - - { - - name: "IdentityAPI: fetchItemByIdentity(item) [SYNC_MODE]", - runTest: function(t){ - var store= new dojox.data.jsonPathStore({data:dojox.data.tests.testData, mode: dojox.data.SYNC_MODE, idAttribute: "_id"}); - - var data= store.fetch("$.store.book[0]")[0]; - var id = store.getIdentity(data); - var result = dojo.toJson(store.fetchItemByIdentity({identity:id})); - var success = dojo.toJson(data); - doh.assertEqual(success,result); - return true; - } - }, - { - - name: "jsonPathStore Feature: byId(item) [fetchItemByIdentity alias] [SYNC_MODE]", - runTest: function(t){ - var store= new dojox.data.jsonPathStore({data:dojox.data.tests.testData, mode: dojox.data.SYNC_MODE, idAttribute: "_id"}); - - var data= store.fetch("$.store.book[0]")[0]; - var id = store.getIdentity(data); - var result = dojo.toJson(store.byId({identity:id})); - var success = dojo.toJson(data); - doh.assertEqual(success,result); - return true; - } - }, - - { - name: "IdentityAPI: fetchItemByIdentity(id) single Item [ASYNC_MODE]", - timeout: 1000, - runTest: function(datastore, t){ - // summary: - // Simple test of the fetchItemByIdentity function of the store. - var store= new dojox.data.jsonPathStore({data:dojox.data.tests.testData, indexOnLoad: true}); - var d = new doh.Deferred(); - var query = {query: "$.store.book[0]", mode: dojox.data.SYNC_MODE}; - var data = store.fetch(query)[0]; - var id = store.getIdentity(data); - - function onItem(item){ - doh.assertTrue(store.isItem(item)); - doh.assertEqual(data["author"], item["author"]); - d.callback(true); - } - - function onError(errData){ - - t.assertTrue(false); - d.errback(errData); - } - - store.fetchItemByIdentity({identity: id, onItem: onItem, onError: onError}); - - return d; // Deferred - } - }, - { - name: "IdentityAPI: getIdentityAttributes(item) ", - runTest: function(t) { - var store= new dojox.data.jsonPathStore({data:dojox.data.tests.testData, mode: dojox.data.SYNC_MODE, idAttribute: "_id"}); - var data= store.fetch("$.store.book[0]")[0]; - var result = dojo.toJson(store.getIdentityAttributes(data)); - var success = '["_id"]'; - doh.assertEqual(success,result); - return true; - } - }, - { - name: "WriteAPI: newItem(item) add to store root.", - runTest: function(t) { - var original = dojox.data.tests.testData; - var store= new dojox.data.jsonPathStore({data:original, mode: dojox.data.SYNC_MODE, idAttribute: "_id"}); - - var testObject = { - propA: "foo", - propB: "bar" - } - - var testObject2 = { - propA: "foo", - propB: "bar" - } - - var newItem = store.newItem(testObject); - doh.assertTrue(store.isItem(newItem)); - - newItem = store.newItem(testObject2); - doh.assertTrue(store.isItem(newItem)); - - return true; - } - }, - { - name: "WriteAPI: newItem(item) no idAttribute on data item, added only with pInfo", - runTest: function(t) { - var original = dojox.data.tests.testData; - var store= new dojox.data.jsonPathStore({data:original, mode: dojox.data.SYNC_MODE}); - - var parentItem = store.fetch("$.store.book[0]")[0]; - - var testObject = { - propA: "foo", - propB: "bar" - } - - var newItem = store.newItem(testObject,{parent: parentItem, attribute: "TEST_PROPERTY"}); - doh.assertTrue(store.isItem(newItem)); - return true; - } - }, - { - name: "WriteAPI: newItem(item) given id, no parent Attribute", - runTest: function(t) { - var original = dojox.data.tests.testData; - var store= new dojox.data.jsonPathStore({data:original, mode: dojox.data.SYNC_MODE, idAttribute: "_id"}); - - var parentItem = store.fetch("$.store.book[0]")[0]; - - var testObject = { - _id: "99999", - propA: "foo", - propB: "bar" - } - - var newItem = store.newItem(testObject,{parent: parentItem}); - doh.assertTrue(store.isItem(newItem)); - return true; - } - }, - { - name: "WriteAPI: newItem(item) given id and parent Attribute", - runTest: function(t) { - var original = dojox.data.tests.testData; - var store= new dojox.data.jsonPathStore({data:original, mode: dojox.data.SYNC_MODE, idAttribute: "_id"}); - - var parentItem = store.fetch("$.store.book[0]")[0]; - - var testObject = { - _id: "99999", - propA: "foo", - propB: "bar" - } - - var newItem = store.newItem(testObject,{parent: parentItem, attribute: "TEST"}); - doh.assertTrue(store.isItem(newItem)); - return true; - } - }, - { - name: "WriteAPI: newItem(item) adding to an array", - runTest: function(t) { - var original = dojox.data.tests.testData; - var store= new dojox.data.jsonPathStore({data:original, mode: dojox.data.SYNC_MODE, idAttribute: "_id"}); - - var parentItem = store.fetch("$.store")[0]; - - var testObject = { - _id: "99999", - propA: "foo", - propB: "bar" - } - - var newItem = store.newItem(testObject,{parent: parentItem, attribute: "book"}); - doh.assertTrue(store.isItem(newItem)); - return true; - } - }, - { - name: "WriteAPI: setValue(item, value)", - runTest: function(t) { - var original = dojox.data.tests.testData; - var store= new dojox.data.jsonPathStore({data:original, mode: dojox.data.SYNC_MODE, indexOnLoad: true, idAttribute: "_id"}); - var item = store.fetch("$.store")[0]; - - var snapshot = store.dump({clone:true, cleanMeta: false, suppressExportMeta: true}); - - store.setValue(item, "Foo", "Bar"); - doh.assertEqual(store._data.store.Foo, "Bar"); - doh.assertTrue(store._data.store._meta.isDirty); - store.save(); - doh.assertFalse(store._data.store._meta.isDirty); - return true; - } - }, - { - name: "WriteAPI: setValues(item, value)", - runTest: function(t) { - var original = dojox.data.tests.testData; - var store= new dojox.data.jsonPathStore({data:original, mode: dojox.data.SYNC_MODE, indexOnLoad: true, idAttribute: "_id"}); - var item = store.fetch("$.store")[0]; - - var snapshot = store.dump({clone:true, cleanMeta: false, suppressExportMeta: true}); - - store.setValues(item, "Foo", ["Bar", "Diddly", "Ar"]); - doh.assertEqual(store._data.store.Foo[0], "Bar"); - doh.assertEqual(store._data.store.Foo.length, 3); - doh.assertTrue(store._data.store._meta.isDirty); - store.save(); - doh.assertFalse(store._data.store._meta.isDirty); - return true; - } - }, - { - name: "WriteAPI: unsetAttribute(item, attribute)", - runTest: function(t) { - var original = dojox.data.tests.testData; - var store= new dojox.data.jsonPathStore({data:original, mode: dojox.data.SYNC_MODE, indexOnLoad: true, idAttribute: "_id"}); - var item = store.fetch("$.store")[0]; - - var snapshot = store.dump({clone:true, cleanMeta: false, suppressExportMeta: true}); - - store.setValues(item, "Foo", ["Bar", "Diddly", "Ar"]); - doh.assertEqual(store._data.store.Foo[0], "Bar"); - doh.assertEqual(store._data.store.Foo.length, 3); - doh.assertTrue(store._data.store._meta.isDirty); - store.save(); - doh.assertFalse(store._data.store._meta.isDirty); - store.unsetAttribute(item,"Foo"); - doh.assertFalse(item.Foo); - doh.assertTrue(store._data.store._meta.isDirty); - store.save(); - doh.assertFalse(store._data.store._meta.isDirty); - return true; - } - }, - { - name: "WriteAPI: revert()", - runTest: function(t) { - var original = dojox.data.tests.testData; - var store= new dojox.data.jsonPathStore({data:original, mode: dojox.data.SYNC_MODE, indexOnLoad: true, idAttribute: "_id"}); - var item = store.fetch("$.store")[0]; - - var snapshot = store.dump({clone:true, cleanMeta: false, suppressExportMeta: true}); - - store.setValues(item, "Foo", ["Bar", "Diddly", "Ar"]); - doh.assertEqual(store._data.store.Foo[0], "Bar"); - doh.assertEqual(store._data.store.Foo.length, 3); - doh.assertTrue(store._data.store._meta.isDirty); - store.revert(); - doh.assertFalse(store._data.store._meta.isDirty); - doh.assertFalse(store._data.store.Foo); - return true; - } - } - ] -); - -} diff --git a/includes/js/dojox/data/tests/stores/movies.csv b/includes/js/dojox/data/tests/stores/movies.csv deleted file mode 100644 index baf71eb..0000000 --- a/includes/js/dojox/data/tests/stores/movies.csv +++ /dev/null @@ -1,9 +0,0 @@ -Title, Year, Producer -City of God, 2002, Katia Lund -Rain,, Christine Jeffs -2001: A Space Odyssey, , Stanley Kubrick -"This is a ""fake"" movie title", 1957, Sidney Lumet -Alien, 1979 , Ridley Scott -"The Sequel to ""Dances With Wolves.""", 1982, Ridley Scott -"Caine Mutiny, The", 1954, "Dymtryk ""the King"", Edward" - diff --git a/includes/js/dojox/data/tests/stores/movies2.csv b/includes/js/dojox/data/tests/stores/movies2.csv deleted file mode 100644 index 401bcfc..0000000 --- a/includes/js/dojox/data/tests/stores/movies2.csv +++ /dev/null @@ -1,9 +0,0 @@ -Title, Year, Producer -City of God, 2002, Katia Lund -Rain,"", Christine Jeffs -2001: A Space Odyssey, , Stanley Kubrick -"This is a ""fake"" movie title", 1957, Sidney Lumet -Alien, 1979 , Ridley Scott -"The Sequel to ""Dances With Wolves.""", 1982, Ridley Scott -"Caine Mutiny, The", 1954, "Dymtryk ""the King"", Edward" - diff --git a/includes/js/dojox/data/tests/stores/patterns.csv b/includes/js/dojox/data/tests/stores/patterns.csv deleted file mode 100644 index a9bee64..0000000 --- a/includes/js/dojox/data/tests/stores/patterns.csv +++ /dev/null @@ -1,11 +0,0 @@ -uniqueId, value -9, jfq4@#!$!@Rf14r14i5u -6, BaBaMaSaRa***Foo -2, bar*foo -8, 123abc -4, bit$Bite -3, 123abc -10, 123abcdefg -1, foo*bar -7, -5, 123abc diff --git a/includes/js/dojox/data/tests/stores/properties.js b/includes/js/dojox/data/tests/stores/properties.js deleted file mode 100644 index bbdd38d..0000000 --- a/includes/js/dojox/data/tests/stores/properties.js +++ /dev/null @@ -1,10 +0,0 @@ -/*[ - // Properties of December 1, 2007 - { "year": "2007" }, - { "nmonth": "12" }, - { "month": "December" }, - { "nday": "1" }, - { "day": "Saturday" }, - { "dayOfYear": "335" }, - { "weekOfYear": "48" } -]*/ diff --git a/includes/js/dojox/data/tests/stores/snap_pipeline.php b/includes/js/dojox/data/tests/stores/snap_pipeline.php deleted file mode 100644 index a7e6033..0000000 --- a/includes/js/dojox/data/tests/stores/snap_pipeline.php +++ /dev/null @@ -1,72 +0,0 @@ -= count($rows) || $limit < 0) { - header("HTTP/1.1 400 Bad Request"); - echo "sn.start and/or sn.limit out of range"; - exit(0); - } - - $slice = array_slice($rows, $start, $limit); - - header("Content-type: application/javascript"); - echo $prefix . "(["; - - $out_rows = array("[" . join(", ", $field_names) . "]"); - foreach($slice as $r) { - $out_rows[] = "[" . join(", ", $r) . "]"; - } - - echo join(", ", $out_rows); - echo "])"; - } - -?> - -- cgit v1.2.3