Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
client push
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Huang committed Apr 24, 2012
1 parent 4ea6354 commit 799bb1f
Show file tree
Hide file tree
Showing 19 changed files with 188 additions and 78 deletions.
29 changes: 26 additions & 3 deletions server/functional-test/pom.xml
Expand Up @@ -19,6 +19,7 @@
<webdriver.version>0.9.7376</webdriver.version>
<selenium.version>2.20.0</selenium.version>
<hamcrest.version>1.2.1</hamcrest.version>
<commons-io.version>1.3.2</commons-io.version>

<!--Cargo Settings -->
<cargo.wait>false</cargo.wait>
Expand Down Expand Up @@ -46,6 +47,7 @@
<zanata.target.version>${parent.version}</zanata.target.version>
<zanata.instance.url>http://${cargo.host}:8080/${context.path}</zanata.instance.url>
<zanata.client.version>${project.version}</zanata.client.version>
<zanata.sample.projects.basedir>${project.build.testOutputDirectory}/sample-projects</zanata.sample.projects.basedir>
<functional-tests.skip>false</functional-tests.skip>
</properties>

Expand Down Expand Up @@ -84,6 +86,11 @@
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-io</artifactId>
<version>${commons-io.version}</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
Expand Down Expand Up @@ -145,13 +152,29 @@
<directory>src/test/resources</directory>
<filtering>true</filtering>
<includes>
<include>**/zanata.xml</include>
<include>**/pom.xml</include>
<include>**/*.properties</include>
<include>**/log4j.xml</include>
<include>**/zanata-ds.xml</include>
</includes>
</testResource>
<testResource>
<directory>sample-projects</directory>
<targetPath>${zanata.sample.projects.basedir}</targetPath>
<filtering>true</filtering>
<includes>
<include>**/zanata.xml</include>
<include>**/pom.xml</include>
</includes>
</testResource>
<testResource>
<directory>sample-projects</directory>
<targetPath>${zanata.sample.projects.basedir}</targetPath>
<filtering>false</filtering>
<excludes>
<exclude>**/zanata.xml</exclude>
<exclude>**/pom.xml</exclude>
</excludes>
</testResource>
</testResources>
<plugins>
<!--we want to run tests in integration phase-->
Expand Down Expand Up @@ -225,7 +248,7 @@
<deployables>
<deployable>
<type>file</type>
<location>${project.build.directory}/test-classes/datasource</location>
<location>${project.build.testOutputDirectory}/datasource</location>
</deployable>
<deployable>
<!--<groupId>${project.groupId}</groupId>-->
Expand Down
Expand Up @@ -15,6 +15,8 @@
*/
package org.zanata.page;

import static java.util.concurrent.TimeUnit.SECONDS;

import java.util.Collection;
import java.util.List;

Expand All @@ -28,13 +30,12 @@
import org.openqa.selenium.support.ui.FluentWait;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.common.base.Function;
import com.google.common.base.Preconditions;
import com.google.common.collect.Collections2;
import com.google.common.collect.ImmutableList;

import static java.util.concurrent.TimeUnit.SECONDS;

public class AbstractPage
{
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractPage.class);
Expand All @@ -56,10 +57,7 @@ public AbstractPage(final WebDriver driver)

public static FluentWait<WebDriver> createWaitForAjax(WebDriver webDriver, int durationInSec)
{
return new FluentWait<WebDriver>(webDriver)
.withTimeout(durationInSec, SECONDS)
.pollingEvery(1, SECONDS)
.ignoring(NoSuchElementException.class);
return new FluentWait<WebDriver>(webDriver).withTimeout(durationInSec, SECONDS).pollingEvery(1, SECONDS).ignoring(NoSuchElementException.class);
}

public WebDriver getDriver()
Expand Down Expand Up @@ -97,7 +95,7 @@ public <P> P goToPage(String navLinkText, Class<P> pageClass)
return PageFactory.initElements(driver, pageClass);
}

