001    /**
002     *  Licensed to the Apache Software Foundation (ASF) under one
003     *  or more contributor license agreements.  See the NOTICE file
004     *  distributed with this work for additional information
005     *  regarding copyright ownership.  The ASF licenses this file
006     *  to you under the Apache License, Version 2.0 (the
007     *  "License"); you may not use this file except in compliance
008     *  with the License.  You may obtain a copy of the License at
009     *
010     *    http://www.apache.org/licenses/LICENSE-2.0
011     *
012     *  Unless required by applicable law or agreed to in writing,
013     *  software distributed under the License is distributed on an
014     *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015     *  KIND, either express or implied.  See the License for the
016     *  specific language governing permissions and limitations
017     *  under the License.
018     */
019    
020    package org.apache.geronimo.testsupport;
021    
022    import org.apache.geronimo.testsupport.TestSupport;
023    
024    import com.thoughtworks.selenium.Selenium;
025    
026    import org.openqa.selenium.server.SeleniumServer;
027    
028    import org.testng.annotations.BeforeSuite;
029    import org.testng.annotations.AfterSuite;
030    
031    /**
032     * ???
033     *
034     * @version $Rev: 514087 $ $Date: 2007-03-03 01:13:40 -0500 (Sat, 03 Mar 2007) $
035     */
036    public class SeleniumTestSupport
037        extends TestSupport
038    {
039        protected static ExtendedSelenium selenium;
040        
041        protected ExtendedSelenium createSeleniumClient(String url) throws Exception {
042            super.setUp();
043            
044            if (url == null) {
045                url = "http://localhost:" + SeleniumServer.DEFAULT_PORT;
046            }
047            
048            log.info("Creating Selenium client for URL: " + url);
049            
050            ExtendedSelenium selenium = new ExtendedSelenium(
051                "localhost", SeleniumServer.DEFAULT_PORT, "*firefox", url);
052            
053            return selenium;
054        }
055        
056        @BeforeSuite
057        protected void startSeleniumClient() throws Exception {
058            log.info("Starting Selenium client");
059            
060            selenium = createSeleniumClient("http://localhost:8080/");
061            selenium.start();
062        }
063        
064        @AfterSuite
065        protected void stopSeleniumClient() throws Exception {
066            log.info("Stopping Selenium client");
067            
068            selenium.stop();
069        }
070    
071        /**
072         * junit's per class setup.
073         * 
074        protected void setUp() throws Exception {
075            log.info("Starting Selenium client");
076            
077            selenium = createSeleniumClient("http://localhost:8080/");
078            selenium.start();
079        }
080         */
081        
082        /**
083         * junit's per class teardown.
084         * 
085        protected void tearDown() throws Exception {
086            log.info("Stopping Selenium client");
087            
088            selenium.stop();
089        }
090         */
091    }
092