• Post Reply Bookmark Topic Watch Topic
  • New Topic

Testing overridden startElement from a Custom XML processor  RSS feed

Geane Norm
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have been struggling trying to understand how I can Unit Test the overridden startElement method in my Custom Xml Processor that extends DefaultHandler. What I would like to do (correct me if I am wrong) is to be able to compare the start element found in my InputStream with that returned by the startElement method. In order to do so, I have converted the InputStream into a String and using the Pattern/Matcher I hit the tag in question (not sure whether this is the best approach, feel free to suggest any alternative, please). Now, in my test I need to call the overridden version of startElement and in order to do so, I need to get hold of the following parameters: String uri, String localName, String qNam and Attributes attribute. I have seen a number of examples online on how to call the get methods on Attributes, but in my case I am not sure how to do that, can you help? Unfortunately, I cannot provide the working xml file, but an example with one found online would be OK, as follows:

Subsequently, I would like to get hold of the same tag from my InputStream-String conversion and you can see an example below. Am I actually going towards the right direction?

Thank you,

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!