http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/4621d41c/JSLib/tests/odata-xml-tests.js ---------------------------------------------------------------------- diff --git a/JSLib/tests/odata-xml-tests.js b/JSLib/tests/odata-xml-tests.js deleted file mode 100644 index 9eb936e..0000000 --- a/JSLib/tests/odata-xml-tests.js +++ /dev/null @@ -1,259 +0,0 @@ -/// <reference path="../src/odata-xml.js" /> -/// <reference path="common/djstest.js" /> - -// odata-xml-tests.js - -(function (window, undefined) { - - // DATAJS INTERNAL START - - djstest.addTest(function getURIInfoTest() { - var tests = [ - { input: "https://host.com:8080/path1/path2?p1=1&p2=2#fragment", expected: { scheme: "https:", authority: "//host.com:8080", path: "/path1/path2", query: "?p1=1&p2=2", fragment: "#fragment", isAbsolute: true} }, - { input: "http://host.com:8080/path1/path2?p1=1&p2=2#fragment", expected: { scheme: "http:", authority: "//host.com:8080", path: "/path1/path2", query: "?p1=1&p2=2", fragment: "#fragment", isAbsolute: true} }, - { input: "https:", expected: { scheme: "https:", isAbsolute: true} }, - { input: "http:", expected: { scheme: "http:", isAbsolute: true} }, - { input: "//host.com", expected: { authority: "//host.com", isAbsolute: false} }, - { input: "path1", expected: { path: "path1", isAbsolute: false} }, - { input: "?query", expected: { query: "?query", isAbsolute: false} }, - { input: "#fragment", expected: { fragment: "#fragment", isAbsolute: false} }, - { input: undefined, expected: { isAbsolute: false} }, - { input: "", expected: { isAbsolute: false} }, - { input: null, expected: { isAbsolute: false} } - ]; - - var i, len; - for (i = 0, len = tests.length; i < len; i++) { - var actual = odatajs.getURIInfo(tests[i].input); - djstest.assertAreEqualDeep(actual, tests[i].expected, "test " + i + "didn't return the expected URI parts"); - } - djstest.done(); - }); - - djstest.addTest(function normalizeURICaseTest() { - var tests = [ - { uri: "hTTp://HOST.com/path1/Path2/PATH3?Query1=x&query2=Y#Fragment", expected: "http://host.com/path1/Path2/PATH3?Query1=x&query2=Y#Fragment" }, - { uri: "http://fabrikam%20user%[email protected]:5895/Path%3A%201?q1=hi%20%3Ato%20you", expected: "http://fabrikam%20user%[email protected]:5895/Path%3a%201?q1=hi%20%3ato%20you" }, - { uri: "/PATH1/PATH2?P1=AbC#fraGment", expected: "/PATH1/PATH2?P1=AbC#fraGment" }, - { uri: "HttP://" + encodeURIComponent("FTP://www.example.com&story=breaking_news:[email protected]:5678/"), expected: "http://" + encodeURIComponent("FTP://www.example.com&story=breaking_news:[email protected]:5678/").toLowerCase() } - ]; - - var i, len; - for (i = 0, len = tests.length; i < len; i++) { - var actual = odatajs.normalizeURICase(tests[i].uri, tests[i].base); - djstest.assertAreEqual(actual, tests[i].expected, "test " + i + "didn't return the expected URI"); - } - djstest.done(); - }); - - djstest.addTest(function normalizeURITest() { - var tests = [ - { uri: "http://host.com/path1#fragment", base: "http://base", expected: "http://host.com/path1#fragment" }, - { uri: "//host.com/path1?p1=0", base: "http://base?p2=1", expected: "http://host.com/path1?p1=0" }, - { uri: "?p1=0#fragment", base: "http://base/basepath", expected: "http://base/basepath?p1=0#fragment" }, - { uri: "?p1=0#fragment", base: "http://base/basepath?p2=1", expected: "http://base/basepath?p1=0#fragment" }, - { uri: "#fragment", base: "http://base/basepath?p2=1", expected: "http://base/basepath?p2=1#fragment" }, - { uri: "/path1/path2?p1=0", base: "http://base/basePath", expected: "http://base/path1/path2?p1=0" }, - { uri: "path1/path2?p1=0", base: "http://base/basepath", expected: "http://base/path1/path2?p1=0" }, - { uri: "path1/path2?p1=0", base: "http://base/basepath/basepath2", expected: "http://base/basepath/path1/path2?p1=0" }, - { uri: "", base: "http://base/basepath?p1=0#fragment", expected: "http://base/basepath?p1=0" }, - { uri: "path1/path2?p1=0", base: "", expected: "path1/path2?p1=0" }, - { uri: "/a/b/c/./../../g", base: "http://base/basepath", expected: "http://base/a/g" }, - { uri: "a/b/c/././../../g", base: "http://base/basepath/", expected: "http://base/basepath/a/g" }, - { uri: "../a/b/c/././../../g", base: "http://base/basepath/", expected: "http://base/a/g" }, - { uri: "./a/b/c/././../../g", base: "http://base/basepath/", expected: "http://base/basepath/a/g" }, - { uri: "/../a/b/c/././../../g", base: "http://base/basepath/", expected: "http://base/a/g" }, - { uri: "/./a/b/c/././../../g", base: "http://base/basepath/", expected: "http://base/a/g" } - ]; - - var i, len; - for (i = 0, len = tests.length; i < len; i++) { - var actual = odatajs.normalizeURI(tests[i].uri, tests[i].base); - djstest.assertAreEqual(actual, tests[i].expected, "test " + i + "didn't return the expected normalized URI"); - } - djstest.done(); - }); - - djstest.addTest(function xmlParseTest() { - var xml = '<root xmlns:n1="http://namespace1" xml:base="http://base.org" />'; - var root = odatajs.xmlParse(xml); - djstest.assert(root, "xml._parse didn't return a xml dom object"); - djstest.done(); - }); - - djstest.addTest(function xmlbaseURITest() { - var xml = "\ - <root xmlns:n1=\"http://namespace1\" \r\n\ - xml:base=\"http://base.org\"> \r\n\ - <element base=\"this is not a xml base attribute\" /> \r\n\ - </root>\r\n"; - - var doc = odatajs.xmlParse(xml); - var root = odatajs.xmlFirstChildElement(doc); - var child = odatajs.xmlFirstChildElement(root); - - djstest.assertAreEqual(odatajs.xmlBaseURI(root), "http://base.org", "xml._baseURI didn't return the expected value"); - djstest.assert(!odatajs.xmlBaseURI(child), "xml._baseURI returned a value when it wasn't expected"); - djstest.done(); - }); - - djstest.addTest(function xmlAttributeValueTest() { - var xml = "\ - <root xmlns:n1=\"http://namespace1\" \r\n\ - xml:base=\"http://base.org\"> \r\n\ - <element attribute=\"value\" n1:nsAttribute=\"nsValue\" /> \r\n\ - </root> \r\n"; - - var doc = odatajs.xmlParse(xml); - var root = odatajs.xmlFirstChildElement(doc); - var child = odatajs.xmlFirstChildElement(root); - - djstest.assertAreEqual(odatajs.xmlAttributeValue(child, "attribute"), "value", "xml._attribute didn't return the expected value for attribute"); - djstest.assertAreEqual(odatajs.xmlAttributeValue(child, "nsAttribute", "http://namespace1"), "nsValue", "xml._attribute didn't return the expected value for nsAttribute"); - djstest.assert(!odatajs.xmlAttributeValue(child, "nsAttribute"), "xml._attribute returned a value for nsAttribute without specifying a namespace"); - - djstest.done(); - }); - - djstest.addTest(function xmlLocalNameTest() { - var xml = "<root xmlns:n1=\"http://namespace1\" /> \r\n"; - - var doc = odatajs.xmlParse(xml); - var root = odatajs.xmlFirstChildElement(doc); - - djstest.assertAreEqual(odatajs.xmlLocalName(root), "root", "xml._localName didn't return the expected localName of the root element"); - djstest.done(); - }); - - djstest.addTest(function xmlFirstChildElement() { - var xml = "\ - <root xmlns:n1=\"http://namespace1\" \r\n\ - xml:base=\"http://base.org\"> \r\n\ - <element1 /> \r\n\ - <element2 /> \r\n\ - </root>\r\n"; - - - var doc = odatajs.xmlParse(xml); - var root = odatajs.xmlFirstChildElement(doc); - var child = odatajs.xmlFirstChildElement(root); - - djstest.assertAreEqual(odatajs.xmlLocalName(child), "element1", "xml.firstElement returned didn't return the expected element"); - djstest.done(); - }); - - djstest.addTest(function xmlChildElementsTest() { - var xml = "\ - <root xmlns:n1=\"http://namespace1\" \r\n\ - xml:base=\"http://base.org\"> \r\n\ - <element1 /> \r\n\ - <element2 xml:base=\"http://otherBase.org\" /> \r\n\ - <n1:element3 xml:base=\"path1/path2\" /> \r\n\ - </root>\r\n"; - - var expected = [ - { localName: "element1", nsURI: null }, - { localName: "element2", nsURI: null }, - { localName: "element3", nsURI: "http://namespace1" } - ]; - - var actual = []; - - var doc = odatajs.xmlParse(xml); - var root = odatajs.xmlFirstChildElement(doc); - - odatajs.xmlChildElements(root, function (child) { - djstest.log("in child elements callback"); - actual.push({ - localName: odatajs.xmlLocalName(child), - nsURI: odatajs.xmlNamespaceURI(child) - }); - }); - - djstest.assertAreEqualDeep(actual, expected, "xml.childElements didn't return the expected elements"); - djstest.done(); - }); - - djstest.addTest(function xmlAttributesTest() { - var xml = "\ - <root xmlns:n1=\"http://namespace1\" \r\n\ - xml:base=\"http://base.org\" \r\n\ - attribute=\"value\" \r\n\ - n1:nsAttribute=\"nsValue\" />\r\n"; - - var expected = { - n1: { localName: "n1", nsURI: "http://www.w3.org/2000/xmlns/", value: "http://namespace1" }, - base: { localName: "base", nsURI: "http://www.w3.org/XML/1998/namespace", value: "http://base.org" }, - attribute: { localName: "attribute", nsURI: null, value: "value" }, - nsAttribute: { localName: "nsAttribute", nsURI: "http://namespace1", value: "nsValue" } - }; - - var actual = {}; - - var doc = odatajs.xmlParse(xml); - var root = odatajs.xmlFirstChildElement(doc); - - odatajs.xmlAttributes(root, function (attribute) { - djstest.log("in child elements callback"); - var localName = odatajs.xmlLocalName(attribute); - actual[localName] = { - localName: localName, - nsURI: odatajs.xmlNamespaceURI(attribute), - value: attribute.value - }; - }); - - djstest.assertAreEqualDeep(actual, expected, "xml.attributes returned didn't return the expected attributes"); - djstest.done(); - }); - - djstest.addTest(function hasLeadingOrTrailingWhitespaceTest() { - // tests are in text / expected format. - var tests = [ - { t: "", r: false }, - { t: " ", r: true }, - { t: "text", r: false }, - { t: "text with spaces", r: false }, - { t: "not \r\n really", r: false }, - { t: " at start", r: true }, - { t: "at end ", r: true }, - { t: "end\r", r: true }, - { t: "end\n", r: true }, - { t: "end\r\n", r: true } - ]; - - var i, len; - for (i = 0, len = tests.length; i < len; i++) { - var result = odatajs.hasLeadingOrTrailingWhitespace(tests[i].t); - djstest.assertAreEqual(result, tests[i].r, "match for " + tests[i].t); - } - - djstest.done(); - }); - - djstest.addTest(function xmlInnerTextTest() { - // Tests are in test / expected format. - var tests = [ - { t: "<t>text</t>", r: "text" }, - { t: "<t>text with a <![CDATA[cdata block]]></t>", r: "text with a cdata block" }, - { t: "<t> text </t>", r: " text " }, - { t: "<t> </t>", r: null }, - { t: "<t> <b>text</b> </t>", r: null }, - { t: "<t> preceding</t>", r: " preceding" }, - { t: "<t xml:space='preserve'> <b>text</b> </t>", r: " " }, - { t: "<t xml:space='default'> <b>text</b> </t>", r: null} - ]; - - var i, len; - for (i = 0, len = tests.length; i < len; i++) { - var test = tests[i]; - var doc = odatajs.xmlParse(test.t); - var actual = odatajs.xmlInnerText(doc); - djstest.assertAreEqual(actual, test.r, "test for [" + test.t + "]"); - } - - djstest.done(); - }); - - // DATAJS INTERNAL END -})(this);
http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/4621d41c/JSLib/tests/run-tests.wsf ---------------------------------------------------------------------- diff --git a/JSLib/tests/run-tests.wsf b/JSLib/tests/run-tests.wsf deleted file mode 100644 index 26d954d..0000000 --- a/JSLib/tests/run-tests.wsf +++ /dev/null @@ -1,427 +0,0 @@ -<!-- -Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation -files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, -modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ---> -<job> - <runtime> - <description>Test driver for running datajs tests - run from the same directory as the script</description> - <comment> - Result codes: - 0 - success - 1 - failed to launch tests - 2 - tests failed - </comment> - </runtime> - <script language="JScript" src="test-list.js" /> - <script language="JScript"> - - var exitCode; - var fso = WScript.CreateObject("Scripting.FileSystemObject"); - var shell = WScript.CreateObject("WScript.Shell"); - - function attempt(action, interval, maxAttempts) { - /// <summary>Attempt an action at an interval, optionally for a maximum number of attempts</summary> - /// <param name="action">Action callback; should return boolean whether it succeeded</param> - /// <param name="interval">Interval (milliseconds) between attempts</param> - /// <param name="maxAttempts">(Optional) Maximum number of attempts. Infinite if undefined.</param> - /// <returns>Whether the action succeeded</returns> - var done = false; - var attempts = 0; - while (!done) { - var success = action(); - if (maxAttempts !== undefined) { - attempts++; - } - done = success === true || (maxAttempts !== undefined && attempts >= maxAttempts); - if (!done) { - WScript.Sleep(interval); - } - } - - return success; - } - - function parseJson(text) { - /// <summary>Parses a JSON document, removes the 'd' wrapper.</summary> - try { - return eval("(" + text + ")").d; - } catch (e) { - throw { message: "Error parsing JSON: [" + text + "]" }; - } - } - - function SaveTextToFile(content, path) { - /// <summary>Saves text content into a file.</summary> - /// <param name="content" type="String">Content to save.</param> - /// <param name="path" type="String">Path of file to save into.</param> - var ForReading = 1, ForWriting = 2; - var file = fso.OpenTextFile(path, ForWriting, true, -1 /* open as unicode */); - file.Write(content); - file.Close(); - } - - function GetUrlSync(url) { - var xhr; - xhr = WScript.CreateObject("Msxml2.ServerXMLHTTP.6.0"); - xhr.open("GET", url, false); - xhr.send(); - return xhr.responseText; - } - - function LaunchBrowser(browsers, serviceRoot, followingPages, url, testRunId, outputDirectory) { - /// <summary>Launches a browsers and waits until the service tells us the run is complete.</summary> - /// <param name="browsers">Browsers to run.</param> - /// <param name="serviceRoot" type="String">Root URL of the logging service.</param> - /// <param name="followingPages" type="Array">Array of pages that should follow the given url.</param> - /// <param name="url" type="String">URL of the page to start the browser on.</param> - /// <param name="testRunId" type="String">ID of the test run being monitored.</param> - /// <param name="outputDirectory" type="String">Directory in which to output screenshots.</param> - - for (browserName in browsers) { - var xhr; - var markInProgressUrl = serviceRoot + "MarkInProgress?testRunId=" + testRunId; - GetUrlSync(markInProgressUrl); - - // Add all the pages that follow the given URL. - if (followingPages && followingPages.length > 0) { - var addFilesUrl = serviceRoot + "AddTestPages?testRunId=" + testRunId + "&pages=" + followingPages.join(); - GetUrlSync(addFilesUrl); - } - - var setPrefixUrl = serviceRoot + "SetTestNamePrefix?testRunId=" + testRunId + "&prefix=" + browserName + "-"; - GetUrlSync(setPrefixUrl); - - exitCode = 0; - var response; - - // Only the first location found from the browsers array is used. If none of the listed locations of the browser exist and the browser argument was - // explicitly used then an exception is thrown. - var browserFound = false; - for (var i = 0; i < browsers[browserName].length && !browserFound; i++) { - var path = shell.ExpandEnvironmentStrings(browsers[browserName][i]); - if (fso.FileExists(path)) { - browserFound = true; - - WScript.Echo("Navigating to " + url + " with " + path); - var browser = shell.Exec("\"" + path + "\" " + url); - - var checkRunUrl = serviceRoot + "IsTestRunInProgress?testRunId=" + testRunId; - WScript.Echo("Monitoring status on " + checkRunUrl); - - var interval = 2000; - var maxAttempts = WScript.Arguments.Named.Exists("timeout") ? Math.floor((WScript.Arguments.Named.Item("timeout") / interval) * 1000) : undefined; - var success = attempt(function () { - return parseJson(GetUrlSync(checkRunUrl)) !== true; - }, interval, maxAttempts); - if (!success) { - WScript.Echo("Timed out waiting for test to complete"); - exitCode = 2; - } - - RunCommand("taskkill.exe /pid " + browser.ProcessID, true); - } - } - - // If the "/browsers" argument was explicitly used and all location have been checked, then throw an exception. - if (!browserFound) { - var message = "Unable to find browser at: " + path; - if (WScript.Arguments.Named.Exists("browsers")) { - throw { message: message }; - } else { - WScript.Echo(message); - } - } - } - } - - function WriteTestRunResults(serviceRoot, testRunId, outputDirectory) { - /// <summary>Writes the results of the test run to disk and updates the overall status.</summary> - /// <param name="serviceRoot" type="String">Root URL of the logging service.</param> - /// <param name="testRunId" type="String">ID of the test run being monitored.</param> - /// <param name="outputDirectory" type="String">Directory in which to write test result files.</param> - - var getResultsUrl = serviceRoot + "GetTestRunResults?testRunId=" + testRunId; - WScript.Echo("Querying " + getResultsUrl); - - var response = GetUrlSync(getResultsUrl); - - var resultsPath = outputDirectory + "\\results.trx"; - WScript.Echo("Writing results.trx file to " + resultsPath); - SaveTextToFile(response, resultsPath); - - var xml = new ActiveXObject("Msxml2.DOMDocument.6.0"); - xml.loadXML(response); - xml.setProperty("SelectionNamespaces", "xmlns:trx='http://microsoft.com/schemas/VisualStudio/TeamTest/2010'"); - xml.setProperty("SelectionLanguage", "XPath"); - var resultNode = xml.selectSingleNode("/trx:TestRun/trx:ResultSummary"); - if (resultNode === null) { - throw { message: "Unable to find results summary" }; - } - - var outcome = resultNode.getAttribute("outcome"); - if (outcome !== "Passed") { - WScript.Echo("Outcome: " + outcome); - var failedTests = xml.selectNodes("/trx:TestRun/trx:Results/trx:UnitTestResult[@outcome != 'Passed']/@testName"); - for (var i = 0; i < failedTests.length; i++) { - WScript.Echo(" Failed test: " + failedTests[i].value); - } - exitCode = 2; - } else { - WScript.Echo("All tests passed."); - } - } - - function CheckUrl(url) { - var xhr = WScript.CreateObject("Msxml2.ServerXMLHTTP.6.0"); - xhr.open("GET", url, false); - var success = false; - try { - xhr.send(); - success = (xhr.status === 200); - if (!success) { - WScript.Echo("status: " + xhr.status + " - " + xhr.statusText); - } - } catch (err) { - WScript.Echo("error: " + err.message); - } - - return success; - } - - function ExpandWildcard(path) { - var wcRegEx = /\\\*\*?\\/; - var wcMatch = wcRegEx.exec(path); - - var paths = []; - if (wcMatch !== null) { - var recursive = wcMatch[0] === "\\**\\"; - var basePath = path.substring(0, wcMatch.index); - var relativePath = path.substring(wcMatch.index + wcMatch[0].length); - - if (fso.FolderExists(basePath)) { - var folder = fso.GetFolder(basePath); - var subFolders = new Enumerator(folder.SubFolders); - - paths = paths.concat(ExpandWildcard(basePath + "\\" + relativePath)); - - for (; !subFolders.atEnd(); subFolders.moveNext()) { - var expandedPath = subFolders.item().Path + "\\" - if (recursive) { - expandedPath += "**\\"; - } - expandedPath += path.substring(wcMatch.index + wcMatch[0].length); - paths = paths.concat(ExpandWildcard(expandedPath)); - } - } - } else { - paths.push(path); - } - return paths; - } - - function FindFirstPath(candidates) { - /// <summary>Finds the first path present from a candidate list.</summary> - /// <param name="candidates" type="Array">Array of paths (possibly with environment variables).</param> - /// <returns type="String">The first folder on disk found; null if none are present.</returns> - - var paths = []; - - for (var i = 0; i < candidates.length; i++) { - var path = shell.ExpandEnvironmentStrings(candidates[i]); - paths = paths.concat(ExpandWildcard(path)); - } - - for (var i = 0; i < paths.length; i++) { - if (fso.FolderExists(paths[i]) || fso.FileExists(paths[i])) { - return paths[i]; - } - } - return null; - } - - function RunCommand(command, waitForExit, expectedExitCode) { - /// <summary>Runs a command or program</summary> - /// <param name="command" type="String">Command to run</param> - /// <param name="waitForExit" type="Boolean">Whether to wait for program to exit</param> - /// <param name="expectedExitCode" type="Integer">If waitForExit is true, throw if the exit code is not expected</param> - /// <returns type="Integer">The exitcode if waitForExit is true; always 0 if waitForExit is false</returns> - WScript.Echo("[cmd] " + command); - var exitCode = shell.Run(command, 0, waitForExit); - if (expectedExitCode !== undefined && exitCode !== expectedExitCode) { - throw { message: "Process exited with unexpected exit code. (Expected: " + expectedExitCode + ", Actual: " + exitCode + ")" }; - } else { - return exitCode; - } - } - - function SetupWebDevServer() { - /// <summary>Starts up IIS Express if it's not running.</summary> - /// <returns type="String">The URL to the server root.</returns> - var siteName = "DataJS Development Site"; - var appName = "datajs"; - var port = "8989"; - var result = "http://" + shell.ExpandEnvironmentStrings("%COMPUTERNAME%").toLowerCase() + ":" + port + "/" + appName + "/"; - var url = result + "tests/common/TestLogger.svc"; - - var success = CheckUrl(url); - - if (!success) { - // Assume that we need to launch this. - var src = fso.GetAbsolutePathName(".."); - - var folder = FindFirstPath([ - "%ProgramFiles(x86)%\\IIS Express", - "%ProgramFiles%\\IIS Express"]); - - if (!folder) { - throw { message: "Unable to find path to IIS Express" }; - } - - var appCmd = "\"" + folder + "\\appcmd.exe\""; - var iisExpress = "\"" + folder + "\\iisexpress.exe\""; - - // Delete site if it already exists - WScript.Echo("Checking if site '" + siteName + "' already exists..."); - if (RunCommand(appCmd + " list site \"" + siteName + "\"", true) === 0) { - WScript.Echo("Deleting existing site '" + siteName + "'..."); - RunCommand(appCmd + " delete site \"" + siteName + "\"", true, 0); - } - - // Create site and app - WScript.Echo("Creating site '" + siteName + "'..."); - RunCommand(appCmd + " add site /name:\"" + siteName + "\" /bindings:http/*:" + port + ": /physicalPath:%IIS_BIN%\\AppServer\\empty_wwwroot", true, 0); - - WScript.Echo("Creating application '" + appName + "'..."); - RunCommand(appCmd + " add app /site.name:\"" + siteName + "\" /path:\"/" + appName + "\" /physicalPath:\"" + src + "\"", true, 0); - - // Start the server - WScript.Echo("Starting IIS Express server..."); - RunCommand(iisExpress + " /site:\"" + siteName + "\" /trace:error"); - - WScript.Sleep(2 * 1000); - success = attempt(function () { - WScript.Echo("Waiting for server to come up, looking for " + url + " ..."); - return CheckUrl(url); - }, 5 * 1000, 3); - - if (!success) { - throw { message: "Unable to verify the URL at " + url }; - } - } - return result; - } - - function CreateTestRunId(serviceRoot) { - /// <summary>Creates a new test run ID from the service.</summary> - /// <param name="serviceRoot" type="String">Root of logger service.</param> - /// <returns type="String">The test run ID created.</returns> - var xhr = WScript.CreateObject("Msxml2.ServerXMLHTTP.6.0"); - var url = serviceRoot + "CreateTestRun"; - xhr.open("GET", url, false); - WScript.Echo("URL: " + url); - xhr.send(); - - var response = xhr.responseText; - var result = parseJson(response); - return result; - } - - function GetBrowsers() { - /// <summary>Gets the browsers that should be used for running the tests.</summary> - /// <returns type="Object">Dictionary object containing the browser and its executable path as key value pairs.</returns> - var localAppData = fso.FolderExists(shell.ExpandEnvironmentStrings("%LOCALAPPDATA%")) ? "%LOCALAPPDATA%" : "%USERPROFILE%\\Local Settings\\Application Data"; - var programFiles = fso.FolderExists(shell.ExpandEnvironmentStrings("%ProgramFiles(x86)%")) ? "%ProgramFiles(x86)%" : "%ProgramFiles%"; - var browsers = { - IE8: [programFiles + "\\Internet Explorer\\iexplore.exe"], - Firefox4: [programFiles + "\\Mozilla Firefox\\firefox.exe"], - Chrome: [programFiles + "\\Google\\Chrome\\Application\\chrome.exe", localAppData + "\\Google\\Chrome\\Application\\chrome.exe"], - Safari5: [programFiles + "\\Safari\\safari.exe"], - Opera: [programFiles + "\\Opera\\opera.exe"] - }; - - var browsersToRun = {}; - - if (WScript.Arguments.Named.Exists("browsers")) { - browserNames = WScript.Arguments.Named.Item("browsers").split(','); - for (i in browserNames) { - var browserName = browserNames[i]; - if (browsers[browserName]) { - browsersToRun[browserName] = browsers[browserName]; - } else { - throw { message: "Unknown browser: " + browserName }; - } - } - } - else { - browsersToRun = browsers; - } - - return browsersToRun; - } - - function GetTestFilesList() { - /// <summary>Gets the list of test files that are going to be executed in the test run.</summary> - /// <returns type="Array">The list of test files.</returns> - var testFilesList = null; - if (WScript.Arguments.Named.Exists("testFiles")) { - testFilesList = WScript.Arguments.Named.Item("testFiles").split(','); - } - - if (testFilesList === null) { - testFilesList = getAllTestFiles(); - } - - WScript.Echo("Test files to be executed: " + testFilesList.toString()); - return testFilesList; - } - - function GetOutputDirectory() { - /// <summary>Gets the test run output directory.</summary> - /// <returns type="String">Output directory.</returns> - var result; - if (WScript.Arguments.Named.Exists("outputDirectory")) { - result = WScript.Arguments.Named.Item("outputDirectory"); - } else { - result = shell.ExpandEnvironmentStrings("%DJSOUT%\\JSLib.sln\\tests"); - } - - - return result; - } - - try { - var root = SetupWebDevServer(); - var serviceRoot = root + "tests/common/TestLogger.svc/"; - var testRunId = CreateTestRunId(serviceRoot); - WScript.Echo("Test Run ID: " + testRunId); - - var testFilesList = GetTestFilesList(); - var browsers = GetBrowsers(); - var outputDirectory = GetOutputDirectory(); - - if (testFilesList.length > 0) { - var url = root + "tests/" + testFilesList[0] + "?testRunId=" + testRunId; - LaunchBrowser(browsers, serviceRoot, testFilesList.splice(1, testFilesList.length), url, testRunId, outputDirectory); - WriteTestRunResults(serviceRoot, testRunId, outputDirectory); - } - else { - WScript.Echo("No test files specified to run."); - } - } catch (e) { - WScript.Echo("Error running tests"); - for (var p in e) WScript.Echo(p + ": " + e[p]); - exitCode = 1; - } - - WScript.Quit(exitCode); - - </script> -</job> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/4621d41c/JSLib/tests/store-indexeddb-tests.js ---------------------------------------------------------------------- diff --git a/JSLib/tests/store-indexeddb-tests.js b/JSLib/tests/store-indexeddb-tests.js deleted file mode 100644 index 6751363..0000000 --- a/JSLib/tests/store-indexeddb-tests.js +++ /dev/null @@ -1,246 +0,0 @@ -/// <reference path="../src/local-indexeddb.js" /> -/// <reference path="common/djstest.js" /> - -// store-indexeddb-tests.js - -(function (window, undefined) { - // DATAJS INTERNAL START - var unexpectedSuccess = function (key, value) { - djstest.fail("Unexpected call to success handler: key = " + key + ", value = " + value); - djstest.done(); - }; - - var unexpectedError = function (e) { - djstest.fail("Unexpected call to error handler: " + djstest.toString(e)); - djstest.done(); - }; - - var storeCounter = 0; - var storeName = "test"; - - var getNextStoreName = function () { - storeCounter++; - return getCurrentStoreName(); - }; - - var getCurrentStoreName = function(){ - return storeName + storeCounter; - }; - - var oldWindowOnError; - - if (djstest.indexedDB) { - module("Unit", { - setup: function () { - djstest.wait(function (done) { - djstest.cleanStoreOnIndexedDb([{ name: getNextStoreName() }], done); - }); - - // FireFox 7.0.1 bubbles an error event when there is an IndexedDB error, even when the error has been handled graciously. - // This is a work around to keep QUnit from reporting false failures in IndexedDB negative tests. - oldWindowOnError = window.onerror; - window.onerror = null; - }, - teardown: function () { - var store = this.store; - if (store) { - store.close(); - } - - djstest.wait(function (done) { - djstest.cleanStoreOnIndexedDb([store], done); - }); - - - // Restore QUnit's onerror handler. - window.onerror = oldWindowOnError; - } - }); - - djstest.addTest(function testIndexedDBStoreConstructor() { - var store = this.store = window.odatajs.IndexedDBStore.create(getCurrentStoreName()); - djstest.assertAreEqual(store.name, getCurrentStoreName()); - djstest.assertAreEqual(store.mechanism, "indexeddb"); - djstest.done(); - }); - - djstest.addTest(function testIndexedDBStoreAddGet() { - var store = this.store = window.odatajs.IndexedDBStore.create(getCurrentStoreName()); - store.add("key", "value", function (key, value) { - djstest.assertAreEqual(key, "key"); - djstest.assertAreEqual(value, "value"); - store.read("key", function (key, value) { - djstest.assertAreEqual(key, "key"); - djstest.assertAreEqual(value, "value"); - djstest.done(); - }, unexpectedError); - }, unexpectedError); - }); - - djstest.addTest(function testIndexedDBStoreAddUpdateGet() { - var store = this.store = window.odatajs.IndexedDBStore.create(getCurrentStoreName()); - store.add("key", "value", function (key, value) { - store.update("key", "value2", function (key, value) { - djstest.assertAreEqual(key, "key"); - djstest.assertAreEqual(value, "value2"); - store.read("key", function (key, value) { - djstest.assertAreEqual(key, "key"); - djstest.assertAreEqual(value, "value2"); - djstest.done(); - }, unexpectedError); - }, unexpectedError); - }, unexpectedError); - }); - - djstest.addTest(function testIndexedDBStoreAddOrUpdateGet() { - var store = this.store = window.odatajs.IndexedDBStore.create(getCurrentStoreName()); - store.addOrUpdate("key", "value", function (key, value) { - djstest.assertAreEqual(key, "key"); - djstest.assertAreEqual(value, "value"); - store.addOrUpdate("key", "value2", function (key, value) { - djstest.assertAreEqual(key, "key"); - djstest.assertAreEqual(value, "value2"); - store.read("key", function (key, value) { - djstest.assertAreEqual(key, "key"); - djstest.assertAreEqual(value, "value2"); - djstest.done(); - }, unexpectedError); - }, unexpectedError); - }, unexpectedError); - }); - - djstest.addTest(function testIndexedDBStoreAddRemoveContains() { - var store = this.store = window.odatajs.IndexedDBStore.create(getCurrentStoreName()); - store.add("key", "value", function (key, value) { - store.contains("key", function (result) { - djstest.assert(result); - store.remove("key", function () { - djstest.pass("key removed"); - store.contains("key", function (result) { - djstest.assert(!result); - djstest.done(); - }, unexpectedError); - }, unexpectedError); - }, unexpectedError); - }, unexpectedError); - }); - - djstest.addTest(function testIndexedDBStoreAddConsecutiveGetAllKeys() { - var store = this.store = window.odatajs.IndexedDBStore.create(getCurrentStoreName()); - store.add("key", "value", function (key, value) { - store.add("key2", "value2", function (key, value) { - store.add("key3", "value3", function (key, value) { - store.getAllKeys(function (keys) { - djstest.assertAreEqualDeep(keys, ["key", "key2", "key3"]); - djstest.done(); - }, unexpectedError); - }, unexpectedError); - }, unexpectedError); - }, unexpectedError); - }); - - djstest.addTest(function testIndexedDBStoreAddArrayClear() { - var addedKeys = ["key", "key2", "key3"]; - var addedValues = ["value", "value2", "value3"]; - var store = this.store = window.odatajs.IndexedDBStore.create(getCurrentStoreName()); - store.add(addedKeys, addedValues, function (keys, values) { - djstest.assertAreEqualDeep(keys, addedKeys); - djstest.assertAreEqualDeep(values, addedValues); - store.clear(function () { - store.getAllKeys(function (keys) { - djstest.assertAreEqualDeep(keys, []); - djstest.done(); - }, unexpectedError); - }, unexpectedError); - }, unexpectedError); - }); - - djstest.addTest(function testIndexedDBStoreAddArrayUpdateArrayGetArray() { - var addedKeys = ["key", "key2", "key3"]; - var addedValues = ["value", "value2", "value3"]; - var store = this.store = window.odatajs.IndexedDBStore.create(getCurrentStoreName()); - store.add(addedKeys, addedValues, function (keys, values) { - djstest.assertAreEqualDeep(keys, addedKeys); - djstest.assertAreEqualDeep(values, addedValues); - var updatedKeys = ["key", "key3"]; - var updatedValues = ["newValue", "newValue3"]; - store.update(updatedKeys, updatedValues, function (keys, values) { - djstest.assertAreEqualDeep(keys, updatedKeys); - djstest.assertAreEqualDeep(values, updatedValues); - store.read(addedKeys, function (keys, values) { - djstest.assertAreEqualDeep(keys, ["key", "key2", "key3"]); - djstest.assertAreEqualDeep(values, ["newValue", "value2", "newValue3"]); - djstest.done(); - }, unexpectedError); - }, unexpectedError); - }, unexpectedError); - }); - - djstest.addTest(function testIndexedDBStoreAddOrUpdateArrayGetArray() { - var expectedKeys = ["key", "key2", "key3"]; - var expectedValues = ["value", "value2", "value3"]; - var store = this.store = window.odatajs.IndexedDBStore.create(getCurrentStoreName()); - store.add("key2", "value", function (key, value) { - store.addOrUpdate(expectedKeys, expectedValues, function (keys, values) { - djstest.assertAreEqualDeep(keys, expectedKeys); - djstest.assertAreEqualDeep(values, expectedValues); - store.read(keys, function (keys, values) { - djstest.assertAreEqualDeep(values, expectedValues); - djstest.done(); - }, unexpectedError); - }, unexpectedError); - }, unexpectedError); - }); - - djstest.addTest(function testIndexedDBStoreAddDuplicate() { - var store = this.store = window.odatajs.IndexedDBStore.create(getCurrentStoreName()); - store.add("key", "value", function (key, value) { - store.add("key", "value2", unexpectedSuccess, function (err) { - djstest.pass("Error callback called as expected"); - djstest.done(); - }); - }, unexpectedError); - }); - - djstest.addTest(function testIndexedDBStoreAddArrayDuplicate() { - var store = this.store = window.odatajs.IndexedDBStore.create(getCurrentStoreName()); - store.add(["key", "key2", "key"], ["value", "value2", "value3"], unexpectedSuccess, function (err) { - djstest.pass("Error callback called as expected"); - djstest.done(); - }); - }); - - djstest.addTest(function testIndexedDBStoreGetArrayNonExistent() { - var store = this.store = window.odatajs.IndexedDBStore.create(getCurrentStoreName()); - store.add("key", "value", function (key, value) { - store.read(["key", "badkey"], function (keys, values) { - djstest.assertAreEqualDeep(keys, ["key", "badkey"]); - djstest.assertAreEqualDeep(values, ["value", undefined]); - djstest.done(); - }, unexpectedError); - }); - }); - - djstest.addTest(function testIndexedDBStoreUpdateNonExistent() { - var store = this.store = window.odatajs.IndexedDBStore.create(getCurrentStoreName()); - store.update("badkey", "badvalue", unexpectedSuccess, function (err) { - djstest.pass("Error callback called as expected"); - djstest.done(); - }); - }); - - djstest.addTest(function testIndexedDBStoreUpdateArrayNonExistent() { - var store = this.store = window.odatajs.IndexedDBStore.create(getCurrentStoreName()); - store.add("key", "value", function (key, value) { - store.update(["key", "badkey"], ["value", "badvalue"], unexpectedSuccess, function (err) { - djstest.pass("Error callback called as expected"); - store.read("key", function (key, value) { - djstest.assertAreEqual(value, "value", "value was not changed"); - djstest.done(); - }), unexpectedError; - }); - }, unexpectedError); - }); - } - // DATAJS INTERNAL END -})(this); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/4621d41c/JSLib/tests/store-tests.js ---------------------------------------------------------------------- diff --git a/JSLib/tests/store-tests.js b/JSLib/tests/store-tests.js deleted file mode 100644 index 4bf6d3e..0000000 --- a/JSLib/tests/store-tests.js +++ /dev/null @@ -1,684 +0,0 @@ -/// <reference path="../src/datajs-store.js"> -/// <reference path="../src/datajs-store-dom.js"> -/// <reference path="common/djstest.js" /> - -// odata-tests.js -(function (window, undefined) { - - var cleanDomStorage = function () { - /// <summary>Cleans all the data saved in the browser's DOM Storage.</summary> - if (window.localStorage) { - window.localStorage.clear(); - } - }; - - var cleanMemoryStorage = function () { - /// <summary>Clean memory storage is a no op.</summary> - }; - - var cleanIndexedDbStorage = function () { - var stores = this.stores; - $.each(stores, function (_, store) { - store.close(); - }); - - djstest.wait(function (done) { - djstest.cleanStoreOnIndexedDb(stores, done); - }); - }; - - var canCreateMemoryStore = function () { - /// <summary>Checks whether memory storage is supported by the browser.</summary> - /// <returns type="Boolean">True.</summary> - return true; - }; - - var canCreateDomStore = function () { - /// <summary>Checks whether Web Storage (DOM Storage) is supported by the browser.</summary> - /// <returns type="Boolean">True if DOM Storage is supported by the browser; false otherwise.</summary> - return !!window.localStorage; - }; - - var canCreateIndexedDb = function () { - /// <summary>Checks whether Web Storage (DOM Storage) is supported by the browser.</summary> - /// <returns type="Boolean">True if IndexedDB is supported by the browser, false otherwise.</returns> - return !!djstest.indexedDB; - }; - - var canCreateStore = function (mechanism) { - /// <summary>Determines whether a particular mechanism is supported by the browser.</summary> - /// <param name="mechanism" type="String">Mechanism name.</param> - /// <returns type="Boolean">True if the mechanism is supported by the browser; otherwise false.</summary> - var implementation = mechanismImplementations[mechanism]; - return implementation && implementation.canCreate(); - } - var makeUnexpectedErrorHandler = function (fail) { - return function (err) { - djstest.fail("error: " + err.name + " -- message: " + err.message); - fail(); - }; - }; - - var testJobDone = function (succeeded) { - if (!succeeded) { - djstest.fail("Job completed but some of the functions it called failed"); - } - djstest.done(); - }; - - var mechanismImplementations = { - indexeddb: { factory: odatajs.IndexedDBStore, canCreate: canCreateIndexedDb, cleanup: cleanIndexedDbStorage }, - dom: { factory: odatajs.DomStore, canCreate: canCreateDomStore, cleanup: cleanDomStorage }, - memory: { factory: odatajs.MemoryStore, canCreate: canCreateMemoryStore, cleanup: cleanMemoryStorage } - }; - - var oldWindowOnError; - - for (var mechanism in mechanismImplementations) { - module("Unit", { - mechanism: mechanism, - createStore: function (name) { - var store = odatajs.createStore(name + "_" + this.mechanism, this.mechanism); - this.stores.push(store); - return store; - }, - setup: function () { - this.stores = []; - mechanismImplementations[this.mechanism].cleanup.call(this); - - // FireFox 7.0.1 bubbles an error event when there is an IndexedDB error, even when the error has been handled graciously. - // This is a work around to keep QUnit from reporting false failures in IndexedDB negative tests. - if (this.mechanism === "indexeddb") { - oldWindowOnError = window.onerror; - window.onerror = null; - } - }, - teardown: function () { - mechanismImplementations[this.mechanism].cleanup.call(this); - this.stores = []; - - // Restore QUnit's onerror handler. - if (this.mechanism === "indexeddb") { - window.onerror = oldWindowOnError; - } - } - }); - - if (!canCreateStore(mechanism)) { - djstest.addTest(function (mechanism) { - djstest.expectException(function () { - mechanismImplemenatations[mechanism].factory.create("my horrible not working store"); - }); - djstest.done(); - }, "Local storage mechanism " + mechanism + " not supported by this browser", mechanism); - } else { - - djstest.addTest(function storeAddTest(mechanism) { - var tuples = [ - { key: "null", value: null }, - { key: "undefined", value: undefined }, - { key: "number", value: 12345.678 }, - { key: "string", value: "String value" }, - { key: "date", value: new Date() }, - { key: "object", value: { p1: 1234, nested: { p1: "a", p2: "b"}} }, - { key: "array", value: [1, 2, 3, 4, 5] }, - { key: "key1", value: "some value" }, - { key: "key1", value: "this should fail", error: true }, - { key: ["key", "key2"], value: ["value", "value2"], error: mechanism !== "indexeddb" }, - { key: ["key6", "key7", "key6"], value: ["value", "value2", "value3"], error: true } - ]; - - var store = this.createStore("store1"); - var job = new djstest.Job(); - - $.each(tuples, function (_, tuple) { - job.queue(function task(success, fail) { - - var unexpectedError = makeUnexpectedErrorHandler(fail); - djstest.log("running task"); - - store.add(tuple.key, tuple.value, - function (key, value) { - djstest.assertAreEqual(key, tuple.key, "Keys match for " + mechanism + " - key = " + key.toString()); - djstest.assertAreEqualDeep(value, tuple.value, "Values match for " + mechanism + " - key = " + key.toString()); - - job.queueNext(function (success, fail) { - store.read(tuple.key, function (key, value) { - djstest.assertAreEqualDeep(value, tuple.value, "Key: " + key + " is present in the store"); - success(); - }, makeUnexpectedErrorHandler(fail)); - }); - success(); - }, - function (err) { - if (!tuple.error) { - unexpectedError(err); - } else { - djstest.pass("error handler was called as expected"); - success(); - } - }); - }); - }); - - job.run(function (succeeded) { - store.close(); - testJobDone(succeeded); - }); - - }, "Store Add Test with mechanism " + mechanism, mechanism); - - djstest.addTest(function storeAddOrUpdateTest(mechanism) { - var tuples = [ - { key: "null", value: null }, - { key: "undefined", value: undefined }, - { key: "number", value: 12345.678 }, - { key: "string", value: "String value" }, - { key: "date", value: new Date() }, - { key: "object", value: { p1: 1234, nested: { p1: "a", p2: "b"}} }, - { key: "array", value: [1, 2, 3, 4, 5] }, - { key: "key1", value: "some value" }, - { key: "key1", value: "this should not fail" }, - { key: ["key", "key2", "key3"], value: ["value", "value2", "value3"], error: mechanism !== "indexeddb" }, - { key: ["key", "key2", "key3"], value: ["value4", "value5", "value6"], error: mechanism !== "indexeddb" }, - { key: "key1", value: 456 } - ]; - - var store = this.createStore("store2"); - var job = new djstest.Job(); - - $.each(tuples, function (_, tuple) { - job.queue(function (success, fail) { - - var unexpectedError = makeUnexpectedErrorHandler(fail); - - store.addOrUpdate(tuple.key, tuple.value, - function (key, value) { - djstest.assert(!tuple.error, "success should be called"); - djstest.assertAreEqual(key, tuple.key, "Keys match"); - djstest.assertAreEqualDeep(value, tuple.value, "Values match"); - - store.read(tuple.key, function (key, value) { - djstest.assertAreEqual(key, tuple.key, "Keys match"); - djstest.assertAreEqualDeep(value, tuple.value, "Values match"); - success(); - }, unexpectedError); - }, - function (err) { - if (!tuple.error) { - unexpectedError(err); - } else { - djstest.pass("error handler was called as expected"); - success(); - } - }); - }); - }); - - job.run(function (succeeded) { - store.close(); - testJobDone(succeeded); - }); - }, "Store Add or Update Test with mechanism " + mechanism, mechanism); - - djstest.addTest(function storeContainsTest(mechanism) { - var store = this.createStore("store3"); - var job = new djstest.Job(); - - job.queue(function (success, fail) { - store.add("Key1", "Some value", success, makeUnexpectedErrorHandler(fail)); - }); - - job.queue(function (success, fail) { - store.contains("Key1", function (contained) { - djstest.assert(contained, "Key is present in the store"); - success(); - }, makeUnexpectedErrorHandler(fail)); - }); - - job.queue(function (success, fail) { - store.contains("Key2", function (contained) { - djstest.assert(!contained, "Key is not present in the store"); - success(); - }, makeUnexpectedErrorHandler(fail)); - }); - - job.run(function (succeeded) { - store.close(); - testJobDone(succeeded); - }); - - }, "Store Contains Test with mechanism " + mechanism, mechanism); - - djstest.addTest(function storeGetAllKeysTest(mechanism) { - var store = this.createStore("store4"); - var store2 = this.createStore("store4_1"); - - var expectedKeys = []; - var job = new djstest.Job(); - - var i; - for (i = 1; i <= 20; i++) { - (function (i) { - job.queue(function (success, fail) { - store.add(i.toString(), "value" + i, success, makeUnexpectedErrorHandler(fail)); - }); - - job.queue(function (success, fail) { - store2.add((i + 20).toString(), "value" + (i + 20), success, makeUnexpectedErrorHandler(fail)); - }); - })(i); - - expectedKeys.push(i.toString()); - } - - job.queue(function (success, fail) { - store.getAllKeys(function (keys) { - expectedKeys.sort(); - keys.sort(); - djstest.assertAreEqualDeep(keys, expectedKeys, "All expected keys where returned"); - success(); - }, makeUnexpectedErrorHandler(fail)); - }); - - job.run(function (succeeded) { - store.close(); - store2.close(); - testJobDone(succeeded); - }); - }, "Store Get All Keys Test with mechanism " + mechanism, mechanism); - - djstest.addTest(function storeReadTest(mechanism) { - var tuples = [ - { key: "null", value: null }, - { key: "undefined", value: undefined }, - { key: "number", value: 12345.678 }, - { key: "string", value: "String value" }, - { key: "date", value: new Date() }, - { key: "dateOffset", value: (function () { - var d = new Date(); - d.__type = "Edm.DateTimeOffset"; - d.__offset = "+03:30"; - return d; - })() - }, - { key: "complexDate", value: (function () { - var d = new Date(); - d.nestedDate = new Date(); - d.nestedDate.__type = "Edm.DateTimeOffset"; - d.nestedDate.__offset = "+03:30"; - return d; - })() - }, - { key: "object", value: { p1: 1234, nested: { p1: "a", p2: "b", p3: new Date()}} }, - { key: "array", value: [1, 2, 3, 4, 5] } - ]; - - var store = this.createStore("store5"); - var job = new djstest.Job(); - - $.each(tuples, function (_, tuple) { - job.queue(function (success, fail) { - store.add(tuple.key, tuple.value, - function () { - job.queue(function (success, fail) { - store.read(tuple.key, function (key, value) { - djstest.assertAreEqual(key, tuple.key, "Keys match"); - djstest.assertAreEqualDeep(value, tuple.value, "Values match"); - success(); - }, makeUnexpectedErrorHandler(fail)); - }); - success(); - }, - function (err) { - if (!tuple.error) { - djstest.fail(err.message); - fail(); - } else { - djstest.pass("error handler was called as expected"); - success(); - } - }); - }); - }); - - job.queue(function (success, fail) { - store.read("Unknown key", function (key, value) { - djstest.assertAreEqual(value, undefined, "Store get returns undefined for keys that do not exist in the store"); - success(); - }, makeUnexpectedErrorHandler(fail)); - }); - - job.run(function (succeeded) { - store.close(); - testJobDone(succeeded); - }); - - }, "Store Read Test with mechanism " + mechanism, mechanism); - - djstest.addTest(function storeReadArrayTest(mechanism) { - var makeError = function (success, fail) { - return function (err) { - if (mechanism !== "indexeddb") { - djstest.pass("Error callback called as expected"); - success(); - } else { - djstest.fail(err.message); - fail(); - } - }; - }; - - var store = this.createStore("store6"); - var job = new djstest.Job(); - - job.queue(function (success, fail) { - store.add(["key", "key2", "key3"], ["value", "value2", "value3"], success, makeError(success, fail)); - }); - - job.queue(function (success, fail) { - store.read(["key", "key2", "key3"], function (keys, values) { - djstest.assertAreEqualDeep(keys, ["key", "key2", "key3"]); - djstest.assertAreEqualDeep(values, ["value", "value2", "value3"]); - success(); - }, makeError(success, fail)); - }); - - job.queue(function (success, fail) { - store.read(["key", "badkey"], function (keys, values) { - djstest.assertAreEqualDeep(keys, ["key", "badkey"]); - djstest.assertAreEqualDeep(values, ["value", undefined]); - success(); - }, makeError(success, fail)); - }); - - job.run(function (succeeded) { - store.close(); - testJobDone(succeeded); - }); - }, "Store Read Array Test with mechanism " + mechanism, mechanism); - - djstest.addTest(function storeRemoveTest(mechanism) { - var store = this.createStore("store7"); - var job = new djstest.Job(); - - job.queue(function (success, fail) { - store.add("Key1", "Some value", success, makeUnexpectedErrorHandler(fail)); - }); - - job.queue(function (success, fail) { - store.add("Key2", "Some value", success, makeUnexpectedErrorHandler(fail)); - }); - - job.queue(function (success, fail) { - store.remove("Key1", function () { - djstest.pass("Key1 was removed from the store") - success(); - }, makeUnexpectedErrorHandler(fail)); - }); - - job.queue(function (success, fail) { - store.contains("Key1", function (contained) { - djstest.assert(!contained, "Key1 is not present in the store"); - success(); - }, makeUnexpectedErrorHandler(fail)); - }); - - job.queue(function (success, fail) { - store.remove("Key that has never been added", function () { - djstest.pass('"Key that has never been added" was removed from the store'); - success(); - }, makeUnexpectedErrorHandler(fail)); - }); - - job.queue(function (success, fail) { - store.contains("Key2", function (contained) { - djstest.assert(contained, "Key2 is present in the store"); - success(); - }, makeUnexpectedErrorHandler(fail)); - }); - - job.run(function (succeeded) { - store.close(); - testJobDone(succeeded); - }); - }, "Store Remove Test with mechanism " + mechanism, mechanism); - - djstest.addTest(function storeUpdateTest(mechanism) { - var store = this.createStore("store8"); - - var startKey = "Key1"; - var startValue = "start value"; - var updateKey = "Key2"; - var updatedValue = "updated value"; - - var job = new djstest.Job(); - - job.queue(function (success, fail) { - store.add(startKey, startValue, success, makeUnexpectedErrorHandler(fail)); - }); - - job.queue(function (success, fail) { - store.add(updateKey, startValue, success, makeUnexpectedErrorHandler(fail)); - }); - - job.queue(function (success, fail) { - store.update(updateKey, updatedValue, function (key, value) { - djstest.assertAreEqual(key, updateKey, "Updated keys match"); - djstest.assertAreEqualDeep(value, updatedValue, "Updated values match"); - success(); - }, makeUnexpectedErrorHandler(fail)); - }); - - job.queue(function (success, fail) { - store.read(updateKey, function (key, value) { - djstest.assertAreEqual(key, updateKey, "Updated keys match after get"); - djstest.assertAreEqualDeep(value, updatedValue, "Updated values match after get"); - success(); - }, makeUnexpectedErrorHandler(fail)); - }); - - job.queue(function (success, fail) { - store.read(startKey, function (key, value) { - djstest.assertAreEqual(key, startKey, "Non updated keys match after get"); - djstest.assertAreEqualDeep(value, startValue, "Non updated values match after get"); - success(); - }, makeUnexpectedErrorHandler(fail)); - }); - - job.run(function (succeeded) { - store.close(); - testJobDone(succeeded); - }); - }, "Store Update Test with mechanism " + mechanism, mechanism); - - djstest.addTest(function storeClearTest(mechanism) { - var store = this.createStore("store9"); - var store2 = this.createStore("store9_1"); - - var job = new djstest.Job(); - job.queue(function (success, fail) { - store.add("Key1", "value in store", success, makeUnexpectedErrorHandler(fail)); - }); - - job.queue(function (success, fail) { - store.add("Key2", "value in store", success, makeUnexpectedErrorHandler(fail)); - }); - - job.queue(function (success, fail) { - store.add("Key3", "value in store", success, makeUnexpectedErrorHandler(fail)); - }); - - job.queue(function (success, fail) { - store2.add("Key1", "value in store2", success, makeUnexpectedErrorHandler(fail)); - }); - - job.queue(function (success, fail) { - store.clear(function () { - djstest.pass("Store was cleared"); - success(); - }, makeUnexpectedErrorHandler(fail)); - }); - - job.queue(function (success, fail) { - store.contains("Key1", function (contained) { - djstest.assert(!contained, "Key1 was removed from store"); - success(); - }, makeUnexpectedErrorHandler(fail)); - }); - - job.queue(function (success, fail) { - store2.contains("Key1", function (contained) { - djstest.assert(contained, "Key1 still exists in store 2"); - success(); - }, makeUnexpectedErrorHandler(fail)); - }); - - job.run(function (succeeded) { - store.close(); - store2.close(); - testJobDone(succeeded); - }); - }, "Store Clear Test with mechanism " + mechanism, mechanism); - - djstest.addTest(function storeUpdateNonExistentTest(mechanism) { - var store = this.createStore("store10"); - var job = new djstest.Job(); - - job.queue(function (success, fail) { - store.add("key", "value", success, makeUnexpectedErrorHandler(fail)); - }); - - job.queue(function (success, fail) { - store.update("badKey", "new value", - function () { - djstest.fail("Sucess handler called when not expected"); - fail(); - }, - function (err) { - djstest.pass("Error callback called as expexted"); - success(); - }); - }); - - job.queue(function (success, fail) { - store.update(["key", "badkey"], ["value", "badvalue"], - function () { - djstest.fail("Sucess handler called when not expected"); - fail(); - }, - function (err) { - djstest.pass("Error callback called as expected"); - success(); - }); - }); - - job.queue(function (success, fail) { - store.read("key", function (key, value) { - djstest.assertAreEqual(value, "value", "value was not changed"); - success(); - }, makeUnexpectedErrorHandler(fail)); - }); - - job.run(function (succeeded) { - store.close(); - testJobDone(succeeded); - }); - }, "Store Update Non-Existent Test with mechanism " + mechanism, mechanism); - - djstest.addTest(function storeUpdateArrayTest(mechanism) { - var makeError = function (success, fail) { - return function (err) { - if (mechanism !== "indexeddb") { - djstest.pass("Error callback called as expected"); - success(); - } else { - djstest.fail(err.message); - fail(); - } - }; - }; - - var store = this.createStore("store11"); - var job = new djstest.Job(); - - job.queue(function (success, fail) { - store.add(["key", "key2"], ["value1", "value2"], success, makeError(success, fail)); - }); - - job.queue(function (success, fail) { - store.update(["key", "key2"], ["value1", "value4"], success, makeError(success, fail)); - }); - - job.queue(function (success, fail) { - store.read(["key", "key2"], function (key, value) { - djstest.assertAreEqualDeep(value, ["value1", "value4"], "value was not changed"); - success(); - }, makeError(success, fail)); - }); - - job.run(function (succeeded) { - store.close(); - testJobDone(succeeded); - }); - }, "Store Update Array Test with mechanism " + mechanism, mechanism); - } - } - - module("Unit"); - - djstest.addTest(function CreateStoreTest() { - var defaultExpected = canCreateDomStore() ? "dom" : "memory"; - var tests = [ - { mechanism: "dom", exception: !canCreateDomStore(), expected: "dom" }, - { mechanism: "memory", exception: false, expected: "memory" }, - { mechanism: "", exception: false, expected: defaultExpected }, - { mechanism: null, exception: false, expected: defaultExpected }, - { mechanism: "unknown", exception: true } - ]; - - var i, len; - for (i = 0, len = tests.length; i < len; i++) { - try { - var test = tests[i]; - var store = odatajs.createStore("testStore" + i, tests[i].mechanism); - - if (!test.exception) { - djstest.assertAreEqual(store.mechanism, test.expected, "Created store of the expected mechanism"); - } else { - djstest.fail("Didn't get the expected exception"); - } - } - catch (e) { - djstest.assert(test.exception, "Expected exception"); - } - } - djstest.done(); - }); - - djstest.addTest(function CreateBestStoreTest() { - var bestMechanism; - - for (var name in mechanismImplementations) { - if (!bestMechanism && canCreateStore(name) && name !== "indexeddb") { - bestMechanism = name; - } - } - - if (bestMechanism) { - var tests = [ - "best", - undefined - ]; - - for (var i in tests) { - var store = odatajs.createStore("best store ever " + i, tests[i]); - djstest.assertAreEqual(store.mechanism, bestMechanism, "Mechanisms match"); - } - } else { - djstest.pass("This browser doesn't support any of the implemented local storage mechanisms"); - } - djstest.done(); - }); - -})(this); http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/4621d41c/JSLib/tests/test-list.js ---------------------------------------------------------------------- diff --git a/JSLib/tests/test-list.js b/JSLib/tests/test-list.js deleted file mode 100644 index 3a805d1..0000000 --- a/JSLib/tests/test-list.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, -// modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -// WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -// Test list for datajs tests - -function getAllTestFiles() { - return [ - "odata-qunit-tests.htm" - ]; -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/4621d41c/JSLib/tests/test-manager.html ---------------------------------------------------------------------- diff --git a/JSLib/tests/test-manager.html b/JSLib/tests/test-manager.html deleted file mode 100644 index fa4911a..0000000 --- a/JSLib/tests/test-manager.html +++ /dev/null @@ -1,88 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml"> -<head> - <title>datajs test manager</title> - <script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.5.1.js"></script> - <script type="text/javascript" src="test-list.js"></script> - <script type="text/javascript"> - var serviceRoot = "./common/TestLogger.svc/"; - $(function () { - $(getAllTestFiles()).each(function () { - $("#pages").append("<input type='checkbox' name='page' value='" + this + "' checked />" + this + "<br />"); - }); - refreshActiveRuns(); - }); - - var createTestRun = function (form) { - $.getJSON(serviceRoot + "CreateTestRun", function (data) { - var testRunId = data.d; - - // Build pages list - var pages = []; - $(form).find("input[name='page']:checked").each(function () { - pages.push(this.value); - }); - - var firstPage = pages[0]; - pages.shift(); - - $.get(serviceRoot + "MarkInProgress?testRunId=" + testRunId, function () { - $.get(serviceRoot + "SetTestNamePrefix?testRunId=" + testRunId + "&prefix=" + $("#browser").val() + "-", function () { - var renderLinks = function () { - $("#runLink").attr("href", firstPage + "?testRunId=" + testRunId); - $("#runLink").text(testRunId); - $("#resultsLink").attr("href", serviceRoot + "GetTestRunResults?testRunId=" + testRunId); - $("#resultsLink").text(testRunId); - refreshActiveRuns(); - }; - - if (pages.length > 0) { - $.get(serviceRoot + "AddTestPages?testRunId=" + testRunId + "&pages=" + pages.join(","), renderLinks); - } - else { - renderLinks(); - } - }); - }); - }); - }; - - var refreshActiveRuns = function () { - $("#activeRuns").empty(); - $.getJSON(serviceRoot + "GetActiveTestRuns", function (data) { - if (data.d.length === 0) { - $("#activeRuns").text("There are no active runs"); - } else { - $.each(data.d, function (_, id) { - $("#activeRuns").append("<a href='" + serviceRoot + "GetTestRunResults?testRunId=" + id + "'>" + id + "</a><br />"); - }) - }; - }); - }; - </script> -</head> -<body> - <h1>datajs test manager</h1> - <table style="width:100%"><tr><td style="vertical-align:top"> - <h4>1. Create Test Run</h4> - <form onsubmit="createTestRun(this); return false;"> - <div>Pages</div> - <div id="pages"></div> - <br /> - <div>Browser: <input type="text" id="browser" /></div> - <br /> - <input type="submit" value="Create Test Run" /> - </form> - - <h4>2. Run Tests</h4> - Test Run ID: <a id="runLink"></a> - - <h4>3. View Results</h4> - Test Run ID: <a id="resultsLink"></a> - - </td><td style="vertical-align:top"> - <h4>Active Runs <input type="button" value="Refresh" onclick="refreshActiveRuns()" /></h4> - <div id="activeRuns"></div> - </td></tr></table> -</body> -</html> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/4621d41c/grunt-config/custom-tasks/sign.js ---------------------------------------------------------------------- diff --git a/grunt-config/custom-tasks/sign.js b/grunt-config/custom-tasks/sign.js index 86e0d04..7f6319c 100644 --- a/grunt-config/custom-tasks/sign.js +++ b/grunt-config/custom-tasks/sign.js @@ -31,7 +31,7 @@ module.exports = function(grunt) { var options = this.options({ types : [] }); var workLoad = []; var writeToLogOk = function(data) { grunt.log.ok(data.toString()); }; - + //console.log("this.files" +JSON.stringify(this.files)); // fill workLoad for(var i = 0; i < this.files.length; i++) { for(var ii = 0; ii < this.files[i].src.length; ii++) { http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/4621d41c/grunt-config/sign-config.js ---------------------------------------------------------------------- diff --git a/grunt-config/sign-config.js b/grunt-config/sign-config.js index f5bc129..a0ff676 100644 --- a/grunt-config/sign-config.js +++ b/grunt-config/sign-config.js @@ -25,7 +25,7 @@ module.exports = function(grunt) { 'release' : { options: { types : ['md5', 'sha']}, expand : true, - cwd : './../dist/<%= artifactname %>/', + cwd : './_dist/<%= artifactname %>/', src : [ '<%= artifactname %>-lib.zip', 'odatajs.4.0.0-beta01.nupkg', @@ -36,7 +36,7 @@ module.exports = function(grunt) { 'asc' : { options: { types : ['asc']}, expand : true, - cwd : './../dist/<%= artifactname %>/', + cwd : './_dist/<%= artifactname %>/', src : [ '<%= artifactname %>-lib.zip', 'odatajs.4.0.0-beta01.nupkg', @@ -47,7 +47,7 @@ module.exports = function(grunt) { 'asc-verify' : { options: { types : ['asc-verify']}, expand : true, - cwd : './../dist/<%= artifactname %>/', + cwd : './_dist/<%= artifactname %>/', src : [ '<%= artifactname %>-lib.zip', 'odatajs.4.0.0-beta01.nupkg', http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/4621d41c/src/lib/cache.js ---------------------------------------------------------------------- diff --git a/src/lib/cache.js b/src/lib/cache.js index da7c35b..dce74b6 100644 --- a/src/lib/cache.js +++ b/src/lib/cache.js @@ -336,17 +336,17 @@ function DataCacheOperation(stateMachine, promise, isCancelable, index, count, d default: // Any other state is passed down to the state machine describing the operation's specific behavior. - // DATAJS INTERNAL START + if (true) { // Check that the state machine actually handled the sate. var handled = stateMachine(that, opTargetState, cacheState, data); djsassert(handled, "Bad operation state: " + opTargetState + " cacheState: " + cacheState, this); } else { - // DATAJS INTERNAL END + stateMachine(that, opTargetState, cacheState, data); - // DATAJS INTERNAL START + } - // DATAJS INTERNAL END + break; } }; http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/4621d41c/src/lib/deferred.js ---------------------------------------------------------------------- diff --git a/src/lib/deferred.js b/src/lib/deferred.js index ffc2431..520a857 100644 --- a/src/lib/deferred.js +++ b/src/lib/deferred.js @@ -18,7 +18,7 @@ */ 'use strict'; -/** @module datajs/deferred */ +/** @module odatajs/deferred */ http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/4621d41c/src/lib/odata.js ---------------------------------------------------------------------- diff --git a/src/lib/odata.js b/src/lib/odata.js index 6f18c01..6f660f6 100644 --- a/src/lib/odata.js +++ b/src/lib/odata.js @@ -165,9 +165,9 @@ exports.request = function (request, success, error, handler, httpClient, metada }; -/** Parses the csdl metadata to DataJS metatdata format. This method can be used when the metadata is retrieved using something other than DataJS +/** Parses the csdl metadata to ODataJS metatdata format. This method can be used when the metadata is retrieved using something other than odatajs * @param {string} csdlMetadataDocument - A string that represents the entire csdl metadata. - * @returns {Object} An object that has the representation of the metadata in Datajs format. + * @returns {Object} An object that has the representation of the metadata in odatajs format. */ exports.parseMetadata = function (csdlMetadataDocument) { http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/4621d41c/src/lib/store/indexeddb.js ---------------------------------------------------------------------- diff --git a/src/lib/store/indexeddb.js b/src/lib/store/indexeddb.js index aea0a50..d7527c1 100644 --- a/src/lib/store/indexeddb.js +++ b/src/lib/store/indexeddb.js @@ -75,7 +75,7 @@ function getError(error, defaultError) { function openStoreDb(store, success, error) { var storeName = store.name; - var dbName = "_datajs_" + storeName; + var dbName = "_odatajs_" + storeName; var request = indexedDB.open(dbName); request.onblocked = error; http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/4621d41c/src/lib/utils.js ---------------------------------------------------------------------- diff --git a/src/lib/utils.js b/src/lib/utils.js index 77b2cde..429a56a 100644 --- a/src/lib/utils.js +++ b/src/lib/utils.js @@ -18,7 +18,7 @@ */ 'use strict'; -/** @module datajs/utils */ +/** @module odatajs/utils */ function inBrowser() { @@ -92,7 +92,6 @@ function delay(callback) { * @param {String} message - Message explaining the assertion. * @param {Object} data - Additional data to be included in the exception. */ -// DATAJS INTERNAL START function djsassert(condition, message, data) { @@ -100,7 +99,6 @@ function djsassert(condition, message, data) { throw { message: "Assert fired: " + message, data: data }; } } -// DATAJS INTERNAL END /** Extends the target with the specified values. * @param {Object} target - Object to add properties to. http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/4621d41c/src/lib/xml.js ---------------------------------------------------------------------- diff --git a/src/lib/xml.js b/src/lib/xml.js index 0f9cb0b..194b4ba 100644 --- a/src/lib/xml.js +++ b/src/lib/xml.js @@ -19,7 +19,7 @@ 'use strict'; -/** @module datajs/xml */ +/** @module odatajs/xml */ var utils = require('./utils.js'); http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/4621d41c/tests/odata-fuzz.html ---------------------------------------------------------------------- diff --git a/tests/odata-fuzz.html b/tests/odata-fuzz.html index 740b31a..908ea82 100644 --- a/tests/odata-fuzz.html +++ b/tests/odata-fuzz.html @@ -551,7 +551,7 @@ <body> <h1>OData Fuzzing Tests</h1> <p> -This page fuzzes the OData parsers in the datajs library. +This page fuzzes the OData parsers in the odatajs library. </p> <button id='start-button'>Start</button> <p id='fuzz-status'> </p>
