1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.springframework.xml.stream;
18
19 import java.io.InputStream;
20 import java.io.StringReader;
21 import javax.xml.stream.XMLEventReader;
22 import javax.xml.stream.XMLInputFactory;
23 import javax.xml.stream.XMLStreamException;
24
25 import org.easymock.MockControl;
26 import org.xml.sax.ContentHandler;
27 import org.xml.sax.InputSource;
28 import org.xml.sax.helpers.AttributesImpl;
29
30 public class StaxEventXmlReaderTest extends AbstractStaxXmlReaderTestCase {
31
32 public static final String CONTENT = "<root xmlns='http://springframework.org/spring-ws'><child/></root>";
33
34 protected AbstractStaxXmlReader createStaxXmlReader(InputStream inputStream) throws XMLStreamException {
35 return new StaxEventXmlReader(inputFactory.createXMLEventReader(inputStream));
36 }
37
38 public void testPartial() throws Exception {
39 XMLInputFactory inputFactory = XMLInputFactory.newInstance();
40 XMLEventReader eventReader = inputFactory.createXMLEventReader(new StringReader(CONTENT));
41 eventReader.nextTag();
42 StaxEventXmlReader xmlReader = new StaxEventXmlReader(eventReader);
43
44 MockControl mockControl = MockControl.createStrictControl(ContentHandler.class);
45 mockControl.setDefaultMatcher(new SaxArgumentMatcher());
46 ContentHandler contentHandlerMock = (ContentHandler) mockControl.getMock();
47
48 contentHandlerMock.startDocument();
49 contentHandlerMock.startElement("http://springframework.org/spring-ws", "child", "child", new AttributesImpl());
50 contentHandlerMock.endElement("http://springframework.org/spring-ws", "child", "child");
51 contentHandlerMock.endDocument();
52
53 xmlReader.setContentHandler(contentHandlerMock);
54 mockControl.replay();
55 xmlReader.parse(new InputSource());
56 mockControl.verify();
57 }
58
59 }
60