1 /* 2 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 import java.beans.BeanInfo; 25 import java.beans.BeanProperty; 26 import java.beans.Introspector; 27 import java.beans.PropertyChangeListener; 28 import java.beans.PropertyDescriptor; 29 30 /** 31 * @test 32 * @bug 8132566 8132565 8131939 33 * @summary Check if the derived class overrides 34 * the parent's property info. 35 * @author a.stepanov 36 */ 37 38 public class OverridePropertyInfoTest { 39 40 public static class C extends CBase { 41 42 private int value; 43 44 @BeanProperty( 45 bound = false, 46 expert = false, 47 hidden = false, 48 preferred = false, 49 required = false, 50 visualUpdate = false, 51 description = "CHILD", 52 enumerationValues = {"javax.swing.SwingConstants.BOTTOM"} 53 ) 54 @Override 55 public void setValue(int v) { value = v; } 56 @Override 57 public int getValue() { return value; } 58 59 @Override 60 public void addPropertyChangeListener(PropertyChangeListener l) {} 61 @Override 62 public void removePropertyChangeListener(PropertyChangeListener l) {} 63 } 64 65 public static void main(String[] args) throws Exception { 66 67 BeanInfo i = Introspector.getBeanInfo(C.class, Object.class); 68 PropertyDescriptor[] pds = i.getPropertyDescriptors(); 69 70 Checker.checkEq("number of properties", pds.length, 1); 71 PropertyDescriptor p = pds[0]; 72 Checker.checkEq("property description", p.getShortDescription(), "CHILD"); 73 74 Checker.checkEq("isBound", p.isBound(), false); 75 Checker.checkEq("isExpert", p.isExpert(), false); 76 Checker.checkEq("isHidden", p.isHidden(), false); 77 Checker.checkEq("isPreferred", p.isPreferred(), false); 78 Checker.checkEq("required", p.getValue("required"), false); 79 Checker.checkEq("visualUpdate", p.getValue("visualUpdate"), false); 80 81 Checker.checkEnumEq("enumerationValues", p.getValue("enumerationValues"), 82 new Object[]{"BOTTOM", 3, "javax.swing.SwingConstants.BOTTOM"}); 83 } 84 }