struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukaszlen...@apache.org
Subject [20/24] struts git commit: Renames LocalizedTextUtil into DefaultLocalizedTextProvider
Date Tue, 14 Mar 2017 18:36:13 GMT
http://git-wip-us.apache.org/repos/asf/struts/blob/008c28ac/core/src/main/java/com/opensymphony/xwork2/util/LocalizedTextUtil.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/com/opensymphony/xwork2/util/LocalizedTextUtil.java b/core/src/main/java/com/opensymphony/xwork2/util/LocalizedTextUtil.java
deleted file mode 100644
index 8fb9e00..0000000
--- a/core/src/main/java/com/opensymphony/xwork2/util/LocalizedTextUtil.java
+++ /dev/null
@@ -1,1035 +0,0 @@
-/*
- * $Id$
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package com.opensymphony.xwork2.util;
-
-import com.opensymphony.xwork2.ActionContext;
-import com.opensymphony.xwork2.ActionInvocation;
-import com.opensymphony.xwork2.LocalizedTextProvider;
-import com.opensymphony.xwork2.ModelDriven;
-import com.opensymphony.xwork2.conversion.impl.XWorkConverter;
-import com.opensymphony.xwork2.inject.Inject;
-import com.opensymphony.xwork2.util.reflection.ReflectionProviderFactory;
-import org.apache.commons.lang3.ObjectUtils;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.apache.struts2.StrutsConstants;
-
-import java.beans.PropertyDescriptor;
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.text.MessageFormat;
-import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-
-/**
- * Provides support for localization in XWork.
- *
- * <!-- START SNIPPET: searchorder -->
- * <p>Resource bundles are searched in the following order:</p>
- *
- * <ol>
- * <li>ActionClass.properties</li>
- * <li>Interface.properties (every interface and sub-interface)</li>
- * <li>BaseClass.properties (all the way to Object.properties)</li>
- * <li>ModelDriven's model (if implements ModelDriven), for the model object repeat from 1</li>
- * <li>package.properties (of the directory where class is located and every parent directory all the way to the root directory)</li>
- * <li>search up the i18n message key hierarchy itself</li>
- * <li>global resource properties</li>
- * </ol>
- *
- * <!-- END SNIPPET: searchorder -->
- *
- * <!-- START SNIPPET: packagenote -->
- * <p>To clarify #5, while traversing the package hierarchy, Struts 2 will look for a file package.properties:</p>
- * com/<br>
- * &nbsp; acme/<br>
- * &nbsp; &nbsp; package.properties<br>
- * &nbsp; &nbsp; actions/<br>
- * &nbsp; &nbsp; &nbsp; package.properties<br>
- * &nbsp; &nbsp; &nbsp; FooAction.java<br>
- * &nbsp; &nbsp; &nbsp; FooAction.properties<br>
- * <p>
- * If FooAction.properties does not exist, com/acme/action/package.properties will be searched for, if
- * not found com/acme/package.properties, if not found com/package.properties, etc.
- * </p>
- * <!-- END SNIPPET: packagenote -->
- *
- * <!-- START SNIPPET: globalresource -->
- * <p>
- * A global resource bundle could be specified programmatically, as well as the locale.
- * </p>
- * <!-- END SNIPPET: globalresource -->
- *
- * @author Jason Carreira
- * @author Mark Woon
- * @author Rainer Hermanns
- * @author tm_jee
- */
-public class LocalizedTextUtil implements LocalizedTextProvider {
-
-    private static final Logger LOG = LogManager.getLogger(LocalizedTextUtil.class);
-
-    private static final String TOMCAT_RESOURCE_ENTRIES_FIELD = "resourceEntries";
-
-    private final ConcurrentMap<Integer, List<String>> classLoaderMap = new ConcurrentHashMap<>();
-
-    private boolean reloadBundles = false;
-    private boolean devMode = false;
-
-    private final ConcurrentMap<String, ResourceBundle> bundlesMap = new ConcurrentHashMap<>();
-    private final ConcurrentMap<MessageFormatKey, MessageFormat> messageFormats = new ConcurrentHashMap<>();
-    private final ConcurrentMap<Integer, ClassLoader> delegatedClassLoaderMap = new ConcurrentHashMap<>();
-    private final Set<String> missingBundles = Collections.synchronizedSet(new HashSet<String>());
-
-    private final String RELOADED = "com.opensymphony.xwork2.util.LocalizedTextUtil.reloaded";
-    private final String XWORK_MESSAGES_BUNDLE = "com/opensymphony/xwork2/xwork-messages";
-
-    /**
-     * Clears the internal list of resource bundles.
-     *
-     * @deprecated used only in tests
-     */
-    @Deprecated
-    public static void clearDefaultResourceBundles() {
-        // no-op
-    }
-
-    public LocalizedTextUtil() {
-        addDefaultResourceBundle("org/apache/struts2/struts-messages");
-    }
-
-    /**
-     * Should resorce bundles be reloaded.
-     *
-     * @param reloadBundles reload bundles?
-     */
-    @Inject(value = StrutsConstants.STRUTS_I18N_RELOAD, required = false)
-    public void setReloadBundles(String reloadBundles) {
-        this.reloadBundles = Boolean.parseBoolean(reloadBundles);
-    }
-
-    @Inject(value = StrutsConstants.STRUTS_DEVMODE, required = false)
-    public void setDevMode(String devMode) {
-        this.devMode = Boolean.parseBoolean(devMode);
-    }
-
-    @Inject(value = StrutsConstants.STRUTS_CUSTOM_I18N_RESOURCES, required = false)
-    public void setCustomI18NBundles(String bundles) {
-        if (bundles != null && bundles.length() > 0) {
-            StringTokenizer customBundles = new StringTokenizer(bundles, ", ");
-
-            while (customBundles.hasMoreTokens()) {
-                String name = customBundles.nextToken();
-                try {
-                    LOG.trace("Loading global messages from [{}]", name);
-                    addDefaultResourceBundle(name);
-                } catch (Exception e) {
-                    LOG.error("Could not find messages file {}.properties. Skipping", name);
-                }
-            }
-        }
-    }
-
-    /**
-     * Add's the bundle to the internal list of default bundles.
-     * <p>
-     * If the bundle already exists in the list it will be readded.
-     * </p>
-     *
-     * @param resourceBundleName the name of the bundle to add.
-     */
-    @Override
-    public void addDefaultResourceBundle(String resourceBundleName) {
-        //make sure this doesn't get added more than once
-        final ClassLoader ccl = getCurrentThreadContextClassLoader();
-        synchronized (XWORK_MESSAGES_BUNDLE) {
-            List<String> bundles = classLoaderMap.get(ccl.hashCode());
-            if (bundles == null) {
-                bundles = new CopyOnWriteArrayList<>();
-                bundles.add(XWORK_MESSAGES_BUNDLE);
-                classLoaderMap.put(ccl.hashCode(), bundles);
-            }
-            bundles.remove(resourceBundleName);
-            bundles.add(0, resourceBundleName);
-        }
-
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("Added default resource bundle '{}' to default resource bundles for the following classloader '{}'", resourceBundleName, ccl.toString());
-        }
-    }
-
-    /**
-     * Builds a {@link java.util.Locale} from a String of the form en_US_foo into a Locale
-     * with language "en", country "US" and variant "foo". This will parse the output of
-     * {@link java.util.Locale#toString()}.
-     *
-     * @param localeStr     The locale String to parse.
-     * @param defaultLocale The locale to use if localeStr is <tt>null</tt>.
-     * @return requested Locale
-     */
-    public static Locale localeFromString(String localeStr, Locale defaultLocale) {
-        if ((localeStr == null) || (localeStr.trim().length() == 0) || ("_".equals(localeStr))) {
-            if (defaultLocale != null) {
-                return defaultLocale;
-            }
-            return Locale.getDefault();
-        }
-
-        int index = localeStr.indexOf('_');
-        if (index < 0) {
-            return new Locale(localeStr);
-        }
-
-        String language = localeStr.substring(0, index);
-        if (index == localeStr.length()) {
-            return new Locale(language);
-        }
-
-        localeStr = localeStr.substring(index + 1);
-        index = localeStr.indexOf('_');
-        if (index < 0) {
-            return new Locale(language, localeStr);
-        }
-
-        String country = localeStr.substring(0, index);
-        if (index == localeStr.length()) {
-            return new Locale(language, country);
-        }
-
-        localeStr = localeStr.substring(index + 1);
-        return new Locale(language, country, localeStr);
-    }
-
-    /**
-     * Returns a localized message for the specified key, aTextName.  Neither the key nor the
-     * message is evaluated.
-     *
-     * @param aTextName the message key
-     * @param locale    the locale the message should be for
-     * @return a localized message based on the specified key, or null if no localized message can be found for it
-     */
-    @Override
-    public String findDefaultText(String aTextName, Locale locale) {
-        List<String> localList = classLoaderMap.get(Thread.currentThread().getContextClassLoader().hashCode());
-
-        for (String bundleName : localList) {
-            ResourceBundle bundle = findResourceBundle(bundleName, locale);
-            if (bundle != null) {
-                reloadBundles();
-                try {
-                    return bundle.getString(aTextName);
-                } catch (MissingResourceException e) {
-                	// will be logged when not found in any bundle
-                }
-            }
-        }
-
-        if (devMode) {
-            LOG.warn("Missing key [{}] in bundles [{}]!", aTextName, localList);
-        } else {
-            LOG.debug("Missing key [{}] in bundles [{}]!", aTextName, localList);
-        }
-
-        return null;
-    }
-
-    /**
-     * Returns a localized message for the specified key, aTextName, substituting variables from the
-     * array of params into the message.  Neither the key nor the message is evaluated.
-     *
-     * @param aTextName the message key
-     * @param locale    the locale the message should be for
-     * @param params    an array of objects to be substituted into the message text
-     * @return A formatted message based on the specified key, or null if no localized message can be found for it
-     */
-    @Override
-    public String findDefaultText(String aTextName, Locale locale, Object[] params) {
-        String defaultText = findDefaultText(aTextName, locale);
-        if (defaultText != null) {
-            MessageFormat mf = buildMessageFormat(defaultText, locale);
-            return formatWithNullDetection(mf, params);
-        }
-        return null;
-    }
-
-    /**
-     * Finds the given resource bundle by it's name.
-     * <p>
-     * Will use <code>Thread.currentThread().getContextClassLoader()</code> as the classloader.
-     * </p>
-     *
-     * @param aBundleName the name of the bundle (usually it's FQN classname).
-     * @param locale      the locale.
-     * @return the bundle, <tt>null</tt> if not found.
-     */
-    @Override
-    public ResourceBundle findResourceBundle(String aBundleName, Locale locale) {
-        ClassLoader classLoader = getCurrentThreadContextClassLoader();
-        String key = createMissesKey(String.valueOf(classLoader.hashCode()), aBundleName, locale);
-
-        if (missingBundles.contains(key)) {
-            return null;
-        }
-
-        ResourceBundle bundle = null;
-        try {
-            if (bundlesMap.containsKey(key)) {
-                bundle = bundlesMap.get(key);
-            } else {
-                bundle = ResourceBundle.getBundle(aBundleName, locale, classLoader);
-                bundlesMap.putIfAbsent(key, bundle);
-            }
-        } catch (MissingResourceException ex) {
-            if (delegatedClassLoaderMap.containsKey(classLoader.hashCode())) {
-                try {
-                    if (bundlesMap.containsKey(key)) {
-                        bundle = bundlesMap.get(key);
-                    } else {
-                        bundle = ResourceBundle.getBundle(aBundleName, locale, delegatedClassLoaderMap.get(classLoader.hashCode()));
-                        bundlesMap.putIfAbsent(key, bundle);
-                    }
-                } catch (MissingResourceException e) {
-                    LOG.debug("Missing resource bundle [{}]!", aBundleName, e);
-                    missingBundles.add(key);
-                }
-            } else {
-                LOG.debug("Missing resource bundle [{}]!", aBundleName);
-                missingBundles.add(key);
-            }
-        }
-        return bundle;
-    }
-
-    /**
-     * @param classLoader a {@link ClassLoader} to look up the bundle from if none can be found on the current thread's classloader
-     */
-    public void setDelegatedClassLoader(final ClassLoader classLoader) {
-        synchronized (bundlesMap) {
-            delegatedClassLoaderMap.put(getCurrentThreadContextClassLoader().hashCode(), classLoader);
-        }
-    }
-
-    /**
-     * @param bundleName Removes the bundle from any cached "misses"
-     */
-    public void clearBundle(final String bundleName) {
-        bundlesMap.remove(getCurrentThreadContextClassLoader().hashCode() + bundleName);
-    }
-
-
-    /**
-     * Creates a key to used for lookup/storing in the bundle misses cache.
-     *
-     * @param prefix      the prefix for the returning String - it is supposed to be the ClassLoader hash code.
-     * @param aBundleName the name of the bundle (usually it's FQN classname).
-     * @param locale      the locale.
-     * @return the key to use for lookup/storing in the bundle misses cache.
-     */
-    private String createMissesKey(String prefix, String aBundleName, Locale locale) {
-        return prefix + aBundleName + "_" + locale.toString();
-    }
-
-    /**
-     * Calls {@link #findText(Class aClass, String aTextName, Locale locale, String defaultMessage, Object[] args)}
-     * with aTextName as the default message.
-     *
-     * @param aClass class name
-     * @param aTextName  text name
-     * @param locale the locale
-     *
-     * @return the localized text, or null if none can be found and no defaultMessage is provided
-     * @see #findText(Class aClass, String aTextName, Locale locale, String defaultMessage, Object[] args)
-     */
-    @Override
-    public String findText(Class aClass, String aTextName, Locale locale) {
-        return findText(aClass, aTextName, locale, aTextName, new Object[0]);
-    }
-
-    /**
-     * <p>
-     * Finds a localized text message for the given key, aTextName. Both the key and the message
-     * itself is evaluated as required.  The following algorithm is used to find the requested
-     * message:
-     * </p>
-     *
-     * <ol>
-     * <li>Look for message in aClass' class hierarchy.
-     * <ol>
-     * <li>Look for the message in a resource bundle for aClass</li>
-     * <li>If not found, look for the message in a resource bundle for any implemented interface</li>
-     * <li>If not found, traverse up the Class' hierarchy and repeat from the first sub-step</li>
-     * </ol></li>
-     * <li>If not found and aClass is a {@link ModelDriven} Action, then look for message in
-     * the model's class hierarchy (repeat sub-steps listed above).</li>
-     * <li>If not found, look for message in child property.  This is determined by evaluating
-     * the message key as an OGNL expression.  For example, if the key is
-     * <i>user.address.state</i>, then it will attempt to see if "user" can be resolved into an
-     * object.  If so, repeat the entire process fromthe beginning with the object's class as
-     * aClass and "address.state" as the message key.</li>
-     * <li>If not found, look for the message in aClass' package hierarchy.</li>
-     * <li>If still not found, look for the message in the default resource bundles.</li>
-     * <li>Return defaultMessage</li>
-     * </ol>
-     *
-     * <p>
-     * When looking for the message, if the key indexes a collection (e.g. user.phone[0]) and a
-     * message for that specific key cannot be found, the general form will also be looked up
-     * (i.e. user.phone[*]).
-     * </p>
-     *
-     * <p>
-     * If a message is found, it will also be interpolated.  Anything within <code>${...}</code>
-     * will be treated as an OGNL expression and evaluated as such.
-     * </p>
-     *
-     * @param aClass         the class whose name to use as the start point for the search
-     * @param aTextName      the key to find the text message for
-     * @param locale         the locale the message should be for
-     * @param defaultMessage the message to be returned if no text message can be found in any
-     *                       resource bundle
-     * @param args           arguments
-     *                       resource bundle
-     * @return the localized text, or null if none can be found and no defaultMessage is provided
-     */
-    @Override
-    public String findText(Class aClass, String aTextName, Locale locale, String defaultMessage, Object[] args) {
-        ValueStack valueStack = ActionContext.getContext().getValueStack();
-        return findText(aClass, aTextName, locale, defaultMessage, args, valueStack);
-
-    }
-
-    /**
-     * <p>
-     * Finds a localized text message for the given key, aTextName. Both the key and the message
-     * itself is evaluated as required.  The following algorithm is used to find the requested
-     * message:
-     * </p>
-     *
-     * <ol>
-     * <li>Look for message in aClass' class hierarchy.
-     * <ol>
-     * <li>Look for the message in a resource bundle for aClass</li>
-     * <li>If not found, look for the message in a resource bundle for any implemented interface</li>
-     * <li>If not found, traverse up the Class' hierarchy and repeat from the first sub-step</li>
-     * </ol></li>
-     * <li>If not found and aClass is a {@link ModelDriven} Action, then look for message in
-     * the model's class hierarchy (repeat sub-steps listed above).</li>
-     * <li>If not found, look for message in child property.  This is determined by evaluating
-     * the message key as an OGNL expression.  For example, if the key is
-     * <i>user.address.state</i>, then it will attempt to see if "user" can be resolved into an
-     * object.  If so, repeat the entire process fromthe beginning with the object's class as
-     * aClass and "address.state" as the message key.</li>
-     * <li>If not found, look for the message in aClass' package hierarchy.</li>
-     * <li>If still not found, look for the message in the default resource bundles.</li>
-     * <li>Return defaultMessage</li>
-     * </ol>
-     *
-     * <p>
-     * When looking for the message, if the key indexes a collection (e.g. user.phone[0]) and a
-     * message for that specific key cannot be found, the general form will also be looked up
-     * (i.e. user.phone[*]).
-     * </p>
-     *
-     * <p>
-     * If a message is found, it will also be interpolated.  Anything within <code>${...}</code>
-     * will be treated as an OGNL expression and evaluated as such.
-     * </p>
-     *
-     * <p>
-     * If a message is <b>not</b> found a WARN log will be logged.
-     * </p>
-     *
-     * @param aClass         the class whose name to use as the start point for the search
-     * @param aTextName      the key to find the text message for
-     * @param locale         the locale the message should be for
-     * @param defaultMessage the message to be returned if no text message can be found in any
-     *                       resource bundle
-     * @param args           arguments
-     * @param valueStack     the value stack to use to evaluate expressions instead of the
-     *                       one in the ActionContext ThreadLocal
-     * @return the localized text, or null if none can be found and no defaultMessage is provided
-     */
-    @Override
-    public String findText(Class aClass, String aTextName, Locale locale, String defaultMessage, Object[] args,
-                           ValueStack valueStack) {
-        String indexedTextName = null;
-        if (aTextName == null) {
-        	LOG.warn("Trying to find text with null key!");
-            aTextName = "";
-        }
-        // calculate indexedTextName (collection[*]) if applicable
-        if (aTextName.contains("[")) {
-            int i = -1;
-
-            indexedTextName = aTextName;
-
-            while ((i = indexedTextName.indexOf("[", i + 1)) != -1) {
-                int j = indexedTextName.indexOf("]", i);
-                String a = indexedTextName.substring(0, i);
-                String b = indexedTextName.substring(j);
-                indexedTextName = a + "[*" + b;
-            }
-        }
-
-        // search up class hierarchy
-        String msg = findMessage(aClass, aTextName, indexedTextName, locale, args, null, valueStack);
-
-        if (msg != null) {
-            return msg;
-        }
-
-        if (ModelDriven.class.isAssignableFrom(aClass)) {
-            ActionContext context = ActionContext.getContext();
-            // search up model's class hierarchy
-            ActionInvocation actionInvocation = context.getActionInvocation();
-
-            // ActionInvocation may be null if we're being run from a Sitemesh filter, so we won't get model texts if this is null
-            if (actionInvocation != null) {
-                Object action = actionInvocation.getAction();
-                if (action instanceof ModelDriven) {
-                    Object model = ((ModelDriven) action).getModel();
-                    if (model != null) {
-                        msg = findMessage(model.getClass(), aTextName, indexedTextName, locale, args, null, valueStack);
-                        if (msg != null) {
-                            return msg;
-                        }
-                    }
-                }
-            }
-        }
-
-        // nothing still? alright, search the package hierarchy now
-        for (Class clazz = aClass;
-             (clazz != null) && !clazz.equals(Object.class);
-             clazz = clazz.getSuperclass()) {
-
-            String basePackageName = clazz.getName();
-            while (basePackageName.lastIndexOf('.') != -1) {
-                basePackageName = basePackageName.substring(0, basePackageName.lastIndexOf('.'));
-                String packageName = basePackageName + ".package";
-                msg = getMessage(packageName, locale, aTextName, valueStack, args);
-
-                if (msg != null) {
-                    return msg;
-                }
-
-                if (indexedTextName != null) {
-                    msg = getMessage(packageName, locale, indexedTextName, valueStack, args);
-
-                    if (msg != null) {
-                        return msg;
-                    }
-                }
-            }
-        }
-
-        // see if it's a child property
-        int idx = aTextName.indexOf(".");
-
-        if (idx != -1) {
-            String newKey = null;
-            String prop = null;
-
-            if (aTextName.startsWith(XWorkConverter.CONVERSION_ERROR_PROPERTY_PREFIX)) {
-                idx = aTextName.indexOf(".", XWorkConverter.CONVERSION_ERROR_PROPERTY_PREFIX.length());
-
-                if (idx != -1) {
-                    prop = aTextName.substring(XWorkConverter.CONVERSION_ERROR_PROPERTY_PREFIX.length(), idx);
-                    newKey = XWorkConverter.CONVERSION_ERROR_PROPERTY_PREFIX + aTextName.substring(idx + 1);
-                }
-            } else {
-                prop = aTextName.substring(0, idx);
-                newKey = aTextName.substring(idx + 1);
-            }
-
-            if (prop != null) {
-                Object obj = valueStack.findValue(prop);
-                try {
-                    Object actionObj = ReflectionProviderFactory.getInstance().getRealTarget(prop, valueStack.getContext(), valueStack.getRoot());
-                    if (actionObj != null) {
-                        PropertyDescriptor propertyDescriptor = ReflectionProviderFactory.getInstance().getPropertyDescriptor(actionObj.getClass(), prop);
-
-                        if (propertyDescriptor != null) {
-                            Class clazz = propertyDescriptor.getPropertyType();
-
-                            if (clazz != null) {
-                                if (obj != null) {
-                                    valueStack.push(obj);
-                                }
-                                msg = findText(clazz, newKey, locale, null, args);
-                                if (obj != null) {
-                                    valueStack.pop();
-                                }
-                                if (msg != null) {
-                                    return msg;
-                                }
-                            }
-                        }
-                    }
-                } catch (Exception e) {
-                    LOG.debug("unable to find property {}", prop, e);
-                }
-            }
-        }
-
-        // get default
-        GetDefaultMessageReturnArg result;
-        if (indexedTextName == null) {
-            result = getDefaultMessage(aTextName, locale, valueStack, args, defaultMessage);
-        } else {
-            result = getDefaultMessage(aTextName, locale, valueStack, args, null);
-            if (result != null && result.message != null) {
-                return result.message;
-            }
-            result = getDefaultMessage(indexedTextName, locale, valueStack, args, defaultMessage);
-        }
-
-        // could we find the text, if not log a warn
-        if (unableToFindTextForKey(result) && LOG.isDebugEnabled()) {
-            String warn = "Unable to find text for key '" + aTextName + "' ";
-            if (indexedTextName != null) {
-                warn += " or indexed key '" + indexedTextName + "' ";
-            }
-            warn += "in class '" + aClass.getName() + "' and locale '" + locale + "'";
-            LOG.debug(warn);
-        }
-
-        return result != null ? result.message : null;
-    }
-
-    /**
-     * Determines if we found the text in the bundles.
-     *
-     * @param result the result so far
-     * @return <tt>true</tt> if we could <b>not</b> find the text, <tt>false</tt> if the text was found (=success).
-     */
-    private static boolean unableToFindTextForKey(GetDefaultMessageReturnArg result) {
-        if (result == null || result.message == null) {
-            return true;
-        }
-
-        // did we find it in the bundle, then no problem?
-        if (result.foundInBundle) {
-            return false;
-        }
-
-        // not found in bundle
-        return true;
-    }
-
-    /**
-     * <p>
-     * Finds a localized text message for the given key, aTextName, in the specified resource bundle
-     * with aTextName as the default message.
-     * </p>
-     *
-     * <p>
-     * If a message is found, it will also be interpolated.  Anything within <code>${...}</code>
-     * will be treated as an OGNL expression and evaluated as such.
-     * </p>
-     *
-     * @param bundle a resource bundle name
-     * @param aTextName  text name
-     * @param locale the locale
-     *
-     * @return the localized text, or null if none can be found and no defaultMessage is provided
-     * @see #findText(java.util.ResourceBundle, String, java.util.Locale, String, Object[])
-     */
-    @Override
-    public String findText(ResourceBundle bundle, String aTextName, Locale locale) {
-        return findText(bundle, aTextName, locale, aTextName, new Object[0]);
-    }
-
-    /**
-     * <p>
-     * Finds a localized text message for the given key, aTextName, in the specified resource
-     * bundle.
-     * </p>
-     *
-     * <p>
-     * If a message is found, it will also be interpolated.  Anything within <code>${...}</code>
-     * will be treated as an OGNL expression and evaluated as such.
-     * </p>
-     *
-     * <p>
-     * If a message is <b>not</b> found a WARN log will be logged.
-     * </p>
-     *
-     * @param bundle         the bundle
-     * @param aTextName      the key
-     * @param locale         the locale
-     * @param defaultMessage the default message to use if no message was found in the bundle
-     * @param args           arguments for the message formatter.
-     * @return the localized text, or null if none can be found and no defaultMessage is provided
-     */
-    @Override
-    public String findText(ResourceBundle bundle, String aTextName, Locale locale, String defaultMessage, Object[] args) {
-        ValueStack valueStack = ActionContext.getContext().getValueStack();
-        return findText(bundle, aTextName, locale, defaultMessage, args, valueStack);
-    }
-
-    /**
-     * <p>
-     * Finds a localized text message for the given key, aTextName, in the specified resource
-     * bundle.
-     * </p>
-     *
-     * <p>
-     * If a message is found, it will also be interpolated.  Anything within <code>${...}</code>
-     * will be treated as an OGNL expression and evaluated as such.
-     * </p>
-     *
-     * <p>
-     * If a message is <b>not</b> found a WARN log will be logged.
-     * </p>
-     *
-     * @param bundle         the bundle
-     * @param aTextName      the key
-     * @param locale         the locale
-     * @param defaultMessage the default message to use if no message was found in the bundle
-     * @param args           arguments for the message formatter.
-     * @param valueStack     the OGNL value stack.
-     * @return the localized text, or null if none can be found and no defaultMessage is provided
-     */
-    @Override
-    public String findText(ResourceBundle bundle, String aTextName, Locale locale, String defaultMessage, Object[] args,
-                           ValueStack valueStack) {
-        try {
-            reloadBundles(valueStack.getContext());
-
-            String message = TextParseUtil.translateVariables(bundle.getString(aTextName), valueStack);
-            MessageFormat mf = buildMessageFormat(message, locale);
-
-            return formatWithNullDetection(mf, args);
-        } catch (MissingResourceException ex) {
-            if (devMode) {
-                LOG.warn("Missing key [{}] in bundle [{}]!", aTextName, bundle);
-            } else {
-                LOG.debug("Missing key [{}] in bundle [{}]!", aTextName, bundle);
-            }
-        }
-
-        GetDefaultMessageReturnArg result = getDefaultMessage(aTextName, locale, valueStack, args, defaultMessage);
-        if (unableToFindTextForKey(result)) {
-            LOG.warn("Unable to find text for key '{}' in ResourceBundles for locale '{}'", aTextName, locale);
-        }
-        return result != null ? result.message : null;
-    }
-
-    /**
-     * @return the default message.
-     */
-    private GetDefaultMessageReturnArg getDefaultMessage(String key, Locale locale, ValueStack valueStack, Object[] args,
-                                                                String defaultMessage) {
-        GetDefaultMessageReturnArg result = null;
-        boolean found = true;
-
-        if (key != null) {
-            String message = findDefaultText(key, locale);
-
-            if (message == null) {
-                message = defaultMessage;
-                found = false; // not found in bundles
-            }
-
-            // defaultMessage may be null
-            if (message != null) {
-                MessageFormat mf = buildMessageFormat(TextParseUtil.translateVariables(message, valueStack), locale);
-
-                String msg = formatWithNullDetection(mf, args);
-                result = new GetDefaultMessageReturnArg(msg, found);
-            }
-        }
-
-        return result;
-    }
-
-    /**
-     * @return the message from the named resource bundle.
-     */
-    private String getMessage(String bundleName, Locale locale, String key, ValueStack valueStack, Object[] args) {
-        ResourceBundle bundle = findResourceBundle(bundleName, locale);
-        if (bundle == null) {
-            return null;
-        }
-        if (valueStack != null) 
-            reloadBundles(valueStack.getContext());
-        try {
-        	String message = bundle.getString(key);
-        	if (valueStack != null) 
-        		message = TextParseUtil.translateVariables(bundle.getString(key), valueStack);
-            MessageFormat mf = buildMessageFormat(message, locale);
-            return formatWithNullDetection(mf, args);
-        } catch (MissingResourceException e) {
-            if (devMode) {
-                LOG.warn("Missing key [{}] in bundle [{}]!", key, bundleName);
-            } else {
-                LOG.debug("Missing key [{}] in bundle [{}]!", key, bundleName);
-            }
-            return null;
-        }
-    }
-
-    private String formatWithNullDetection(MessageFormat mf, Object[] args) {
-        String message = mf.format(args);
-        if ("null".equals(message)) {
-            return null;
-        } else {
-            return message;
-        }
-    }
-
-    private MessageFormat buildMessageFormat(String pattern, Locale locale) {
-        MessageFormatKey key = new MessageFormatKey(pattern, locale);
-        MessageFormat format = messageFormats.get(key);
-        if (format == null) {
-            format = new MessageFormat(pattern);
-            format.setLocale(locale);
-            format.applyPattern(pattern);
-            messageFormats.put(key, format);
-        }
-
-        return format;
-    }
-
-    /**
-     * Traverse up class hierarchy looking for message.  Looks at class, then implemented interface,
-     * before going up hierarchy.
-     *
-     * @return the message
-     */
-    private String findMessage(Class clazz, String key, String indexedKey, Locale locale, Object[] args, Set<String> checked,
-                                      ValueStack valueStack) {
-        if (checked == null) {
-            checked = new TreeSet<String>();
-        } else if (checked.contains(clazz.getName())) {
-            return null;
-        }
-
-        // look in properties of this class
-        String msg = getMessage(clazz.getName(), locale, key, valueStack, args);
-
-        if (msg != null) {
-            return msg;
-        }
-
-        if (indexedKey != null) {
-            msg = getMessage(clazz.getName(), locale, indexedKey, valueStack, args);
-
-            if (msg != null) {
-                return msg;
-            }
-        }
-
-        // look in properties of implemented interfaces
-        Class[] interfaces = clazz.getInterfaces();
-
-        for (Class anInterface : interfaces) {
-            msg = getMessage(anInterface.getName(), locale, key, valueStack, args);
-
-            if (msg != null) {
-                return msg;
-            }
-
-            if (indexedKey != null) {
-                msg = getMessage(anInterface.getName(), locale, indexedKey, valueStack, args);
-
-                if (msg != null) {
-                    return msg;
-                }
-            }
-        }
-
-        // traverse up hierarchy
-        if (clazz.isInterface()) {
-            interfaces = clazz.getInterfaces();
-
-            for (Class anInterface : interfaces) {
-                msg = findMessage(anInterface, key, indexedKey, locale, args, checked, valueStack);
-
-                if (msg != null) {
-                    return msg;
-                }
-            }
-        } else {
-            if (!clazz.equals(Object.class) && !clazz.isPrimitive()) {
-                return findMessage(clazz.getSuperclass(), key, indexedKey, locale, args, checked, valueStack);
-            }
-        }
-
-        return null;
-    }
-
-    private void reloadBundles() {
-        reloadBundles(ActionContext.getContext() != null ? ActionContext.getContext().getContextMap() : null);
-    }
-
-    private void reloadBundles(Map<String, Object> context) {
-        if (reloadBundles) {
-            try {
-                Boolean reloaded;
-                if (context != null) {
-                    reloaded = (Boolean) ObjectUtils.defaultIfNull(context.get(RELOADED), Boolean.FALSE);
-                }else {
-                    reloaded = Boolean.FALSE;
-                }
-                if (!reloaded) {
-                    bundlesMap.clear();
-                    try {
-                        clearMap(ResourceBundle.class, null, "cacheList");
-                    } catch (NoSuchFieldException e) {
-                        // happens in IBM JVM, that has a different ResourceBundle impl
-                        // it has a 'cache' member
-                        clearMap(ResourceBundle.class, null, "cache");
-                    }
-
-                    // now, for the true and utter hack, if we're running in tomcat, clear
-                    // it's class loader resource cache as well.
-                    clearTomcatCache();
-                    if(context!=null) {
-                        context.put(RELOADED, true);
-                    }
-                    LOG.debug("Resource bundles reloaded");
-                }
-            } catch (Exception e) {
-                LOG.error("Could not reload resource bundles", e);
-            }
-        }
-    }
-
-
-    private static void clearTomcatCache() {
-        ClassLoader loader = getCurrentThreadContextClassLoader();
-        // no need for compilation here.
-        Class cl = loader.getClass();
-
-        try {
-            if ("org.apache.catalina.loader.WebappClassLoader".equals(cl.getName())) {
-                clearMap(cl, loader, TOMCAT_RESOURCE_ENTRIES_FIELD);
-            } else {
-                LOG.debug("Class loader {} is not tomcat loader.", cl.getName());
-            }
-        } catch (NoSuchFieldException nsfe) {
-            if ("org.apache.catalina.loader.WebappClassLoaderBase".equals(cl.getSuperclass().getName())) {
-                LOG.debug("Base class {} doesn't contain '{}' field, trying with parent!", cl.getName(), TOMCAT_RESOURCE_ENTRIES_FIELD, nsfe);
-                try {
-                    clearMap(cl.getSuperclass(), loader, TOMCAT_RESOURCE_ENTRIES_FIELD);
-                } catch (Exception e) {
-                    LOG.warn("Couldn't clear tomcat cache using {}", cl.getSuperclass().getName(), e);
-                }
-            }
-        } catch (Exception e) {
-      	    LOG.warn("Couldn't clear tomcat cache", cl.getName(), e);
-        }
-    }
-
-
-    private static void clearMap(Class cl, Object obj, String name)
-            throws NoSuchFieldException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
-
-        Field field = cl.getDeclaredField(name);
-        field.setAccessible(true);
-
-        Object cache = field.get(obj);
-
-        synchronized (cache) {
-            Class ccl = cache.getClass();
-            Method clearMethod = ccl.getMethod("clear");
-            clearMethod.invoke(cache);
-        }
-    }
-
-    /**
-     * Clears all the internal lists.
-     *
-     * @deprecated used only in tests
-     */
-    @Override
-    @Deprecated
-    public void reset() {
-        // no-op
-    }
-
-    static class MessageFormatKey {
-        String pattern;
-        Locale locale;
-
-        MessageFormatKey(String pattern, Locale locale) {
-            this.pattern = pattern;
-            this.locale = locale;
-        }
-
-        @Override
-        public boolean equals(Object o) {
-            if (this == o) return true;
-            if (!(o instanceof MessageFormatKey)) return false;
-
-            final MessageFormatKey messageFormatKey = (MessageFormatKey) o;
-
-            if (locale != null ? !locale.equals(messageFormatKey.locale) : messageFormatKey.locale != null)
-                return false;
-            if (pattern != null ? !pattern.equals(messageFormatKey.pattern) : messageFormatKey.pattern != null)
-                return false;
-
-            return true;
-        }
-
-        @Override
-        public int hashCode() {
-            int result;
-            result = (pattern != null ? pattern.hashCode() : 0);
-            result = 29 * result + (locale != null ? locale.hashCode() : 0);
-            return result;
-        }
-    }
-
-    private static ClassLoader getCurrentThreadContextClassLoader() {
-        return Thread.currentThread().getContextClassLoader();
-    }
-
-    static class GetDefaultMessageReturnArg {
-        String message;
-        boolean foundInBundle;
-
-        public GetDefaultMessageReturnArg(String message, boolean foundInBundle) {
-            this.message = message;
-            this.foundInBundle = foundInBundle;
-        }
-    }
-
-    private static class EmptyResourceBundle extends ResourceBundle {
-        @Override
-        public Enumeration<String> getKeys() {
-            return null; // dummy
-        }
-
-        @Override
-        protected Object handleGetObject(String key) {
-            return null; // dummy
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/struts/blob/008c28ac/core/src/main/java/org/apache/struts2/components/Date.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/struts2/components/Date.java b/core/src/main/java/org/apache/struts2/components/Date.java
index 46c193d..f1a3c97 100644
--- a/core/src/main/java/org/apache/struts2/components/Date.java
+++ b/core/src/main/java/org/apache/struts2/components/Date.java
@@ -23,7 +23,6 @@ package org.apache.struts2.components;
 
 import com.opensymphony.xwork2.ActionContext;
 import com.opensymphony.xwork2.TextProvider;
-import com.opensymphony.xwork2.util.LocalizedTextUtil;
 import com.opensymphony.xwork2.util.ValueStack;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;

http://git-wip-us.apache.org/repos/asf/struts/blob/008c28ac/core/src/main/java/org/apache/struts2/components/I18n.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/struts2/components/I18n.java b/core/src/main/java/org/apache/struts2/components/I18n.java
index 7065c4b..f934a3e 100644
--- a/core/src/main/java/org/apache/struts2/components/I18n.java
+++ b/core/src/main/java/org/apache/struts2/components/I18n.java
@@ -33,7 +33,7 @@ import com.opensymphony.xwork2.TextProvider;
 import com.opensymphony.xwork2.TextProviderFactory;
 import com.opensymphony.xwork2.inject.Container;
 import com.opensymphony.xwork2.inject.Inject;
-import com.opensymphony.xwork2.util.LocalizedTextUtil;
+import com.opensymphony.xwork2.util.DefaultLocalizedTextProvider;
 import com.opensymphony.xwork2.util.ValueStack;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
@@ -121,7 +121,7 @@ public class I18n extends Component {
             ResourceBundle bundle = defaultTextProvider.getTexts(name);
 
             if (bundle == null) {
-                bundle = container.getInstance(LocalizedTextUtil.class).findResourceBundle(name, localeProvider.getLocale());
+                bundle = container.getInstance(DefaultLocalizedTextProvider.class).findResourceBundle(name, localeProvider.getLocale());
             }
 
             if (bundle != null) {

http://git-wip-us.apache.org/repos/asf/struts/blob/008c28ac/core/src/main/java/org/apache/struts2/config/DefaultBeanSelectionProvider.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/struts2/config/DefaultBeanSelectionProvider.java b/core/src/main/java/org/apache/struts2/config/DefaultBeanSelectionProvider.java
index b21376e..6e5bf8b 100644
--- a/core/src/main/java/org/apache/struts2/config/DefaultBeanSelectionProvider.java
+++ b/core/src/main/java/org/apache/struts2/config/DefaultBeanSelectionProvider.java
@@ -53,7 +53,6 @@ import com.opensymphony.xwork2.factory.ResultFactory;
 import com.opensymphony.xwork2.factory.ValidatorFactory;
 import com.opensymphony.xwork2.inject.ContainerBuilder;
 import com.opensymphony.xwork2.inject.Scope;
-import com.opensymphony.xwork2.util.LocalizedTextUtil;
 import com.opensymphony.xwork2.util.PatternMatcher;
 import com.opensymphony.xwork2.util.TextParser;
 import com.opensymphony.xwork2.util.ValueStackFactory;
@@ -74,8 +73,6 @@ import org.apache.struts2.views.freemarker.FreemarkerManager;
 import org.apache.struts2.views.util.UrlHelper;
 import org.apache.struts2.views.velocity.VelocityManager;
 
-import java.util.StringTokenizer;
-
 /**
  * Selects the implementations of key framework extension points, using the loaded
  * property constants.  The implementations are selected from the container builder

http://git-wip-us.apache.org/repos/asf/struts/blob/008c28ac/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java b/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
index 7b28117..047238f 100644
--- a/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
+++ b/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
@@ -26,14 +26,13 @@ import com.opensymphony.xwork2.config.*;
 import com.opensymphony.xwork2.config.entities.InterceptorMapping;
 import com.opensymphony.xwork2.config.entities.InterceptorStackConfig;
 import com.opensymphony.xwork2.config.entities.PackageConfig;
-import com.opensymphony.xwork2.config.impl.DefaultConfiguration;
 import com.opensymphony.xwork2.config.providers.XmlConfigurationProvider;
 import com.opensymphony.xwork2.inject.Container;
 import com.opensymphony.xwork2.inject.ContainerBuilder;
 import com.opensymphony.xwork2.inject.Inject;
 import com.opensymphony.xwork2.interceptor.Interceptor;
 import com.opensymphony.xwork2.util.ClassLoaderUtil;
-import com.opensymphony.xwork2.util.LocalizedTextUtil;
+import com.opensymphony.xwork2.util.DefaultLocalizedTextProvider;
 import com.opensymphony.xwork2.util.ValueStack;
 import com.opensymphony.xwork2.util.ValueStackFactory;
 import com.opensymphony.xwork2.util.location.LocatableProperties;
@@ -647,7 +646,7 @@ public class Dispatcher {
 
         Locale locale;
         if (defaultLocale != null) {
-            locale = LocalizedTextUtil.localeFromString(defaultLocale, request.getLocale());
+            locale = DefaultLocalizedTextProvider.localeFromString(defaultLocale, request.getLocale());
         } else {
             locale = request.getLocale();
         }
@@ -729,7 +728,7 @@ public class Dispatcher {
 
         Locale locale = null;
         if (defaultLocale != null) {
-            locale = LocalizedTextUtil.localeFromString(defaultLocale, request.getLocale());
+            locale = DefaultLocalizedTextProvider.localeFromString(defaultLocale, request.getLocale());
         }
 
         if (encoding != null) {

http://git-wip-us.apache.org/repos/asf/struts/blob/008c28ac/core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java b/core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java
index f12f1b5..e6fab1e 100644
--- a/core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java
+++ b/core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java
@@ -21,7 +21,6 @@
 
 package org.apache.struts2.dispatcher.multipart;
 
-import com.opensymphony.xwork2.util.LocalizedTextUtil;
 import org.apache.commons.fileupload.FileItem;
 import org.apache.commons.fileupload.FileUploadBase;
 import org.apache.commons.fileupload.FileUploadException;

http://git-wip-us.apache.org/repos/asf/struts/blob/008c28ac/core/src/main/java/org/apache/struts2/dispatcher/multipart/MultiPartRequestWrapper.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/struts2/dispatcher/multipart/MultiPartRequestWrapper.java b/core/src/main/java/org/apache/struts2/dispatcher/multipart/MultiPartRequestWrapper.java
index 4f55621..571f5c3 100644
--- a/core/src/main/java/org/apache/struts2/dispatcher/multipart/MultiPartRequestWrapper.java
+++ b/core/src/main/java/org/apache/struts2/dispatcher/multipart/MultiPartRequestWrapper.java
@@ -22,14 +22,12 @@
 package org.apache.struts2.dispatcher.multipart;
 
 import com.opensymphony.xwork2.LocaleProvider;
-import com.opensymphony.xwork2.util.LocalizedTextUtil;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 import org.apache.struts2.dispatcher.LocalizedMessage;
 import org.apache.struts2.dispatcher.StrutsRequestWrapper;
 
 import javax.servlet.http.HttpServletRequest;
-import java.io.File;
 import java.io.IOException;
 import java.util.*;
 

http://git-wip-us.apache.org/repos/asf/struts/blob/008c28ac/core/src/main/java/org/apache/struts2/factory/StrutsActionProxy.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/struts2/factory/StrutsActionProxy.java b/core/src/main/java/org/apache/struts2/factory/StrutsActionProxy.java
index 9b8e681..a444953 100644
--- a/core/src/main/java/org/apache/struts2/factory/StrutsActionProxy.java
+++ b/core/src/main/java/org/apache/struts2/factory/StrutsActionProxy.java
@@ -26,7 +26,6 @@ package org.apache.struts2.factory;
 import com.opensymphony.xwork2.ActionContext;
 import com.opensymphony.xwork2.ActionInvocation;
 import com.opensymphony.xwork2.DefaultActionProxy;
-import com.opensymphony.xwork2.util.LocalizedTextUtil;
 import org.apache.struts2.ServletActionContext;
 
 import java.util.Locale;

http://git-wip-us.apache.org/repos/asf/struts/blob/008c28ac/core/src/main/java/org/apache/struts2/interceptor/I18nInterceptor.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/struts2/interceptor/I18nInterceptor.java b/core/src/main/java/org/apache/struts2/interceptor/I18nInterceptor.java
index 9060d69..4b6c8f5 100644
--- a/core/src/main/java/org/apache/struts2/interceptor/I18nInterceptor.java
+++ b/core/src/main/java/org/apache/struts2/interceptor/I18nInterceptor.java
@@ -24,7 +24,7 @@ import com.opensymphony.xwork2.ActionInvocation;
 import com.opensymphony.xwork2.LocaleProvider;
 import com.opensymphony.xwork2.inject.Inject;
 import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
-import com.opensymphony.xwork2.util.LocalizedTextUtil;
+import com.opensymphony.xwork2.util.DefaultLocalizedTextProvider;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.message.ParameterizedMessage;
@@ -163,7 +163,7 @@ public class I18nInterceptor extends AbstractInterceptor {
             } else {
                 String localeStr = requestedLocale.toString();
                 if (localeProvider.isValidLocaleString(localeStr)) {
-                    locale = LocalizedTextUtil.localeFromString(requestedLocale.toString(), null);
+                    locale = DefaultLocalizedTextProvider.localeFromString(requestedLocale.toString(), null);
                 }
             }
             if (locale != null) {

http://git-wip-us.apache.org/repos/asf/struts/blob/008c28ac/core/src/main/java/org/apache/struts2/util/StrutsTestCaseHelper.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/struts2/util/StrutsTestCaseHelper.java b/core/src/main/java/org/apache/struts2/util/StrutsTestCaseHelper.java
index f778e4c..9c449f5 100644
--- a/core/src/main/java/org/apache/struts2/util/StrutsTestCaseHelper.java
+++ b/core/src/main/java/org/apache/struts2/util/StrutsTestCaseHelper.java
@@ -23,7 +23,7 @@ package org.apache.struts2.util;
 
 import com.opensymphony.xwork2.ActionContext;
 import com.opensymphony.xwork2.inject.Container;
-import com.opensymphony.xwork2.util.LocalizedTextUtil;
+import com.opensymphony.xwork2.util.DefaultLocalizedTextProvider;
 import com.opensymphony.xwork2.util.ValueStack;
 import com.opensymphony.xwork2.util.ValueStackFactory;
 import org.apache.struts2.dispatcher.Dispatcher;
@@ -47,7 +47,7 @@ public class StrutsTestCaseHelper {
      * @throws Exception in case of any error
      */
     public static void setUp() throws Exception {
-        LocalizedTextUtil.clearDefaultResourceBundles();
+        DefaultLocalizedTextProvider.clearDefaultResourceBundles();
     }
     
     public static Dispatcher initDispatcher(ServletContext ctx, Map<String,String> params) {

http://git-wip-us.apache.org/repos/asf/struts/blob/008c28ac/core/src/main/java/org/apache/struts2/util/TokenHelper.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/struts2/util/TokenHelper.java b/core/src/main/java/org/apache/struts2/util/TokenHelper.java
index a5affaa..28f42f6 100644
--- a/core/src/main/java/org/apache/struts2/util/TokenHelper.java
+++ b/core/src/main/java/org/apache/struts2/util/TokenHelper.java
@@ -23,7 +23,6 @@ package org.apache.struts2.util;
 
 import com.opensymphony.xwork2.ActionContext;
 import com.opensymphony.xwork2.LocalizedTextProvider;
-import com.opensymphony.xwork2.util.LocalizedTextUtil;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 import org.apache.struts2.dispatcher.Parameter;

http://git-wip-us.apache.org/repos/asf/struts/blob/008c28ac/core/src/main/resources/struts-default.xml
----------------------------------------------------------------------
diff --git a/core/src/main/resources/struts-default.xml b/core/src/main/resources/struts-default.xml
index 4a20ac9..1f516b7 100644
--- a/core/src/main/resources/struts-default.xml
+++ b/core/src/main/resources/struts-default.xml
@@ -131,7 +131,7 @@
     <bean type="com.opensymphony.xwork2.conversion.impl.StringConverter" name="struts" class="com.opensymphony.xwork2.conversion.impl.StringConverter" scope="singleton"/>
 
     <bean type="com.opensymphony.xwork2.TextProviderFactory" name="struts" class="com.opensymphony.xwork2.TextProviderFactory" scope="prototype" />
-    <bean type="com.opensymphony.xwork2.LocalizedTextProvider" name="struts" class="com.opensymphony.xwork2.util.LocalizedTextUtil" scope="singleton" />
+    <bean type="com.opensymphony.xwork2.LocalizedTextProvider" name="struts" class="com.opensymphony.xwork2.util.DefaultLocalizedTextProvider" scope="singleton" />
     <bean type="com.opensymphony.xwork2.TextProvider" name="struts" class="com.opensymphony.xwork2.TextProviderSupport" scope="prototype" />
     <bean type="com.opensymphony.xwork2.LocaleProvider" name="struts" class="com.opensymphony.xwork2.DefaultLocaleProvider" scope="singleton" />
 

http://git-wip-us.apache.org/repos/asf/struts/blob/008c28ac/core/src/test/java/com/opensymphony/xwork2/TextProviderSupportTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/com/opensymphony/xwork2/TextProviderSupportTest.java b/core/src/test/java/com/opensymphony/xwork2/TextProviderSupportTest.java
index c0ea23d..118c419 100644
--- a/core/src/test/java/com/opensymphony/xwork2/TextProviderSupportTest.java
+++ b/core/src/test/java/com/opensymphony/xwork2/TextProviderSupportTest.java
@@ -16,8 +16,6 @@
 
 package com.opensymphony.xwork2;
 
-import com.opensymphony.xwork2.util.LocalizedTextUtil;
-
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Locale;

http://git-wip-us.apache.org/repos/asf/struts/blob/008c28ac/core/src/test/java/com/opensymphony/xwork2/util/DefaultLocalizedTextProviderTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/com/opensymphony/xwork2/util/DefaultLocalizedTextProviderTest.java b/core/src/test/java/com/opensymphony/xwork2/util/DefaultLocalizedTextProviderTest.java
new file mode 100644
index 0000000..a9dca08
--- /dev/null
+++ b/core/src/test/java/com/opensymphony/xwork2/util/DefaultLocalizedTextProviderTest.java
@@ -0,0 +1,267 @@
+/*
+ * Copyright 2002-2006,2009 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.opensymphony.xwork2.util;
+
+import com.mockobjects.dynamic.Mock;
+import com.opensymphony.xwork2.*;
+import com.opensymphony.xwork2.config.providers.XmlConfigurationProvider;
+import com.opensymphony.xwork2.test.ModelDrivenAction2;
+import com.opensymphony.xwork2.test.TestBean2;
+
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+
+/**
+ * Unit test for {@link DefaultLocalizedTextProvider}.
+ *
+ * @author jcarreira
+ * @author tm_jee
+ * 
+ * @version $Date$ $Id$
+ */
+public class DefaultLocalizedTextProviderTest extends XWorkTestCase {
+
+    private LocalizedTextProvider localizedTextProvider;
+    
+	public void testNpeWhenClassIsPrimitive() throws Exception {
+		ValueStack stack = ActionContext.getContext().getValueStack();
+		stack.push(new MyObject());
+		String result = localizedTextProvider.findText(MyObject.class, "someObj.someI18nKey", Locale.ENGLISH, "default message", null, stack);
+		System.out.println(result);
+	}
+	
+	public static class MyObject extends ActionSupport {
+		public boolean getSomeObj() {
+			return true;
+		}
+	}
+	
+	public void testActionGetTextWithNullObject() throws Exception {
+		MyAction action = new MyAction();
+        container.inject(action);
+		
+		Mock mockActionInvocation = new Mock(ActionInvocation.class);
+        mockActionInvocation.expectAndReturn("getAction", action);
+        ActionContext.getContext().setActionInvocation((ActionInvocation) mockActionInvocation.proxy());
+		ActionContext.getContext().getValueStack().push(action);
+		
+		String message = action.getText("barObj.title");
+		assertEquals("Title:", message);
+	}
+	
+	
+	public static class MyAction extends ActionSupport {
+		private Bar testBean2;
+		
+		public Bar getBarObj() {
+			return testBean2;
+		}
+		public void setBarObj(Bar testBean2) {
+			this.testBean2 = testBean2;
+		}
+	}
+	
+    public void testActionGetText() throws Exception {
+        ModelDrivenAction2 action = new ModelDrivenAction2();
+        container.inject(action);
+
+        TestBean2 bean = (TestBean2) action.getModel();
+        Bar bar = new Bar();
+        bean.setBarObj(bar);
+
+        Mock mockActionInvocation = new Mock(ActionInvocation.class);
+        mockActionInvocation.expectAndReturn("getAction", action);
+        ActionContext.getContext().setActionInvocation((ActionInvocation) mockActionInvocation.proxy());
+        ActionContext.getContext().getValueStack().push(action);
+        ActionContext.getContext().getValueStack().push(action.getModel());
+
+        String message = action.getText("barObj.title");
+        assertEquals("Title:", message);
+    }
+
+    public void testNullKeys() {
+        localizedTextProvider.findText(this.getClass(), null, Locale.getDefault());
+    }
+
+    public void testActionGetTextXXX() throws Exception {
+        localizedTextProvider.addDefaultResourceBundle("com/opensymphony/xwork2/util/FindMe");
+
+        SimpleAction action = new SimpleAction();
+        container.inject(action);
+
+        Mock mockActionInvocation = new Mock(ActionInvocation.class);
+        mockActionInvocation.expectAndReturn("getAction", action);
+        ActionContext.getContext().setActionInvocation((ActionInvocation) mockActionInvocation.proxy());
+        ActionContext.getContext().getValueStack().push(action);
+
+        String message = action.getText("bean.name");
+        String foundBean2 = action.getText("bean2.name");
+
+        assertEquals("Okay! You found Me!", foundBean2);
+        assertEquals("Haha you cant FindMe!", message);
+    }
+
+    public void testAddDefaultResourceBundle() {
+        String text = localizedTextProvider.findDefaultText("foo.range", Locale.getDefault());
+        assertNull("Found message when it should not be available.", text);
+
+        localizedTextProvider.addDefaultResourceBundle("com/opensymphony/xwork2/SimpleAction");
+
+        String message = localizedTextProvider.findDefaultText("foo.range", Locale.US);
+        assertEquals("Foo Range Message", message);
+    }
+
+    public void testAddDefaultResourceBundle2() throws Exception {
+        localizedTextProvider.addDefaultResourceBundle("com/opensymphony/xwork2/SimpleAction");
+
+        ActionProxy proxy = actionProxyFactory.createActionProxy("/", "packagelessAction", null, new HashMap<String, Object>(), false, true);
+        proxy.execute();
+    }
+
+    public void testDefaultMessage() throws Exception {
+        String message = localizedTextProvider.findDefaultText("xwork.error.action.execution", Locale.getDefault());
+        assertEquals("Error during Action invocation", message);
+    }
+
+    public void testDefaultMessageOverride() throws Exception {
+        String message = localizedTextProvider.findDefaultText("xwork.error.action.execution", Locale.getDefault());
+        assertEquals("Error during Action invocation", message);
+
+        localizedTextProvider.addDefaultResourceBundle("com/opensymphony/xwork2/test");
+
+        message = localizedTextProvider.findDefaultText("xwork.error.action.execution", Locale.getDefault());
+        assertEquals("Testing resource bundle override", message);
+    }
+
+    public void testFindTextInChildProperty() throws Exception {
+        ModelDriven action = new ModelDrivenAction2();
+        TestBean2 bean = (TestBean2) action.getModel();
+        Bar bar = new Bar();
+        bean.setBarObj(bar);
+
+        Mock mockActionInvocation = new Mock(ActionInvocation.class);
+        mockActionInvocation.expectAndReturn("hashCode", 0);
+        mockActionInvocation.expectAndReturn("getAction", action);
+        ActionContext.getContext().setActionInvocation((ActionInvocation) mockActionInvocation.proxy());
+        ActionContext.getContext().getValueStack().push(action);
+        ActionContext.getContext().getValueStack().push(action.getModel());
+
+        String message = localizedTextProvider.findText(ModelDrivenAction2.class, "invalid.fieldvalue.barObj.title", Locale.getDefault());
+        assertEquals("Title is invalid!", message);
+    }
+
+    public void testFindTextInInterface() throws Exception {
+        Action action = new ModelDrivenAction2();
+        Mock mockActionInvocation = new Mock(ActionInvocation.class);
+        mockActionInvocation.expectAndReturn("getAction", action);
+        ActionContext.getContext().setActionInvocation((ActionInvocation) mockActionInvocation.proxy());
+
+        String message = localizedTextProvider.findText(ModelDrivenAction2.class, "test.foo", Locale.getDefault());
+        assertEquals("Foo!", message);
+    }
+
+    public void testFindTextInPackage() throws Exception {
+        ModelDriven action = new ModelDrivenAction2();
+
+        Mock mockActionInvocation = new Mock(ActionInvocation.class);
+        mockActionInvocation.expectAndReturn("getAction", action);
+        ActionContext.getContext().setActionInvocation((ActionInvocation) mockActionInvocation.proxy());
+
+        String message = localizedTextProvider.findText(ModelDrivenAction2.class, "package.properties", Locale.getDefault());
+        assertEquals("It works!", message);
+    }
+
+    public void testParameterizedDefaultMessage() throws Exception {
+        String message = localizedTextProvider.findDefaultText("xwork.exception.missing-action", Locale.getDefault(), new String[]{"AddUser"});
+        assertEquals("There is no Action mapped for action name AddUser.", message);
+    }
+
+    public void testParameterizedDefaultMessageWithPackage() throws Exception {
+        String message = localizedTextProvider.findDefaultText("xwork.exception.missing-package-action", Locale.getDefault(), new String[]{"blah", "AddUser"});
+        assertEquals("There is no Action mapped for namespace blah and action name AddUser.", message);
+    }
+
+    public void testLocalizedDateFormatIsUsed() throws ParseException {
+        localizedTextProvider.addDefaultResourceBundle("com/opensymphony/xwork2/util/LocalizedTextUtilTest");
+        Date date = DateFormat.getDateInstance(DateFormat.SHORT, Locale.US).parse("01/01/2015");
+        Object[] params = new Object[]{ date };
+        String usDate = localizedTextProvider.findDefaultText("test.format.date", Locale.US, params);
+        String germanDate = localizedTextProvider.findDefaultText("test.format.date", Locale.GERMANY, params);
+        assertEquals(usDate, "1/1/15");
+        assertEquals(germanDate, "01.01.15");
+    }
+
+    public void testXW377() {
+        localizedTextProvider.addDefaultResourceBundle("com/opensymphony/xwork2/util/LocalizedTextUtilTest");
+
+        String text = localizedTextProvider.findText(Bar.class, "xw377", ActionContext.getContext().getLocale(), "xw377", null, ActionContext.getContext().getValueStack());
+        assertEquals("xw377", text); // should not log
+
+        String text2 = localizedTextProvider.findText(DefaultLocalizedTextProviderTest.class, "notinbundle", ActionContext.getContext().getLocale(), "hello", null, ActionContext.getContext().getValueStack());
+        assertEquals("hello", text2); // should log WARN
+
+        String text3 = localizedTextProvider.findText(DefaultLocalizedTextProviderTest.class, "notinbundle.key", ActionContext.getContext().getLocale(), "notinbundle.key", null, ActionContext.getContext().getValueStack());
+        assertEquals("notinbundle.key", text3); // should log WARN
+
+        String text4 = localizedTextProvider.findText(DefaultLocalizedTextProviderTest.class, "xw377", ActionContext.getContext().getLocale(), "hello", null, ActionContext.getContext().getValueStack());
+        assertEquals("xw377", text4); // should not log
+
+        String text5 = localizedTextProvider.findText(DefaultLocalizedTextProviderTest.class, "username", ActionContext.getContext().getLocale(), null, null, ActionContext.getContext().getValueStack());
+        assertEquals("Santa", text5); // should not log
+    }
+
+    public void testXW404() {
+        // This tests will try to load bundles from the 3 locales but we only have files for France and Germany.
+        // Before this fix loading the bundle for Germany failed since Italy have previously failed and thus the misses cache
+        // contained a false entry
+
+        ResourceBundle rbFrance = localizedTextProvider.findResourceBundle("com/opensymphony/xwork2/util/XW404", Locale.FRANCE);
+        ResourceBundle rbItaly = localizedTextProvider.findResourceBundle("com/opensymphony/xwork2/util/XW404", Locale.ITALY);
+        ResourceBundle rbGermany = localizedTextProvider.findResourceBundle("com/opensymphony/xwork2/util/XW404", Locale.GERMANY);
+
+        assertNotNull(rbFrance);
+        assertEquals("Bonjour", rbFrance.getString("hello"));
+
+        assertNull(rbItaly);
+
+        assertNotNull(rbGermany);
+        assertEquals("Hallo", rbGermany.getString("hello"));
+    }
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        XmlConfigurationProvider provider = new XmlConfigurationProvider("xwork-sample.xml");
+        container.inject(provider);
+        loadConfigurationProviders(provider);
+
+        localizedTextProvider = container.getInstance(LocalizedTextProvider.class);
+        
+        ActionContext.getContext().setLocale(Locale.US);
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        super.tearDown();
+        localizedTextProvider = null;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/struts/blob/008c28ac/core/src/test/java/com/opensymphony/xwork2/util/LocalizedTextUtilTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/com/opensymphony/xwork2/util/LocalizedTextUtilTest.java b/core/src/test/java/com/opensymphony/xwork2/util/LocalizedTextUtilTest.java
deleted file mode 100644
index 75e5569..0000000
--- a/core/src/test/java/com/opensymphony/xwork2/util/LocalizedTextUtilTest.java
+++ /dev/null
@@ -1,267 +0,0 @@
-/*
- * Copyright 2002-2006,2009 The Apache Software Foundation.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.opensymphony.xwork2.util;
-
-import com.mockobjects.dynamic.Mock;
-import com.opensymphony.xwork2.*;
-import com.opensymphony.xwork2.config.providers.XmlConfigurationProvider;
-import com.opensymphony.xwork2.test.ModelDrivenAction2;
-import com.opensymphony.xwork2.test.TestBean2;
-
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.ResourceBundle;
-
-
-/**
- * Unit test for {@link LocalizedTextUtil}.
- *
- * @author jcarreira
- * @author tm_jee
- * 
- * @version $Date$ $Id$
- */
-public class LocalizedTextUtilTest extends XWorkTestCase {
-
-    private LocalizedTextProvider localizedTextProvider;
-    
-	public void testNpeWhenClassIsPrimitive() throws Exception {
-		ValueStack stack = ActionContext.getContext().getValueStack();
-		stack.push(new MyObject());
-		String result = localizedTextProvider.findText(MyObject.class, "someObj.someI18nKey", Locale.ENGLISH, "default message", null, stack);
-		System.out.println(result);
-	}
-	
-	public static class MyObject extends ActionSupport {
-		public boolean getSomeObj() {
-			return true;
-		}
-	}
-	
-	public void testActionGetTextWithNullObject() throws Exception {
-		MyAction action = new MyAction();
-        container.inject(action);
-		
-		Mock mockActionInvocation = new Mock(ActionInvocation.class);
-        mockActionInvocation.expectAndReturn("getAction", action);
-        ActionContext.getContext().setActionInvocation((ActionInvocation) mockActionInvocation.proxy());
-		ActionContext.getContext().getValueStack().push(action);
-		
-		String message = action.getText("barObj.title");
-		assertEquals("Title:", message);
-	}
-	
-	
-	public static class MyAction extends ActionSupport {
-		private Bar testBean2;
-		
-		public Bar getBarObj() {
-			return testBean2;
-		}
-		public void setBarObj(Bar testBean2) {
-			this.testBean2 = testBean2;
-		}
-	}
-	
-    public void testActionGetText() throws Exception {
-        ModelDrivenAction2 action = new ModelDrivenAction2();
-        container.inject(action);
-
-        TestBean2 bean = (TestBean2) action.getModel();
-        Bar bar = new Bar();
-        bean.setBarObj(bar);
-
-        Mock mockActionInvocation = new Mock(ActionInvocation.class);
-        mockActionInvocation.expectAndReturn("getAction", action);
-        ActionContext.getContext().setActionInvocation((ActionInvocation) mockActionInvocation.proxy());
-        ActionContext.getContext().getValueStack().push(action);
-        ActionContext.getContext().getValueStack().push(action.getModel());
-
-        String message = action.getText("barObj.title");
-        assertEquals("Title:", message);
-    }
-
-    public void testNullKeys() {
-        localizedTextProvider.findText(this.getClass(), null, Locale.getDefault());
-    }
-
-    public void testActionGetTextXXX() throws Exception {
-        localizedTextProvider.addDefaultResourceBundle("com/opensymphony/xwork2/util/FindMe");
-
-        SimpleAction action = new SimpleAction();
-        container.inject(action);
-
-        Mock mockActionInvocation = new Mock(ActionInvocation.class);
-        mockActionInvocation.expectAndReturn("getAction", action);
-        ActionContext.getContext().setActionInvocation((ActionInvocation) mockActionInvocation.proxy());
-        ActionContext.getContext().getValueStack().push(action);
-
-        String message = action.getText("bean.name");
-        String foundBean2 = action.getText("bean2.name");
-
-        assertEquals("Okay! You found Me!", foundBean2);
-        assertEquals("Haha you cant FindMe!", message);
-    }
-
-    public void testAddDefaultResourceBundle() {
-        String text = localizedTextProvider.findDefaultText("foo.range", Locale.getDefault());
-        assertNull("Found message when it should not be available.", text);
-
-        localizedTextProvider.addDefaultResourceBundle("com/opensymphony/xwork2/SimpleAction");
-
-        String message = localizedTextProvider.findDefaultText("foo.range", Locale.US);
-        assertEquals("Foo Range Message", message);
-    }
-
-    public void testAddDefaultResourceBundle2() throws Exception {
-        localizedTextProvider.addDefaultResourceBundle("com/opensymphony/xwork2/SimpleAction");
-
-        ActionProxy proxy = actionProxyFactory.createActionProxy("/", "packagelessAction", null, new HashMap<String, Object>(), false, true);
-        proxy.execute();
-    }
-
-    public void testDefaultMessage() throws Exception {
-        String message = localizedTextProvider.findDefaultText("xwork.error.action.execution", Locale.getDefault());
-        assertEquals("Error during Action invocation", message);
-    }
-
-    public void testDefaultMessageOverride() throws Exception {
-        String message = localizedTextProvider.findDefaultText("xwork.error.action.execution", Locale.getDefault());
-        assertEquals("Error during Action invocation", message);
-
-        localizedTextProvider.addDefaultResourceBundle("com/opensymphony/xwork2/test");
-
-        message = localizedTextProvider.findDefaultText("xwork.error.action.execution", Locale.getDefault());
-        assertEquals("Testing resource bundle override", message);
-    }
-
-    public void testFindTextInChildProperty() throws Exception {
-        ModelDriven action = new ModelDrivenAction2();
-        TestBean2 bean = (TestBean2) action.getModel();
-        Bar bar = new Bar();
-        bean.setBarObj(bar);
-
-        Mock mockActionInvocation = new Mock(ActionInvocation.class);
-        mockActionInvocation.expectAndReturn("hashCode", 0);
-        mockActionInvocation.expectAndReturn("getAction", action);
-        ActionContext.getContext().setActionInvocation((ActionInvocation) mockActionInvocation.proxy());
-        ActionContext.getContext().getValueStack().push(action);
-        ActionContext.getContext().getValueStack().push(action.getModel());
-
-        String message = localizedTextProvider.findText(ModelDrivenAction2.class, "invalid.fieldvalue.barObj.title", Locale.getDefault());
-        assertEquals("Title is invalid!", message);
-    }
-
-    public void testFindTextInInterface() throws Exception {
-        Action action = new ModelDrivenAction2();
-        Mock mockActionInvocation = new Mock(ActionInvocation.class);
-        mockActionInvocation.expectAndReturn("getAction", action);
-        ActionContext.getContext().setActionInvocation((ActionInvocation) mockActionInvocation.proxy());
-
-        String message = localizedTextProvider.findText(ModelDrivenAction2.class, "test.foo", Locale.getDefault());
-        assertEquals("Foo!", message);
-    }
-
-    public void testFindTextInPackage() throws Exception {
-        ModelDriven action = new ModelDrivenAction2();
-
-        Mock mockActionInvocation = new Mock(ActionInvocation.class);
-        mockActionInvocation.expectAndReturn("getAction", action);
-        ActionContext.getContext().setActionInvocation((ActionInvocation) mockActionInvocation.proxy());
-
-        String message = localizedTextProvider.findText(ModelDrivenAction2.class, "package.properties", Locale.getDefault());
-        assertEquals("It works!", message);
-    }
-
-    public void testParameterizedDefaultMessage() throws Exception {
-        String message = localizedTextProvider.findDefaultText("xwork.exception.missing-action", Locale.getDefault(), new String[]{"AddUser"});
-        assertEquals("There is no Action mapped for action name AddUser.", message);
-    }
-
-    public void testParameterizedDefaultMessageWithPackage() throws Exception {
-        String message = localizedTextProvider.findDefaultText("xwork.exception.missing-package-action", Locale.getDefault(), new String[]{"blah", "AddUser"});
-        assertEquals("There is no Action mapped for namespace blah and action name AddUser.", message);
-    }
-
-    public void testLocalizedDateFormatIsUsed() throws ParseException {
-        localizedTextProvider.addDefaultResourceBundle("com/opensymphony/xwork2/util/LocalizedTextUtilTest");
-        Date date = DateFormat.getDateInstance(DateFormat.SHORT, Locale.US).parse("01/01/2015");
-        Object[] params = new Object[]{ date };
-        String usDate = localizedTextProvider.findDefaultText("test.format.date", Locale.US, params);
-        String germanDate = localizedTextProvider.findDefaultText("test.format.date", Locale.GERMANY, params);
-        assertEquals(usDate, "1/1/15");
-        assertEquals(germanDate, "01.01.15");
-    }
-
-    public void testXW377() {
-        localizedTextProvider.addDefaultResourceBundle("com/opensymphony/xwork2/util/LocalizedTextUtilTest");
-
-        String text = localizedTextProvider.findText(Bar.class, "xw377", ActionContext.getContext().getLocale(), "xw377", null, ActionContext.getContext().getValueStack());
-        assertEquals("xw377", text); // should not log
-
-        String text2 = localizedTextProvider.findText(LocalizedTextUtilTest.class, "notinbundle", ActionContext.getContext().getLocale(), "hello", null, ActionContext.getContext().getValueStack());
-        assertEquals("hello", text2); // should log WARN
-
-        String text3 = localizedTextProvider.findText(LocalizedTextUtilTest.class, "notinbundle.key", ActionContext.getContext().getLocale(), "notinbundle.key", null, ActionContext.getContext().getValueStack());
-        assertEquals("notinbundle.key", text3); // should log WARN
-
-        String text4 = localizedTextProvider.findText(LocalizedTextUtilTest.class, "xw377", ActionContext.getContext().getLocale(), "hello", null, ActionContext.getContext().getValueStack());
-        assertEquals("xw377", text4); // should not log
-
-        String text5 = localizedTextProvider.findText(LocalizedTextUtilTest.class, "username", ActionContext.getContext().getLocale(), null, null, ActionContext.getContext().getValueStack());
-        assertEquals("Santa", text5); // should not log
-    }
-
-    public void testXW404() {
-        // This tests will try to load bundles from the 3 locales but we only have files for France and Germany.
-        // Before this fix loading the bundle for Germany failed since Italy have previously failed and thus the misses cache
-        // contained a false entry
-
-        ResourceBundle rbFrance = localizedTextProvider.findResourceBundle("com/opensymphony/xwork2/util/XW404", Locale.FRANCE);
-        ResourceBundle rbItaly = localizedTextProvider.findResourceBundle("com/opensymphony/xwork2/util/XW404", Locale.ITALY);
-        ResourceBundle rbGermany = localizedTextProvider.findResourceBundle("com/opensymphony/xwork2/util/XW404", Locale.GERMANY);
-
-        assertNotNull(rbFrance);
-        assertEquals("Bonjour", rbFrance.getString("hello"));
-
-        assertNull(rbItaly);
-
-        assertNotNull(rbGermany);
-        assertEquals("Hallo", rbGermany.getString("hello"));
-    }
-
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-        XmlConfigurationProvider provider = new XmlConfigurationProvider("xwork-sample.xml");
-        container.inject(provider);
-        loadConfigurationProviders(provider);
-
-        localizedTextProvider = container.getInstance(LocalizedTextProvider.class);
-        
-        ActionContext.getContext().setLocale(Locale.US);
-    }
-
-    @Override
-    protected void tearDown() throws Exception {
-        super.tearDown();
-        localizedTextProvider = null;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/struts/blob/008c28ac/core/src/test/java/org/apache/struts2/components/ComponentTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/struts2/components/ComponentTest.java b/core/src/test/java/org/apache/struts2/components/ComponentTest.java
index 80cf82b..dffa5d7 100644
--- a/core/src/test/java/org/apache/struts2/components/ComponentTest.java
+++ b/core/src/test/java/org/apache/struts2/components/ComponentTest.java
@@ -46,7 +46,6 @@ import org.apache.struts2.views.jsp.ui.TextFieldTag;
 import org.apache.struts2.views.jsp.ui.UpDownSelectTag;
 
 import com.opensymphony.xwork2.ActionContext;
-import com.opensymphony.xwork2.util.LocalizedTextUtil;
 
 /**
  * Test case for method findAncestor(Class) in Component and some commons

http://git-wip-us.apache.org/repos/asf/struts/blob/008c28ac/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 771c056..ab7ee0d 100644
--- a/core/src/test/java/org/apache/struts2/config/DefaultBeanSelectionProviderTest.java
+++ b/core/src/test/java/org/apache/struts2/config/DefaultBeanSelectionProviderTest.java
@@ -25,14 +25,11 @@ import java.util.Locale;
 
 import com.opensymphony.xwork2.XWorkTestCase;
 import com.opensymphony.xwork2.LocalizedTextProvider;
-import com.opensymphony.xwork2.config.Configuration;
 import com.opensymphony.xwork2.config.ConfigurationException;
-import com.opensymphony.xwork2.config.ConfigurationProvider;
 import com.opensymphony.xwork2.test.StubConfigurationProvider;
 import org.apache.struts2.StrutsConstants;
 
 import com.opensymphony.xwork2.inject.ContainerBuilder;
-import com.opensymphony.xwork2.util.LocalizedTextUtil;
 import com.opensymphony.xwork2.util.location.LocatableProperties;
 
 public class DefaultBeanSelectionProviderTest extends XWorkTestCase {

http://git-wip-us.apache.org/repos/asf/struts/blob/008c28ac/core/src/test/java/org/apache/struts2/config/PropertiesConfigurationProviderTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/struts2/config/PropertiesConfigurationProviderTest.java b/core/src/test/java/org/apache/struts2/config/PropertiesConfigurationProviderTest.java
index 123f8eb..05606ce 100644
--- a/core/src/test/java/org/apache/struts2/config/PropertiesConfigurationProviderTest.java
+++ b/core/src/test/java/org/apache/struts2/config/PropertiesConfigurationProviderTest.java
@@ -23,7 +23,7 @@ package org.apache.struts2.config;
 
 import com.opensymphony.xwork2.inject.Container;
 import com.opensymphony.xwork2.inject.ContainerBuilder;
-import com.opensymphony.xwork2.util.LocalizedTextUtil;
+import com.opensymphony.xwork2.util.DefaultLocalizedTextProvider;
 import com.opensymphony.xwork2.util.location.LocatableProperties;
 import junit.framework.TestCase;
 import org.apache.struts2.StrutsConstants;
@@ -49,7 +49,7 @@ public class PropertiesConfigurationProviderTest extends TestCase {
         Container container = builder.create(true);
 
         String localeStr = container.getInstance(String.class, StrutsConstants.STRUTS_LOCALE);
-        Locale locale = LocalizedTextUtil.localeFromString(localeStr, Locale.FRANCE);
+        Locale locale = DefaultLocalizedTextProvider.localeFromString(localeStr, Locale.FRANCE);
 
         assertNotNull(locale);
         assertEquals("DE", locale.getCountry());
@@ -68,7 +68,7 @@ public class PropertiesConfigurationProviderTest extends TestCase {
         Container container = builder.create(true);
 
         String localeStr = container.getInstance(String.class, StrutsConstants.STRUTS_LOCALE);
-        Locale locale = LocalizedTextUtil.localeFromString(localeStr, Locale.getDefault());
+        Locale locale = DefaultLocalizedTextProvider.localeFromString(localeStr, Locale.getDefault());
 
         assertNotNull(locale);
         Locale vmLocale = Locale.getDefault();

http://git-wip-us.apache.org/repos/asf/struts/blob/008c28ac/core/src/test/java/org/apache/struts2/config/SettingsTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/struts2/config/SettingsTest.java b/core/src/test/java/org/apache/struts2/config/SettingsTest.java
index 9f92f7d..11aacfc 100644
--- a/core/src/test/java/org/apache/struts2/config/SettingsTest.java
+++ b/core/src/test/java/org/apache/struts2/config/SettingsTest.java
@@ -22,7 +22,6 @@
 package org.apache.struts2.config;
 
 import com.opensymphony.xwork2.LocalizedTextProvider;
-import com.opensymphony.xwork2.util.LocalizedTextUtil;
 import org.apache.struts2.StrutsConstants;
 import org.apache.struts2.StrutsInternalTestCase;
 

http://git-wip-us.apache.org/repos/asf/struts/blob/008c28ac/plugins/pell-multipart/src/main/java/org/apache/struts2/dispatcher/multipart/PellMultiPartRequest.java
----------------------------------------------------------------------
diff --git a/plugins/pell-multipart/src/main/java/org/apache/struts2/dispatcher/multipart/PellMultiPartRequest.java b/plugins/pell-multipart/src/main/java/org/apache/struts2/dispatcher/multipart/PellMultiPartRequest.java
index c91c52e..9dba92e 100644
--- a/plugins/pell-multipart/src/main/java/org/apache/struts2/dispatcher/multipart/PellMultiPartRequest.java
+++ b/plugins/pell-multipart/src/main/java/org/apache/struts2/dispatcher/multipart/PellMultiPartRequest.java
@@ -21,7 +21,6 @@
 
 package org.apache.struts2.dispatcher.multipart;
 
-import com.opensymphony.xwork2.util.LocalizedTextUtil;
 import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.LogManager;
 import http.utils.multipartrequest.ServletMultipartRequest;
@@ -32,7 +31,6 @@ import java.io.UnsupportedEncodingException;
 import java.util.ArrayList;
 import java.util.Enumeration;
 import java.util.List;
-import java.util.Locale;
 
 
 /**

http://git-wip-us.apache.org/repos/asf/struts/blob/008c28ac/plugins/portlet/src/main/java/org/apache/struts2/portlet/dispatcher/Jsr168Dispatcher.java
----------------------------------------------------------------------
diff --git a/plugins/portlet/src/main/java/org/apache/struts2/portlet/dispatcher/Jsr168Dispatcher.java b/plugins/portlet/src/main/java/org/apache/struts2/portlet/dispatcher/Jsr168Dispatcher.java
index 42d7e30..9a15b87 100644
--- a/plugins/portlet/src/main/java/org/apache/struts2/portlet/dispatcher/Jsr168Dispatcher.java
+++ b/plugins/portlet/src/main/java/org/apache/struts2/portlet/dispatcher/Jsr168Dispatcher.java
@@ -26,8 +26,7 @@ import com.opensymphony.xwork2.ActionProxy;
 import com.opensymphony.xwork2.ActionProxyFactory;
 import com.opensymphony.xwork2.config.ConfigurationException;
 import com.opensymphony.xwork2.inject.Container;
-import com.opensymphony.xwork2.util.LocalizedTextUtil;
-import com.sun.net.httpserver.HttpsParameters;
+import com.opensymphony.xwork2.util.DefaultLocalizedTextProvider;
 import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.LogManager;
 import org.apache.commons.lang3.StringUtils;
@@ -397,7 +396,7 @@ public class Jsr168Dispatcher extends GenericPortlet implements StrutsStatics {
         String defaultLocale = container.getInstance(String.class, StrutsConstants.STRUTS_LOCALE);
         Locale locale;
         if (defaultLocale != null) {
-            locale = LocalizedTextUtil.localeFromString(defaultLocale, request.getLocale());
+            locale = DefaultLocalizedTextProvider.localeFromString(defaultLocale, request.getLocale());
         } else {
             locale = request.getLocale();
         }


Mime
View raw message