[ptt-users] Enable redirect in TestMaker functional tests

DGeorgie at wiley.com DGeorgie at wiley.com
Wed Mar 12 05:59:01 PST 2008


That was really helpful but unfortunately I still have issue running the 
code both from TestMaker and the command line: Ideally I would like to run 
the code from the command line so I can integrate it with some automation 
scripts that can be run on demand,

First  I created a JAR file and try to run the Java code using new 
Functional Test in TestMaker:
====================================================================================
The test failed and the following error was generated:
java.lang.NullPointerException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at
com.pushtotest.testmaker.XSTest.xml.TestScenario.ScriptRunner$Excecuter.run(ScriptRunner.java:1330)
java.lang.NullPointerException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at
com.pushtotest.testmaker.XSTest.xml.TestScenario.ScriptRunner$Excecuter.run(ScriptRunner.java:1330)



Second, i tried to run the program from the command line. I compileed the 
Java code using TestMaker.sh start-up script as a template to create the 
classpath. When I run the program from the command line I receive this 
error:
===================================================================================================================================================
I will put my questions in front of the log output so they are not 
overlooked.

1) what is null/pttfrozen1_ProfLogin_loop2.tg4w_rec.html file? TestMaker 
created only pttfrozen1_ProfLogin_loop2.tg4w at the conversion.

2) any idea why the placeholder variables are not replaced with the actual 
values from the dataset?

./ProfLogin.sh  (this script creates the classpath and starts 
ProfLogin_loop2_tg4w program)

java.io.FileNotFoundException: 
null/pttfrozen1_ProfLogin_loop2.tg4w_rec.html (No such file or directory)
        at java.io.FileOutputStream.open(Native Method)
        at java.io.FileOutputStream.<init>(FileOutputStream.java:179)
        at java.io.FileOutputStream.<init>(FileOutputStream.java:70)
        at java.io.FileWriter.<init>(FileWriter.java:46)
        at 
com.spike.tg4w.htmlunit.XmlTestResultImpl.outputFileAsHtml(XmlTestResultImpl.java:126)
        at 
com.spike.tg4w.htmlunit.XmlTestResultImpl._startTest(XmlTestResultImpl.java:74)
        at 
com.spike.tg4w.htmlunit.XmlTestResultImpl.testStart(XmlTestResultImpl.java:159)
        at 
gen.tests.htmlunit.ProfLogin_loop2_tg4w.run(ProfLogin_loop2_tg4w.java:23)
        at 
gen.tests.htmlunit.ProfLogin_loop2_tg4w.runMe(ProfLogin_loop2_tg4w.java:152)
        at 
gen.tests.htmlunit.ProfLogin_loop2_tg4w.main(ProfLogin_loop2_tg4w.java:166)
Mar 12, 2008 8:49:35 AM com.spike.tg4w.htmlunit.XmlTestResultImpl info
INFO: Enabling EasySSL
Mar 12, 2008 8:49:36 AM com.spike.tg4w.htmlunit.XmlTestResultImpl info
INFO: parsing 
file:/home/dgeorgie/programs/PushToTest/TestMaker/tests/wplus/pttfrozen1_ProfLogin_loop2.tg4w
Mar 12, 2008 8:49:36 AM com.spike.tg4w.htmlunit.XmlTestResultImpl info
INFO: setDatasets: Total datasets:1
Mar 12, 2008 8:49:36 AM com.spike.tg4w.htmlunit.XmlTestResultImpl info
INFO: setDatasets: initializing dataset: dt_servers with file 
/home/dgeorgie/programs/PushToTest/TestMaker/tests/wplus/wp_server.cvs
Mar 12, 2008 8:49:36 AM com.spike.tg4w.htmlunit.XmlTestResultImpl info
INFO: Step start: 0 type=loop-dataset-dt_servers-server
Mar 12, 2008 8:49:36 AM com.spike.tg4w.htmlunit.XmlTestResultImpl info
INFO: Step start: 1 type=goto
Mar 12, 2008 8:49:36 AM com.spike.tg4w.htmlunit.XmlTestResultImpl info
INFO: changing url to page: 
http://${dt_servers.wp_server}:${dt_servers.wp_port}/edugen/secure/index.uni
------------- ERROR ---------------- 
com.spike.tg4w.htmlunit.InterpreterException: error while fetching url: 
http://${dt_servers.wp_server}:${dt_servers.wp_port}/edugen/secure/index.uni
        at 
