From: Dan L. <dl...@ca...> - 2005-05-03 20:37:05
|
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. > > > > > > > > > ------------------------------------------------------- > > > This SF.Net email is sponsored by: NEC IT Guy Games. > > > Get your fingers limbered up and give it your best shot. 4 > great events, 4 > > > opportunities to win big! Highest score wins.NEC IT Guy Games. Play to > > > win an NEC 61 plasma display. Visit http://www.necitguy.com/?r=20 > > > _______________________________________________ > > > Htmlunit-user mailing list > > > Htm...@li... > > > https://lists.sourceforge.net/lists/listinfo/htmlunit-user > > > > > > > > > > > > > ------------------------------------------------------- > > This SF.Net email is sponsored by: NEC IT Guy Games. > > Get your fingers limbered up and give it your best shot. 4 > great events, 4 > > opportunities to win big! Highest score wins.NEC IT Guy Games. Play to > > win an NEC 61 plasma display. Visit http://www.necitguy.com/?r=20 > > _______________________________________________ > > Htmlunit-user mailing list > > Htm...@li... > > https://lists.sourceforge.net/lists/listinfo/htmlunit-user > > > > > ------------------------------------------------------- > This SF.Net email is sponsored by: NEC IT Guy Games. > Get your fingers limbered up and give it your best shot. 4 great events, 4 > opportunities to win big! Highest score wins.NEC IT Guy Games. Play to > win an NEC 61 plasma display. Visit http://www.necitguy.com/?r=20 > _______________________________________________ > Htmlunit-user mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/htmlunit-user > |