Hi Jason,

> what is the format that you would like to receive the changes (code + unit 
> test 
>class + additional html resource file)

A standard .patch file would be great (you can create one using svn patch 
command).

> where the It would appear that i can reference HtmlUnitTestingEngineImpl from 
>inside the "jwebunit-commons-tests".

You are right, there is a dependency issue because common-tests are designed to 
be independent of the testing engine. So this is the testing engine module that 
depends on common-tests.

I will look at your work but I guess the best solution is to put this test that 
is very specific to HtmlUnit in HtmlUnit module.

Regards,

Julien


>
>De : Jason McSwain <[email protected]>
>À : Julien HENRY <[email protected]>
>Envoyé le : Sam 4 septembre 2010, 0h 24min 20s
>Objet : Re: Re : Attempted to refresh a page using an ImmediateRefreshHandler 
>which could have caused an OutOfMemoryError Please use WaitingRefreshHandler 
>or 
>ThreadedRefreshHandler instead
>
>Ok, next question:
>
>If i wanted to create a Test Class "RefreshHandlerTest" and an associated 
>resource, 
>
>
>I tried putting the test in the 
>"jwebunit-common-tests/src/test/java/net.sourceforge.jwebunit.tests.util.reflect"
>
>and i put the test html page into 
>"jwebunit-common-tests/src/main/resources/testcases/RefreshHandlerTest/testPage.html"
>
>
>ive attached them, incase you want to give it a try yourself.  
>
>My problem is a compilation issue, where the It would appear that i can 
>reference HtmlUnitTestingEngineImpl from inside the "jwebunit-commons-tests".  
>I 
>then tried moving the test over to the 
>"jwebunit-htmlunit-plugin/net.sourceforge.jwebunit.htmlunit package" and then 
>ran the "mvn clean ; mvn compile ; mvn test " from there, too, but i get even 
>more errors.
>
>Any guidance would be appreciated.
>
>thank you.
>
>-Jason-
>
>
>On Fri, Sep 3, 2010 at 3:24 PM, Jason McSwain <[email protected]> wrote:
>
>Hey Julien,
>>
>>I figured out the issue i was having with eclipse, after searching the 
>>mailing 
>>archives, i found a msg where you were talking about "mvn eclipse:eclipse".  
>>I 
>>ran that, then restarted eclipse, and all was fine.
>>
>>I'm currently in the process of writing the unit tests for validation.  when 
>>i 
>>have this completed, what is the format that you would like to receive the 
>>changes (code + unit test class + additional html resource file) ?
>>
>>Thanks,
>>-Jason-
>>
>>
>>
>>On Fri, Sep 3, 2010 at 12:47 PM, Jason McSwain <[email protected]> 
wrote:
>>
>>Hey Julien,
>>>
>>>i've been following the instructions on the web about setting up 
>>>maven/jwebunit, 
>>>and i'm running into a couple problems.  here is what i've done:
>>>
>>>
>>>     1. setup ubuntu 10.04.1 64bit VM
>>>     2. installed jdk 1.5.0_22 to /opt/jdk1.5.0_22
>>>     3. install svn
>>>     4. check jwebunit to home dir:   
>>>
>>>     1. svn co https://jwebunit.svn.sourceforge.net/svnroot/jwebunit jwebunit
>>>     5. installed and configured maven2
>>>     6. setup env and path changes.
>>>     7. defined ~/.m2/toolchains.xml
>>>     1. <?xml version="1.0" encoding="UTF8"?>
>>><toolchains>
>>>  <toolchain>
>>>     <type>jdk</type>
>>>     <provides>
>>>         <version>1.5</version>
>>>         <vendor>sun</vendor>
>>>         <id>1.5</id>
>>>     </provides>
>>>     <configuration>
>>>        <jdkHome>/opt/jdk1.5.0_22</jdkHome>
>>>     </configuration>
>>>  </toolchain>
>>></toolchains>
>>>     2. confirm path to java is correct  
>>>
>>>     8. cd jwebunit/trunk
>>>     9. ran mvn compile
>>>
>>>     10. mvn install
>>>
>>>     11. mvn clean
>>>
>>>     12. mvn test
>>>
>>>     13. mvn package assembly:assembly
>>>     14. export MAVEN_OPTS=-Xmx384M
>>>     15. mvn site
>>>     16. mvn site:stage -DstagingDirectory=./staging
>>>     17. all of this seems to be working fine.
>>>     18. so i moved onto setting up a dev env with eclipse.
>>>     1. install eclipse heilos
>>>     2. install maven plugin
>>>     3. import maven project into eclipse from ~/jwebunit/trunk to eclipse 
>>> workspace 
>>>@ ~/workspace/jwebunit/trunk
>>>     4. the project builds, but i have compilation errors:
>>>     1. [ERROR] Cannot find matching toolchain dfinitions for the following 
>>>toolchain types: jdk [ vendor='sun'  version='1.5' ]
>>>     2. [ERROR] Build errors for jwebunit-commons-test; 
>>>org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute 
>>>goal 
>>>org.apache.maven.plugins:maven-toolchains-plugin1.0:toolchain (default) on 
>>>project jwebunit-commons-teste: Cannot find matching toolchain definitions 
>>>for 
>>>the following toolchain types: jdk [ vendor='sun'  version='1.5' ]
>>>     3. Please make sure you define the required toolchains in your 
>>>~/.m2/toolchains.xml file
>>>I wanted to setup the eclipse env so that i could easily add the unit tests 
>>>you 
>>>requested. I did make the change and all builds correctly, I also took the 
>>>"snapshot jars" and put them in my project, and it fixes the problem.  I 
>>>will be 
>>>happy to add unit tests for this, if someone can assist me in getting my 
>>>eclipse 
>>>env working.
>>>
>>>here is the code i used to validate the change fixes the problem.  JWebUnit 
>>>Trunk code change has been attached to this email.
>>>
>>>
>>>public class TestWebTester extends WebTester {
>>>    private String baseUrl;
>>>
>>>    public TestWebTester() {
>>>        super();
>>>        init();
>>>    }
>>>
>>>    public TestWebTester(String baseUrl) {
>>>        super();
>>>        this.baseUrl = baseUrl;
>>>        init();
>>>    }
>>>
>>>    public void init() {
>>>        System.out.println("TestWebTester.init()");
>>>        // set base url
>>>        try {
>>>            ITestingEngine engine = this.getTestingEngine();
>>>            HtmlUnitTestingEngineImpl impl = (HtmlUnitTestingEngineImpl) 
>>>engine;            
>>>
>>>            impl.setRefreshHandler(new ThreadedRefreshHandler());
>>>            setBaseUrl(this.baseUrl);
>>>
>>>            System.out.println("  -> set begin at  = '/'");
>>>            beginAt("/");
>>>
            System.out.println("-------------------------");
>>>            System.out.println(impl.getPageTitle());
>>>            System.out.println("-------------------------");
>>>            System.out.println(impl.getPageSource());
>>>            System.out.println("-------------------------");
>>>
>>>        } catch (TestingEngineResponseException e) {
>>>            throw new RuntimeException("Unexpected 
>>>TestingEngineResponseException during init.", e);
>>>        } catch (Exception e) {
>>>            throw new RuntimeException("Unexpected Exception during init.", 
>e);
>>>        }
>>>    }
>>>
>>>    public static void main(String[] args) {
>>>        System.out.println("----- Begin -----");
>>>        try {
>>>            // TestWebTester twt = new 
>TestWebTester("http://10.10.10.31:90/";);
>>>            TestWebTester twt = new 
TestWebTester("http://192.168.44.21:90/";);
>>>
>>>        } catch (Throwable t) {
>>>            System.out.println("*** ERROR ***");
>>>            t.printStackTrace();
>>>            System.out.println();
>>>            System.out.println("*************");
>>>        }
>>>
>>>        System.out.println("-----  end  -----");
>>>    }
>>>}
>>>
>>>
>>>
>>>
>>>
>>>
>>>On Thu, Sep 2, 2010 at 10:05 AM, Jason McSwain <[email protected]> 
>wrote:
>>>
>>>Will do.  I'll keep you posted when i have this completed.
>>>>
>>>>thanks,
>>>>-Jason-
>>>>
>>>>
>>>>
>>>>On Thu, Sep 2, 2010 at 10:02 AM, Julien HENRY <[email protected]> wrote:
>>>>
>>>>(I have switched to the DEV list)
>>>>>
>>>>>Sound good to me. Don't forget to update the WebClient if it is already 
>>>>>initialized:
>>>>>
>>>>>public void setRefreshHandler(RefreshHandler refreshHandler) {
>>>>>    this.refreshHanlder = refreshHandler;
>>>>>    //In case user wants to change RH in the middle of a test
>>>>>    if (wc != null) {
>>>>>      wc.setRefreshHandler(refreshHandler);
>>>>>    }
>>>>>}
>>>>>
>>>>>Could you please try to write a small JUnit test that is failing when 
>>>>>using 
>>>>>ImmediateRefreshHandler and is fixed when using your patch. I think a page 
>>>>>with 
>>>>>a refresh <meta> could do the job.
>>>>>
>>>>>Also don't forget the ugly instanceof before casting the result of 
>>>>>getTestingEngine(), because JUnit tests are  designed to run with all 
>>>>>testing 
>>>>>engines.
>>>>>
>>>>>Regards,
>>>>>
>>>>>Julien
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>>
>>>>>>De : Jason McSwain <[email protected]>
>>>>>>À : Usage problems for JWebUnit <[email protected]>
>>>>>>Envoyé le : Jeu 2 septembre 2010, 16h 43min 03s
>>>>>>Objet : Re: [JWebUnit-users] Re : Re : Attempted to refresh a page using 
>>>>>>an 
>>>>>>ImmediateRefreshHandler which could have caused an OutOfMemoryError 
>>>>>>Please use 
>>>>>>WaitingRefreshHandler or  ThreadedRefreshHandler instead
>>>>>>
>>>>>>
>>>>>>i agree it's not a clean solution, but that's exactly what i was planning 
>>>>>>on 
>>>>>>doing.  i'm working through the maven setup today and hope to have my env 
>>>>>>setup, 
>>>>>>compiled, and tested soon enough.
>>>>>>
>>>>>>here is what i was planning on doing in HtmlUnitTestingEngineImpl:
>>>>>>
>>>>>>
>>>>>>  * Add these:
>>>>>>  * private RefreshHandler refreshHandler = null;
>>>>>>  * public void setRefreshHandler(RefreshHandler refreshHandler)
>>>>>>  * Modify initWebClient()
>>>>>>  * if (this.refreshHandler == null) {
>>>>>>       wc.setRefreshHandler(new ImmediateRefreshHandler());
>>>>>>    } else {
>>>>>>        wc.setRefreshHandler(this.refreshHandler);
>>>>>>    }i'll also be putting the updated jar in my env, to see if this fixes 
>>>>>> the 
>>>>>>problem.
>>>>>>
>>>>>>-Jason-
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>On Thu, Sep 2, 2010 at 1:54 AM, Julien HENRY <[email protected]> wrote:
>>>>>>
>>>>>>This is not a clean solution but an easy fix is to change visibility or 
>>>>>>add some 
>>>>>>methods in HtmlUnitTestingEngineImpl, and cast the use:
>>>>>>>((HtmlUnitTestingEngineImpl) getTestingEngine()).xxxxx (where xxx could 
>>>>>>>be 
>>>>>>>setDefaultRefreshHandler) before calling beginAt().
>>>>>>>
>>>>>>>Regards,
>>>>>>>
>>>>>>>Julien
>>>>>>>
>>>>>>>
>>>>>>>>
>>>>>>>>De : Jason McSwain <[email protected]>
>>>>>>>>À : Usage problems for JWebUnit  <[email protected]>
>>>>>>>>Envoyé le : Mer 1 septembre 2010, 18h 34min 35s
>>>>>>>>Objet : Re: [JWebUnit-users] Re : Attempted to refresh a page using an 
>>>>>>>>ImmediateRefreshHandler which could have caused an OutOfMemoryError 
>>>>>>>>Please use 
>>>>>>>>WaitingRefreshHandler or ThreadedRefreshHandler instead
>>>>>>>>
>>>>>>>>
>>>>>>>>Thank you for the quick response.  I would be interested in 
>>>>>>>>contributing.  i'm 
>>>>>>>>looking through the contribution steps here.  I would assume that it 
>>>>>>>>would be an 
>>>>>>>>easy fix.  Once i have an env setup, i'll put in a fix, and let you 
>>>>>>>>review it.
>>>>>>>>
>>>>>>>>Is there any particular way that you would prefer to have this done?
>>>>>>>>
>>>>>>>>-Jason-
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>On Wed, Sep 1, 2010 at 7:26 AM, Julien HENRY <[email protected]> wrote:
>>>>>>>>
>>>>>>>>Hi Jason,
>>>>>>>>>
>>>>>>>>>Currently there is no way to change the refresh handler. There is a 
>>>>>>>>>long 
>>>>>>>>>standing issue about accessing HtmlUnit internals from JWebUnit API. 
>>>>>>>>>At first it 
>>>>>>>>>was a choice to prevent user to call HtmlUnit specific API and prevent 
>>>>>>>>>easy 
>>>>>>>>>switch to another testing engine but now we admit there are cases 
>>>>>>>>>where it 
>>>>>>>>>should be possible.
>>>>>>>>>
>>>>>>>>>We are waiting for contribution in this area.
>>>>>>>>>
>>>>>>>>>Regards,
>>>>>>>>>
>>>>>>>>>Julien
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>De : Jason McSwain <[email protected]>
>>>>>>>>>>
>>>>>>>>>>À : [email protected]
>>>>>>>>>>Envoyé le : Mer 1 septembre 2010, 1h 03min 13s
>>>>>>>>>>Objet : [JWebUnit-users] Attempted to refresh a page using an 
>>>>>>>>>>ImmediateRefreshHandler which could have caused an OutOfMemoryError 
>>>>>>>>>>Please use 
>>>>>>>>>>WaitingRefreshHandler or ThreadedRefreshHandler instead
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>Hello,
>>>>>>>>>>
>>>>>>>>>>I searched both the Development and User forums, but didn't find an 
>>>>>>>>>>answer.  if 
>>>>>>>>>>this has already been answered please point me to the right entry in 
>>>>>>>>>>the 
>>>>>>>>>>archives.  Thank you in advance for any help you can provide.
>>>>>>>>>>
>>>>>>>>>>i'm new to the list, but have been using JWebUnit for the last 6 
>>>>>>>>>>months.  it 
>>>>>>>>>>works great on one of the products i test, so we decided to use it on 
>>>>>>>>>>another 
>>>>>>>>>>product, too.  This new product has a page that refreshes every 30 
>>>>>>>>>>seconds, and 
>>>>>>>>>>when i go to setup my WebTester, i get an exception. about 
>>>>>>>>>>RefreshHandlers.  We 
>>>>>>>>>>are using the HtmlUnit plugin, not selenium.  The Question i have is 
>>>>>>>>>>how do i 
>>>>>>>>>>change the Refresh handler?  This error happens when i call 
>>>>>>>>>>WebTester.beginAt("/"), and that method initializes the WebClient 
>>>>>>>>>>inside a 
>>>>>>>>>>private method, and sets the refreshHandler to the 
>>>>>>>>>>ImmediateRefreshHandler.  i'd 
>>>>>>>>>>like to use another type.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>Error:
>>>>>>>>>>java.lang.RuntimeException: Unexpected Exception during init.
>>>>>>>>>>    at TestWebTester.init(TestWebTester.java:53)
>>>>>>>>>>    at TestWebTester.<init>(TestWebTester.java:37)
>>>>>>>>>>    at TestWebTester.main(TestWebTester.java:60)
>>>>>>>>>>Caused by: java.lang.RuntimeException: Refresh to 
>>>>>>>>>>http://10.10.10.31:90/ (30s) 
>>>>>>>>>>aborted by HtmlUnit: Attempted to refresh a page using an 
>>>>>>>>>>ImmediateRefreshHandler which could have caused an OutOfMemoryError 
>>>>>>>>>>Please use 
>>>>>>>>>>WaitingRefreshHandler or ThreadedRefreshHandler instead.
>>>>>>>>>>    at 
>>>>>>>>>>com.gargoylesoftware.htmlunit.ImmediateRefreshHandler.handleRefresh(ImmediateRefreshHandler.java:58)
>>>>>>>>>>
>>>>>>>>>>    at 
>>>>>>>>>>com.gargoylesoftware.htmlunit.html.HtmlPage.executeRefreshIfNeeded(HtmlPage.java:1279)
>>>>>>>>>>
>>>>>>>>>>    at 
>>>>>>>>>com.gargoylesoftware.htmlunit.html.HtmlPage.initialize(HtmlPage.java:218)
>>>>>>>>>>    at 
>>>>>>>>>>com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.java:427)
>>>>>>>>>>    at 
>>>com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:303)
>>>>>>>>>>    at 
>>>com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:360)
>>>>>>>>>>    at 
>>>>>>>>>>net.sourceforge.jwebunit.htmlunit.HtmlUnitTestingEngineImpl.gotoPage(HtmlUnitTestingEngineImpl.java:248)
>>>>>>>>>>
>>>>>>>>>>    at 
>>>>>>>>>>net.sourceforge.jwebunit.htmlunit.HtmlUnitTestingEngineImpl.beginAt(HtmlUnitTestingEngineImpl.java:207)
>>>>>>>>>>
>>>>>>>>>>    at 
>>>>net.sourceforge.jwebunit.junit.WebTester.beginAt(WebTester.java:228)
>>>>>>>>>>    at TestWebTester.init(TestWebTester.java:48)
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>Here is an example code snippet that uncovers the issue:
>>>>>>>>>>
>>>>>>>>>>****************************************************************************************
>>>>>>>>>>
>>>>>>>>>>public class TestWebTester extends WebTester {
>>>>>>>>>>    private String baseUrl;
>>>>>>>>>>
>>>>>>>>>>    public TestWebTester() {
>>>>>>>>>>        super();
>>>>>>>>>>        init();
>>>>>>>>>>    }
>>>>>>>>>>
>>>>>>>>>>    public TestWebTester(String baseUrl) {
>>>>>>>>>>        super();
>>>>>>>>>>        this.baseUrl = baseUrl;
>>>>>>>>>>        init();
>>>>>>>>>>    }
>>>>>>>>>>
>>>>>>>>>>    public void init() {
>>>>>>>>>>        System.out.println("TestWebTester.init()");
>>>>>>>>>>        // set base url
>>>>>>>>>>        try {
>>>>>>>>>>
>>>>>>>>>>            setBaseUrl(this.baseUrl);
>>>>>>>>>>            // first part to load
>>>>>>>>>>            System.out.println("  -> set begin at  = '/'");
>>>>>>>>>>            beginAt("/");
>>>>>>>>>>
>>>>>>>>>>        } catch (TestingEngineResponseException e) {
>>>>>>>>>>            throw new RuntimeException("Unexpected 
>>>>>>>>>>TestingEngineResponseException during init.", e);
>>>>>>>>>>        } catch (Exception e) {
>>>>>>>>>>            throw new RuntimeException("Unexpected Exception during 
>>>>>>>>>> init.", 
>>>>>>>>e);
>>>>>>>>>>        }
>>>>>>>>>>    }
>>>>>>>>>>
>>>>>>>>>>    public static void main(String[] args) {
>>>>>>>>>>        System.out.println("----- Begin -----");
>>>>>>>>>>        try {
>>>>>>>>>>            TestWebTester twt = new 
>>>>>TestWebTester("http://10.10.10.31:90/";);
>>>>>>>>>>        } catch (Throwable t) {
>>>>>>>>>>            System.out.println("*** ERROR ***");
>>>>>>>>>>            t.printStackTrace();
>>>>>>>>>>            System.out.println();
>>>>>>>>>>            System.out.println("*************");
>>>>>>>>>>        }
>>>>>>>>>>
>>>>>>>>>>        System.out.println("-----  end  -----");
>>>>>>>>>>    }
>>>>>>>>>>}
>>>>>>>>>>****************************************************************************************
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>------------------------------------------------------------------------------
>>>>>>
>>>>>>>>>This SF.net Dev2Dev email is sponsored by:
>>>>>>>>>
>>>>>>>>>Show off your parallel programming skills.
>>>>>>>>>Enter the Intel(R) Threading Challenge 2010.
>>>>>>>>>http://p.sf.net/sfu/intel-thread-sfd
>>>>>>>>>_______________________________________________
>>>>>>>>>JWebUnit-users mailing list
>>>>>>>>>[email protected]
>>>>>>>>>https://lists.sourceforge.net/lists/listinfo/jwebunit-users
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>------------------------------------------------------------------------------
>>>>
>>>>>>>This SF.net Dev2Dev email is sponsored by:
>>>>>>>
>>>>>>>Show off your parallel programming skills.
>>>>>>>Enter the Intel(R) Threading Challenge 2010.
>>>>>>>http://p.sf.net/sfu/intel-thread-sfd
>>>>>>>_______________________________________________
>>>>>>>JWebUnit-users mailing list
>>>>>>>[email protected]
>>>>>>>https://lists.sourceforge.net/lists/listinfo/jwebunit-users
>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
>


      
------------------------------------------------------------------------------
This SF.net Dev2Dev email is sponsored by:

Show off your parallel programming skills.
Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd
_______________________________________________
JWebUnit-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jwebunit-development

Reply via email to