1 20 21 package org.jivesoftware.smack; 22 23 import org.jivesoftware.smack.test.SmackTestCase; 24 25 30 public class FloodTest extends SmackTestCase { 31 32 public FloodTest(String arg0) { 33 super(arg0); 34 } 35 36 public void testMessageFlood() { 37 try { 38 Chat chat11 = getConnection(0).createChat(getBareJID(1)); 39 Chat chat12 = new Chat(getConnection(1), getBareJID(0), chat11.getThreadID()); 40 41 Chat chat21 = getConnection(0).createChat(getBareJID(2)); 42 Chat chat22 = new Chat(getConnection(2), getBareJID(0), chat21.getThreadID()); 43 44 Chat chat31 = getConnection(0).createChat(getBareJID(3)); 45 Chat chat32 = new Chat(getConnection(3), getBareJID(0), chat31.getThreadID()); 46 47 for (int i=0; i<500; i++) { 48 chat11.sendMessage("Hello_1" + i); 49 chat21.sendMessage("Hello_2" + i); 50 chat31.sendMessage("Hello_3" + i); 51 } 52 for (int i=0; i<500; i++) { 53 assertNotNull("Some message was lost (" + i + ")", chat12.nextMessage(1000)); 54 assertNotNull("Some message was lost (" + i + ")", chat22.nextMessage(1000)); 55 assertNotNull("Some message was lost (" + i + ")", chat32.nextMessage(1000)); 56 } 57 } 58 catch (Exception e) { 59 e.printStackTrace(); 60 fail(e.getMessage()); 61 } 62 } 63 64 98 99 protected int getMaxConnections() { 100 return 4; 101 } 102 } 103 | Popular Tags |