Quantcast
Channel: Active questions tagged servlets - Stack Overflow
Viewing all articles
Browse latest Browse all 714

Testing email contact form with JWebUnit without sending the email

$
0
0

I have a Java web application built using servlet and JSP pages. I have written some integration tests using JWebUnit (http://jwebunit.sourceforge.net).

I have a test method like this:

@Testpublic void testContact() {beginAt("contact");assertResponseCode(200);assertFormPresent("form_contact");assertElementPresent("page_contact_form_uitleg");assertTextInElement("page_contact_form_uitleg", getMessage("pagina.contact.uitleg"));assertFormElementPresent("form_naam");assertFormElementPresent("form_email");assertFormElementPresent("form_boodschap");setTextField("form_email", "joel@craenhals.eu");setTextField("form_wachtwoord", "Joel1234!");}

However when I submit the form in the test method the email is sent out. Is there a way I can test this email functionality like there is in Rails? In Rails when you are in the test environment, the app is not sending out real emails. Instead it is adding those emails to some sort of test queue where you can check if the email would have been sent.

Can I use something like that in a Java web app?


Viewing all articles
Browse latest Browse all 714

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>