Update Javadocs, move to JUnit 5, update changes.xml location, cleanup some of the StringUtil method calls to improve readability

git-svn-id: https://svn.apache.org/repos/asf/turbine/fulcrum/trunk/localization@1851408 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/xdocs/changes.xml b/src/changes/changes.xml
similarity index 82%
rename from xdocs/changes.xml
rename to src/changes/changes.xml
index 7c96488..5e17813 100644
--- a/xdocs/changes.xml
+++ b/src/changes/changes.xml
@@ -24,6 +24,23 @@
   </properties>
 
   <body>
+    <release version="1.0.7" date="in SVN">
+	  <action dev="painter" type="update">
+        Moved changes.xml location for inclusion in report generation
+      </action>
+      <action dev="painter" type="update">
+        Update to Java 8
+      </action>
+      <action dev="painter" type="update">
+        Added commons-lang3
+      </action>
+      <action dev="painter" type="update">
+        Update unit tests to BaseUnit5Test
+      </action>
+      <action dev="painter" type="update">
+        Update to yaafi-1.0.8 and testcontainer 1.0.8
+      </action>    
+    </release>
     <release version="1.0.6" date="2009-06-18">
       <action dev="tv" type="add">
         Added a Maven-2 build.
diff --git a/src/java/org/apache/fulcrum/localization/DefaultLocalizationService.java b/src/java/org/apache/fulcrum/localization/DefaultLocalizationService.java
index 1f52571..d4deea0 100644
--- a/src/java/org/apache/fulcrum/localization/DefaultLocalizationService.java
+++ b/src/java/org/apache/fulcrum/localization/DefaultLocalizationService.java
@@ -27,9 +27,11 @@
 import org.apache.commons.lang3.StringUtils;
 
 /**
- * <p>This class is the single point of access to all localization
+ * <p>
+ * This class is the single point of access to all localization
  * resources.  It caches different ResourceBundles for different
- * Locales.</p>
+ * Locales.
+ * </p>
  *
  * <p>Usage example:</p>
  *
@@ -40,8 +42,10 @@
  * </code>
  * </pre>
  *
- * <p>Then call {@link #getString(String, Locale, String)}, or one of
- * four methods to retrieve a ResourceBundle:</p>
+ * <p>
+ * Then call {@link #getString(String, Locale, String)}, or one of
+ * four methods to retrieve a ResourceBundle:
+ * </p>
  *
  * <ul>
  * <li>getBundle("MyBundleName")</li>
@@ -78,6 +82,8 @@
      * This method returns a ResourceBundle given the bundle name and
      * the Locale information supplied in the HTTP "Accept-Language"
      * header.
+     * 
+     * @see org.apache.fulcrum.localization.LocalizationService#getBundle(java.lang.String, java.lang.String)
      *
      * @param bundleName Name of bundle.
      * @param languageHeader A String with the language header.
@@ -102,6 +108,8 @@
     }
 
     /**
+     * @see org.apache.fulcrum.localization.LocalizationService#getBundle(java.lang.String, javax.servlet.http.HttpServletRequest)
+     * 
      * This method returns a ResourceBundle given the bundle name and
      * the Locale information supplied in the HTTP "Accept-Language"
      * header which is stored in HttpServletRequest.
@@ -116,8 +124,8 @@
         return getBundle(bundleName, getLocale(req));
     }
 
-    /**
-     * @see org.apache.fulcrum.localization.LocalizationService#getLocale(HttpServletRequest)
+    /* (non-Javadoc)
+     * @see org.apache.fulcrum.localization.LocalizationService#getLocale(javax.servlet.http.HttpServletRequest)
      */
     public Locale getLocale(HttpServletRequest req)
     {
@@ -128,8 +136,8 @@
         //        return (l != null ? l : getLocale(req.getHeader(ACCEPT_LANGUAGE)));
     }
 
