public void testRegularAndOOBUnicasts2() throws Exception { DISCARD discard = new DISCARD(); ProtocolStack stack = a.getProtocolStack(); stack.insertProtocol( discard, ProtocolStack.BELOW, (Class<? extends Protocol>[]) Util.getUnicastProtocols()); Address dest = b.getAddress(); Message m1 = new Message(dest, 1); Message m2 = new Message(dest, 2).setFlag(Message.Flag.OOB); Message m3 = new Message(dest, 3).setFlag(Message.Flag.OOB); Message m4 = new Message(dest, 4); MyReceiver receiver = new MyReceiver("B"); b.setReceiver(receiver); a.send(m1); discard.setDropDownUnicasts(2); a.send(m2); // dropped a.send(m3); // dropped a.send(m4); Collection<Integer> list = receiver.getMsgs(); int count = 10; while (list.size() < 4 && --count > 0) { Util.sleep(500); // time for potential retransmission sendStableMessages(a, b); } System.out.println("list = " + list); assert list.size() == 4 : "list is " + list; assert list.contains(1) && list.contains(2) && list.contains(3) && list.contains(4); }
protected void removeAllConnections() { Protocol prot = channel.getProtocolStack().findProtocol(Util.getUnicastProtocols()); if (prot instanceof UNICAST) ((UNICAST) prot).removeAllConnections(); else if (prot instanceof UNICAST2) ((UNICAST2) prot).removeAllConnections(); else if (prot instanceof UNICAST3) ((UNICAST3) prot).removeAllConnections(); }
protected void printConnections() { Protocol prot = channel.getProtocolStack().findProtocol(Util.getUnicastProtocols()); if (prot instanceof UNICAST) System.out.println(((UNICAST) prot).printConnections()); else if (prot instanceof UNICAST2) System.out.println(((UNICAST2) prot).printConnections()); else if (prot instanceof UNICAST3) System.out.println(((UNICAST3) prot).printConnections()); }