diff --git a/managers-semweb/managers-xml/src/test/java/net/bioclipse/managers/XMLManagerTest.java b/managers-semweb/managers-xml/src/test/java/net/bioclipse/managers/XMLManagerTest.java index d4a8253..6ce2fcf 100644 --- a/managers-semweb/managers-xml/src/test/java/net/bioclipse/managers/XMLManagerTest.java +++ b/managers-semweb/managers-xml/src/test/java/net/bioclipse/managers/XMLManagerTest.java @@ -1,4 +1,4 @@ -/* Copyright (c) 2020 Egon Willighagen +/* Copyright (c) 2020-2024 Egon Willighagen * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -84,6 +84,18 @@ public void testReadValid() throws Exception { assertSame("project", doc.getRootElement().getLocalName()); } + @Test + public void testReadValid_NotValid() throws Exception { + Exception exception = assertThrows( + BioclipseException.class, () -> + { + xml.readValid("/XMLTests/justWrong.xml"); + } + ); + assertNotNull(exception); + assertTrue(exception.getMessage().contains("must be terminated by the matching end-tag")); + } + @Test public void testReadValidString() throws Exception { String xmlContent = bioclipse.download("https://raw.githubusercontent.com/egonw/bacting/master/pom.xml"); @@ -92,6 +104,19 @@ public void testReadValidString() throws Exception { assertSame("project", doc.getRootElement().getLocalName()); } + @Test + public void testReadValidString_NotValid() throws Exception { + Exception exception = assertThrows( + BioclipseException.class, () -> + { + String xmlContent = bioclipse.download("https://raw.githubusercontent.com/egonw/bacting/master/pom.xml"); + xml.readValidString(xmlContent.substring(10)); + } + ); + assertNotNull(exception); + assertTrue(exception.getMessage().contains("Content is not allowed in prolog.")); + } + @Test public void testReadString() throws Exception { String xmlContent = bioclipse.download("https://raw.githubusercontent.com/egonw/bacting/master/pom.xml");