Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 87775 invoked from network); 14 May 2007 06:08:47 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 14 May 2007 06:08:47 -0000 Received: (qmail 32631 invoked by uid 500); 14 May 2007 06:08:52 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 32555 invoked by uid 500); 14 May 2007 06:08:52 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 32492 invoked by uid 99); 14 May 2007 06:08:51 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 13 May 2007 23:08:51 -0700 X-ASF-Spam-Status: No, hits=-99.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 13 May 2007 23:08:44 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 343FB1A983E; Sun, 13 May 2007 23:08:24 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@harmony.apache.org From: pyang@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070514060824.343FB1A983E@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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; + } + + } + +}