Code example for DefaultHandler

0
 
    public void testFailOnSecondErrorContentHandler() throws Exception {
        CustomErrorValidationEventHandler eventHandler = new CustomErrorValidationEventHandler();
        marshaller.setEventHandler(eventHandler);
        try { 
            marshaller.marshal(employee, new DefaultHandler());
        } catch (MarshalException ex) {
            assertEquals(2, eventHandler.getErrorCount());
            return; 
        } catch(Exception e) {
            throw e;
        } 
        fail("No Exceptions thrown."); 
    } 
 
    public void testFailOnSecondErrorContentHandler_Fragment() throws Exception {
        CustomErrorValidationEventHandler eventHandler = new CustomErrorValidationEventHandler();
        marshaller.setEventHandler(eventHandler);
        marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
        try {