Skip to content

Commit 8fc904e

Browse files
committed
Add test for nested type literal. (#405)
1 parent 4d92b5c commit 8fc904e

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

metafacture-biblio/src/test/java/org/metafacture/biblio/marc21/MarcXmlEncoderTest.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ public void shouldIgnoreNullValueOfTypeLiteral() {
246246
}
247247

248248
@Test
249-
public void shouldEncodeTypeLiteralAsAttribute() {
249+
public void issue402_shouldEncodeTypeLiteralAsAttribute() {
250250
encoder.startRecord(RECORD_ID);
251251
encoder.literal("type", "value");
252252
encoder.endRecord();
@@ -258,4 +258,23 @@ public void shouldEncodeTypeLiteralAsAttribute() {
258258
assertEquals(expected, actual);
259259
}
260260

261+
@Test
262+
public void shouldNotEncodeNestedTypeLiteralAsAttribute() {
263+
encoder.startRecord(RECORD_ID);
264+
encoder.startEntity("tag12");
265+
encoder.literal("type", "value");
266+
encoder.endEntity();
267+
encoder.endRecord();
268+
encoder.closeStream();
269+
String expected = XML_DECLARATION + XML_ROOT_OPEN
270+
+ "<marc:record>"
271+
+ "<marc:datafield tag=\"tag\" ind1=\"1\" ind2=\"2\">"
272+
+ "<marc:subfield code=\"type\">value</marc:subfield>"
273+
+ "</marc:datafield>"
274+
+ "</marc:record>"
275+
+ XML_MARC_COLLECTION_END_TAG;
276+
String actual = resultCollector.toString();
277+
assertEquals(expected, actual);
278+
}
279+
261280
}

0 commit comments

Comments
 (0)