未验证 提交 1c269620 编写于 作者: O openharmony_ci 提交者: Gitee

!6803 Distributeddatamgr】【master】monthly_20221018分支代码回合;替换p7b文件

Merge pull request !6803 from yanglifeng/master
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
"mainAbility": ".MainAbility", "mainAbility": ".MainAbility",
"deviceType": [ "deviceType": [
"default", "default",
"tablet",
"phone" "phone"
], ],
"distro": { "distro": {
......
...@@ -16,8 +16,8 @@ ...@@ -16,8 +16,8 @@
"package": "ohos.acts.dataSharejstest", "package": "ohos.acts.dataSharejstest",
"name": ".entry", "name": ".entry",
"deviceType": [ "deviceType": [
"tablet",
"default", "default",
"tablet",
"phone" "phone"
], ],
"distro": { "distro": {
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
"srcPath":"", "srcPath":"",
"deviceType": [ "deviceType": [
"default", "default",
"tablet",
"phone" "phone"
], ],
"distro": { "distro": {
......
...@@ -17,7 +17,8 @@ ...@@ -17,7 +17,8 @@
"name": ".entry", "name": ".entry",
"deviceType": [ "deviceType": [
"tablet", "tablet",
"default" "default",
"phone"
], ],
"distro": { "distro": {
"deliveryWithInstall": true, "deliveryWithInstall": true,
......
...@@ -12,35 +12,35 @@ ...@@ -12,35 +12,35 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
// import rdbStoreBackupRestoreCallbackTest from './RdbstoreBackupRestoreCallbackJsunit.test.js' import rdbStoreBackupRestoreCallbackTest from './RdbstoreBackupRestoreCallbackJsunit.test.js'
// import rdbStoreBackupRestoreWithFAContextTest from './RdbstoreBackupRestoreWithFAContextJsunit.test.js' import rdbStoreBackupRestoreWithFAContextTest from './RdbstoreBackupRestoreWithFAContextJsunit.test.js'
// import rdbStoreDeleteTest from './RdbstoreDeleteJsunit.test.js' import rdbStoreDeleteTest from './RdbstoreDeleteJsunit.test.js'
import rdbStoreDistributedTest from './RdbStoreDistributedJsunit.test.js' import rdbStoreDistributedTest from './RdbStoreDistributedJsunit.test.js'
// import rdbstoreInsertTest from './RdbstoreInsertJsunit.test.js' import rdbstoreInsertTest from './RdbstoreInsertJsunit.test.js'
// import rdbStorePredicatesJoinTest from './RdbstorePredicatesJoinJsunit.test.js' import rdbStorePredicatesJoinTest from './RdbstorePredicatesJoinJsunit.test.js'
// import rdbPredicatesTest from './RdbstorePredicatesJsunit.test.js' import rdbPredicatesTest from './RdbstorePredicatesJsunit.test.js'
// import rdbStoreTest from './RdbstoreRdbstoreJsunit.test.js' import rdbStoreTest from './RdbstoreRdbstoreJsunit.test.js'
import rdbResultSetTest from './RdbStoreResultSetJsunit.test.js' import rdbResultSetTest from './RdbStoreResultSetJsunit.test.js'
// import rdbstoreStoreExcuteSqlTest from './RdbstoreStoreExcuteSqlJsunit.test.js' import rdbstoreStoreExcuteSqlTest from './RdbstoreStoreExcuteSqlJsunit.test.js'
// import rdbstoreTransactionTest from './RdbstoreTransactionJsunit.test.js' import rdbstoreTransactionTest from './RdbstoreTransactionJsunit.test.js'
// import rdbStoreUpdateTest from './RdbstoreUpdateJsunit.test.js' import rdbStoreUpdateTest from './RdbstoreUpdateJsunit.test.js'
// import rdbstoreQueryTest from './RdbstoreQuery.test.js' import rdbstoreQueryTest from './RdbstoreQuery.test.js'
// import rdbStoreEncryptionTest from './RdbstoreEncryptionJsunit.test.js' import rdbStoreEncryptionTest from './RdbstoreEncryptionJsunit.test.js'
// import rdbStorePredicatesComplexFiledTest from './RdbstorePredicatesComplexFiledJsunit.test.js' import rdbStorePredicatesComplexFiledTest from './RdbstorePredicatesComplexFiledJsunit.test.js'
export default function testsuite() { export default function testsuite() {
// rdbStoreBackupRestoreCallbackTest() rdbStoreBackupRestoreCallbackTest()
// rdbStoreBackupRestoreWithFAContextTest() rdbStoreBackupRestoreWithFAContextTest()
// rdbStoreDeleteTest() rdbStoreDeleteTest()
rdbStoreDistributedTest() rdbStoreDistributedTest()
// rdbstoreInsertTest() rdbstoreInsertTest()
// rdbStorePredicatesJoinTest() rdbStorePredicatesJoinTest()
// rdbPredicatesTest() rdbPredicatesTest()
// rdbStoreTest() rdbStoreTest()
rdbResultSetTest() rdbResultSetTest()
// rdbstoreStoreExcuteSqlTest() rdbstoreStoreExcuteSqlTest()
// rdbstoreTransactionTest() rdbstoreTransactionTest()
// rdbStoreUpdateTest() rdbStoreUpdateTest()
// rdbstoreQueryTest() rdbstoreQueryTest()
// rdbStoreEncryptionTest() rdbStoreEncryptionTest()
// rdbStorePredicatesComplexFiledTest() rdbStorePredicatesComplexFiledTest()
} }
...@@ -13,19 +13,63 @@ ...@@ -13,19 +13,63 @@
* limitations under the License. * limitations under the License.
*/ */
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium';
import dataRdb from '@ohos.data.rdb'; import dataRdb from '@ohos.data.rdb';
import abilityFeatureAbility from '@ohos.ability.featureAbility'; import abilityFeatureAbility from '@ohos.ability.featureAbility';
let context = abilityFeatureAbility.getContext(); let context = abilityFeatureAbility.getContext();
var sqlStatement = "CREATE TABLE IF NOT EXISTS employee (" +
"id INTEGER PRIMARY KEY AUTOINCREMENT," +
"name TEXT NOT NULL," +"age INTEGER)"
sqlStatement = "CREATE TABLE IF NOT EXISTS product (" +
"id INTEGER PRIMARY KEY AUTOINCREMENT," +
"name TEXT NOT NULL," +"price REAL," +
"vendor INTEGER," +"describe TEXT)"
const TAG = "[RDB_JSKITS_TEST_Distributed]" const TAG = "[RDB_JSKITS_TEST_Distributed]"
const STORE_NAME = "distributed_rdb.db" const STORE_NAME = "distributed_rdb.db"
var rdbStore = undefined; var rdbStore = undefined;
const config = {
"name": STORE_NAME,
}
async function executeSql1() {
let sqlStatement = "CREATE TABLE IF NOT EXISTS employee (" +
"id INTEGER PRIMARY KEY AUTOINCREMENT," +
"name TEXT NOT NULL," +
"age INTEGER)"
try {
await rdbStore.executeSql(sqlStatement, null)
console.info(TAG + "create table employee success")
} catch (err) {
console.info(TAG + "create table employee failed")
expect(null).assertFail()
}
}
async function executeSql2() {
let sqlStatement = "CREATE TABLE IF NOT EXISTS product (" +
"id INTEGER PRIMARY KEY AUTOINCREMENT," +
"name TEXT NOT NULL," +
"price REAL," +
"vendor INTEGER," +
"describe TEXT)"
try {
await rdbStore.executeSql(sqlStatement, null)
console.info(TAG + "create table product success")
} catch (err) {
console.info(TAG + "create table product failed")
expect(null).assertFail()
}
}
export default function rdbStoreDistributedTest() { export default function rdbStoreDistributedTest() {
describe('rdbStoreDistributedTest', function () { describe('rdbStoreDistributedTest', function () {
beforeAll(async function () { beforeAll(async function () {
console.info(TAG + 'beforeAll') console.info(TAG + 'beforeAll')
rdbStore = await dataRdb.getRdbStore(config, 1);
console.info(TAG + "create rdb store success")
await executeSql1()
await executeSql2()
}) })
beforeEach(async function () { beforeEach(async function () {
...@@ -43,53 +87,6 @@ describe('rdbStoreDistributedTest', function () { ...@@ -43,53 +87,6 @@ describe('rdbStoreDistributedTest', function () {
console.info(TAG + "*************Unit Test Begin*************"); console.info(TAG + "*************Unit Test Begin*************");
/**
* @tc.name rdb open test
* @tc.number SUB_DDM_AppDataFWK_JSRDB_Distributed_001
* @tc.desc rdb open test
*/
it('testRdbStoreDistributed0001', 0, async function (done) {
console.info(TAG + "************* testRdbStoreDistributed001 start *************");
const config = {
"name": STORE_NAME,
}
try {
rdbStore = await dataRdb.getRdbStore(config, 1);
console.info(TAG + "create rdb store success")
expect(rdbStore).assertEqual(rdbStore)
let sqlStatement = "CREATE TABLE IF NOT EXISTS employee (" +
"id INTEGER PRIMARY KEY AUTOINCREMENT," +
"name TEXT NOT NULL," +
"age INTEGER)"
try {
await rdbStore.executeSql(sqlStatement, null)
console.info(TAG + "create table employee success")
} catch (err) {
console.info(TAG + "create table employee failed")
expect(null).assertFail()
}
sqlStatement = "CREATE TABLE IF NOT EXISTS product (" +
"id INTEGER PRIMARY KEY AUTOINCREMENT," +
"name TEXT NOT NULL," +
"price REAL," +
"vendor INTEGER," +
"describe TEXT)"
try {
await rdbStore.executeSql(sqlStatement, null)
console.info(TAG + "create table product success")
} catch (err) {
console.info(TAG + "create table product failed")
expect(null).assertFail()
}
} catch (err) {
console.info(TAG + "create rdb store failed")
expect(null).assertFail()
}
done()
console.info(TAG + "************* testRdbStoreDistributed001 end *************");
})
/** /**
* @tc.name set_distributed_table_none_table * @tc.name set_distributed_table_none_table
* @tc.number SUB_DDM_AppDataFWK_JSRDB_Distributed_002 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Distributed_002
...@@ -163,7 +160,7 @@ describe('rdbStoreDistributedTest', function () { ...@@ -163,7 +160,7 @@ describe('rdbStoreDistributedTest', function () {
console.info(TAG + "insert one record success " + rowId) console.info(TAG + "insert one record success " + rowId)
expect(1).assertEqual(rowId) expect(1).assertEqual(rowId)
} catch (err) { } catch (err) {
console.info(TAG + "insert one record failed"); console.info(TAG + "insert one record failed" + err);
expect(null).assertFail(); expect(null).assertFail();
} }
done() done()
...@@ -189,7 +186,7 @@ describe('rdbStoreDistributedTest', function () { ...@@ -189,7 +186,7 @@ describe('rdbStoreDistributedTest', function () {
console.info(TAG + "update one record success " + rowId) console.info(TAG + "update one record success " + rowId)
expect(1).assertEqual(rowId) expect(1).assertEqual(rowId)
} catch (err) { } catch (err) {
console.info(TAG + "update one record failed"); console.info(TAG + "update one record failed" + err);
expect(null).assertFail(); expect(null).assertFail();
} }
} catch (err) { } catch (err) {
......
...@@ -94,7 +94,7 @@ describe('rdbEncryptTest', function () { ...@@ -94,7 +94,7 @@ describe('rdbEncryptTest', function () {
console.info(TAG + 'afterAll') console.info(TAG + 'afterAll')
}) })
console.log(TAG + "*************Unit Test Begin*************") console.info(TAG + "*************Unit Test Begin*************")
/** /**
* @tc.name RDB encrypted test * @tc.name RDB encrypted test
...@@ -102,23 +102,15 @@ describe('rdbEncryptTest', function () { ...@@ -102,23 +102,15 @@ describe('rdbEncryptTest', function () {
* @tc.desc RDB create encrypt db test * @tc.desc RDB create encrypt db test
*/ */
it('RdbEncryptTest_0010', 0, async function (done) { it('RdbEncryptTest_0010', 0, async function (done) {
await console.log(TAG + "************* RdbEncryptTest_0010 start *************") console.info(TAG + "************* RdbEncryptTest_0010 start *************")
context = ability_featureAbility.getContext() context = ability_featureAbility.getContext()
let storePromise = data_rdb.getRdbStore(context, STORE_CONFIG_ENCRYPT, 1); data_rdb.getRdbStore(context, STORE_CONFIG_ENCRYPT, 1).then((store) => {
storePromise.then(async (store) => { done()
try { expect(store != null).assertTrue();
await console.log(TAG + "getRdbStore done: " + store);
} catch (err) {
expect(null).assertFail();
}
}).catch((err) => { }).catch((err) => {
expect(null).assertFail(); expect(null).assertFail();
}) })
await storePromise console.info(TAG + "************* RdbEncryptTest_0010 end *************")
storePromise = null
done()
await console.log(TAG + "************* RdbEncryptTest_0010 end *************")
}) })
/** /**
...@@ -127,23 +119,17 @@ describe('rdbEncryptTest', function () { ...@@ -127,23 +119,17 @@ describe('rdbEncryptTest', function () {
* @tc.desc RDB create unencrypted db test * @tc.desc RDB create unencrypted db test
*/ */
it('RdbEncryptTest_0020', 0, async function (done) { it('RdbEncryptTest_0020', 0, async function (done) {
await console.log(TAG + "************* RdbEncryptTest_0020 start *************") console.info(TAG + "************* RdbEncryptTest_0020 start *************")
context = ability_featureAbility.getContext() context = ability_featureAbility.getContext()
let storePromise = data_rdb.getRdbStore(context, STORE_CONFIG_UNENCRYPT, 1); let storePromise = data_rdb.getRdbStore(context, STORE_CONFIG_UNENCRYPT, 1);
storePromise.then(async (store) => { storePromise.then((store) => {
try { expect(store != null).assertTrue();
await console.log(TAG + "getRdbStore done: " + store); done()
} catch (err) {
expect(null).assertFail();
}
}).catch((err) => { }).catch((err) => {
expect(null).assertFail(); expect(null).assertFail();
}) })
await storePromise
storePromise = null
done() console.info(TAG + "************* RdbEncryptTest_0020 end *************")
await console.log(TAG + "************* RdbEncryptTest_0020 end *************")
}) })
...@@ -153,14 +139,14 @@ describe('rdbEncryptTest', function () { ...@@ -153,14 +139,14 @@ describe('rdbEncryptTest', function () {
* @tc.desc RDB Encrypt function test * @tc.desc RDB Encrypt function test
*/ */
it('RdbEncryptTest_0030', 0, async function (done) { it('RdbEncryptTest_0030', 0, async function (done) {
await console.log(TAG + "************* RdbEncryptTest_0030 start *************") console.info(TAG + "************* RdbEncryptTest_0030 start *************")
context = ability_featureAbility.getContext() context = ability_featureAbility.getContext()
rdbStore = await CreatRdbStore(context, STORE_CONFIG_ENCRYPT) rdbStore = await CreatRdbStore(context, STORE_CONFIG_ENCRYPT)
let predicates = new data_rdb.RdbPredicates("test") let predicates = new data_rdb.RdbPredicates("test")
predicates.equalTo("name", "zhangsan") predicates.equalTo("name", "zhangsan")
let resultSet = await rdbStore.query(predicates) let resultSet = await rdbStore.query(predicates)
try { try {
console.log(TAG + "After restore resultSet query done") console.info(TAG + "After restore resultSet query done")
expect(true).assertEqual(resultSet.goToFirstRow()) expect(true).assertEqual(resultSet.goToFirstRow())
const id = resultSet.getLong(resultSet.getColumnIndex("id")) const id = resultSet.getLong(resultSet.getColumnIndex("id"))
const name = resultSet.getString(resultSet.getColumnIndex("name")) const name = resultSet.getString(resultSet.getColumnIndex("name"))
...@@ -174,7 +160,7 @@ describe('rdbEncryptTest', function () { ...@@ -174,7 +160,7 @@ describe('rdbEncryptTest', function () {
resultSet = null resultSet = null
rdbStore = null rdbStore = null
done() done()
await console.log(TAG + "************* RdbEncryptTest_0030 end *************") console.info(TAG + "************* RdbEncryptTest_0030 end *************")
}) })
/** /**
...@@ -183,7 +169,7 @@ describe('rdbEncryptTest', function () { ...@@ -183,7 +169,7 @@ describe('rdbEncryptTest', function () {
* @tc.desc RDB Encrypt function test * @tc.desc RDB Encrypt function test
*/ */
it('RdbEncryptTest_0040', 0, async function (done) { it('RdbEncryptTest_0040', 0, async function (done) {
await console.log(TAG + "************* RdbEncryptTest_0040 start *************") console.info(TAG + "************* RdbEncryptTest_0040 start *************")
context = ability_featureAbility.getContext() context = ability_featureAbility.getContext()
rdbStore = await CreatRdbStore(context, STORE_CONFIG_ENCRYPT) rdbStore = await CreatRdbStore(context, STORE_CONFIG_ENCRYPT)
rdbStore = null rdbStore = null
...@@ -191,9 +177,9 @@ describe('rdbEncryptTest', function () { ...@@ -191,9 +177,9 @@ describe('rdbEncryptTest', function () {
expect(rdbStore).assertNull expect(rdbStore).assertNull
done() done()
await console.log(TAG + "************* RdbEncryptTest_0040 end *************") console.info(TAG + "************* RdbEncryptTest_0040 end *************")
}) })
console.log(TAG + "*************Unit Test End*************") console.info(TAG + "*************Unit Test End*************")
} }
) )
......
...@@ -12,23 +12,22 @@ ...@@ -12,23 +12,22 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium';
import dataRdb from '@ohos.data.rdb'; import dataRdb from '@ohos.data.rdb';
import factory from '@ohos.data.distributedData' import factory from '@ohos.data.distributedData';
import abilityFeatureAbility from '@ohos.ability.featureAbility' import abilityFeatureAbility from '@ohos.ability.featureAbility';
const TAG = "[RDB_JSKITS_TEST]" const TAG = "[RDB_JSKITS_TEST]"
const CREATE_TABLE_TEST = "CREATE TABLE IF NOT EXISTS test (" + "id INTEGER PRIMARY KEY AUTOINCREMENT, " const CREATE_TABLE_TEST = "CREATE TABLE IF NOT EXISTS test (" + "id INTEGER PRIMARY KEY AUTOINCREMENT, "
+ "name TEXT NOT NULL, " + "age INTEGER, " + "salary REAL, " + "blobType BLOB)" + "name TEXT NOT NULL, " + "age INTEGER, " + "salary REAL, " + "blobType BLOB)"
const DATABASE_DIR = "/data/storage/el2/database/entry/rdb/"
const STORE_CONFIG = { const STORE_CONFIG = {
name: "Query.db", name: "Query.db",
} }
const TEST_BUNDLE_NAME="ohos.acts.relationalStorejstest" const TEST_BUNDLE_NAME="ohos.acts.relationalStorejstest"
var kvManager = null; var kvManager = null
var kvStore = null; var kvStore = null
var localDeviceId = null; var localDeviceId = null
var rdbStore var rdbStore
let context = abilityFeatureAbility.getContext() let context = abilityFeatureAbility.getContext()
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
* limitations under the License. * limitations under the License.
*/ */
import AbilityStage from "@ohos.app.ability.AbilityStage" import AbilityStage from "@ohos.application.AbilityStage"
export default class MyAbilityStage extends AbilityStage { export default class MyAbilityStage extends AbilityStage {
onCreate() { onCreate() {
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
* limitations under the License. * limitations under the License.
*/ */
import Ability from '@ohos.app.ability.UIAbility' import Ability from '@ohos.application.Ability'
import dataShare from '@ohos.data.dataShare' import dataShare from '@ohos.data.dataShare'
import rpc from "@ohos.rpc"; import rpc from "@ohos.rpc";
...@@ -111,7 +111,7 @@ export default class MainAbility extends Ability { ...@@ -111,7 +111,7 @@ export default class MainAbility extends Ability {
console.log("[ttt] [DataShareTest] <<Consumer>> MainAbility onWindowStageCreate") console.log("[ttt] [DataShareTest] <<Consumer>> MainAbility onWindowStageCreate")
globalThis.abilityContext = this.context; globalThis.abilityContext = this.context;
let context = this.context; let context = this.context;
dseConnectionId = context.connectServiceExtensionAbility(dseWant, dseConnect); dseConnectionId = context.connectAbility(dseWant, dseConnect);
globalThis.connectDataShareExtAbility = (async () => { globalThis.connectDataShareExtAbility = (async () => {
console.log("[ttt] [DataShareTest] <<Consumer>> connectDataShareExtAbility begin"); console.log("[ttt] [DataShareTest] <<Consumer>> connectDataShareExtAbility begin");
await dataShare.createDataShareHelper(globalThis.abilityContext, dseUri, (err,data)=>{ await dataShare.createDataShareHelper(globalThis.abilityContext, dseUri, (err,data)=>{
...@@ -122,7 +122,7 @@ export default class MainAbility extends Ability { ...@@ -122,7 +122,7 @@ export default class MainAbility extends Ability {
console.info("[ttt] [DataShareTest] <<Consumer>> ----- 3 -----, err = " + err); console.info("[ttt] [DataShareTest] <<Consumer>> ----- 3 -----, err = " + err);
console.info("[ttt] [DataShareTest] <<Consumer>> ----- 4 -----, JSON.stringify(err) = " + JSON.stringify(err)); console.info("[ttt] [DataShareTest] <<Consumer>> ----- 4 -----, JSON.stringify(err) = " + JSON.stringify(err));
}); });
dseConnectionId = await context.connectServiceExtensionAbility(dseWant, dseConnect); dseConnectionId = await context.connectAbility(dseWant, dseConnect);
}) })
windowStage.setUIContent(this.context, "MainAbility/pages/index", null) windowStage.setUIContent(this.context, "MainAbility/pages/index", null)
} }
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import Ability from '@ohos.app.ability.UIAbility' import Ability from '@ohos.application.Ability'
export default class TestAbility extends Ability { export default class TestAbility extends Ability {
onCreate(want, launchParam) { onCreate(want, launchParam) {
......
...@@ -9,7 +9,8 @@ ...@@ -9,7 +9,8 @@
"mainElement": "MainAbility", "mainElement": "MainAbility",
"deviceTypes": [ "deviceTypes": [
"default", "default",
"tablet" "tablet",
"phone"
], ],
"deliveryWithInstall": true, "deliveryWithInstall": true,
"installationFree": false, "installationFree": false,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册