continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r471774 - in /maven/continuum/trunk/continuum-webapp-test: ./ src/test/it/org/apache/continuum/web/test/
Date Mon, 06 Nov 2006 16:05:00 GMT
Author: evenisse
Date: Mon Nov  6 08:04:59 2006
New Revision: 471774

URL: http://svn.apache.org/viewvc?view=rev&rev=471774
Log:
Use the new maven-web-ui-tests module from shared

Added:
    maven/continuum/trunk/continuum-webapp-test/src/test/it/org/apache/continuum/web/test/AbstractContinuumTestCase.java
      - copied, changed from r470978, maven/continuum/trunk/continuum-webapp-test/src/test/it/org/apache/continuum/web/test/AbstractSeleniumTestCase.java
Removed:
    maven/continuum/trunk/continuum-webapp-test/src/test/it/org/apache/continuum/web/test/AbstractSeleniumTestCase.java
Modified:
    maven/continuum/trunk/continuum-webapp-test/pom.xml
    maven/continuum/trunk/continuum-webapp-test/src/test/it/org/apache/continuum/web/test/AbstractAuthenticatedAccessTestCase.java
    maven/continuum/trunk/continuum-webapp-test/src/test/it/org/apache/continuum/web/test/AbstractGuestAccessTestCase.java
    maven/continuum/trunk/continuum-webapp-test/src/test/it/org/apache/continuum/web/test/AntTest.java
    maven/continuum/trunk/continuum-webapp-test/src/test/it/org/apache/continuum/web/test/LoginTest.java

Modified: maven/continuum/trunk/continuum-webapp-test/pom.xml
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp-test/pom.xml?view=diff&rev=471774&r1=471773&r2=471774
==============================================================================
--- maven/continuum/trunk/continuum-webapp-test/pom.xml (original)
+++ maven/continuum/trunk/continuum-webapp-test/pom.xml Mon Nov  6 08:04:59 2006
@@ -31,38 +31,12 @@
       <type>war</type>
     </dependency>
     <dependency>
-      <groupId>org.openqa.selenium.client-drivers</groupId>
-      <artifactId>selenium-java-client-driver</artifactId>
-      <version>0.8.1</version>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.openqa.selenium.client-drivers</groupId>
-      <artifactId>selenium-java-client-driver</artifactId>
-      <version>0.8.1</version>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.openqa.selenium.server</groupId>
-      <artifactId>selenium-server</artifactId>
-      <version>0.8.1</version>
+      <groupId>org.apache.maven.shared</groupId>
+      <artifactId>maven-web-ui-tests</artifactId>
+      <version>1.0-SNAPSHOT</version>
       <scope>test</scope>
     </dependency>
   </dependencies>
-  <repositories>
-    <repository>
-      <id>openqa</id>
-      <name>OpenQA Repository</name>
-      <url>http://maven.openqa.org</url>
-      <layout>default</layout>
-      <snapshots>
-        <enabled>true</enabled>
-      </snapshots>
-      <releases>
-        <enabled>true</enabled>
-      </releases>
-    </repository>
-  </repositories>
 
   <build>
     <testSourceDirectory>src/test/it</testSourceDirectory>

