String message = complexDispatcherPortlet.getPortletApplicationContext().getMessage("test.args", args, Locale.ENGLISH);
assertEquals("test this and that", message);
}
public void testPortletApplicationContextLookup() {
MockPortletContext portletContext = new MockPortletContext();
ApplicationContext ac = PortletApplicationContextUtils.getWebApplicationContext(portletContext);
assertNull(ac);
try {
ac = PortletApplicationContextUtils.getRequiredWebApplicationContext(portletContext);
fail("Should have thrown IllegalStateException");
}
catch (IllegalStateException ex) {
// expected
}
portletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE,
new StaticWebApplicationContext());
try {
ac = PortletApplicationContextUtils.getRequiredWebApplicationContext(portletContext);
assertNotNull(ac);
}