aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/org/zwobble/mammoth/tests/xml
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2016-03-02 18:40:00 +0000
committerMichael Williamson <mike@zwobble.org>2016-03-02 20:37:08 +0000
commit2aa8d73e234ffd91990187e6bd733c5aa514cff1 (patch)
tree4eae0fcc912a705d7fb00f67f441fb29d5e4e332 /src/test/java/org/zwobble/mammoth/tests/xml
parent0518e1624cae35738e71c98ef6150105524871f3 (diff)
Throw more information exception when attribute is missing
Diffstat (limited to 'src/test/java/org/zwobble/mammoth/tests/xml')
-rw-r--r--src/test/java/org/zwobble/mammoth/tests/xml/XmlElementTests.java21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/test/java/org/zwobble/mammoth/tests/xml/XmlElementTests.java b/src/test/java/org/zwobble/mammoth/tests/xml/XmlElementTests.java
new file mode 100644
index 0000000..f396b1b
--- /dev/null
+++ b/src/test/java/org/zwobble/mammoth/tests/xml/XmlElementTests.java
@@ -0,0 +1,21 @@
+package org.zwobble.mammoth.tests.xml;
+
+import org.junit.Test;
+import org.zwobble.mammoth.internal.xml.XmlElement;
+import org.zwobble.mammoth.internal.xml.XmlNodes;
+
+import static org.junit.Assert.assertEquals;
+import static org.zwobble.mammoth.tests.util.MammothAsserts.assertThrows;
+
+public class XmlElementTests {
+ @Test
+ public void TryingToGetNonExistentAttributeThrowsException() {
+ XmlElement element = XmlNodes.element("p");
+
+ RuntimeException exception = assertThrows(
+ RuntimeException.class,
+ () -> element.getAttribute("class"));
+
+ assertEquals("Element has no 'class' attribute", exception.getMessage());
+ }
+}