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

Commit

Permalink
Merge remote branch 'origin/master' into prevent-reindexer-session-leak
Browse files Browse the repository at this point in the history
Conflicts:
	zanata-war/src/main/java/org/zanata/service/SearchIndexManager.java
  • Loading branch information
seanf committed May 22, 2014
2 parents 16c1fd7 + 9c41355 commit d153fee
Show file tree
Hide file tree
Showing 452 changed files with 17,077 additions and 11,595 deletions.
502 changes: 502 additions & 0 deletions LICENSE.LESSER.txt

Large diffs are not rendered by default.

681 changes: 259 additions & 422 deletions LICENSE.txt

Large diffs are not rendered by default.

33 changes: 14 additions & 19 deletions functional-test/pom.xml
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.zanata</groupId>
<artifactId>server</artifactId>
<version>3.4.0-SNAPSHOT</version>
<version>3.5.0-SNAPSHOT</version>
</parent>
<artifactId>functional-test</artifactId>
<!--if we want to use pom packaging, we need to explicitly enable some plugins and various things-->
Expand Down Expand Up @@ -53,7 +53,7 @@
<webdriver.display>:0</webdriver.display>
<webdriver.log>${project.build.directory}/webdriver.log</webdriver.log>
<webdriver.screenshot.dir>${project.build.directory}/screenshots</webdriver.screenshot.dir>

<googleopenid.credentials>zanata.user.1:</googleopenid.credentials>
<!-- on jenkins, this needs to be set to empty - so that cargo can shutdown. see http://stackoverflow.com/questions/1096642/tomcat-failed-to-shutdown -->
<cargo.debug.jvm.args>
-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8787
Expand All @@ -62,10 +62,17 @@
<!-- this property can be used to control what test needs to be run by failsafe -->
<include.test.patterns>**/AggregateTestSuite.java</include.test.patterns>
<hibernate.search.default.indexBase>${project.build.directory}/zanataindex</hibernate.search.default.indexBase>
<javamelody.storage-directory>${project.build.directory}/zanatastats</javamelody.storage-directory>
<smtp.port>2552</smtp.port>
</properties>

<dependencies>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-api</artifactId>
Expand Down Expand Up @@ -111,15 +118,6 @@
<artifactId>guava</artifactId>
</dependency>

<dependency>
<groupId>org.concordion</groupId>
<artifactId>concordion</artifactId>
</dependency>
<dependency>
<groupId>org.concordion</groupId>
<artifactId>concordion-extensions</artifactId>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand Down Expand Up @@ -362,6 +360,10 @@
<scope>system</scope>
<systemPath>${zanata.war.location}</systemPath>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
</dependency>

</dependencies>

Expand Down Expand Up @@ -518,6 +520,7 @@
<ehcache.disk.store.dir>${project.build.directory}/ehcache</ehcache.disk.store.dir>
<jboss.server.log.threshold>WARN</jboss.server.log.threshold>
<hibernate.search.default.indexBase>${hibernate.search.default.indexBase}</hibernate.search.default.indexBase>
<javamelody.storage-directory>${javamelody.storage-directory}</javamelody.storage-directory>
<jboss.socket.binding.port-offset>${cargo.port.offset}</jboss.socket.binding.port-offset>
</systemProperties>

