You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by or...@apache.org on 2026/01/25 05:32:27 UTC
(camel) 04/04: CAMEL-21196: modernize exception-based assertions in camel-xml-io
This is an automated email from the ASF dual-hosted git repository.
orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
commit ee0f4b4507154959a3953de0979b541a934ebd93
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Sat Jan 24 17:20:51 2026 +0000
CAMEL-21196: modernize exception-based assertions in camel-xml-io
---
.../java/org/apache/camel/xml/in/ModelParserTest.java | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/core/camel-xml-io/src/test/java/org/apache/camel/xml/in/ModelParserTest.java b/core/camel-xml-io/src/test/java/org/apache/camel/xml/in/ModelParserTest.java
index e2d9dd65a281..150e89434e8d 100644
--- a/core/camel-xml-io/src/test/java/org/apache/camel/xml/in/ModelParserTest.java
+++ b/core/camel-xml-io/src/test/java/org/apache/camel/xml/in/ModelParserTest.java
@@ -63,8 +63,8 @@ import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.jupiter.api.Assertions.fail;
public class ModelParserTest {
@@ -439,16 +439,14 @@ public class ModelParserTest {
Path dir = getResourceFolder();
Path path = new File(dir.toFile() + "/invalid", "convertBodyParseError.xml").toPath();
Resource resource = ResourceHelper.fromString("file:convertBodyParseError.xml", Files.readString(path));
- try {
+ XmlPullParserLocationException e = assertThrows(XmlPullParserLocationException.class, () -> {
ModelParser parser = new ModelParser(resource, NAMESPACE);
parser.parseRoutesDefinition();
- fail("Should throw exception");
- } catch (XmlPullParserLocationException e) {
- assertEquals(22, e.getLineNumber());
- assertEquals(25, e.getColumnNumber());
- assertEquals("file:convertBodyParseError.xml", e.getResource().getLocation());
- assertTrue(e.getMessage().startsWith("Unexpected attribute '{}ref'"));
- }
+ });
+ assertEquals(22, e.getLineNumber());
+ assertEquals(25, e.getColumnNumber());
+ assertEquals("file:convertBodyParseError.xml", e.getResource().getLocation());
+ assertTrue(e.getMessage().startsWith("Unexpected attribute '{}ref'"));
}
private Path getResourceFolder() {