From 9e9185a0d4fc2b08b6321da3c76e31c1cfaea550 Mon Sep 17 00:00:00 2001 From: wupingyuan Date: Thu, 31 Aug 2023 16:56:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8E=8B=E5=8A=9B=E6=B5=8B?= =?UTF-8?q?=E8=AF=95SMTP=E5=92=8CPOP3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/ohosTest/ets/test/POP3Press.test.ets | 333 ++++++++---------- .../src/ohosTest/ets/test/SMTPPress.test.ets | 58 ++- 2 files changed, 184 insertions(+), 207 deletions(-) diff --git a/POP3Client/entry/src/ohosTest/ets/test/POP3Press.test.ets b/POP3Client/entry/src/ohosTest/ets/test/POP3Press.test.ets index b45e645..c5560a2 100644 --- a/POP3Client/entry/src/ohosTest/ets/test/POP3Press.test.ets +++ b/POP3Client/entry/src/ohosTest/ets/test/POP3Press.test.ets @@ -39,205 +39,184 @@ export default function POP3PressTest() { describe('POP3PressTest', function () { - it('LIST', 0, function () { - let option = { - host: 'pop.qq.com', - port: 110, - user: account + mailType, - password: password, - timeout: 30000, - servername: 'pop.qq.com', - tls: false, - tlsOptions: undefined - } - client = new Pop3Command(option); - for (var i = 1;i < BASE_COUNT; i++) { + for (var i = 1;i < BASE_COUNT; i++) { + + it('LIST', 0, function () { + let option = { + host: 'pop.qq.com', + port: 110, + user: account + mailType, + password: password, + timeout: 30000, + servername: 'pop.qq.com', + tls: false, + tlsOptions: undefined + } + client = new Pop3Command(option); let result = client.LIST(); console.log("LIST count:" + i) - } - }) - - it('STAT', 0, function () { - let option = { - host: 'pop.qq.com', - port: 110, - user: account + mailType, - password: password, - timeout: 30000, - servername: 'pop.qq.com', - tls: false, - tlsOptions: undefined - } - client = new Pop3Command(option); - for (var i = 1;i < BASE_COUNT; i++) { + }) + + it('STAT', 0, function () { + let option = { + host: 'pop.qq.com', + port: 110, + user: account + mailType, + password: password, + timeout: 30000, + servername: 'pop.qq.com', + tls: false, + tlsOptions: undefined + } + client = new Pop3Command(option); let result = client.STAT() console.log("STAT count:" + i) - } - }) - - it('NOOP', 0, function () { - let option = { - host: 'pop.qq.com', - port: 110, - user: account + mailType, - password: password, - timeout: 30000, - servername: 'pop.qq.com', - tls: false, - tlsOptions: undefined - } - client = new Pop3Command(option); - for (var i = 1;i < BASE_COUNT; i++) { + }) + + it('NOOP', 0, function () { + let option = { + host: 'pop.qq.com', + port: 110, + user: account + mailType, + password: password, + timeout: 30000, + servername: 'pop.qq.com', + tls: false, + tlsOptions: undefined + } + client = new Pop3Command(option); let result = client.NOOP() console.log("NOOP count:" + i) - } - }) - - it('UIDL', 0, function () { - let option = { - host: 'pop.qq.com', - port: 110, - user: account + mailType, - password: password, - timeout: 30000, - servername: 'pop.qq.com', - tls: false, - tlsOptions: undefined - } - client = new Pop3Command(option); - for (var i = 1;i < BASE_COUNT; i++) { + }) + + it('UIDL', 0, function () { + let option = { + host: 'pop.qq.com', + port: 110, + user: account + mailType, + password: password, + timeout: 30000, + servername: 'pop.qq.com', + tls: false, + tlsOptions: undefined + } + client = new Pop3Command(option); let result = client.UIDL("1") console.log("UIDL count:" + i) - } - }) - - it('RSET', 0, function () { - let option = { - host: 'pop.qq.com', - port: 110, - user: account + mailType, - password: password, - timeout: 30000, - servername: 'pop.qq.com', - tls: false, - tlsOptions: undefined - } - client = new Pop3Command(option); - for (var i = 1;i < BASE_COUNT; i++) { + }) + + it('RSET', 0, function () { + let option = { + host: 'pop.qq.com', + port: 110, + user: account + mailType, + password: password, + timeout: 30000, + servername: 'pop.qq.com', + tls: false, + tlsOptions: undefined + } + client = new Pop3Command(option); let result = client.RSET() console.log("RSET count:" + i) - } - }) - - it('RETR', 0, function () { - let option = { - host: 'pop.qq.com', - port: 110, - user: account + mailType, - password: password, - timeout: 30000, - servername: 'pop.qq.com', - tls: false, - tlsOptions: undefined - } - client = new Pop3Command(option); - for (var i = 1;i < BASE_COUNT; i++) { + }) + + it('RETR', 0, function () { + let option = { + host: 'pop.qq.com', + port: 110, + user: account + mailType, + password: password, + timeout: 30000, + servername: 'pop.qq.com', + tls: false, + tlsOptions: undefined + } + client = new Pop3Command(option); let result = client.RETR("1") console.log("RETR count:" + i) - } - }) - - - it('DELE', 0, function () { - let option = { - host: 'pop.qq.com', - port: 110, - user: account + mailType, - password: password, - timeout: 30000, - servername: 'pop.qq.com', - tls: false, - tlsOptions: undefined - } - client = new Pop3Command(option); - for (var i = 1;i < BASE_COUNT; i++) { + }) + + it('DELE', 0, function () { + let option = { + host: 'pop.qq.com', + port: 110, + user: account + mailType, + password: password, + timeout: 30000, + servername: 'pop.qq.com', + tls: false, + tlsOptions: undefined + } + client = new Pop3Command(option); let result = client.DELE("1") console.log("DELE count:" + i) - } - }) - - - it('QUIT', 0, function () { - let option = { - host: 'pop.qq.com', - port: 110, - user: account + mailType, - password: password, - timeout: 30000, - servername: 'pop.qq.com', - tls: false, - tlsOptions: undefined - } - client = new Pop3Command(option); - for (var i = 1;i < BASE_COUNT; i++) { + }) + + it('QUIT', 0, function () { + let option = { + host: 'pop.qq.com', + port: 110, + user: account + mailType, + password: password, + timeout: 30000, + servername: 'pop.qq.com', + tls: false, + tlsOptions: undefined + } + client = new Pop3Command(option); let result = client.QUIT() console.log("QUIT count:" + i) - } - }) - - it('connect', 0, function () { - let option = { - host: 'pop.qq.com', - port: 110, - user: account + mailType, - password: password, - timeout: 30000, - servername: 'pop.qq.com', - tls: false, - tlsOptions: undefined - } - client = new Pop3Command(option); - for (var i = 1;i < BASE_COUNT; i++) { + }) + + it('connect', 0, function () { + let option = { + host: 'pop.qq.com', + port: 110, + user: account + mailType, + password: password, + timeout: 30000, + servername: 'pop.qq.com', + tls: false, + tlsOptions: undefined + } + client = new Pop3Command(option); let result = client.connect() console.log("connect count:" + i) - } - }) - - it('TOP', 0, function () { - let option = { - host: 'pop.qq.com', - port: 110, - user: account + mailType, - password: password, - timeout: 30000, - servername: 'pop.qq.com', - tls: false, - tlsOptions: undefined - } - client = new Pop3Command(option); - for (var i = 1;i < BASE_COUNT; i++) { + }) + + it('TOP', 0, function () { + let option = { + host: 'pop.qq.com', + port: 110, + user: account + mailType, + password: password, + timeout: 30000, + servername: 'pop.qq.com', + tls: false, + tlsOptions: undefined + } + client = new Pop3Command(option); let result = client.TOP("1") console.log("TOP count:" + i) - } - }) - - it('command', 0, function () { - let option = { - host: 'pop.qq.com', - port: 110, - user: account + mailType, - password: password, - timeout: 30000, - servername: 'pop.qq.com', - tls: false, - tlsOptions: undefined - } - client = new Pop3Command(option); - for (var i = 1;i < BASE_COUNT; i++) { + }) + + it('command', 0, function () { + let option = { + host: 'pop.qq.com', + port: 110, + user: account + mailType, + password: password, + timeout: 30000, + servername: 'pop.qq.com', + tls: false, + tlsOptions: undefined + } + client = new Pop3Command(option); let result = client.command("NOOP") console.log("command count:" + i) - } - }) + }) + } }) } \ No newline at end of file diff --git a/SMTPClient/entry/src/ohosTest/ets/test/SMTPPress.test.ets b/SMTPClient/entry/src/ohosTest/ets/test/SMTPPress.test.ets index 687758e..dfcfd02 100644 --- a/SMTPClient/entry/src/ohosTest/ets/test/SMTPPress.test.ets +++ b/SMTPClient/entry/src/ohosTest/ets/test/SMTPPress.test.ets @@ -1,11 +1,10 @@ import hilog from '@ohos.hilog'; -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' -import { AUTH_METHODS, SMTPClient } from '@ohos/emailjs' +import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it } from '@ohos/hypium' +import { AUTH_METHODS, Message, MessageAttachment, MessageHeaders, SMTPClient } from '@ohos/emailjs' import promptAction from '@ohos.promptAction' import router from '@ohos.router' import socket from '@ohos.net.socket' import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; -import { Message, MessageHeaders, MessageAttachment } from '@ohos/emailjs' import fs from '@ohos.file.fs'; export default function SMTPPressTest() { @@ -17,11 +16,12 @@ export default function SMTPPressTest() { let bcc: string = '2' let subject: string = 'test' let content: string = 'test' + const BASE_COUNT = 1000 describe('SMTPPressTest', function () { - it('new_SMTPClient', 0, function () { - for (var i = 1;i <= 1000; i++) { + for (var i = 1;i <= BASE_COUNT; i++) { + it('new_SMTPClient', 0, function () { let client = new SMTPClient({ user: '479868299@qq.com', password: 'bfxeualuaxambged', @@ -33,34 +33,32 @@ export default function SMTPPressTest() { tls: undefined }); console.log("new SMTPClient count:" + i); - } - }) + }) - it('sendAsync', 0, function () { - let client = new SMTPClient({ - user: '479868299@qq.com', - password: 'bfxeualuaxambged', - host: 'smtp.qq.com', - port: 25, - timeout: 30000, - authentication: [AUTH_METHODS.LOGIN], - ssl: false, - tls: undefined - }); + it('sendAsync', 0, function () { + let client = new SMTPClient({ + user: '479868299@qq.com', + password: 'bfxeualuaxambged', + host: 'smtp.qq.com', + port: 25, + timeout: 30000, + authentication: [AUTH_METHODS.LOGIN], + ssl: false, + tls: undefined + }); - let msg: Message | MessageHeaders = { - text: content, - from: `${accountName} <${from}>`, - to: to, - cc: cc, - bcc: cc, - subject: subject, - attachment: null - } - for (var i = 1;i <= 1000; i++) { + let msg: Message | MessageHeaders = { + text: content, + from: `${accountName} <${from}>`, + to: to, + cc: cc, + bcc: cc, + subject: subject, + attachment: null + } client.sendAsync(msg) console.log("sendAsync count:" + i) - } - }) + }) + } }) } \ No newline at end of file -- Gitee