jakarta-cactus-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Clovis Yutaka Harada <clo...@scopus.com.br>
Subject External Javascript files
Date Wed, 19 Mar 2003 14:35:16 GMT

Hi list,

I´m using cactus 1.4.1 to test a web app.
I´ve built some unit tests with cactus and junit and everything is ok.
They are integrated with ant and cruise-control so all tests run every hour.

Now I´m doing some functional tests using cactus with httpunit and I´m
having problems with external javascript files.

If i have something like:
-----
<SCRIPT language=JavaScript1.2 src="common/HM_Loader.js"
type=text/javascript></SCRIPT>
-----
the test fails with this trace:
    [junit] Testcase: testTelaMenu1 took 0.794 sec
    [junit]     Caused an ERROR
    [junit] null
    [junit] java.lang.NullPointerException
    [junit]     at
com.meterware.httpunit.HTMLPage.getIncludedScript(HTMLPage.java:105)
    [junit]     at
com.meterware.httpunit.DOMParser.getIncludedScript(NekoHTMLParser.java:117)
    [junit]     at
com.meterware.httpunit.ScriptFilter.startElement(ScriptFilter.java:87)
    [junit]     at org.cyberneko.html.HTMLTagBalancer.startElement(Unknown
Source)
    [junit]     at
org.cyberneko.html.HTMLScanner$ContentScanner.scanStartElement(Unknown
Source)
    [junit]     at
org.cyberneko.html.HTMLScanner$ContentScanner.scan(Unknown Source)
    [junit]     at org.cyberneko.html.HTMLScanner.scanDocument(Unknown
Source)
    [junit]     at org.cyberneko.html.HTMLConfiguration.parse(Unknown
Source)
    [junit]     at org.cyberneko.html.HTMLConfiguration.parse(Unknown
Source)
    [junit]     at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    [junit]     at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
    [junit]     at
com.meterware.httpunit.NekoHTMLParser.parse(NekoHTMLParser.java:49)
    [junit]     at com.meterware.httpunit.HTMLPage.parse(HTMLPage.java:249)
    [junit]     at
com.meterware.httpunit.WebResponse.getReceivedPage(WebResponse.java:918)
    [junit]     at
com.meterware.httpunit.WebResponse.getForms(WebResponse.java:289)
    [junit]     at
iwse.controller.ControllerTest.endTelaMenu1(ControllerTest.java:280)
    [junit]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)
    [junit]     at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
)
    [junit]     at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)
    [junit]     at
org.apache.cactus.AbstractWebTestCase.callEndMethod(AbstractWebTestCase.java
:177)
    [junit]     at
org.apache.cactus.AbstractWebTestCase.runGenericTest(AbstractWebTestCase.jav
a:263)
    [junit]     at
org.apache.cactus.ServletTestCase.runTest(ServletTestCase.java:133)
    [junit]     at
org.apache.cactus.AbstractTestCase.runBare(AbstractTestCase.java:195)


Note that, if I retrive the page with HttpUnit alone everything works fine.
Also, if I put the javascript code inside the html page (insted of loading
in separate file) using:
-----
<script>
<%@include file="HM_Loader.js" %>
</script>
-----
the test run without any problem.


I think it is obvious but here is the code that fails (with external
javascript file):
---------
    public void endTelaMenu1(
            com.meterware.httpunit.WebResponse theResponse) throws Exception
{
        com.meterware.httpunit.WebForm form = theResponse.getForms()[0];
        assertEquals(reqScrambled, form.getParameterValue("CTL"));
        assertEquals("-1", form.getParameterValue("NUMCC"));
        assertEquals("-1", form.getParameterValue("NUMPP"));
---------

And here is the httpunit code that works (with external javascript file):
---------
    public void testTelaMenu() {
            WebConversation wc = new WebConversation();
            WebRequest     req =
                new GetMethodWebRequest(
                "http://xxxxx:8080/xxx/xxxx/xxxxxx.asp?CTL=4272910994907");
            WebResponse   resp = wc.getResponse(req);
            WebForm form = resp.getForms()[0];
            assertEquals(reqScrambled, form.getParameterValue("CTL"));
            assertEquals("-1", form.getParameterValue("NUMCC"));
            assertEquals("-1", form.getParameterValue("NUMPP"));
    }
---------

Clovis



Mime
View raw message