Skip to content

Commit 2d2f0c7

Browse files
committed
minor changes to try to ensure cobertura tests pass (mysterious problem with DocumentBuilderFactory)
1 parent db0eadb commit 2d2f0c7

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

src/main/java/com/fasterxml/jackson/databind/ext/DOMDeserializer.java

+3
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ public abstract class DOMDeserializer<T> extends FromStringDeserializer<T>
3535
parserFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
3636
} catch(ParserConfigurationException pce) {
3737
// not much point to do anything; could log but...
38+
} catch (Error e) {
39+
// 14-Jul-2016, tatu: Not sure how or why, but during code coverage runs
40+
// (via Cobertura) we get `java.lang.AbstractMethodError` so... ignore that too
3841
}
3942
DEFAULT_PARSER_FACTORY = parserFactory;
4043
}

src/test/java/com/fasterxml/jackson/databind/ext/TestDOM.java

+10-11
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,19 @@ public class TestDOM extends com.fasterxml.jackson.databind.BaseMapTest
1414
"<root attr='3'><leaf>Rock &amp; Roll!</leaf><?proc instr?></root>";
1515
final static String SIMPLE_XML_NS =
1616
"<root ns:attr='abc' xmlns:ns='http://foo' />";
17+
18+
private final ObjectMapper MAPPER = new ObjectMapper();
1719

1820
public void testSerializeSimpleNonNS() throws Exception
1921
{
2022
// Let's just parse first, easiest
2123
Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse
2224
(new InputSource(new StringReader(SIMPLE_XML)));
2325
assertNotNull(doc);
24-
ObjectMapper mapper = new ObjectMapper();
2526
// need to strip xml declaration, if any
26-
String outputRaw = mapper.writeValueAsString(doc);
27+
String outputRaw = MAPPER.writeValueAsString(doc);
2728
// And re-parse as String, since JSON has quotes...
28-
String output = mapper.readValue(outputRaw, String.class);
29+
String output = MAPPER.readValue(outputRaw, String.class);
2930
/* ... and finally, normalize to (close to) canonical XML
3031
* output (single vs double quotes, xml declaration etc)
3132
*/
@@ -34,16 +35,15 @@ public void testSerializeSimpleNonNS() throws Exception
3435

3536
public void testDeserializeNonNS() throws Exception
3637
{
37-
ObjectMapper mapper = new ObjectMapper();
3838
for (int i = 0; i < 2; ++i) {
3939
Document doc;
4040

4141
if (i == 0) {
4242
// First, as Document:
43-
doc = mapper.readValue(quote(SIMPLE_XML), Document.class);
43+
doc = MAPPER.readValue(quote(SIMPLE_XML), Document.class);
4444
} else {
4545
// and then as plain Node (no difference)
46-
Node node = mapper.readValue(quote(SIMPLE_XML), Node.class);
46+
Node node = MAPPER.readValue(quote(SIMPLE_XML), Node.class);
4747
doc = (Document) node;
4848
}
4949
Element root = doc.getDocumentElement();
@@ -66,8 +66,7 @@ public void testDeserializeNonNS() throws Exception
6666

6767
public void testDeserializeNS() throws Exception
6868
{
69-
ObjectMapper mapper = new ObjectMapper();
70-
Document doc = mapper.readValue(quote(SIMPLE_XML_NS), Document.class);
69+
Document doc = MAPPER.readValue(quote(SIMPLE_XML_NS), Document.class);
7170
Element root = doc.getDocumentElement();
7271
assertNotNull(root);
7372
assertEquals("root", root.getTagName());
@@ -82,9 +81,9 @@ public void testDeserializeNS() throws Exception
8281
}
8382

8483
/*
85-
**********************************************************
86-
* Helper methods
87-
**********************************************************
84+
/**********************************************************
85+
/* Helper methods
86+
/**********************************************************
8887
*/
8988

9089
protected static String normalizeOutput(String output)

0 commit comments

Comments
 (0)