SocketNetwork implements CloseableNetwork { @Override public void send(int partyId, byte[] data) { if (partyId == conf.getMyId()) { this.selfQueue.add(data); } else { inRange(partyId); if (!senders.get(partyId).isRunning()) { throw new RuntimeException( "P" + conf.getMyId() + ": Unable to send to P" + partyId + ". Sender not running"); } this.senders.get(partyId).queueMessage(data); } } SocketNetwork(NetworkConfiguration conf, Map<Integer, Socket> socketMap);  SocketNetwork(NetworkConfiguration conf); @Override void send(int partyId, byte[] data); @Override byte[] receive(final int partyId); @Override void close(); @Override int getNoOfParties();  }
@Test(expected = RuntimeException.class) public void testStoppedSender() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { networks = createNetworks(2); Field f1 = networks.get(1).getClass().getDeclaredField("senders"); f1.setAccessible(true); @SuppressWarnings("unchecked") Sender sender = ((HashMap<Integer, Sender>) f1.get(networks.get(1))).get(2); sender.stop(); networks.get(1).send(2, new byte[] { 0x01 }); f1.setAccessible(false); }