//TODO this doesn't seem useful
// TODO this doesn't seem useful
public <P> P goToUrl(String url, P page)
{
LOGGER.info("go to url: {}", url);
Expand Down
Expand Up @@ -18,7 +18,6 @@
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.ui.Select;

public class CreateProjectPage extends AbstractPage
Expand Down
Expand Up @@ -18,7 +18,6 @@
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.ui.Select;

public class CreateVersionPage extends AbstractPage
Expand Down
Expand Up @@ -15,18 +15,14 @@
*/
package org.zanata.page;

import java.util.Collection;
import java.util.List;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.base.Predicate;
import com.google.common.collect.Collections2;

public class HomePage extends AbstractPage
{
Expand All @@ -50,9 +46,9 @@ public SignInPage clickSignInLink()
WebElement firstLink = links.get(0);
if (firstLink.getText().equalsIgnoreCase("Sign In"))
{
firstLink.click();
firstLink.click();
}
//else already signed in, no op
// else already signed in, no op
return new SignInPage(getDriver());
}

Expand Down
Expand Up @@ -22,6 +22,7 @@
import org.openqa.selenium.WebElement;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.common.base.Function;

public class ManageLanguagePage extends AbstractPage
Expand Down
Expand Up @@ -16,19 +16,15 @@
package org.zanata.page;

import java.util.Collection;
import java.util.Collections;
import java.util.List;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.pagefactory.ByChained;
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.common.base.Preconditions;
import com.google.common.base.Predicate;
import com.google.common.collect.Collections2;
Expand Down Expand Up @@ -81,7 +77,7 @@ public ProjectVersionPage goToActiveVersion(final String versionId)
@Override
public boolean apply(WebElement input)
{
//the link text has line break in it
// the link text has line break in it
String linkText = input.getText().replaceAll("\\n", " ");
return linkText.matches(versionId + "\\s+Documents:.+");
}
Expand Down
Expand Up @@ -19,8 +19,6 @@
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import com.google.common.base.Preconditions;

public class ProjectsPage extends AbstractPage
{
Expand Down
Expand Up @@ -36,7 +36,8 @@ public SignInPage(final WebDriver driver)
super(driver);
}

public <P extends AbstractPage> P signInAndGoToPage(String username, String password, Class<P> pageClass) {
public <P extends AbstractPage> P signInAndGoToPage(String username, String password, Class<P> pageClass)
{
usernameField.sendKeys(username);
passwordField.sendKeys(password);
signInButton.click();
Expand Down
Expand Up @@ -15,6 +15,12 @@
*/
package org.zanata.page;

import static org.zanata.util.Constants.chrome;
import static org.zanata.util.Constants.firefox;
import static org.zanata.util.Constants.loadProperties;
import static org.zanata.util.Constants.webDriverType;
import static org.zanata.util.Constants.zanataInstance;

import java.util.Properties;

import org.openqa.selenium.WebDriver;
Expand All @@ -25,10 +31,8 @@
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.zanata.util.Constants;
import com.google.common.base.Strings;

import static org.zanata.util.Constants.*;
import com.google.common.base.Strings;

public enum WebDriverFactory
{
Expand Down Expand Up @@ -61,7 +65,7 @@ public String getHostUrl()
{
getDriver();
}
return properties.getProperty("zanata.instance.url");
return properties.getProperty(zanataInstance.value());
}

private WebDriver createDriver()
Expand All @@ -70,10 +74,12 @@ private WebDriver createDriver()
if (driverType.equalsIgnoreCase(chrome.value()))
{
return configureChromeDriver();
} else if (driverType.equalsIgnoreCase(firefox.value()))
}
else if (driverType.equalsIgnoreCase(firefox.value()))
{
return configureFirefoxDriver();
} else
}
else
{
return configureHtmlDriver();
}
Expand All @@ -92,22 +98,22 @@ private WebDriver configureChromeDriver()

private WebDriver configureFirefoxDriver()
{
// final String pathToFirefox = Strings.emptyToNull(props.getProperty("functionaltest.browser.path"));
// final String pathToFirefox =
// Strings.emptyToNull(props.getProperty("functionaltest.browser.path"));

FirefoxBinary firefoxBinary = null;
// if (pathToFirefox != null)
// {
// firefoxBinary = new FirefoxBinary(new File(pathToFirefox));
// } else
// {
// if (pathToFirefox != null)
// {
// firefoxBinary = new FirefoxBinary(new File(pathToFirefox));
// } else
// {
firefoxBinary = new FirefoxBinary();
// }
// }

// return new FirefoxDriver(firefoxBinary, makeFirefoxProfile());
// return new FirefoxDriver(firefoxBinary, makeFirefoxProfile());
return new FirefoxDriver();
}


private FirefoxProfile makeFirefoxProfile()
{
if (!Strings.isNullOrEmpty(System.getProperty("webdriver.firefox.profile")))
Expand All @@ -116,7 +122,8 @@ private FirefoxProfile makeFirefoxProfile()
// TODO - look at FirefoxDriver.getProfile().
}
final FirefoxProfile firefoxProfile = new FirefoxProfile();
// firefoxProfile.setPreference("browser.safebrowsing.malware.enabled", false); // disables connection to sb-ssl.google.com
// firefoxProfile.setPreference("browser.safebrowsing.malware.enabled",
// false); // disables connection to sb-ssl.google.com
firefoxProfile.setAlwaysLoadNoFocusLib(true);
firefoxProfile.setEnableNativeEvents(true);
return firefoxProfile;
Expand Down
Expand Up @@ -21,16 +21,18 @@

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.common.base.Objects;

public enum Constants
{
//constants used by page and workflow objects
// constants used by page and workflow objects
propFile("setup.properties"),
zanataInstance("zanata.instance.url"),
projectsLink("Projects"),
webDriverType("webdriver.type"),
chrome, firefox, htmlUnit
;
chrome, firefox, htmlUnit,
sampleProjects("zanata.sample.projects.basedir");

private static final Logger LOGGER = LoggerFactory.getLogger(Constants.class);
private String value;
Expand All @@ -49,10 +51,7 @@ private Constants()
@Override
public String toString()
{
return Objects.toStringHelper(this).
add("name", name()).
add("value", value).
toString();
return Objects.toStringHelper(this).add("name", name()).add("value", value).toString();
}

public static Properties loadProperties()
Expand All @@ -63,7 +62,8 @@ public static Properties loadProperties()
{
properties.load(inputStream);
return properties;
} catch (IOException e)
}
catch (IOException e)
{
LOGGER.error("can't load {}", propFile);
throw new IllegalStateException("can't load setup.properties");
Expand Down

0 comments on commit 799bb1f

Please sign in to comment.