mirror of
https://github.com/apache/struts.git
synced 2026-08-11 01:27:14 +00:00
test no session but with locale parameter
See also WW-4741
This commit is contained in:
@@ -281,7 +281,6 @@ public class I18nInterceptor extends AbstractInterceptor {
|
||||
|
||||
@Override
|
||||
public Locale store(ActionInvocation invocation, Locale locale) {
|
||||
LOG.debug("Do not create session if it doesn't exist");
|
||||
HttpSession session = ServletActionContext.getRequest().getSession(false);
|
||||
|
||||
if (session != null) {
|
||||
@@ -289,6 +288,8 @@ public class I18nInterceptor extends AbstractInterceptor {
|
||||
synchronized (sessionId.intern()) {
|
||||
invocation.getInvocationContext().getSession().put(attributeName, locale);
|
||||
}
|
||||
} else {
|
||||
LOG.debug("session creation avoided as it doesn't exist already");
|
||||
}
|
||||
|
||||
return locale;
|
||||
|
||||
@@ -52,7 +52,7 @@ public class I18nInterceptorTest extends TestCase {
|
||||
interceptor.intercept(mai);
|
||||
}
|
||||
|
||||
public void testNoSession() throws Exception {
|
||||
public void testNoSessionNoLocale() throws Exception {
|
||||
request.setSession(null);
|
||||
try {
|
||||
interceptor.intercept(mai);
|
||||
@@ -60,6 +60,25 @@ public class I18nInterceptorTest extends TestCase {
|
||||
} catch (Exception ignore) {
|
||||
fail("Shouldn't throw any exception!");
|
||||
}
|
||||
|
||||
assertFalse(mai.getInvocationContext().getParameters().get(I18nInterceptor.DEFAULT_PARAMETER).isDefined()); // should have been removed
|
||||
|
||||
assertNull(session.get(I18nInterceptor.DEFAULT_SESSION_ATTRIBUTE)); // should not be stored here
|
||||
}
|
||||
|
||||
public void testNoSessionButLocale() throws Exception {
|
||||
prepare(I18nInterceptor.DEFAULT_PARAMETER, "da_DK"); //prevents shouldStore to being false
|
||||
request.setSession(null);
|
||||
try {
|
||||
interceptor.intercept(mai);
|
||||
assertTrue(true);
|
||||
} catch (Exception ignore) {
|
||||
fail("Shouldn't throw any exception!");
|
||||
}
|
||||
|
||||
assertFalse(mai.getInvocationContext().getParameters().get(I18nInterceptor.DEFAULT_PARAMETER).isDefined()); // should have been removed
|
||||
|
||||
assertNull(session.get(I18nInterceptor.DEFAULT_SESSION_ATTRIBUTE)); // should not be stored here
|
||||
}
|
||||
|
||||
public void testDefaultLocale() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user