使用多个客户端实例自动化 XMPP 服务器测试

发布于 2024-09-06 21:26:43 字数 195 浏览 3 评论 0原文

我正在开发 XMPP 服务器的测试套件。目前,我已经实现了一个客户端,能够连接、创建帐户、发送从 XML 文件中获取的节、接收回复、将其存储在另一个文件中并将其与预期输出进行比较。我可以创建多个客户端,但我正在寻找并发操作。

我该如何让多个客户端相互通信?我的愿景 - 将客户端放入单独的线程中并提供“等待回复”等命令。

任何建议表示赞赏...

I'm working on a test suite for XMPP server. Currently I have implemented a client able to connect, create account, send stanzas taken from XML file, receive the reply, store it in another file and compare that with the expected output. I can create several clients, but I'm looking for concurrent operation.

How do I go about making multiple clients to communicate with each other? My vision - put the clients into separate threads and provide commands like 'wait for reply'.

Any advice is appreciated...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

给不了的爱 2024-09-13 21:26:43

全部在单个测试用例中的同一线程上完成。

  • 以用户 1 的身份创建传出连接。
  • 以用户 2 的身份创建传入连接。
  • 为测试节注册 PacketListener,该测试节会在传入连接上写入 BlockingQueue。
  • 在传出连接上写入节。
  • 对队列调用 take() 并测试结果。

注意:PacketListener 将在 Smack 内部生成的单独线程上调用,这就是为什么您需要 BlockingQueue 来协调发送和回复。

All done on same thread in a single testcase.

  • Create outgoing connection as user 1.
  • Create incoming connection as user 2.
  • Register PacketListener for your test stanza which writes to a BlockingQueue on incoming connection.
  • Write stanza on outgoing connection.
  • Call take() on the queue and test results.

Note: The PacketListener will get called on a separate thread spawned internally by Smack, which is why you need the BlockingQueue to coordinate the send and the reply.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文