コード例 #1
0
  public void testValidateComplexType() throws Exception {
    boolean caughtException = false;
    File file = new File(ClassLoader.getSystemResource(CONTROL_XML_FILE_NAME).getFile());
    Employee employee = (Employee) unmarshaller.unmarshal(file);

    try {
      validator.validate(employee.getHomeAddress());
    } catch (ValidationException xmlpe) {
      caughtException = true;
    }
    assertFalse("Address object did not validate.", caughtException);
  }
コード例 #2
0
  public void testValidateInheritanceComplexType() throws Exception {
    boolean caughtException = false;
    File file =
        new File(ClassLoader.getSystemResource(CONTROL_XML_INHERITANCE_FILE_NAME).getFile());
    Employee employee = (Employee) unmarshaller.unmarshal(file);

    try {
      validator.validate(employee.getHomeAddress());
    } catch (org.eclipse.persistence.platform.xml.XMLPlatformException xmlpe) {
      caughtException = true;
    }
    assertFalse("Address object did not validate.", caughtException);
  }
コード例 #3
0
  public void testValidationEventHandler() throws Exception {
    boolean caughtException = false;
    File file = new File(ClassLoader.getSystemResource(CONTROL_XML_ADDRESS_FAIL).getFile());
    Employee employee = (Employee) unmarshaller.unmarshal(file);

    try {
      validator.setEventHandler(new ValidationEventHandlerImpl());
      validator.validate(employee.getHomeAddress());
    } catch (ValidationException xmlpe) {
      caughtException = true;
    } catch (Exception ex) {
    }
    assertFalse("The event handler did not consume the exceptions as expected.", caughtException);
  }