Package net.sourceforge.jwebunit.junit

Examples of net.sourceforge.jwebunit.junit.WebTester


    public void testCycleWithXrdsUser() throws Exception
    {
        HttpServletSupport.lastException = null;
        HttpServletSupport.count_ = 0;
        WebTester wc = new WebTester();
        try
        {
            wc.setScriptingEnabled(false);
            wc.beginAt(_baseUrl + "/login");
            wc.setTextField("openid_identifier", _baseUrl + "/user");
            wc.submit();
            wc.clickLink("login");
            wc.assertTextPresent("success");
            wc.assertTextPresent("emailFromFetch:user@example.com");
            wc.assertTextPresent("emailFromSReg:user@example.com");
        }
        catch (Exception exc)
        {
            System.err.println("last page before exception :" + wc.getPageSource());
            if (HttpServletSupport.lastException != null)
            {
                throw HttpServletSupport.lastException;
            }
            else
View Full Code Here


    public void testCycleWithHtmlUser() throws Exception
    {
        HttpServletSupport.lastException = null;
        HttpServletSupport.count_ = 0;
        WebTester wc = new WebTester();
        try
        {
            wc.setScriptingEnabled(false);
            wc.beginAt(_baseUrl + "/login");
            wc.setTextField("openid_identifier", _baseUrl + "/user?format=html");
            wc.submit();
            wc.clickLink("login");
            wc.assertTextPresent("success");
            wc.assertTextPresent("emailFromFetch:user@example.com");
            wc.assertTextPresent("emailFromSReg:user@example.com");
        }
        catch (Exception exc)
        {
            System.err.println("last page before exception :" + wc.getPageSource());
            if (HttpServletSupport.lastException != null)
            {
                throw HttpServletSupport.lastException;
            }
            else
View Full Code Here

     */
    @BeforeClass
    protected void init() throws Exception {

        // Build tester object
        this.webTester = new WebTester();

        // Get the http port property
        String httpPort = System.getProperty("http.port");

        if (httpPort == null) {
View Full Code Here

     * @throws Exception if the framework is not initalized.
     */
    @BeforeClass
    protected void init() throws Exception {
        // Build tester object
        this.webTester = new WebTester();

        // Get the http port property
        String httpPort = System.getProperty("http.port");

        if (httpPort == null) {
View Full Code Here

    private static WebTester tester;

    @BeforeClass
    public static void setUp() {
        tester = new WebTester();
        tester.setTestingEngineKey(TestingEngineRegistry.TESTING_ENGINE_HTMLUNIT);
    }
View Full Code Here

        server = new org.mortbay.jetty.Server(8080);
        server.addHandler(new WebAppContext("./src/main/webapp", "/ultimate-roundtrip"));
        server.start();

        // Set up tester
        tester = new WebTester();
        tester.setTestingEngineKey(TestingEngineRegistry.TESTING_ENGINE_HTMLUNIT);
        tester.getTestContext().setBaseUrl("http://localhost:8080/ultimate-roundtrip");
    }
View Full Code Here

    public void maxConcurrentLoginsValueIsRespected() throws Exception {
        beginAt("secure/index.html");
        login("jimi", "jimispassword");
        // Login again
        System.out.println("Client: ******* Second login ******* ");
        WebTester tester2 = new WebTester();
        tester2.getTestContext().setBaseUrl(getBaseUrl());
        tester2.beginAt("secure/index.html");
        tester2.setTextField("j_username", "jimi");
        tester2.setTextField("j_password", "jimispassword");
        tester2.setIgnoreFailingStatusCodes(true);
        tester2.submit();
        Assert.assertTrue(tester2.getServerResponse().contains("Maximum sessions of 1 for this principal exceeded"));
    }
View Full Code Here

        tester.gotoPage("/j_spring_security_logout");

        // Login again
        System.out.println("Client: ******* Second login ******* ");
        WebTester tester2 = new WebTester();
        tester2.getTestContext().setBaseUrl(getBaseUrl());
        tester2.beginAt("secure/index.html");
        tester2.setTextField("j_username", "bessie");
        tester2.setTextField("j_password", "bessiespassword");
        tester2.setIgnoreFailingStatusCodes(true);
        tester2.submit();
        Assert.assertTrue(tester2.getServerResponse().contains("A secure page"));
    }
View Full Code Here

        System.out.println("Client: ******* First login ******* ");
        beginAt("secure/index.html");
        login("jimi", "jimispassword");
        // Login again
        System.out.println("Client: ******* Second login ******* ");
        WebTester tester2 = new WebTester();
        tester2.getTestContext().setBaseUrl(getBaseUrl());
        tester2.beginAt("secure/index.html");
        // seems to be a bug in checking for form here (it fails)
        //tester2.assertFormPresent();
        tester2.setTextField("j_username", "jimi");
        tester2.setTextField("j_password", "jimispassword");
        // tester2.submit() also fails to detect the form
        tester2.getTestingEngine().submit();
        tester2.assertTextPresent("Maximum sessions of 1 for this principal exceeded");

        // Now logout to kill first session
        tester.gotoPage("/logout");


        // Try second session again
        tester2.setTextField("j_username", "jimi");
        tester2.setTextField("j_password", "jimispassword");
        // tester2.submit() also fails to detect the form
        tester2.getTestingEngine().submit();
        tester2.assertTextPresent("A Secure Page");
    }
View Full Code Here

  /**
   * @return
   */
  private static WebTester getCustomTester() {
    return new WebTester() {

      /* (non-Javadoc)
       * @see net.sourceforge.jwebunit.junit.WebTester#initializeDialog()
       */
      @Override
 
View Full Code Here

TOP

Related Classes of net.sourceforge.jwebunit.junit.WebTester

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.