@Test
public void testClearSourceHandlers() throws UnknownHostException {

    InetAddress address = InetAddress.getByName("localhost");
    int port = 10213;
    String firstSource = "first";
    client = new FalseClient(firstSource);
    ConfigurableUDPSource.notificationHandlers.put(firstSource,
            new UDPNotificationHandler(new LinkedHashMap<>(), client));
    ConfigurableUDPSource.clients.put(firstSource, client);
    String secondSource = "second";
    client = new FalseClient(secondSource);
    ConfigurableUDPSource.notificationHandlers.put(secondSource,
            new UDPNotificationHandler(new LinkedHashMap<>(), client));
    ConfigurableUDPSource.clients.put(secondSource, client);
    
    assumeTrue("Cannot perform test. Address at port:" + port + " and IP:" + address + "already bound"
            , socketCanBind(port, address));             
    DatagramSocket socket = ConfigurableUDPSource.createUDPSocket(port, address, firstSource);
    ConfigurableUDPSource.listenOnUDPSocket(port, address, secondSource);
    
    assert ConfigurableUDPSource.udpSocketToSources.get(socket) instanceof List;
    List<String> l = (List) ConfigurableUDPSource.udpSocketToSources.get(socket);
    assert l.contains(firstSource);
    assert l.contains(secondSource);
    
    assert ConfigurableUDPSource.notificationHandlers.containsKey(firstSource);
    ConfigurableUDPSource.clearSourceHandlers(firstSource);
    l = (List) ConfigurableUDPSource.udpSocketToSources.get(socket);
    assert !l.contains(firstSource);
    assert l.contains(secondSource);
    assert !ConfigurableUDPSource.notificationHandlers.containsKey(firstSource);
    assert !socket.isClosed();
    
    assert ConfigurableUDPSource.notificationHandlers.containsKey(secondSource);
    ConfigurableUDPSource.clearSourceHandlers(secondSource);
    assert !ConfigurableUDPSource.udpSocketToSources.containsKey(socket);
    assert !ConfigurableUDPSource.notificationHandlers.containsKey(secondSource);
    assert socket.isClosed();
}