Expand Down Expand Up @@ -617,7 +620,6 @@
<printSummary>true</printSummary>
<runOrder>alphabetical</runOrder>
<!--<forkMode>always</forkMode>-->
<argLine>-Dconcordion.output.dir=${concordion.output.dir}</argLine>
<includes>
<include>${include.test.patterns}</include>
<!--index page-->
Expand Down Expand Up @@ -679,13 +681,6 @@
<exclude>**/pom.xml</exclude>
</excludes>
</testResource>
<testResource>
<directory>src/test/resources/concordion</directory>
<filtering>false</filtering>
<includes>
<include>**/*.*</include>
</includes>
</testResource>
</testResources>
<plugins>
<plugin>
Expand Down
55 changes: 42 additions & 13 deletions functional-test/src/main/java/org/zanata/page/AbstractPage.java
Expand Up @@ -28,12 +28,7 @@

import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.Cookie;
import org.openqa.selenium.NoAlertPresentException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.*;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.pagefactory.AjaxElementLocatorFactory;
import org.openqa.selenium.support.ui.FluentWait;
Expand All @@ -52,6 +47,14 @@ public class AbstractPage {
private final WebDriver driver;
private final FluentWait<WebDriver> ajaxWaitForTenSec;

public AbstractPage(final WebDriver driver) {
PageFactory.initElements(new AjaxElementLocatorFactory(driver, 10),
this);
this.driver = driver;
ajaxWaitForTenSec = WebElementUtil.waitForTenSeconds(driver);
waitForPageSilence();
}

public void reload() {
getDriver().navigate().refresh();
}
Expand All @@ -65,13 +68,6 @@ public void deleteCookiesAndRefresh() {
getDriver().navigate().refresh();
}

public AbstractPage(final WebDriver driver) {
PageFactory.initElements(new AjaxElementLocatorFactory(driver, 10),
this);
this.driver = driver;
ajaxWaitForTenSec = WebElementUtil.waitForTenSeconds(driver);
}

public WebDriver getDriver() {
return driver;
}
Expand Down Expand Up @@ -155,4 +151,37 @@ public boolean apply(WebDriver input) {
}
});
}

/**
* Wait for jQuery and Ajax calls to be 0
* If either are not defined, they can be assumed to be 0.
*/
public void waitForPageSilence() {
// Wait for jQuery calls to be 0
waitForTenSec().until(new Predicate<WebDriver>() {
@Override
public boolean apply(WebDriver input) {
int ajaxCalls;
int jQueryCalls;
try {
jQueryCalls = Integer.parseInt(
((JavascriptExecutor) getDriver())
.executeScript("return jQuery.active")
.toString());
} catch (WebDriverException jCall) {
jQueryCalls = 0;
}

try {
ajaxCalls = Integer.parseInt(
((JavascriptExecutor) getDriver())
.executeScript("return Ajax.activeRequestCount")
.toString());
} catch (WebDriverException jCall) {
ajaxCalls = 0;
}
return ajaxCalls + jQueryCalls == 0;
}
});
}
}
48 changes: 39 additions & 9 deletions functional-test/src/main/java/org/zanata/page/BasePage.java
Expand Up @@ -26,13 +26,14 @@
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import org.zanata.page.account.MyAccountPage;
import org.zanata.page.account.RegisterPage;
import org.zanata.page.account.SignInPage;
import org.zanata.page.administration.AdministrationPage;
import org.zanata.page.dashboard.DashboardBasePage;
import org.zanata.page.glossary.GlossaryPage;
import org.zanata.page.groups.VersionGroupsPage;
import org.zanata.page.projects.ProjectVersionsPage;
Expand Down Expand Up @@ -73,19 +74,17 @@ public class BasePage extends CorePage {

private static final By BY_SIGN_IN = By.id("signin_link");
private static final By BY_SIGN_OUT = By.id("right_menu_sign_out_link");
private static final By BY_PROFILE_LINK = By.id("profile");
private static final By BY_DASHBOARD_LINK = By.id("dashboard");
private static final By BY_ADMINISTRATION_LINK = By.id("administration");

public BasePage(final WebDriver driver) {
super(driver);
}

public MyAccountPage goToMyProfile() {
public DashboardBasePage goToMyDashboard() {
userAvatar.click();

clickLinkAfterAnimation(BY_PROFILE_LINK);

return new MyAccountPage(getDriver());
clickLinkAfterAnimation(BY_DASHBOARD_LINK);
return new DashboardBasePage(getDriver());
}

public ProjectsPage goToProjects() {
Expand All @@ -94,6 +93,7 @@ public ProjectsPage goToProjects() {
}

private void clickNavMenuItem(final WebElement menuItem) {
scrollIntoView(menuItem);
if (!menuItem.isDisplayed()) {
// screen is too small the menu become dropdown
getDriver().findElement(By.id("nav-main"))
Expand All @@ -115,7 +115,7 @@ public VersionGroupsPage goToGroups() {

public GlossaryPage goToGlossary() {
// Dynamically find the link, as it is not present for every user
getDriver().findElement(By.id("glossary_link")).click();
clickNavMenuItem(getDriver().findElement(By.id("glossary_link")));
return new GlossaryPage(getDriver());
}

Expand Down Expand Up @@ -154,6 +154,7 @@ public String loggedInAs() {
}

public HomePage logout() {
scrollIntoView(userAvatar);
userAvatar.click();

clickLinkAfterAnimation(BY_SIGN_OUT);
Expand Down Expand Up @@ -236,13 +237,14 @@ public ProjectsPage submitSearch() {
return new ProjectsPage(getDriver());
}

public void waitForSearchListContains(final String expected) {
public BasePage waitForSearchListContains(final String expected) {
waitForTenSec().until(new Predicate<WebDriver>() {
@Override
public boolean apply(WebDriver input) {
return getProjectSearchAutocompleteItems().contains(expected);
}
});
return new BasePage(getDriver());
}

public List<String> getProjectSearchAutocompleteItems() {
Expand Down Expand Up @@ -272,9 +274,37 @@ public WebElement apply(WebDriver driver) {
return new ProjectVersionsPage(getDriver());
}

public void clickWhenTabEnabled(final WebElement tab) {
waitForTenSec().until(new Predicate<WebDriver>() {
@Override
public boolean apply(WebDriver input) {
waitForPageSilence();
boolean clicked = false;
try {
if (tab.isDisplayed() && tab.isEnabled()) {
tab.click();
clicked = true;
}
} catch(WebDriverException wde) {
return clicked;
}
return clicked;
}
});
}

public String getHtmlSource(WebElement webElement) {
return (String) ((JavascriptExecutor) getDriver()).executeScript(
"return arguments[0].innerHTML;", webElement);
}

public void scrollIntoView(WebElement targetElement) {
((JavascriptExecutor) getDriver()).executeScript(
"arguments[0].scrollIntoView(true);", targetElement);
}

public void clickElement(By findby) {
scrollIntoView(getDriver().findElement(findby));
getDriver().findElement(findby).click();
}
}
16 changes: 16 additions & 0 deletions functional-test/src/main/java/org/zanata/page/CorePage.java
Expand Up @@ -122,6 +122,22 @@ public String getNotificationMessage() {
return messages.size() > 0 ? messages.get(0).getText() : "";
}

public boolean expectNotification(final String notification) {
return waitForTenSec().until(new Function<WebDriver, Boolean>() {
@Override
public Boolean apply(WebDriver driver) {
List<WebElement> messages = getDriver()
.findElement(By.id("messages"))
.findElements(By.tagName("li"));
List<String> notifications = new ArrayList<String>();
for( WebElement message : messages ) {
notifications.add(message.getText().trim());
}
return notifications.contains(notification);
}
});
}

public List<String> waitForErrors() {
waitForTenSec().until(new Function<WebDriver, WebElement>() {
@Override
Expand Down

This file was deleted.

0 comments on commit d153fee

Please sign in to comment.