(Fwd) httpunit xml-response
"Wolfgang Fahl" <[email protected]> Wed, 03 Dec 2008 11:29:27 +1300
| Newsgroups | gmane.comp.web.httpunit.devel |
|---|---|
| Organization | BITPlan GmbH |
| Message-ID | <[email protected]> |
Hi,
i'm forwarding Frank's proposal to the developer list
since his Bug report filed as
https://sourceforge.net/tracker2/?func=detail&aid=2373755&group_id=6550&atid=106550
is in conflict with one that was the basis for a
modification in version 1.7 in the first place:
https://sourceforge.net/tracker2/?func=detail&aid=1281655&group_id=6550&atid=106550
I have added the test case proposed by Frank to the svn
repository in the file XMLTest.java but deactivated it
by prepending an "x" to the test case name:
/**
* test case for BR [2373755] by Frank Waldheim
* deactivated since it is the opposite of 1281655
* @throws Exception
*/
public void xtestXMLisHTML() throws Exception {
String originalXml = "<?xml version=\"1.0\" ?><main><title>See me now</title></main>";
defineResource("SimplePage.xml", originalXml, "text/xml");
WebConversation wc = new WebConversation();
WebRequest request = new GetMethodWebRequest(getHostPath()+"/SimplePage.xml");
WebResponse simplePage = wc.getResponse(request);
// we do not have an html result
assertFalse("xml result is not HTML",simplePage.isHTML());
// get the main element as root
assertNotNull("we do have an root-element",simplePage.getDOM().getDocumentElement());
assertEquals("the actual root must be the root of our test-xml",simplePage.getDOM().getDocumentElement().getTagName(),"main");
}
based on Frank's comments below I'm looking for ideas to
get the two issues aligned with each other in a way that
might most of the httpunit users happy.
Currently only the static setValidContentTypes accessor
is available as a workaround.
So what do you think?
Wolfgang
------- Forwarded message follows -------
To: [email protected]
Subject: httpunit xml-response
From: [email protected]
Date sent: Mon, 1 Dec 2008 12:41:50 +0100
hi there,
as i am not a registered bugtrackuser for httpunit yet and i am not
completely sure if i _really_ have a problem
i write directly to you.
first of all i have to mention, that i have a servlet 2.5 webapp which only
renders XML responses.
now i have a 'problem' with the WebResponse class.
// [ 1281655 ] [patch] allow text/xml to be parsed as html
// testTraversal test changed after positive reply by Russell
private static final String XML_CONTENT = "text/xml";
// the list of valid content Types
private static String[] validContentTypes={
HTML_CONTENT, XHTML_CONTENT, FAUX_XHTML_CONTENT,
XML_CONTENT
};
and isHTML uses exactly those to identify HTML-content
later this method is used to distinguish between 'html' and 'raw' result.
public Document getDOM() throws SAXException {
if (isHTML()) {
return (Document) getReceivedPage().getDOM();
} else {
try {
return HttpUnitUtils.parse( new InputSource( new StringReader(
getText() ) ) );
} catch (IOException e) {
throw new SAXException( e );
}
}
}
so if my xml-response is recognized as a valid html-response i get a 'html-
view' on my xml
which starts with <html><head>...
this renders httpunit completely useless for me, as the original response is
modified.
i would strongly suggest to not mark text/xml as a valid _HTML_ response.
i hope i got the situation right and sorry for the direct mail to you.
hope to hear from you
~fw
BITPlan - smart solutions
Pater-Delp-Str. 1, D-47877 Willich Schiefbahn
Tel. +49 2154 811-480, Fax +49 2154 811-481
Web: http://www.bitplan.de
bitplan GmbH, Willich - HRB 6820 Krefeld, VAT-ID: 10258040548,
Geschäftsführer: Wolfgang Fahl
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Httpunit-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/httpunit-develop