diff --git a/distributeddatamgr/BUILD.gn b/distributeddatamgr/BUILD.gn
index 5abec885da6193710bd8701c74197b4c4198cf49..77f131ccd2c8c41e6070dfed655535d2f63b38e4 100755
--- a/distributeddatamgr/BUILD.gn
+++ b/distributeddatamgr/BUILD.gn
@@ -17,6 +17,7 @@ group("distributeddatamgr") {
if (is_standard_system) {
deps = [
"appdatamgrjstest/hap:appdatamgr_js_test",
+ "distributeddatamgrjstest/hap:distributeddatamgr_js_test",
"distributedfilejstest:distributedfile_js_test",
]
} else {
diff --git a/distributeddatamgr/distributeddatamgrjstest/hap/BUILD.gn b/distributeddatamgr/distributeddatamgrjstest/hap/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..73aec025eae3e34eeb2d0dc98b6cb091ff403c42
--- /dev/null
+++ b/distributeddatamgr/distributeddatamgrjstest/hap/BUILD.gn
@@ -0,0 +1,18 @@
+# Copyright (C) 2021 Huawei Device Co., Ltd.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+import("//test/xts/tools/build/suite.gni")
+
+ohos_js_hap_suite("distributeddatamgr_js_test") {
+ test_hap_name = "DistributeddatamgrJsTest"
+ hap_source_path = "entry-test-signed.hap"
+}
diff --git a/distributeddatamgr/distributeddatamgrjstest/hap/Test.json b/distributeddatamgr/distributeddatamgrjstest/hap/Test.json
new file mode 100644
index 0000000000000000000000000000000000000000..422336d25155596e8c23af64b33cecc5b91a19a5
--- /dev/null
+++ b/distributeddatamgr/distributeddatamgrjstest/hap/Test.json
@@ -0,0 +1,19 @@
+{
+ "description": "Configuration for hjunit demo Tests",
+ "driver": {
+ "type": "JSUnitTest",
+ "test-timeout": "21600000",
+ "package": "com.example.datamanagertest",
+ "abilityName": "decc.testkit.runner.JsEntryAbility",
+ "shell-timeout": "21600000"
+ },
+ "kits": [
+ {
+ "test-file-name": [
+ "DistributeddatamgrJsTest.hap"
+ ],
+ "type": "AppInstallKit",
+ "cleanup-apps": true
+ }
+ ]
+}
diff --git a/distributeddatamgr/distributeddatamgrjstest/hap/entry-test-signed.hap b/distributeddatamgr/distributeddatamgrjstest/hap/entry-test-signed.hap
new file mode 100644
index 0000000000000000000000000000000000000000..29962716e598b05f97dadaf110a5154167236942
Binary files /dev/null and b/distributeddatamgr/distributeddatamgrjstest/hap/entry-test-signed.hap differ
diff --git a/distributeddatamgr/distributeddatamgrjstest/hap/entry/package.json b/distributeddatamgr/distributeddatamgrjstest/hap/entry/package.json
new file mode 100644
index 0000000000000000000000000000000000000000..0967ef424bce6791893e9a57bb952f80fd536e93
--- /dev/null
+++ b/distributeddatamgr/distributeddatamgrjstest/hap/entry/package.json
@@ -0,0 +1 @@
+{}
diff --git a/distributeddatamgr/distributeddatamgrjstest/hap/entry/src/main/config.json b/distributeddatamgr/distributeddatamgrjstest/hap/entry/src/main/config.json
new file mode 100644
index 0000000000000000000000000000000000000000..4dc11536b60a180dea101e5edfdd9c62b62c84cd
--- /dev/null
+++ b/distributeddatamgr/distributeddatamgrjstest/hap/entry/src/main/config.json
@@ -0,0 +1,57 @@
+{
+ "app": {
+ "bundleName": "com.example.datamanagertest",
+ "vendor": "example",
+ "version": {
+ "code": 2000000,
+ "name": "2.0.0"
+ }
+ },
+ "deviceConfig": {},
+ "module": {
+ "package": "com.example.datamanagertest",
+ "name": ".MyApplication",
+ "mainAbility": "com.example.datamanagertest.MainAbility",
+ "deviceType": [
+ "phone"
+ ],
+ "distro": {
+ "deliveryWithInstall": true,
+ "moduleName": "entry",
+ "moduleType": "entry",
+ "installationFree": false
+ },
+ "abilities": [
+ {
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ],
+ "name": "com.example.datamanagertest.MainAbility",
+ "icon": "$media:icon",
+ "description": "$string:mainability_description",
+ "label": "$string:app_name",
+ "type": "page",
+ "launchType": "standard"
+ }
+ ],
+ "js": [
+ {
+ "pages": [
+ "pages/index/index"
+ ],
+ "name": "default",
+ "window": {
+ "designWidth": 720,
+ "autoDesignWidth": true
+ }
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/distributeddatamgr/distributeddatamgrjstest/hap/entry/src/main/js/default/app.js b/distributeddatamgr/distributeddatamgrjstest/hap/entry/src/main/js/default/app.js
new file mode 100644
index 0000000000000000000000000000000000000000..6a06f7f6cad18519bf28b42a2a171b69d2140f32
--- /dev/null
+++ b/distributeddatamgr/distributeddatamgrjstest/hap/entry/src/main/js/default/app.js
@@ -0,0 +1,22 @@
+/*
+* Copyright (c) 2021 Huawei Device Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+export default {
+ onCreate() {
+ console.info('TestApplication onCreate');
+ },
+ onDestroy() {
+ console.info('TestApplication onDestroy');
+ }
+};
diff --git a/distributeddatamgr/distributeddatamgrjstest/hap/entry/src/main/js/default/i18n/en-US.json b/distributeddatamgr/distributeddatamgrjstest/hap/entry/src/main/js/default/i18n/en-US.json
new file mode 100644
index 0000000000000000000000000000000000000000..55561b83737c3c31d082fbfa11e5fc987a351104
--- /dev/null
+++ b/distributeddatamgr/distributeddatamgrjstest/hap/entry/src/main/js/default/i18n/en-US.json
@@ -0,0 +1,8 @@
+{
+ "strings": {
+ "hello": "Hello",
+ "world": "World"
+ },
+ "Files": {
+ }
+}
\ No newline at end of file
diff --git a/distributeddatamgr/distributeddatamgrjstest/hap/entry/src/main/js/default/i18n/zh-CN.json b/distributeddatamgr/distributeddatamgrjstest/hap/entry/src/main/js/default/i18n/zh-CN.json
new file mode 100644
index 0000000000000000000000000000000000000000..cce1af06761a42add0cac1a0567aa3237eda8cb4
--- /dev/null
+++ b/distributeddatamgr/distributeddatamgrjstest/hap/entry/src/main/js/default/i18n/zh-CN.json
@@ -0,0 +1,8 @@
+{
+ "strings": {
+ "hello": "您好",
+ "world": "世界"
+ },
+ "Files": {
+ }
+}
\ No newline at end of file
diff --git a/distributeddatamgr/distributeddatamgrjstest/hap/entry/src/main/js/default/pages/index/index.css b/distributeddatamgr/distributeddatamgrjstest/hap/entry/src/main/js/default/pages/index/index.css
new file mode 100644
index 0000000000000000000000000000000000000000..e19021816bc61bc4cb5128677386b9789132e270
--- /dev/null
+++ b/distributeddatamgr/distributeddatamgrjstest/hap/entry/src/main/js/default/pages/index/index.css
@@ -0,0 +1,23 @@
+/*
+* Copyright (c) 2021 Huawei Device Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+.container {
+ flex-direction: column;
+ justify-content: center;
+ align-items: center;
+}
+
+.title {
+ font-size: 100px;
+}
diff --git a/distributeddatamgr/distributeddatamgrjstest/hap/entry/src/main/js/default/pages/index/index.hml b/distributeddatamgr/distributeddatamgrjstest/hap/entry/src/main/js/default/pages/index/index.hml
new file mode 100644
index 0000000000000000000000000000000000000000..1c26cf73deab18390844a53a103458b10ed11e93
--- /dev/null
+++ b/distributeddatamgr/distributeddatamgrjstest/hap/entry/src/main/js/default/pages/index/index.hml
@@ -0,0 +1,5 @@
+
+
+ {{ $t('strings.hello') }} {{title}}
+
+
diff --git a/distributeddatamgr/distributeddatamgrjstest/hap/entry/src/main/js/default/pages/index/index.js b/distributeddatamgr/distributeddatamgrjstest/hap/entry/src/main/js/default/pages/index/index.js
new file mode 100644
index 0000000000000000000000000000000000000000..272eebb28dfe4e80731e71da8a4eee94ac5aae91
--- /dev/null
+++ b/distributeddatamgr/distributeddatamgrjstest/hap/entry/src/main/js/default/pages/index/index.js
@@ -0,0 +1,33 @@
+/*
+* Copyright (c) 2021 Huawei Device Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+import {Core} from 'deccjsunit/index'
+
+export default {
+ data: {
+ title: ""
+ },
+ onInit() {
+ this.title = this.$t('strings.world');
+ },
+ onShow() {
+ console.info('onShow finish')
+ const core = Core.getInstance()
+ core.init()
+ require('../../../test/List.test')
+ core.execute()
+ },
+ onReady() {
+ },
+}
\ No newline at end of file
diff --git a/distributeddatamgr/distributeddatamgrjstest/hap/entry/src/main/js/test/List.test.js b/distributeddatamgr/distributeddatamgrjstest/hap/entry/src/main/js/test/List.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..4ecd4949e16c855b201d9369f46d3773119d1c48
--- /dev/null
+++ b/distributeddatamgr/distributeddatamgrjstest/hap/entry/src/main/js/test/List.test.js
@@ -0,0 +1,2 @@
+require('./SingleKvStorePromiseJsunit.test.js')
+require('./SingleKvStoreCallbackJsunit.test.js')
\ No newline at end of file
diff --git a/distributeddatamgr/distributeddatamgrjstest/hap/entry/src/main/js/test/SingleKvStoreCallbackJsunit.test.js b/distributeddatamgr/distributeddatamgrjstest/hap/entry/src/main/js/test/SingleKvStoreCallbackJsunit.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..1924d94e3ea0893ea489cd9a3b0bd3fe4fe306de
--- /dev/null
+++ b/distributeddatamgr/distributeddatamgrjstest/hap/entry/src/main/js/test/SingleKvStoreCallbackJsunit.test.js
@@ -0,0 +1,325 @@
+/*
+* Copyright (c) 2021 Huawei Device Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
+import factory from '@ohos.data.distributeddata'
+
+const KEY_TEST_INT_ELEMENT = 'key_test_int_2';
+const KEY_TEST_FLOAT_ELEMENT = 'key_test_float_2';
+const KEY_TEST_BOOLEAN_ELEMENT = 'key_test_boolean_2';
+const KEY_TEST_STRING_ELEMENT = 'key_test_string_2';
+
+const VALUE_TEST_INT_ELEMENT = 1234;
+const VALUE_TEST_FLOAT_ELEMENT = 4321.12;
+const VALUE_TEST_BOOLEAN_ELEMENT = true;
+const VALUE_TEST_STRING_ELEMENT = 'value-string-002';
+
+var kvManager = null;
+var kvStore = null;
+
+describe('KvStoreTest', function () {
+ const config = {
+ bundleName : 'com.example.datamanagertest',
+ userInfo : {
+ userId : '0',
+ userType : 0
+ }
+ }
+
+ const options = {
+ createIfMissing : true,
+ encrypt : false,
+ backup : false,
+ autoSync : true,
+ kvStoreType : 1,
+ schema : '',
+ securityLevel : 3,
+ }
+
+ it('testCreateKVManager102', 0, async function (done) {
+ try {
+ await factory.createKVManager(null, function (err, manager) {
+ kvManager = manager;
+ expect(false).assertEqual(manager == null);
+ });
+ }catch (e) {
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ it('testCreateKVManager103', 0, async function (done) {
+ try {
+ await factory.createKVManager('', function (err, manager) {
+ kvManager = manager;
+ expect(false).assertEqual(manager == null);
+ });
+ }catch(e) {
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ it('testCreateKVManager101', 0, async function (done) {
+ try {
+ await factory.createKVManager(config, function (err, manager) {
+ kvManager = manager;
+ expect(false).assertEqual(manager == null);
+ });
+ }catch(e) {
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ it('testGetKVStore101', 0, async function (done) {
+ try {
+ await kvManager.getKVStore(options, function (err, store) {
+ kvStore = store;
+ expect(false).assertEqual(store == null);
+ });
+ expect(null).assertFail();
+ }catch(e) {
+ }
+ done();
+ })
+
+ it('testGetKVStore101', 0, async function (done) {
+ try {
+ await kvManager.getKVStore('storeId', options, function (err, store) {
+ kvStore = store;
+ expect(false).assertEqual(store == null);
+ });
+ }catch(e) {
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ it('testPutString101', 0, async function (done) {
+ try {
+ await kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, function (err,data) {
+ if (err != undefined) {
+ expect(null).assertFail();
+ }
+ });
+ }catch (e) {
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ it('testGetString101', 0, async function (done) {
+ try{
+ await kvStore.get(KEY_TEST_STRING_ELEMENT, function (err,data) {
+ expect(VALUE_TEST_STRING_ELEMENT).assertEqual(data);
+ });
+ }catch(e) {
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ it('testPutString102', 0, async function (done) {
+ try {
+ var str = '';
+ for (var i = 0 ; i < 4095; i++) {
+ str += 'x';
+ }
+ await kvStore.put(KEY_TEST_STRING_ELEMENT+'102', str, function (err,data) {
+ kvStore.get(KEY_TEST_STRING_ELEMENT+'102', function (err,data) {
+ expect(str).assertEqual(data);
+ });
+ });
+ }catch (e) {
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ it('testPutInt101', 0, async function (done) {
+ try {
+ await kvStore.put(KEY_TEST_INT_ELEMENT, VALUE_TEST_INT_ELEMENT, function (err,data) {
+ if (err != undefined) {
+ expect(null).assertFail();
+ }
+ });
+ }catch(e) {
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ it('testGetInt101', 0, async function (done) {
+ try {
+ await kvStore.get(KEY_TEST_INT_ELEMENT, function (err,data) {
+ expect(VALUE_TEST_INT_ELEMENT).assertEqual(data);
+ });
+ }catch(e) {
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ it('testPutBoolean101', 0, async function (done) {
+ try {
+ await kvStore.put(KEY_TEST_BOOLEAN_ELEMENT, VALUE_TEST_BOOLEAN_ELEMENT, function (err,data) {
+ if (err != undefined) {
+ expect(null).assertFail();
+ }
+ });
+ }catch(e) {
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ it('testGetBoolean101', 0, async function (done) {
+ try {
+ await kvStore.get(KEY_TEST_BOOLEAN_ELEMENT, function (err,data) {
+ expect(VALUE_TEST_BOOLEAN_ELEMENT).assertEqual(data);
+ });
+ }catch(e) {
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ it('testPutFloat101', 0, async function (done) {
+ try {
+ await kvStore.put(KEY_TEST_FLOAT_ELEMENT, VALUE_TEST_FLOAT_ELEMENT, function (err,data) {
+ if (err != undefined) {
+ expect(null).assertFail();
+ }
+ });
+ }catch(e) {
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ it('testGetFloat101', 0, async function (done) {
+ try {
+ await kvStore.get(KEY_TEST_FLOAT_ELEMENT, function (err,data) {
+ expect(VALUE_TEST_FLOAT_ELEMENT).assertEqual(data);
+ });
+ }catch(e) {
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ it('testDeleteString101', 0, async function (done) {
+ try {
+ await kvStore.delete(KEY_TEST_STRING_ELEMENT, function (err,data) {
+ if (err != undefined) {
+ expect(null).assertFail();
+ }
+ });
+ }catch(e) {
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ it('testDeleteInt101', 0, async function (done) {
+ try{
+ await kvStore.delete(KEY_TEST_INT_ELEMENT, function (err,data) {
+ if (err != undefined) {
+ expect(null).assertFail();
+ }
+ });
+ }catch(e) {
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ it('testDeleteFloat101', 0, async function (done) {
+ try{
+ await kvStore.delete(KEY_TEST_FLOAT_ELEMENT, function (err,data) {
+ if (err != undefined) {
+ expect(null).assertFail();
+ }
+ });
+ }catch(e) {
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ it('testDeleteBoolean101', 0, async function (done) {
+ try{
+ await kvStore.delete(KEY_TEST_BOOLEAN_ELEMENT, function (err,data) {
+ if (err != undefined) {
+ expect(null).assertFail();
+ }
+ });
+ }catch(e) {
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ it('testOnChange101', 0, async function (done) {
+ try {
+ kvStore.on('dataChange', 0, function (data) {
+ expect(true).assertEqual(data !=null);
+ });
+ await kvStore.put(KEY_TEST_FLOAT_ELEMENT, VALUE_TEST_FLOAT_ELEMENT, function (err,data) {
+ if (err != undefined) {
+ expect(null).assertFail();
+ }
+ });
+ await(3000);
+ }catch(e) {
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ it('testOnChange101', 0, async function (done) {
+ try {
+ kvStore.on('dataChange', 1, function (data) {
+ expect(true).assertEqual(data !=null);
+ });
+ await kvStore.put(KEY_TEST_FLOAT_ELEMENT, VALUE_TEST_FLOAT_ELEMENT, function (err,data) {
+ if (err != undefined) {
+ expect(null).assertFail();
+ }
+ });
+ await(3000);
+ }catch(e) {
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ it('testOnChange102', 0, async function (done) {
+ try {
+ kvStore.on('dataChange', 2, function (data) {
+ expect(true).assertEqual(data !=null);
+ });
+ await kvStore.put(KEY_TEST_FLOAT_ELEMENT+ '102', VALUE_TEST_FLOAT_ELEMENT, function (err,data) {
+ if (err != undefined) {
+ expect(null).assertFail();
+ }
+ });
+ await(3000);
+ }catch(e) {
+ expect(null).assertFail();
+ }
+ done();
+ })
+})
\ No newline at end of file
diff --git a/distributeddatamgr/distributeddatamgrjstest/hap/entry/src/main/js/test/SingleKvStorePromiseJsunit.test.js b/distributeddatamgr/distributeddatamgrjstest/hap/entry/src/main/js/test/SingleKvStorePromiseJsunit.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..1d1ca0791d494741baf2a5a7fb60486a6c828b77
--- /dev/null
+++ b/distributeddatamgr/distributeddatamgrjstest/hap/entry/src/main/js/test/SingleKvStorePromiseJsunit.test.js
@@ -0,0 +1,594 @@
+/*
+* Copyright (c) 2021 Huawei Device Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
+import factory from '@ohos.data.distributeddata'
+
+const KEY_TEST_INT_ELEMENT = 'key_test_int';
+const KEY_TEST_FLOAT_ELEMENT = 'key_test_float';
+const KEY_TEST_BOOLEAN_ELEMENT = 'key_test_boolean';
+const KEY_TEST_STRING_ELEMENT = 'key_test_string';
+
+const VALUE_TEST_INT_ELEMENT = 123;
+const VALUE_TEST_FLOAT_ELEMENT = 321.12;
+const VALUE_TEST_BOOLEAN_ELEMENT = true;
+const VALUE_TEST_STRING_ELEMENT = 'value-string-001';
+
+var kvManager = null;
+var kvStore = null;
+
+describe('KvStoreTest', function () {
+ const config = {
+ bundleName : 'com.example.datamanagertest',
+ userInfo : {
+ userId : '0',
+ userType : 0
+ }
+ }
+
+ const options = {
+ createIfMissing : true,
+ encrypt : false,
+ backup : false,
+ autoSync : true,
+ kvStoreType : 1,
+ schema : '',
+ securityLevel : 3,
+ }
+
+ it('testCreateKVManager001', 0, async function (done) {
+ try {
+ const promise = factory.createKVManager(config);
+ promise.then((manager) => {
+ kvManager = manager;
+ expect(false).assertEqual(manager == null);
+ }).catch((err) => {
+ expect(null).assertFail();
+ });
+ await promise;
+ }catch (e) {
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ it('testGetKVStore001', 0, async function (done) {
+ try {
+ const promise = kvManager.getKVStore(options);
+ promise.then((store) => {
+ kvStore = store;
+ expect(false).assertEqual(store == null);
+ }).catch((err) => {
+ expect(null).assertFail();
+ });
+ expect(null).assertFail();
+ await promise;
+ } catch (e) {
+ }
+ done();
+ })
+
+ it('testGetKVStore001', 0, async function (done) {
+ try {
+ const promise = kvManager.getKVStore('storeId', options);
+ promise.then((store) => {
+ kvStore = store;
+ expect(false).assertEqual(store == null);
+ }).catch((err) => {
+ expect(null).assertFail();
+ });
+ await promise;
+ }catch(e) {
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ it('testPutString003', 0, async function (done) {
+ try {
+ const promise = kvStore.put(KEY_TEST_STRING_ELEMENT, null);
+ promise.then((data) => {
+ }).catch((err) => {
+ expect(null).assertFail();
+ });
+ await promise;
+ } catch (e) {
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ it('testPutString004', 0, async function (done) {
+ try {
+ const promise = kvStore.put(KEY_TEST_STRING_ELEMENT, '');
+ promise.then((data) => {
+ }).catch((err) => {
+ expect(null).assertFail();
+ });
+ await promise;
+ } catch (e) {
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ it('testPutString0051', 0, async function (done) {
+ try {
+ const promise = kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT);
+ promise.then((data) => {
+ }).catch((err) => {
+ expect(null).assertFail();
+ });
+ await promise;
+ } catch (e) {
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ it('testGetString001', 0, async function (done) {
+ try {
+ const promise = kvStore.get(KEY_TEST_STRING_ELEMENT);
+ promise.then((data) => {
+ expect(VALUE_TEST_STRING_ELEMENT).assertEqual(data);
+ }).catch((err) => {
+ expect(null).assertFail();
+ });
+ await promise;
+ }catch (e){
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ it('testPutString0021', 0, async function (done) {
+ try {
+ var str = '';
+ for (var i = 0 ; i < 4095; i++) {
+ str += 'x';
+ }
+ const promise = kvStore.put(KEY_TEST_STRING_ELEMENT+'002', str);
+ promise.then((data) => {
+ }).catch((err) => {
+ expect(null).assertFail();
+ });
+ await promise;
+
+ const promise1 = kvStore.get(KEY_TEST_STRING_ELEMENT + '002');
+ promise1.then((data) => {
+ expect(str).assertEqual(data);
+ }).catch((err) => {
+ expect(null).assertFail();
+ });
+ await promise1;
+ }catch (e) {
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ it('testPutString005', 0, async function (done) {
+ try {
+ const promise1 = kvStore.get(KEY_TEST_STRING_ELEMENT + '005');
+ promise1.then((data) => {
+ expect(null).assertFail();
+ }).catch((err) => {
+ });
+ await promise1;
+ }catch(e) {
+ }
+ done();
+ })
+
+ it('testPutInt001', 0, async function (done) {
+ try {
+ const promise = kvStore.put(KEY_TEST_INT_ELEMENT, VALUE_TEST_INT_ELEMENT);
+ promise.then((data) => {
+ }).catch((err) => {
+ expect(null).assertFail();
+ });
+ await promise;
+ }catch(e) {
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ it('testGetInt001', 0, async function (done) {
+ try {
+ const promise = kvStore.put(KEY_TEST_INT_ELEMENT+ '001', VALUE_TEST_INT_ELEMENT);
+ promise.then((data) => {
+ }).catch((err) => {
+ expect(null).assertFail();
+ });
+ await promise;
+ const promise1 = kvStore.get(KEY_TEST_INT_ELEMENT+ '001');
+ promise1.then((data) => {
+ expect(VALUE_TEST_INT_ELEMENT).assertEqual(data);
+ }).catch((err) => {
+ expect(null).assertFail();
+ });
+ await promise1;
+ }catch(e) {
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ it('testPutInt002', 0, async function (done) {
+ try {
+ var intValue = 987654321;
+ const promise = kvStore.put(KEY_TEST_INT_ELEMENT+'002', intValue);
+ promise.then((data) => {
+ }).catch((err) => {
+ expect(null).assertFail();
+ });
+ await promise;
+
+ const promise1 = kvStore.get(KEY_TEST_INT_ELEMENT+'002');
+ promise1.then((data) => {
+ expect(intValue).assertEqual(data);
+ }).catch((err) => {
+ expect(null).assertFail();
+ });
+ await promise1;
+ }catch(e) {
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ it('testPutInt003', 0, async function (done) {
+ try{
+ var intValue = Number.MAX_VALUE;
+ const promise = kvStore.put(KEY_TEST_INT_ELEMENT+'003', intValue);
+ promise.then((data) => {
+ }).catch((err) => {
+ expect(null).assertFail();
+ });
+ await promise;
+
+ const promise1 = kvStore.get(KEY_TEST_INT_ELEMENT+'003');
+ promise1.then((data) => {
+ expect(intValue).assertEqual(data);
+ }).catch((err) => {
+ expect(null).assertFail();
+ });
+ await promise1;
+ }catch(e) {
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ it('testPutInt004', 0, async function (done) {
+ try{
+ var intValue = Number.MIN_VALUE;
+ const promise = kvStore.put(KEY_TEST_INT_ELEMENT+'004', intValue);
+ promise.then((data) => {
+ }).catch((err) => {
+ expect(null).assertFail();
+ });
+ await promise;
+
+ const promise1 = kvStore.get(KEY_TEST_INT_ELEMENT+'004');
+ promise1.then((data) => {
+ expect(intValue).assertEqual(data);
+ }).catch((err) => {
+ expect(null).assertFail();
+ });
+ await promise1;
+ }catch(e) {
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ it('testPutBoolean001', 0, async function (done) {
+ try{
+ const promise = kvStore.put(KEY_TEST_BOOLEAN_ELEMENT, VALUE_TEST_BOOLEAN_ELEMENT);
+ promise.then((data) => {
+ }).catch((err) => {
+ expect(null).assertFail();
+ });
+ await promise;
+ }catch(e) {
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ it('testGetBoolean002', 0, async function (done) {
+ var boolValue = false;
+ const promise = kvStore.put(KEY_TEST_BOOLEAN_ELEMENT+ '002', boolValue);
+ promise.then((data) => {
+ }).catch((err) => {
+ expect(null).assertFail();
+ });
+ await promise;
+ const promise1 = kvStore.get(KEY_TEST_BOOLEAN_ELEMENT+ '002');
+ promise1.then((data) => {
+ expect(boolValue).assertEqual(data);
+ }).catch((err) => {
+ expect(null).assertFail();
+ });
+ await promise1;
+ done();
+ })
+
+ it('testPutFloat001', 0, async function (done) {
+ try {
+ const promise = kvStore.put(KEY_TEST_FLOAT_ELEMENT, VALUE_TEST_FLOAT_ELEMENT);
+ promise.then((data) => {
+ }).catch((err) => {
+ expect(null).assertFail();
+ });
+ await promise;
+ }catch(e) {
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ it('testGetFloat002', 0, async function (done) {
+ try {
+ var floatValue = 123456.654321;
+ const promise = kvStore.put(KEY_TEST_FLOAT_ELEMENT+ '002', floatValue);
+ promise.then((data) => {
+ }).catch((err) => {
+ expect(null).assertFail();
+ });
+ await promise;
+ const promise1 = kvStore.get(KEY_TEST_FLOAT_ELEMENT+ '002');
+ promise1.then((data) => {
+ expect(floatValue).assertEqual(data);
+ }).catch((err) => {
+ expect(null).assertFail();
+ });
+ await promise1;
+ }catch (e) {
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ it('testGetFloat003', 0, async function (done) {
+ try {
+ var floatValue = 123456.0;
+ const promise = kvStore.put(KEY_TEST_FLOAT_ELEMENT+ '003', floatValue);
+ promise.then((data) => {
+ }).catch((err) => {
+ expect(null).assertFail();
+ });
+ await promise;
+ const promise1 = kvStore.get(KEY_TEST_FLOAT_ELEMENT+ '003');
+ promise1.then((data) => {
+ expect(floatValue).assertEqual(data);
+ }).catch((err) => {
+ expect(null).assertFail();
+ });
+ await promise1;
+ }catch (e) {
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ it('testGetFloat004', 0, async function (done) {
+ try {
+ var floatValue = 123456.00;
+ const promise = kvStore.put(KEY_TEST_FLOAT_ELEMENT+ '004', floatValue);
+ promise.then((data) => {
+ }).catch((err) => {
+ expect(null).assertFail();
+ });
+ await promise;
+ const promise1 = kvStore.get(KEY_TEST_FLOAT_ELEMENT+ '004');
+ promise1.then((data) => {
+ expect(floatValue).assertEqual(data);
+ }).catch((err) => {
+ expect(null).assertFail();
+ });
+ await promise1;
+ }catch (e) {
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ it('testDeleteString001', 0, async function (done) {
+ try {
+ var str = 'this is a test string';
+ const promise = kvStore.put(KEY_TEST_STRING_ELEMENT+'003', str);
+ promise.then((data) => {
+ }).catch((err) => {
+ expect(null).assertFail();
+ });
+ await promise;
+ const promise1 = kvStore.delete(KEY_TEST_STRING_ELEMENT+'003');
+ promise1.then((data) => {
+ }).catch((err) => {
+ expect(null).assertFail();
+ });
+ await promise1;
+ }catch(e) {
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ it('testDeleteString002', 0, async function (done) {
+ try {
+ var str = '';
+ for (var i = 0 ; i < 4096; i++) {
+ str += 'x';
+ }
+ const promise = kvStore.put(KEY_TEST_STRING_ELEMENT+'003', str);
+ promise.then((data) => {
+ }).catch((err) => {
+ expect(null).assertFail();
+ });
+ await promise;
+
+ const promise1 = kvStore.delete(KEY_TEST_STRING_ELEMENT+'003');
+ promise1.then((data) => {
+ }).catch((err) => {
+ expect(null).assertFail();
+ });
+ await promise1;
+ }catch(e) {
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ it('testDeleteString003', 0, async function (done) {
+ try {
+ const promise1 = kvStore.delete(KEY_TEST_STRING_ELEMENT+'unkonwn');
+ promise1.then((data) => {
+ }).catch((err) => {
+ expect(null).assertFail();
+ });
+ await promise1;
+ }catch(e) {
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ it('testDeleteInt001', 0, async function (done) {
+ try {
+ const promise = kvStore.delete(KEY_TEST_INT_ELEMENT);
+ promise.then((data) => {
+ }).catch((err) => {
+ expect(null).assertFail();
+ });
+ await promise;
+ }catch(e) {
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ it('testDeleteFloat001', 0, async function (done) {
+ try {
+ const promise = kvStore.delete(KEY_TEST_FLOAT_ELEMENT);
+ promise.then((data) => {
+ }).catch((err) => {
+ expect(null).assertFail();
+ });
+ await promise;
+ }catch(e) {
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ it('testDeleteFloat002', 0, async function (done) {
+ try {
+ const promise = kvStore.put(KEY_TEST_FLOAT_ELEMENT+'002', VALUE_TEST_FLOAT_ELEMENT);
+ promise.then((data) => {
+ }).catch((err) => {
+ expect(null).assertFail();
+ });
+ await promise;
+ const promise1 = kvStore.delete(KEY_TEST_FLOAT_ELEMENT+'002');
+ promise1.then((data) => {
+ }).catch((err) => {
+ expect(null).assertFail();
+ });
+ await promise1;
+ const promise2 = kvStore.delete(KEY_TEST_FLOAT_ELEMENT+'002');
+ promise2.then((data) => {
+ }).catch((err) => {
+ expect(null).assertFail();
+ });
+ await promise2;
+ }catch(e) {
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ it('testDeleteBoolean001', 0, async function (done) {
+ try {
+ const promise = kvStore.delete(KEY_TEST_BOOLEAN_ELEMENT);
+ promise.then((data) => {
+ }).catch((err) => {
+ expect(null).assertFail();
+ });
+ await promise;
+ }catch (e) {
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ it('testOnChange001', 0, async function (done) {
+ try {
+ kvStore.on('dataChange', 0, function (data) {
+ console.log('testOnChange001 0' + data)
+ expect(true).assertEqual(data !=null);
+ });
+ const promise = kvStore.put(KEY_TEST_FLOAT_ELEMENT, VALUE_TEST_FLOAT_ELEMENT);
+ promise.then((data) => {
+ }).catch((err) => {
+ expect(null).assertFail();
+ });
+ await promise;
+ await(3000);
+ }catch(e) {
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ it('testOnChange002', 0, async function (done) {
+ try {
+ kvStore.on('dataChange', 1, function (data) { //remote
+ console.log('testOnChange001 1' + data)
+ expect(true).assertEqual(data !=null);
+ });
+ const promise = kvStore.put(KEY_TEST_INT_ELEMENT + '002', VALUE_TEST_INT_ELEMENT);
+ promise.then((data) => {
+ }).catch((err) => {
+ expect(null).assertFail();
+ });
+ await promise;
+ await(3000);
+ }catch(e) {
+ expect(null).assertFail();
+ }
+ done();
+ })
+
+ it('testOnChange003', 0, async function (done) {
+ try {
+ kvStore.on('dataChange', 2, function (data) {
+ console.log('testOnChange001 2' + data)
+ expect(true).assertEqual(data !=null);
+ });
+ const promise = kvStore.put(KEY_TEST_INT_ELEMENT + '003', VALUE_TEST_INT_ELEMENT);
+ promise.then((data) => {
+ }).catch((err) => {
+ expect(null).assertFail();
+ });
+ await promise;
+ await(3000);
+ }catch(e) {
+ expect(null).assertFail();
+ }
+ done();
+ })
+})
\ No newline at end of file
diff --git a/distributeddatamgr/distributeddatamgrjstest/hap/entry/src/main/resources/base/element/string.json b/distributeddatamgr/distributeddatamgrjstest/hap/entry/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..4388f588a5a0d0c4870e009ac8757faf51598432
--- /dev/null
+++ b/distributeddatamgr/distributeddatamgrjstest/hap/entry/src/main/resources/base/element/string.json
@@ -0,0 +1,12 @@
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "MyApplication"
+ },
+ {
+ "name": "mainability_description",
+ "value": "hap sample empty page"
+ }
+ ]
+}
diff --git a/distributeddatamgr/distributeddatamgrjstest/hap/entry/src/main/resources/base/media/icon.png b/distributeddatamgr/distributeddatamgrjstest/hap/entry/src/main/resources/base/media/icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c
Binary files /dev/null and b/distributeddatamgr/distributeddatamgrjstest/hap/entry/src/main/resources/base/media/icon.png differ