0N/A/*
2362N/A * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/A/*
0N/A * @test
0N/A * @bug 5004188
0N/A * @summary Tests sequence of methods
0N/A * @author Sergey Malenkov
0N/A */
0N/A
0N/Aimport java.beans.PropertyChangeEvent;
0N/Aimport java.beans.PropertyChangeListener;
0N/Aimport java.beans.PropertyChangeSupport;
0N/A
0N/Aenum Fire {
0N/A PropertyChangeEvent,
0N/A PropertyObject,
0N/A PropertyInteger,
0N/A PropertyBoolean,
0N/A IndexedPropertyObject,
0N/A IndexedPropertyInteger,
0N/A IndexedPropertyBoolean,
0N/A}
0N/A
0N/Apublic class TestMethods extends PropertyChangeSupport implements PropertyChangeListener {
0N/A private static final String NAME = "property";
0N/A
0N/A public static void main(String[] args) {
0N/A Object source = new Object();
0N/A new TestMethods(source).firePropertyChange(new PropertyChangeEvent(source, NAME, null, null));
0N/A new TestMethods(source).firePropertyChange(NAME, null, null);
0N/A new TestMethods(source).firePropertyChange(NAME, 0, 1);
0N/A new TestMethods(source).firePropertyChange(NAME, true, false);
0N/A new TestMethods(source).fireIndexedPropertyChange(NAME, 0, null, null);
0N/A new TestMethods(source).fireIndexedPropertyChange(NAME, 0, 0, 1);
0N/A new TestMethods(source).fireIndexedPropertyChange(NAME, 0, true, false);
0N/A }
0N/A
0N/A private Fire state;
0N/A
0N/A public TestMethods(Object source) {
0N/A super(source);
0N/A addPropertyChangeListener(this);
0N/A }
0N/A
0N/A public void propertyChange(PropertyChangeEvent event) {
0N/A if (this.state != Fire.PropertyChangeEvent)
0N/A throw new Error("Illegal state: " + this.state);
0N/A }
0N/A
0N/A @Override
0N/A public void firePropertyChange(String property, Object oldValue, Object newValue) {
0N/A if ((this.state != null) && (this.state != Fire.PropertyBoolean) && (this.state != Fire.PropertyInteger))
0N/A throw new Error("Illegal state: " + this.state);
0N/A
0N/A this.state = Fire.PropertyObject;
0N/A super.firePropertyChange(property, oldValue, newValue);
0N/A }
0N/A
0N/A @Override
0N/A public void firePropertyChange(String property, int oldValue, int newValue) {
0N/A if (this.state != null)
0N/A throw new Error("Illegal state: " + this.state);
0N/A
0N/A this.state = Fire.PropertyInteger;
0N/A super.firePropertyChange(property, oldValue, newValue);
0N/A }
0N/A
0N/A @Override
0N/A public void firePropertyChange(String property, boolean oldValue, boolean newValue) {
0N/A if (this.state != null)
0N/A throw new Error("Illegal state: " + this.state);
0N/A
0N/A this.state = Fire.PropertyBoolean;
0N/A super.firePropertyChange(property, oldValue, newValue);
0N/A }
0N/A
0N/A @Override
0N/A public void firePropertyChange(PropertyChangeEvent event) {
0N/A if ((this.state != null) && (this.state != Fire.PropertyObject) && (this.state != Fire.IndexedPropertyObject))
0N/A throw new Error("Illegal state: " + this.state);
0N/A
0N/A this.state = Fire.PropertyChangeEvent;
0N/A super.firePropertyChange(event);
0N/A }
0N/A
0N/A @Override
0N/A public void fireIndexedPropertyChange(String property, int index, Object oldValue, Object newValue) {
0N/A if ((this.state != null) && (this.state != Fire.IndexedPropertyBoolean) && (this.state != Fire.IndexedPropertyInteger))
0N/A throw new Error("Illegal state: " + this.state);
0N/A
0N/A this.state = Fire.IndexedPropertyObject;
0N/A super.fireIndexedPropertyChange(property, index, oldValue, newValue);
0N/A }
0N/A
0N/A @Override
0N/A public void fireIndexedPropertyChange(String property, int index, int oldValue, int newValue) {
0N/A if (this.state != null)
0N/A throw new Error("Illegal state: " + this.state);
0N/A
0N/A this.state = Fire.IndexedPropertyInteger;
0N/A super.fireIndexedPropertyChange(property, index, oldValue, newValue);
0N/A }
0N/A
0N/A @Override
0N/A public void fireIndexedPropertyChange(String property, int index, boolean oldValue, boolean newValue) {
0N/A if (this.state != null)
0N/A throw new Error("Illegal state: " + this.state);
0N/A
0N/A this.state = Fire.IndexedPropertyBoolean;
0N/A super.fireIndexedPropertyChange(property, index, oldValue, newValue);
0N/A }
0N/A}