mardi 30 mai 2017

System Test for a Timer which sends Emails

I have a timer which I schedule to run once a week:

http://ift.tt/2qv7JMG

at the moment I annotate a method to achieve this.

This timer sends an email:

    Session session = Session.getInstance(props,
            new javax.mail.Authenticator() {
                protected PasswordAuthentication getPasswordAuthentication() {
                    return new PasswordAuthentication("", "");
                }
            }
    );

    MimeMessage message = Message.build(session, addresses);
    Transport.send(message);

I wish to write a system test for this. But how might I trigger my timer without having to wait a week? And how might I mock the smtp server?

I m using JBoss-EAP/7 but am new to this platform.

Aucun commentaire:

Enregistrer un commentaire