Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h2>General Worklight 5.0.6 Debugging</h2> <ul> <li>Look at the training module titled <a href="http://www.ibm.com/developerworks/mobile/worklight/getting-started.html#client-basics" rel="nofollow noreferrer">Debugging your applications</a>. (<a href="http://public.dhe.ibm.com/software/mobile-solutions/worklight/docs/v506/03_04_Debugging_your_applications.pdf" rel="nofollow noreferrer">Direct PDF link</a>)</li> </ul> <h2>Debug Tips for JSONStore on Worklight 5.0.6</h2> <ul> <li>Try <code>console.log('message')</code> or <code>WL.Logger.debug('message')</code> inside <code>jsonstore.js</code> and your code (<code>[app-name].js</code>, etc.). The output should show up in Xcode's console and Android's LogCat.</li> <li>Reset the Simulator or Emulator and/or call <code>WL.JSONStore.destroy()</code>.</li> <li>Make sure you're running on a supported environment: <ul> <li>Android >=2.2 ARM/x86 Emulator or Devices</li> <li>iOS >=5.0 Simulator or Device</li> </ul></li> <li>Try turning encryption off (ie. do not pass a password to <code>WL.JSONStore.init</code> or <code>WL.JSONStore.initCollection</code>).</li> <li><p>Look at the SQLite Database file generated by JSONStore. This only works if encryption is off.</p> <ul> <li><p>Android:</p> <pre><code>$ adb shell $ cd /data/data/com.[app-name]/databases/wljsonstore $ sqlite3 jsonstore.sqlite </code></pre></li> <li><p>iOS</p> <pre><code>$ cd ~/Library/Application Support/iPhone Simulator/6.1/Applications/[id]/Documents/wljsonstore $ sqlite3 jsonstore.sqlite </code></pre></li> </ul> <p>Try looking at the searchFields with <code>.schema</code> and selecting data with <code>SELECT * FROM [collection-name];</code>. To exit <code>sqlite3</code> type <code>.exit</code>. Take a look at <a href="https://stackoverflow.com/a/15425797/186909">this StackOverflow question</a> for an example.</p></li> <li><p>(Android Only) Enable verbose JSONStore.</p> <pre><code>adb shell setprop log.tag.jsonstore-core VERBOSE adb shell getprop log.tag.jsonstore-core </code></pre></li> <li><p>(iOS >=6.0 and Safari >=6.0 Only) Try to use the <a href="http://webdesign.tutsplus.com/tutorials/workflow-tutorials/quick-tip-using-web-inspector-to-debug-mobile-safari/" rel="nofollow noreferrer">JavaScript debugger</a>. Set break points inside <code>jsonstore.js</code>. Helpful lines:</p> <ul> <li><p>Bridge to Native code:</p> <pre><code>cdv.exec(options.onSuccess, options.onFailure, pluginName, nativeFunction, args); </code></pre></li> <li><p>Success Callbacks returning from Native code:</p> <pre><code>deferred.resolve(data, more); </code></pre></li> <li><p>Failure Callbacks returning from Native code:</p> <pre><code>deferred.reject(new ErrorObject(errorObject)); </code></pre></li> </ul></li> <li><p>Write Proper Tests (Unit, Functional, Integration -- get test coverage). Here's a template that uses <a href="http://qunitjs.com/" rel="nofollow noreferrer">QUnit</a> and <a href="http://sinonjs.org/" rel="nofollow noreferrer">Sinon.js</a> to create a Sandbox environment where you can test how JSONStore handles different types of data/calls:</p> <pre><code>&lt;!DOCTYPE HTML&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;JSONStore Test App&lt;/title&gt; &lt;link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-1.11.0.css"&gt; &lt;script src="http://code.jquery.com/qunit/qunit-1.11.0.js"&gt;&lt;/script&gt; &lt;script src="http://sinonjs.org/releases/sinon-1.6.0.js"&gt;&lt;/script&gt; &lt;script&gt; //QUnit configuration flags, no need to change it. QUnit.config.requireExpects = true; &lt;/script&gt; &lt;/head&gt; &lt;body id="content" style="display: none;"&gt; &lt;!-- Test results will be appended to the div below, no need to make changes here. --&gt; &lt;div id="qunit"&gt;&lt;/div&gt; &lt;script&gt; //Start Worklight WL.Client.init({connectOnStartup : false}); //Hook into the deviceready event document.addEventListener("deviceready", onDeviceReady, false); //onDeviceReady will be called when JSONStore/Cordova is ready function onDeviceReady () { //Auto executing function that holds the test (function (jQuery) { //The variable jQuery is usable inside. //Mock WL.Client.invokeProcedure using a Stub. //This is only useful if you need to link a Worklight Adapter //to a JSONStore collection to reproduce your issue or bug. //API Doc: http://sinonjs.org/docs/#stubs var fakeAdapter = sinon.stub(WL.Client, "invokeProcedure", function (invocationData, options) { //DO NOT Create a real adapter, just mock the reponse here if it's relevant to the bug. var ADAPTER_RESPONSE = {invocationResult: {fakeKey: [{fn: 'carlos'}, {fn: 'mike'}]}}; options.onSuccess(ADAPTER_RESPONSE); }); //[**Explain your test here**] var EXPECTED_ASSERTIONS = 2; //every assertion is a deepEqual below. asyncTest('[**Meaningful title here**]', EXPECTED_ASSERTIONS, function () { //Destroy first to make sure we don't depend on state WL.JSONStore.destroy() .then(function () { //[**Start writting your test here**] //The test below is an example, it does the following: // - Initializes a collection linked to a fake adapter (see stub above). // - Checks if initialization worked by checking the collection name. // - Loads data from the fake adapter (see stub above). // - Checks if load worked by checking the number of documents loaded. var collections = { col1 : { searchFields : {fn: 'string'}, adapter : {name: 'fakeAdapter', load: { procedure: 'fakeProcedure', params: [], key: 'fakeKey' } } } }; return WL.JSONStore.init(collections); }) .then(function (response) { //Prep for your assertion var ACTUAL_VALUE = response.col1.name; var EXPECTED_VALUE = 'col1'; var COMMENT = 'Checking for the right collection name'; //Do your assertion using deepEqual //API Doc: http://api.qunitjs.com/deepEqual/ deepEqual(ACTUAL_VALUE, EXPECTED_VALUE, COMMENT); return WL.JSONStore.get('col1').load(); }) .then(function (response) { //Prep for your assertion var ACTUAL_VALUE = response; //load returns number of documents loaded var EXPECTED_VALUE = 2; //two documents are returned by the fake adapter (stub) var COMMENT = 'Checking if load worked'; //Do the assertion using deepEqual deepEqual(ACTUAL_VALUE, EXPECTED_VALUE, COMMENT); start();//call start() after you finish your test succesfully }) .fail(function (error) { deepEqual(false, true, 'Failure callback should not be called' + error.toString()); start();//call start() after you finish your test with a failure }); }); }(WLJQ)); //end auto executing function that holds the test } //end wlCommonInit &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre></li> </ul> <p>Expected output of the code above:</p> <p><img src="https://s3.amazonaws.com/f.cl.ly/items/2Y2q20230N272z1T1p25/Screen%20Shot%202013-03-20%20at%2011.16.15%20PM.png" alt="image"></p> <p><strong>Side-note:</strong> Here's a <a href="http://www.tricedesigns.com/2013/01/18/my-workflow-for-developing-phonegap-applications/" rel="nofollow noreferrer">general article</a> about the PhoneGap/Cordova workflow for a specific developer. There's a part of debugging, just browser-based though. Some of it applies to IBM Worklight development too.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload