You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by lu...@apache.org on 2014/08/13 11:07:15 UTC

[3/3] git commit: WW-4049 Removes Locale.setDefault() from tests

WW-4049 Removes Locale.setDefault() from tests


Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/d749bb8f
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/d749bb8f
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/d749bb8f

Branch: refs/heads/develop
Commit: d749bb8f7a4d7b0007e088385d8a0c9387d63618
Parents: 08ad119
Author: Lukasz Lenart <lu...@apache.org>
Authored: Wed Aug 13 11:06:40 2014 +0200
Committer: Lukasz Lenart <lu...@apache.org>
Committed: Wed Aug 13 11:06:40 2014 +0200

----------------------------------------------------------------------
 .../config/DefaultBeanSelectionProviderTest.java |  3 +--
 .../struts2/dispatcher/DispatcherTest.java       |  2 --
 .../OValValidationInterceptorTest.java           |  1 -
 xwork-core/pom.xml                               |  5 +++++
 .../xwork2/config/impl/DefaultConfiguration.java |  3 +++
 .../conversion/impl/DefaultTypeConverter.java    | 19 ++++++++++++++-----
 .../opensymphony/xwork2/ognl/OgnlUtilTest.java   | 10 ++--------
 .../xwork2/util/LocalizedTextUtilTest.java       |  7 -------
 .../xwork2/validator/DateRangeValidatorTest.java |  6 ------
 .../validator/DoubleRangeValidatorTest.java      | 12 ------------
 .../validator/SimpleActionValidationTest.java    |  9 ---------
 .../VisitorFieldValidatorModelTest.java          |  6 ------
 .../validator/VisitorFieldValidatorTest.java     |  5 -----
 .../validators/DateRangeFieldValidatorTest.java  | 12 ++----------
 xwork-core/src/test/resources/log4j.properties   | 13 +------------
 15 files changed, 28 insertions(+), 85 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts/blob/d749bb8f/core/src/test/java/org/apache/struts2/config/DefaultBeanSelectionProviderTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/struts2/config/DefaultBeanSelectionProviderTest.java b/core/src/test/java/org/apache/struts2/config/DefaultBeanSelectionProviderTest.java
index d0974d7..f7c4066 100644
--- a/core/src/test/java/org/apache/struts2/config/DefaultBeanSelectionProviderTest.java
+++ b/core/src/test/java/org/apache/struts2/config/DefaultBeanSelectionProviderTest.java
@@ -34,14 +34,13 @@ import junit.framework.TestCase;
 public class DefaultBeanSelectionProviderTest extends TestCase {
 
     public void testRegister() {
-        Locale.setDefault(Locale.US); // force to US locale as we also have _de and _da properties
-
         LocalizedTextUtil.clearDefaultResourceBundles();
         LocalizedTextUtil.addDefaultResourceBundle("org/apache/struts2/struts-messages");
         assertEquals("The form has already been processed or no token was supplied, please try again.", LocalizedTextUtil.findDefaultText("struts.messages.invalid.token", Locale.getDefault()));
         
         LocatableProperties props = new LocatableProperties();
         props.setProperty(StrutsConstants.STRUTS_CUSTOM_I18N_RESOURCES, "testmessages,testmessages2");
+        props.setProperty(StrutsConstants.STRUTS_LOCALE, "US");
         
         new DefaultBeanSelectionProvider().register(new ContainerBuilder(), props);
 

http://git-wip-us.apache.org/repos/asf/struts/blob/d749bb8f/core/src/test/java/org/apache/struts2/dispatcher/DispatcherTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/struts2/dispatcher/DispatcherTest.java b/core/src/test/java/org/apache/struts2/dispatcher/DispatcherTest.java
index 691657a..dffb09f 100644
--- a/core/src/test/java/org/apache/struts2/dispatcher/DispatcherTest.java
+++ b/core/src/test/java/org/apache/struts2/dispatcher/DispatcherTest.java
@@ -56,8 +56,6 @@ import java.util.Map;
 public class DispatcherTest extends StrutsInternalTestCase {
 
     public void testDefaultResurceBundlePropertyLoaded() throws Exception {
-        Locale.setDefault(Locale.US); // force to US locale as we also have _de and _da properties
-
         // some i18n messages from xwork-messages.properties
         assertEquals(
                 LocalizedTextUtil.findDefaultText("xwork.error.action.execution", Locale.US),

http://git-wip-us.apache.org/repos/asf/struts/blob/d749bb8f/plugins/oval/src/test/java/org/apache/struts2/oval/interceptor/OValValidationInterceptorTest.java
----------------------------------------------------------------------
diff --git a/plugins/oval/src/test/java/org/apache/struts2/oval/interceptor/OValValidationInterceptorTest.java b/plugins/oval/src/test/java/org/apache/struts2/oval/interceptor/OValValidationInterceptorTest.java
index 1e85d7c..5ab288a 100644
--- a/plugins/oval/src/test/java/org/apache/struts2/oval/interceptor/OValValidationInterceptorTest.java
+++ b/plugins/oval/src/test/java/org/apache/struts2/oval/interceptor/OValValidationInterceptorTest.java
@@ -319,7 +319,6 @@ public class OValValidationInterceptorTest extends XWorkTestCase {
 
     @Override
     protected void setUp() throws Exception {
-        Locale.setDefault(Locale.US);
         super.setUp();
         loadConfigurationProviders(new XmlConfigurationProvider("oval-test.xml"));
     }

http://git-wip-us.apache.org/repos/asf/struts/blob/d749bb8f/xwork-core/pom.xml
----------------------------------------------------------------------
diff --git a/xwork-core/pom.xml b/xwork-core/pom.xml
index a35ead4..d8fdc46 100644
--- a/xwork-core/pom.xml
+++ b/xwork-core/pom.xml
@@ -202,6 +202,11 @@
             <artifactId>easymock</artifactId>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>log4j</groupId>
+            <artifactId>log4j</artifactId>
+            <scope>test</scope>
+        </dependency>
 
         <!-- SLF4J support -->
         <dependency>

http://git-wip-us.apache.org/repos/asf/struts/blob/d749bb8f/xwork-core/src/main/java/com/opensymphony/xwork2/config/impl/DefaultConfiguration.java
----------------------------------------------------------------------
diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/config/impl/DefaultConfiguration.java b/xwork-core/src/main/java/com/opensymphony/xwork2/config/impl/DefaultConfiguration.java
index 0192729..57e7f97 100644
--- a/xwork-core/src/main/java/com/opensymphony/xwork2/config/impl/DefaultConfiguration.java
+++ b/xwork-core/src/main/java/com/opensymphony/xwork2/config/impl/DefaultConfiguration.java
@@ -16,9 +16,11 @@
 package com.opensymphony.xwork2.config.impl;
 
 import com.opensymphony.xwork2.ActionContext;
+import com.opensymphony.xwork2.DefaultLocaleProvider;
 import com.opensymphony.xwork2.DefaultTextProvider;
 import com.opensymphony.xwork2.FileManager;
 import com.opensymphony.xwork2.FileManagerFactory;
+import com.opensymphony.xwork2.LocaleProvider;
 import com.opensymphony.xwork2.ObjectFactory;
 import com.opensymphony.xwork2.TextProvider;
 import com.opensymphony.xwork2.XWorkConstants;
@@ -335,6 +337,7 @@ public class DefaultConfiguration implements Configuration {
 
         builder.factory(TextParser.class, OgnlTextParser.class, Scope.SINGLETON);
         builder.factory(TextProvider.class, "system", DefaultTextProvider.class, Scope.SINGLETON);
+        builder.factory(LocaleProvider.class, DefaultLocaleProvider.class, Scope.SINGLETON);
 
         builder.factory(ObjectTypeDeterminer.class, DefaultObjectTypeDeterminer.class, Scope.SINGLETON);
         builder.factory(PropertyAccessor.class, CompoundRoot.class.getName(), CompoundRootAccessor.class, Scope.SINGLETON);

http://git-wip-us.apache.org/repos/asf/struts/blob/d749bb8f/xwork-core/src/main/java/com/opensymphony/xwork2/conversion/impl/DefaultTypeConverter.java
----------------------------------------------------------------------
diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/conversion/impl/DefaultTypeConverter.java b/xwork-core/src/main/java/com/opensymphony/xwork2/conversion/impl/DefaultTypeConverter.java
index b1342cd..e3363c2 100644
--- a/xwork-core/src/main/java/com/opensymphony/xwork2/conversion/impl/DefaultTypeConverter.java
+++ b/xwork-core/src/main/java/com/opensymphony/xwork2/conversion/impl/DefaultTypeConverter.java
@@ -31,7 +31,9 @@
 package com.opensymphony.xwork2.conversion.impl;
 
 import com.opensymphony.xwork2.ActionContext;
+import com.opensymphony.xwork2.LocaleProvider;
 import com.opensymphony.xwork2.conversion.TypeConverter;
+import com.opensymphony.xwork2.inject.Inject;
 import com.opensymphony.xwork2.ognl.XWorkTypeConverterWrapper;
 
 import java.lang.reflect.Array;
@@ -50,7 +52,7 @@ import java.util.Map;
  * @author Luke Blanshard (blanshlu@netscape.net)
  * @author Drew Davidson (drew@ognl.org)
  */
-public class DefaultTypeConverter implements TypeConverter {
+public abstract class DefaultTypeConverter implements TypeConverter {
 
     protected static String MILLISECOND_FORMAT = ".SSS";
 
@@ -58,6 +60,8 @@ public class DefaultTypeConverter implements TypeConverter {
 
     private static final Map<Class, Object> primitiveDefaults;
 
+    private LocaleProvider localeProvider;
+
     static {
         Map<Class, Object> map = new HashMap<Class, Object>();
         map.put(Boolean.TYPE, Boolean.FALSE);
@@ -73,6 +77,11 @@ public class DefaultTypeConverter implements TypeConverter {
         primitiveDefaults = Collections.unmodifiableMap(map);
     }
 
+    @Inject
+    public void setLocaleProvider(LocaleProvider localeProvider) {
+        this.localeProvider = localeProvider;
+    }
+
     public Object convertValue(Map<String, Object> context, Object value, Class toType) {
         return convertValue(value, toType);
     }
@@ -332,12 +341,12 @@ public class DefaultTypeConverter implements TypeConverter {
     }
 
     protected Locale getLocale(Map<String, Object> context) {
-        if (context == null) {
-            return Locale.getDefault();
+        Locale locale = null;
+        if (context != null) {
+            locale = (Locale) context.get(ActionContext.LOCALE);
         }
-        Locale locale = (Locale) context.get(ActionContext.LOCALE);
         if (locale == null) {
-            locale = Locale.getDefault();
+            locale = localeProvider.getLocale();
         }
         return locale;
     }

http://git-wip-us.apache.org/repos/asf/struts/blob/d749bb8f/xwork-core/src/test/java/com/opensymphony/xwork2/ognl/OgnlUtilTest.java
----------------------------------------------------------------------
diff --git a/xwork-core/src/test/java/com/opensymphony/xwork2/ognl/OgnlUtilTest.java b/xwork-core/src/test/java/com/opensymphony/xwork2/ognl/OgnlUtilTest.java
index e8733d6..6726af6 100644
--- a/xwork-core/src/test/java/com/opensymphony/xwork2/ognl/OgnlUtilTest.java
+++ b/xwork-core/src/test/java/com/opensymphony/xwork2/ognl/OgnlUtilTest.java
@@ -333,9 +333,6 @@ public class OgnlUtilTest extends XWorkTestCase {
     }
 
     public void testSetPropertiesDate() {
-        Locale orig = Locale.getDefault();
-        Locale.setDefault(Locale.US);
-
         Foo foo = new Foo();
 
         Map context = ognlUtil.createDefaultContext(foo);
@@ -353,10 +350,11 @@ public class OgnlUtilTest extends XWorkTestCase {
 
         assertEquals(cal.getTime(), foo.getBirthday());
         
-        Locale.setDefault(Locale.UK);
         //UK style test
         props.put("event", "18/10/2006 14:23:45");
         props.put("meeting", "09/09/2006 14:30");
+        context.put(ActionContext.LOCALE, Locale.UK);
+
         ognlUtil.setProperties(props, foo, context);
         
         cal = Calendar.getInstance();
@@ -380,10 +378,6 @@ public class OgnlUtilTest extends XWorkTestCase {
         
         assertEquals(cal.getTime(), foo.getMeeting());
         
-        Locale.setDefault(orig);
-         
-        Locale.setDefault(orig);
-        
         //test RFC 3339 date format for JSON
         props.put("event", "1996-12-19T16:39:57Z");
         ognlUtil.setProperties(props, foo, context);

http://git-wip-us.apache.org/repos/asf/struts/blob/d749bb8f/xwork-core/src/test/java/com/opensymphony/xwork2/util/LocalizedTextUtilTest.java
----------------------------------------------------------------------
diff --git a/xwork-core/src/test/java/com/opensymphony/xwork2/util/LocalizedTextUtilTest.java b/xwork-core/src/test/java/com/opensymphony/xwork2/util/LocalizedTextUtilTest.java
index bac41ba..540b89d 100644
--- a/xwork-core/src/test/java/com/opensymphony/xwork2/util/LocalizedTextUtilTest.java
+++ b/xwork-core/src/test/java/com/opensymphony/xwork2/util/LocalizedTextUtilTest.java
@@ -223,17 +223,10 @@ public class LocalizedTextUtilTest extends XWorkTestCase {
         // Before this fix loading the bundle for Germany failed since Italy have previously failed and thus the misses cache
         // contained a false entry
 
-        // Set default Locale to Locale.US
-        Locale defaultLocale = Locale.getDefault();
-        Locale.setDefault(Locale.US);
-
         ResourceBundle rbFrance = LocalizedTextUtil.findResourceBundle("com/opensymphony/xwork2/util/XW404", Locale.FRANCE);
         ResourceBundle rbItaly = LocalizedTextUtil.findResourceBundle("com/opensymphony/xwork2/util/XW404", Locale.ITALY);
         ResourceBundle rbGermany = LocalizedTextUtil.findResourceBundle("com/opensymphony/xwork2/util/XW404", Locale.GERMANY);
 
-        // Reset to previous default Locale 
-        Locale.setDefault(defaultLocale);
-
         assertNotNull(rbFrance);
         assertEquals("Bonjour", rbFrance.getString("hello"));
 

http://git-wip-us.apache.org/repos/asf/struts/blob/d749bb8f/xwork-core/src/test/java/com/opensymphony/xwork2/validator/DateRangeValidatorTest.java
----------------------------------------------------------------------
diff --git a/xwork-core/src/test/java/com/opensymphony/xwork2/validator/DateRangeValidatorTest.java b/xwork-core/src/test/java/com/opensymphony/xwork2/validator/DateRangeValidatorTest.java
index 2c8de2c..316f414 100644
--- a/xwork-core/src/test/java/com/opensymphony/xwork2/validator/DateRangeValidatorTest.java
+++ b/xwork-core/src/test/java/com/opensymphony/xwork2/validator/DateRangeValidatorTest.java
@@ -38,9 +38,6 @@ import java.util.Map;
  */
 public class DateRangeValidatorTest extends XWorkTestCase {
 
-    private Locale origLocale;
-
-
     /**
      * Tests whether the date range validation is working. Should produce an validation error,
      * because the action config sets date to 12/20/2002 while expected range is Dec 22-25.
@@ -81,14 +78,11 @@ public class DateRangeValidatorTest extends XWorkTestCase {
     @Override
     protected void setUp() throws Exception {
         super.setUp();
-        origLocale = Locale.getDefault();
-        Locale.setDefault(Locale.US);
         loadConfigurationProviders(new MockConfigurationProvider());
     }
 
     @Override
     protected void tearDown() throws Exception {
         super.tearDown();
-        Locale.setDefault(origLocale);
     }
 }

http://git-wip-us.apache.org/repos/asf/struts/blob/d749bb8f/xwork-core/src/test/java/com/opensymphony/xwork2/validator/DoubleRangeValidatorTest.java
----------------------------------------------------------------------
diff --git a/xwork-core/src/test/java/com/opensymphony/xwork2/validator/DoubleRangeValidatorTest.java b/xwork-core/src/test/java/com/opensymphony/xwork2/validator/DoubleRangeValidatorTest.java
index b6fa06b..2a07e0b 100644
--- a/xwork-core/src/test/java/com/opensymphony/xwork2/validator/DoubleRangeValidatorTest.java
+++ b/xwork-core/src/test/java/com/opensymphony/xwork2/validator/DoubleRangeValidatorTest.java
@@ -29,10 +29,6 @@ public class DoubleRangeValidatorTest extends XWorkTestCase {
         params.put("percentage", 100.0123d);
         context.put(ActionContext.PARAMETERS, params);
 
-        // must set a locale to US as error message contains a locale dependent number (see XW-490)
-        Locale defLocale = Locale.getDefault();
-        Locale.setDefault(Locale.US);
-        
         ActionProxy proxy = actionProxyFactory.createActionProxy("", MockConfigurationProvider.VALIDATION_ACTION_NAME, context);
         proxy.execute();
         assertTrue(((ValidationAware) proxy.getAction()).hasFieldErrors());
@@ -46,8 +42,6 @@ public class DoubleRangeValidatorTest extends XWorkTestCase {
         String errorMessage = errorMessages.get(0);
         assertNotNull("Expecting: percentage must be between 0.1 and 10.1, current value is 100.0123.", errorMessage);
         assertEquals("percentage must be between 0.1 and 10.1, current value is 100.0123.", errorMessage);
-
-        Locale.setDefault(defLocale);
     }
 
     public void testRangeValidationNoError() throws Exception {
@@ -193,10 +187,6 @@ public class DoubleRangeValidatorTest extends XWorkTestCase {
         params.put("percentage", 100.0123d);
         context.put(ActionContext.PARAMETERS, params);
 
-        // must set a locale to US as error message contains a locale dependent number (see XW-490)
-        Locale defLocale = Locale.getDefault();
-        Locale.setDefault(Locale.US);
-
         ActionProxy proxy = actionProxyFactory.createActionProxy("", MockConfigurationProvider.EXPRESSION_VALIDATION_ACTION, context);
         proxy.execute();
         assertTrue(((ValidationAware) proxy.getAction()).hasFieldErrors());
@@ -209,8 +199,6 @@ public class DoubleRangeValidatorTest extends XWorkTestCase {
         String errorMessage = errorMessages.get(0);
         assertNotNull("Expecting: percentage must be between 0.1 and 10.1, current value is 100.0123.", errorMessage);
         assertEquals("percentage must be between 0.1 and 10.1, current value is 100.0123.", errorMessage);
-
-        Locale.setDefault(defLocale);
     }
 
     public void testExpressionParams() throws Exception {

http://git-wip-us.apache.org/repos/asf/struts/blob/d749bb8f/xwork-core/src/test/java/com/opensymphony/xwork2/validator/SimpleActionValidationTest.java
----------------------------------------------------------------------
diff --git a/xwork-core/src/test/java/com/opensymphony/xwork2/validator/SimpleActionValidationTest.java b/xwork-core/src/test/java/com/opensymphony/xwork2/validator/SimpleActionValidationTest.java
index 51309e0..c511a64 100644
--- a/xwork-core/src/test/java/com/opensymphony/xwork2/validator/SimpleActionValidationTest.java
+++ b/xwork-core/src/test/java/com/opensymphony/xwork2/validator/SimpleActionValidationTest.java
@@ -33,9 +33,6 @@ import java.util.*;
  */
 public class SimpleActionValidationTest extends XWorkTestCase {
 
-    private Locale origLocale;
-
-
     public void testAliasValidation() {
         HashMap<String, Object> params = new HashMap<String, Object>();
         params.put("baz", "10");
@@ -225,16 +222,10 @@ public class SimpleActionValidationTest extends XWorkTestCase {
     @Override
     protected void setUp() throws Exception {
         super.setUp();
-        origLocale = Locale.getDefault();
-        Locale.setDefault(Locale.US);
 
         XmlConfigurationProvider provider = new XmlConfigurationProvider("xwork-test-beans.xml");
         container.inject(provider);
         loadConfigurationProviders(provider, new MockConfigurationProvider());
     }
 
-    @Override
-    protected void tearDown() throws Exception {
-        Locale.setDefault(origLocale);
-    }
 }

http://git-wip-us.apache.org/repos/asf/struts/blob/d749bb8f/xwork-core/src/test/java/com/opensymphony/xwork2/validator/VisitorFieldValidatorModelTest.java
----------------------------------------------------------------------
diff --git a/xwork-core/src/test/java/com/opensymphony/xwork2/validator/VisitorFieldValidatorModelTest.java b/xwork-core/src/test/java/com/opensymphony/xwork2/validator/VisitorFieldValidatorModelTest.java
index 34a7806..22488b2 100644
--- a/xwork-core/src/test/java/com/opensymphony/xwork2/validator/VisitorFieldValidatorModelTest.java
+++ b/xwork-core/src/test/java/com/opensymphony/xwork2/validator/VisitorFieldValidatorModelTest.java
@@ -33,15 +33,10 @@ import org.easymock.EasyMock;
 public class VisitorFieldValidatorModelTest extends XWorkTestCase {
 
     protected VisitorValidatorModelAction action;
-    private Locale origLocale;
-
 
     @Override
     public void setUp() throws Exception {
         super.setUp();
-        origLocale = Locale.getDefault();
-        Locale.setDefault(Locale.US);
-
         action = new VisitorValidatorModelAction();
 
         TestBean bean = action.getBean();
@@ -125,6 +120,5 @@ public class VisitorFieldValidatorModelTest extends XWorkTestCase {
     protected void tearDown() throws Exception {
         super.tearDown();
         ActionContext.setContext(null);
-        Locale.setDefault(origLocale);
     }
 }

http://git-wip-us.apache.org/repos/asf/struts/blob/d749bb8f/xwork-core/src/test/java/com/opensymphony/xwork2/validator/VisitorFieldValidatorTest.java
----------------------------------------------------------------------
diff --git a/xwork-core/src/test/java/com/opensymphony/xwork2/validator/VisitorFieldValidatorTest.java b/xwork-core/src/test/java/com/opensymphony/xwork2/validator/VisitorFieldValidatorTest.java
index ad5c1b6..3073d6a 100644
--- a/xwork-core/src/test/java/com/opensymphony/xwork2/validator/VisitorFieldValidatorTest.java
+++ b/xwork-core/src/test/java/com/opensymphony/xwork2/validator/VisitorFieldValidatorTest.java
@@ -34,14 +34,10 @@ import org.easymock.IAnswer;
 public class VisitorFieldValidatorTest extends XWorkTestCase {
 
     protected VisitorValidatorTestAction action;
-    private Locale origLocale;
-
 
     @Override
     public void setUp() throws Exception {
         super.setUp();
-        origLocale = Locale.getDefault();
-        Locale.setDefault(Locale.US);
 
         action = new VisitorValidatorTestAction();
 
@@ -209,7 +205,6 @@ public class VisitorFieldValidatorTest extends XWorkTestCase {
     protected void tearDown() throws Exception {
         super.tearDown();
         ActionContext.setContext(null);
-        Locale.setDefault(origLocale);
     }
 
     private void validate(String context) throws ValidationException {

http://git-wip-us.apache.org/repos/asf/struts/blob/d749bb8f/xwork-core/src/test/java/com/opensymphony/xwork2/validator/validators/DateRangeFieldValidatorTest.java
----------------------------------------------------------------------
diff --git a/xwork-core/src/test/java/com/opensymphony/xwork2/validator/validators/DateRangeFieldValidatorTest.java b/xwork-core/src/test/java/com/opensymphony/xwork2/validator/validators/DateRangeFieldValidatorTest.java
index 2e7dd22..9103169 100644
--- a/xwork-core/src/test/java/com/opensymphony/xwork2/validator/validators/DateRangeFieldValidatorTest.java
+++ b/xwork-core/src/test/java/com/opensymphony/xwork2/validator/validators/DateRangeFieldValidatorTest.java
@@ -1,5 +1,6 @@
 package com.opensymphony.xwork2.validator.validators;
 
+import com.opensymphony.xwork2.ActionContext;
 import com.opensymphony.xwork2.XWorkTestCase;
 import com.opensymphony.xwork2.util.ValueStack;
 import com.opensymphony.xwork2.util.ValueStackFactory;
@@ -12,8 +13,6 @@ import java.util.Locale;
 
 public class DateRangeFieldValidatorTest extends XWorkTestCase {
 
-    private Locale copy;
-
     public void testPassValidation() throws Exception {
         // given
         ValidationAction action = prepareAction(createDate(2013, 6, 6));
@@ -88,14 +87,7 @@ public class DateRangeFieldValidatorTest extends XWorkTestCase {
     @Override
     public void setUp() throws Exception {
         super.setUp();
-        copy = Locale.getDefault();
-        Locale.setDefault(new Locale("DE"));
-    }
-
-    @Override
-    public void tearDown() throws Exception {
-        super.tearDown();
-        Locale.setDefault(copy);
+        ActionContext.getContext().setLocale(new Locale("DE"));
     }
 
 }

http://git-wip-us.apache.org/repos/asf/struts/blob/d749bb8f/xwork-core/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/xwork-core/src/test/resources/log4j.properties b/xwork-core/src/test/resources/log4j.properties
index 89cf0df..cd27a6c 100644
--- a/xwork-core/src/test/resources/log4j.properties
+++ b/xwork-core/src/test/resources/log4j.properties
@@ -1,17 +1,6 @@
-log4j.rootLogger = WARN, stdout
+log4j.rootLogger = INFO, stdout
 
 log4j.appender.stdout = org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.Threshold = WARN
 log4j.appender.stdout.Target   = System.out
 log4j.appender.stdout.layout = org.apache.log4j.PatternLayout
 log4j.appender.stdout.layout.ConversionPattern = %d{ISO8601} %-5p [%F:%L] : %m%n
-
-# set to info to let the code be executed when doing unit test for this interceptor
-log4j.category.com.opensymphony.xwork2.interceptor.LoggingInterceptor=INFO
-log4j.category.com.opensymphony.xwork2.interceptor.TimerInterceptor=INFO
-
-# set to debug to let the code be executed when doing unit test for this interceptor
-log4j.category.com.opensymphony.xwork2.interceptor.ParametersInterceptor=DEBUG
-
-# set to debug for testing timer interceptor with custom log category
-log4j.category.com.mycompany.myapp.actiontiming=DEBUG