From 5440040c8fff9d94bd28d70e28746289b88a74d0 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Tue, 25 Dec 2012 23:12:59 +0000 Subject: [PATCH] test web tests via fluentlenium git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1425783 13f79535-47bb-0310-9956-ffa450edef68 --- .../archiva-webapp-test-js/pom.xml | 24 ++++-- .../archiva/web/test/WebDriverTest.java | 76 +++++++++++++++++++ 2 files changed, 95 insertions(+), 5 deletions(-) create mode 100644 archiva-modules/archiva-web/archiva-webapp-test-js/src/test/java/org/apache/archiva/web/test/WebDriverTest.java diff --git a/archiva-modules/archiva-web/archiva-webapp-test-js/pom.xml b/archiva-modules/archiva-web/archiva-webapp-test-js/pom.xml index e2a7fdd01..8907c32cb 100644 --- a/archiva-modules/archiva-web/archiva-webapp-test-js/pom.xml +++ b/archiva-modules/archiva-web/archiva-webapp-test-js/pom.xml @@ -60,6 +60,11 @@ + + org.seleniumhq.selenium + selenium-java + ${selenium-server.version} + org.seleniumhq.selenium.client-drivers selenium-java-client-driver @@ -72,6 +77,20 @@ + + org.fluentlenium + fluentlenium-festassert + 0.7.4 + test + + + + org.fluentlenium + fluentlenium-core + 0.7.4 + test + + jdom @@ -188,11 +207,6 @@ org.apache.maven.plugins maven-compiler-plugin - - 1.5 - 1.5 - true - diff --git a/archiva-modules/archiva-web/archiva-webapp-test-js/src/test/java/org/apache/archiva/web/test/WebDriverTest.java b/archiva-modules/archiva-web/archiva-webapp-test-js/src/test/java/org/apache/archiva/web/test/WebDriverTest.java new file mode 100644 index 000000000..6631c4354 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-webapp-test-js/src/test/java/org/apache/archiva/web/test/WebDriverTest.java @@ -0,0 +1,76 @@ +package org.apache.archiva.web.test; +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import junit.framework.Assert; +import junit.framework.TestCase; +import org.fluentlenium.adapter.FluentTest; +import org.fluentlenium.core.domain.FluentList; +import org.fluentlenium.core.domain.FluentWebElement; +import org.junit.Test; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.firefox.FirefoxDriver; + +import java.io.File; +import java.io.FileInputStream; +import java.util.Properties; + +/** + * @author Olivier Lamy + */ +public class WebDriverTest + extends FluentTest +{ + + @Test + public void simpletest() + throws Exception + { + + Properties tomcatPortProperties = new Properties(); + tomcatPortProperties.load( + new FileInputStream( new File( System.getProperty( "tomcat.propertiesPortFilePath" ) ) ) ); + + int tomcatPort = Integer.parseInt( tomcatPortProperties.getProperty( "tomcat.maven.http.port" ) ); + + goTo( "http://localhost:" + tomcatPort + "/archiva/index.html?request_lang=en" ); + + FluentList elements = find( "#create-admin-link-a" ); + + if ( !elements.isEmpty() && elements.get( 0 ).isDisplayed() ) + { + WebElement webElement = elements.get( 0 ).getElement(); + Assert.assertEquals( "Create Admin User", webElement.getText() ); + } + else + { + elements = find( "#login-link-a" ); + WebElement webElement = elements.get( 0 ).getElement(); + Assert.assertEquals( "LOGIN", webElement.getText() ); + } + + } + + @Override + public WebDriver getDefaultDriver() + { + return new FirefoxDriver(); + } +}