diff --git a/kvdb/kvdbTest/.gitignore b/kvdb/kvdbTest/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..fdc0c4a65db238be4186f16e1e0911b1d61fbf31
--- /dev/null
+++ b/kvdb/kvdbTest/.gitignore
@@ -0,0 +1,16 @@
+*.iml
+.gradle
+/local.properties
+/.idea/caches
+/.idea/libraries
+/.idea/modules.xml
+/.idea/workspace.xml
+/.idea/navEditor.xml
+/.idea/assetWizardSettings.xml
+.DS_Store
+/build
+/captures
+.externalNativeBuild
+/entry/.preview
+.cxx
+/node_modules
diff --git a/kvdb/kvdbTest/.idea/.gitignore b/kvdb/kvdbTest/.idea/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..26d33521af10bcc7fd8cea344038eaaeb78d0ef5
--- /dev/null
+++ b/kvdb/kvdbTest/.idea/.gitignore
@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml
diff --git a/kvdb/kvdbTest/.idea/compiler.xml b/kvdb/kvdbTest/.idea/compiler.xml
new file mode 100644
index 0000000000000000000000000000000000000000..fb7f4a8a465d42b4a0390d464b83b99e8465bba7
--- /dev/null
+++ b/kvdb/kvdbTest/.idea/compiler.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/kvdb/kvdbTest/.idea/gradle.xml b/kvdb/kvdbTest/.idea/gradle.xml
new file mode 100644
index 0000000000000000000000000000000000000000..9bdd85f2f0a6d3d02fade881ed3b8369fcc1c0e6
--- /dev/null
+++ b/kvdb/kvdbTest/.idea/gradle.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/kvdb/kvdbTest/.idea/jarRepositories.xml b/kvdb/kvdbTest/.idea/jarRepositories.xml
new file mode 100644
index 0000000000000000000000000000000000000000..19e238eaa31f512cfc1e8641964227098d1eb8bb
--- /dev/null
+++ b/kvdb/kvdbTest/.idea/jarRepositories.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/kvdb/kvdbTest/.idea/misc.xml b/kvdb/kvdbTest/.idea/misc.xml
new file mode 100644
index 0000000000000000000000000000000000000000..58918f50335428f2efb3af4d621f9f405ed659d4
--- /dev/null
+++ b/kvdb/kvdbTest/.idea/misc.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/kvdb/kvdbTest/.idea/previewer/phone/phoneSettingConfig_MateX2.json b/kvdb/kvdbTest/.idea/previewer/phone/phoneSettingConfig_MateX2.json
new file mode 100644
index 0000000000000000000000000000000000000000..f505e6b9ca3d41faf1f0a39a496db58b117fbd60
--- /dev/null
+++ b/kvdb/kvdbTest/.idea/previewer/phone/phoneSettingConfig_MateX2.json
@@ -0,0 +1,25 @@
+{
+ "setting": {
+ "1.0.1": {
+ "Language": {
+ "args": {
+ "Language": "zh-CN"
+ }
+ }
+ }
+ },
+ "frontend": {
+ "1.0.0": {
+ "Resolution": {
+ "args": {
+ "Resolution": "360*780"
+ }
+ },
+ "DeviceType": {
+ "args": {
+ "DeviceType": "phone"
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/kvdb/kvdbTest/.idea/previewer/phone/phoneSettingConfig_P40.json b/kvdb/kvdbTest/.idea/previewer/phone/phoneSettingConfig_P40.json
new file mode 100644
index 0000000000000000000000000000000000000000..69beee7fd7694e767677c5d3b4863f419c2bf84e
--- /dev/null
+++ b/kvdb/kvdbTest/.idea/previewer/phone/phoneSettingConfig_P40.json
@@ -0,0 +1,25 @@
+{
+ "setting": {
+ "1.0.1": {
+ "Language": {
+ "args": {
+ "Language": "zh_CN"
+ }
+ }
+ }
+ },
+ "frontend": {
+ "1.0.0": {
+ "Resolution": {
+ "args": {
+ "Resolution": "360*780"
+ }
+ },
+ "DeviceType": {
+ "args": {
+ "DeviceType": "phone"
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/kvdb/kvdbTest/.idea/previewer/previewConfigV2.json b/kvdb/kvdbTest/.idea/previewer/previewConfigV2.json
new file mode 100644
index 0000000000000000000000000000000000000000..7fa502d91cd30a1890ca6cb17256e5d4bcef3ac5
--- /dev/null
+++ b/kvdb/kvdbTest/.idea/previewer/previewConfigV2.json
@@ -0,0 +1,37 @@
+{
+ "1.0.0": {
+ "LastPreviewDevice": {}
+ },
+ "1.0.1": {
+ "profileList": [
+ {
+ "id": "P40",
+ "deviceType": "phone",
+ "width": 1080,
+ "height": 2340,
+ "shape": "rect",
+ "dpi": 480,
+ "orientation": "portrait",
+ "language": "zh_CN",
+ "colorMode": "light"
+ },
+ {
+ "id": "MateX2",
+ "deviceType": "phone",
+ "width": 2200,
+ "height": 2480,
+ "shape": "rect",
+ "dpi": 520,
+ "orientation": "portrait",
+ "language": "zh_CN",
+ "colorMode": "light"
+ }
+ ],
+ "runningProfileList": [
+ "P40"
+ ],
+ "availableProfileList": [
+ "MateX2"
+ ]
+ }
+}
\ No newline at end of file
diff --git a/kvdb/kvdbTest/build.gradle b/kvdb/kvdbTest/build.gradle
new file mode 100644
index 0000000000000000000000000000000000000000..92913c416935e41c5a26572ad770511f192554b3
--- /dev/null
+++ b/kvdb/kvdbTest/build.gradle
@@ -0,0 +1,45 @@
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
+apply plugin: 'com.huawei.ohos.app'
+
+//For instructions on signature configuration, see https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ide_debug_device-0000001053822404#section1112183053510
+ohos {
+ signingConfigs {
+ debug {
+ storeFile file('C:\\Users\\zuojiangjiang\\Desktop\\DEVECOsign\\securitySign\\StartSysDeviceInfo.p12')
+ storePassword '0000001963C58BD45059F4DD5A78110121C6CF960D3118B950FED132F1C7C0DD2C1E0A018DB608446D'
+ keyAlias = 'test'
+ keyPassword '0000001903B2375C25CE3F2826FBFC3D99C65E6436CDC9371C0D1FB410337BCA1ACF26B3E28F4EAB6B'
+ signAlg = 'SHA256withECDSA'
+ profile file('C:\\Users\\zuojiangjiang\\Desktop\\DEVECOsign\\securitySign\\StartupSysDeviceInfo.p7b')
+ certpath file('C:\\Users\\zuojiangjiang\\Desktop\\DEVECOsign\\securitySign\\StartupSysDeviceInfo.cer')
+ }
+ }
+ compileSdkVersion 8
+ supportSystem "standard"
+}
+
+buildscript {
+ repositories {
+ maven {
+ url 'https://repo.huaweicloud.com/repository/maven/'
+ }
+ maven {
+ url 'https://developer.huawei.com/repo/'
+ }
+ }
+ dependencies {
+ classpath 'com.huawei.ohos:hap:3.0.5.2'
+ classpath 'com.huawei.ohos:decctest:1.2.7.2'
+ }
+}
+
+allprojects {
+ repositories {
+ maven {
+ url 'https://repo.huaweicloud.com/repository/maven/'
+ }
+ maven {
+ url 'https://developer.huawei.com/repo/'
+ }
+ }
+}
diff --git a/kvdb/kvdbTest/entry/.gitignore b/kvdb/kvdbTest/entry/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..7d5b7a94f4dcf381f03ff21f28f8a2494b58023f
--- /dev/null
+++ b/kvdb/kvdbTest/entry/.gitignore
@@ -0,0 +1,2 @@
+/build
+/node_modules
diff --git a/kvdb/kvdbTest/entry/build.gradle b/kvdb/kvdbTest/entry/build.gradle
new file mode 100644
index 0000000000000000000000000000000000000000..05a33cd3adb09a68a581b9f7c02c57d3911630e8
--- /dev/null
+++ b/kvdb/kvdbTest/entry/build.gradle
@@ -0,0 +1,21 @@
+apply plugin: 'com.huawei.ohos.hap'
+//For instructions on signature configuration, see https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ide_debug_device-0000001053822404#section1112183053510
+ohos {
+ compileSdkVersion 8
+ defaultConfig {
+ compatibleSdkVersion 8
+ }
+ buildTypes {
+ release {
+ proguardOpt {
+ proguardEnabled false
+ rulesFiles 'proguard-rules.pro'
+ }
+ }
+ }
+}
+
+dependencies {
+ implementation fileTree(dir: 'libs', include: ['*.jar', '*.har'])
+ testImplementation 'junit:junit:4.13.1'
+}
diff --git a/kvdb/kvdbTest/entry/package.json b/kvdb/kvdbTest/entry/package.json
new file mode 100644
index 0000000000000000000000000000000000000000..0967ef424bce6791893e9a57bb952f80fd536e93
--- /dev/null
+++ b/kvdb/kvdbTest/entry/package.json
@@ -0,0 +1 @@
+{}
diff --git a/kvdb/kvdbTest/entry/proguard-rules.pro b/kvdb/kvdbTest/entry/proguard-rules.pro
new file mode 100644
index 0000000000000000000000000000000000000000..f7666e47561d514b2a76d5a7dfbb43ede86da92a
--- /dev/null
+++ b/kvdb/kvdbTest/entry/proguard-rules.pro
@@ -0,0 +1 @@
+# config module specific ProGuard rules here.
\ No newline at end of file
diff --git a/kvdb/kvdbTest/entry/src/main/config.json b/kvdb/kvdbTest/entry/src/main/config.json
new file mode 100644
index 0000000000000000000000000000000000000000..66642f2aa83385be78574c0474059eb5fadf7579
--- /dev/null
+++ b/kvdb/kvdbTest/entry/src/main/config.json
@@ -0,0 +1,67 @@
+{
+ "app": {
+ "bundleName": "com.example.myapplicationsectest",
+ "vendor": "example",
+ "version": {
+ "code": 1000000,
+ "name": "1.0.0"
+ }
+ },
+ "deviceConfig": {},
+ "module": {
+ "package": "com.example.myapplicationsectest",
+ "name": ".MyApplication",
+ "mainAbility": ".MainAbility",
+ "deviceType": [
+ "phone"
+ ],
+ "distro": {
+ "deliveryWithInstall": true,
+ "moduleName": "entry",
+ "moduleType": "entry",
+ "installationFree": false
+ },
+ "abilities": [
+ {
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ],
+ "orientation": "unspecified",
+ "visible": true,
+ "srcPath": "MainAbility",
+ "name": ".MainAbility",
+ "srcLanguage": "js",
+ "icon": "$media:icon",
+ "description": "$string:mainability_description",
+ "formsEnabled": false,
+ "label": "$string:entry_MainAbility",
+ "type": "page",
+ "launchType": "standard"
+ }
+ ],
+ "js": [
+ {
+ "pages": [
+ "pages/index/index"
+ ],
+ "name": ".MainAbility",
+ "window": {
+ "designWidth": 720,
+ "autoDesignWidth": false
+ }
+ }
+ ],
+ "reqPermissions": [
+ {
+ "name":"ohos.permission.DISTRIBUTED_DATASYNC"
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/kvdb/kvdbTest/entry/src/main/js/MainAbility/app.js b/kvdb/kvdbTest/entry/src/main/js/MainAbility/app.js
new file mode 100644
index 0000000000000000000000000000000000000000..6d060ffe5682c19fc83e2274a9e62cbc40a655f8
--- /dev/null
+++ b/kvdb/kvdbTest/entry/src/main/js/MainAbility/app.js
@@ -0,0 +1,8 @@
+export default {
+ onCreate() {
+ console.info("Application onCreate");
+ },
+ onDestroy() {
+ console.info("Application onDestroy");
+ }
+};
diff --git a/kvdb/kvdbTest/entry/src/main/js/MainAbility/i18n/en-US.json b/kvdb/kvdbTest/entry/src/main/js/MainAbility/i18n/en-US.json
new file mode 100644
index 0000000000000000000000000000000000000000..08e34eac912bf2651eefc20e26aa479b5e4e7ec2
--- /dev/null
+++ b/kvdb/kvdbTest/entry/src/main/js/MainAbility/i18n/en-US.json
@@ -0,0 +1,11 @@
+{
+ "strings": {
+ "hello": "Hello",
+ "world": "World",
+ "page": "Second Page",
+ "next": "Next Page",
+ "back": "Back"
+ },
+ "Files": {
+ }
+}
\ No newline at end of file
diff --git a/kvdb/kvdbTest/entry/src/main/js/MainAbility/i18n/zh-CN.json b/kvdb/kvdbTest/entry/src/main/js/MainAbility/i18n/zh-CN.json
new file mode 100644
index 0000000000000000000000000000000000000000..3dd53b3a8b808aec9396fa663cb00ef22ba61e0a
--- /dev/null
+++ b/kvdb/kvdbTest/entry/src/main/js/MainAbility/i18n/zh-CN.json
@@ -0,0 +1,11 @@
+{
+ "strings": {
+ "hello": "您好",
+ "world": "世界",
+ "page": "第二页",
+ "next": "下一页",
+ "back": "返回"
+ },
+ "Files": {
+ }
+}
\ No newline at end of file
diff --git a/kvdb/kvdbTest/entry/src/main/js/MainAbility/pages/index/index.css b/kvdb/kvdbTest/entry/src/main/js/MainAbility/pages/index/index.css
new file mode 100644
index 0000000000000000000000000000000000000000..464de0dc5f3228bee98a7f0137259d31be6560e1
--- /dev/null
+++ b/kvdb/kvdbTest/entry/src/main/js/MainAbility/pages/index/index.css
@@ -0,0 +1,110 @@
+.container {
+ flex-direction: column;
+ justify-content: center;
+ align-items: center;
+ width: 100%;
+ height: 100%;
+}
+
+.kvmanger-box {
+ flex-direction: column;
+ width: 650px;
+ height: 5%;
+ border-width: 0.5px;
+ border-color: black;
+}
+
+.kvstore-box {
+ flex-direction: row;
+ width: 650px;
+ height: 10%;
+ border-width: 0.5px;
+ border-color: black;
+}
+
+.callback-box {
+ flex-direction: row;
+ width: 650px;
+ height: 10%;
+ border-width: 0.5px;
+ border-color: black;
+}
+
+.func-box {
+ flex-direction: row;
+ width: 650px;
+ height: 25%;
+ border-width: 0.5px;
+ border-color: black;
+}
+
+.log-box {
+ width: 650px;
+ height: 50%;
+ border-width: 0.5px;
+ border-color: black;
+}
+
+.func-child {
+ flex-direction: column;
+ justify-content: space-evenly;
+}
+
+.radio-style {
+ flex-direction: row;
+ justify-content: space-evenly;
+}
+
+.sync-mode-dialog {
+ width: 90%;
+}
+
+.dialog-content-row-style {
+ flex-direction: row;
+ justify-content: space-evenly;
+}
+
+.dialog-content-col-style {
+ flex-direction: column;
+}
+
+.text_title {
+ margin-top: 10px;
+ margin-left: 10px;
+ font-size: 15px;
+}
+
+.radio-style {
+ flex-direction: row;
+ justify-content: space-evenly;
+}
+
+.text_log {
+ text-align: left;
+ line-height: 0px;
+ font-size: 15px;
+}
+
+.row {
+ flex-direction: row;
+}
+
+.label {
+ width: 150px;
+ font-size: 15px;
+}
+
+.input_text {
+ height: 35px;
+ border-width: 0.5px;
+}
+
+.input_button {
+ width: 150px;
+ height: 60px;
+ font-size: 15px;
+}
+
+.kvmanger-row {
+ height: 100%;
+}
\ No newline at end of file
diff --git a/kvdb/kvdbTest/entry/src/main/js/MainAbility/pages/index/index.hml b/kvdb/kvdbTest/entry/src/main/js/MainAbility/pages/index/index.hml
new file mode 100644
index 0000000000000000000000000000000000000000..805b6990a4d3fe4b5cea4c6338c494c271ecb0b2
--- /dev/null
+++ b/kvdb/kvdbTest/entry/src/main/js/MainAbility/pages/index/index.hml
@@ -0,0 +1,117 @@
+
+
+
+
+
+
+ {{logText}}
+
+
+
+
+
\ No newline at end of file
diff --git a/kvdb/kvdbTest/entry/src/main/js/MainAbility/pages/index/index.js b/kvdb/kvdbTest/entry/src/main/js/MainAbility/pages/index/index.js
new file mode 100644
index 0000000000000000000000000000000000000000..1eb717c420770d964b4a3ce2fabc4236abcab44d
--- /dev/null
+++ b/kvdb/kvdbTest/entry/src/main/js/MainAbility/pages/index/index.js
@@ -0,0 +1,585 @@
+// @ts-nocheck
+import router from '@system.router'
+import data_distributedData from '@ohos.data.distributedData';
+import distributedHardware_deviceManager from '@ohos.distributedHardware.deviceManager';
+import commonEvent from '@ohos.commonEvent';
+import {Core, ExpectExtend, ReportExtend, InstrumentLog} from 'deccjsunit/index';
+import file from '@system.file';
+import featureAbility from '@ohos.ability.featureAbility';
+import bundle from '@ohos.bundle';
+import abilityAccessCtrl from '@ohos.abilityAccessCtrl';
+
+let kvManager,kvStore,devManager;
+const bundle_name = 'com.example.myapplicationsectest';
+
+export default {
+ data: {
+ logText: '',
+ deviceList:[],
+ syncMode: data_distributedData.SyncMode.PUSH_ONLY,
+ store_id:'myapplicationsectest_storeid',
+ subscribeType: 2,
+ dataListenerStarted: false,
+ syncListenerStarted: false,
+ securityLevel: data_distributedData.SecurityLevel.NO_LEVEL,
+ },
+ onInit() {
+ this.grantpermission();
+ this.logText = '';
+ kvManager = null;
+ kvStore = null;
+ devManager = null;
+ },
+ onShow() {
+// console.log('securityTest:onShow')
+// const core = Core.getInstance()
+// const expectExtend = new ExpectExtend({
+// 'id': 'extend'
+// })
+// const reportExtend = new ReportExtend(file)
+// core.addService('expect', expectExtend)
+// core.addService('report', reportExtend)
+// core.init()
+// core.subscribeEvent('task', reportExtend)
+//
+// const configService = core.getDefaultService('config')
+// configService.setConfig(this)
+// require('../../../test/List.test')
+// core.execute()
+//
+// console.log('securityTest:onShow finished')
+ },
+ onReady() {
+ },
+ onDestroy(){
+ if( kvStore != null) {
+ this.stopDataListener();
+ this.stopSyncListener();
+ }
+ this.logText = '';
+ this.release();
+ },
+ release() {
+ if (devManager != null) {
+ devManager.off('deviceStateChange');
+ devManager.off('serviceDie');
+ devManager.release();
+ }
+ },
+ async grantpermission() {
+ console.info('zjj grantpermission');
+ let context = featureAbility.getContext();
+ let bundleFlag = 0;
+ let tokenId = undefined;
+ let userId = 100;
+ let appInfo = await bundle.getApplicationInfo('com.example.myapplicationsectest', bundleFlag, userId);
+ tokenId = appInfo.accessTokenId;
+ console.info('zjj tokenId=${tokenId}');
+ let atManager = abilityAccessCtrl.createAtManager();
+
+ let result = await atManager.verifyAccessToken(tokenId, 'ohos.permission.DISTRIBUTED_DATASYNC');
+ console.info('zjj result=${result}');
+
+ if (result == abilityAccessCtrl.GrantStatus.PERMISSION_DENIED) {
+ console.info('zjj result=PERMISSION_DENIED');
+ context.requestPermissionsFromUser(['ohos.permission.DISTRIBUTED_DATASYNC'], 666, function(result) {
+ console.info('zjj result.requestcode=${result.requestCode}');
+ })
+ }
+
+ },
+ CreateDevManager() {
+ if (devManager != null) {
+ console.info('[JSDemo] devManager already created');
+ this.logText += "devManager already created.\r\n";
+ return;
+ }
+ distributedHardware_deviceManager.createDeviceManager("com.example.myapplicationsectest", (error, value) => {
+ if (error) {
+ console.error("createDeviceManager failed.");
+ this.logText += "createDeviceManager failed.\r\n";
+ return;
+ }
+ devManager = value;
+ this.logText += "createDeviceManager success.\r\n";
+ devManager.on('deviceStateChange', (data) => {
+ this.logText += "deviceStateChange on: " + JSON.stringify(data) + ".\r\n";
+ console.info("deviceStateChange on:" + JSON.stringify(data));
+ });
+
+ devManager.on('serviceDie', () => {
+ this.logList.push("serviceDie on:");
+ this.logText += "serviceDie on: " + ".\r\n";
+ console.info("serviceDie on:");
+ });
+ });
+ },
+ GetDevList() {
+ if(devManager != null) {
+ var array = devManager.getTrustedDeviceListSync();
+ // this.logText += "array: " + JSON.stringify(array) + ".\r\n";
+ // console.info("array: " + JSON.stringify(array));
+ // var local = devManager.getLocalDeviceInfoSync();
+ // this.logText += "local: " + JSON.stringify(local) + ".\r\n";
+ // console.info("local: " + JSON.stringify(local));
+ // var filterStr = "{\"filters\":[{\"commonFilter\":{\"groupType\":\"1\",\"curComType\" :4}}]}";
+ // let options = {
+ // "targetPkgName": "com.example.jsdistributedatademo",
+ // "sortType": 0,
+ // "filter": filterStr
+ // }
+ // devManager.getTrustedDeviceList(options, (err, data) => {
+ // if (err) {
+ // return;
+ // }
+ // var arr = data;
+ // this.logText += "arr: " + JSON.stringify(arr) + ".\r\n";
+ // console.info("arr: " + JSON.stringify(arr));
+ // });
+ var list = new Array();
+ console.info('[JSDemo] getTrustedDeviceListSync, count=' + array.length);
+ for (var i = 0; i < array.length; i++) {
+ console.info('[JSDemo] device ' + (i+1) + '/' + array.length +
+ ' deviceId=' + array[i].deviceId + ' deviceName=' + array[i].deviceName
+ + ' deviceType=' + array[i].deviceType);
+ list[i] = array[i].deviceId;
+ }
+ this.deviceList = list;
+ }
+ },
+ CreateKVManager() {
+ this.CreateDevManager();
+ console.info("[JSDemo] CreateKVManager begin");
+ if (kvManager != null) {
+ console.info('[JSDemo] kvManager already created');
+ this.logText += "kvManager already created.\r\n";
+ return;
+ }
+ try {
+ const config = {
+ bundleName : bundle_name,
+ userInfo : {
+ userId : '0',
+ userType : 0
+ }
+ }
+ const promise = data_distributedData.createKVManager(config);
+ promise.then((manager) => {
+ if (manager == null) {
+ console.info("[JSDemo] CreateKVManager createKVManager fail ");
+ return;
+ }
+ kvManager = manager;
+ // kvManager.GetDeviceList()
+ console.info("[JSDemo] CreateKVManager createKVManager success " + manager);
+ this.logText += "CreateKVManager success.\r\n";
+ }).catch((err) => {
+ console.info("[JSDemo] createKVManager createKVManager err " + err);
+ this.logText += "CreateKVManager err " + err + ".\r\n";
+ });
+ } catch (e) {
+ console.log("[JSDemo] createKVManager e " + e);
+ this.logText += "CreateKVManager e " + e + ".\r\n";
+ }
+ },
+ GetKVStore() {
+ console.info("[JSDemo] GetKVStore begin");
+ if(kvManager == null) {
+ console.info('[JSDemo] GetKVStore kvManager is null');
+ this.logText += "GetKVStore kvManager is null.\r\n";
+ return;
+ }
+ if(kvStore != null) {
+ console.info('[JSDemo] kvStore already created');
+ this.logText += "kvStore already created.\r\n";
+ return;
+ }
+ try {
+ const options = {
+ createIfMissing : true,
+ encrypt : true,
+ backup : false,
+ autoSync : false,
+ kvStoreType : 1,
+ schema : '',
+ securityLevel : this.securityLevel
+ }
+ const promise = kvManager.getKVStore(this.store_id, options);
+ promise.then((store) => {
+ if (store == null) {
+ console.info("[JSDemo] CreateKVManager createKVManager fail ");
+ return;
+ }
+ kvStore = store;
+ console.log("[JSDemo] GetKVStore getKVStore success " + store);
+ this.logText += "GetKVStore success.\r\n";
+ this.logText += "GetKVStore success securityLevel:" + this.securityLevel + "kvStoreType:1.\r\n";
+ }).catch((err) => {
+ console.log("[JSDemo] GetKVStore getKVStore err " + err);
+ this.logText += "GetKVStore err " + err + ".\r\n";
+ });
+ } catch (e) {
+ console.log("[JSDemo] GetKVStore e " + e);
+ this.logText += "GetKVStore e " + e + ".\r\n";
+ }
+ },
+ DeleteKvStore () {
+ console.info("[JSDemo] DeleteKvStore begin");
+ if(kvManager == null) {
+ console.info('[JSDemo] DeleteKvStore kvManager is null');
+ this.logText += "DeleteKvStore kvManager is null.\r\n";
+ return;
+ }
+ if(kvStore == null) {
+ console.info('[JSDemo] kvStore already remove');
+ this.logText += "kvStore already remove.\r\n";
+ return;
+ }
+ try {
+ kvManager.closeKVStore('com.example.myapplicationsectest', this.store_id, kvStore).then(() => {
+ console.log('closeKVStore success');
+ this.logText += "closeKVStore success.\r\n";
+ }).catch((err) => {
+ console.log('closeKVStore err');
+ this.logText += "closeKVStore success.\r\n";
+ });
+ kvManager.deleteKVStore('com.example.myapplicationsectest', this.store_id).then(() => {
+ console.log('deleteKVStore success');
+ kvStore = null;
+ kvManager = null;
+ this.logText += "deleteKVStore success.\r\n";
+ }).catch((err) => {
+ console.log('deleteKVStore err ' );
+ this.logText += "deleteKVStore fail.\r\n";
+ });
+// const promise = kvManager.closeAllKVStore(bundle_name);
+// promise.then((status) => {
+// console.log("RemoveAllStore closeAllKVStore success " + status);
+// const promise1 = kvManager.deleteAllKVStore(bundle_name);
+// promise1.then((status) => {
+// console.log("RemoveAllStore deleteAllKVStore success " + status);
+// kvStore = null;
+// this.stopDataListener();
+// this.stopSyncListener();
+// this.logText += "RemoveAllStore success.\r\n";
+// }).catch((err) => {
+// console.log("RemoveAllStore deleteAllKVStore fail " + err);
+// this.logText += "RemoveAllStore deleteAllKVStore err " + err + ".\r\n";
+// });
+// }).catch((err) => {
+// console.log("RemoveAllStore closeAllKVStore fail " + err);
+// this.logText += "RemoveAllStore closeAllKVStore fail " + err + ".\r\n";
+// });
+ } catch (e) {
+ console.log("[JSDemo] RemoveAllStore e " + e);
+ this.logText += "RemoveAllStore e " + e + ".\r\n";
+ }
+ },
+ GetSecurityLevel() {
+ if(kvStore == null) {
+ console.info('[JSDemo] kvStore is null');
+ this.logText += "kvStore is null.\r\n";
+ return;
+ }
+ try {
+ kvStore.getSecurityLevel().then((data) => {
+ console.log(' getSecurityLevel success');
+ switch(data) {
+ case data_distributedData.SecurityLevel.NO_LEVEL:
+ this.logText += "getSecurityLevel success: NO_LEVEL.\r\n";
+ break;
+ case data_distributedData.SecurityLevel.S0:
+ this.logText += "getSecurityLevel success: S0.\r\n";
+ break;
+ case data_distributedData.SecurityLevel.S1:
+ this.logText += "getSecurityLevel success: S1.\r\n";
+ break;
+ case data_distributedData.SecurityLevel.S2:
+ this.logText += "getSecurityLevel success: S2.\r\n";
+ break;
+ case data_distributedData.SecurityLevel.S3:
+ this.logText += "getSecurityLevel success: S3.\r\n";
+ break;
+ case data_distributedData.SecurityLevel.S4:
+ this.logText += "getSecurityLevel success: S4.\r\n";
+ break;
+ default:
+ this.logText += "getSecurityLevel success: NO_LEVEL.\r\n";
+ }
+ }).catch((err) => {
+ console.log('getSecurityLevel fail ' + JSON.stringify(err));
+ this.logText += "getSecurityLevel fail" + JSON.stringify(err) + ".\r\n";
+ });
+ }catch(e) {
+ console.log('GetSecurityLevel e ' + e);
+ }
+ },
+ SetSecurityLevel() {
+ this.$element('securityLevelDialog').show();
+ },
+ cancelSecurityLevelDialog() {
+ this.$element('securityLevelDialog').close();
+ },
+ onSecurityLevelChange(e) {
+ if (e.value != this.securityLevel) {
+ this.logText += "securityLevel select: " + e.value + ".\r\n";
+ switch(e.value) {
+ case '0':
+ this.securityLevel = data_distributedData.SecurityLevel.NO_LEVEL;
+ break;
+ case '1':
+ this.securityLevel = data_distributedData.SecurityLevel.S0;
+ break;
+ case '2':
+ this.securityLevel = data_distributedData.SecurityLevel.S1;
+ break;
+ case '3':
+ this.securityLevel = data_distributedData.SecurityLevel.S2;
+ break;
+ case '5':
+ this.securityLevel = data_distributedData.SecurityLevel.S3;
+ break;
+ case '6':
+ this.securityLevel = data_distributedData.SecurityLevel.S4;
+ break;
+ default:
+ this.securityLevel = data_distributedData.SecurityLevel.NO_LEVEL;
+ }
+ }
+ },
+ SubscribeType() {
+ this.$element('subscribeTypeDialog').show();
+ },
+ cancelSubscribeTypeDialog() {
+ this.$element('subscribeTypeDialog').close();
+ },
+ onSubscribeTypeChange(e){
+ if (this.subscribeType != e.value) {
+ this.logText += "SubscribeType select: " + e.value + ".\r\n";
+ switch(e.value) {
+ case '0':
+ this.subscribeType = data_distributedData.SubscribeType.SUBSCRIBE_TYPE_LOCAL;
+ break;
+ case '1':
+ this.subscribeType = data_distributedData.SubscribeType.SUBSCRIBE_TYPE_REMOTE;
+ break;
+ case '2':
+ this.subscribeType = data_distributedData.SubscribeType.SUBSCRIBE_TYPE_ALL;
+ break;
+ default:
+ this.subscribeType = data_distributedData.SubscribeType.SUBSCRIBE_TYPE_REMOTE;
+ }
+ }
+ },
+ RegDataChange () {
+ console.info("[JSDemo] RegDataChange begin");
+ if(kvStore == null) {
+ console.info('[JSDemo] RegDataChange kvStore is null');
+ this.logText += "RegDataChange kvStore is null.\r\n";
+ return;
+ }
+ if (!this.dataListenerStarted) {
+ this.startDataListener();
+ this.logText += "Register dataChange callback success.\r\n";
+ } else {
+ this.logText += "DataChange callback already registed.\r\n";
+ }
+ },
+ RegSyncComplete () {
+ console.info("[JSDemo] RegSyncComplete begin");
+ if(kvStore == null) {
+ console.info('[JSDemo] RegSyncComplete kvStore is null');
+ this.logText += "RegSyncComplete kvStore is null.\r\n";
+ return;
+ }
+ if (!this.syncListenerStarted) {
+ this.startSyncListener();
+ this.logText += "Register syncComplete callback success.\r\n";
+ } else {
+ this.logText += "SyncComplete callback already registed.\r\n";
+ }
+ },
+ Put() {
+ console.info("[JSDemo] Put begin");
+ if(kvStore == null) {
+ console.info('[JSDemo] Put kvStore is null');
+ this.logText += "Put kvStore is null.\r\n";
+ return;
+ }
+ try {
+ const promise = kvStore.put('key_test_string', 'value_test_string');
+ promise.then((data) => {
+ console.log("[JSDemo] Put success " + data);
+ this.logText += "Put success.\r\n";
+ }).catch((err) => {
+ console.log("[JSDemo] Put fail " + err);
+ this.logText += "Put fail " + err + ".\r\n";
+ });
+ } catch (e) {
+ console.log("[JSDemo] Put err " + e);
+ this.logText += "Put err " + e + ".\r\n";
+ }
+ },
+ Get() {
+ console.info("[JSDemo] Get begin");
+ if(kvStore == null) {
+ console.info('[JSDemo] Get kvStore is null');
+ this.logText += "Get kvStore is null.\r\n";
+ return;
+ }
+ try {
+ const promise1 = kvStore.get('key_test_string');
+ promise1.then((data) => {
+ console.log("[JSDemo] Get success " + data);
+ this.logText += ("Get success. data:" + data + "\r\n");
+ }).catch((err) => {
+ console.log("[JSDemo] Get fail " + err);
+ this.logText += "Get fail " + err + ".\r\n";
+ });
+ }catch (e){
+ console.log("[JSDemo] Get err " + e);
+ this.logText += "Get err " + e + ".\r\n";
+ }
+ },
+ Delete() {
+ console.info("[JSDemo] Delete begin");
+ if(kvStore == null) {
+ console.info('[JSDemo] Delete kvStore is null');
+ this.logText += "Delete kvStore is null.\r\n";
+ return;
+ }
+ try {
+ const promise1 = kvStore.delete('key_test_string');
+ promise1.then((data) => {
+ console.log("[JSDemo] Delete success ");
+ this.logText += "Delete success.\r\n";
+ }).catch((err) => {
+ console.log("[JSDemo] Delete fail " + err);
+ this.logText += "Delete fail " + err + ".\r\n";
+ });
+ } catch(e) {
+ console.log("[JSDemo] Delete err " + e);
+ this.logText += "Delete err " + e + ".\r\n";
+ }
+ },
+ SyncMode() {
+ this.$element('syncModeDialog').show();
+ },
+ cancelSyncModeDialog() {
+ this.$element('syncModeDialog').close();
+ },
+ onSyncModeChange(e){
+ if (e.value != this.syncMode) {
+ this.logText += "syncMode select: " + e.value + ".\r\n";
+ switch(e.value) {
+ case '0':
+ this.syncMode = data_distributedData.SyncMode.PULL_ONLY;
+ break;
+ case '1':
+ this.syncMode = data_distributedData.SyncMode.PUSH_ONLY;
+ break;
+ case '2':
+ this.syncMode = data_distributedData.SyncMode.PUSH_PULL;
+ break;
+ default:
+ this.syncMode = data_distributedData.SyncMode.PUSH_ONLY;
+ }
+ }
+ },
+ Sync() {
+ console.info("[JSDemo] Sync begin");
+ if(kvStore == null) {
+ console.info('[JSDemo] Sync kvStore is null');
+ this.logText += "Sync kvStore is null.\r\n";
+ return;
+ }
+ this.GetDevList();
+ if(this.deviceList.length == 0) {
+ console.info('[JSDemo] Sync deviceList is null');
+ this.logText += "Sync deviceList is null.\r\n";
+ return;
+ }
+ var devices = this.deviceList;
+ // var devices = ['15F21F503830418064542AA40C4D39FBE6BD3B7F143B35718F484D4AEAA42CE5']; //222
+ // var devices = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB']; //111
+ var mode = this.syncMode;
+ console.info('[JSDemo] Sync start');
+ this.logText += "Sync" + devices + " SyncMode:" + mode + ".\r\n";
+ kvStore.sync(devices, data_distributedData.SyncMode.PUSH_ONLY);
+ this.logText += "Sync success.\r\n";
+ },
+ ClearLog() {
+ this.logText = '';
+ },
+ print(list, name) {
+ if (list != null) {
+ for(var i = 0; i < list.length; i++) {
+ console.info('[JSDemo] dataChange ' + name + ' key: ' + list[i].key + ' value: ' + list[i].value.value + ' type: ' + list[i].value.type);
+ this.logText += (name + ' key: ' + list[i].key + ' value: ' + list[i].value.value + ' type: ' + list[i].value.type + ".\r\n");
+ }
+ }
+ },
+ printChangeData(notification) {
+ var change = 'I(' + notification.insertEntries.length + ') U(' + notification.updateEntries.length +
+ ') D(' + notification.deleteEntries.length + ') deviceId:' + notification.deviceId;
+ console.info('[JSDemo] dataChange ' + change);
+ this.logText += ("dataChange: " + change + ".\r\n");
+ var inserts = notification.insertEntries;
+ this.print(inserts, 'inserts');
+ var deletes = notification.deleteEntries;
+ this.print(deletes, 'deletes');
+ var updates = notification.updateEntries;
+ this.print(updates, 'updates');
+ },
+ startDataListener(){
+ console.info("[JSDemo] startDataListener begin");
+ let that = this;
+ if(kvStore == null) {
+ console.info('[JSDemo] startDataListener kvstore is null');
+ return;
+ }
+ try {
+ this.logText += "register dataChange SubscribeType:" + this.subscribeType + ".\r\n";
+ kvStore.on('dataChange', parseInt(this.SubscribeType), function (data) {
+ console.info('[JSDemo] dataChange callback call' + data);
+ that.logText += "dataChange callback call.\r\n";
+ if(data) {
+ that.printChangeData(data);
+ }
+ });
+ this.dataListenerStarted = true;
+ }catch(e) {
+ console.info("[JSDemo] startDataListener err " + e);
+ this.dataListenerStarted = false;
+ }
+ },
+ stopDataListener(){
+ console.log("[JSDemo] stopDataListener");
+ this.dataListenerStarted = false;
+ },
+ startSyncListener(){
+ console.info("[JSDemo] startSyncListener begin");
+ let that = this;
+ if(kvStore == null) {
+ console.info('[JSDemo] startSyncListener kvstore is null');
+ return;
+ }
+ try {
+ kvStore.on('syncComplete', function (data) {
+ console.info('[JSDemo] syncComplete callback call ' + data);
+ that.logText += "syncComplete callback call.\r\n";
+ if(data) {
+ that.logText += (data + ".\r\n");
+ }
+ });
+ this.syncListenerStarted = true;
+ }catch(e) {
+ console.info("[JSDemo] startSyncListener err " + e);
+ this.syncListenerStarted = false;
+ }
+ },
+ stopSyncListener(){
+ console.log("[JSDemo] stopSyncListener");
+ this.syncListenerStarted = false;
+ },
+}
diff --git a/kvdb/kvdbTest/entry/src/main/js/test/List.test.js b/kvdb/kvdbTest/entry/src/main/js/test/List.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..d1a221b93368a47d56631febc6fb4f5e655ff515
--- /dev/null
+++ b/kvdb/kvdbTest/entry/src/main/js/test/List.test.js
@@ -0,0 +1,3 @@
+require('./securityJsunit.test.js')
+require('./RdbstoreTransactionJsunit1.test.js')
+require('./RdbstoreTransactionJsunit.test.js')
\ No newline at end of file
diff --git a/kvdb/kvdbTest/entry/src/main/js/test/RdbstoreTransactionJsunit.test.js b/kvdb/kvdbTest/entry/src/main/js/test/RdbstoreTransactionJsunit.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..655a5ac32c1841ffb784f4d901e9c526efb50b8d
--- /dev/null
+++ b/kvdb/kvdbTest/entry/src/main/js/test/RdbstoreTransactionJsunit.test.js
@@ -0,0 +1,418 @@
+/*
+ * 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 dataRdb from '@ohos.data.rdb';
+import distributedObject from '@ohos.data.distributedDataObject';
+
+const TAG = "[ObjectStore_JSKITS_TEST]"
+const CREATE_TABLE_TEST = "CREATE TABLE IF NOT EXISTS test (" + "id INTEGER PRIMARY KEY, " + "name TEXT NOT NULL, " + "age INTEGER, " + "salary REAL, " + "blobType BLOB)";
+
+const STORE_CONFIG = {
+ name: "InsertTest.db",
+}
+
+var rdbStore = undefined;
+
+var g_object = distributedObject.distributed({ name: "Amy", age: 18, isVis: false });
+
+describe('objectStoreTest', function () {
+ beforeAll(async function () {
+ console.info(TAG + 'beforeAll')
+ rdbStore = await dataRdb.getRdbStore(STORE_CONFIG, 1);
+ await rdbStore.executeSql(CREATE_TABLE_TEST, null);
+ })
+
+ beforeEach(async function () {
+ console.info(TAG + 'beforeEach')
+
+ })
+
+ afterEach(async function () {
+ console.info(TAG + 'afterEach')
+ await rdbStore.executeSql("DELETE FROM test");
+ })
+
+ afterAll(async function () {
+ console.info(TAG + 'afterAll')
+ rdbStore = null
+ await dataRdb.deleteRdbStore("InsertTest.db");
+ })
+
+ console.log(TAG + "*************Unit Test Begin*************");
+
+ /**
+ * @tc.name rdb transaction insert test
+ * @tc.number testRdbTransactionInsert0001
+ * @tc.desc rdb transaction insert & commit, the result comes out is 3 items;
+ *//*
+ it('testRdbTransactionInsert0001', 0, async function (done) {
+ console.log(TAG + "************* testRdbStoreInsert0001 start *************");
+ var u8 = new Uint8Array([1, 2, 3])
+ try {
+ rdbStore.beginTransaction()
+ const valueBucket = {
+ "name": "lisi",
+ "age": 18,
+ "salary": 100.5,
+ "blobType": u8,
+ }
+ await rdbStore.insert("test", valueBucket)
+
+ await rdbStore.commit()
+
+ let predicates = new dataRdb.RdbPredicates("test");
+ let resultSet = await rdbStore.query(predicates)
+ console.log(TAG + "testRdbTransactionInsert0001 result count " + resultSet.rowCount)
+ expect(1).assertEqual(resultSet.rowCount)
+ resultSet.close()
+// resultSet == null;
+ } catch (e) {
+ console.log(TAG + e);
+ expect(null).assertFail()
+ console.log(TAG + "testRdbTransactionInsert0001 failed");
+ }
+ done()
+ console.log(TAG + "************* testRdbTransactionInsert0001 end *************");
+ })
+
+ *//**
+ * @tc.name rdb transaction insert test
+ * @tc.number testRdbTransactionInsert0001
+ * @tc.desc rdb transaction insert & commit, the result comes out is 3 items;
+ *//*
+ it('testRdbTransactionInsert0002', 0, async function (done) {
+ console.log(TAG + "************* testRdbStoreInsert0002 start *************");
+ var u8 = new Uint8Array([1, 2, 3])
+ try {
+ await rdbStore.beginTransaction()
+ const valueBucket = {
+ "name": "lisi",
+ "age": 18,
+ "salary": 100.5,
+ "blobType": u8,
+ }
+ await rdbStore.insert("test", valueBucket)
+
+ const valueBucket1 = {
+ "name": "zhangsan",
+ "age": 20,
+ "salary": 9.5,
+ "blobType": u8,
+ }
+ await rdbStore.insert("test", valueBucket1)
+
+
+ const valueBucket2 = {
+ "name": "wangwu",
+ "age": 16,
+ "salary": 99,
+ "blobType": u8,
+ }
+ await rdbStore.insert("test", valueBucket2)
+
+ await rdbStore.commit()
+
+ let predicates = new dataRdb.RdbPredicates("test");
+ let resultSet = await rdbStore.query(predicates)
+ expect(3).assertEqual(resultSet.rowCount)
+ resultSet.close()
+// resultSet == null;
+ } catch (e) {
+ expect(null).assertFail()
+ console.log(TAG + "testRdbTransactionInsert0002 failed");
+ }
+ done()
+ console.log(TAG + "************* testRdbTransactionInsert0002 end *************");
+ })
+
+
+ *//**
+ * @tc.name rdb transaction insert test
+ * @tc.number testRdbTransactionInsert0002
+ * @tc.desc while using transaction to insert values, querying the db,
+ * the result comes out is 0;
+ *//*
+ it('testRdbTransactionInsert0003', 0, async function (done) {
+ console.log(TAG + "************* testRdbTransactionInsert0003 start *************");
+ var u8 = new Uint8Array([1, 2, 3])
+ try {
+ await rdbStore.beginTransaction()
+ const valueBucket = {
+ "name": "lisi",
+ "age": 18,
+ "salary": 100.5,
+ "blobType": u8,
+ }
+ await rdbStore.insert("test", valueBucket)
+
+ const valueBucket1 = {
+ "name": "zhangsan",
+ "age": 20,
+ "salary": 9.5,
+ "blobType": u8,
+ }
+ await rdbStore.insert("test", valueBucket1)
+
+ let predicates = new dataRdb.RdbPredicates("test");
+ let resultSet = await rdbStore.query(predicates)
+ expect(0).assertEqual(resultSet.rowCount)
+ resultSet.close()
+// resultSet == null;
+ const valueBucket2 = {
+ "name": "wangwu",
+ "age": 16,
+ "salary": 99,
+ "blobType": u8,
+ }
+ await rdbStore.insert("test", valueBucket2)
+
+ await rdbStore.commit()
+ } catch (e) {
+ expect(null).assertFail()
+ console.log(TAG + "testRdbTransactionInsert0003 failed");
+ }
+ done()
+ console.log(TAG + "************* testRdbTransactionInsert0003 end *************");
+ })
+
+ *//**
+ * @tc.name rdb insert test
+ * @tc.number SUB_DDM_AppDataFWK_JSRDB_Insert_0010
+ * @tc.desc the classical transaction scenario, when we insert or commit the value,
+ * db returns an exception, we need to catch exception and rollback.
+ *//*
+ it('testRdbTransactionRollBack0001', 0, async function (done) {
+ console.log(TAG + "************* testRdbTransactionRollBack0001 start *************");
+ var u8 = new Uint8Array([1, 2, 3])
+ try {
+ await rdbStore.beginTransaction()
+ const valueBucket = {
+ "id": 1,
+ "name": "lisi",
+ "age": 18,
+ "salary": 100.5,
+ "blobType": u8,
+ }
+ await rdbStore.insert("test", valueBucket)
+ await rdbStore.insert("test", valueBucket)
+
+ await rdbStore.commit()
+ } catch (e) {
+ await rdbStore.rollBack()
+ let predicates = new dataRdb.RdbPredicates("test");
+ let resultSet = await rdbStore.query(predicates)
+ console.log(TAG + "testRdbTransactionRollBack0001 result count " + resultSet.rowCount);
+ expect(0).assertEqual(resultSet.rowCount)
+ resultSet.close()
+// resultSet == null;
+ }
+ done()
+ console.log(TAG + "************* testRdbTransactionRollBack0001 end *************");
+ })
+
+ *//**
+ * @tc.name rdb insert test
+ * @tc.number SUB_DDM_AppDataFWK_JSRDB_Insert_0010
+ * @tc.desc the classical transaction scenario, when we insert or commit the value,
+ * db returns an exception, we need to catch exception and rollback.
+ *//*
+ it('testRdbTransactionMulti0001', 0, async function (done) {
+ console.log(TAG + "************* testRdbTransactionMulti0001 start *************");
+ var u8 = new Uint8Array([1, 2, 3])
+ try {
+ await rdbStore.beginTransaction()
+ const valueBucket = {
+ "id": 1,
+ "name": "lisi",
+ "age": 18,
+ "salary": 100.5,
+ "blobType": u8,
+ }
+ await rdbStore.insert("test", valueBucket)
+
+ await rdbStore.beginTransaction()
+ const valueBucket1 = {
+ "name": "zhangsan",
+ "age": 20,
+ "salary": 220.5,
+ "blobType": u8,
+ }
+ let num = rdbStore.insert("test", valueBucket1)
+ num.then(async (ret) => {
+ console.log(TAG + "testRdbTransactionMulti0001 * insert result " + ret);
+ expect(2).assertEqual(ret)
+ })
+
+ await rdbStore.commit()
+ await rdbStore.commit()
+
+ let predicates = new dataRdb.RdbPredicates("test");
+ num = rdbStore.query(predicates)
+ num.then(async (ret) => {
+ expect(2).assertEqual(ret.rowCount)
+ ret.close()
+ })
+ } catch (e) {
+ console.log(TAG + "testRdbTransactionMulti0001 fail ***** ");
+ }
+ done()
+ console.log(TAG + "************* testRdbTransactionMulti0001 end *************");
+ })
+
+ *//**
+ * @tc.name rdb insert test
+ * @tc.number SUB_DDM_AppDataFWK_JSRDB_Insert_0010
+ * @tc.desc the classical transaction scenario, when we insert or commit the value,
+ * db returns an exception, we need to catch exception and rollback.
+ *//*
+ it('testRdbTransactionMulti0002', 0, async function (done) {
+ console.log(TAG + "************* testRdbTransactionMulti0002 start *************");
+ var u8 = new Uint8Array([1, 2, 3])
+ try {
+ await rdbStore.beginTransaction()
+ const valueBucket = {
+ "id": 1,
+ "name": "lisi",
+ "age": 18,
+ "salary": 100.5,
+ "blobType": u8,
+ }
+ await rdbStore.insert("test", valueBucket, function (err, ret){
+
+ });
+
+ await rdbStore.beginTransaction()
+ const valueBucket1 = {
+ "name": "zhangsan",
+ "age": 20,
+ "salary": 220.5,
+ "blobType": u8,
+ }
+ let num = rdbStore.insert("test", valueBucket1)
+ num.then(async (ret) => {
+ console.log(TAG + "testRdbTransactionMulti0002 * insert result " + ret);
+ expect(2).assertEqual(ret)
+ ret.close()
+ })
+
+ await rdbStore.rollBack()
+
+ await rdbStore.commit()
+
+ let predicates = new dataRdb.RdbPredicates("test");
+ num = rdbStore.query(predicates)
+ num.then(async (ret) => {
+ console.log(TAG + "testRdbTransactionMulti0002 * final query " + ret.rowCount);
+ expect(1).assertEqual(ret.rowCount)
+ ret.close()
+ })
+ } catch (e) {
+ console.log(TAG + "testRdbTransactionMulti0002 fail ***** ");
+ }
+ done()
+ console.log(TAG + "************* testRdbTransactionMulti0002 end *************");
+ })*/
+
+ /*
+ * @tc.name rdb insert test
+ * @tc.number SUB_DDM_AppDataFWK_JSRDB_Insert_0010
+ * @tc.desc the classical transaction scenario, when we insert or commit the value,
+ * db returns an exception, we need to catch exception and rollback.
+ */
+ it('testRdbTransactionMulti0003', 0, async function (done) {
+ console.log(TAG + "************* testRdbTransactionMulti0003 start *************");
+ var u8 = new Uint8Array([1, 2, 3])
+ try {
+ await rdbStore.beginTransaction()
+ const valueBucket = {
+ "id": 1,
+ "name": "lisi",
+ "age": 18,
+ "salary": 100.5,
+ "blobType": u8,
+ }
+ await rdbStore.insert("test", valueBucket, function (err, ret){
+
+ });
+
+ await rdbStore.beginTransaction()
+ const valueBucket1 = {
+ "name": "zhangsan",
+ "age": 20,
+ "salary": 220.5,
+ "blobType": u8,
+ }
+ let num = await rdbStore.insert("test", valueBucket1)
+
+ await rdbStore.rollBack()
+
+ await rdbStore.insert("test", valueBucket)
+ await rdbStore.commit()
+
+ let predicates = new dataRdb.RdbPredicates("test");
+ num = rdbStore.query(predicates)
+ num.then(async (ret) => {
+ console.log(TAG + "testRdbTransactionMulti0003 * final query " + ret.rowCount);
+ expect(1).assertEqual(ret.rowCount)
+ ret.close()
+ })
+ } catch (e) {
+ await rdbStore.rollBack()
+ console.log(TAG + "testRdbTransactionMulti0003 rollback ***** ");
+ }
+ done()
+ console.log(TAG + "************* testRdbTransactionMulti0003 end *************");
+ })
+
+ /**
+ * @tc.name objectstore joinSession test
+ * @tc.number testJoinSession001
+ * @tc.desc object join to session,can get session from object
+ */
+ it('testJoinSession001', 0, async function (done) {
+ console.log(TAG + "************* testJoinSession001 start *************");
+ g_object.setSession("session1");
+ if (g_object != undefined && g_object != null) {
+ expect("session1").assertEqual(g_object.__sessionId);
+ } else {
+ console.log(TAG + "testJoinSession001 joinSession failed");
+ }
+
+ done()
+ console.log(TAG + "************* testJoinSession001 end *************");
+ })
+
+ /**
+ * @tc.name objectstore leaveSession test
+ * @tc.number testLeaveSession001
+ * @tc.desc object leave session,can not get session from object
+ */
+ it('testLeaveSession001', 0, async function (done) {
+ console.log(TAG + "************* testLeaveSession001 start *************");
+ g_object.setSession(" ");
+ if (g_object != undefined && g_object != null) {
+ expect(" ").assertEqual(g_object.__sessionId);
+ } else {
+ console.log(TAG + "testLeaveSession001 joinSession failed");
+ }
+
+ done()
+ console.log(TAG + "************* testLeaveSession001 end *************");
+ })
+
+ console.log(TAG + "*************Unit Test End*************");
+
+})
\ No newline at end of file
diff --git a/kvdb/kvdbTest/entry/src/main/js/test/RdbstoreTransactionJsunit1.test.js b/kvdb/kvdbTest/entry/src/main/js/test/RdbstoreTransactionJsunit1.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..98bbc8be0955292e46563d1de673470e01fdb0df
--- /dev/null
+++ b/kvdb/kvdbTest/entry/src/main/js/test/RdbstoreTransactionJsunit1.test.js
@@ -0,0 +1,379 @@
+/*
+ * 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 dataRdb from '@ohos.data.rdb';
+
+const TAG = "[RDB_JSKITS_TEST]"
+const CREATE_TABLE_TEST = "CREATE TABLE IF NOT EXISTS test (" + "id INTEGER PRIMARY KEY, " + "name TEXT NOT NULL, " + "age INTEGER, " + "salary REAL, " + "blobType BLOB)";
+
+const STORE_CONFIG = {
+ name: "InsertTest.db",
+}
+
+var rdbStore = undefined;
+
+describe('rdbStoreInsertTest', function () {
+ beforeAll(async function () {
+ console.info(TAG + 'beforeAll')
+ rdbStore = await dataRdb.getRdbStore(STORE_CONFIG, 1);
+ await rdbStore.executeSql(CREATE_TABLE_TEST, null);
+ })
+
+ beforeEach(async function () {
+ console.info(TAG + 'beforeEach')
+
+ })
+
+ afterEach(async function () {
+ console.info(TAG + 'afterEach')
+ await rdbStore.executeSql("DELETE FROM test");
+ })
+
+ afterAll(async function () {
+ console.info(TAG + 'afterAll')
+ rdbStore = null
+ await dataRdb.deleteRdbStore("InsertTest.db");
+ })
+
+ console.log(TAG + "*************Unit Test Begin*************");
+
+ /**
+ * @tc.name rdb transaction insert test
+ * @tc.number testRdbTransactionInsert0001
+ * @tc.desc rdb transaction insert & commit, the result comes out is 3 items;
+ */
+ it('testRdbTransactionInsert0001', 0, async function (done) {
+ console.log(TAG + "************* testRdbStoreInsert0001 start *************");
+ var u8 = new Uint8Array([1, 2, 3])
+ try {
+ rdbStore.beginTransaction()
+ const valueBucket = {
+ "name": "lisi",
+ "age": 18,
+ "salary": 100.5,
+ "blobType": u8,
+ }
+ await rdbStore.insert("test", valueBucket)
+
+ await rdbStore.commit()
+
+ let predicates = new dataRdb.RdbPredicates("test");
+ let resultSet = await rdbStore.query(predicates)
+ console.log(TAG + "testRdbTransactionInsert0001 result count " + resultSet.rowCount)
+ expect(1).assertEqual(resultSet.rowCount)
+ resultSet.close()
+ // resultSet == null;
+ } catch (e) {
+ console.log(TAG + e);
+ expect(null).assertFail()
+ console.log(TAG + "testRdbTransactionInsert0001 failed");
+ }
+ done()
+ console.log(TAG + "************* testRdbTransactionInsert0001 end *************");
+ })
+
+ /**
+ * @tc.name rdb transaction insert test
+ * @tc.number testRdbTransactionInsert0001
+ * @tc.desc rdb transaction insert & commit, the result comes out is 3 items;
+ */
+ it('testRdbTransactionInsert0002', 0, async function (done) {
+ console.log(TAG + "************* testRdbStoreInsert0002 start *************");
+ var u8 = new Uint8Array([1, 2, 3])
+ try {
+ await rdbStore.beginTransaction()
+ const valueBucket = {
+ "name": "lisi",
+ "age": 18,
+ "salary": 100.5,
+ "blobType": u8,
+ }
+ await rdbStore.insert("test", valueBucket)
+
+ const valueBucket1 = {
+ "name": "zhangsan",
+ "age": 20,
+ "salary": 9.5,
+ "blobType": u8,
+ }
+ await rdbStore.insert("test", valueBucket1)
+
+
+ const valueBucket2 = {
+ "name": "wangwu",
+ "age": 16,
+ "salary": 99,
+ "blobType": u8,
+ }
+ await rdbStore.insert("test", valueBucket2)
+
+ await rdbStore.commit()
+
+ let predicates = new dataRdb.RdbPredicates("test");
+ let resultSet = await rdbStore.query(predicates)
+ expect(3).assertEqual(resultSet.rowCount)
+ resultSet.close()
+ // resultSet == null;
+ } catch (e) {
+ expect(null).assertFail()
+ console.log(TAG + "testRdbTransactionInsert0002 failed");
+ }
+ done()
+ console.log(TAG + "************* testRdbTransactionInsert0002 end *************");
+ })
+
+
+ /**
+ * @tc.name rdb transaction insert test
+ * @tc.number testRdbTransactionInsert0002
+ * @tc.desc while using transaction to insert values, querying the db,
+ * the result comes out is 0;
+ */
+ it('testRdbTransactionInsert0003', 0, async function (done) {
+ console.log(TAG + "************* testRdbTransactionInsert0003 start *************");
+ var u8 = new Uint8Array([1, 2, 3])
+ try {
+ await rdbStore.beginTransaction()
+ const valueBucket = {
+ "name": "lisi",
+ "age": 18,
+ "salary": 100.5,
+ "blobType": u8,
+ }
+ await rdbStore.insert("test", valueBucket)
+
+ const valueBucket1 = {
+ "name": "zhangsan",
+ "age": 20,
+ "salary": 9.5,
+ "blobType": u8,
+ }
+ await rdbStore.insert("test", valueBucket1)
+
+ let predicates = new dataRdb.RdbPredicates("test");
+ let resultSet = await rdbStore.query(predicates)
+ expect(0).assertEqual(resultSet.rowCount)
+ resultSet.close()
+ // resultSet == null;
+ const valueBucket2 = {
+ "name": "wangwu",
+ "age": 16,
+ "salary": 99,
+ "blobType": u8,
+ }
+ await rdbStore.insert("test", valueBucket2)
+
+ await rdbStore.commit()
+ } catch (e) {
+ expect(null).assertFail()
+ console.log(TAG + "testRdbTransactionInsert0003 failed");
+ }
+ done()
+ console.log(TAG + "************* testRdbTransactionInsert0003 end *************");
+ })
+
+ /**
+ * @tc.name rdb insert test
+ * @tc.number SUB_DDM_AppDataFWK_JSRDB_Insert_0010
+ * @tc.desc the classical transaction scenario, when we insert or commit the value,
+ * db returns an exception, we need to catch exception and rollback.
+ */
+ it('testRdbTransactionRollBack0001', 0, async function (done) {
+ console.log(TAG + "************* testRdbTransactionRollBack0001 start *************");
+ var u8 = new Uint8Array([1, 2, 3])
+ try {
+ await rdbStore.beginTransaction()
+ const valueBucket = {
+ "id": 1,
+ "name": "lisi",
+ "age": 18,
+ "salary": 100.5,
+ "blobType": u8,
+ }
+ await rdbStore.insert("test", valueBucket)
+ await rdbStore.insert("test", valueBucket)
+
+ await rdbStore.commit()
+ } catch (e) {
+ await rdbStore.rollBack()
+ let predicates = new dataRdb.RdbPredicates("test");
+ let resultSet = await rdbStore.query(predicates)
+ console.log(TAG + "testRdbTransactionRollBack0001 result count " + resultSet.rowCount);
+ expect(0).assertEqual(resultSet.rowCount)
+ resultSet.close()
+ // resultSet == null;
+ }
+ done()
+ console.log(TAG + "************* testRdbTransactionRollBack0001 end *************");
+ })
+
+ /**
+ * @tc.name rdb insert test
+ * @tc.number SUB_DDM_AppDataFWK_JSRDB_Insert_0010
+ * @tc.desc the classical transaction scenario, when we insert or commit the value,
+ * db returns an exception, we need to catch exception and rollback.
+ */
+ it('testRdbTransactionMulti0001', 0, async function (done) {
+ console.log(TAG + "************* testRdbTransactionMulti0001 start *************");
+ var u8 = new Uint8Array([1, 2, 3])
+ try {
+ await rdbStore.beginTransaction()
+ const valueBucket = {
+ "id": 1,
+ "name": "lisi",
+ "age": 18,
+ "salary": 100.5,
+ "blobType": u8,
+ }
+ await rdbStore.insert("test", valueBucket)
+
+ await rdbStore.beginTransaction()
+ const valueBucket1 = {
+ "name": "zhangsan",
+ "age": 20,
+ "salary": 220.5,
+ "blobType": u8,
+ }
+ let num = rdbStore.insert("test", valueBucket1)
+ num.then(async (ret) => {
+ console.log(TAG + "testRdbTransactionMulti0001 * insert result " + ret);
+ expect(2).assertEqual(ret)
+ })
+
+ await rdbStore.commit()
+ await rdbStore.commit()
+
+ let predicates = new dataRdb.RdbPredicates("test");
+ num = rdbStore.query(predicates)
+ num.then(async (ret) => {
+ expect(2).assertEqual(ret.rowCount)
+ ret.close()
+ })
+ } catch (e) {
+ console.log(TAG + "testRdbTransactionMulti0001 fail ***** ");
+ }
+ done()
+ console.log(TAG + "************* testRdbTransactionMulti0001 end *************");
+ })
+
+ /**
+ * @tc.name rdb insert test
+ * @tc.number SUB_DDM_AppDataFWK_JSRDB_Insert_0010
+ * @tc.desc the classical transaction scenario, when we insert or commit the value,
+ * db returns an exception, we need to catch exception and rollback.
+ */
+ it('testRdbTransactionMulti0002', 0, async function (done) {
+ console.log(TAG + "************* testRdbTransactionMulti0002 start *************");
+ var u8 = new Uint8Array([1, 2, 3])
+ try {
+ await rdbStore.beginTransaction()
+ const valueBucket = {
+ "id": 1,
+ "name": "lisi",
+ "age": 18,
+ "salary": 100.5,
+ "blobType": u8,
+ }
+ await rdbStore.insert("test", valueBucket, function (err, ret){
+
+ });
+
+ await rdbStore.beginTransaction()
+ const valueBucket1 = {
+ "name": "zhangsan",
+ "age": 20,
+ "salary": 220.5,
+ "blobType": u8,
+ }
+ let num = rdbStore.insert("test", valueBucket1)
+ num.then(async (ret) => {
+ console.log(TAG + "testRdbTransactionMulti0002 * insert result " + ret);
+ expect(2).assertEqual(ret)
+ ret.close()
+ })
+
+ await rdbStore.rollBack()
+
+ await rdbStore.commit()
+
+ let predicates = new dataRdb.RdbPredicates("test");
+ num = rdbStore.query(predicates)
+ num.then(async (ret) => {
+ console.log(TAG + "testRdbTransactionMulti0002 * final query " + ret.rowCount);
+ expect(1).assertEqual(ret.rowCount)
+ ret.close()
+ })
+ } catch (e) {
+ console.log(TAG + "testRdbTransactionMulti0002 fail ***** ");
+ }
+ done()
+ console.log(TAG + "************* testRdbTransactionMulti0002 end *************");
+ })
+
+ /**
+ * @tc.name rdb insert test
+ * @tc.number SUB_DDM_AppDataFWK_JSRDB_Insert_0010
+ * @tc.desc the classical transaction scenario, when we insert or commit the value,
+ * db returns an exception, we need to catch exception and rollback.
+ */
+ it('testRdbTransactionMulti0003', 0, async function (done) {
+ console.log(TAG + "************* testRdbTransactionMulti0003 start *************");
+ var u8 = new Uint8Array([1, 2, 3])
+ try {
+ await rdbStore.beginTransaction()
+ const valueBucket = {
+ "id": 1,
+ "name": "lisi",
+ "age": 18,
+ "salary": 100.5,
+ "blobType": u8,
+ }
+ await rdbStore.insert("test", valueBucket, function (err, ret){
+
+ });
+
+ await rdbStore.beginTransaction()
+ const valueBucket1 = {
+ "name": "zhangsan",
+ "age": 20,
+ "salary": 220.5,
+ "blobType": u8,
+ }
+ let num = await rdbStore.insert("test", valueBucket1)
+
+ await rdbStore.rollBack()
+
+ await rdbStore.insert("test", valueBucket)
+ await rdbStore.commit()
+
+ let predicates = new dataRdb.RdbPredicates("test");
+ num = rdbStore.query(predicates)
+ num.then(async (ret) => {
+ console.log(TAG + "testRdbTransactionMulti0003 * final query " + ret.rowCount);
+ expect(1).assertEqual(ret.rowCount)
+ ret.close()
+ })
+ } catch (e) {
+ await rdbStore.rollBack()
+ console.log(TAG + "testRdbTransactionMulti0003 rollback ***** ");
+ }
+ done()
+ console.log(TAG + "************* testRdbTransactionMulti0003 end *************");
+ })
+
+ console.log(TAG + "*************Unit Test End*************");
+
+})
\ No newline at end of file
diff --git a/kvdb/kvdbTest/entry/src/main/js/test/securityJsunit.test.js b/kvdb/kvdbTest/entry/src/main/js/test/securityJsunit.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..939e2edc687f1f01a32a9c998945bcbed793a19c
--- /dev/null
+++ b/kvdb/kvdbTest/entry/src/main/js/test/securityJsunit.test.js
@@ -0,0 +1,225 @@
+import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
+import data_distributedData from '@ohos.data.distributedData';
+import distributedHardware_deviceManager from '@ohos.distributedHardware.deviceManager';
+
+const TAG = "[SingleKvStore_Security_Test]"
+const KVSTOREID = 'SingleKvstoreSecurityTest'
+const BUNDLENAME = 'com.example.myapplication1';
+
+let kvManager ,kvStore;
+
+describe('securityTest', function () {
+ beforeAll(async function() {
+ console.log(TAG + 'beforeAll')
+ const config = {
+ bundleName : BUNDLENAME,
+ userInfo : {
+ userId : '0',
+ userType : 0
+ }
+ }
+ const promise = data_distributedData.createKVManager(config);
+ promise.then((manager) => {
+ if (manager == null) {
+ console.info(TAG + "CreateKVManager createKVManager fail ");
+ return;
+ }
+ kvManager = manager;
+ console.log(TAG + "CreateKVManager createKVManager success " + manager);
+ }).catch((err) => {
+ console.info(TAG + "createKVManager createKVManager err " + err);
+ });
+ })
+ afterAll(async function() {
+ console.info(TAG + 'afterAll')
+ const promise = kvManager.closeAllKVStore(BUNDLENAME);
+ promise.then((status) => {
+ console.log(TAG+ "closeAllKVStore success " + status);
+ const promise1 = kvManager.deleteAllKVStore(BUNDLENAME);
+ promise1.then((status) => {
+ console.log(TAG + "deleteAllKVStore success " + status);
+ kvStore = null;
+ }).catch((err) => {
+ console.log(TAG + "RemoveAllStore deleteAllKVStore fail " + err);
+ });
+ }).catch((err) => {
+ console.log(TAG + "RemoveAllStore closeAllKVStore fail " + err);
+ });
+ })
+ beforeEach(async function() {
+ console.info(TAG + 'beforeEach')
+ })
+ afterEach(async function() {
+ console.info(TAG + 'afterEach')
+ const promise = kvManager.closeAllKVStore(BUNDLENAME);
+ promise.then((status) => {
+ console.log(TAG+ "closeAllKVStore success " + status);
+ const promise1 = kvManager.deleteAllKVStore(BUNDLENAME);
+ promise1.then((status) => {
+ console.log(TAG + "deleteAllKVStore success " + status);
+ kvStore = null;
+ }).catch((err) => {
+ console.log(TAG + "RemoveAllStore deleteAllKVStore fail " + err);
+ });
+ }).catch((err) => {
+ console.log(TAG + "RemoveAllStore closeAllKVStore fail " + err);
+ });
+ })
+
+ console.log(TAG + "*********Unit Test Begin*********");
+ /**
+ * @tc.name setSecurityLevel, secureityLevel is S0
+ * @tc.number SUB_DDM_DDB_DataSecurity_0010
+ * @tc.desc 1.构造条件 2.检查结果
+ * @tc.author
+ */
+ it('securityLabelTest010', 0, async function(done) {
+ const options = {
+ createIfMissing : true,
+ encrypt : false,
+ backup : false,
+ autoSync : false,
+ kvStoreType : 1,
+ schema : '',
+ securityLevel : 1,
+ }
+ const promise = kvManager.getKVStore(KVSTOREID, options);
+ promise.then((store) => {
+ if (store == null) {
+ console.info(TAG + "GetKVStore getKVStore fail ");
+ return;
+ }
+ kvStore = store;
+ console.info("GetKVStore getKVStore success " + store);
+ })
+ })
+ /**
+ * @tc.name setSecurityLevel, secureityLevel is S1
+ * @tc.number SUB_DDM_DDB_DataSecurity_0020
+ * @tc.desc 1.构造条件 2.检查结果
+ * @tc.author
+ */
+ it('securityLabelTest020', 0, async function(done) {
+ const options = {
+ createIfMissing : true,
+ encrypt : false,
+ backup : false,
+ autoSync : false,
+ kvStoreType : 1,
+ schema : '',
+ securityLevel : 2,
+ }
+ const promise = kvManager.getKVStore(KVSTOREID, options);
+ promise.then((store) => {
+ if (store == null) {
+ console.info(TAG + "GetKVStore getKVStore fail ");
+ return;
+ }
+ kvStore = store;
+ console.info("GetKVStore getKVStore success " + store);
+ })
+ })
+ /**
+ * @tc.name setSecurityLevel, secureityLevel is S2
+ * @tc.number SUB_DDM_DDB_DataSecurity_0030
+ * @tc.desc 1.构造条件 2.检查结果
+ * @tc.author
+ */
+ it('securityLabelTest030', 0, async function(done) {
+ const options = {
+ createIfMissing : true,
+ encrypt : false,
+ backup : false,
+ autoSync : false,
+ kvStoreType : 1,
+ schema : '',
+ securityLevel : 3,
+ }
+ const promise = kvManager.getKVStore(KVSTOREID, options);
+ promise.then((store) => {
+ if (store == null) {
+ console.info(TAG + "GetKVStore getKVStore fail ");
+ return;
+ }
+ kvStore = store;
+ console.info("GetKVStore getKVStore success " + store);
+ })
+ })
+ /**
+ * @tc.name setSecurityLevel, secureityLevel is S3
+ * @tc.number SUB_DDM_DDB_DataSecurity_0040
+ * @tc.desc 1.构造条件 2.检查结果
+ * @tc.author
+ */
+ it('securityLabelTest040', 0, async function(done) {
+ const options = {
+ createIfMissing : true,
+ encrypt : false,
+ backup : false,
+ autoSync : false,
+ kvStoreType : 1,
+ schema : '',
+ securityLevel : 5,
+ }
+ const promise = kvManager.getKVStore(KVSTOREID, options);
+ promise.then((store) => {
+ if (store == null) {
+ console.info(TAG + "GetKVStore getKVStore fail ");
+ return;
+ }
+ kvStore = store;
+ console.info("GetKVStore getKVStore success " + store);
+ })
+ })
+ /**
+ * @tc.name setSecurityLevel, secureityLevel is S4
+ * @tc.number SUB_DDM_DDB_DataSecurity_0050
+ * @tc.desc 1.构造条件 2.检查结果
+ * @tc.author
+ */
+ it('securityLabelTest050', 0, async function(done) {
+ const options = {
+ createIfMissing : true,
+ encrypt : false,
+ backup : false,
+ autoSync : false,
+ kvStoreType : 1,
+ schema : '',
+ securityLevel : 6,
+ }
+ const promise = kvManager.getKVStore(KVSTOREID, options);
+ promise.then((store) => {
+ if (store == null) {
+ console.info(TAG + "GetKVStore getKVStore fail ");
+ return;
+ }
+ kvStore = store;
+ console.info("GetKVStore getKVStore success " + store);
+ })
+ })
+ /**
+ * @tc.name setSecurityLevel, secureityLevel is NO_LEVEL
+ * @tc.number SUB_DDM_DDB_DataSecurity_0060
+ * @tc.desc 1.构造条件 2.检查结果
+ * @tc.author
+ */
+ it('securityLabelTest060', 0, async function(done) {
+ const options = {
+ createIfMissing : true,
+ encrypt : false,
+ backup : false,
+ autoSync : false,
+ kvStoreType : 1,
+ schema : '',
+ }
+ const promise = kvManager.getKVStore(KVSTOREID, options);
+ promise.then((store) => {
+ if (store == null) {
+ console.info(TAG + "GetKVStore getKVStore fail ");
+ return;
+ }
+ kvStore = store;
+ console.info("GetKVStore getKVStore success " + store);
+ })
+ })
+})
\ No newline at end of file
diff --git a/kvdb/kvdbTest/entry/src/main/resources/base/element/string.json b/kvdb/kvdbTest/entry/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..0bae6bd40f7360d5d818998221b199d3ec0f69c0
--- /dev/null
+++ b/kvdb/kvdbTest/entry/src/main/resources/base/element/string.json
@@ -0,0 +1,12 @@
+{
+ "string": [
+ {
+ "name": "entry_MainAbility",
+ "value": "entry_MainAbility"
+ },
+ {
+ "name": "mainability_description",
+ "value": "JS_Empty Ability"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/kvdb/kvdbTest/entry/src/main/resources/base/media/icon.png b/kvdb/kvdbTest/entry/src/main/resources/base/media/icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c
Binary files /dev/null and b/kvdb/kvdbTest/entry/src/main/resources/base/media/icon.png differ
diff --git a/kvdb/kvdbTest/gradle.properties b/kvdb/kvdbTest/gradle.properties
new file mode 100644
index 0000000000000000000000000000000000000000..be492496f9a20ac2d980ef4fc30061f4184c1c40
--- /dev/null
+++ b/kvdb/kvdbTest/gradle.properties
@@ -0,0 +1,13 @@
+# Project-wide Gradle settings.
+# IDE (e.g. DevEco Studio) users:
+# Gradle settings configured through the IDE *will override*
+# any settings specified in this file.
+# For more details on how to configure your build environment visit
+# http://www.gradle.org/docs/current/userguide/build_environment.html
+# Specifies the JVM arguments used for the daemon process.
+# The setting is particularly useful for tweaking memory settings.
+# If the Chinese output is garbled, please configure the following parameter.
+# This function is enabled by default when the DevEco Studio builds the hap/app,if you need disable gradle parallel,you should set org.gradle.parallel false.
+# more information see https://docs.gradle.org/current/userguide/performance.html
+# org.gradle.parallel=false
+# org.gradle.jvmargs=-Dfile.encoding=GBK
\ No newline at end of file
diff --git a/kvdb/kvdbTest/gradle/wrapper/gradle-wrapper.jar b/kvdb/kvdbTest/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000000000000000000000000000000000000..490fda8577df6c95960ba7077c43220e5bb2c0d9
Binary files /dev/null and b/kvdb/kvdbTest/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/kvdb/kvdbTest/gradle/wrapper/gradle-wrapper.properties b/kvdb/kvdbTest/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000000000000000000000000000000000000..f59159e865d4b59feb1b8c44b001f62fc5d58df4
--- /dev/null
+++ b/kvdb/kvdbTest/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,5 @@
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+distributionUrl=https\://repo.huaweicloud.com/gradle/gradle-6.3-bin.zip
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
diff --git a/kvdb/kvdbTest/gradlew b/kvdb/kvdbTest/gradlew
new file mode 100644
index 0000000000000000000000000000000000000000..2fe81a7d95e4f9ad2c9b2a046707d36ceb3980b3
--- /dev/null
+++ b/kvdb/kvdbTest/gradlew
@@ -0,0 +1,183 @@
+#!/usr/bin/env sh
+
+#
+# Copyright 2015 the original author or authors.
+#
+# 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
+#
+# https://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.
+#
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn () {
+ echo "$*"
+}
+
+die () {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+ NONSTOP* )
+ nonstop=true
+ ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+ JAVACMD=`cygpath --unix "$JAVACMD"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=`expr $i + 1`
+ done
+ case $i in
+ 0) set -- ;;
+ 1) set -- "$args0" ;;
+ 2) set -- "$args0" "$args1" ;;
+ 3) set -- "$args0" "$args1" "$args2" ;;
+ 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Escape application args
+save () {
+ for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+ echo " "
+}
+APP_ARGS=`save "$@"`
+
+# Collect all arguments for the java command, following the shell quoting and substitution rules
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
+
+exec "$JAVACMD" "$@"
diff --git a/kvdb/kvdbTest/gradlew.bat b/kvdb/kvdbTest/gradlew.bat
new file mode 100644
index 0000000000000000000000000000000000000000..62bd9b9ccefea2b65ae41e5d9a545e2021b90a1d
--- /dev/null
+++ b/kvdb/kvdbTest/gradlew.bat
@@ -0,0 +1,103 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windows variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/kvdb/kvdbTest/package.json b/kvdb/kvdbTest/package.json
new file mode 100644
index 0000000000000000000000000000000000000000..0967ef424bce6791893e9a57bb952f80fd536e93
--- /dev/null
+++ b/kvdb/kvdbTest/package.json
@@ -0,0 +1 @@
+{}
diff --git a/kvdb/kvdbTest/settings.gradle b/kvdb/kvdbTest/settings.gradle
new file mode 100644
index 0000000000000000000000000000000000000000..4773db73233a570c2d0c01a22e75321acfbf7a07
--- /dev/null
+++ b/kvdb/kvdbTest/settings.gradle
@@ -0,0 +1 @@
+include ':entry'