@Test public void testReceivingFromServer() throws UnknownHostException { assumeTrue(invalidAddress != null); InetAddress address = InetAddress.getByName("localhost"); int port = 10213; ConfigurableUDPSource.sourceAddresses.put(sourceName, ConfigurableUDPSource.ALL_ADDR); ConfigurableUDPSource.sourcePorts.put(sourceName, ConfigurableUDPSource.ALL_PORTS); assert ConfigurableUDPSource.receivingFromServer(sourceName, port, address); List<Object> l = new ArrayList<>(); l.add(123); ConfigurableUDPSource.sourcePorts.put(sourceName, l); assert !ConfigurableUDPSource.receivingFromServer(sourceName, port, address); l.add(port); ConfigurableUDPSource.sourcePorts.put(sourceName, l); assert ConfigurableUDPSource.receivingFromServer(sourceName, port, address); l = new ArrayList<>(); l.add(invalidAddress); ConfigurableUDPSource.sourceAddresses.put(sourceName, l); assert !ConfigurableUDPSource.receivingFromServer(sourceName, port, address); l.add(address); ConfigurableUDPSource.sourceAddresses.put(sourceName, l); assert ConfigurableUDPSource.receivingFromServer(sourceName, port, address); ConfigurableUDPSource.sourcePorts.put(sourceName, ConfigurableUDPSource.NO_PORTS); assert !ConfigurableUDPSource.receivingFromServer(sourceName, port, address); List<List> list = new ArrayList<>(); List<Object> subl = new ArrayList<>(); subl.add(invalidAddress); subl.add(port); list.add(subl); subl = new ArrayList<>(); subl.add(invalidAddress); subl.add(123); list.add(subl); subl = new ArrayList<>(); subl.add(address); subl.add(123); list.add(subl); ConfigurableUDPSource.sourceServers.put(sourceName, list); assert !ConfigurableUDPSource.receivingFromServer(sourceName, port, address); subl = new ArrayList<>(); subl.add(address); subl.add(port); list.add(subl); ConfigurableUDPSource.sourceServers.put(sourceName, list); assert ConfigurableUDPSource.receivingFromServer(sourceName, port, address); }
static boolean receivingFromServer(String sourceName, int port, InetAddress address) { return (matchesPort(sourceName, port) && matchesAddress(sourceName, address)) || matchesServer(sourceName, port, address); }
ConfigurableUDPSource { static boolean receivingFromServer(String sourceName, int port, InetAddress address) { return (matchesPort(sourceName, port) && matchesAddress(sourceName, address)) || matchesServer(sourceName, port, address); } }
ConfigurableUDPSource { static boolean receivingFromServer(String sourceName, int port, InetAddress address) { return (matchesPort(sourceName, port) && matchesAddress(sourceName, address)) || matchesServer(sourceName, port, address); }  }
ConfigurableUDPSource { static boolean receivingFromServer(String sourceName, int port, InetAddress address) { return (matchesPort(sourceName, port) && matchesAddress(sourceName, address)) || matchesServer(sourceName, port, address); }  static DatagramSocket createUDPSocket(int port, InetAddress address, String sourceName); static DatagramSocket listenOnUDPSocket(int port, InetAddress address, String sourceName); static void setNotificationHandler(UDPNotificationHandler handler, String sourceName, Map incoming); static void main(String[] args); static void sendFromDatagram(DatagramPacket packet, List<String> sources); }
ConfigurableUDPSource { static boolean receivingFromServer(String sourceName, int port, InetAddress address) { return (matchesPort(sourceName, port) && matchesAddress(sourceName, address)) || matchesServer(sourceName, port, address); }  static DatagramSocket createUDPSocket(int port, InetAddress address, String sourceName); static DatagramSocket listenOnUDPSocket(int port, InetAddress address, String sourceName); static void setNotificationHandler(UDPNotificationHandler handler, String sourceName, Map incoming); static void main(String[] args); static void sendFromDatagram(DatagramPacket packet, List<String> sources);  }