Skip to content

Commit

Permalink
More testing, of faulty states
Browse files Browse the repository at this point in the history
  • Loading branch information
egonw committed Feb 18, 2024
1 parent f2a7633 commit 8639dc8
Showing 1 changed file with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2020 Egon Willighagen <egon.willighagen@gmail.com>
/* Copyright (c) 2020-2024 Egon Willighagen <egon.willighagen@gmail.com>
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand Down Expand Up @@ -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");
Expand All @@ -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");
Expand Down

0 comments on commit 8639dc8

Please sign in to comment.