From: Brad C. <yo...@br...> - 2005-05-04 20:13:47
|
I'm asking lots of questions because I don't like overloading getPage...I just finished cleaning up that mess! :) It seems like adding a setVirtualHost on HttpWebConnection would be able to accomplish what you need and minimize the testing needs. Due to the client pooling in there you'd need to store the value in HttpWebConnection but I think that could disappear when the pooling does. At one point it was suggested that the goal was to expose the HttpClient to the user for doing things like this. Maybe it would be better to figure out how to go about that instead? Brad C --- Dan Levine <dl...@ca...> wrote: > Brad, > > I want to run test cases for hostnames that are not registered in DNS, and > don't want to hack the hostnames into /etc/hosts on every machine that the > tests will run on. So I want to embed the /etc/host virtual host mapping > into the HttpClient. That functionality is available through > > commonsHttpClient.getParams().setVirtualHost("www.mydomain.com"); > > http://jakarta.apache.org/commons/httpclient/3.0/apidocs/org/apache/commons/ > httpclient/params/HostParams.html#setVirtualHost(java.lang.String) > > Then you can htmlUnitWebClient.getPage with a URL "192.168.10.10" and if > there are cookies on that site that reqire the domain to be "mydomain.com" > it will work. That is useful for testing locally sites that have required > cookies for the eventual DNS of the production site. > > I have very simple test cases with HtmlUnit that show this to work, but I am > trying to break it down to JUnit tests with mock objects so I can submit a > patch to HtmlUnit. > > > Chris, > > > I would start by overloading the getPage call to add the extra > > parameter. This would then allow all of the existing calls still work > > and you would only be adding the test that calls your new method. > > Yes, I am doing it like that :), but I dont know how to write Junit tests > for a getPage(..) call using the GS mock objects, and I dont see any other > examples I can model off. I cant use the MockWebConnection obviously > because I have to use the HttpWebConnection, so ... ? Is there an example of > how to mock this? > > -d > > > > -----Original Message----- > > From: htm...@li... > > [mailto:htm...@li...]On Behalf Of Brad > > Clarke > > Sent: Tuesday, May 03, 2005 1:22 PM > > To: htm...@li... > > Subject: Re: [Htmlunit-user] Virtual Host feature -- tests? > > > > > > I've only heard the term virtual host used when talking about > > apache virtual hosts, > > which doesn't seem right. Could you point me at some > > documentation about what it is > > you are doing? > > > > Brad C > > > > --- Dan Levine <dl...@ca...> wrote: > > > Hey all, > > > > > > I need to allow virtual host functionality for my tests. After > > asking here > > > a bit ago, I took the issue up with the HttpClient list. They > > showed my how > > > to achieve this functionality which I began testing out thought the > > > HttpClient in the HttpWebConnection class. turns out there was a bug in > > > HttpClient, and they have now provided a patch. Now, I would > > like to add an > > > additional parameter to WebClient.getPage(..) to take a String > > virtualHost > > > in as well as a URL. I am not sure how to go about writing > > tests for this > > > however, since none of the getPage(..) functions currently have > > tests, and > > > since this is hitting right in the middle of MockWebConnection. > > Since the > > > change also needs to go down into HttpWebConnection.getResponse(..) so I > > > could add the tests there, but there are not currently any tests for the > > > HttpWebConnection.getResponse(..) functions that i can model it after. > > > > > > Thoughts? > > > > > > dan > > > > > > > -----Original Message----- > > > > From: htm...@li... > > > > [mailto:htm...@li...]On Behalf Of Marc > > > > Guillemot > > > > Sent: Tuesday, May 03, 2005 6:24 AM > > > > To: htm...@li... > > > > Subject: Re: [Htmlunit-user] Re: Javascript problem > > > > > > > > > > > > Dave Kosenko wrote: > > > > > But I am running v 1.5 and am seeing the problem . Do you > > mean that it > > > > > is fixed in versions > > > > > *after* 1.5? > > > > > > > > yes, this is has been fixed since version 1.5 and as long as no > > > > new release is published, you can only get it using the > > > > CVS access. > > > > > > > > Marc. |