Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JUnit5 assertThrows DTDValidationTestCase #43

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@
<version>4.13</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix weird formatting

.setErrorHandler(new ErrorHandler() {

@Override
public void warning(final SAXParseException e)
throws SAXException {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

throws can be on the same line as method signature.

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