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

!9221 销毁http创建的对象

Merge pull request !9221 from 邓显俊/master
......@@ -54,6 +54,7 @@ export default function NetworkManagerCaPathTest() {
if (err) {
console.info(`${CASE_NAME} httpsRequest fail, err: ${JSON.stringify(err)}`);
expect(err.code == 2300077).assertTrue();
httpRequest.destroy();
done();
} else {
console.info(`${CASE_NAME} httpsRequest success, data: ${JSON.stringify(data)}`);
......@@ -75,6 +76,7 @@ export default function NetworkManagerCaPathTest() {
if (err) {
console.info(`${CASE_NAME} httpsRequest fail, err: ${JSON.stringify(err)}`);
expect(err.code == 2300077).assertTrue();
httpRequest.destroy();
done();
} else {
console.info(`${CASE_NAME} httpsRequest success, data: ${JSON.stringify(data)}`);
......@@ -96,6 +98,7 @@ export default function NetworkManagerCaPathTest() {
if (err) {
console.info(`${CASE_NAME} httpsRequest fail, err: ${JSON.stringify(err)}`);
expect(err.code == 2300077).assertTrue();
httpRequest.destroy();
done();
} else {
console.info(`${CASE_NAME} httpsRequest success, data: ${JSON.stringify(data)}`);
......
......@@ -28,6 +28,7 @@ export default function httpJsunit() {
var httpRequest = http.createHttp();
expect(httpRequest != null).assertTrue();
console.log("-----------------------http createHttp Test end-----------------------");
httpRequest.destroy();
done();
});
/**
......
......@@ -38,6 +38,7 @@ export default function httpRequestJsunit() {
httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
httpRequest.destroy();
console.log("-----------------------HttpRequest_request Test end-----------------------");
done();
});
......@@ -61,6 +62,7 @@ export default function httpRequestJsunit() {
httpRequest.request("https://www.baidu.com/", (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
httpRequest.destroy();
console.log("-----------------------HttpRequest_request_01 Test end-----------------------");
done();
});
......@@ -91,6 +93,7 @@ export default function httpRequestJsunit() {
httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => {
console.log(casename + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
httpRequest.destroy();
console.log("-----------------------HttpRequest_request_02 Test end-----------------------");
done();
}).catch(error => {
......@@ -154,6 +157,7 @@ export default function httpRequestJsunit() {
httpRequest.on('headerReceive', (data) => {
console.log(casename + " data: " + JSON.stringify(data));
expect(true).assertTrue();
httpRequest.destroy();
console.log("-----------------------HttpRequest_on_headerReceive Test end-----------------------");
done();
});
......@@ -180,6 +184,7 @@ export default function httpRequestJsunit() {
httpRequest.off('headerReceive', (data) => {
console.log(casename + " data: " + JSON.stringify(data));
expect(false).assertTrue();
httpRequest.destroy();
console.log("-----------------------HttpRequest_off_headerReceive Test end-----------------------");
done();
});
......@@ -209,6 +214,7 @@ export default function httpRequestJsunit() {
httpRequest.on("headersReceive", (data) => {
console.log(casename + " data: " + JSON.stringify(data));
expect(true).assertTrue();
httpRequest.destroy();
console.log("-----------------------HttpRequest_on_headersReceive Test end-----------------------");
done();
});
......@@ -235,6 +241,7 @@ export default function httpRequestJsunit() {
httpRequest.off("headersReceive", (data) => {
console.log(casename + " data: " + JSON.stringify(data));
expect(false).assertTrue();
httpRequest.destroy();
console.log("-----------------------HttpRequest_off_headersReceive Test end-----------------------");
done();
});
......@@ -260,6 +267,7 @@ export default function httpRequestJsunit() {
var httpRequest = http.createHttp();
httpRequest.off('headersReceive');
expect(true).assertTrue();
httpRequest.destroy();
console.log("-----------------------HttpRequest_off_headersReceive_0200 Test end-----------------------");
done();
} catch (error) {
......@@ -282,6 +290,7 @@ export default function httpRequestJsunit() {
httpRequest.once('headersReceive', (data) => {
console.log(casename + " data: " + JSON.stringify(data));
expect(true).assertTrue();
httpRequest.destroy();
console.log("-----------------------HttpRequest_on_headersReceive Test end-----------------------");
done();
});
......
......@@ -40,6 +40,7 @@ export default function HttpRequestOptionsJsunit() {
httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
httpRequest.destroy();
console.log("-----------------------HttpRequestOptions_method Test end-----------------------");
done();
});
......@@ -70,6 +71,7 @@ export default function HttpRequestOptionsJsunit() {
httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => {
console.log(casename + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
httpRequest.destroy();
console.log("-----------------------HttpRequestOptions_method_01 Test end-----------------------");
done();
}).catch(error => {
......@@ -112,6 +114,7 @@ export default function HttpRequestOptionsJsunit() {
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();
httpRequest.destroy();
console.log("-----------------------HttpRequestOptions_extraData Test end-----------------------");
done();
});
......@@ -150,6 +153,7 @@ export default function HttpRequestOptionsJsunit() {
httpRequest.request("https://image.baidu.com/search/albumsdetail/", httpRequestOptions).then(data => {
console.log(casename + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
httpRequest.destroy();
console.log("-----------------------HttpRequestOptions_extraData_01 Test end-----------------------");
done();
}).catch(error => {
......@@ -185,6 +189,7 @@ export default function HttpRequestOptionsJsunit() {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
try {
expect(true).assertTrue();
httpRequest.destroy();
console.log("-----------------------HttpRequestOptions_header Test end-----------------------");
done();
} catch (error) {
......@@ -221,6 +226,7 @@ export default function HttpRequestOptionsJsunit() {
console.log(casename + JSON.stringify(data));
try {
expect(true).assertTrue();
httpRequest.destroy();
console.log("-----------------------HttpRequestOptions_header_01 Test end-----------------------");
done();
} catch (error) {
......@@ -264,6 +270,7 @@ export default function HttpRequestOptionsJsunit() {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
try {
expect(data.responseCode == 200).assertTrue();
httpRequest.destroy();
console.log("-----------------------HttpRequestOptions_header_02 Test end-----------------------");
done();
} catch (error) {
......@@ -300,6 +307,7 @@ export default function HttpRequestOptionsJsunit() {
console.log(casename + JSON.stringify(data));
try {
expect(data.result.valueOf() != "").assertTrue();
httpRequest.destroy();
console.log("-----------------------HttpRequestOptions_header_03 Test end-----------------------");
done();
} catch (error) {
......@@ -343,6 +351,7 @@ export default function HttpRequestOptionsJsunit() {
httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 408).assertTrue();
httpRequest.destroy();
console.log("-----------------------HttpRequestOptions_readTimeout Test end-----------------------");
done();
});
......@@ -377,6 +386,7 @@ export default function HttpRequestOptionsJsunit() {
httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => {
console.log(casename + JSON.stringify(data));
expect(data.responseCode == 408).assertTrue();
httpRequest.destroy();
console.log("-----------------------HttpRequestOptions_readTimeout_01 Test end-----------------------");
done();
}).catch(error => {
......@@ -415,6 +425,7 @@ export default function HttpRequestOptionsJsunit() {
httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 504).assertTrue();
httpRequest.destroy();
console.log("-----------------------HttpRequestOptions_connectTimeout Test end-----------------------");
done();
});
......@@ -450,6 +461,7 @@ export default function HttpRequestOptionsJsunit() {
httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => {
console.log(casename + JSON.stringify(data));
expect(data.responseCode == 504).assertTrue();
httpRequest.destroy();
console.log("-----------------------HttpRequestOptions_connectTimeout_01 Test end-----------------------");
done();
}).catch(error => {
......
......@@ -39,6 +39,7 @@ export default function httpResponseJsunit() {
httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.result != null).assertTrue();
httpRequest.destroy();
console.log("-----------------------HttpResponse result Test end-----------------------");
done();
});
......@@ -64,6 +65,7 @@ export default function httpResponseJsunit() {
httpRequest.request("https://www.baidu.com/", (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.result != null).assertTrue();
httpRequest.destroy();
console.log("-----------------------HttpResponse result_01 Test end-----------------------");
done();
});
......@@ -96,6 +98,7 @@ export default function httpResponseJsunit() {
httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => {
console.log(casename + JSON.stringify(data));
expect(data.result != null).assertTrue();
httpRequest.destroy();
console.log("-----------------------HttpResponse result_02 Test end-----------------------");
done();
}).catch(error => {
......@@ -132,6 +135,7 @@ export default function httpResponseJsunit() {
httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode != 0).assertTrue();
httpRequest.destroy();
console.log("-----------------------HttpResponse responseCode Test end-----------------------");
done();
});
......@@ -157,6 +161,7 @@ export default function httpResponseJsunit() {
httpRequest.request("https://www.baidu.com/", (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode != 0).assertTrue();
httpRequest.destroy();
console.log("-----------------------HttpResponse responseCode_01 Test end-----------------------");
done();
});
......@@ -190,6 +195,7 @@ export default function httpResponseJsunit() {
httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => {
console.log(casename + JSON.stringify(data));
expect(data.responseCode != 0).assertTrue();
httpRequest.destroy();
console.log("-----------------------HttpResponse responseCode_02 Test end-----------------------");
done();
}).catch(error => {
......@@ -225,6 +231,7 @@ export default function httpResponseJsunit() {
httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.header != null).assertTrue();
httpRequest.destroy();
console.log("-----------------------header result Test end-----------------------");
done();
});
......@@ -250,6 +257,7 @@ export default function httpResponseJsunit() {
httpRequest.request("https://www.baidu.com/", (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.header != null).assertTrue();
httpRequest.destroy();
console.log("-----------------------header header_01 Test end-----------------------");
done();
});
......@@ -283,6 +291,7 @@ export default function httpResponseJsunit() {
httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => {
console.log(casename + JSON.stringify(data));
expect(data.header != null).assertTrue();
httpRequest.destroy();
console.log("-----------------------HttpResponse header_02 Test end-----------------------");
done();
}).catch(error => {
......@@ -317,6 +326,7 @@ export default function httpResponseJsunit() {
httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.cookies != null).assertTrue();
httpRequest.destroy();
console.log("-----------------------HttpResponse cookies Test end-----------------------");
done();
});
......@@ -343,6 +353,7 @@ export default function httpResponseJsunit() {
httpRequest.request("https://www.baidu.com/", (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.cookies != null).assertTrue();
httpRequest.destroy();
console.log("-----------------------HttpResponse cookies_01 Test end-----------------------");
done();
});
......@@ -375,6 +386,7 @@ export default function httpResponseJsunit() {
httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => {
console.log(casename + JSON.stringify(data));
expect(data.cookies != null).assertTrue();
httpRequest.destroy();
console.log("-----------------------HttpResponse cookies_02 Test end-----------------------");
done();
}).catch(error => {
......
......@@ -39,6 +39,7 @@ export default function requestMethodJsunit() {
httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
httpRequest.destroy();
console.log("-----------------------HttpRequestMethod_options Test end-----------------------");
done();
});
......@@ -72,6 +73,7 @@ export default function requestMethodJsunit() {
httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => {
console.log(casename + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
httpRequest.destroy();
console.log("-----------------------HttpRequestMethod_options_01 Test end-----------------------");
done();
}).catch(error => {
......@@ -109,6 +111,7 @@ export default function requestMethodJsunit() {
httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
httpRequest.destroy();
console.log("-----------------------HttpRequestMethod_GET Test end-----------------------");
done();
});
......@@ -142,6 +145,7 @@ export default function requestMethodJsunit() {
httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => {
console.log(casename + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
httpRequest.destroy();
console.log("-----------------------HttpRequestMethod_GET_01 Test end-----------------------");
done();
}).catch(error => {
......@@ -184,6 +188,7 @@ export default function requestMethodJsunit() {
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();
httpRequest.destroy();
console.log("-----------------------HttpRequestMethod_POST Test end-----------------------");
done();
});
......@@ -225,6 +230,7 @@ export default function requestMethodJsunit() {
httpRequest.request("https://image.baidu.com/search/albumsdetail/", httpRequestOptions).then(data => {
console.log(casename + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
httpRequest.destroy();
console.log("-----------------------HttpRequestMethod_POST_01 Test end-----------------------");
done();
}).catch(error => {
......@@ -262,6 +268,7 @@ export default function requestMethodJsunit() {
httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
httpRequest.destroy();
console.log("-----------------------HttpRequestMethod_TRACE Test end-----------------------");
done();
});
......@@ -294,6 +301,7 @@ export default function requestMethodJsunit() {
httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => {
console.log(casename + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
httpRequest.destroy();
console.log("-----------------------HttpRequestMethod_TRACE_01 Test end-----------------------");
done();
}).catch(error => {
......@@ -337,6 +345,7 @@ export default function requestMethodJsunit() {
httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
httpRequest.destroy();
console.log("-----------------------HttpRequestMethod_PUT Test end-----------------------");
done();
});
......@@ -374,6 +383,7 @@ export default function requestMethodJsunit() {
httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => {
console.log(casename + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
httpRequest.destroy();
console.log("-----------------------HttpRequestMethod_PUT_01 Test end-----------------------");
done();
}).catch(error => {
......@@ -409,6 +419,7 @@ export default function requestMethodJsunit() {
httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
httpRequest.destroy();
console.log("-----------------------HttpRequestMethod_head Test end-----------------------");
done();
});
......@@ -439,6 +450,7 @@ export default function requestMethodJsunit() {
httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => {
console.log(casename + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
httpRequest.destroy();
console.log("-----------------------HttpRequestMethod_HEAD_01 Test end-----------------------");
done();
}).catch(error => {
......@@ -474,6 +486,7 @@ export default function requestMethodJsunit() {
httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
httpRequest.destroy();
console.log("-----------------------HttpRequestMethod_DELETE Test end-----------------------");
done();
});
......@@ -504,6 +517,7 @@ export default function requestMethodJsunit() {
httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => {
console.log(casename + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
httpRequest.destroy();
console.log("-----------------------HttpRequestMethod_DELETE_01 Test end-----------------------");
done();
}).catch(error => {
......@@ -539,6 +553,7 @@ export default function requestMethodJsunit() {
httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
httpRequest.destroy();
console.log("-----------------------HttpRequestMethod_CONNECT Test end-----------------------");
done();
});
......@@ -569,6 +584,7 @@ export default function requestMethodJsunit() {
httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => {
console.log(casename + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
httpRequest.destroy();
console.log("-----------------------HttpRequestMethod_CONNECT_01 Test end-----------------------");
done();
}).catch(error => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册