There is nothing in the code you posted that relates to XML. Where does XML come into play here? If you're expecting 'parentId' values to be in XML format, then you should pass it to some other class that expects this and can validate it accordingly.
Still not getting how this new code relates to the original code you posted and your question about "testing in XML." BTW, there are several "code smells" that make me crinkle my nose when reading this code.
I could give more details but that would steer the discussion away from your original question. Do you want to digress or stick with the original question? Sorry for opening the door to the digression, but sometimes I can't resist pointing out code smells. Force of habit from doing daily code reviews.
Joined: Oct 27, 2010
Hello I appreciate what you have said so far, it is food for thought, that is for sure. I will be sure and point this out to my team. I knew already that we had authentication problems.
I guess if you had the time, I would like to do both, to digress and to stick to the original question, only if you have the time, if not, can you revert back to the original question asked,
For the original question: What exactly do you mean by "testing in XML"? Nothing you have given so far gives any context around that.
As for code smells:
1. "SelectFinanceReporting" is a poor class name. Class names should be nouns or noun phrases. In this case, you have a verb phrase.
2. getNavBarItem and getBanner methods have parameters that are never used.
3. getContent has a catch block but all it does is rethrow the exception. This does nothing useful; it's redundant and pointless. You should do more in the catch block or just remove the try-catch altogether.
4. You appear to be building XML content in a servlet. This responsibility should be given to another class, one that doesn't care about HttpServletRequest or HttpServletResponse or Context. Your servlet should just delegate to that class, passing in any information which it already extracted from the request. This makes the class that generates the XML easier to unit test. Hopefully, you are unit testing you code but my guess is your team is not doing much automated unit testing.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com