diff --git a/distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/DeviceKvStoreCallbackJsunit.test.js b/distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/DeviceKvStoreCallbackJsunit.test.js index 88d1c163c48555b5a5ee1bd9f83e97e60f0fe55b..ea5e7a77ed09e86fb28ef7d3d427e0e043efc86c 100644 --- a/distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/DeviceKvStoreCallbackJsunit.test.js +++ b/distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/DeviceKvStoreCallbackJsunit.test.js @@ -854,19 +854,21 @@ describe('DeviceKvStoreCallbackTest', function () { await kvStore.put(KEY_TEST_SYNC_ELEMENT + 'testSync101', VALUE_TEST_SYNC_ELEMENT, function (err,data) { console.log('testDeviceKvStoreOnSyncComplete101 put success'); expect(err == undefined).assertTrue(); + }).catch((error) => { + console.log('testDeviceKvStoreOnSyncComplete101 put failed:' + e); + expect(null).assertFail(); + }); + try { var devices = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB']; var mode = factory.SyncMode.PULL_ONLY; - try { - kvStore.sync(devices, mode); - } catch(e) { - console.log('testDeviceKvStoreOnSyncComplete101 sync no peer device :e:' + e); - } - done(); - }); + kvStore.sync(devices, mode); + } catch(e) { + console.log('testDeviceKvStoreOnSyncComplete101 sync no peer device :e:' + e); + } }catch(e) { console.log('testDeviceKvStoreOnSyncComplete101 no peer device :e:' + e); - done(); } + done(); }) /** @@ -883,19 +885,21 @@ describe('DeviceKvStoreCallbackTest', function () { await kvStore.put(KEY_TEST_SYNC_ELEMENT + 'testSync101', VALUE_TEST_SYNC_ELEMENT, function (err,data) { console.log('testDeviceKvStoreOnSyncComplete102 put success'); expect(err == undefined).assertTrue(); + }).catch((error) => { + console.log('testDeviceKvStoreOnSyncComplete102 put failed:' + e); + expect(null).assertFail(); + }); + try { var devices = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB']; var mode = factory.SyncMode.PUSH_ONLY; - try { - kvStore.sync(devices, mode); - } catch(e) { - console.log('testDeviceKvStoreOnSyncComplete101 sync no peer device :e:' + e); - } - done(); - }); + kvStore.sync(devices, mode); + } catch(e) { + console.log('testDeviceKvStoreOnSyncComplete102 sync no peer device :e:' + e); + } }catch(e) { console.log('testDeviceKvStoreOnSyncComplete102 no peer device :e:' + e); - done(); } + done(); }) /** @@ -912,19 +916,21 @@ describe('DeviceKvStoreCallbackTest', function () { await kvStore.put(KEY_TEST_SYNC_ELEMENT + 'testSync101', VALUE_TEST_SYNC_ELEMENT, function (err,data) { console.log('testDeviceKvStoreOnSyncComplete103 put success'); expect(err == undefined).assertTrue(); + }).catch((error) => { + console.log('testDeviceKvStoreOnSyncComplete103 put failed:' + e); + expect(null).assertFail(); + }); + try { var devices = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB']; var mode = factory.SyncMode.PUSH_PULL; - try { - kvStore.sync(devices, mode); - } catch(e) { - console.log('testDeviceKvStoreOnSyncComplete101 sync no peer device :e:' + e); - } - done(); - }); + kvStore.sync(devices, mode); + } catch(e) { + console.log('testDeviceKvStoreOnSyncComplete103 sync no peer device :e:' + e); + } }catch(e) { console.log('testDeviceKvStoreOnSyncComplete103 no peer device :e:' + e); - done(); } + done(); }) /** diff --git a/distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/DeviceKvStorePromiseJsunit.test.js b/distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/DeviceKvStorePromiseJsunit.test.js index 29f13cdef932da7eab2443a23f9f246580529163..2a4b51aff72b71709ba8dd9e951f9d760f0db0f5 100644 --- a/distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/DeviceKvStorePromiseJsunit.test.js +++ b/distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/DeviceKvStorePromiseJsunit.test.js @@ -860,14 +860,19 @@ describe('DeviceKvStorePromiseTest', function () { await kvStore.put(KEY_TEST_SYNC_ELEMENT, VALUE_TEST_SYNC_ELEMENT).then((data) => { console.log('testDeviceKvStoreOnSyncComplete001 put success'); expect(data == undefined).assertTrue(); + }).catch((error) => { + console.log('testDeviceKvStoreOnSyncComplete001 put failed:' + e); + expect(null).assertFail(); + }); + try { var devices = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB']; var mode = factory.SyncMode.PULL_ONLY; kvStore.sync(devices, mode); - }).catch((error) => { - console.log('testDeviceKvStoreOnSyncComplete001 no peer device :e:' + error); - }); - }catch(e) { - console.log('testDeviceKvStoreOnSyncComplete001 put e ' + e); + } catch (e) { + console.log('testDeviceKvStoreOnSyncComplete001 sync no peer device :e:' + e); + } + } catch(e) { + console.log('testDeviceKvStoreOnSyncComplete001 e ' + e); expect(null).assertFail(); } done(); @@ -887,13 +892,18 @@ describe('DeviceKvStorePromiseTest', function () { await kvStore.put(KEY_TEST_SYNC_ELEMENT, VALUE_TEST_SYNC_ELEMENT).then((data) => { console.log('testDeviceKvStoreOnSyncComplete002 put success'); expect(data == undefined).assertTrue(); + }).catch((error) => { + console.log('testDeviceKvStoreOnSyncComplete002 put failed:' + e); + expect(null).assertFail(); + }); + try { var devices = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB']; var mode = factory.SyncMode.PUSH_ONLY; kvStore.sync(devices, mode); - }).catch((error) => { + } catch(error) { console.log('testDeviceKvStoreOnSyncComplete002 no peer device :e:' + error); - }); - }catch(e) { + }; + } catch(e) { console.log('testDeviceKvStoreOnSyncComplete002 put e ' + e); expect(null).assertFail(); } @@ -914,13 +924,18 @@ describe('DeviceKvStorePromiseTest', function () { await kvStore.put(KEY_TEST_SYNC_ELEMENT, VALUE_TEST_SYNC_ELEMENT).then((data) => { console.log('testDeviceKvStoreOnSyncComplete003 put success'); expect(data == undefined).assertTrue(); + }).catch((error) => { + console.log('testDeviceKvStoreOnSyncComplete002 put failed:' + e); + expect(null).assertFail(); + }); + try { var devices = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB']; var mode = factory.SyncMode.PUSH_PULL; kvStore.sync(devices, mode); - }).catch((error) => { + } catch(error) { console.log('testDeviceKvStoreOnSyncComplete003 no peer device :e:' + error); - }); - }catch(e) { + }; + } catch(e) { console.log('testDeviceKvStoreOnSyncComplete003 put e ' + e); expect(null).assertFail(); } diff --git a/distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/SchemaJsunit.test.js b/distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/SchemaJsunit.test.js index 2c19f8ded76181521ebfcd6dfffb8b7154ecd1fd..af901a6f16c870cbb634b4460ac006aecfc48450 100644 --- a/distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/SchemaJsunit.test.js +++ b/distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/SchemaJsunit.test.js @@ -262,4 +262,25 @@ describe('SchemaTest', function() { } done(); }) + + /** + * @tc.number SUB_DISTRIBUTEDDATAMGR_SCHEMA_TOJSONSTRING_0400 + * @tc.name [JS-API8]Schema.ToJsonString() + * @tc.desc Test Js Api Schema.ToJsonString() testcase 004 + */ + it('testToJsonString004', 0, async function(done) { + try { + let english = new ddm.FieldNode('english'); + english.type = ddm.ValueType.STRING; + + let schema = new ddm.Schema(); + schema.root.appendChild(english); + schema.indexes = []; // indexex set to empty array. + console.log("schema: " + schema.toJsonString()); + } catch (e) { + console.log("schema fail on exception: " + e); + expect(null).assertFail(); + } + done(); + }) }) \ No newline at end of file diff --git a/distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/SingleKvStoreCallbackJsunit.test.js b/distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/SingleKvStoreCallbackJsunit.test.js index 9aa1dc4eeed838afaa832e53a0a416f456920109..9f428a3dfa5f37b4951d891c6f8cfc033cc05092 100755 --- a/distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/SingleKvStoreCallbackJsunit.test.js +++ b/distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/SingleKvStoreCallbackJsunit.test.js @@ -821,11 +821,14 @@ describe('SingleKvStoreCallbackTest', function () { await kvStore.put(KEY_TEST_SYNC_ELEMENT + 'testSync101', VALUE_TEST_SYNC_ELEMENT, function (err,data) { console.log('testSingleKvStoreOnSyncComplete101 put success'); expect(err == undefined).assertTrue(); + }); + try { var devices = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB']; var mode = factory.SyncMode.PULL_ONLY; kvStore.sync(devices, mode, 10); - done(); - }); + } catch (e) { + console.log('testSingleKvStoreOnSyncComplete101 sync no peer device :e:' + e); + } }catch(e) { console.log('testSingleKvStoreOnSyncComplete101 e' + e); expect(null).assertFail(); @@ -844,19 +847,22 @@ describe('SingleKvStoreCallbackTest', function () { console.log('testSingleKvStoreOnSyncComplete102 dataChange'); expect(data != null).assertTrue(); }); - await kvStore.put(KEY_TEST_SYNC_ELEMENT + 'testSync101', VALUE_TEST_SYNC_ELEMENT, function (err,data) { + await kvStore.put(KEY_TEST_SYNC_ELEMENT + 'testSync102', VALUE_TEST_SYNC_ELEMENT, function (err,data) { console.log('testSingleKvStoreOnSyncComplete102 put success'); expect(err == undefined).assertTrue(); + }); + try { var devices = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB']; var mode = factory.SyncMode.PUSH_ONLY; kvStore.sync(devices, mode, 10); - done(); - }); + } catch (e) { + console.log('testSingleKvStoreOnSyncComplete102 sync no peer device :e:' + e); + } }catch(e) { console.log('testSingleKvStoreOnSyncComplete102 e' + e); expect(null).assertFail(); - done(); } + done(); }) /** @@ -870,19 +876,22 @@ describe('SingleKvStoreCallbackTest', function () { console.log('testSingleKvStoreOnSyncComplete103 dataChange'); expect(data != null).assertTrue(); }); - await kvStore.put(KEY_TEST_SYNC_ELEMENT + 'testSync101', VALUE_TEST_SYNC_ELEMENT, function (err,data) { + await kvStore.put(KEY_TEST_SYNC_ELEMENT + 'testSync103', VALUE_TEST_SYNC_ELEMENT, function (err,data) { console.log('testSingleKvStoreOnSyncComplete103 put success'); expect(err == undefined).assertTrue(); + }); + try { var devices = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB']; var mode = factory.SyncMode.PUSH_PULL; kvStore.sync(devices, mode, 10); - done(); - }); + } catch (e) { + console.log('testSingleKvStoreOnSyncComplete103 sync no peer device :e:' + e); + } }catch(e) { console.log('testSingleKvStoreOnSyncComplete103 e' + e); expect(null).assertFail(); - done(); } + done(); }) /** diff --git a/distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/SingleKvStorePromiseJsunit.test.js b/distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/SingleKvStorePromiseJsunit.test.js index a1dd76880f68f09d9c805bf3a7d08cc49e5def8d..68fdfd3312c71192deba39b190592fa9a5a07815 100755 --- a/distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/SingleKvStorePromiseJsunit.test.js +++ b/distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/SingleKvStorePromiseJsunit.test.js @@ -830,15 +830,19 @@ describe('SingleKvStorePromiseTest', function () { await kvStore.put(KEY_TEST_SYNC_ELEMENT, VALUE_TEST_SYNC_ELEMENT).then((data) => { console.log('testSingleKvStoreOnSyncComplete001 put success'); expect(data == undefined).assertTrue(); - var devices = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB']; - var mode = factory.SyncMode.PULL_ONLY; - kvStore.sync(devices, mode, 10); }).catch((error) => { console.log('testSingleKvStoreOnSyncComplete001 put fail ' + error); expect(null).assertFail(); }); + try { + var devices = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB']; + var mode = factory.SyncMode.PULL_ONLY; + kvStore.sync(devices, mode, 10); + } catch (e) { + console.log('testSingleKvStoreOnSyncComplete001 sync no peer device :e:' + e); + } }catch(e) { - console.log('testSingleKvStoreOnSyncComplete001 put e ' + e); + console.log('testSingleKvStoreOnSyncComplete001 e ' + e); expect(null).assertFail(); } done(); @@ -858,15 +862,19 @@ describe('SingleKvStorePromiseTest', function () { await kvStore.put(KEY_TEST_SYNC_ELEMENT, VALUE_TEST_SYNC_ELEMENT).then((data) => { console.log('testSingleKvStoreOnSyncComplete002 put success'); expect(data == undefined).assertTrue(); - var devices = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB']; - var mode = factory.SyncMode.PUSH_ONLY; - kvStore.sync(devices, mode, 10); }).catch((error) => { console.log('testSingleKvStoreOnSyncComplete002 put fail ' + error); expect(null).assertFail(); }); + try { + var devices = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB']; + var mode = factory.SyncMode.PUSH_ONLY; + kvStore.sync(devices, mode, 10); + } catch (e) { + console.log('testSingleKvStoreOnSyncComplete002 sync no peer device :e:' + e); + } }catch(e) { - console.log('testSingleKvStoreOnSyncComplete002 put e ' + e); + console.log('testSingleKvStoreOnSyncComplete002 e ' + e); expect(null).assertFail(); } done(); @@ -886,15 +894,19 @@ describe('SingleKvStorePromiseTest', function () { await kvStore.put(KEY_TEST_SYNC_ELEMENT, VALUE_TEST_SYNC_ELEMENT).then((data) => { console.log('testSingleKvStoreOnSyncComplete003 put success'); expect(data == undefined).assertTrue(); - var devices = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB']; - var mode = factory.SyncMode.PUSH_PULL; - kvStore.sync(devices, mode, 10); }).catch((error) => { console.log('testSingleKvStoreOnSyncComplete003 put fail ' + error); expect(null).assertFail(); }); + try { + var devices = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB']; + var mode = factory.SyncMode.PUSH_PULL; + kvStore.sync(devices, mode, 10); + } catch (e) { + console.log('testSingleKvStoreOnSyncComplete003 sync no peer device :e:' + e); + } }catch(e) { - console.log('testSingleKvStoreOnSyncComplete003 put e ' + e); + console.log('testSingleKvStoreOnSyncComplete003 e ' + e); expect(null).assertFail(); } done();