Skip to content

Commit

Permalink
JUnit assertThrows DTDValidationTestCase
Browse files Browse the repository at this point in the history
  • Loading branch information
nhojpatrick committed Nov 22, 2022
1 parent 3d4068d commit 185a72e
Showing 1 changed file with 38 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.apache.commons.digester3;

import static org.apache.commons.digester3.binder.DigesterLoader.newLoader;
import static org.junit.jupiter.api.Assertions.assertThrows;

import java.io.File;

Expand All @@ -29,50 +30,44 @@
/**
* Tests for entity resolution and dtd validation
*/
public class DTDValidationTestCase
{
public class DTDValidationTestCase {

@Test( expected = SAXParseException.class )
public void testDigesterDTDError()
throws Exception
{
newLoader( new AbstractRulesModule() {

@Override
protected void configure()
{
// do nothing
}

} )
.setValidating( true )
.setErrorHandler( new ErrorHandler()
{

@Override
public void warning( final SAXParseException e )
throws SAXException
{
throw e;
}

@Override
public void fatalError( final SAXParseException e )
throws SAXException
{
throw e;
}

@Override
public void error( final SAXParseException e )
throws SAXException
{
throw e;
}

} )
.newDigester()
.parse( new File( "src/test/resources/org/apache/commons/digester3/document-with-relative-dtd-error.xml" ) );
@Test
public void testDigesterDTDError() {

assertThrows(SAXParseException.class, () ->
newLoader(new AbstractRulesModule() {

@Override
protected void configure() {
// do nothing
}

})
.setValidating(true)
.setErrorHandler(new ErrorHandler() {

@Override
public void warning(final SAXParseException e)
throws SAXException {
throw e;
}

@Override
public void fatalError(final SAXParseException e)
throws SAXException {
throw e;
}

@Override
public void error(final SAXParseException e)
throws SAXException {
throw e;
}

})
.newDigester()
.parse(new File("src/test/resources/org/apache/commons/digester3/document-with-relative-dtd-error.xml")));
}

@Test
Expand Down

0 comments on commit 185a72e

Please sign in to comment.