I have written a basic test that works as written; however, I noticed
that the test always leaves a session open on the container; even
though I wrote the test to click the "Logoff" link; I also tried
simply going to the URL that invalidates the session.  Is there
something special I need to do?  I thought maybe cookies were not
enabled but I enabled them with the HttpUnit ClientProperties and
still the sessions are not invalidating ... here is my test as it
stands now ....
<code>
package com.oreilly.strutsckbk.ch13;

import com.meterware.httpunit.HttpUnitOptions;

import net.sourceforge.jwebunit.TestContext;
import net.sourceforge.jwebunit.WebTestCase;

public class RegistrationWebTest extends WebTestCase {
    public RegistrationWebTest(String name) {
        super(name);
    }

    public void setUp() throws Exception {
        HttpUnitOptions.setScriptingEnabled(false);
        TestContext testContext = getTestContext();
        testContext.setBaseUrl("http://localhost/jsc-ch13";);
        
testContext.setResourceBundleName("org.apache.struts.webapp.example.ApplicationResources");
        testContext.getWebClient().getClientProperties().setAcceptCookies(true);
    }
    
    public void testRegistration() {
        beginAt("/index.jsp");
        String regLinkText = getMessage("index.registration");
        clickLinkWithText(regLinkText);
        long ts = System.currentTimeMillis();
        assertFormElementPresent("username");
        setFormElement("username","t"+ts);
        setFormElement("password","gotech");
        setFormElement("password2","gotech");
        String fullName = "George P. Burdell";
        setFormElement("fullName", fullName);
        setFormElement("fromAddress","[EMAIL PROTECTED]");
        setFormElement("replyToAddress","[EMAIL PROTECTED]");
        submit();
        
        assertTextPresent(getMessage("mainMenu.heading")+' '+fullName);

        gotoPage("Logoff.do");
        //String logoffMessage = getMessage("mainMenu.logoff");
        //clickLinkWithText(logoffMessage);
    }


}
</code>

- Bill Siggelkow


-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
Project Admins to receive an Apple iPod Mini FREE for your judgement on
who ports your project to Linux PPC the best. Sponsored by IBM.
Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php
_______________________________________________
Jwebunit-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jwebunit-users

Reply via email to