/* * Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code 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 * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions.
*/
/* * @test * @bug 4619536 * @summary Tests resolving the ambiguities in the resolution of IndexedPropertyDescriptors * @author Mark Davidson
*/
publicclass Test4619536 { publicstaticvoid main(String[] args) throws Exception {
IndexedPropertyDescriptor ipd = BeanUtils.getIndexedPropertyDescriptor(A.class, "foo"); if (!ipd.getIndexedPropertyType().equals(String.class)) {
error(ipd, "A.foo should be String type");
}
PropertyDescriptor pd = BeanUtils.findPropertyDescriptor(B.class, "foo"); if (pd instanceof IndexedPropertyDescriptor) {
error(pd, "B.foo should not be an indexed property");
} if (!pd.getPropertyType().equals(Date.class)) {
error(pd, "B.foo should be Date type");
}
pd = BeanUtils.findPropertyDescriptor(Child.class, "foo"); if (pd instanceof IndexedPropertyDescriptor) {
error(pd, "Child.foo should not be an indexed property");
}
pd = BeanUtils.findPropertyDescriptor(Classic.class, "foo"); if (pd instanceof IndexedPropertyDescriptor) {
error(pd, "Classic.foo should not be an indexed property");
}
ipd = BeanUtils.getIndexedPropertyDescriptor(Index.class, "foo"); if (!hasIPD(ipd)) {
error(pd, "Index.foo should have ipd values");
} if (hasPD(ipd)) {
error(ipd, "Index.foo should not have pd values");
}
ipd = BeanUtils.getIndexedPropertyDescriptor(All.class, "foo"); if (!hasPD(ipd) || !hasIPD(ipd)) {
error(ipd, "All.foo should have all pd/ipd values");
} if (!isValidType(ipd)) {
error(ipd, "All.foo pdType should equal ipdType");
}
ipd = BeanUtils.getIndexedPropertyDescriptor(Getter.class, "foo"); if (ipd.getReadMethod() == null || ipd.getWriteMethod() != null) {
error(ipd, "Getter.foo classic methods incorrect");
} if (!isValidType(ipd)) {
error(ipd, "Getter.foo pdType should equal ipdType");
}
ipd = BeanUtils.getIndexedPropertyDescriptor(BadGetter.class, "foo"); if (hasPD(ipd)) {
error(ipd, "BadGetter.foo should not have classic methods");
}
ipd = BeanUtils.getIndexedPropertyDescriptor(Setter.class, "foo"); if (ipd.getReadMethod() != null || ipd.getWriteMethod() == null) {
error(ipd, "Setter.foo classic methods incorrect");
} if (!isValidType(ipd)) {
error(ipd, "Setter.foo pdType should equal ipdType");
}
ipd = BeanUtils.getIndexedPropertyDescriptor(BadSetter.class, "foo"); if (hasPD(ipd)) {
error(ipd, "BadSetter.foo should not have classic methods");
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.