From 9525df0c87427da652fbcc2630c756b20768a1f2 Mon Sep 17 00:00:00 2001 From: Gaston Dombiak Date: Thu, 23 Dec 2004 18:49:53 +0000 Subject: [PATCH] Initial version. git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@2433 b35dd754-fafc-0310-a699-88a17e54d16e --- test/org/jivesoftware/smack/FloodTest.java | 58 ++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 test/org/jivesoftware/smack/FloodTest.java diff --git a/test/org/jivesoftware/smack/FloodTest.java b/test/org/jivesoftware/smack/FloodTest.java new file mode 100644 index 000000000..a1050bf1c --- /dev/null +++ b/test/org/jivesoftware/smack/FloodTest.java @@ -0,0 +1,58 @@ +/** + * $RCSfile$ + * $Revision$ + * $Date$ + * + * Copyright (C) 2004 Jive Software. All rights reserved. + * + * This software is published under the terms of the GNU Public License (GPL), + * a copy of which is included in this distribution. + */ + +package org.jivesoftware.smack; + +import org.jivesoftware.smack.test.SmackTestCase; + +/** + * Simple test to measure server performance. + * + * @author Gaston Dombiak + */ +public class FloodTest extends SmackTestCase { + + public FloodTest(String arg0) { + super(arg0); + } + + public void testMessageFlood() { + try { + Chat chat11 = getConnection(0).createChat(getBareJID(1)); + Chat chat12 = new Chat(getConnection(1), getBareJID(0), chat11.getThreadID()); + + Chat chat21 = getConnection(0).createChat(getBareJID(2)); + Chat chat22 = new Chat(getConnection(2), getBareJID(0), chat21.getThreadID()); + + Chat chat31 = getConnection(0).createChat(getBareJID(3)); + Chat chat32 = new Chat(getConnection(3), getBareJID(0), chat31.getThreadID()); + + for (int i=0; i<500; i++) { + chat11.sendMessage("Hello_1" + i); + chat21.sendMessage("Hello_2" + i); + chat31.sendMessage("Hello_3" + i); + } + for (int i=0; i<500; i++) { + assertNotNull("Some message was lost (" + i + ")", chat12.nextMessage(1000)); + assertNotNull("Some message was lost (" + i + ")", chat22.nextMessage(1000)); + assertNotNull("Some message was lost (" + i + ")", chat32.nextMessage(1000)); + } + } + catch (Exception e) { + e.printStackTrace(); + fail(e.getMessage()); + } + } + + protected int getMaxConnections() { + return 4; + } +}