< prev index next >
test/java/beans/Introspector/BeanPropertyTest.java
Print this page
*** 295,309 ****
hidden = HIDDEN,
preferred = PREFERRED,
required = REQUIRED,
visualUpdate = UPDATE,
enumerationValues = {V_NAME})
! public int getX(int i) throws IndexOutOfBoundsException {
! if (i < 0 || i >= x.length) {
! throw new IndexOutOfBoundsException(); }
! return x[i];
! }
public void addPropertyChangeListener(PropertyChangeListener l) {}
public void removePropertyChangeListener(PropertyChangeListener l) {}
}
--- 295,305 ----
hidden = HIDDEN,
preferred = PREFERRED,
required = REQUIRED,
visualUpdate = UPDATE,
enumerationValues = {V_NAME})
! public int getX(int i) { return x[i]; }
public void addPropertyChangeListener(PropertyChangeListener l) {}
public void removePropertyChangeListener(PropertyChangeListener l) {}
}
*** 320,334 ****
hidden = HIDDEN,
preferred = PREFERRED,
required = REQUIRED,
visualUpdate = UPDATE,
enumerationValues = {V_NAME})
! public void setX(int i, int v) throws IndexOutOfBoundsException {
! if (i < 0 || i >= x.length) {
! throw new IndexOutOfBoundsException(); }
! x[i] = v;
! }
public void addPropertyChangeListener(PropertyChangeListener l) {}
public void removePropertyChangeListener(PropertyChangeListener l) {}
}
--- 316,326 ----
hidden = HIDDEN,
preferred = PREFERRED,
required = REQUIRED,
visualUpdate = UPDATE,
enumerationValues = {V_NAME})
! public void setX(int i, int v) { x[i] = v; }
public void addPropertyChangeListener(PropertyChangeListener l) {}
public void removePropertyChangeListener(PropertyChangeListener l) {}
}
*** 346,360 ****
hidden = HIDDEN,
preferred = PREFERRED,
required = REQUIRED,
visualUpdate = UPDATE,
enumerationValues = {V_NAME})
! public int getX(int i) throws IndexOutOfBoundsException {
! if (i < 0 || i >= x.length) {
! throw new IndexOutOfBoundsException(); }
! return x[i];
! }
public int[] getX() { return x; }
public void addPropertyChangeListener(PropertyChangeListener l) {}
public void removePropertyChangeListener(PropertyChangeListener l) {}
--- 338,348 ----
hidden = HIDDEN,
preferred = PREFERRED,
required = REQUIRED,
visualUpdate = UPDATE,
enumerationValues = {V_NAME})
! public int getX(int i) { return x[i]; }
public int[] getX() { return x; }
public void addPropertyChangeListener(PropertyChangeListener l) {}
public void removePropertyChangeListener(PropertyChangeListener l) {}
*** 374,388 ****
hidden = HIDDEN,
preferred = PREFERRED,
required = REQUIRED,
visualUpdate = UPDATE,
enumerationValues = {V_NAME})
! public void setX(int i, int v) throws IndexOutOfBoundsException {
! if (i < 0 || i >= x.length) {
! throw new IndexOutOfBoundsException(); }
! x[i] = v;
! }
public void setX(int a[]) { x = Arrays.copyOf(a, a.length); }
public void addPropertyChangeListener(PropertyChangeListener l) {}
public void removePropertyChangeListener(PropertyChangeListener l) {}
--- 362,372 ----
hidden = HIDDEN,
preferred = PREFERRED,
required = REQUIRED,
visualUpdate = UPDATE,
enumerationValues = {V_NAME})
! public void setX(int i, int v) { x[i] = v; }
public void setX(int a[]) { x = Arrays.copyOf(a, a.length); }
public void addPropertyChangeListener(PropertyChangeListener l) {}
public void removePropertyChangeListener(PropertyChangeListener l) {}
*** 405,419 ****
required = REQUIRED,
visualUpdate = UPDATE,
enumerationValues = {V_NAME})
public int[] getX() { return x; }
! public int getX(int i) throws IndexOutOfBoundsException {
! if (i < 0 || i >= x.length) {
! throw new IndexOutOfBoundsException(); }
! return x[i];
! }
public void addPropertyChangeListener(PropertyChangeListener l) {}
public void removePropertyChangeListener(PropertyChangeListener l) {}
}
--- 389,399 ----
required = REQUIRED,
visualUpdate = UPDATE,
enumerationValues = {V_NAME})
public int[] getX() { return x; }
! public int getX(int i) { return x[i]; }
public void addPropertyChangeListener(PropertyChangeListener l) {}
public void removePropertyChangeListener(PropertyChangeListener l) {}
}
*** 434,448 ****
required = REQUIRED,
visualUpdate = UPDATE,
enumerationValues = {V_NAME})
public void setX(int a[]) { x = Arrays.copyOf(a, a.length); }
! public void setX(int i, int v) throws IndexOutOfBoundsException {
! if (i < 0 || i >= x.length) {
! throw new IndexOutOfBoundsException(); }
! x[i] = v;
! }
public void addPropertyChangeListener(PropertyChangeListener l) {}
public void removePropertyChangeListener(PropertyChangeListener l) {}
}
--- 414,424 ----
required = REQUIRED,
visualUpdate = UPDATE,
enumerationValues = {V_NAME})
public void setX(int a[]) { x = Arrays.copyOf(a, a.length); }
! public void setX(int i, int v) { x[i] = v; }
public void addPropertyChangeListener(PropertyChangeListener l) {}
public void removePropertyChangeListener(PropertyChangeListener l) {}
}
*** 470,484 ****
expert = !EXPERT,
hidden = !HIDDEN,
preferred = !PREFERRED,
required = !REQUIRED,
visualUpdate = !UPDATE)
! public int getX(int i) throws IndexOutOfBoundsException {
! if (i < 0 || i >= x.length) {
! throw new IndexOutOfBoundsException(); }
! return x[i];
! }
public void addPropertyChangeListener(PropertyChangeListener l) {}
public void removePropertyChangeListener(PropertyChangeListener l) {}
}
--- 446,456 ----
expert = !EXPERT,
hidden = !HIDDEN,
preferred = !PREFERRED,
required = !REQUIRED,
visualUpdate = !UPDATE)
! public int getX(int i) { return x[i]; }
public void addPropertyChangeListener(PropertyChangeListener l) {}
public void removePropertyChangeListener(PropertyChangeListener l) {}
}
*** 506,520 ****
expert = !EXPERT,
hidden = !HIDDEN,
preferred = !PREFERRED,
required = !REQUIRED,
visualUpdate = !UPDATE)
! public void setX(int i, int v) throws IndexOutOfBoundsException {
! if (i < 0 || i >= x.length) {
! throw new IndexOutOfBoundsException(); }
! x[i] = v;
! }
public void addPropertyChangeListener(PropertyChangeListener l) {}
public void removePropertyChangeListener(PropertyChangeListener l) {}
}
--- 478,488 ----
expert = !EXPERT,
hidden = !HIDDEN,
preferred = !PREFERRED,
required = !REQUIRED,
visualUpdate = !UPDATE)
! public void setX(int i, int v) { x[i] = v; }
public void addPropertyChangeListener(PropertyChangeListener l) {}
public void removePropertyChangeListener(PropertyChangeListener l) {}
}
*** 835,845 ****
--- 803,859 ----
public void addPropertyChangeListener(PropertyChangeListener l) {}
public void removePropertyChangeListener(PropertyChangeListener l) {}
}
+ public static class Self {
+
+ private final static String TESTCASE = "trivial singleton";
+ private static Self instance = null;
+ private Self() {}
+
+ @BeanProperty(
+ description = DESCRIPTION,
+ bound = BOUND,
+ expert = EXPERT,
+ hidden = HIDDEN,
+ preferred = PREFERRED,
+ required = REQUIRED,
+ visualUpdate = UPDATE)
+ public Self getSelf() {
+ if (instance == null) { instance = new Self(); }
+ return instance;
+ }
+
+ public void addPropertyChangeListener(PropertyChangeListener l) {}
+ public void removePropertyChangeListener(PropertyChangeListener l) {}
+ }
+
+ public static class SelfArr {
+
+ private final static String TESTCASE = "trivial singleton + array";
+
+ private static SelfArr arr[] = null;
+ private SelfArr() {}
+
+ @BeanProperty(
+ description = DESCRIPTION,
+ bound = BOUND,
+ expert = EXPERT,
+ hidden = HIDDEN,
+ preferred = PREFERRED,
+ required = REQUIRED,
+ visualUpdate = UPDATE)
+ public SelfArr[] getSelfArr() {
+ if (arr == null) { arr = new SelfArr[]{new SelfArr(), new SelfArr()}; }
+ return arr;
+ }
+
+ public void addPropertyChangeListener(PropertyChangeListener l) {}
+ public void removePropertyChangeListener(PropertyChangeListener l) {}
+ }
// ---------- checks ----------
private static boolean check(String what, boolean v, boolean ref) {
*** 848,858 ****
if (!ok) { System.out.println(
"invalid " + what + ": " + v + ", expected: " + ref); }
return ok;
}
! private static boolean checkInfo(BeanInfo i) {
System.out.println("checking info...");
PropertyDescriptor descriptors[] = i.getPropertyDescriptors();
int nd = descriptors.length;
--- 862,872 ----
if (!ok) { System.out.println(
"invalid " + what + ": " + v + ", expected: " + ref); }
return ok;
}
! private static boolean checkInfo(BeanInfo i, boolean checkVals) {
System.out.println("checking info...");
PropertyDescriptor descriptors[] = i.getPropertyDescriptors();
int nd = descriptors.length;
*** 874,883 ****
--- 888,899 ----
ok &= check("isPreferred", d.isPreferred(), PREFERRED);
ok &= check("required", (boolean) d.getValue("required"), REQUIRED);
ok &= check("visualUpdate",
(boolean) d.getValue("visualUpdate"), UPDATE);
+ if (!checkVals) { return ok; }
+
Object vals[] = (Object[]) d.getValue("enumerationValues");
if (vals == null) {
System.out.println("null enumerationValues");
return false;
}
*** 934,943 ****
--- 950,963 ----
c.equals(G09.class) ||
c.equals(S09.class) ||
c.equals(GS.class));
}
+ private static boolean ignoreVals(Class<?> c) {
+ return (c.equals(Self.class) || c.equals(SelfArr.class));
+ }
+
// ---------- run test ----------
public static void main(String[] args) throws Exception {
*** 957,967 ****
// G12.class, S12.class, // TODO: please update after 8132163 fix
G13.class, // S13.class, // TODO: please update after 8154756 fix
// G14.class, S14.class, // TODO: please update after 8132888 fix or
// remove these cases if it is not an issue
// GS.class, // TODO: please update after 8132973 fix
! getX.class, setX.class
};
boolean passed = true;
for (Class<?> c: cases) {
--- 977,988 ----
// G12.class, S12.class, // TODO: please update after 8132163 fix
G13.class, // S13.class, // TODO: please update after 8154756 fix
// G14.class, S14.class, // TODO: please update after 8132888 fix or
// remove these cases if it is not an issue
// GS.class, // TODO: please update after 8132973 fix
! getX.class, setX.class,
! Self.class, SelfArr.class
};
boolean passed = true;
for (Class<?> c: cases) {
*** 972,982 ****
System.out.println("\n" + c.getSimpleName() + " (" + descr + "):");
BeanInfo i;
try { i = Introspector.getBeanInfo(c, Object.class); }
catch (IntrospectionException e) { throw new RuntimeException(e); }
! boolean ok = checkInfo(i);
if (checkAlternative(c)) {
ok |= checkAlternativeInfo(i);
}
System.out.println(ok ? "OK" : "NOK");
passed = passed && ok;
--- 993,1003 ----
System.out.println("\n" + c.getSimpleName() + " (" + descr + "):");
BeanInfo i;
try { i = Introspector.getBeanInfo(c, Object.class); }
catch (IntrospectionException e) { throw new RuntimeException(e); }
! boolean ok = checkInfo(i, !ignoreVals(c));
if (checkAlternative(c)) {
ok |= checkAlternativeInfo(i);
}
System.out.println(ok ? "OK" : "NOK");
passed = passed && ok;
< prev index next >