Modified: maven/continuum/trunk/continuum-webapp-test/src/test/it/org/apache/continuum/web/test/AbstractAuthenticatedAccessTestCase.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp-test/src/test/it/org/apache/continuum/web/test/AbstractAuthenticatedAccessTestCase.java?view=diff&rev=471774&r1=471773&r2=471774
==============================================================================
--- maven/continuum/trunk/continuum-webapp-test/src/test/it/org/apache/continuum/web/test/AbstractAuthenticatedAccessTestCase.java
(original)
+++ maven/continuum/trunk/continuum-webapp-test/src/test/it/org/apache/continuum/web/test/AbstractAuthenticatedAccessTestCase.java
Mon Nov  6 08:04:59 2006
@@ -24,11 +24,10 @@
     extends AbstractGuestAccessTestCase
 {
     public void setUp()
+        throws Exception
     {
         super.setUp();
-        clickLinkWithText( "Login" );
-        assertLoginPage();
-        submitLoginPage( getUsername(), getPassword() );
+        login( getUsername(), getPassword() );
     }
 
     public abstract String getUsername();

Copied: maven/continuum/trunk/continuum-webapp-test/src/test/it/org/apache/continuum/web/test/AbstractContinuumTestCase.java
(from r470978, maven/continuum/trunk/continuum-webapp-test/src/test/it/org/apache/continuum/web/test/AbstractSeleniumTestCase.java)
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp-test/src/test/it/org/apache/continuum/web/test/AbstractContinuumTestCase.java?view=diff&rev=471774&p1=maven/continuum/trunk/continuum-webapp-test/src/test/it/org/apache/continuum/web/test/AbstractSeleniumTestCase.java&r1=470978&p2=maven/continuum/trunk/continuum-webapp-test/src/test/it/org/apache/continuum/web/test/AbstractContinuumTestCase.java&r2=471774
==============================================================================
--- maven/continuum/trunk/continuum-webapp-test/src/test/it/org/apache/continuum/web/test/AbstractSeleniumTestCase.java
(original)
+++ maven/continuum/trunk/continuum-webapp-test/src/test/it/org/apache/continuum/web/test/AbstractContinuumTestCase.java
Mon Nov  6 08:04:59 2006
@@ -16,23 +16,15 @@
  * limitations under the License.
  */
 
-import com.thoughtworks.selenium.DefaultSelenium;
-import com.thoughtworks.selenium.Selenium;
-import junit.framework.TestCase;
-import org.codehaus.plexus.util.StringUtils;
-import org.openqa.selenium.server.SeleniumServer;
-
-import java.util.Calendar;
+import org.apache.maven.shared.web.test.AbstractSeleniumTestCase;
 
 /**
  * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
  * @version $Id$
  */
-public abstract class AbstractSeleniumTestCase
-    extends TestCase
+public abstract class AbstractContinuumTestCase
+    extends AbstractSeleniumTestCase
 {
-    private Selenium sel;
-
     protected String adminUsername = "admin";
 
     protected String adminPassword = "admin1";
@@ -43,38 +35,15 @@
 
     private String baseUrl = "http://localhost:9595/continuum";
 
-    public void setUp()
-    {
-        String browser = System.getProperty( "browser" );
-        if ( StringUtils.isEmpty( browser ) )
-        {
-            browser = "*firefox";
-        }
-
-        sel = new DefaultSelenium( "localhost", SeleniumServer.DEFAULT_PORT, browser, baseUrl
);
-        sel.start();
-        initialize();
-    }
-
-    public void tearDown()
-    {
-        sel.stop();
-    }
-
-    public Selenium getSelenium()
-    {
-        return sel;
-    }
-
     /**
      * We create an admin user if it doesn't exist
      */
-    private void initialize()
+    protected void initialize()
     {
-        sel.open( "/continuum" );
+        open( "/continuum" );
         waitPage();
 
-        if ( "Create Admin User".equals( sel.getTitle() ) )
+        if ( "Create Admin User".equals( getTitle() ) )
         {
             assertCreateAdminUserPage();
             submitCreateAdminUserPage( adminFullName, adminEmail, adminPassword, adminPassword
);
@@ -86,92 +55,24 @@
         }
     }
 
-    public String getHtmlContent()
-    {
-        return getSelenium().getHtmlSource();
-    }
-
-    public void assertTextPresent( String text )
-    {
-        assertTrue( "'" + text + "' isn't present.", sel.isTextPresent( text ) );
-    }
-
-    public void assertTextNotPresent( String text )
-    {
-        assertFalse( "'" + text + "' is present.", sel.isTextPresent( text ) );
-    }
-
-    public void assertElementPresent( String elementLocator )
-    {
-        assertTrue( "'" + elementLocator + "' isn't present.", sel.isElementPresent( elementLocator
) );
-    }
-
-    public void assertElementNotPresent( String elementLocator )
-    {
-        assertFalse( "'" + elementLocator + "' is present.", sel.isElementPresent( elementLocator
) );
-    }
-
-    public void assertLinkPresent( String text )
-    {
-        assertTrue( "The link '" + text + "' isn't present.", sel.isElementPresent( "link="
+ text ) );
-    }
-
-    public void assertLinkNotPresent( String text )
-    {
-        assertFalse( "The link '" + text + "' is present.", sel.isElementPresent( "link="
+ text ) );
-    }
-
-    public void waitPage()
-    {
-        waitPage( 30000 );
-    }
-
-    public void waitPage( int nbMillisecond )
-    {
-        sel.waitForPageToLoad( String.valueOf( nbMillisecond ) );
-    }
-
-    public void assertPage( String title )
-    {
-        assertEquals( title, sel.getTitle() );
-        assertTrue( sel.getText( "xpath=//div[@id='footer']/table/tbody/tr/td" ).startsWith(
"Continuum " ) );
-        int currentYear = Calendar.getInstance().get( Calendar.YEAR );
-        assertTrue( sel.getText( "xpath=//div[@id='footer']/table/tbody/tr/td" ).endsWith(
-            " 2005-" + currentYear + " Apache Software Foundation" ) );
-    }
-
-    public void clickLinkWithText( String text )
-    {
-        clickLinkWithText( text, true );
-    }
-
-    public void clickLinkWithText( String text, boolean wait )
+    protected String getApplicationName()
     {
-        clickLinkWithLocator( "link=" + text, wait );
+        return "Continuum";
     }
 
-    public void clickLinkWithXPath( String xpath )
+    protected String getInceptionYear()
     {
-        clickLinkWithXPath( xpath, true );
+        return "2005";
     }
 
-    public void clickLinkWithXPath( String xpath, boolean wait )
+    public void assertHeader()
     {
-        clickLinkWithLocator( "xpath=" + xpath, wait );
+        //TODO
     }
 
-    public void clickLinkWithLocator( String locator )
+    public String getBaseUrl()
     {
-        clickLinkWithLocator( locator, true );
-    }
-
-    public void clickLinkWithLocator( String locator, boolean wait )
-    {
-        sel.click( locator );
-        if ( wait )
-        {
-            waitPage();
-        }
+        return "http://localhost:9595/continuum";
     }
 
     //////////////////////////////////////
@@ -195,72 +96,12 @@
 
     public void submitCreateAdminUserPage( String fullName, String email, String password,
String confirmPassword )
     {
-        sel.type( "user.fullName", fullName );
-        sel.type( "user.email", email );
-        sel.type( "user.password", password );
-        sel.type( "user.confirmPassword", confirmPassword );
-        sel.click( "//input[@type='submit']" );
-        waitPage();
-    }
-
-    //////////////////////////////////////
-    // Login
-    //////////////////////////////////////
-    public void assertLoginPage()
-    {
-        assertPage( "Login Page" );
-        assertTextPresent( "Login" );
-        assertTextPresent( "Username" );
-        assertTextPresent( "Password" );
-        assertTextPresent( "Remember Me" );
-        assertFalse( sel.isChecked( "rememberMe" ) );
-    }
-
-    public void submitLoginPage( String username, String password )
-    {
-        submitLoginPage( username, password, false, true );
-    }
-
-    public void submitLoginPage( String username, String password, boolean validUsernamePassword
)
-    {
-        submitLoginPage( username, password, false, validUsernamePassword );
-    }
-
-    public void submitLoginPage( String username, String password, boolean rememberMe, boolean
validUsernamePassword )
-    {
-        sel.type( "username", username );
-        sel.type( "password", password );
-        if ( rememberMe )
-        {
-            sel.check( "rememberMe" );
-        }
-        sel.click( "submitButton" );
+        setFieldValue( "user.fullName", fullName );
+        setFieldValue( "user.email", email );
+        setFieldValue( "user.password", password );
+        setFieldValue( "user.confirmPassword", confirmPassword );
+        submit();
         waitPage();
-        if ( validUsernamePassword )
-        {
-            assertTextPresent( "Welcome, " + username + " - Logout" );
-            assertLinkPresent( username );
-            assertLinkPresent( "Logout" );
-        }
-        else
-        {
-            assertLoginPage();
-        }
-    }
-
-    public boolean isAuthenticated()
-    {
-        return !( sel.isElementPresent( "link=Login" ) && sel.isElementPresent( "link=Register"
) );
-    }
-
-    //////////////////////////////////////
-    // Logout
-    //////////////////////////////////////
-    public void logout()
-    {
-        assertTrue( "User wasn't authenticated.", isAuthenticated() );
-        clickLinkWithText( "Logout" );
-        assertFalse( "The user is always authenticated after a logout.", isAuthenticated()
);
     }
 
     //////////////////////////////////////
@@ -289,20 +130,20 @@
 
     public void submitConfigurationPage( String baseUrl, String companyName, String companyLogo,
String companyUrl )
     {
-        sel.type( "baseUrl", baseUrl );
+        setFieldValue( "baseUrl", baseUrl );
         if ( companyName != null )
         {
-            sel.type( "companyName", companyName );
+            setFieldValue( "companyName", companyName );
         }
         if ( companyLogo != null )
         {
-            sel.type( "companyLogo", companyLogo );
+            setFieldValue( "companyLogo", companyLogo );
         }
         if ( companyUrl != null )
         {
-            sel.type( "companyUrl", companyUrl );
+            setFieldValue( "companyUrl", companyUrl );
         }
-        sel.click( "//input[@type='submit']" );
+        submit();
         waitPage();
     }
 
@@ -346,7 +187,7 @@
     {
         assertPage( "Continuum - Group Summary" );
         assertTextPresent( "Project Groups" );
-        if ( sel.isTextPresent( "No Project Groups Known." ) )
+        if ( isTextPresent( "No Project Groups Known." ) )
         {
             assertTextNotPresent( "Name" );
             assertTextNotPresent( "Group Id" );

Modified: maven/continuum/trunk/continuum-webapp-test/src/test/it/org/apache/continuum/web/test/AbstractGuestAccessTestCase.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp-test/src/test/it/org/apache/continuum/web/test/AbstractGuestAccessTestCase.java?view=diff&rev=471774&r1=471773&r2=471774
==============================================================================
--- maven/continuum/trunk/continuum-webapp-test/src/test/it/org/apache/continuum/web/test/AbstractGuestAccessTestCase.java
(original)
+++ maven/continuum/trunk/continuum-webapp-test/src/test/it/org/apache/continuum/web/test/AbstractGuestAccessTestCase.java
Mon Nov  6 08:04:59 2006
@@ -21,9 +21,10 @@
  * @version $Id$
  */
 public abstract class AbstractGuestAccessTestCase
-    extends AbstractSeleniumTestCase
+    extends AbstractContinuumTestCase
 {
     public void setUp()
+        throws Exception
     {
         super.setUp();
         assertFalse( "User was authenticated.", isAuthenticated() );

Modified: maven/continuum/trunk/continuum-webapp-test/src/test/it/org/apache/continuum/web/test/AntTest.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp-test/src/test/it/org/apache/continuum/web/test/AntTest.java?view=diff&rev=471774&r1=471773&r2=471774
==============================================================================
--- maven/continuum/trunk/continuum-webapp-test/src/test/it/org/apache/continuum/web/test/AntTest.java
(original)
+++ maven/continuum/trunk/continuum-webapp-test/src/test/it/org/apache/continuum/web/test/AntTest.java
Mon Nov  6 08:04:59 2006
@@ -36,11 +36,11 @@
     public void testAddAntProject()
     {
         goToAddAntPage();
-        getSelenium().type( "projectName", "Foo" );
-        getSelenium().type( "projectVersion", "1.0-SNAPSHOT" );
-        getSelenium().type( "projectScmUrl",
+        setFieldValue( "projectName", "Foo" );
+        setFieldValue( "projectVersion", "1.0-SNAPSHOT" );
+        setFieldValue( "projectScmUrl",
                             "https://svn.apache.org/repos/asf/maven/continuum/trunk/continuum-test-projects/ant/"
);
-        clickLinkWithXPath( "//input[@type='submit']" );
+        clickButtonWithValue( "Add" );
         assertGroupSummaryPage();
         assertTextPresent( "Default Project Group" );
         clickLinkWithText( "Default Project Group");
@@ -52,7 +52,7 @@
     public void testSubmitEmptyForm()
     {
         goToAddAntPage();
-        clickLinkWithXPath( "//input[@type='submit']", false );
+        clickButtonWithValue( "Add", false );
         assertAddAntProjectPage();
         assertTextPresent( "Name is required" );
         assertTextPresent( "Version is required" );
@@ -62,7 +62,7 @@
     public void testSubmitEmptyProjectName()
     {
         goToAddAntPage();
-        clickLinkWithXPath( "//input[@type='submit']", false );
+        clickButtonWithValue( "Add", false );
         assertAddAntProjectPage();
         assertTextPresent( "Name is required" );
     }
@@ -70,7 +70,7 @@
     public void testSubmitEmptyVersion()
     {
         goToAddAntPage();
-        clickLinkWithXPath( "//input[@type='submit']", false );
+        clickButtonWithValue( "Add", false );
         assertAddAntProjectPage();
         assertTextPresent( "Version is required" );
     }
@@ -78,7 +78,7 @@
     public void testSubmitEmptyScmUrl()
     {
         goToAddAntPage();
-        clickLinkWithXPath( "//input[@type='submit']", false );
+        clickButtonWithValue( "Add", false );
         assertAddAntProjectPage();
         assertTextPresent( "SCM Url is required" );
     }

Modified: maven/continuum/trunk/continuum-webapp-test/src/test/it/org/apache/continuum/web/test/LoginTest.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp-test/src/test/it/org/apache/continuum/web/test/LoginTest.java?view=diff&rev=471774&r1=471773&r2=471774
==============================================================================
--- maven/continuum/trunk/continuum-webapp-test/src/test/it/org/apache/continuum/web/test/LoginTest.java
(original)
+++ maven/continuum/trunk/continuum-webapp-test/src/test/it/org/apache/continuum/web/test/LoginTest.java
Mon Nov  6 08:04:59 2006
@@ -24,6 +24,7 @@
     extends AbstractGuestAccessTestCase
 {
     public void setUp()
+        throws Exception
     {
         super.setUp();
         clickLinkWithText( "Login" );



Mime
View raw message