19
19
20
20
package org .apache .fop .render .intermediate ;
21
21
22
-
23
22
import org .junit .Before ;
24
23
import org .junit .Test ;
25
24
import org .mockito .InOrder ;
28
27
import org .xml .sax .SAXException ;
29
28
import org .xml .sax .helpers .AttributesImpl ;
30
29
30
+ import static org .mockito .ArgumentMatchers .any ;
31
+ import static org .mockito .ArgumentMatchers .eq ;
31
32
import static org .mockito .Mockito .inOrder ;
32
33
import static org .mockito .Mockito .mock ;
33
34
import static org .mockito .Mockito .verify ;
34
35
36
+ import org .apache .fop .fo .FOElementMapping ;
35
37
import org .apache .fop .render .intermediate .IFStructureTreeBuilder .SAXEventRecorder ;
36
38
import org .apache .fop .util .XMLUtil ;
37
39
40
42
*/
41
43
public class SAXEventRecorderTestCase {
42
44
43
- private static final String URI = "http://www.example.com/" ;
45
+ private static final String URI = FOElementMapping . URI ;
44
46
45
47
private SAXEventRecorder sut ;
46
48
@@ -52,19 +54,19 @@ public void setUp() {
52
54
@ Test
53
55
public void testStartEvent () throws SAXException {
54
56
final String localName = "element" ;
55
- final String qName = "prefix :" + localName ;
57
+ final String qName = "fo :" + localName ;
56
58
final Attributes attributes = new AttributesImpl ();
57
59
58
60
sut .startElement (URI , localName , qName , attributes );
59
61
ContentHandler handler = mock (ContentHandler .class );
60
62
sut .replay (handler );
61
- verify (handler ).startElement (URI , localName , qName , attributes );
63
+ verify (handler ).startElement (eq ( URI ), eq ( localName ), eq ( qName ), any ( Attributes . class ) );
62
64
}
63
65
64
66
@ Test
65
67
public void testEndEvent () throws SAXException {
66
68
final String localName = "element" ;
67
- final String qName = "prefix :" + localName ;
69
+ final String qName = "fo :" + localName ;
68
70
sut .endElement (URI , localName , qName );
69
71
ContentHandler handler = mock (ContentHandler .class );
70
72
sut .replay (handler );
@@ -94,14 +96,14 @@ public void testEndPrefixMapping() throws SAXException {
94
96
@ Test
95
97
public void completeTest () throws SAXException {
96
98
final String localName1 = "element" ;
97
- final String qName1 = "prefix :" + localName1 ;
99
+ final String qName1 = "fo :" + localName1 ;
98
100
final Attributes attributes1 = createAttributes (URI , localName1 , qName1 , "value-1" );
99
101
final String localName2 = "element2" ;
100
- final String qName2 = "prefix :" + localName2 ;
102
+ final String qName2 = "fo :" + localName2 ;
101
103
final Attributes attributes2 = createAttributes (URI , localName2 , qName2 , "value-2" );
102
104
final ContentHandler handler = mock (ContentHandler .class );
103
- final String extensionUrl = "http://www.example.com/extension" ;
104
- final String extensionPrefix = "ext " ;
105
+ final String extensionUrl = URI ;
106
+ final String extensionPrefix = "fo " ;
105
107
106
108
sut .startPrefixMapping (extensionPrefix , extensionUrl );
107
109
sut .startElement (URI , localName1 , qName1 , attributes1 );
@@ -114,8 +116,8 @@ public void completeTest() throws SAXException {
114
116
115
117
InOrder inOrder = inOrder (handler );
116
118
inOrder .verify (handler ).startPrefixMapping (extensionPrefix , extensionUrl );
117
- inOrder .verify (handler ).startElement (URI , localName1 , qName1 , attributes1 );
118
- inOrder .verify (handler ).startElement (URI , localName2 , qName2 , attributes2 );
119
+ inOrder .verify (handler ).startElement (eq ( URI ), eq ( localName1 ), eq ( qName1 ), any ( Attributes . class ) );
120
+ inOrder .verify (handler ).startElement (eq ( URI ), eq ( localName2 ), eq ( qName2 ), any ( Attributes . class ) );
119
121
inOrder .verify (handler ).endElement (URI , localName2 , qName2 );
120
122
inOrder .verify (handler ).endElement (URI , localName1 , qName1 );
121
123
inOrder .verify (handler ).endPrefixMapping (extensionPrefix );
0 commit comments