lundi 30 mai 2016

JUnit exceptions handling testing

I am trying to test the next exception, but I don't know how to throw the exception from JUnit, because is a internal exception of the method.

public boolean suscribirADato(int idDato) {
        InetAddress ip = null;
        boolean adecuadamenteSuscrito = false;

        try {
            ip = InetAddress.getByName(ipMulticast.get(idDato));
            grupoMulticast.set(idDato, ip);
            conexion.joinGroup(grupoMulticast.get(idDato));
            adecuadamenteSuscrito = true;
        } catch (IOException e) {
            LOGGER.info(e.getMessage());
        }
        return adecuadamenteSuscrito;
    }

Aucun commentaire:

Enregistrer un commentaire