mercredi 28 octobre 2015

How to check if warning is correct

I have a function which catch exception and add warning messages in console. I need to create unit test which should verify if the message is as expected.

static int function(String hostname, int ktsPort, boolean sslInsecure) {
    int foundKtsPort = ktsPort;
    if (ktsPort < 0) {
        return checkForKTSPort(hostname, KeyTrusteeConstants.KTS_PORT, sslInsecure);
    } else {

        try {
            ....
            }
        } catch (IOException e) {
            if (e instanceof smth) {
                if (LOG.isWarnEnabled()) {
                    LOG.warn("SSL failure");
                }
            }
        }
}

Test should check if message "SSL failure" is present

I'm new in unit testing. So, maybe somebody have any idea how to do it. Thanks

Aucun commentaire:

Enregistrer un commentaire