jdk/test/java/beans/Introspector/4058433/TestBeanInfoPriority.java
author lana
Tue, 23 May 2017 21:11:42 +0000
changeset 45187 331a6542b5b8
parent 32133 5d1adcc1c3e6
permissions -rw-r--r--
Added tag jdk-10+7 for changeset d554736d963e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
32133
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
     1
/*
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
     4
 *
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
     7
 * published by the Free Software Foundation.
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
     8
 *
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    13
 * accompanied this code).
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    14
 *
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    18
 *
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    21
 * questions.
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    22
 */
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    23
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    24
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    25
import java.awt.event.ActionListener;
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    26
import java.awt.event.MouseListener;
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    27
import java.beans.BeanDescriptor;
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    28
import java.beans.BeanInfo;
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    29
import java.beans.BeanProperty;
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    30
import java.beans.EventSetDescriptor;
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    31
import java.beans.IntrospectionException;
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    32
import java.beans.Introspector;
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    33
import java.beans.JavaBean;
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    34
import java.beans.MethodDescriptor;
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    35
import java.beans.PropertyDescriptor;
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    36
import java.beans.SimpleBeanInfo;
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    37
import javax.swing.SwingContainer;
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    38
import java.util.Arrays;
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    39
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    40
/**
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    41
 * @test
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    42
 * @bug 4058433 8131055
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    43
 * @summary Check if the user-defined bean info
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    44
 *          is not overridden with the annotated one.
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    45
 * @author a.stepanov
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    46
 */
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    47
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    48
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    49
public class TestBeanInfoPriority {
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    50
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    51
    // ========== test bean (annotations must be ignored!) ==========
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    52
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    53
    @JavaBean(
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    54
            description = "annotation-description",
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    55
            defaultProperty = "other",
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    56
            defaultEventSet = "mouse")
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    57
    @SwingContainer(value = false)
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    58
    public static class TestClass {
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    59
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    60
        private int    value;
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    61
        private double other;
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    62
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    63
        @BeanProperty(
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    64
                bound     = false,
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    65
                expert    = false,
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    66
                hidden    = false,
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    67
                preferred = false,
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    68
                required  = false,
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    69
                visualUpdate = false,
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    70
                description = "annotation-value",
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    71
                enumerationValues = {
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    72
                    "javax.swing.SwingConstants.NORTH"}
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    73
                )
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    74
        public void setValue(int v) { value = v; }
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    75
        public  int getValue()      { return value; }
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    76
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    77
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    78
        @BeanProperty(
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    79
            bound     = true,
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    80
            expert    = true,
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    81
            hidden    = true,
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    82
            preferred = true,
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    83
            required  = true,
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    84
            visualUpdate = true,
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    85
            description = "annotation-other",
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    86
            enumerationValues = {
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    87
                "javax.swing.SwingConstants.LEFT",
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    88
                "javax.swing.SwingConstants.RIGHT",
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    89
                "javax.swing.SwingConstants.CENTER"}
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    90
            )
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    91
        public   void setOther(double o) { other = o; }
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    92
        public double getOther()         { return other; }
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    93
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    94
        public void addActionListener(ActionListener l) {}
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    95
        public void removeActionListener(ActionListener l) {}
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    96
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    97
        public void addMouseListener(MouseListener l) {}
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    98
        public void removeMouseListener(MouseListener l) {}
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
    99
    }
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   100
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   101
    // ========== user-defined bean info ==========
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   102
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   103
    public static class TestClassBeanInfo extends SimpleBeanInfo {
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   104
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   105
        private static final int iOther = 0;
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   106
        private static final int iValue = 1;
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   107
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   108
        private static final int iAction = 0;
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   109
        private static final int iMouse  = 1;
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   110
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   111
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   112
        @Override
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   113
        public BeanDescriptor getBeanDescriptor() {
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   114
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   115
            BeanDescriptor bd = new BeanDescriptor(TestClass.class, null);
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   116
            bd.setShortDescription("user-defined-description");
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   117
            bd.setValue("isContainer", true);
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   118
            bd.setValue("containerDelegate", "user-defined-delegate");
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   119
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   120
            return bd;
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   121
        }
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   122
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   123
        @Override
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   124
        public PropertyDescriptor[] getPropertyDescriptors() {
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   125
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   126
            PropertyDescriptor[] p = new PropertyDescriptor[2];
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   127
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   128
            try {
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   129
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   130
                // value
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   131
                PropertyDescriptor pdValue = new PropertyDescriptor(
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   132
                    "value", TestClass.class, "getValue", "setValue");
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   133
                pdValue.setBound(true);
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   134
                pdValue.setConstrained(true);
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   135
                pdValue.setExpert(true);
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   136
                pdValue.setHidden(true);
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   137
                pdValue.setPreferred(true);
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   138
                pdValue.setValue("required", true);
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   139
                pdValue.setValue("visualUpdate", true);
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   140
                pdValue.setShortDescription("user-defined-value");
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   141
                pdValue.setValue("enumerationValues", new Object[]{
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   142
                        "EAST", 3, "javax.swing.SwingConstants.EAST",
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   143
                        "WEST", 7, "javax.swing.SwingConstants.WEST"});
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   144
                p[iValue] = pdValue;
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   145
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   146
                // other
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   147
                PropertyDescriptor pdOther = new PropertyDescriptor(
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   148
                        "other", TestClass.class, "getOther", "setOther");
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   149
                pdOther.setBound(false);
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   150
                pdOther.setConstrained(false);
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   151
                pdOther.setExpert(false);
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   152
                pdOther.setHidden(false);
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   153
                pdOther.setPreferred(false);
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   154
                pdOther.setValue("required", false);
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   155
                pdOther.setValue("visualUpdate", false);
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   156
                pdOther.setShortDescription("user-defined-other");
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   157
                pdOther.setValue("enumerationValues", new Object[]{
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   158
                        "TOP", 1, "javax.swing.SwingConstants.TOP"});
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   159
                p[iOther] = pdOther;
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   160
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   161
            } catch(IntrospectionException e) {
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   162
                e.printStackTrace();
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   163
            }
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   164
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   165
            return p;
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   166
        }
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   167
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   168
        @Override
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   169
        public EventSetDescriptor[] getEventSetDescriptors() {
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   170
            EventSetDescriptor[] es = new EventSetDescriptor[2];
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   171
            try {
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   172
                es[iAction] = new EventSetDescriptor(
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   173
                        TestClass.class,
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   174
                        "actionListener",
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   175
                        java.awt.event.ActionListener.class,
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   176
                        new String[] {"actionPerformed"},
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   177
                        "addActionListener",
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   178
                        "removeActionListener");
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   179
                es[iMouse] = new EventSetDescriptor(
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   180
                        TestClass.class,
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   181
                        "mouseListener",
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   182
                        java.awt.event.MouseListener.class,
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   183
                        new String[] {"mouseClicked", "mousePressed", "mouseReleased", "mouseEntered", "mouseExited"},
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   184
                        "addMouseListener",
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   185
                        "removeMouseListener");
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   186
            } catch(IntrospectionException e) {
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   187
                e.printStackTrace();
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   188
            }
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   189
            return es;
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   190
        }
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   191
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   192
        @Override
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   193
        public MethodDescriptor[] getMethodDescriptors() {
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   194
            MethodDescriptor[] m = new MethodDescriptor[0];
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   195
            return m;
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   196
        }
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   197
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   198
        @Override
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   199
        public int getDefaultPropertyIndex() { return iValue; } // default: value
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   200
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   201
        @Override
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   202
        public int getDefaultEventIndex() { return iAction; } // default: action
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   203
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   204
        @Override
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   205
        public java.awt.Image getIcon(int iconKind) { return null; }
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   206
    }
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   207
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   208
    // ========== auxiliary functions ==========
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   209
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   210
    static void checkEq(String what, Object v, Object ref) throws Exception {
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   211
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   212
        if ((v != null) && v.equals(ref)) {
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   213
            System.out.println(what + ": ok (" + ref.toString() + ")");
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   214
        } else {
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   215
            throw new Exception(
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   216
                "invalid " + what + ", expected: \"" + ref + "\", got: \"" + v + "\"");
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   217
        }
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   218
    }
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   219
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   220
    static void checkEnumEq(String what, Object v, Object ref[]) throws Exception {
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   221
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   222
        what = "\"" + what + "\"";
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   223
        if (v == null) {
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   224
            throw new Exception("null " + what + " enumeration values");
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   225
        }
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   226
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   227
        String msg = "invalid " + what + " enumeration values";
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   228
        if (!(v instanceof Object[])) { throw new Exception(msg); }
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   229
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   230
        if (Arrays.equals((Object []) v, ref)) {
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   231
            System.out.println(what + " enumeration values: ok");
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   232
        } else { throw new Exception(msg); }
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   233
    }
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   234
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   235
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   236
    // ========== test ==========
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   237
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   238
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   239
    public static void main(String[] args) throws Exception {
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   240
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   241
        BeanInfo i = Introspector.getBeanInfo(TestClass.class, Object.class);
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   242
        BeanDescriptor bd = i.getBeanDescriptor();
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   243
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   244
        checkEq("description", bd.getShortDescription(), "user-defined-description");
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   245
        checkEq("default property index", i.getDefaultPropertyIndex(), 1);
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   246
        checkEq("default event index", i.getDefaultEventIndex(), 0);
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   247
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   248
        checkEq("isContainer", i.getBeanDescriptor().getValue("isContainer"), true);
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   249
        checkEq("containerDelegate",
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   250
            i.getBeanDescriptor().getValue("containerDelegate"), "user-defined-delegate");
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   251
        System.out.println("");
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   252
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   253
        PropertyDescriptor[] pds = i.getPropertyDescriptors();
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   254
        for (PropertyDescriptor pd: pds) {
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   255
            String name = pd.getName();
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   256
            switch (name) {
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   257
                case "value":
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   258
                    checkEq("\"value\" isBound",       pd.isBound(),       true);
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   259
                    checkEq("\"value\" isConstrained", pd.isConstrained(), true);
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   260
                    checkEq("\"value\" isExpert",      pd.isExpert(),      true);
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   261
                    checkEq("\"value\" isHidden",      pd.isHidden(),      true);
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   262
                    checkEq("\"value\" isPreferred",   pd.isPreferred(),   true);
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   263
                    checkEq("\"value\" required",      pd.getValue("required"),     true);
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   264
                    checkEq("\"value\" visualUpdate",  pd.getValue("visualUpdate"), true);
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   265
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   266
                    checkEq("\"value\" description",   pd.getShortDescription(), "user-defined-value");
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   267
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   268
                    checkEnumEq(pd.getName(), pd.getValue("enumerationValues"),
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   269
                        new Object[]{
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   270
                        "EAST", 3, "javax.swing.SwingConstants.EAST",
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   271
                        "WEST", 7, "javax.swing.SwingConstants.WEST"});
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   272
                    System.out.println("");
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   273
                    break;
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   274
                case "other":
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   275
                    checkEq("\"other\" isBound",       pd.isBound(),       false);
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   276
                    checkEq("\"other\" isConstrained", pd.isConstrained(), false);
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   277
                    checkEq("\"other\" isExpert",      pd.isExpert(),      false);
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   278
                    checkEq("\"other\" isHidden",      pd.isHidden(),      false);
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   279
                    checkEq("\"other\" isPreferred",   pd.isPreferred(),   false);
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   280
                    checkEq("\"other\" required",      pd.getValue("required"),     false);
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   281
                    checkEq("\"other\" visualUpdate",  pd.getValue("visualUpdate"), false);
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   282
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   283
                    checkEq("\"other\" description",   pd.getShortDescription(), "user-defined-other");
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   284
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   285
                    checkEnumEq(pd.getName(), pd.getValue("enumerationValues"),
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   286
                        new Object[]{"TOP", 1, "javax.swing.SwingConstants.TOP"});
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   287
                    System.out.println("");
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   288
                    break;
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   289
                default:
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   290
                    throw new Exception("invalid property descriptor: " + name);
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   291
            }
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   292
        }
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   293
    }
5d1adcc1c3e6 8131055: bean annotations: add a test checking if a user-defined BeanInfo is top-priority as compared with the annotations
avstepan
parents:
diff changeset
   294
}