Discussion:
[castor-dev] StAX2SAX Bridge. How to test it ?
Philipp Erlacher
2010-06-16 16:28:31 UTC
Permalink
Hello Devs,

As part of my GSoC program I'm writing a StAX-2-SAX-Bridge for the
StAX Event API.

How should the bridge be used ?
First instantiate the bridge. It takes a SAX ContentHandler and a StAX
XMLEventReader.
bridge = new Stax2SaxBridge(contentHandler, eventReader);

Then, Call bridge.bridge() which will handle XMLEvents as long as
there are more events in the stream.

That's how it should work... but


I'd feel much more comfortable if I had some tests and hereby I need
your help and wisdom.
How would you write tests for this bridge ?

My idea is to use a contentHandler called Stax2SaxMockHandler which
extends DefaultHandler.
In this mockHandler I am going to check if a startElement was
correctly produced or not.
To know whether a startElement was correctly produced or not
I first parse the same sample xml directly using SAX, remember the
output of startElement and then compare it
to the startElement the bridge produced.

I hope I could clarify the idea.


I currently tried to parse the sample xml using SAX but I get [Fatal
Error] :1:1: Content is not allowed in prolog.

If you want, and I hope you do, you could look at the source code and
tell me your ideas. The source is attached as Jirra issue [1].

Cheers,
Philipp

[1] http://jira.codehaus.org/browse/CASTOR-2949

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Loading...