SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 3 of 3
  1. #1
    Junior Member
    Join Date
    Feb 2005
    Location
    India
    Posts
    7
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Deprication in HttpUnit code

    Hi All

    Please have a look on the java code fragment as an attachment.

    *************************************************
    import com.meterware.httpunit.*;

    class QaInfoTech {

    public static void main (String param[]) {

    try {

    //Creating a Conversation class
    WebConversation ObjWc = new WebConversation ();

    //Obtaining the web page of QaInfoTech
    WebRequest ObjReq = new GetMethodWebRequest("http://www.qainfotech.net");
    WebResponse ObjRes = ObjWc.getResponse ( ObjReq );

    int size = ObjRes.getContentLength ();
    System.out.println ("The size of QaInfoTech page is " + size + " kb.");
    }

    catch (Exception e){
    System.out.println ("Exception " +e);
    }
    }


    }
    *************************************************

    When i compilethis code (javac QaInfoTech.java) its prompting two notes as follows

    Note: Some input files use or override a deprecated API.
    Note: Recompile with -deprecation for details.

    While this code is compiled with -deprecation option, it prompts three warning messages that HttpUnitOptions has been deprecated for following methods;

    (1) HttpUnitOptions.getParameterValuesValidated (In WebRequest.java)
    (2) HttpUnitOptions.getParameterValuesValidated (In WebForm.java)

    java.net.URLEncoder has been deprecated for
    (3) URLEncoder.encode (source)

    and Program compiles successfully. Running this Program to get the Content Length for a particular web site's home page returns output as -1kb.

    I have tried some web references and have not been able to come up with any kind of soultion so far.
    Kindly provide me with your thoughts on this problem.


    Thanks in Advance
    Shailesh
    Many of life's failures are people who did not realize how close they were to success when they gave up.

  2. #2
    Member
    Join Date
    Jul 2002
    Posts
    56
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Deprication in HttpUnit code

    A content length will only be returned if the HTTP header of Content-Length has been set. This wouldn't normally be set for a static web page (if it can even be set?). It is more likely to be set if the page is programatically generated such as from a servlet which "knows" the size of the page that it is outputting.

    Instead use

    int size = response.getText().length();

    to get the length of the response excluding headers. You should find it returns 115kb.
    Jill

    http://www.ozibug.com - quality web based bug tracking

  3. #3
    Advanced Member
    Join Date
    Jan 2002
    Location
    ma
    Posts
    531
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Deprication in HttpUnit code

    IF you are testing the header objects, the prior answer won't work.

    To get back to your original question...
    Your post is wrong. It's not that httpunit deprecated, but Java deprecated some calls in their java.net class that httpunit depends on. You have several options.
    1. Go back to older build of java. You don't always need to have the latest and greatest for 'testing' purpose. I stick with a working one as long as I can.
    2. Download the latest httpunit. Maybe they fixed the deprecated calls? The last release was in October so if you are using a JDK newer then the latest version, you may be out of luck.
    3. Get the source of httpunit, fix it, then submit it back to httpunit project. (Hell, I've submitted code to Ant project to fix bugs...).

    First two is ideal. I would guess the third is out of question as you'd probably done that by now. If you download their source, and simply compile it, you will see all the deprecation errors/warning.

    NOTE: I also use httpunit, but we are using an older version of jdk 1.4.x.

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 10.71%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 02:47 AM.

Copyright BetaSoft Inc.