Пример #1
0
  /*
   * (non-Javadoc)
   *
   * @see
   * org.eclipse.birt.report.model.metadata.PropertyTypeTestCase#testValidateXml
   * ()
   */
  public void testValidateXml() throws PropertyValueException {
    assertEquals(null, type.validateXml(design, null, propDefn, null));
    assertEquals(null, type.validateXml(design, null, propDefn, "")); // $NON-NLS-1$

    Date value =
        (Date) type.validateXml(design, null, propDefn, "2004-10-18 10:34:22"); // $NON-NLS-1$
    calendar.setTime(value);
    assertEquals(2004 - 1900, calendar.get(Calendar.YEAR) - 1900);
    assertEquals(9, calendar.get(Calendar.MONTH));
    assertEquals(18, calendar.get(Calendar.DAY_OF_MONTH));

    // wrong value
    try {
      type.validateXml(design, null, propDefn, "wrong-datetime-value"); // $NON-NLS-1$
      fail();
    } catch (PropertyValueException e) {
      assertEquals(PropertyValueException.DESIGN_EXCEPTION_INVALID_VALUE, e.getErrorCode());
    }
  }