Anonymous avatar Anonymous committed 6dd3cca

Solved issue XW-714 - if no locale found in session and no locale specified in request parameters, use locale from browser

git-svn-id: http://svn.opensymphony.com/svn/xwork/trunk@2052 e221344d-f017-0410-9bd5-d282ab1896d7

Comments (0)

Files changed (2)

core/src/main/java/com/opensymphony/xwork2/interceptor/I18nInterceptor.java

                         if (locale != null && LOG.isDebugEnabled()) {
                             LOG.debug("applied invocation context locale=" + locale);
                         }
+                        storeInSession = false;
                     }
                 }
                 if (storeInSession) {

core/src/test/java/com/opensymphony/xwork2/interceptor/I18nInterceptorTest.java

 import com.opensymphony.xwork2.Action;
 import com.opensymphony.xwork2.ActionContext;
 import com.opensymphony.xwork2.SimpleFooAction;
+import com.opensymphony.xwork2.ActionInvocation;
 import com.opensymphony.xwork2.mock.MockActionInvocation;
 import junit.framework.TestCase;
 
 import java.util.HashMap;
 import java.util.Locale;
 import java.util.Map;
+import java.io.Serializable;
 
 /**
  * Unit test for I18nInterceptor.
 
     private I18nInterceptor interceptor;
     private ActionContext ac;
-    private Map params;
+    private Map<String, Serializable> params;
     private Map session;
-    private MockActionInvocation mai;
+    private ActionInvocation mai;
 
     public void testEmptyParamAndSession() throws Exception {
         interceptor.intercept(mai);
         interceptor.intercept(mai);
 
         Locale locale = (Locale) session.get(I18nInterceptor.DEFAULT_SESSION_ATTRIBUTE);
-        assertNotNull(locale); // should be stored here
+        assertNull(locale); // should not be stored here
+        locale = mai.getInvocationContext().getLocale();
         assertEquals(locale1, locale);
     }
 
     protected void setUp() throws Exception {
         interceptor = new I18nInterceptor();
         interceptor.init();
-        params = new HashMap();
+        params = new HashMap<String, Serializable>();
         session = new HashMap();
 
-        Map ctx = new HashMap();
+        Map<String, Object> ctx = new HashMap<String, Object>();
         ctx.put(ActionContext.PARAMETERS, params);
         ctx.put(ActionContext.SESSION, session);
         ac = new ActionContext(ctx);
 
         Action action = new SimpleFooAction();
         mai = new MockActionInvocation();
-        mai.setAction(action);
-        mai.setInvocationContext(ac);
+        ((MockActionInvocation) mai).setAction(action);
+        ((MockActionInvocation) mai).setInvocationContext(ac);
     }
 
     @Override
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.