Пример #1
0
  public void testSetNull() {
    TstJavaBean o1 = new TstJavaBean();

    o1.setStringField("xyz");
    PropertyUtils.setProperty(o1, "stringField", null);
    assertNull(o1.getStringField());

    o1.setBooleanField(true);
    PropertyUtils.setProperty(o1, "booleanField", null);
    assertEquals(false, o1.isBooleanField());

    o1.setByteField((byte) 2);
    PropertyUtils.setProperty(o1, "byteField", null);
    assertEquals((byte) 0, o1.getByteField());

    o1.setShortField((short) 3);
    PropertyUtils.setProperty(o1, "shortField", null);
    assertEquals((short) 0, o1.getShortField());

    o1.setIntField(99);
    PropertyUtils.setProperty(o1, "intField", null);
    assertEquals(0, o1.getIntField());

    o1.setLongField(98);
    PropertyUtils.setProperty(o1, "longField", null);
    assertEquals(0L, o1.getLongField());

    o1.setFloatField(4.5f);
    PropertyUtils.setProperty(o1, "floatField", null);
    assertEquals(0.0f, o1.getFloatField());

    o1.setDoubleField(5.5f);
    PropertyUtils.setProperty(o1, "doubleField", null);
    assertEquals(0.0, o1.getDoubleField());
  }
Пример #2
0
  protected TstJavaBean createBean() {
    TstJavaBean o1 = new TstJavaBean();
    o1.setByteArrayField(new byte[] {1, 2, 3});
    o1.setIntegerField(new Integer(33));
    o1.setIntField(-44);
    o1.setNumberField(new BigDecimal("11111"));
    o1.setObjectField(new Object());
    o1.setStringField("aaaaa");
    o1.setBooleanField(true);

    return o1;
  }