Hi,

I have completed sending loging / logout observation events and trying to
write integration test for the task. I have written a test case similar to
the attached file. I want to clear few things about it. As well as I got few
issues while trying to run.

*Question 1* - I think this test should check my observation event sending -
Please comment on if there is any mistake on groovy script added to
createPage() content.

*Question 2 *- On running the selinium tests
Test is named LoginObservationTest

After writing the test case, For first time run, I went to
/enterprise/distribution-test/selenium-tests directory and run the following
command as in tutorial
mvn install -Dpattern=LoginObservationTest

It showed an error saying
java.lang.RuntimeException: Firefox couldn't be found in the path!
Please add the directory containing 'firefox-bin' to your PATH environment
variable, or explicitly specify a path to Firefox like this:
*firefox /blah/blah/firefox-bin

Then I have linked the firefox folder as it was suggested in this
http://willbryant.net/software/2008/05/26/selenium_rc_firefox_2_on_ubuntu_hardy
But in my case I have firefox-3.0.10 and inside that I had firefox binary
not a file named firefox-bin
Then I linked to path like this.
sudo ln /usr/lib/firefox-3.0.10/firefox /usr/lib/firefox/firefox-bin

Now I get an exception like this when I run the command to test my selenium
test :(

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running com.xpn.xwiki.it.selenium.AllTests
09:59:44,591 INFO  [org.mortbay.util.Credential] Checking Resource aliases
09:59:44,602 INFO
[org.openqa.selenium.server.SeleniumDriverResourceHandler] Command request:
getNewBrowserSession[*firefox, http://localhost:8080, ] on session null
09:59:44,603 INFO  [org.openqa.selenium.server.BrowserSessionFactory]
creating new remote session
09:59:44,936 INFO  [org.openqa.selenium.server.BrowserSessionFactory]
Allocated session 775dad4fbed24b0e98a86c0652ec136c for http://localhost:8080,
launching...
09:59:45,092 INFO
[org.openqa.selenium.server.browserlaunchers.FirefoxCustomProfileLauncher]
Preparing Firefox profile...
Could not read application.ini
10:00:05,235 WARN  [org.mortbay.http.HttpConnection] POST
/selenium-server/driver/ HTTP/1.1
java.lang.RuntimeException: Timed out waiting for profile to be created!

Kindly tell me some tips to solve this.

Thank you,
-Tharindu
/*
 * See the NOTICE file distributed with this work for additional
 * information regarding copyright ownership.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */
package com.xpn.xwiki.it.selenium;

import com.xpn.xwiki.it.selenium.framework.AbstractXWikiTestCase;
import com.xpn.xwiki.it.selenium.framework.AlbatrossSkinExecutor;
import com.xpn.xwiki.it.selenium.framework.XWikiTestSuite;

import junit.framework.Test;
import junit.framework.AssertionFailedError;

/**
 * Verify observation events of login logout.
 *
 * @version $Id: $
 */
public class LoginObservationTest extends AbstractXWikiTestCase
{
    public static Test suite()
    {
        XWikiTestSuite suite = new XWikiTestSuite("Verify login logout sends observation events");
        suite.addTestSuite(DeletePageTest.class, AlbatrossSkinExecutor.class);
        return suite;
    }

    protected void setUp() throws Exception
    {
        super.setUp();
        loginAsAdmin();
    }

    /**
     * Verify that user login sends login and logout observation events with a groovy
     * script attached to new page.
     */
    public void testLoginLogoutSendsObservationEvents()
    {
        createPage("Test", "LoginObservationTest", "<% import org.xwiki.observation.EventListener; import org.xwiki.observation.event.Event; import org.xwiki.observation.event.UserLoginEvent; import org.xwiki.observation.event.UserLogoutEvent; public class LoginObservationTest implements EventListener { public void onEvent(Event event, Object source, Object data) { if (event instanceof UserLoginEvent) { doc.setContent(doc.getContent() + 'user logged in.'); doc.save(); } else if (event instanceof UserLogoutEvent) { doc.setContent(doc.getContent() + 'user logged out.'); doc.save(); } } } %>");
        //createPage("Test", "LoginObservationTest", "<% import org.xwiki.observation.EventListener; import org.xwiki.observation.event.Event; doc.setContent(doc.getContent() + 'user logged in.'); doc.save(); public class LoginObservationTest implements EventListener { public void onEvent(Event event, Object source, Object data) { doc.setContent(doc.getContent() + 'user logged in.'); doc.save(); } } %>");
        
        logout();
        
        assertTextPresent("user logged out.");
        
        loginAsAdmin();
        
        assertTextPresent("user logged in.");
               
    }

}
_______________________________________________
devs mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/devs

Reply via email to