16
16
package org .metafacture .biblio .marc21 ;
17
17
18
18
import static org .mockito .Mockito .verify ;
19
+ import static org .mockito .Mockito .verifyNoMoreInteractions ;
19
20
20
21
import org .junit .After ;
21
22
import org .junit .Before ;
@@ -37,6 +38,8 @@ public final class MarcXmlHandlerTest {
37
38
private static final String LEADER = "leader" ;
38
39
private static final String CONTROLFIELD = "controlfield" ;
39
40
private static final String NAMESPACE = "http://www.loc.gov/MARC21/slim" ;
41
+ private static final String RECORD = "record" ;
42
+ private static final String TYPE = "type" ;
40
43
41
44
private MarcXmlHandler marcXmlHandler ;
42
45
@@ -84,4 +87,46 @@ public void issue233ShouldNotRemoveWhitespaceFromLeader()
84
87
verify (receiver ).literal ("leader" , leaderValue );
85
88
}
86
89
90
+ @ Test
91
+ public void shouldRecognizeRecordsWithNamespace ()
92
+ throws SAXException {
93
+ final AttributesImpl attributes = new AttributesImpl ();
94
+
95
+ marcXmlHandler .startElement (NAMESPACE , RECORD , "" , attributes );
96
+ marcXmlHandler .endElement (NAMESPACE , RECORD , "" );
97
+
98
+ verify (receiver ).startRecord ("" );
99
+ verify (receiver ).literal (TYPE , null );
100
+ verify (receiver ).endRecord ();
101
+
102
+ verifyNoMoreInteractions (receiver );
103
+ }
104
+
105
+ @ Test
106
+ public void shouldNotRecognizeRecordsWithoutNamespace ()
107
+ throws SAXException {
108
+ final AttributesImpl attributes = new AttributesImpl ();
109
+
110
+ marcXmlHandler .startElement (null , RECORD , "" , attributes );
111
+ marcXmlHandler .endElement (null , RECORD , "" );
112
+
113
+ verifyNoMoreInteractions (receiver );
114
+ }
115
+
116
+ @ Test
117
+ public void issue330ShouldOptionallyRecognizeRecordsWithoutNamespace ()
118
+ throws SAXException {
119
+ final AttributesImpl attributes = new AttributesImpl ();
120
+
121
+ marcXmlHandler .setNamespace (null );
122
+ marcXmlHandler .startElement (null , RECORD , "" , attributes );
123
+ marcXmlHandler .endElement (null , RECORD , "" );
124
+
125
+ verify (receiver ).startRecord ("" );
126
+ verify (receiver ).literal (TYPE , null );
127
+ verify (receiver ).endRecord ();
128
+
129
+ verifyNoMoreInteractions (receiver );
130
+ }
131
+
87
132
}
0 commit comments