-    /**
-     * @see org.apache.fulcrum.localization.LocalizationService#getLocale(String)
+    /* (non-Javadoc)
+     * @see org.apache.fulcrum.localization.LocalizationService#getLocale(java.lang.String)
      */
     public Locale getLocale(String header)
     {
diff --git a/src/java/org/apache/fulcrum/localization/LocaleTokenizer.java b/src/java/org/apache/fulcrum/localization/LocaleTokenizer.java
index e7e90d6..7176f25 100644
--- a/src/java/org/apache/fulcrum/localization/LocaleTokenizer.java
+++ b/src/java/org/apache/fulcrum/localization/LocaleTokenizer.java
@@ -1,6 +1,5 @@
 package org.apache.fulcrum.localization;
 
-
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -28,8 +27,6 @@
 import java.util.NoSuchElementException;
 import java.util.StringTokenizer;
 
-import org.apache.fulcrum.localization.LocaleTokenizer.AcceptLanguage;
-
 /**
  * Parses the HTTP <code>Accept-Language</code> header as per section
  * 14.4 of RFC 2068 (HTTP 1.1 header field definitions).
@@ -38,7 +35,7 @@
  * @version $Id$
  */
 public class LocaleTokenizer
-    implements Iterator
+    implements Iterator<Object>
 {
     /**
      * Separates elements of the <code>Accept-Language</code> HTTP
diff --git a/src/java/org/apache/fulcrum/localization/LocalizationService.java b/src/java/org/apache/fulcrum/localization/LocalizationService.java
index 504cb9f..0bb6d2c 100644
--- a/src/java/org/apache/fulcrum/localization/LocalizationService.java
+++ b/src/java/org/apache/fulcrum/localization/LocalizationService.java
@@ -27,15 +27,19 @@
 import javax.servlet.http.HttpServletRequest;
 
 /**
- * <p>Provides localization functionality using the interface provided
+ * <p>
+ * Provides localization functionality using the interface provided
  * by <code>ResourceBundle</code>, plus leverages a "search path"
  * style traversal of the <code>ResourceBundle</code> objects named by
  * the <code>locale.default.bundles</code> to discover a value for a
- * given key.</p>
+ * given key.
+ * </p>
  *
- * <p>It is suggested that one handle
+ * <p>
+ * It is suggested that one handle
  * <a href="http://www.math.fu-berlin.de/~rene/www/java/tutorial/i18n/message/messageFormat.html">dealing with concatenated messages</a>
- * using <code>MessageFormat</code> and properties files.</p>
+ * using <code>MessageFormat</code> and properties files.
+ * </p>
  *
  * @author <a href="mailto:jon@latchkey.com">Jon S. Stevens</a>
  * @author <a href="mailto:dlr@finemaltcoding.com">Daniel Rall</a>
diff --git a/src/java/org/apache/fulcrum/localization/SimpleLocalizationService.java b/src/java/org/apache/fulcrum/localization/SimpleLocalizationService.java
index 27d3720..70b940a 100644
--- a/src/java/org/apache/fulcrum/localization/SimpleLocalizationService.java
+++ b/src/java/org/apache/fulcrum/localization/SimpleLocalizationService.java
@@ -1,6 +1,5 @@
 package org.apache.fulcrum.localization;
 
-
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -26,15 +25,19 @@
 import java.util.ResourceBundle;
 
 /**
- * <p>Provides localization functionality using the interface provided
+ * <p>
+ * Provides localization functionality using the interface provided
  * by <code>ResourceBundle</code>, plus leverages a "search path"
  * style traversal of the <code>ResourceBundle</code> objects named by
  * the <code>locale.default.bundles</code> to discover a value for a
- * given key.</p>
+ * given key.
+ * </p>
  *
- * <p>It is suggested that one handle
+ * <p>
+ * It is suggested that one handle
  * <a href="http://www.math.fu-berlin.de/~rene/www/java/tutorial/i18n/message/messageFormat.html">dealing with concatenated messages</a>
- * using <code>MessageFormat</code> and properties files.</p>
+ * using <code>MessageFormat</code> and properties files.
+ * </p>
  *
  * @author <a href="mailto:jon@latchkey.com">Jon S. Stevens</a>
  * @author <a href="mailto:dlr@finemaltcoding.com">Daniel Rall</a>
diff --git a/src/java/org/apache/fulcrum/localization/SimpleLocalizationServiceImpl.java b/src/java/org/apache/fulcrum/localization/SimpleLocalizationServiceImpl.java
index 566437a..a104293 100644
--- a/src/java/org/apache/fulcrum/localization/SimpleLocalizationServiceImpl.java
+++ b/src/java/org/apache/fulcrum/localization/SimpleLocalizationServiceImpl.java
@@ -34,9 +34,11 @@
 import org.apache.commons.lang3.StringUtils;
 
 /**
- * <p>This class is the single point of access to all localization
+ * <p>
+ * This class is the single point of access to all localization
  * resources.  It caches different ResourceBundles for different
- * Locales.</p>
+ * Locales.
+ * </p>
  *
  * <p>Usage example:</p>
  *
@@ -47,8 +49,10 @@
  * </code>
  * </pre>
  *
- * <p>Then call {@link #getString(String, Locale, String)}, or one of
- * two methods to retrieve a ResourceBundle:</p>
+ * <p>
+ * Then call {@link #getString(String, Locale, String)}, or one of
+ * two methods to retrieve a ResourceBundle:
+ * </p>
  *
  * <ul>
  * <li>getBundle("MyBundleName")</li>
@@ -163,7 +167,6 @@
     @Override
 	public void initialize() throws Exception
     {
-        // initBundleNames(null);
         defaultLocale = new Locale(defaultLanguage, defaultCountry);
         if (getLogger().isInfoEnabled())
         {
@@ -241,7 +244,7 @@
     }
     
     /**
-     * {@link org.apache.fulcrum.localization.SimpleLocalizationService#getBundle()}
+     * @see org.apache.fulcrum.localization.SimpleLocalizationService#getBundle()
      * 
      * @return the default resource bundle
      */
@@ -252,7 +255,7 @@
     }
     
     /**
-     * {@link org.apache.fulcrum.localization.SimpleLocalizationService#getBundle(String)}
+     * @see org.apache.fulcrum.localization.SimpleLocalizationService#getBundle(java.lang.String)
      * 
      * @param bundleName the name of a bundle
      * @return the resource bundle
@@ -264,6 +267,8 @@
     }
     
     /**
+     * @see org.apache.fulcrum.localization.SimpleLocalizationService#getBundle(java.lang.String, java.util.Locale)
+     * 
      * This method returns a ResourceBundle for the given bundle name
      * and the given Locale.
      *
@@ -385,7 +390,7 @@
         Map<Locale, ResourceBundle> bundlesByLocale)
     {
         ResourceBundle rb = null;
-        if (!StringUtils.isNotEmpty(locale.getCountry())
+        if (StringUtils.isEmpty(locale.getCountry())
             && defaultLanguage.equals(locale.getLanguage()))
         {
             /*
@@ -402,7 +407,7 @@
             }
         }
         else if (
-            !StringUtils.isNotEmpty(locale.getLanguage())
+            StringUtils.isEmpty(locale.getLanguage())
                 && defaultCountry.equals(locale.getCountry()))
         {
             Locale withDefaultLanguage =
@@ -413,6 +418,7 @@
                 rb = getBundleIgnoreException(bundleName, withDefaultLanguage);
             }
         }
+        
         if (rb == null && !defaultLocale.equals(locale))
         {
             rb = getBundleIgnoreException(bundleName, defaultLocale);
@@ -582,8 +588,8 @@
         return format(bundleName, locale, key, new Object[] { arg1 });
     }
     
-    /**
-     * {@link org.apache.fulcrum.localization.SimpleLocalizationService#format(String, Locale, String, Object, Object)}
+    /* (non-Javadoc)
+     * @see org.apache.fulcrum.localization.SimpleLocalizationService#format(java.lang.String, java.util.Locale, java.lang.String, java.lang.Object, java.lang.Object)
      */
     @Override
 	public String format(
diff --git a/src/test/org/apache/fulcrum/localization/LocaleTokenizerTest.java b/src/test/org/apache/fulcrum/localization/LocaleTokenizerTest.java
index 4af9db9..16f72de 100644
--- a/src/test/org/apache/fulcrum/localization/LocaleTokenizerTest.java
+++ b/src/test/org/apache/fulcrum/localization/LocaleTokenizerTest.java
@@ -1,6 +1,5 @@
 package org.apache.fulcrum.localization;
 
-
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -20,12 +19,15 @@
  * under the License.
  */
 
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
 
 import java.util.Locale;
 
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import org.apache.fulcrum.testcontainer.BaseUnit5Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
 
 /**
  * Test case for the locale tokenizer.
@@ -34,35 +36,32 @@
  * @author <a href="mailto:jason@zenplex.com">Jason van Zyl</a>
  * @version $Id$
  */
-public class LocaleTokenizerTest
-    extends TestCase
+public class LocaleTokenizerTest extends BaseUnit5Test
 {
     private static final String HEADER = "en, es;q=0.8, zh-TW;q=0.1";
 
-    public LocaleTokenizerTest(String name)
-    {
-        super(name);
+    @BeforeEach
+    public void setup() {
+    	
     }
-
-    public static Test suite()
-    {
-        return new TestSuite(LocaleTokenizerTest.class);
-    }
-
+    
+    @Test
     public void testLocaleTokenizer()
     {
         try
         {
             LocaleTokenizer tok = new LocaleTokenizer(HEADER);
             Locale locale = (Locale) tok.next();
-            assertEquals("Either wrong language or order parsing: " + locale,
-                         locale.getLanguage(), "en");
+            assertEquals(locale.getLanguage(), "en",
+            		"Either wrong language or order parsing: " + locale);
+            
             locale = (Locale) tok.next();
-            assertEquals("Either wrong language or order parsing: " + locale,
-                         locale.getLanguage(), "es");
+            assertEquals(locale.getLanguage(), "es",
+            		"Either wrong language or order parsing: " + locale);
+            
             locale = (Locale) tok.next();
-            assertEquals("Either wrong country or order parsing: " + locale,
-                         locale.getCountry(), "TW");
+            assertEquals(locale.getLanguage(), "zh",
+            		"Either wrong language or order parsing: " + locale);
         }
         catch (Exception e)
         {
diff --git a/src/test/org/apache/fulcrum/localization/LocalizationTest.java b/src/test/org/apache/fulcrum/localization/LocalizationTest.java
index c75c6ab..9908f15 100644
--- a/src/test/org/apache/fulcrum/localization/LocalizationTest.java
+++ b/src/test/org/apache/fulcrum/localization/LocalizationTest.java
@@ -19,72 +19,56 @@
  * under the License.
  */
 
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
+
 import java.util.Locale;
 import java.util.MissingResourceException;
 
-import org.apache.fulcrum.testcontainer.BaseUnitTest;
+import org.apache.fulcrum.testcontainer.BaseUnit5Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 /**
  * Tests the API of the
  * {@link org.apache.fulcrum.localization.LocalizationService}.
- * <br>
  *
  * @author <a href="mailto:mcconnell@apache.org">Stephen McConnell</a>
  * @author <a href="mailto:dlr@finemaltcoding.com">Daniel Rall</a>
  * @author <a href="mailto:jason@zenplex.com">Jason van Zyl</a>
  */
-public class LocalizationTest extends BaseUnitTest
+public class LocalizationTest extends BaseUnit5Test
 {
 
-    private LocalizationService ls = null;
-    public LocalizationTest(String name)
-    {
-        super( name );
-    }
+    private LocalizationService localizationService = null;
 
-    /**
-     * Perform test setup
-     * 
-     * @throws Exception generic exception
-     */
+    @BeforeEach
     public void setUp() throws Exception
     {
-        super.setUp();
-        try
-        {
-            ls = (LocalizationService) this.resolve( LocalizationService.class.getName() );
-        }
-        catch (Throwable e)
-        {
-            fail(e.getMessage());
-        }
+    	localizationService = (LocalizationService) lookup(LocalizationService.ROLE);
     }
     
     
     /**
-     * Test init
-     */
-    public void testInitialization()
-    {
-        assertTrue(true);
-    }
-    
-    /**
      * Test localization
      * @throws Exception generic exception
      */
+    @Test
     public void testLocalization() throws Exception
     {
         // Test retrieval of text using multiple default bundles
-        String s = ls.getString(null, null, "key1");
-        assertEquals("Unable to retrieve localized text for locale: default", "value1", s);
-        s = ls.getString(null, new Locale("en", "US"), "key2");
-        assertEquals("Unable to retrieve localized text for locale: en-US", "value2", s);
-        s = ls.getString("org.apache.fulcrum.localization.BarBundle", new Locale("ko", "KR"), "key3");
-        assertEquals("Unable to retrieve localized text for locale: ko-KR", s, "[ko] value3");
+        String s = localizationService.getString(null, null, "key1");
+        assertEquals("value1", s, "Unable to retrieve localized text for locale: default");
+        
+        s = localizationService.getString(null, new Locale("en", "US"), "key2");
+        assertEquals("value2", s, "Unable to retrieve localized text for locale: en-US");
+        
+        s = localizationService.getString("org.apache.fulcrum.localization.BarBundle", new Locale("ko", "KR"), "key3");
+        assertEquals(s, "[ko] value3", "Unable to retrieve localized text for locale: ko-KR");
+        
         try
         {
-            ls.getString("DoesNotExist", new Locale("ko", ""), "key1");
+            localizationService.getString("DoesNotExist", new Locale("ko", ""), "key1");
             fail();
         }
         catch (MissingResourceException expectedFailure)
@@ -96,13 +80,15 @@
             // should not happen
             fail();
         }
+        
         // When a locale is used which cannot be produced for a given
         // bundle, fall back to the default locale.
-        s = ls.getString(null, new Locale("ko", "KR"), "key4");
-        assertEquals("Unable to retrieve localized text for locale: default", s, "value4");
+        s = localizationService.getString(null, new Locale("ko", "KR"), "key4");
+        assertEquals(s, "value4", "Unable to retrieve localized text for locale: default");
+        
         try
         {
-            ls.getString(null, null, "NoSuchKey");
+            localizationService.getString(null, null, "NoSuchKey");
             fail();
         }
         catch (MissingResourceException expectedFailure)
@@ -111,7 +97,7 @@
         }
     }
     
-    
+    @Test
     public void testGetString()
     {
         String key1 = "key1";
@@ -123,23 +109,25 @@
         String key4 = "key4";
         String value4 = "value4";
 
-        assertEquals(value1, ls.getString(key1));
-        assertEquals(value2, ls.getString(key2));
-        assertEquals(value3, ls.getString(key3));
-        assertEquals(value4, ls.getString(key4));
+        assertEquals(value1, localizationService.getString(key1));
+        assertEquals(value2, localizationService.getString(key2));
+        assertEquals(value3, localizationService.getString(key3));
+        assertEquals(value4, localizationService.getString(key4));
 
     }
     
     /**
-     * Putting this in a seperate testcase because it fails..  Why?  I don't know.  I have never
+     * Putting this in a separate test case because it fails..  Why?  I don't know.  I have never
      * used localization, so I leave it to brains better then mine. -dep
      * 
      * @throws Exception generic exception
      */
+    /*
     public void OFFtestRetrievingOddLocale() throws Exception
     {
     	// TODO Figure out why this test fails!
-        String s = ls.getString(null, new Locale("fr", "US"), "key3");
-        assertEquals("Unable to retrieve localized text for locale: fr", "[fr] value3", s);
+        String s = localizationService.getString(null, new Locale("fr", "US"), "key3");
+        assertEquals("[fr] value3", s, "Unable to retrieve localized text for locale: fr");
     }
+    */
 }