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

!9294 完成telephony子系统http模块的跨平台测试套

Merge pull request !9294 from huyanqiang/telephony_zhangqiang
......@@ -13,5 +13,8 @@
group("telephony") {
testonly = true
deps = [ "telephonyjstest:telephonyjstest" ]
deps = [
"crossplatform/telephony_http_test:ActsCrossplatformTelephonyHttpEtsTest",
"telephonyjstest:telephonyjstest",
]
}
{
"app": {
"bundleName": "ohos.acts.telephony.crossplatform.http.normal",
"vendor": "example",
"versionCode": 1000000,
"versionName": "1.0.0",
"icon": "$media:app_icon",
"label": "$string:app_name",
"minAPIVersion": 10,
"targetAPIVersion": 10,
"car": {
"apiCompatibleVersion": 10,
"singleUser": false
}
}
}
# Copyright (C) 2023 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsCrossplatformTelephonyHttpEtsTest") {
hap_profile = "src/main/module.json"
deps = [
":windowStage_js_assets",
":windowStage_resources",
]
ets2abc = true
certificate_profile = "./signature/openharmony_sx.p7b"
# hap_name: HAP的名字,可选,默认为目标名
hap_name = "ActsCrossplatformTelephonyHttpEtsTest"
part_name = "netstack"
subsystem_name = "communication"
}
ohos_app_scope("windowStage_app_profile") {
# app_profile: HAP的AppScope中的app.json,只在Stage模型下使用
app_profile = "AppScope/app.json"
# sources: 资源文件路径
sources = [ "AppScope/resources" ]
}
ohos_js_assets("windowStage_js_assets") {
# source_dir: js或ets代码路径,兼容FA模型的单ability配置到ability目录
source_dir = "src/main/ets"
}
ohos_resources("windowStage_resources") {
# sources: 资源文件路径
sources = [ "src/main/resources" ]
# deps: 当前目标的依赖
deps = [ ":windowStage_app_profile" ]
# hap_profile: HAP的config.json,Stage模型对应module.json
hap_profile = "src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "60000",
"shell-timeout": "60000",
"bundle-name": "ohos.acts.telephony.crossplatform.http.normal",
"module-name": "entry_test"
},
"kits": [
{
"test-file-name": [
"ActsCrossplatformTelephonyHttpEtsTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
\ No newline at end of file
/*
* Copyright (C) 2023 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 UIAbility from '@ohos.app.ability.UIAbility';
import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
import hilog from '@ohos.hilog';
import { Hypium } from '@ohos/hypium';
import testsuite from '../test/List.test';
import window from '@ohos.window';
export default class TestAbility extends UIAbility {
onCreate(want, launchParam) {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onCreate');
hilog.info(0x0000, 'testTag', '%{public}s', 'want param:' + JSON.stringify(want) ?? '');
hilog.info(0x0000, 'testTag', '%{public}s', 'launchParam:'+ JSON.stringify(launchParam) ?? '');
var abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
hilog.info(0x0000, 'testTag', '%{public}s', 'start run testcase!!!');
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
}
onDestroy() {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onDestroy');
}
onWindowStageCreate(windowStage: window.WindowStage) {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageCreate');
globalThis.abilityContext = this.context;
windowStage.loadContent('TestAbility/pages/Index', (err, data) => {
if (err.code) {
hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
return;
}
hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s',
JSON.stringify(data) ?? '');
});
}
onWindowStageDestroy() {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageDestroy');
}
onForeground() {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onForeground');
}
onBackground() {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onBackground');
}
}
\ No newline at end of file
/*
* Copyright (C) 2023 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 hilog from '@ohos.hilog';
@Entry
@Component
struct Index {
aboutToAppear() {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility index aboutToAppear');
}
@State message: string = 'Hello World'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('next page 123')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.width('35%')
.height('5%')
.onClick(()=>{
})
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
import hilog from '@ohos.hilog';
import TestRunner from '@ohos.application.testRunner';
import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
var abilityDelegator = undefined
var abilityDelegatorArguments = undefined
async function onAbilityCreateCallback() {
hilog.info(0x0000, 'testTag', '%{public}s', 'onAbilityCreateCallback');
}
async function addAbilityMonitorCallback(err: any) {
hilog.info(0x0000, 'testTag', 'addAbilityMonitorCallback : %{public}s', JSON.stringify(err) ?? '');
}
export default class OpenHarmonyTestRunner implements TestRunner {
constructor() {
}
onPrepare() {
hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner OnPrepare ');
}
async onRun() {
hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun run');
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.bundleName + '.TestAbility'
let lMonitor = {
abilityName: testAbilityName,
onAbilityCreate: onAbilityCreateCallback,
};
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback)
var cmd = 'aa start -d 0 -a TestAbility' + ' -b ' + abilityDelegatorArguments.bundleName
var debug = abilityDelegatorArguments.parameters['-D']
if (debug == 'true')
{
cmd += ' -D'
}
hilog.info(0x0000, 'testTag', 'cmd : %{public}s', cmd);
abilityDelegator.executeShellCommand(cmd,
(err: any, d: any) => {
hilog.info(0x0000, 'testTag', 'executeShellCommand : err : %{public}s', JSON.stringify(err) ?? '');
hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.stdResult ?? '');
hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.exitCode ?? '');
})
hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun end');
}
}
\ No newline at end of file
/*
* Copyright (C) 2023 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, expect, it } from '@ohos/hypium';
import http from '@ohos.net.http';
export default function httpRequestJsunit() {
describe("HttpRequestJsunitTest", function () {
/**
* @tc.number TEST_TELEPHONY_HTTPREQUEST_REQUEST_001
* @tc.name testTelephonyHttpRequestRequest001
* @tc.desc Test Test httprequest property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpRequestRequest001", 0, async function (done) {
var casename = "Telephony_http_HttpRequest_0100"
console.log("-----------------------HttpRequest_request Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.GET,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000
}
var httpRequest = http.createHttp();
httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequest_request Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
console.log("testTelephonyHttpRequestRequest001 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTPREQUEST_REQUEST_002
* @tc.name testTelephonyHttpRequestRequest002
* @tc.desc Test Test httprequest property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpRequestRequest002", 0, async function (done) {
var casename = "Telephony_http_HttpRequest_0100"
console.log("-----------------------HttpRequest_request_01 Test is starting-----------------------");
try {
var httpRequest = http.createHttp();
httpRequest.request("https://www.baidu.com/", (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequest_request_01 Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
console.log("testTelephonyHttpRequestRequest002 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTPREQUEST_REQUEST_003
* @tc.name testTelephonyHttpRequestRequest003
* @tc.desc Test Test httprequest property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpRequestRequest003", 0, async function (done) {
var casename = "Telephony_http_HttpRequest_0100"
console.log("-----------------------HttpRequest_request_02 Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.GET,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000
};
var httpRequest = http.createHttp();
httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => {
console.log(casename + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequest_request_02 Test end-----------------------");
httpRequest.destroy();
done();
}).catch(error => {
console.info('HttpRequest_request_0300 asyncCallback error : ' + JSON.stringify(error));
expect(false).assertTrue();
done();
});
} catch (error) {
console.log("testTelephonyHttpRequestRequest003 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTPREQUEST_REQUEST_004
* @tc.name testTelephonyHttpRequestRequest004
* @tc.desc Test Test httprequest property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpRequestRequest004", 0, async function (done) {
var casename = "Telephony_http_HttpRequest_0100"
console.log("-----------------------HttpRequest_request Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.GET,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000
}
var httpRequest = http.createHttp();
httpRequest.request("https://app.4399.cn/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequest_request Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
console.log("testTelephonyHttpRequestRequest004 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTPREQUEST_REQUEST_005
* @tc.name testTelephonyHttpRequestRequest005
* @tc.desc Test Test httprequest property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpRequestRequest005", 0, async function (done) {
var casename = "Telephony_http_HttpRequest_0100"
console.log("-----------------------HttpRequest_request Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.GET,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000
}
var httpRequest = http.createHttp();
httpRequest.request("https://www.zhihu.com/signin", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequest_request Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
console.log("testTelephonyHttpRequestRequest005 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTPREQUEST_DESTROY_001
* @tc.name testTelephonyHttpRequestDestroy001
* @tc.desc Test Test httprequest property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpRequestDestroy001", 0, async function (done) {
var casename = "Telephony_http_HttpRequest_0200"
console.log("-----------------------HttpRequest_destroy Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.GET,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000
}
var httpRequest = http.createHttp();
httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
try {
httpRequest.destroy();
expect(true).assertTrue();
console.log("-----------------------HttpRequest_destroy Test end-----------------------");
httpRequest.destroy();
done();
} catch (error) {
expect(false).assertFail();
done();
}
});
} catch (error) {
console.log("testTelephonyHttpRequestDestroy001 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTPREQUEST_DESTROY_002
* @tc.name testTelephonyHttpRequestDestroy002
* @tc.desc Test Test httprequest property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpRequestDestroy002", 0, async function (done) {
var casename = "Telephony_http_HttpRequest_0200"
console.log("-----------------------HttpRequest_destroy Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.GET,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000
}
var httpRequest = http.createHttp();
httpRequest.request("https://app.4399.cn/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
try {
httpRequest.destroy();
expect(true).assertTrue();
console.log("-----------------------HttpRequest_destroy Test end-----------------------");
httpRequest.destroy();
done();
} catch (error) {
expect(false).assertFail();
done();
}
});
} catch (error) {
console.log("testTelephonyHttpRequestDestroy002 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTPREQUEST_DESTROY_003
* @tc.name testTelephonyHttpRequestDestroy003
* @tc.desc Test Test httprequest property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpRequestDestroy003", 0, async function (done) {
var casename = "Telephony_http_HttpRequest_0200"
console.log("-----------------------HttpRequest_destroy Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.GET,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000
}
var httpRequest = http.createHttp();
httpRequest.request("https://www.zhihu.com/signin", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
try {
httpRequest.destroy();
expect(true).assertTrue();
console.log("-----------------------HttpRequest_destroy Test end-----------------------");
httpRequest.destroy();
done();
} catch (error) {
expect(false).assertFail();
done();
}
});
} catch (error) {
console.log("testTelephonyHttpRequestDestroy003 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONYHTTPREQUESTONHEADERSRECEIVE_001
* @tc.name testTelephonyHttpRequestOnheadersReceive001
* @tc.desc Test Test httprequest property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpRequestOnheadersReceive001", 0, function (done) {
var casename = "Telephony_http_HttpRequest_0500"
console.log("-----------------------HttpRequest_on_headersReceive Test is starting-----------------------");
try {
var httpRequest = http.createHttp();
httpRequest.on("headersReceive", (data) => {
console.log(casename + " data: " + JSON.stringify(data));
expect(true).assertTrue();
console.log("-----------------------HttpRequest_on_headersReceive Test end-----------------------");
httpRequest.destroy();
done();
});
httpRequest.request("https://www.baidu.com/", (err, data) => {
console.log(casename + " data: " + JSON.stringify(data.responseCode) + " err: " + JSON.stringify(err));
});
} catch (error) {
console.log("testTelephonyHttpRequestOnheadersReceive001 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONYHTTPREQUESTOFFHEADERSRECEIVE_001
* @tc.name testTelephonyHttpRequestOffheadersReceive001
* @tc.desc Test Test httprequest property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpRequestOffheadersReceive001", 0, function (done) {
var casename = "Telephony_http_HttpRequest_0600"
console.log("-----------------------HttpRequest_off_headersReceive Test is starting-----------------------");
try {
var httpRequest = http.createHttp();
httpRequest.off("headersReceive", (data) => {
console.log(casename + " data: " + JSON.stringify(data));
expect(false).assertTrue();
console.log("-----------------------HttpRequest_off_headersReceive Test end-----------------------");
httpRequest.destroy();
done();
});
httpRequest.request("https://www.baidu.com/", (err, data) => {
console.log(casename + " data: " + JSON.stringify(data.responseCode) + " err: " + JSON.stringify(err));
done();
});
} catch (error) {
console.log("testTelephonyHttpRequestOffheadersReceive001 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONYHTTPREQUESTOFFHEADERSRECEIVE_002
* @tc.name testTelephonyHttpRequestOffheadersReceive002
* @tc.desc Test Test httprequest property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpRequestOffheadersReceive002", 0, function (done) {
console.log("-----------------------HttpRequest_off_headersReceive Test is starting-----------------------");
try {
var httpRequest = http.createHttp();
httpRequest.off('headersReceive');
expect(true).assertTrue();
console.log("-----------------------HttpRequest_off_headersReceive_0200 Test end-----------------------");
httpRequest.destroy();
done();
} catch (error) {
console.log("testTelephonyHttpRequestOffheadersReceive002 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONYHTTPREQUESTONCEHEADERSRECEIVE_001
* @tc.name testTelephonyHttpRequestOnceheadersReceive001
* @tc.desc Test Test httprequest property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpRequestOnceheadersReceive001", 0, function (done) {
var casename = "Telephony_http_HttpRequest_once_headersReceive_0100"
console.log("-----------------------HttpRequest_once_headersReceive Test is starting-----------------------");
try {
var httpRequest = http.createHttp();
httpRequest.once('headersReceive', (data) => {
console.log(casename + " data: " + JSON.stringify(data));
expect(true).assertTrue();
console.log("-----------------------HttpRequest_on_headersReceive Test end-----------------------");
httpRequest.destroy();
done();
});
httpRequest.request("https://www.baidu.com/", (err, data) => {
console.log(casename + " data: " + JSON.stringify(data.responseCode) + " err: " + JSON.stringify(err));
});
} catch (error) {
console.log("testTelephonyHttpRequestOnceheadersReceive001 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONYHTTPREQUESTONCEHEADERSRECEIVE_002
* @tc.name testTelephonyHttpRequestOnceheadersReceive002
* @tc.desc Test Test httprequest property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpRequestOnceheadersReceive002", 0, function (done) {
var casename = "Telephony_http_HttpRequest_once_headersReceive_0100"
console.log("-----------------------HttpRequest_once_headersReceive Test is starting-----------------------");
try {
var httpRequest = http.createHttp();
httpRequest.once('headersReceive', (data) => {
console.log(casename + " data: " + JSON.stringify(data));
expect(true).assertTrue();
console.log("-----------------------HttpRequest_on_headersReceive Test end-----------------------");
httpRequest.destroy();
done();
});
httpRequest.request("https://app.4399.cn/", (err, data) => {
console.log(casename + " data: " + JSON.stringify(data.responseCode) + " err: " + JSON.stringify(err));
});
} catch (error) {
console.log("testTelephonyHttpRequestOnceheadersReceive002 : error = " + error);
expect(false).assertTrue();
done();
}
});
})
};
/*
* Copyright (C) 2023 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, it, expect} from '@ohos/hypium';
import http from '@ohos.net.http';
export default function HttpRequestOptionsJsunit() {
describe("HttpRequestOptionsJsunitTest", function () {
/**
* @tc.number TEST_TELEPHONYHTTPREQUESTOPTIONSMETHOD_001
* @tc.name testTelephonyHttpRequestOptionsMethod001
* @tc.desc Test Test HttpRequestOptions property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpRequestOptionsMethod001", 0, async function (done) {
var casename = 'Telephony_Http_HttpRequestOptions_0100';
console.log("-----------------------HttpRequestOptions_method Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.GET,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000
}
var httpRequest = http.createHttp();
httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestOptions_method Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
console.log("testTelephonyHttpRequestOptionsMethod001 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONYHTTPREQUESTOPTIONSMETHOD_002
* @tc.name testTelephonyHttpRequestOptionsMethod002
* @tc.desc Test Test HttpRequestOptions property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpRequestOptionsMethod002", 0, async function (done) {
var casename = 'Telephony_Http_HttpRequestOptions_0100';
console.log("-----------------------HttpRequestOptions_method_01 Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.GET,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000
}
var httpRequest = http.createHttp();
httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => {
console.log(casename + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestOptions_method_01 Test end-----------------------");
httpRequest.destroy();
done();
}).catch(error => {
console.info(casename+"errocode" + JSON.stringify(error));
expect(false).assertTrue();
done();
});
} catch (error) {
console.log("testTelephonyHttpRequestOptionsMethod002 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONYHTTPREQUESTOPTIONSMETHOD_003
* @tc.name testTelephonyHttpRequestOptionsMethod003
* @tc.desc Test Test HttpRequestOptions property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpRequestOptionsMethod003", 0, async function (done) {
var casename = 'Telephony_Http_HttpRequestOptions_0100';
console.log("-----------------------HttpRequestOptions_method Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.GET,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000
}
var httpRequest = http.createHttp();
httpRequest.request("https://app.4399.cn/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestOptions_method Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
console.log("testTelephonyHttpRequestOptionsMethod003 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONYHTTPREQUESTOPTIONSEXTRADATA_001
* @tc.name testTelephonyHttpRequestOptionsExtraData001
* @tc.desc Test Test HttpRequestOptions property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpRequestOptionsExtraData001", 0, async function (done) {
var casename = 'Telephony_Http_HttpRequestOptions_0200';
console.log("-----------------------HttpRequestOptions_extraData Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.GET,
extraData: {
//tn=albumsdetail&word=渐变风格插画&fr=albumslist&album_tab=设计素材&album_id=409&rn=30
tn: "albumsdetail",
work: "渐变风格插画",
fr: "albumslist",
album_tab: "设计素材",
album_id: "409",
rn: "30"
},
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000
}
var httpRequest = http.createHttp();
httpRequest.request("https://image.baidu.com/search/albumsdetail/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestOptions_extraData Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
console.log("testTelephonyHttpRequestOptionsExtraData001 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONYHTTPREQUESTOPTIONSEXTRADATA_002
* @tc.name testTelephonyHttpRequestOptionsExtraData002
* @tc.desc Test Test HttpRequestOptions property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpRequestOptionsExtraData002", 0, async function (done) {
var casename = 'Telephony_Http_HttpRequestOptions_0200';
console.log("-----------------------HttpRequestOptions_extraData_01 Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.GET,
extraData: {
//tn=albumsdetail&word=渐变风格插画&fr=albumslist&album_tab=设计素材&album_id=409&rn=30
tn: "albumsdetail",
work: "渐变风格插画",
fr: "albumslist",
album_tab: "设计素材",
album_id: "409",
rn: "30"
},
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000
}
var httpRequest = http.createHttp();
httpRequest.request("https://image.baidu.com/search/albumsdetail/", httpRequestOptions).then(data => {
console.log(casename + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestOptions_extraData_01 Test end-----------------------");
httpRequest.destroy();
done();
}).catch(error => {
console.info(casename+"errocode" + JSON.stringify(error));
expect(false).assertTrue();
done();
});
} catch (error) {
console.log("testTelephonyHttpRequestOptionsExtraData002 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONYHTTPREQUESTOPTIONSEXPECTDATATYPE_001
* @tc.name testTelephonyHttpRequestOptionsExpectDataType001
* @tc.desc Test Test HttpRequestOptions property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpRequestOptionsExpectDataType001", 0, async function (done) {
var casename = 'Telephony_Http_HttpRequestOptions_expectDataType_0100';
console.log("-----------------------HttpRequestOptions_extraData Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.GET,
extraData: {
//tn=albumsdetail&word=渐变风格插画&fr=albumslist&album_tab=设计素材&album_id=409&rn=30
tn: "albumsdetail",
work: "渐变风格插画",
fr: "albumslist",
album_tab: "设计素材",
album_id: "409",
rn: "30",
},
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000,
expectDataType: http.HttpDataType.STRING
}
var httpRequest = http.createHttp();
httpRequest.request("https://image.baidu.com/search/albumsdetail/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestOptions_extraData Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
console.log("testTelephonyHttpRequestOptionsExpectDataType001 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONYHTTPREQUESTOPTIONSEXPECTDATATYPE_002
* @tc.name testTelephonyHttpRequestOptionsExpectDataType002
* @tc.desc Test Test HttpRequestOptions property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpRequestOptionsExpectDataType002", 0, async function (done) {
var casename = 'Telephony_Http_HttpRequestOptions_expectDataType_0100';
console.log("-----------------------HttpRequestOptions_extraData Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.GET,
extraData: {
//tn=albumsdetail&word=渐变风格插画&fr=albumslist&album_tab=设计素材&album_id=409&rn=30
tn: "albumsdetail",
work: "渐变风格插画",
fr: "albumslist",
album_tab: "设计素材",
album_id: "409",
rn: "30",
},
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000,
expectDataType: http.HttpDataType.OBJECT
}
var httpRequest = http.createHttp();
httpRequest.request("https://image.baidu.com/search/albumsdetail/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestOptions_extraData Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
console.log("testTelephonyHttpRequestOptionsExpectDataType002 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONYHTTPREQUESTOPTIONSEXPECTDATATYPE_003
* @tc.name testTelephonyHttpRequestOptionsExpectDataType003
* @tc.desc Test Test HttpRequestOptions property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpRequestOptionsExpectDataType003", 0, async function (done) {
var casename = 'Telephony_Http_HttpRequestOptions_expectDataType_0100';
console.log("-----------------------HttpRequestOptions_extraData Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.GET,
extraData: {
//tn=albumsdetail&word=渐变风格插画&fr=albumslist&album_tab=设计素材&album_id=409&rn=30
tn: "albumsdetail",
work: "渐变风格插画",
fr: "albumslist",
album_tab: "设计素材",
album_id: "409",
rn: "30",
},
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000,
expectDataType: http.HttpDataType.ARRAY_BUFFER
}
var httpRequest = http.createHttp();
httpRequest.request("https://image.baidu.com/search/albumsdetail/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestOptions_extraData Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
console.log("testTelephonyHttpRequestOptionsExpectDataType003 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONYHTTPREQUESTOPTIONSHEADER_001
* @tc.name testTelephonyHttpRequestOptionsHeader001
* @tc.desc Test Test HttpRequestOptions property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpRequestOptionsHeader001", 0, async function (done) {
var casename = 'Telephony_Http_HttpRequestOptions_0300';
console.log("-----------------------HttpRequestOptions_header Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.GET,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000
}
var httpRequest = http.createHttp();
httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
try {
expect(true).assertTrue();
console.log("-----------------------HttpRequestOptions_header Test end-----------------------");
httpRequest.destroy();
done();
} catch (error) {
console.log("testTelephonyHttpRequestOptionsHeaders001 : JSON parse error = " + error);
expect(false).assertFail();
done();
}
});
} catch (error) {
console.log("testTelephonyHttpRequestOptionsHeader001 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONYHTTPREQUESTOPTIONSHEADER_002
* @tc.name testTelephonyHttpRequestOptionsHeader002
* @tc.desc Test Test HttpRequestOptions property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpRequestOptionsHeader002", 0, async function (done) {
var casename = 'Telephony_Http_HttpRequestOptions_0300';
console.log("-----------------------HttpRequestOptions_header_01 Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.GET,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000
}
var httpRequest = http.createHttp();
httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => {
console.log(casename + JSON.stringify(data));
try {
expect(true).assertTrue();
console.log("-----------------------HttpRequestOptions_header_01 Test end-----------------------");
httpRequest.destroy();
done();
} catch (error) {
console.log("Telephony_Http_HttpRequestOptions_header_0200 : JSON parse error = " + error);
expect().assertFail();
done();
}
}).catch(error => {
console.info(casename+"errocode" + JSON.stringify(error));
expect(false).assertTrue();
done();
});
} catch (error) {
console.log("testTelephonyHttpRequestOptionsHeader002 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONYHTTPREQUESTOPTIONSHEADER_003
* @tc.name testTelephonyHttpRequestOptionsHeader003
* @tc.desc Test Test HttpRequestOptions property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpRequestOptionsHeader003", 0, async function (done) {
var casename = 'Telephony_Http_HttpRequestOptions_0300';
console.log("-----------------------HttpRequestOptions_header_02 Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.GET,
extraData: null,
header: "content-type': 'application/xml",
readTimeout: 60000,
connectTimeout: 60000
}
var httpRequest = http.createHttp();
httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
try {
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestOptions_header_02 Test end-----------------------");
httpRequest.destroy();
done();
} catch (error) {
console.log("testTelephonyHttpRequestOptionsHeader003 : JSON parse error = " + error);
expect().assertFail();
done();
}
});
} catch (error) {
console.log("testTelephonyHttpRequestOptionsHeader003 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONYHTTPREQUESTOPTIONSHEADER_004
* @tc.name testTelephonyHttpRequestOptionsHeader004
* @tc.desc Test Test HttpRequestOptions property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpRequestOptionsHeader004", 0, async function (done) {
var casename = 'Telephony_Http_HttpRequestOptions_0300';
console.log("-----------------------HttpRequestOptions_header_03 Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.GET,
extraData: null,
header: "content-type': 'application/xml",
readTimeout: 60000,
connectTimeout: 60000
}
var httpRequest = http.createHttp();
httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => {
console.log(casename + JSON.stringify(data));
try {
expect(data.result.valueOf() != "").assertTrue();
console.log("-----------------------HttpRequestOptions_header_03 Test end-----------------------");
httpRequest.destroy();
done();
} catch (error) {
console.log("testTelephonyHttpRequestOptionsHeader004 : JSON parse error = " + error);
expect().assertFail();
done();
}
}).catch(error => {
console.info(casename+"errocode" + JSON.stringify(error));
expect(false).assertTrue();
done();
});
} catch (error) {
console.log("testTelephonyHttpRequestOptionsHeader004 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONYHTTPREQUESTOPTIONSHEADER_005
* @tc.name testTelephonyHttpRequestOptionsHeader005
* @tc.desc Test Test HttpRequestOptions property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpRequestOptionsHeader005", 0, async function (done) {
var casename = 'Telephony_Http_HttpRequestOptions_0300';
console.log("-----------------------HttpRequestOptions_header Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.GET,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000
}
var httpRequest = http.createHttp();
httpRequest.request("https://app.4399.cn/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
try {
expect(true).assertTrue();
console.log("-----------------------HttpRequestOptions_header Test end-----------------------");
httpRequest.destroy();
done();
} catch (error) {
console.log("testTelephonyHttpRequestOptionsHeaders001 : JSON parse error = " + error);
expect(false).assertFail();
done();
}
});
} catch (error) {
console.log("testTelephonyHttpRequestOptionsHeader005 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONYHTTPREQUESTOPTIONSUSINGCACHE_001
* @tc.name testTelephonyHttpRequestOptionsUsingCache001
* @tc.desc Test Test HttpRequestOptions property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpRequestOptionsUsingCache001", 0, async function (done) {
var casename = 'Telephony_Http_HttpRequestOptions_usingCache_0100';
console.log("-----------------------HttpRequestOptions_usingCache Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.GET,
extraData: {
//tn=albumsdetail&word=渐变风格插画&fr=albumslist&album_tab=设计素材&album_id=409&rn=30
tn: "albumsdetail",
work: "渐变风格插画",
fr: "albumslist",
album_tab: "设计素材",
album_id: "409",
rn: "30"
},
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000,
usingCache: true
}
var httpRequest = http.createHttp();
httpRequest.request("https://image.baidu.com/search/albumsdetail/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestOptions_extraData Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
console.log("testTelephonyHttpRequestOptionsUsingCache001 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONYHTTPREQUESTOPTIONSPRIORITY_001
* @tc.name testTelephonyHttpRequestOptionsPriority001
* @tc.desc Test Test HttpRequestOptions property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpRequestOptionsPriority001", 0, async function (done) {
var casename = 'Telephony_Http_HttpRequestOptions_priority_0100';
console.log("-----------------------HttpRequestOptions_priority Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.GET,
extraData: {
//tn=albumsdetail&word=渐变风格插画&fr=albumslist&album_tab=设计素材&album_id=409&rn=30
tn: "albumsdetail",
work: "渐变风格插画",
fr: "albumslist",
album_tab: "设计素材",
album_id: "409",
rn: "30"
},
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000,
priority: 1
}
var httpRequest = http.createHttp();
httpRequest.request("https://image.baidu.com/search/albumsdetail/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestOptions_extraData Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
console.log("testTelephonyHttpRequestOptionsPriority001 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONYHTTPREQUESTOPTIONSPRIORITY_002
* @tc.name testTelephonyHttpRequestOptionsPriority002
* @tc.desc Test Test HttpRequestOptions property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpRequestOptionsPriority002", 0, async function (done) {
var casename = 'Telephony_Http_HttpRequestOptions_priority_0100';
console.log("-----------------------HttpRequestOptions_priority Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.GET,
extraData: {
//tn=albumsdetail&word=渐变风格插画&fr=albumslist&album_tab=设计素材&album_id=409&rn=30
tn: "albumsdetail",
work: "渐变风格插画",
fr: "albumslist",
album_tab: "设计素材",
album_id: "409",
rn: "30"
},
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000,
priority: 1000
}
var httpRequest = http.createHttp();
httpRequest.request("https://image.baidu.com/search/albumsdetail/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestOptions_extraData Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
console.log("testTelephonyHttpRequestOptionsPriority001 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTPREQUESTOPTIONS_USINGPROTOCOL_001
* @tc.name testTelephonyHttpRequestOptionsUsingProtocol001
* @tc.desc Test Test HttpRequestOptions property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpRequestOptionsUsingProtocol001", 0, async function (done) {
var casename = 'Telephony_Http_HttpRequestOptions_usingProtocol_0100';
console.log("-----------------------HttpRequestOptions_usingProtocol Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.GET,
extraData: {
//tn=albumsdetail&word=渐变风格插画&fr=albumslist&album_tab=设计素材&album_id=409&rn=30
tn: "albumsdetail",
work: "渐变风格插画",
fr: "albumslist",
album_tab: "设计素材",
album_id: "409",
rn: "30"
},
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000,
usingProtocol: http.HttpProtocol.HTTP1_1
}
var httpRequest = http.createHttp();
httpRequest.request("https://image.baidu.com/search/albumsdetail/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestOptions_usingProtocol Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
console.log("testTelephonyHttpRequestOptionsUsingProtocol001 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTPREQUESTOPTIONS_USINGPROTOCOL_002
* @tc.name testTelephonyHttpRequestOptionsUsingProtocol002
* @tc.desc Test Test HttpRequestOptions property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpRequestOptionsUsingProtocol002", 0, async function (done) {
var casename = 'Telephony_Http_HttpRequestOptions_usingProtocol_0100';
console.log("-----------------------HttpRequestOptions_usingProtocol Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.GET,
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000,
usingProtocol: http.HttpProtocol.HTTP1_1
}
var httpRequest = http.createHttp();
httpRequest.request("https://app.4399.cn/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestOptions_usingProtocol Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
console.log("testTelephonyHttpRequestOptionsUsingProtocol002 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTPREQUESTOPTIONS_USINGPROTOCOL_003
* @tc.name testTelephonyHttpRequestOptionsUsingProtocol003
* @tc.desc Test Test HttpRequestOptions property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpRequestOptionsUsingProtocol003", 0, async function (done) {
var casename = 'Telephony_Http_HttpRequestOptions_usingProtocol_0300';
console.log("-----------------------HttpRequestOptions_usingProtocol Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.GET,
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000,
usingProtocol: http.HttpProtocol.HTTP2,
extraData: {
'next': ''
}
}
var httpRequest = http.createHttp();
httpRequest.request("https://www.zhihu.com/signin", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestOptions_usingProtocol Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
console.log("testTelephonyHttpRequestOptionsUsingProtocol003 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTPREQUESTOPTIONS_READTIOMEOUT_001
* @tc.name testTelephonyHttpRequestOptionsReadTimeout001
* @tc.desc Test Test HttpRequestOptions property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpRequestOptionsReadTimeout001", 0, async function (done) {
var casename = 'testTelephonyHttpRequestOptionsReadTimeout001';
console.log("-----------------------testTelephonyHttpRequestOptionsReadTimeout001 Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.GET,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 0.1,
connectTimeout: 60
}
var httpRequest = http.createHttp();
httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => {
console.log(casename + ' error:' + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(err.code == 2300028).assertTrue();
expect(err.message == 'Timeout was reached').assertTrue();
httpRequest.destroy();
console.log("-----------------------testTelephonyHttpRequestOptionsReadTimeout001 Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
console.log("testTelephonyHttpRequestOptionsReadTimeout001 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTPREQUESTOPTIONS_READTIOMEOUT_002
* @tc.name testTelephonyHttpRequestOptionsReadTimeout002
* @tc.desc Test Test HttpRequestOptions property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpRequestOptionsReadTimeout002", 0, async function (done) {
var casename = 'testTelephonyHttpRequestOptionsReadTimeout002';
console.log("-----------------------HttpRequestOptions_readTimeout_02 Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.GET,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 0.1,
connectTimeout: 60
}
var httpRequest = http.createHttp();
httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => {
console.log(casename + JSON.stringify(data));
console.log("-----------------------HttpRequestOptions_readTimeout_02 Test end-----------------------");
expect().assertFail();
httpRequest.destroy();
done();
}).catch(error => {
console.info(casename+"errocode" + JSON.stringify(error));
expect(error.code == 2300028).assertTrue();
expect(error.message == 'Timeout was reached').assertTrue();
done();
});
} catch (error) {
console.log("testTelephonyHttpRequestOptionsReadTimeout002 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTPREQUESTOPTIONS_CONNECTTIMEOUT_001
* @tc.name testTelephonyHttpRequestOptionsConnectTimeout001
* @tc.desc Test Test HttpRequestOptions property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpRequestOptionsConnectTimeout001", 0, async function (done) {
var casename = 'Telephony_Http_HttpRequestOptions_0500';
console.log("-----------------------HttpRequestOptions_connectTimeout Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.GET,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60,
connectTimeout: 0.1
}
var httpRequest = http.createHttp();
httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(err.code == 2300028).assertTrue();
expect(err.message == 'Timeout was reached').assertTrue();
console.log("-----------------------HttpRequestOptions_connectTimeout Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
console.log("testTelephonyHttpRequestOptionsConnectTimeout001 : error = " + error);
//expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTPREQUESTOPTIONS_CONNECTTIMEOUT_002
* @tc.name testTelephonyHttpRequestOptionsConnectTimeout002
* @tc.desc Test Test HttpRequestOptions property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpRequestOptionsConnectTimeout002", 0, async function (done) {
var casename = 'Telephony_Http_HttpRequestOptions_0600';
console.log("-----------------------HttpRequestOptions_connectTimeout_01 Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.GET,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60,
connectTimeout: 0.1
}
var httpRequest = http.createHttp();
httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => {
console.log(casename + JSON.stringify(data));
console.log("-----------------------HttpRequestOptions_connectTimeout_01 Test end-----------------------");
expect().assertFail();
httpRequest.destroy();
done();
}).catch(error => {
console.info(casename+"errocode" + JSON.stringify(error));
expect(error.code == 2300028).assertTrue();
expect(error.message == 'Timeout was reached').assertTrue();
done();
});
} catch (error) {
console.log("testTelephonyHttpRequestOptionsConnectTimeout002 : error = " + error);
done();
}
});
})
};
/*
* Copyright (C) 2023 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,it, expect} from '@ohos/hypium';
import http from '@ohos.net.http';
export default function httpResponseJsunit() {
describe("HttpResponseCacheJsunitTest", function () {
/**
*@tc.number : TEST_TELEPHONYHTTPRESPONSECACHESIZE_001
*@tc.name : testTelephonyHttpResponseCacheSize001
*@tc.desc : Test HttpResponseCache method: flush:callback.
*@tc.size : MediumTest
*@tc.type : Function
*@tc.level : Level 2
*/
it("testTelephonyHttpResponseCacheSize001", 0, async function (done) {
console.log("-----------------------HttpResponse result Test is starting-----------------------");
var caseName = 'telephonyHttpResponseCacheSize_0001';
try {
console.log("-----------------------HttpRequestOptions_method_01 Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.GET,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000,
usingCache: true
}
var httpRequest = http.createHttp();
httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => {
console.log(caseName + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
const httpResponseCache = http.createHttpResponseCache(1*1024*1024);
httpResponseCache.flush(err => {
try {
if (err) {
console.info(caseName + ' flush fail: ' + err);
expect().assertFail();
} else {
expect(true).assertTrue();
}
done();
} catch (err) {
console.info(caseName + ' meet error: ' + err);
done();
}
});
}).catch(error => {
console.info(caseName + "errocode" + JSON.stringify(error));
expect(false).assertTrue();
done();
});
} catch (error) {
console.log(caseName + " : error = " + error);
expect(false).assertTrue();
done();
}
} catch (error) {
console.log(caseName + " : error = " + error);
expect().assertFail();
done();
}
httpRequest.destroy();
});
/**
*@tc.number : TEST_TELEPHONYHTTPRESPONSECACHESIZE_002
*@tc.name : testTelephonyHttpResponseCacheSize002
*@tc.desc : Test HttpResponseCache method: flush:callback.
*@tc.size : MediumTest
*@tc.type : Function
*@tc.level : Level 2
*/
it("testTelephonyHttpResponseCacheSize002", 0, async function (done) {
console.log("-----------------------HttpResponse result Test is starting-----------------------");
var caseName = 'telephonyHttpResponseCacheSize_0002';
try {
console.log("-----------------------HttpRequestOptions_method_01 Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.GET,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000,
usingCache: true
}
var httpRequest = http.createHttp();
httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => {
console.log(caseName + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
const httpResponseCache = http.createHttpResponseCache(5*1024*1024);
httpResponseCache.flush(err => {
try {
if (err) {
console.info(caseName + ' flush fail: ' + err);
expect().assertFail();
} else {
expect(true).assertTrue();
}
done();
} catch (err) {
console.info(caseName + ' meet error: ' + err);
done();
}
});
}).catch(error => {
console.info(caseName + "errocode" + JSON.stringify(error));
expect(false).assertTrue();
done();
});
} catch (error) {
console.log(caseName + " : error = " + error);
expect(false).assertTrue();
done();
}
} catch (error) {
console.log(caseName + " : error = " + error);
expect().assertFail();
done();
}
httpRequest.destroy();
});
/**
*@tc.number : TEST_TELEPHONYHTTPRESPONSECACHESIZE_003
*@tc.name : testTelephonyHttpResponseCacheSize003
*@tc.desc : Test HttpResponseCache method: flush:callback.
*@tc.size : MediumTest
*@tc.type : Function
*@tc.level : Level 2
*/
it("testTelephonyHttpResponseCacheSize003", 0, async function (done) {
console.log("-----------------------HttpResponse result Test is starting-----------------------");
var caseName = 'telephonyHttpResponseCacheSize_0003';
try {
console.log("-----------------------HttpRequestOptions_method_01 Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.GET,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000,
usingCache: true
}
var httpRequest = http.createHttp();
httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => {
console.log(caseName + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
const httpResponseCache = http.createHttpResponseCache(10*1024*1024);
httpResponseCache.flush(err => {
try {
if (err) {
console.info(caseName + ' flush fail: ' + err);
expect().assertFail();
} else {
expect(true).assertTrue();
}
done();
} catch (err) {
console.info(caseName + ' meet error: ' + err);
done();
}
});
}).catch(error => {
console.info(caseName + "errocode" + JSON.stringify(error));
expect(false).assertTrue();
done();
});
} catch (error) {
console.log(caseName + " : error = " + error);
expect(false).assertTrue();
done();
}
} catch (error) {
console.log(caseName + " : error = " + error);
expect().assertFail();
done();
}
httpRequest.destroy();
});
/**
*@tc.number : TEST_TELEPHONY_HTTPRESPONSECACHEFLUSH_001
*@tc.name : testTelephonyHttpResponseCacheFlush001
*@tc.desc : Test HttpResponseCache method: flush:callback.
*@tc.size : MediumTest
*@tc.type : Function
*@tc.level : Level 2
*/
it("testTelephonyHttpResponseCacheFlush001", 0, async function (done) {
console.log("-----------------------HttpResponse result Test is starting-----------------------");
var caseName = 'telephonyHttpResponseCacheFlush_0001';
try {
console.log("-----------------------HttpRequestOptions_method_01 Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.GET,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000,
usingCache: true
}
var httpRequest = http.createHttp();
httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => {
console.log(caseName + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
const httpResponseCache = http.createHttpResponseCache();
httpResponseCache.flush(err => {
try {
if (err) {
console.info(caseName + ' flush fail: ' + err);
expect().assertFail();
} else {
expect(true).assertTrue();
}
done();
} catch (err) {
console.info(caseName + ' meet error: ' + err);
done();
}
});
}).catch(error => {
console.info(caseName + "errocode" + JSON.stringify(error));
expect(false).assertTrue();
done();
});
} catch (error) {
console.log(caseName + " : error = " + error);
expect(false).assertTrue();
done();
}
} catch (error) {
console.log(caseName + " : error = " + error);
expect().assertFail();
done();
}
httpRequest.destroy();
});
/**
*@tc.number : TEST_TELEPHONY_HTTPRESPONSECACHEFLUSH_002
*@tc.name : testTelephonyHttpResponseCacheFlush002
*@tc.desc : Test HttpResponseCache method: flush:callback.
*@tc.size : MediumTest
*@tc.type : Function
*@tc.level : Level 2
*/
it("testTelephonyHttpResponseCacheFlush002", 0, async function (done) {
console.log("-----------------------HttpResponse result Test is starting-----------------------");
var caseName = 'telephonyHttpResponseCacheFlush_0001';
try {
console.log("-----------------------HttpRequestOptions_method_01 Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.GET,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000,
usingCache: true
}
var httpRequest = http.createHttp();
httpRequest.request("https://app.4399.cn/", httpRequestOptions).then(data => {
console.log(caseName + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
const httpResponseCache = http.createHttpResponseCache();
httpResponseCache.flush(err => {
try {
if (err) {
console.info(caseName + ' flush fail: ' + err);
expect().assertFail();
} else {
expect(true).assertTrue();
}
done();
} catch (err) {
console.info(caseName + ' meet error: ' + err);
done();
}
});
}).catch(error => {
console.info(caseName + "errocode" + JSON.stringify(error));
expect(false).assertTrue();
done();
});
} catch (error) {
console.log(caseName + " : error = " + error);
expect(false).assertTrue();
done();
}
} catch (error) {
console.log(caseName + " : error = " + error);
expect().assertFail();
done();
}
httpRequest.destroy();
});
/**
*@tc.number : TEST_TELEPHONY_HTTP_RESPONSE_CACHE_FLUSH_003
*@tc.name : testTelephonyHttpResponseCacheFlush_003
*@tc.desc : Test HttpResponseCache method: flush:promise.
*@tc.size : MediumTest
*@tc.type : Function
*@tc.level : Level 2
*/
it("testTelephonyHttpResponseCacheFlush_003", 0, async function (done) {
console.log("-----------------------HttpResponse result Test is starting-----------------------");
var caseName = 'telephonyHttpResponseCacheFlush_0002';
try {
console.log("-----------------------HttpRequestOptions_method_01 Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.GET,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000,
usingCache: true
}
var httpRequest = http.createHttp();
httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => {
console.log(caseName + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
const httpResponseCache = http.createHttpResponseCache();
httpResponseCache.flush().then(() => {
expect(true).assertTrue();
done();
}).catch(err => {
console.info(caseName + "err: " + JSON.stringify(err));
expect().assertFail();
done();
});
}).catch(error => {
console.info(caseName + "errocode" + JSON.stringify(error));
expect(false).assertTrue();
done();
});
} catch (error) {
console.log("Telephony_http_HttpRequestOptions_method_0200 : error = " + error);
expect(false).assertTrue();
done();
}
} catch (error) {
console.log(caseName + " : error = " + error);
expect().assertFail();
done();
}
httpRequest.destroy();
});
/**
*@tc.number : TEST_TELEPHONY_HTTP_RESPONSE_CACHE_FLUSH_004
*@tc.name : testTelephonyHttpResponseCacheFlush_004
*@tc.desc : Test HttpResponseCache method: flush:promise.
*@tc.size : MediumTest
*@tc.type : Function
*@tc.level : Level 2
*/
it("testTelephonyHttpResponseCacheFlush_004", 0, async function (done) {
console.log("-----------------------HttpResponse result Test is starting-----------------------");
var caseName = 'telephonyHttpResponseCacheFlush_0002';
try {
console.log("-----------------------HttpRequestOptions_method_01 Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.GET,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000,
usingCache: true
}
var httpRequest = http.createHttp();
httpRequest.request("https://app.4399.cn/", httpRequestOptions).then(data => {
console.log(caseName + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
const httpResponseCache = http.createHttpResponseCache();
httpResponseCache.flush().then(() => {
expect(true).assertTrue();
done();
}).catch(err => {
console.info(caseName + "err: " + JSON.stringify(err));
expect().assertFail();
done();
});
}).catch(error => {
console.info(caseName + "errocode" + JSON.stringify(error));
expect(false).assertTrue();
done();
});
} catch (error) {
console.log("Telephony_http_HttpRequestOptions_method_0200 : error = " + error);
expect(false).assertTrue();
done();
}
} catch (error) {
console.log(caseName + " : error = " + error);
expect().assertFail();
done();
}
httpRequest.destroy();
});
/**
*@tc.number : TELEPHONY_HTTP_RESPONSE_CACHE_DELETE_001
*@tc.name : testTelephonyHttpResponseCacheDelete001
*@tc.desc : Test HttpResponseCache method: delete:callback.
*@tc.size : MediumTest
*@tc.type : Function
*@tc.level : Level 2
*/
it("testTelephonyHttpResponseCacheDelete001", 0, async function (done) {
console.log("-----------------------HttpResponse result Test is starting-----------------------");
var caseName = 'testTelephonyHttpResponseCacheDelete001';
try {
console.log("-----------------------HttpRequestOptions_method_01 Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.GET,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000,
usingCache: true
}
var httpRequest = http.createHttp();
httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => {
console.log(caseName + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
const httpResponseCache = http.createHttpResponseCache();
httpResponseCache.delete(err => {
try {
if (err) {
console.info(caseName + ' delete fail: ' + err);
expect().assertFail();
} else {
expect(true).assertTrue();
}
done();
} catch (err) {
console.info(caseName + ' meet error: ' + err);
done();
}
});
}).catch(error => {
console.info(caseName + "errocode" + JSON.stringify(error));
expect(false).assertTrue();
done();
});
} catch (error) {
console.log("testTelephonyHttpResponseCacheDelete001 : error = " + error);
expect(false).assertTrue();
done();
}
} catch (error) {
console.log(caseName + " : error = " + error);
expect().assertFail();
done();
}
httpRequest.destroy();
});
/**
*@tc.number : TELEPHONY_HTTP_RESPONSE_CACHE_DELETE_002
*@tc.name : testTelephonyHttpResponseCacheDelete002
*@tc.desc : Test HttpResponseCache method: delete:promise.
*@tc.size : MediumTest
*@tc.type : Function
*@tc.level : Level 2
*/
it("testTelephonyHttpResponseCacheDelete002", 0, async function (done) {
console.log("-----------------------HttpResponse result Test is starting-----------------------");
var caseName = 'testTelephonyHttpResponseCacheDelete002';
try {
console.log("-----------------------telephonyHttpResponseCacheDelete_0002 Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.GET,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000,
usingCache: true
}
var httpRequest = http.createHttp();
httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => {
console.log(caseName + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
const httpResponseCache = http.createHttpResponseCache();
httpResponseCache.delete().then(() => {
expect(true).assertTrue();
done();
}).catch(err => {
console.info(caseName + "err: " + JSON.stringify(err));
expect().assertFail();
done();
});
}).catch(error => {
console.info(caseName + "errocode" + JSON.stringify(error));
expect(false).assertTrue();
done();
});
} catch (error) {
console.log("telephonyHttpResponseCacheDelete_0001 : error = " + error);
expect(false).assertTrue();
done();
}
} catch (error) {
console.log(caseName + " : error = " + error);
expect().assertFail();
done();
}
httpRequest.destroy();
});
})
};
/*
* Copyright (C) 2023 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,it, expect} from '@ohos/hypium';
import http from '@ohos.net.http';
export default function httpResponseJsunit() {
describe("HttpResponseJsunitTest", function () {
/**
* @tc.number TEST_TELEPHONY_HTTPRESPONSE_RESULT_001
* @tc.name testTelephonyHttpResponseResult001
* @tc.desc Test Test HttpResponse property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpResponseResult001", 0, async function (done) {
var casename = 'Telephony_Http_HttpResponse_0100';
console.log("-----------------------HttpResponse result Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.GET,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000
}
var httpRequest = http.createHttp();
httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.result != null).assertTrue();
console.log("-----------------------HttpResponse result Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
console.log("testTelephonyHttpResponseResult001 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTPRESPONSE_RESULT_002
* @tc.name testTelephonyHttpResponseResult002
* @tc.desc Test Test HttpResponse property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpResponseResult002", 0, async function (done) {
var casename = 'Telephony_Http_HttpResponse_0100';
console.log("-----------------------HttpResponse result_01 Test is starting-----------------------");
try {
var httpRequest = http.createHttp();
httpRequest.request("https://www.baidu.com/", (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.result != null).assertTrue();
console.log("-----------------------HttpResponse result_01 Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
console.log("testTelephonyHttpResponseResult002 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTPRESPONSE_RESULT_003
* @tc.name testTelephonyHttpResponseResult003
* @tc.desc Test Test HttpResponse property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpResponseResult003", 0, async function (done) {
var casename = 'Telephony_Http_HttpResponse_0100';
console.log("-----------------------HttpResponse result_02 Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.GET,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000
}
var httpRequest = http.createHttp();
httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => {
console.log(casename + JSON.stringify(data));
expect(data.result != null).assertTrue();
console.log("-----------------------HttpResponse result_02 Test end-----------------------");
httpRequest.destroy();
done();
}).catch(error => {
console.info(casename+"errocode" + JSON.stringify(error));
expect(false).assertTrue();
done();
});
} catch (error) {
console.log("testTelephonyHttpResponseResult003 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTPRESPONSE_RESULT_004
* @tc.name testTelephonyHttpResponseResult004
* @tc.desc Test Test HttpResponse property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpResponseResult004", 0, async function (done) {
var casename = 'Telephony_Http_HttpResponse_0100';
console.log("-----------------------HttpResponse result Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.GET,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000
}
var httpRequest = http.createHttp();
httpRequest.request("https://app.4399.cn/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.result != null).assertTrue();
console.log("-----------------------HttpResponse result Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
console.log("testTelephonyHttpResponseResult004 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTPRESPONSE_RESULTTYPE_001
* @tc.name testTelephonyHttpResponseResultType001
* @tc.desc Test Test HttpResponse property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpResponseResultType001", 0, async function (done) {
var casename = 'Telephony_Http_HttpResponse_0100';
console.log("-----------------------HttpResponse result Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.GET,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000,
expectDataType: http.HttpDataType.STRING
}
var httpRequest = http.createHttp();
httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.resultType == http.HttpDataType.STRING).assertTrue();
console.log("-----------------------HttpResponse result Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
console.log("testTelephonyHttpResponseResultType001 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTPRESPONSE_RESULTTYPE_002
* @tc.name testTelephonyHttpResponseResultType002
* @tc.desc Test Test HttpResponse property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpResponseResultType002", 0, async function (done) {
var casename = 'Telephony_Http_HttpResponse_0100';
console.log("-----------------------HttpResponse result Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.GET,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000,
expectDataType: http.HttpDataType.OBJECT
}
var httpRequest = http.createHttp();
httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.resultType == http.HttpDataType.OBJECT).assertTrue();
console.log("-----------------------HttpResponse result Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
console.log("testTelephonyHttpResponseResultType002 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTPRESPONSE_RESULTTYPE_003
* @tc.name testTelephonyHttpResponseResultType003
* @tc.desc Test Test HttpResponse property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpResponseResultType003", 0, async function (done) {
var casename = 'Telephony_Http_HttpResponse_0100';
console.log("-----------------------HttpResponse result Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.GET,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000,
expectDataType: http.HttpDataType.ARRAY_BUFFER
}
var httpRequest = http.createHttp();
httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.resultType == http.HttpDataType.ARRAY_BUFFER).assertTrue();
console.log("-----------------------HttpResponse result Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
console.log("testTelephonyHttpResponseResultType003 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTPRESPONSE_RESPONSECODE_001
* @tc.name testTelephonyHttpResponseResponseCode001
* @tc.desc Test Test HttpResponse property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpResponseResponseCode001", 0, async function (done) {
var casename = 'Telephony_Http_HttpResponse_0200';
console.log("-----------------------HttpResponse responseCode Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.GET,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000
}
var httpRequest = http.createHttp();
httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode != 0).assertTrue();
console.log("-----------------------HttpResponse responseCode Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
console.log("testTelephonyHttpResponseResponseCode001 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTPRESPONSE_RESPONSECODE_002
* @tc.name testTelephonyHttpResponseResponseCode002
* @tc.desc Test Test HttpResponse property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpResponseResponseCode002", 0, async function (done) {
var casename = 'Telephony_Http_HttpResponse_0200';
console.log("-----------------------HttpResponse responseCode_01 Test is starting-----------------------");
try {
var httpRequest = http.createHttp();
httpRequest.request("https://www.baidu.com/", (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode != 0).assertTrue();
console.log("-----------------------HttpResponse responseCode_01 Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
console.log("testTelephonyHttpResponseResponseCode002 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTPRESPONSE_RESPONSECODE_003
* @tc.name testTelephonyHttpResponseResponseCode003
* @tc.desc Test Test HttpResponse property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpResponseResponseCode003", 0, async function (done) {
var casename = 'Telephony_Http_HttpResponse_0200';
console.log("-----------------------HttpResponse responseCode_02 Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.GET,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000
}
var httpRequest = http.createHttp();
httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => {
console.log(casename + JSON.stringify(data));
expect(data.responseCode != 0).assertTrue();
console.log("-----------------------HttpResponse responseCode_02 Test end-----------------------");
httpRequest.destroy();
done();
}).catch(error => {
console.info(casename+"errocode" + JSON.stringify(error));
expect(false).assertTrue();
done();
});
} catch (error) {
console.log("testTelephonyHttpResponseResponseCode003 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTPRESPONSE_RESPONSECODE_004
* @tc.name testTelephonyHttpResponseResponseCode004
* @tc.desc Test Test HttpResponse property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpResponseResponseCode004", 0, async function (done) {
var casename = 'Telephony_Http_HttpResponse_0200';
console.log("-----------------------HttpResponse responseCode Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.GET,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000
}
var httpRequest = http.createHttp();
httpRequest.request("https://app.4399.cn/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode != 0).assertTrue();
console.log("-----------------------HttpResponse responseCode Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
console.log("testTelephonyHttpResponseResponseCode004 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTPRESPONSE_HEADER_001
* @tc.name testTelephonyHttpResponseHeader001
* @tc.desc Test Test HttpResponse property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpResponseHeader001", 0, async function (done) {
var casename = 'Telephony_Http_HttpResponse_0300';
console.log("-----------------------HttpResponse header Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.GET,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000
}
var httpRequest = http.createHttp();
httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.header != null).assertTrue();
console.log("-----------------------header result Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
console.log("testTelephonyHttpResponseHeader001 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTPRESPONSE_HEADER_002
* @tc.name testTelephonyHttpResponseHeader002
* @tc.desc Test Test HttpResponse property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpResponseHeader002", 0, async function (done) {
var casename = 'Telephony_Http_HttpResponse_0300';
console.log("-----------------------HttpResponse header_01 Test is starting-----------------------");
try {
var httpRequest = http.createHttp();
httpRequest.request("https://www.baidu.com/", (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.header != null).assertTrue();
console.log("-----------------------header header_01 Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
console.log("testTelephonyHttpResponseHeader002 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTPRESPONSE_HEADER_003
* @tc.name testTelephonyHttpResponseHeader003
* @tc.desc Test Test HttpResponse property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpResponseHeader003", 0, async function (done) {
var casename = 'Telephony_Http_HttpResponse_0300';
console.log("-----------------------HttpResponse header_02 Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.GET,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000
}
var httpRequest = http.createHttp();
httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => {
console.log(casename + JSON.stringify(data));
expect(data.header != null).assertTrue();
console.log("-----------------------HttpResponse header_02 Test end-----------------------");
httpRequest.destroy();
done();
}).catch(error => {
console.info(casename+"errocode" + JSON.stringify(error));
done();
});
} catch (error) {
console.log("testTelephonyHttpResponseHeader003 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTPRESPONSE_HEADER_004
* @tc.name testTelephonyHttpResponseHeader004
* @tc.desc Test Test HttpResponse property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpResponseHeader004", 0, async function (done) {
var casename = 'Telephony_Http_HttpResponse_0300';
console.log("-----------------------HttpResponse header Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.GET,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000
}
var httpRequest = http.createHttp();
httpRequest.request("https://app.4399.cn/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.header != null).assertTrue();
console.log("-----------------------header result Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
console.log("testTelephonyHttpResponseHeader001 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTPRESPONSE_Cookies_001
* @tc.name testTelephonyHttpResponseCookies001
* @tc.desc Test Test HttpResponse property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpResponseCookies001", 0, async function (done) {
var casename = 'Telephony_Http_HttpResponse_0400';
console.log("-----------------------HttpResponse cookies Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.GET,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000
}
var httpRequest = http.createHttp();
httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.cookies != null).assertTrue();
console.log("-----------------------HttpResponse cookies Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
console.log("testTelephonyHttpResponseCookies001 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTPRESPONSE_Cookies_002
* @tc.name testTelephonyHttpResponseCookies002
* @tc.desc Test Test HttpResponse property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpResponseCookies002", 0, async function (done) {
var casename = 'Telephony_Http_HttpResponse_0400';
console.log("-----------------------HttpResponse cookies_01 Test is starting-----------------------");
try {
var httpRequest = http.createHttp();
httpRequest.request("https://www.baidu.com/", (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.cookies != null).assertTrue();
console.log("-----------------------HttpResponse cookies_01 Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
console.log("testTelephonyHttpResponseCookies002 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTPRESPONSE_Cookies_003
* @tc.name testTelephonyHttpResponseCookies003
* @tc.desc Test Test HttpResponse property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpResponseCookies003", 0, async function (done) {
var casename = 'Telephony_Http_HttpResponse_0400';
console.log("-----------------------HttpResponse cookies_02 Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.GET,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000
}
var httpRequest = http.createHttp();
httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => {
console.log(casename + JSON.stringify(data));
expect(data.cookies != null).assertTrue();
console.log("-----------------------HttpResponse cookies_02 Test end-----------------------");
httpRequest.destroy();
done();
}).catch(error => {
console.info(casename+"errocode" + JSON.stringify(error));
done();
});
} catch (error) {
console.log("testTelephonyHttpResponseCookies003 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTPRESPONSE_Cookies_004
* @tc.name testTelephonyHttpResponseCookies004
* @tc.desc Test Test HttpResponse property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpResponseCookies004", 0, async function (done) {
var casename = 'Telephony_Http_HttpResponse_0400';
console.log("-----------------------HttpResponse cookies Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.GET,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000
}
var httpRequest = http.createHttp();
httpRequest.request("https://app.4399.cn/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.cookies != null).assertTrue();
console.log("-----------------------HttpResponse cookies Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
console.log("testTelephonyHttpResponseCookies001 : error = " + error);
expect(false).assertTrue();
done();
}
});
})
};
/**
* Copyright (c) 2023 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 HttpResponseCacheJsunit from './HttpResponseCacheJsunit.test';
import responseCodeJsunit from './ResponseCodeJsunit.test';
import requestMethodJsunit from './RequestMethodJsunit.test';
import httpResponseJsunit from './HttpResponseJsunit.test';
import HttpRequestOptionsJsunit from './HttpRequestOptionsJsunit.test';
import httpRequestJsunit from './HttpRequestJsunit.test';
export default function testsuite() {
HttpResponseCacheJsunit();
responseCodeJsunit();
requestMethodJsunit();
httpResponseJsunit();
HttpRequestOptionsJsunit();
httpRequestJsunit();
}
\ No newline at end of file
/*
* Copyright (C) 2023 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, it, expect} from '@ohos/hypium';
import http from '@ohos.net.http';
export default function requestMethodJsunit() {
describe("requestMethodJsunit", function () {
/**
* @tc.number TEST_TELEPHONY_HTTPREQUESTMETHOD_OPTIONS_001
* @tc.name testTelephonyHttpRequestMethodOptions001
* @tc.desc Test Test HttpRequestMethod property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpRequestMethodOptions001", 0, async function (done) {
var casename = 'Telephony_http_HttpRequestMethod_0100';
console.log("-----------------------HttpRequestMethod_options Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.OPTIONS,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000
}
var httpRequest = http.createHttp();
httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestMethod_options Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
console.log("testTelephonyHttpRequestMethodOptions001 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTPREQUESTMETHOD_OPTIONS_002
* @tc.name testTelephonyHttpRequestMethodOptions002
* @tc.desc Test Test HttpRequestMethod property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpRequestMethodOptions002", 0, async function (done) {
var casename = 'Telephony_http_HttpRequestMethod_0100';
console.log("-----------------------HttpRequestMethod_options_01 Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.OPTIONS,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000
}
var httpRequest = http.createHttp();
httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => {
console.log(casename + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestMethod_options_01 Test end-----------------------");
httpRequest.destroy();
done();
}).catch(error => {
console.info(casename+"errocode" + JSON.stringify(error));
expect(false).assertTrue();
done();
});
} catch (error) {
console.log("testTelephonyHttpRequestMethodOptions002 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTPREQUESTMETHOD_OPTIONS_003
* @tc.name testTelephonyHttpRequestMethodOptions003
* @tc.desc Test Test HttpRequestMethod property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpRequestMethodOptions003", 0, async function (done) {
var casename = 'Telephony_http_HttpRequestMethod_0100';
console.log("-----------------------HttpRequestMethod_options Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.OPTIONS,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000
}
var httpRequest = http.createHttp();
httpRequest.request("https://app.4399.cn/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestMethod_options Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
console.log("testTelephonyHttpRequestMethodOptions001 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTPREQUESTMETHOD_GET_001
* @tc.name testTelephonyHttpRequestMethodGet001
* @tc.desc Test Test HttpRequestMethod property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpRequestMethodGet001", 0, async function (done) {
var casename = "Telephony_http_HttpRequestMethod_0200"
console.log("-----------------------HttpRequestMethod_GET Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.GET,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000
}
var httpRequest = http.createHttp();
httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestMethod_GET Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
console.log("testTelephonyHttpRequestMethodGet001 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTPREQUESTMETHOD_GET_002
* @tc.name testTelephonyHttpRequestMethodGet002
* @tc.desc Test Test HttpRequestMethod property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpRequestMethodGet002", 0, async function (done) {
var casename = "Telephony_http_HttpRequestMethod_0200"
console.log("-----------------------HttpRequestMethod_GET_01 Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.GET,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000
}
var httpRequest = http.createHttp();
httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => {
console.log(casename + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestMethod_GET_01 Test end-----------------------");
httpRequest.destroy();
done();
}).catch(error => {
console.info(casename+"errocode" + JSON.stringify(error));
done();
});
} catch (error) {
console.log("testTelephonyHttpRequestMethodGet002 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTPREQUESTMETHOD_GET_003
* @tc.name testTelephonyHttpRequestMethodGet003
* @tc.desc Test Test HttpRequestMethod property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpRequestMethodGet003", 0, async function (done) {
var casename = "Telephony_http_HttpRequestMethod_0200"
console.log("-----------------------HttpRequestMethod_GET Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.GET,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000
}
var httpRequest = http.createHttp();
httpRequest.request("https://app.4399.cn/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestMethod_GET Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
console.log("testTelephonyHttpRequestMethodGet001 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTPREQUESTMETHOD_POST_001
* @tc.name testTelephonyHttpRequestMethodPost001
* @tc.desc Test Test HttpRequestMethod property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpRequestMethodPost001", 0, async function (done) {
var casename = "Telephony_http_HttpRequestMethod_0300"
console.log("-----------------------HttpRequestMethod_POST Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.POST,
extraData: {
//tn=albumsdetail&word=渐变风格插画&fr=albumslist&album_tab=设计素材&album_id=409&rn=30
tn: "albumsdetail",
work: "渐变风格插画",
fr: "albumslist",
album_tab: "设计素材",
album_id: "409",
rn: "30"
},
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000
}
var httpRequest = http.createHttp();
httpRequest.request("https://image.baidu.com/search/albumsdetail/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestMethod_POST Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
console.log("testTelephonyHttpRequestMethodPost001 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTPREQUESTMETHOD_POST_002
* @tc.name testTelephonyHttpRequestMethodPost002
* @tc.desc Test Test HttpRequestMethod property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpRequestMethodPost002", 0, async function (done) {
var casename = "Telephony_http_HttpRequestMethod_0300"
console.log("-----------------------HttpRequestMethod_POST_01 Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.POST,
extraData: {
//tn=albumsdetail&word=渐变风格插画&fr=albumslist&album_tab=设计素材&album_id=409&rn=30
tn: "albumsdetail",
work: "渐变风格插画",
fr: "albumslist",
album_tab: "设计素材",
album_id: "409",
rn: "30"
},
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000
}
var httpRequest = http.createHttp();
httpRequest.request("https://image.baidu.com/search/albumsdetail/", httpRequestOptions).then(data => {
console.log(casename + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestMethod_POST_01 Test end-----------------------");
httpRequest.destroy();
done();
}).catch(error => {
console.info(casename+"errocode" + JSON.stringify(error));
expect(false).assertTrue();
done();
});
} catch (error) {
console.log("testTelephonyHttpRequestMethodPost002 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTPREQUESTMETHOD_TRACE_001
* @tc.name testTelephonyHttpRequestMenthodTrace001
* @tc.desc Test Test HttpRequestMethod property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpRequestMethodTrace001", 0, async function (done) {
var casename = "Telephony_http_HttpRequestMethod_0400"
console.log("-----------------------HttpRequestMethod_TRACE Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.TRACE,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000
}
var httpRequest = http.createHttp();
httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestMethod_TRACE Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
console.log("testTelephonyHttpRequestMethodTrace001 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTPREQUESTMETHOD_TRACE_002
* @tc.name testTelephonyHttpRequestMethodTrace002
* @tc.desc Test Test HttpRequestMethod property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpRequestMethodTrace002", 0, async function (done) {
var casename = "Telephony_http_HttpRequestMethod_0400"
console.log("-----------------------HttpRequestMethod_TRACE_01 Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.TRACE,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000
}
var httpRequest = http.createHttp();
httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => {
console.log(casename + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestMethod_TRACE_01 Test end-----------------------");
httpRequest.destroy();
done();
}).catch(error => {
console.info(casename+"errocode" + JSON.stringify(error));
expect(false).assertTrue();
done();
});
} catch (error) {
console.log("testTelephonyHttpRequestMethodTrace002 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTPREQUESTMETHOD_PUT_001
* @tc.name testTelephonyHttpRequestMethodPut001
* @tc.desc Test Test HttpRequestMethod property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpRequestMethodPut001", 0, async function (done) {
var casename = "Telephony_http_HttpRequestMethod_0500"
console.log("-----------------------HttpRequestMethod_PUT Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.PUT,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000
}
if (httpRequestOptions.method == http.RequestMethod.PUT) {
done();
return;
}
var httpRequest = http.createHttp();
httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestMethod_PUT Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
console.log("testTelephonyHttpRequestMethodPut001 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTPREQUESTMETHOD_PUT_002
* @tc.name testTelephonyHttpRequestMethodPut002
* @tc.desc Test Test HttpRequestMethod property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpRequestMethodPut002", 0, async function (done) {
var casename = "Telephony_http_HttpRequestMethod_0500"
console.log("-----------------------HttpRequestMethod_PUT_01 Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.PUT,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000
}
if (httpRequestOptions.method == http.RequestMethod.PUT) {
done();
return;
}
var httpRequest = http.createHttp();
httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => {
console.log(casename + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestMethod_PUT_01 Test end-----------------------");
httpRequest.destroy();
done();
}).catch(error => {
console.info(casename+"errocode" + JSON.stringify(error));
expect(false).assertTrue();
done();
});
} catch (error) {
console.log("testTelephonyHttpRequestMethodPut002 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTPREQUESTMETHOD_PUT_003
* @tc.name testTelephonyHttpRequestMethodPut003
* @tc.desc Test Test HttpRequestMethod property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpRequestMethodPut003", 0, async function (done) {
var casename = "Telephony_http_HttpRequestMethod_0500"
console.log("-----------------------HttpRequestMethod_PUT Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.PUT,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000
}
if (httpRequestOptions.method == http.RequestMethod.PUT) {
done();
return;
}
var httpRequest = http.createHttp();
httpRequest.request("https://app.4399.cn/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestMethod_PUT Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
console.log("testTelephonyHttpRequestMethodPut003 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTPREQUESTMETHOD_HEAD_001
* @tc.name testTelephonyHttpRequestMethodHead001
* @tc.desc Test Test HttpRequestMethod property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpRequestMethodHead001", 0, async function (done) {
var casename = 'Telephony_http_HttpRequestMethod_0600';
console.log("-----------------------HttpRequestMethod_head Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.HEAD,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000
}
var httpRequest = http.createHttp();
httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestMethod_head Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
console.log("testTelephonyHttpRequestMethodHead001 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTPREQUESTMETHOD_HEAD_002
* @tc.name testTelephonyHttpRequestMethodHead002
* @tc.desc Test Test HttpRequestMethod property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpRequestMethodHead002", 0, async function (done) {
var casename = "Telephony_http_HttpRequestMethod_0500"
console.log("-----------------------HttpRequestMethod_HEAD_01 Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.HEAD,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000
}
var httpRequest = http.createHttp();
httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => {
console.log(casename + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestMethod_HEAD_01 Test end-----------------------");
httpRequest.destroy();
done();
}).catch(error => {
console.info(casename+"errocode" + JSON.stringify(error));
expect(false).assertTrue();
done();
});
} catch (error) {
console.log("testTelephonyHttpRequestMethodHead002 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTPREQUESTMETHOD_HEAD_003
* @tc.name testTelephonyHttpRequestMethodHead003
* @tc.desc Test Test HttpRequestMethod property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpRequestMethodHead003", 0, async function (done) {
var casename = 'Telephony_http_HttpRequestMethod_0600';
console.log("-----------------------HttpRequestMethod_head Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.HEAD,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000
}
var httpRequest = http.createHttp();
httpRequest.request("https://app.4399.cn/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestMethod_head Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
console.log("testTelephonyHttpRequestMethodHead003 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTPREQUESTMETHOD_DELETE_001
* @tc.name testTelephonyHttpRequestMethodDelete001
* @tc.desc Test Test HttpRequestMethod property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpRequestMethodDelete001", 0, async function (done) {
var casename = 'Telephony_http_HttpRequestMethod_0600';
console.log("-----------------------HttpRequestMethod_DELETE Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.DELETE,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000
}
var httpRequest = http.createHttp();
httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestMethod_DELETE Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
console.log("testTelephonyHttpRequestMethodDelete001 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTPREQUESTMETHOD_DELETE_002
* @tc.name testTelephonyHttpRequestMethodDelete002
* @tc.desc Test Test HttpRequestMethod property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpRequestMethodDelete002", 0, async function (done) {
var casename = "Telephony_http_HttpRequestMethod_0500"
console.log("-----------------------HttpRequestMethod_DELETE_01 Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.DELETE,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000
}
var httpRequest = http.createHttp();
httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => {
console.log(casename + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestMethod_DELETE_01 Test end-----------------------");
httpRequest.destroy();
done();
}).catch(error => {
console.info(casename+"errocode" + JSON.stringify(error));
expect(false).assertTrue();
done();
});
} catch (error) {
console.log("testTelephonyHttpRequestMethodDelete002 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTPREQUESTMETHOD_DELETE_003
* @tc.name testTelephonyHttpRequestMethodDelete003
* @tc.desc Test Test HttpRequestMethod property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpRequestMethodDelete003", 0, async function (done) {
var casename = 'Telephony_http_HttpRequestMethod_0600';
console.log("-----------------------HttpRequestMethod_DELETE Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.DELETE,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000
}
var httpRequest = http.createHttp();
httpRequest.request("https://app.4399.cn/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestMethod_DELETE Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
console.log("testTelephonyHttpRequestMethodDelete003 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTPREQUESTMETHOD_CONNECT_001
* @tc.name testTelephonyHttpRequestMethodConnect001
* @tc.desc Test Test HttpRequestMethod property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpRequestMethodConnect001", 0, async function (done) {
var casename = 'Telephony_http_HttpRequestMethod_0600';
console.log("-----------------------HttpRequestMethod_CONNECT Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.CONNECT,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000
}
var httpRequest = http.createHttp();
httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestMethod_CONNECT Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
console.log("testTelephonyHttpRequestMethodConnect001 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTPREQUESTMETHOD_CONNECT_002
* @tc.name testTelephonyHttpRequestMethodConnect002
* @tc.desc Test Test HttpRequestMethod property.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testTelephonyHttpRequestMethodConnect002", 0, async function (done) {
var casename = "Telephony_http_HttpRequestMethod_0500"
console.log("-----------------------HttpRequestMethod_CONNECT_01 Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.CONNECT,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000
}
var httpRequest = http.createHttp();
httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => {
console.log(casename + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestMethod_CONNECT_01 Test end-----------------------");
httpRequest.destroy();
done();
}).catch(error => {
console.info(casename+"errocode" + JSON.stringify(error));
expect(false).assertTrue();
done();
});
} catch (error) {
console.log("testTelephonyHttpRequestMethodConnect002 : error = " + error);
expect(false).assertTrue();
done();
}
});
})
};
/*
* Copyright (C) 2023 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,it, expect} from '@ohos/hypium';
import http from '@ohos.net.http';
export default function responseCodeJsunit() {
describe("responseCodeJsunitTest", function () {
/**
* @tc.number TEST_TELEPHONY_HTTP_RESPONSECODE_OK_001
* @tc.name testTelephonyHttpResponseCodeOK001
* @tc.desc Test ResponseCode property.
* @tc.size: MediumTest
* @tc.type: Enum
* @tc.level: level 0
*/
it("testTelephonyHttpResponseCodeOK001", 0, async function (done) {
console.log("-----------------------Telephony_Http_ResponseCode_OK_0100 start-----------------------");
try {
expect(200).assertEqual(http.ResponseCode.OK);
console.log("-----------------------Telephony_Http_ResponseCode_OK_0100 OK assertEqual SUCCESS-----------------------");
} catch (error) {
console.log("Telephony_Http_ResponseCode_OK_0100 : error = " + error);
}
done();
console.log("-----------------------Telephony_Http_ResponseCode_OK_0100 end-----------------------");
});
/**
* @tc.number TEST_TELEPHONY_HTTP_RESPONSECODE_ACCEPTED_001
* @tc.name testTelephonyHttpResponseCodeAccepted001
* @tc.desc Test Test ResponseCode property.
*/
it("testTelephonyHttpResponseCodeAccepted001", 0, async function (done) {
console.log("-----------------------ResponseCode_ACCEPTED Test is starting-----------------------");
try {
expect(202).assertEqual(http.ResponseCode.ACCEPTED);
console.log("-----------------------ResponseCode ACCEPTED Test end-----------------------");
done();
} catch (error) {
console.log("testTelephonyHttpResponseCodeAccepted001 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTP_RESPONSECODE_NOT_AUTHORITATIVE_001
* @tc.name testTelephonyHttpResponseCodeNotAuthoritative001
* @tc.desc Test Test ResponseCode property.
* @tc.size: MediumTest
* @tc.type: Enum
* @tc.level: level 0
*/
it("testTelephonyHttpResponseCodeNotAuthoritative001", 0, async function (done) {
console.log("-----------------------ResponseCode NOT_AUTHORITATIVE Test is starting-----------------------");
try {
expect(203).assertEqual(http.ResponseCode.NOT_AUTHORITATIVE);
console.log("-----------------------ResponseCode NOT_AUTHORITATIVE Test end-----------------------");
done();
} catch (error) {
console.log("testTelephonyHttpResponseCodeNotAuthoritative001 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTP_RESPONSECODE_NO_CONNECT_001
* @tc.name testTelephonyHttpResponseCodeNoConnect001
* @tc.desc Test Test ResponseCode property.
* @tc.size: MediumTest
* @tc.type: Enum
* @tc.level: level 0
*/
it("testTelephonyHttpResponseCodeNoConnect001", 0, async function (done) {
console.log("-----------------------ResponseCode NO_CONTENT Test is starting-----------------------");
try {
expect(204).assertEqual(http.ResponseCode.NO_CONTENT);
console.log("-----------------------ResponseCode NO_CONTENT Test end-----------------------");
done();
} catch (error) {
console.log("testTelephonyHttpResponseCodeNotConnect001 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTP_RESPONSECODE_MULT_CHOICE_001
* @tc.name testTelephonyHttpResponseCodeMultChoice001
* @tc.desc Test Test ResponseCode property.
* @tc.size: MediumTest
* @tc.type: Enum
* @tc.level: level 0
*/
it("testTelephonyHttpResponseCodeMultChoice001", 0, async function (done) {
console.log("-----------------------ResponseCode MULT_CHOICE Test is starting-----------------------");
try {
expect(300).assertEqual(http.ResponseCode.MULT_CHOICE);
console.log("-----------------------ResponseCode MULT_CHOICE Test end-----------------------");
done();
} catch (error) {
console.log("testTelephonyHttpResponseCodeMultChoice001 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTP_RESPONSECODE_MOVED_PERM_001
* @tc.name testTelephonyHttpResponseCodeMovedPerm001
* @tc.desc Test Test ResponseCode property.
* @tc.size: MediumTest
* @tc.type: Enum
* @tc.level: level 0
*/
it("testTelephonyHttpResponseCodeMovedPerm001", 0, async function (done) {
console.log("-----------------------ResponseCode MOVED_PERM Test is starting-----------------------");
try {
expect(301).assertEqual(http.ResponseCode.MOVED_PERM);
console.log("-----------------------ResponseCode MOVED_PERM Test end-----------------------");
done();
} catch (error) {
console.log("testTelephonyHttpResponseCodeMovedPerm001 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTP_RESPONSECODE_SEE_OTHER_001
* @tc.name testTelephonyHttpResponseCodeSeeOther001
* @tc.desc Test Test ResponseCode property.
* @tc.size: MediumTest
* @tc.type: Enum
* @tc.level: level 0
*/
it("testTelephonyHttpResponseCodeSeeOther001", 0, async function (done) {
console.log("-----------------------ResponseCode SEE_OTHER Test is starting-----------------------");
try {
expect(303).assertEqual(http.ResponseCode.SEE_OTHER);
console.log("-----------------------ResponseCode SEE_OTHER Test end-----------------------");
done();
} catch (error) {
console.log("testTelephonyHttpResponseCodeSeeOther001 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTP_RESPONSECODE_NOT_MODIFIED_001
* @tc.name testTelephonyHttpResponseCodeNotModified001
* @tc.desc Test Test ResponseCode property.
* @tc.size: MediumTest
* @tc.type: Enum
* @tc.level: level 0
*/
it("testTelephonyHttpResponseCodeNotModified001", 0, async function (done) {
console.log("-----------------------ResponseCode NOT_MODIFIED Test is starting-----------------------");
try {
expect(304).assertEqual(http.ResponseCode.NOT_MODIFIED);
console.log("-----------------------ResponseCode NOT_MODIFIED Test end-----------------------");
done();
} catch (error) {
console.log("testTelephonyHttpResponseCodeNotModified001 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTP_RESPONSECODE_USE_PROXY_001
* @tc.name testTelephonyHttpResponseCodeUseProxy001
* @tc.desc Test Test ResponseCode property.
* @tc.size: MediumTest
* @tc.type: Enum
* @tc.level: level 0
*/
it("testTelephonyHttpResponseCodeUseProxy001", 0, async function (done) {
console.log("-----------------------ResponseCode USE_PROXY Test is starting-----------------------");
try {
expect(305).assertEqual(http.ResponseCode.USE_PROXY);
console.log("-----------------------ResponseCode USE_PROXY Test end-----------------------");
done();
} catch (error) {
console.log("testTelephonyHttpResponseCodeUseProxy001 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTP_RESPONSECODE_BAD_REQUEST_001
* @tc.name testTelephonyHttpResponseCodeBadRequest001
* @tc.desc Test Test ResponseCode property.
* @tc.size: MediumTest
* @tc.type: Enum
* @tc.level: level 0
*/
it("testTelephonyHttpResponseCodeBadRequest001", 0, async function (done) {
console.log("-----------------------ResponseCode BAD_REQUEST Test is starting-----------------------");
try {
expect(400).assertEqual(http.ResponseCode.BAD_REQUEST);
console.log("-----------------------ResponseCode BAD_REQUEST Test end-----------------------");
done();
} catch (error) {
console.log("testTelephonyHttpResponseCodeBadRequest001 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTP_RESPONSECODE_UNAUTHORIZED_001
* @tc.name testTelephonyHttpResponseCodeUnauthorized001
* @tc.desc Test Test ResponseCode property.
* @tc.size: MediumTest
* @tc.type: Enum
* @tc.level: level 0
*/
it("testTelephonyHttpResponseCodeUnauthorized001", 0, async function (done) {
console.log("-----------------------ResponseCode UNAUTHORIZED Test is starting-----------------------");
try {
expect(401).assertEqual(http.ResponseCode.UNAUTHORIZED);
console.log("-----------------------ResponseCode UNAUTHORIZED Test end-----------------------");
done();
} catch (error) {
console.log("Telephony_Http_ResponseCode_UNAUTHORIZED_0100 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTP_RESPONSECODE_PAYMENT_REQUIRED_001
* @tc.name testTelephonyHttpResponseCodePaymentRequest001
* @tc.desc Test Test ResponseCode property.
* @tc.size: MediumTest
* @tc.type: Enum
* @tc.level: level 0
*/
it("testTelephonyHttpResponseCodePaymentRequest001", 0, async function (done) {
console.log("-----------------------ResponseCode PAYMENT_REQUIRED Test is starting-----------------------");
try {
expect(402).assertEqual(http.ResponseCode.PAYMENT_REQUIRED);
console.log("-----------------------ResponseCode PAYMENT_REQUIRED Test end-----------------------");
done();
} catch (error) {
console.log("testTelephonyHttpResponseCodePaymentRequest001 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTP_RESPONSECODE_BAD_METHOD_001
* @tc.name testTelephonyHttpResponseCodeBadMethod001
* @tc.desc Test Test ResponseCode property.
* @tc.size: MediumTest
* @tc.type: Enum
* @tc.level: level 0
*/
it("testTelephonyHttpResponseCodeBadMethod001", 0, async function (done) {
console.log("-----------------------ResponseCode BAD_METHOD Test is starting-----------------------");
try {
expect(405).assertEqual(http.ResponseCode.BAD_METHOD);
console.log("-----------------------ResponseCode BAD_METHOD Test end-----------------------");
done();
} catch (error) {
console.log("testTelephonyHttpResponseCodeBadMethod001 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTP_RESPONSECODE_NOT_ACCEPTABLE_001
* @tc.name testTelephonyHttpResponseCodeNotAcceptable001
* @tc.desc Test Test ResponseCode property.
* @tc.size: MediumTest
* @tc.type: Enum
* @tc.level: level 0
*/
it("testTelephonyHttpResponseCodeNotAcceptable001", 0, async function (done) {
console.log("-----------------------ResponseCode NOT_ACCEPTABLE Test is starting-----------------------");
try {
expect(406).assertEqual(http.ResponseCode.NOT_ACCEPTABLE);
console.log("-----------------------ResponseCode NOT_ACCEPTABLE Test end-----------------------");
done();
} catch (error) {
console.log("testTelephonyHttpResponseCodeNotAcceptable001 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTP_RESPONSECODE_PROXY_AUTH_001
* @tc.name testTelephonyHttpResponseCodeProxyAuth001
* @tc.desc Test Test ResponseCode property.
* @tc.size: MediumTest
* @tc.type: Enum
* @tc.level: level 0
*/
it("testTelephonyHttpResponseCodeProxyAuth001", 0, async function (done) {
console.log("-----------------------ResponseCode PROXY_AUTH Test is starting-----------------------");
try {
expect(407).assertEqual(http.ResponseCode.PROXY_AUTH);
console.log("-----------------------ResponseCode PROXY_AUTH Test end-----------------------");
done();
} catch (error) {
console.log("testTelephonyHttpResponseCodeProxyAuth001 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTP_RESPONSECODE_CLIENT_TIMEOUT_001
* @tc.name testTelephonyHttpResponseCodeClientTimeout001
* @tc.desc Test Test ResponseCode property.
* @tc.size: MediumTest
* @tc.type: Enum
* @tc.level: level 0
*/
it("testTelephonyHttpResponseCodeClientTimeout001", 0, async function (done) {
console.log("-----------------------ResponseCode CLIENT_TIMEOUT Test is starting-----------------------");
try {
expect(408).assertEqual(http.ResponseCode.CLIENT_TIMEOUT);
console.log("-----------------------ResponseCode CLIENT_TIMEOUT Test end-----------------------");
done();
} catch (error) {
console.log("testTelephonyHttpResponseCodeClientTimeout001 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTP_RESPONSECODE_LENGTH_REQUIRED_001
* @tc.name testTelephonyHttpResponseCodeLengthRequired001
* @tc.desc Test Test ResponseCode property.
* @tc.size: MediumTest
* @tc.type: Enum
* @tc.level: level 0
*/
it("testTelephonyHttpResponseCodeLengthRequired001", 0, async function (done) {
console.log("-----------------------ResponseCode LENGTH_REQUIRED Test is starting-----------------------");
try {
expect(411).assertEqual(http.ResponseCode.LENGTH_REQUIRED);
console.log("-----------------------ResponseCode LENGTH_REQUIRED Test end-----------------------");
done();
} catch (error) {
console.log("testTelephonyHttpResponseCodeLengthRequired001 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTP_RESPONSECODE_PRECON_FAILED_001
* @tc.name testTelephonyHttpResponseCodePreconFailed001
* @tc.desc Test Test ResponseCode property.
* @tc.size: MediumTest
* @tc.type: Enum
* @tc.level: level 0
*/
it("testTelephonyHttpResponseCodePreconFailed001", 0, async function (done) {
console.log("-----------------------ResponseCode PRECON_FAILED Test is starting-----------------------");
try {
expect(412).assertEqual(http.ResponseCode.PRECON_FAILED);
console.log("-----------------------ResponseCode PRECON_FAILED Test end-----------------------");
done();
} catch (error) {
console.log("testTelephonyHttpResponseCodePreconFailed001 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTP_RESPONSECODE_ENTITY_TOO_LARGE_001
* @tc.name testTelephonyHttpResponseCodeEntityTooLater001
* @tc.desc Test Test ResponseCode property.
* @tc.size: MediumTest
* @tc.type: Enum
* @tc.level: level 0
*/
it("testTelephonyHttpResponseCodeEntityTooLater001", 0, async function (done) {
console.log("-----------------------ResponseCode ENTITY_TOO_LARGE Test is starting-----------------------");
try {
expect(413).assertEqual(http.ResponseCode.ENTITY_TOO_LARGE);
console.log("-----------------------ResponseCode ENTITY_TOO_LARGE Test end-----------------------");
done();
} catch (error) {
console.log("testTelephonyHttpResponseCodeEntityTooLater001 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTP_RESPONSECODE_ENTITY_TOO_LARGE_001
* @tc.name testTelephonyHttpResponseCodeReqTooLong001
* @tc.desc Test Test ResponseCode property.
* @tc.size: MediumTest
* @tc.type: Enum
* @tc.level: level 0
*/
it("testTelephonyHttpResponseCodeReqTooLong001", 0, async function (done) {
console.log("-----------------------ResponseCode REQ_TOO_LONG Test is starting-----------------------");
try {
expect(414).assertEqual(http.ResponseCode.REQ_TOO_LONG);
console.log("-----------------------ResponseCode REQ_TOO_LONG Test end-----------------------");
done();
} catch (error) {
console.log("testTelephonyHttpResponseCodeReqTooLong001 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTP_RESPONSECODE_UNSUPPORTED_TYPE_001
* @tc.name testTelephonyHttpResponseCodeUnsupportedType001
* @tc.desc Test Test ResponseCode property.
* @tc.size: MediumTest
* @tc.type: Enum
* @tc.level: level 0
*/
it("testTelephonyHttpResponseCodeUnsupportedType001", 0, async function (done) {
console.log("-----------------------ResponseCode UNSUPPORTED_TYPE Test is starting-----------------------");
try {
expect(415).assertEqual(http.ResponseCode.UNSUPPORTED_TYPE);
console.log("-----------------------ResponseCode UNSUPPORTED_TYPE Test end-----------------------");
done();
} catch (error) {
console.log("testTelephonyHttpResponseCodeUnsupportedType001 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTP_RESPONSECODE_INTERNAL_ERROR_001
* @tc.name testTelephonyHttpResponseCodeInternalError001
* @tc.desc Test Test ResponseCode property.
* @tc.size: MediumTest
* @tc.type: Enum
* @tc.level: level 0
*/
it("testTelephonyHttpResponseCodeInternalError001", 0, async function (done) {
console.log("-----------------------ResponseCode INTERNAL_ERROR Test is starting-----------------------");
try {
expect(500).assertEqual(http.ResponseCode.INTERNAL_ERROR);
console.log("-----------------------ResponseCode INTERNAL_ERROR Test end-----------------------");
done();
} catch (error) {
console.log("testTelephonyHttpResponseCodeInternalError001 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTP_RESPONSECODE_NOT_IMPLEMENTED_001
* @tc.name testTelephonyHttpResponseCodeNotImplemented001
* @tc.desc Test Test ResponseCode property.
* @tc.size: MediumTest
* @tc.type: Enum
* @tc.level: level 0
*/
it("testTelephonyHttpResponseCodeNotImplemented001", 0, async function (done) {
console.log("-----------------------ResponseCode NOT_IMPLEMENTED Test is starting-----------------------");
try {
expect(501).assertEqual(http.ResponseCode.NOT_IMPLEMENTED);
console.log("-----------------------ResponseCode NOT_IMPLEMENTED Test end-----------------------");
done();
} catch (error) {
console.log("testTelephonyHttpResponseCodeNotImplemented001 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTP_RESPONSECODE_BAD_GATEWAY_001
* @tc.name testTelephonyHttpResponseCodeBadGateway001
* @tc.desc Test Test ResponseCode property.
* @tc.size: MediumTest
* @tc.type: Enum
* @tc.level: level 0
*/
it("testTelephonyHttpResponseCodeBadGateway001", 0, async function (done) {
console.log("-----------------------ResponseCode BAD_GATEWAY Test is starting-----------------------");
try {
expect(502).assertEqual(http.ResponseCode.BAD_GATEWAY);
console.log("-----------------------ResponseCode BAD_GATEWAY Test end-----------------------");
done();
} catch (error) {
console.log("testTelephonyHttpResponseCodeBadGateway001 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTP_RESPONSECODE_GATEWAY_TIMEOUT_001
* @tc.name testTelephonyHttpResponseCodeGatewayTimeout001
* @tc.desc Test Test ResponseCode property.
* @tc.size: MediumTest
* @tc.type: Enum
* @tc.level: level 0
*/
it("testTelephonyHttpResponseCodeGatewayTimeout001", 0, async function (done) {
console.log("-----------------------ResponseCode GATEWAY_TIMEOUT Test is starting-----------------------");
try {
expect(504).assertEqual(http.ResponseCode.GATEWAY_TIMEOUT);
console.log("-----------------------ResponseCode GATEWAY_TIMEOUT Test end-----------------------");
done();
} catch (error) {
console.log("testTelephonyHttpResponseCodeGatewayTimeout001 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTP_RESPONSECODE_VERSION_001
* @tc.name testTelephonyHttpResponseCodeVersion001
* @tc.desc Test Test ResponseCode property.
* @tc.size: MediumTest
* @tc.type: Enum
* @tc.level: level 0
*/
it("testTelephonyHttpResponseCodeVersion001", 0, async function (done) {
console.log("-----------------------ResponseCode VERSION Test is starting-----------------------");
try {
expect(505).assertEqual(http.ResponseCode.VERSION);
console.log("-----------------------ResponseCode VERSION Test end-----------------------");
done();
} catch (error) {
console.log("testTelephonyHttpResponseCodeVersion001 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTP_RESPONSECODE_CREATED_001
* @tc.name testTelephonyHttpResponseCodeCreated001
* @tc.desc Test Test ResponseCode property.
* @tc.size: MediumTest
* @tc.type: Enum
* @tc.level: level 0
*/
it("testTelephonyHttpResponseCodeCreated001", 0, async function (done) {
console.log("-----------------------ResponseCode CREATED Test is starting-----------------------");
try {
expect(201).assertEqual(http.ResponseCode.CREATED);
console.log("-----------------------ResponseCode CREATED Test end-----------------------");
done();
} catch (error) {
console.log("testTelephonyHttpResponseCodeCreated001 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTP_RESPONSECODE_CREATED_001
* @tc.name testTelephonyHttpResponseCodeReset001
* @tc.desc Test Test ResponseCode property.
* @tc.size: MediumTest
* @tc.type: Enum
* @tc.level: level 0
*/
it("testTelephonyHttpResponseCodeReset001", 0, async function (done) {
console.log("-----------------------ResponseCode RESET Test is starting-----------------------");
try {
expect(205).assertEqual(http.ResponseCode.RESET);
console.log("-----------------------ResponseCode RESET Test end-----------------------");
done();
} catch (error) {
console.log("testTelephonyHttpResponseCodeReset001 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTP_RESPONSECODE_PARTIAL_001
* @tc.name testTelephonyHttpResponseCodePartial001
* @tc.desc Test Test ResponseCode property.
* @tc.size: MediumTest
* @tc.type: Enum
* @tc.level: level 0
*/
it("testTelephonyHttpResponseCodePartial001", 0, async function (done) {
console.log("-----------------------ResponseCode PARTIAL Test is starting-----------------------");
try {
expect(206).assertEqual(http.ResponseCode.PARTIAL);
console.log("-----------------------ResponseCode PARTIAL Test end-----------------------");
done();
} catch (error) {
console.log("testTelephonyHttpResponseCodePartial001 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTP_RESPONSECODE_MOVED_TEMP_001
* @tc.name testTelephonyHttpResponseCodeMovedTemp001
* @tc.desc Test Test ResponseCode property.
* @tc.size: MediumTest
* @tc.type: Enum
* @tc.level: level 0
*/
it("testTelephonyHttpResponseCodeMovedTemp001", 0, async function (done) {
console.log("-----------------------ResponseCode MOVED_TEMP Test is starting-----------------------");
try {
expect(302).assertEqual(http.ResponseCode.MOVED_TEMP);
console.log("-----------------------ResponseCode MOVED_TEMP Test end-----------------------");
done();
} catch (error) {
console.log("testTelephonyHttpResponseCodeMovedTemp001 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTP_RESPONSECODE_FORBIDDEN_001
* @tc.name testTelephonyHttpResponseCodeForbidden001
* @tc.desc Test Test ResponseCode property.
* @tc.size: MediumTest
* @tc.type: Enum
* @tc.level: level 0
*/
it("testTelephonyHttpResponseCodeForbidden001", 0, async function (done) {
console.log("-----------------------ResponseCode FORBIDDEN Test is starting-----------------------");
try {
expect(403).assertEqual(http.ResponseCode.FORBIDDEN);
console.log("-----------------------ResponseCode FORBIDDEN Test end-----------------------");
done();
} catch (error) {
console.log("testTelephonyHttpResponseCodeForbidden001 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTP_RESPONSECODE_NOT_FOUND_001
* @tc.name testTelephonyHttpResponseCodeNotFound001
* @tc.desc Test Test ResponseCode property.
* @tc.size: MediumTest
* @tc.type: Enum
* @tc.level: level 0
*/
it("testTelephonyHttpResponseCodeNotFound001", 0, async function (done) {
console.log("-----------------------ResponseCode NOT_FOUND Test is starting-----------------------");
try {
expect(404).assertEqual(http.ResponseCode.NOT_FOUND);
console.log("-----------------------ResponseCode NOT_FOUND Test end-----------------------");
done();
} catch (error) {
console.log("testTelephonyHttpResponseCodeNotFound001 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTP_RESPONSECODE_CONFLICT_001
* @tc.name testTelephonyHttpResponseCodeConflict001
* @tc.desc Test Test ResponseCode property.
* @tc.size: MediumTest
* @tc.type: Enum
* @tc.level: level 0
*/
it("testTelephonyHttpResponseCodeConflict001", 0, async function (done) {
console.log("-----------------------ResponseCode CONFLICT Test is starting-----------------------");
try {
expect(409).assertEqual(http.ResponseCode.CONFLICT);
console.log("-----------------------ResponseCode CONFLICT Test end-----------------------");
done();
} catch (error) {
console.log("testTelephonyHttpResponseCodeConflict001 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTP_RESPONSECODE_GONE_001
* @tc.name testTelephonyHttpResponseCodeGone001
* @tc.desc Test Test ResponseCode property.
* @tc.size: MediumTest
* @tc.type: Enum
* @tc.level: level 0
*/
it("testTelephonyHttpResponseCodeGone001", 0, async function (done) {
console.log("-----------------------ResponseCode GONE Test is starting-----------------------");
try {
expect(410).assertEqual(http.ResponseCode.GONE);
console.log("-----------------------ResponseCode GONE Test end-----------------------");
done();
} catch (error) {
console.log("testTelephonyHttpResponseCodeGone001 : error = " + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number TEST_TELEPHONY_HTTP_RESPONSECODE_UNAVAILABLE_001
* @tc.name testTelephonyHttpResponseCodeUnavailable001
* @tc.desc Test Test ResponseCode property.
* @tc.size: MediumTest
* @tc.type: Enum
* @tc.level: level 0
*/
it("testTelephonyHttpResponseCodeUnavailable001", 0, async function (done) {
console.log("-----------------------ResponseCode UNAVAILABLE Test is starting-----------------------");
try {
expect(503).assertEqual(http.ResponseCode.UNAVAILABLE);
console.log("-----------------------ResponseCode UNAVAILABLE Test end-----------------------");
done();
} catch (error) {
console.log("testTelephonyHttpResponseCodeUnavailable001 : error = " + error);
expect(false).assertTrue();
done();
}
});
})
};
{
"module": {
"name": "entry_test",
"type": "feature",
"description": "$string:module_test_desc",
"mainElement": "TestAbility",
"deviceTypes": [
"phone"
],
"deliveryWithInstall": true,
"installationFree": false,
"pages": "$profile:test_pages",
"abilities": [
{
"name": "TestAbility",
"srcEntry": "./ets/TestAbility/TestAbility.ets",
"description": "$string:TestAbility_desc",
"icon": "$media:icon",
"label": "$string:TestAbility_label",
"exported": true,
"startWindowIcon": "$media:icon",
"startWindowBackground": "$color:start_window_background",
"skills": [
{
"actions": [
"action.system.home"
],
"entities": [
"entity.system.home"
]
}
]
}
],
"requestPermissions": [
{
"name":"ohos.permission.INTERNET",
"reason":"need use ohos.permission.INTERNET."
},
{"name": "ohos.permission.WRITE_MEDIA",
"reason": "need use ohos.permission.WRITE_MEDIA",
"usedScene": {
"ability": [
"com.acts.request.test.MainAbility"
],
"when":"always"
}
},
{"name": "ohos.permission.READ_MEDIA",
"reason": "need use ohos.permission.WRITE_MEDIA",
"usedScene": {
"ability": [
"com.acts.request.test.MainAbility"
],
"when":"always"
}
}
]
}
}
{
"color": [
{
"name": "start_window_background",
"value": "#FFFFFF"
}
]
}
\ No newline at end of file
{
"string": [
{
"name": "module_test_desc",
"value": "test ability description"
},
{
"name": "TestAbility_desc",
"value": "the test ability"
},
{
"name": "TestAbility_label",
"value": "test label"
}
]
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册