Hi Tom,

I worked on your problem, and I just add some methods you may find usefull (I 
hope):

String getServeurResponse()  //Return HTTP response (header+body) (for debug 
purpose)
void saveAs(File f) //Save the last response to file
void assertDownloadedFileEquals(File expected) //Assert the last downloaded 
file is binary equal to the given one.

I also changed
String getPageSource() //will now return the content of the HTTP Body (As 
string)

In your case, you can use:
clickLinkWithText(LINK_TEST_FILE);
assertEquals(TEST_DATA, getPageSource());

Or better: put a copy of the expected file next to your test cases
clickLinkWithText(LINK_TEST_FILE);

assertDownloadedFileEquals(new File(EXPECTED_FILE_PATH));

Please test it to know if it solve your problem. I upload a new snapshot here:
http://jwebunit.sourceforge.net/m2-repo-snapshots/net/sourceforge/jwebunit
(just take the latest jwebunit-core and jwebunit-htmlunit-plugin JAR to replace 
those in jwebunit-1.4-rc1 release).

Hope it helps.

Julien



----- Message d'origine ----
De : Tom Block <[EMAIL PROTECTED]>
À : [email protected]
Envoyé le : Vendredi, 24 Novembre 2006, 10h47mn 25s
Objet : [Jwebunit-users] getResponseText()

Dear List,

while migrating from version 1.2 to 1.3, i just stumbled over a nasty 
problem:

In the old tests, i used to test downloading of a file by writing a 
temporary file with known TEST_DATA, associating this with the download 
link, press "download" and then grab the downloaded file, like:

clickLinkWithText(LINK_TEST_FILE);
assertEquals(TEST_DATA, getDialog().getResponseText());

This is a nifty way to check that files are correctly downloaded. BUT, 
version 1.3 removed getResponseText() from the public API, and when i 
try to dumpHTML() to a ByteArrayOutputStream, as Julien suggested, i get 
punished with:

java.lang.RuntimeException: Unexpected content

Anybody has a workaround???

Thanks a lot,

Tom


-- 
____________________________________________

 Brockmann Consult
 Dipl.-Ing. Thomas Block

    Max-Planck-Str. 2 / GITZ
    21502 Geesthacht

    Tel:  +49 (0)4152 889 304

    mailto:[EMAIL PROTECTED]
    http://www.brockmann-consult.de
____________________________________________



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Jwebunit-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jwebunit-users







        

        
                
___________________________________________________________________________ 
Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions ! 
Profitez des connaissances, des opinions et des expériences des internautes sur 
Yahoo! Questions/Réponses 
http://fr.answers.yahoo.com
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Jwebunit-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jwebunit-users

Reply via email to