You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by GitBox <gi...@apache.org> on 2022/12/02 12:34:08 UTC

[GitHub] [commons-digester] garydgregory commented on a diff in pull request #43: JUnit5 assertThrows DTDValidationTestCase

garydgregory commented on code in PR #43:
URL: https://github.com/apache/commons-digester/pull/43#discussion_r1038099558


##########
core/src/test/java/org/apache/commons/digester3/DTDValidationTestCase.java:
##########
@@ -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)

Review Comment:
   Fix weird formatting 



##########
core/src/test/java/org/apache/commons/digester3/DTDValidationTestCase.java:
##########
@@ -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 {

Review Comment:
   throws can be on the same line as method signature.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org