HttpSessionEventPublisher now verifies that the ApplicationContext is not null
This commit is contained in:
@@ -20,10 +20,13 @@ import junit.framework.TestCase;
|
||||
import org.springframework.mock.web.MockServletContext;
|
||||
import org.springframework.mock.web.MockHttpSession;
|
||||
import org.springframework.web.context.support.StaticWebApplicationContext;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
|
||||
import javax.servlet.ServletContextEvent;
|
||||
import javax.servlet.http.HttpSessionEvent;
|
||||
|
||||
import net.sf.acegisecurity.MockApplicationContext;
|
||||
|
||||
|
||||
/**
|
||||
* The HttpSessionEventPublisher tests
|
||||
@@ -72,4 +75,22 @@ public class HttpSessionEventPublisherTests extends TestCase {
|
||||
|
||||
publisher.contextDestroyed(new ServletContextEvent(servletContext));
|
||||
}
|
||||
|
||||
public void testContext() throws Exception {
|
||||
HttpSessionEventPublisher pub = new HttpSessionEventPublisher();
|
||||
ConfigurableApplicationContext c = MockApplicationContext.getContext();
|
||||
pub.setContext(c);
|
||||
assertEquals(c, pub.getContext());
|
||||
}
|
||||
|
||||
public void testNullContextCheck() throws Exception {
|
||||
HttpSessionEventPublisher pub = new HttpSessionEventPublisher();
|
||||
|
||||
try {
|
||||
pub.getContext();
|
||||
fail("IllegalArgumentException expected, the context is null");
|
||||
} catch (IllegalArgumentException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user