HttpSessionEventPublisher now verifies that the ApplicationContext is not null

This commit is contained in:
Ray Krueger
2005-05-02 20:31:18 +00:00
parent e2b7b785e1
commit 47989c11bd
2 changed files with 31 additions and 2 deletions

View File

@@ -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();
}
}
}