harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From py...@apache.org
Subject svn commit: r537719 - in /harmony/enhanced/classlib/trunk/modules/beans/src: main/java/java/beans/beancontext/BeanContextSupport.java test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextSupport2Test.java
Date Mon, 14 May 2007 06:08:23 GMT
Author: pyang
Date: Sun May 13 23:08:23 2007
New Revision: 537719

URL: http://svn.apache.org/viewvc?view=rev&rev=537719
Log:
Apply patch for HARMONY-3774([classlib][beans]java.beans.beanscontext.BeanContextSupport.setLocale(null)
should have no effect as spec says, but Harmony set it as default locale.)

Added:
    harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextSupport2Test.java
Modified:
    harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/beancontext/BeanContextSupport.java

Modified: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/beancontext/BeanContextSupport.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/beancontext/BeanContextSupport.java?view=diff&rev=537719&r1=537718&r2=537719
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/beancontext/BeanContextSupport.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/beancontext/BeanContextSupport.java
Sun May 13 23:08:23 2007
@@ -948,8 +948,10 @@
     public synchronized void setLocale(Locale newLocale)
             throws PropertyVetoException {
 
-        // Use default locale if a new value is null
-        newLocale = (newLocale == null ? Locale.getDefault() : newLocale);
+        // As spec says, if newLocale is null, the invocation has no effect.
+        if (null == newLocale) {
+            return;
+        }
 
         // Notify BeanContext about this change
         Locale old = (Locale) this.locale.clone();

Added: harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextSupport2Test.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextSupport2Test.java?view=auto&rev=537719
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextSupport2Test.java
(added)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextSupport2Test.java
Sun May 13 23:08:23 2007
@@ -0,0 +1,55 @@
+/* 
+ * 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 org.apache.harmony.beans.tests.java.beans.beancontext;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.beans.beancontext.BeanContextSupport;
+import java.util.Locale;
+
+import junit.framework.TestCase;
+
+public class BeanContextSupport2Test extends TestCase {
+    
+    //Regression for HARMONY-3774.
+    public void test_setLocale_null() throws Exception
+    {
+        Locale locale = Locale.FRANCE;
+        BeanContextSupport beanContextSupport = new BeanContextSupport(null, locale);
+        assertEquals(Locale.FRANCE, beanContextSupport.getLocale());
+        MyPropertyChangeListener myPropertyChangeListener = new MyPropertyChangeListener();
+        beanContextSupport.addPropertyChangeListener("locale", myPropertyChangeListener);
+        beanContextSupport.setLocale(null);
+        assertEquals(Locale.FRANCE, beanContextSupport.getLocale());
+        assertFalse(myPropertyChangeListener.changed);        
+    }
+    
+    private class MyPropertyChangeListener implements PropertyChangeListener {
+        public boolean changed = false;
+
+        public void propertyChange(PropertyChangeEvent event) {
+            changed = true;
+        }
+
+        public void reset() {
+            changed = false;
+        }
+
+    }
+
+}



Mime
View raw message