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

!9221 销毁http创建的对象

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