A DOMOutputBuffer which is "designed" for use with test cases.
Note that the original "design" for this was simply to collect together all the existing usages demonstrated in the various inner classes which had previously extended DOMOutputBuffer before the existance of this class, so the code is not necessarily the best at the moment. However, with continued use and more refactoring, this should evolve into something which is useful for all test cases.
Make sure you run ALL the test cases if you modify this class!
NOTE: several of the methods of this class are to do with collecting output from the output buffer after it is finished. There are two basic strategies for this, the first is to collect the entire output as a string, the second is to inspect the DOM elements created. Of these two basic strategies, there are quite a few variations used in the existing test cases, as they were all implemented separately. Neither of the two here are optimal in my opinion, which is why I have deprecated them. The variations I have discovered so far are:
- Use {@link #getCurrentElement} to access DOM nodes, this seems reasonable and I have added {@link DOMProtocolTestAbstract#checkElementEquals}, etc based on this.
- Use {@link #popElement} to access DOM nodes, this seems like a duplication of the above so I have deprecated it.
- Use {@link com.volantis.mcs.protocols.html.XHTMLBasicTestCase#bufferToString}(which is based on {@link com.volantis.mcs.dom.DOMUtilities#toString}) to get the output as a String, this seems reasonable.
- Use {@link #getWriter}, and cast it to a {@link StringWriter} to getthe output as a String, seems like a duplication of the above so I have deprecated it.
- Use {@link DOMProtocolTestAbstract.MyPageOutputBuffer#getWriter} which is a variation on this class, it has a to do to that effect.
Note that I have also discovered {@link com.volantis.mcs.protocols.wml.WMLRootTestCase#transformMarkup} to normalise expected markup strings, this should be combined with whatever approach you choose above.