harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ton...@apache.org
Subject svn commit: r645830 - in /harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/util/ main/java/org/apache/harmony/luni/util/ test/api/common/org/apache/harmony/luni/tests/java/util/
Date Tue, 08 Apr 2008 10:31:08 GMT
Author: tonywu
Date: Tue Apr  8 03:31:04 2008
New Revision: 645830

URL: http://svn.apache.org/viewvc?rev=645830&view=rev
Log:
Apply patch for HARMONY-5698 ([classlib][luni] MissingResourceException is missing localized
message)

Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/ResourceBundle.java
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/ExternalMessages.properties
    harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ResourceBundleTest.java

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/ResourceBundle.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/ResourceBundle.java?rev=645830&r1=645829&r2=645830&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/ResourceBundle.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/ResourceBundle.java
Tue Apr  8 03:31:04 2008
@@ -23,6 +23,7 @@
 import java.security.PrivilegedAction;
 
 import org.apache.harmony.kernel.vm.VM;
+import org.apache.harmony.luni.util.Msg;
 
 /**
  * ResourceBundle is an abstract class which is the superclass of classes which
@@ -134,7 +135,7 @@
                     "_" + Locale.getDefault(), true, loader)) != null) { //$NON-NLS-1$
                 return bundle;
             }
-            throw new MissingResourceException(null, bundleName + '_' + locale,
+            throw new MissingResourceException(Msg.getString("KA029", bundleName, locale),
bundleName + '_' + locale, //$NON-NLS-1$
                     ""); //$NON-NLS-1$
         }
         throw new NullPointerException();
@@ -161,7 +162,7 @@
             if ((bundle = handleGetBundle(bundleName, localeName, true, loader)) != null)
{
                 return bundle;
             }
-            throw new MissingResourceException(null, bundleName + '_' + locale,
+            throw new MissingResourceException(Msg.getString("KA029", bundleName, locale),
bundleName + '_' + locale, //$NON-NLS-1$
                     ""); //$NON-NLS-1$
         }
         throw new NullPointerException();
@@ -203,7 +204,7 @@
             last = theParent;
             theParent = theParent.parent;
         } while (theParent != null);
-        throw new MissingResourceException(null, last.getClass().getName(), key);
+        throw new MissingResourceException(Msg.getString("KA029", last.getClass().getName(),
key), last.getClass().getName(), key); //$NON-NLS-1$
     }
 
     /**

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/ExternalMessages.properties
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/ExternalMessages.properties?rev=645830&r1=645829&r2=645830&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/ExternalMessages.properties
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/ExternalMessages.properties
Tue Apr  8 03:31:04 2008
@@ -321,3 +321,4 @@
 KA026=JAR entry {0} not found in {1}
 KA027=Inputstream of the JarURLConnection has been closed
 KA028=Cannot set protocol version when stream in use
+KA029=Can't find resource for bundle {0}, key {1}

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ResourceBundleTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ResourceBundleTest.java?rev=645830&r1=645829&r2=645830&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ResourceBundleTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ResourceBundleTest.java
Tue Apr  8 03:31:04 2008
@@ -65,6 +65,14 @@
 		bundle = ResourceBundle.getBundle(name, new Locale("de", "FR", "var"));
 		assertEquals("Wrong bundle de_FR_var 2", "parentValue4", bundle.getString("parent4")
 				);
+        
+        // Regression test for Harmony-5698
+        try {
+            ResourceBundle.getBundle("Does not exist",Locale.getDefault());
+            fail("Should throw MissingResourceException");
+        } catch (MissingResourceException e) {
+            assertNotNull(e.getLocalizedMessage());
+        }
 
 		// Test with a security manager
 		Locale.setDefault(new Locale("en", "US"));
@@ -134,6 +142,14 @@
 		String s = bb.find("nonexistent");
 		s = bb.find("name");
 		assertEquals("Wrong property got", "Name", s);
+        
+        // Regression test for Harmony-5698
+        try {
+            ResourceBundle.getBundle("Does not exist",Locale.getDefault(), loader);
+            fail("Should throw MissingResourceException");
+        } catch (MissingResourceException e) {
+            assertNotNull(e.getLocalizedMessage());
+        }
 	}
 
 	/**
@@ -158,7 +174,32 @@
 				"frFRVARChildValue2", bundle.getString("child2"));
 		assertEquals("Wrong value child1", 
 				"frFRVARChildValue1", bundle.getString("child1"));
+        
+		// Regression test for Harmony-5698
+        try {
+            ResourceBundle.getBundle("Does not exist");
+            fail("Should throw MissingResourceException");
+        } catch (MissingResourceException e) {
+            assertNotNull(e.getLocalizedMessage());
+        }
 	}
+
+    /**
+     * @tests java.util.ResourceBundle#getObject(java.lang.String)
+     */
+    public void test_getObjectLjava_lang_String() {
+        // Regression test for Harmony-5698
+        try {
+            ResourceBundle bundle;
+            String name = "tests.support.Support_TestResource";
+            Locale.setDefault(new Locale("en", "US"));
+            bundle = ResourceBundle.getBundle(name, new Locale("fr", "FR", "VAR"));
+            bundle.getObject("not exist");
+            fail("Should throw MissingResourceException");
+        } catch (MissingResourceException e) {
+            assertNotNull(e.getLocalizedMessage());
+        }
+    }
 
     public void test_getBundle_getClassName() {
         // Regression test for Harmony-1759



Mime
View raw message