com.spike.tg4w.htmlunit.HtmlUnitInterpreter.handleAction_goto_url(HtmlUnitInterpreter.java:294)
        at 
gen.tests.htmlunit.ProfLogin_loop2_tg4w.run(ProfLogin_loop2_tg4w.java:61)
        at 
gen.tests.htmlunit.ProfLogin_loop2_tg4w.runMe(ProfLogin_loop2_tg4w.java:152)
        at 
gen.tests.htmlunit.ProfLogin_loop2_tg4w.main(ProfLogin_loop2_tg4w.java:166)
Caused by: java.net.MalformedURLException: For input string: 
"${dt_servers.wp_port}"
        at java.net.URL.<init>(URL.java:601)
        at java.net.URL.<init>(URL.java:464)
        at java.net.URL.<init>(URL.java:413)
        at 
com.spike.tg4w.htmlunit.HtmlUnitInterpreter.handleAction_goto_url(HtmlUnitInterpreter.java:292)
        ... 3 more
error while fetching url: 
http://${dt_servers.wp_server}:${dt_servers.wp_port}/edugen/secure/index.uni
------------------------------------ 
[dgeorgie at zadar wplus]$ 

Dimitar Georgievski
----------------------------------------
Senior Unix Admin
Electronic Support Services
John Wiley & Sons, Inc.
Tel: 201.748.5867
Cell: 917.295.1462
email: dgeorgie at wiley.com
----------------------------------------



Olivier Dony <olivier.dony at denali.be> 
Sent by: users-bounces at lists.pushtotest.com
03/12/2008 06:26 AM
Please respond to
TestMaker users list <users at lists.pushtotest.com>


To
TestMaker users list <users at lists.pushtotest.com>
cc

Subject
Re: [ptt-users] Enable redirect in TestMaker functional  tests






On Mar 12, 2008, at 3:16 AM, DGeorgie at wiley.com wrote:

> How do I enable the HTTP redirect in the
> Java code? I am still researching the documentation and  not sure 
> how to
> enable it.


You don't need to enable it, it works by default.
The messages you see about it being disabled are spurious logs 
produced by an underlying library, but they have absolutely no impact 
on the result.

If they really annoy you, it is quite simple to hide them (even 
without knowing the actual loggin system used) with a few lines of 
java code, e.g:

         // attempt to disable commons-httpclient logging
         try {
             java.util.logging.Logger.getLogger 
("org.apache.commons.httpclient.HttpMethodDirector").setLevel 
(java.util.logging.Level.OFF); // java.util.logging
             org.apache.log4j.Logger.getLogger 
("org.apache.commons.httpclient.HttpMethodDirector").setLevel 
(org.apache.log4j.Level.OFF); // log4j logging
         }
         catch (Throwable t) {
             /* ignored, we're just trying to turn off useless 
commons-http logging */
         }



> Too bad HTMLUnit is not supporting redirects. It makes simple tests
> difficult,

As stated, htmlunit does support redirect by default, don't worry 
about that part.
If you'd like to be certain, there's a "setRedirectEnabled()" method 
on the WebClient object from htmlunit, but if you look into the code 
you will see that it is enabled by default.


HTH,


--
Olivier Dony

Denali s.a., "Bridging the gap between Business and IT"
Rue de Clairvaux 8, B-1348 Louvain-la-Neuve, Belgium
Office: +32 10 43 99 51  Fax: +32 10 43 99 52
www.denali.be

Legal Notice: This message may contain confidential and/or privileged 
information. If you are not the addressee or authorized to receive 
this for the addressee, you must not use, copy, disclose or take any 
action based on this message or any information herein. If you have 
received this message by mistake, please advise the sender 
immediately by return e-mail and delete this message from your 
system. Thank you for your cooperation.

_______________________________________________
Users mailing list
Users at lists.pushtotest.com
http://lists.pushtotest.com/mailman/listinfo/users




More information about the Users mailing list