From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25874 invoked by alias); 28 Nov 2006 12:37:35 -0000 Received: (qmail 25859 invoked by uid 22791); 28 Nov 2006 12:37:34 -0000 X-Spam-Check-By: sourceware.org Received: from moutng.kundenserver.de (HELO moutng.kundenserver.de) (212.227.126.171) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 28 Nov 2006 12:37:22 +0000 Received: from [212.126.219.82] (helo=mail.aicas.de) by mrelayeu.kundenserver.de (node=mrelayeu2) with ESMTP (Nemesis), id 0MKwtQ-1Gp2D914Pj-0007Rz; Tue, 28 Nov 2006 13:37:19 +0100 Received: from mail.aicas.burg (caribic.aicas.burg [192.168.1.3]) by mail.aicas.de (Postfix) with ESMTP id 01CC254000D for ; Tue, 28 Nov 2006 13:37:19 +0100 (CET) Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.aicas.burg (Postfix) with ESMTP id D5A4D6BC989 for ; Tue, 28 Nov 2006 13:37:18 +0100 (CET) Received: from mail.aicas.burg ([127.0.0.1]) by localhost (www.aicas.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 05763-09 for ; Tue, 28 Nov 2006 13:37:07 +0100 (CET) Received: from [192.168.1.112] (moonlight.aicas.burg [192.168.1.112]) by mail.aicas.burg (Postfix) with ESMTP id 0BE4A6BC97B for ; Tue, 28 Nov 2006 13:36:57 +0100 (CET) Subject: FYI: New JComponent.putClientProperty() test From: Roman Kennke To: mauve-patches Content-Type: multipart/mixed; boundary="=-AEyKTl3PJ/RvrjBjX/Y2" Date: Tue, 28 Nov 2006 12:37:00 -0000 Message-Id: <1164717416.6844.1.camel@localhost> Mime-Version: 1.0 X-Mailer: Evolution 2.8.1 Mailing-List: contact mauve-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: mauve-patches-owner@sourceware.org X-SW-Source: 2006/txt/msg00754.txt.bz2 --=-AEyKTl3PJ/RvrjBjX/Y2 Content-Type: text/plain Content-Transfer-Encoding: 7bit Content-length: 603 This adds a test for JComponent.putClientProperty() that tests if an event should be fired, when a property that is null has putClientProperty() called with null. No event should be fired in that case. This is different from the behaviour of PropertyChangeSupport which fires an event in that case. I also added a testcase for this. 2006-11-28 Roman Kennke * gnu/testlet/java/beans/PropertyChangeSupport/firePropertyChange.java: New test. * gnu/testlet/javax/swing/JComponent/putClientProperty.java: Added check for how setting a null property fires an event or not. /Roman --=-AEyKTl3PJ/RvrjBjX/Y2 Content-Disposition: attachment; filename=patch.diff Content-Type: text/x-patch; name=patch.diff; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-length: 4528 Index: gnu/testlet/java/beans/PropertyChangeSupport/firePropertyChange.java =================================================================== RCS file: gnu/testlet/java/beans/PropertyChangeSupport/firePropertyChange.java diff -N gnu/testlet/java/beans/PropertyChangeSupport/firePropertyChange.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ gnu/testlet/java/beans/PropertyChangeSupport/firePropertyChange.java 28 Nov 2006 12:34:45 -0000 @@ -0,0 +1,73 @@ +/* firePropertyChange.java -- Tests firePropertyChange() + Copyright (C) 2006 Roman Kennke (kennke@aicas.com) +This file is part of Mauve. + +Mauve is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +Mauve is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Mauve; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +*/ + +// Tags: JDK1.2 + +package gnu.testlet.java.beans.PropertyChangeSupport; + +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeSupport; +import java.util.ArrayList; + +import junit.framework.TestCase; + +public class firePropertyChange extends TestCase + implements PropertyChangeListener +{ + /** + * The object to test. + */ + private PropertyChangeSupport change; + + /** + * The received events. + */ + private ArrayList events; + + public void setUp() + { + change = new PropertyChangeSupport(this); + change.addPropertyChangeListener(this); + events = new ArrayList(); + } + + public void tearDown() + { + change = null; + events = null; + } + + public void testNullNull() + { + change.firePropertyChange("test", null, null); + assertEquals(events.size(), 1); + PropertyChangeEvent ev = (PropertyChangeEvent) events.get(0); + assertEquals(ev.getPropertyName(), "test"); + assertNull(ev.getNewValue()); + assertNull(ev.getOldValue()); + } + + public void propertyChange(PropertyChangeEvent e) + { + events.add(e); + } +} Index: gnu/testlet/javax/swing/JComponent/putClientProperty.java =================================================================== RCS file: /cvs/mauve/mauve/gnu/testlet/javax/swing/JComponent/putClientProperty.java,v retrieving revision 1.1 diff -u -1 -5 -r1.1 putClientProperty.java --- gnu/testlet/javax/swing/JComponent/putClientProperty.java 12 Sep 2005 21:55:39 -0000 1.1 +++ gnu/testlet/javax/swing/JComponent/putClientProperty.java 28 Nov 2006 12:34:45 -0000 @@ -45,38 +45,48 @@ { name = e.getPropertyName(); oldValue = e.getOldValue(); newValue = e.getNewValue(); } /** * Runs the test using the specified harness. * * @param harness the test harness (null not permitted). */ public void test(TestHarness harness) { JComponent label = new JLabel("Test"); label.addPropertyChangeListener(this); - + // add a new property label.putClientProperty("Property1", Boolean.TRUE); harness.check(label.getClientProperty("Property1"), Boolean.TRUE); harness.check(name, "Property1"); harness.check(oldValue, null); harness.check(newValue, Boolean.TRUE); - + + // Set testnull to null. No event is fired. + label.putClientProperty("testnull", null); + name = null; + oldValue = null; + newValue = null; + label.putClientProperty("testnull", null); + harness.check(name, null); + harness.check(oldValue, null); + harness.check(newValue, null); + // overwrite an existing property label.putClientProperty("Property1", Boolean.FALSE); harness.check(label.getClientProperty("Property1"), Boolean.FALSE); harness.check(name, "Property1"); harness.check(oldValue, Boolean.TRUE); harness.check(newValue, Boolean.FALSE); // clear the property label.putClientProperty("Property1", null); harness.check(label.getClientProperty("Property1"), null); harness.check(name, "Property1"); harness.check(oldValue, Boolean.FALSE); harness.check(newValue, null); // try a null key --=-AEyKTl3PJ/RvrjBjX/Y2--