That worked - thanks. Matt
-----Original Message----- From: Vincent Massol [mailto:[EMAIL PROTECTED] Sent: Thursday, September 18, 2003 12:12 AM To: 'Cactus Users List' Subject: RE: Testing Listeners I've never used ServletContextListener but I've had a quick look and it looks easy to unit test. Let's take an example: public class MyListener implements ServletContextListener { public void contextDestroyed(ServletContextEvent sce) { [...] } public void contextInitialized(ServletContextEvent sce) { [...] } } Here's the test: public class MyListenerTest extends ServletTestCase { public void testXXX() { // setup ServletContextEvent sce = new ServletContextEvent(config.getServletContext()); MyListener listener = new MyListener(); // test listener.contextInitialized(sce); // asserts } } Now, what I don't know is whether you need the ServletContext in a given state or not? Is that the kind of test you want? -Vincent > -----Original Message----- > From: Matt Raible [mailto:[EMAIL PROTECTED] > Sent: 18 September 2003 04:22 > To: 'Cactus Users List' > Subject: Testing Listeners > > What is the recommended way to test Listeners with Cactus. I have a > StartupListener ... > > public class StartupListener implements ServletContextListener > > ... That talks to a database and reads a number of properties files - > and stuffs objects into the servlet context. I basically just need to > verify that the variables get set correctly. > > Thanks, > > Matt > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
