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

Commit

Permalink
Merge branch 'master' of github.com:zanata/zanata into integration/ma…
Browse files Browse the repository at this point in the history
…ster

Conflicts:
	pom.xml
	zanata-model/src/main/java/org/zanata/model/HTextFlowTarget.java
	zanata-model/src/main/java/org/zanata/model/SlugEntityBase.java
	zanata-war/src/main/java/org/zanata/dao/TextFlowDAO.java
	zanata-war/src/main/java/org/zanata/webtrans/client/editor/table/InlineTargetCellEditor.java
	zanata-war/src/main/java/org/zanata/webtrans/client/editor/table/TableEditorView.java
	zanata-war/src/main/resources/org/zanata/webtrans/public/Application.css
  • Loading branch information
seanf committed May 16, 2012
2 parents 1c584d0 + e9e513f commit 184df7d
Show file tree
Hide file tree
Showing 118 changed files with 3,864 additions and 1,670 deletions.
5 changes: 3 additions & 2 deletions copyright.txt
Expand Up @@ -11,11 +11,12 @@ Asgeir Frimannsson Project Founder and former Lead
James Ni <jni@redhat.com> Project Contributor
Sean Flanigan <sflaniga@redhat.com> Project Lead
Ding-Yi Chen <dchen@redhat.com> Project Contributor
Caius Carlos Chance <cchance@redhat.com> Project Contributor
Helen Ding <hding@redhat.com> Project Contributor
Caius Carlos Chance Project Contributor
Helen Ding Project Contributor
Alex Eng <aeng@redhat.com> Project Contributor
David Mason <damason@redhat.com> Project Contributor
Carlos Munoz <camunoz@redhat.com> Project Contributor
Patrick Huang <pahuang@redhat.com> Project Contributor



Expand Down
28 changes: 18 additions & 10 deletions functional-test/pom.xml
Expand Up @@ -245,22 +245,30 @@
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
<include>**/*Test*.java</include>
</includes>
</configuration>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.11</version>
<executions>
<execution>
<id>Web Driver Tests</id>
<id>integration-test</id>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
<execution>
<id>verify</id>
<goals>
<goal>test</goal>
<goal>verify</goal>
</goals>
<phase>integration-test</phase>
</execution>
</executions>
<configuration>
<redirectTestOutputToFile>false</redirectTestOutputToFile>
<printSummary>true</printSummary>
<forkMode>always</forkMode>
<includes>
<include>**/*Test.java</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
Expand Down
18 changes: 18 additions & 0 deletions functional-test/src/main/java/org/zanata/page/AbstractPage.java
Expand Up @@ -26,6 +26,7 @@
import java.util.Collections;
import java.util.List;

import org.apache.commons.lang.StringUtils;
import org.openqa.selenium.By;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebDriver;
Expand All @@ -36,6 +37,7 @@
import org.openqa.selenium.support.ui.FluentWait;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.zanata.util.WebElementUtil;

import com.google.common.base.Function;
import com.google.common.base.Preconditions;
Expand All @@ -44,6 +46,12 @@

public class AbstractPage
{
protected List<String> getErrors()
{
List<WebElement> errorSpans = getDriver().findElements(By.xpath("//span[@class='errors']"));
return WebElementUtil.elementsToText(errorSpans);
}

public enum PageContext
{
jsf, webTran
Expand Down Expand Up @@ -124,4 +132,14 @@ public FluentWait<WebDriver> waitForTenSec()
{
return ajaxWaitForTenSec;
}

protected void clickSaveAndCheckErrors(WebElement saveButton)
{
saveButton.click();
List<String> errors = getErrors();
if (!errors.isEmpty())
{
throw new RuntimeException(StringUtils.join(errors, ";"));
}
}
}
Expand Up @@ -70,7 +70,7 @@ public CreateProjectPage selectStatus(String status)

public ProjectPage saveProject()
{
saveButton.click();
clickSaveAndCheckErrors(saveButton);
return new ProjectPage(getDriver());
}
}
Expand Up @@ -55,7 +55,7 @@ public CreateVersionPage selectStatus(String status)

public ProjectVersionPage saveVersion()
{
saveButton.click();
clickSaveAndCheckErrors(saveButton);
return new ProjectVersionPage(getDriver());
}
}
18 changes: 18 additions & 0 deletions functional-test/src/main/java/org/zanata/page/ProjectsPage.java
Expand Up @@ -20,15 +20,22 @@
*/
package org.zanata.page;

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.zanata.util.WebElementUtil;
import com.google.common.base.Function;
import com.google.common.base.Predicate;

public class ProjectsPage extends AbstractPage
{
@FindBy(id = "main_content")
private WebElement mainContentDiv;

public ProjectsPage(final WebDriver driver)
{
super(driver);
Expand All @@ -55,4 +62,15 @@ public ProjectPage goToProject(String projectName)
link.click();
return new ProjectPage(getDriver());
}

public List<String> getProjectNamesOnCurrentPage()
{
if (mainContentDiv.getText().contains("No project exists"))
{
return Collections.emptyList();
}
WebElement table = getDriver().findElement(By.className("rich-table"));
List<WebElement> rows = table.findElements(By.xpath(".//tbody/tr/td[1]"));
return WebElementUtil.elementsToText(rows);
}
}
Expand Up @@ -23,6 +23,7 @@
import static org.hamcrest.MatcherAssert.assertThat;

import java.io.IOException;
import java.util.List;

import org.hamcrest.Matchers;
import org.slf4j.Logger;
Expand All @@ -38,7 +39,7 @@

public class CreateSampleProjectTest
{
private static final Logger LOGGER = LoggerFactory.getLogger(CreateSampleProjectTest.class);
private static final Logger log = LoggerFactory.getLogger(CreateSampleProjectTest.class);
@Test
public void canCreateProjectAndVersion()
{
Expand All @@ -48,6 +49,17 @@ public void canCreateProjectAndVersion()

new LoginWorkFlow().signIn("admin", "admin");
ProjectWorkFlow projectWorkFlow = new ProjectWorkFlow();
List<String> projects = projectWorkFlow.goToHome().goToProjects().getProjectNamesOnCurrentPage();
log.info("current projects: {}", projects);

if (projects.contains(projectName))
{
log.warn("{} has already been created, presumably you are running this test manually and more than once.", projectId);
//since we can't create same project multiple times,
//if we run this test more than once manually, we don't want it to fail
return;
}

ProjectPage projectPage = projectWorkFlow.createNewProject(projectId, projectName);

assertThat(projectPage.getProjectId(), Matchers.equalTo("Project ID: " + projectId));
Expand All @@ -61,6 +73,32 @@ public void canCreateProjectAndVersion()

}

@Test(expectedExceptions = RuntimeException.class, expectedExceptionsMessageRegExp = "This slug is not available")
public void cannotCreateProjectWithSameProjectId() {
new LoginWorkFlow().signIn("admin", "admin");
ProjectWorkFlow projectWorkFlow = new ProjectWorkFlow();
ProjectPage projectPage = projectWorkFlow.createNewProject("project-a", "project a");
assertThat(projectPage.getTitle(), Matchers.containsString("Zanata:project a"));

//second time
projectWorkFlow.createNewProject("project-a", "project with same slug/project id");
}

@Test
public void canCreateSameVersionIdOnDifferentProjects() {
new LoginWorkFlow().signIn("admin", "admin");
ProjectWorkFlow projectWorkFlow = new ProjectWorkFlow();
projectWorkFlow.createNewProject("project-b", "project b")
.clickCreateVersionLink().inputVersionId("master").saveVersion();

//second time
ProjectVersionPage projectVersionPage = projectWorkFlow
.createNewProject("project-c", "project with same version slug/version id")
.clickCreateVersionLink().inputVersionId("master").saveVersion();

assertThat(projectVersionPage.getTitle(), Matchers.equalTo("Zanata:project-c:master"));
}

@Test
public void canAddLanguage()
{
Expand Down Expand Up @@ -89,7 +127,7 @@ public void canSeeDocumentList() {
ProjectVersionPage projectVersionPage = new ProjectWorkFlow().goToProjectByName("plural project").goToActiveVersion("master");
WebTranPage webTranPage = projectVersionPage.translate("pl");

LOGGER.info("document list table: {}", webTranPage.getDocumentListTableContent());
log.info("document list table: {}", webTranPage.getDocumentListTableContent());
}

}
64 changes: 64 additions & 0 deletions pom.xml
Expand Up @@ -22,6 +22,10 @@
<zanata.api.version>1.6.0-alpha-3-SNAPSHOT</zanata.api.version>
<zanata.client.version>1.6.0-alpha-2</zanata.client.version>
<zanata.common.version>1.6.0-alpha-3-SNAPSHOT</zanata.common.version>

<!--delombok properties-->
<lombok.source.dir>${project.build.sourceDirectory}/org/zanata</lombok.source.dir>
<delombok.dir>${project.build.directory}/delombok/org/zanata</delombok.dir>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -85,6 +89,66 @@
</pluginManagement>
</build>

<profiles>
<profile>
<!--this is used to run GWT in dev mode. Adjust your IDE to include the delombok -->
<id>delombok</id>
<properties>
<zanata.gwt.module>org.zanata.webtrans.ApplicationSafari</zanata.gwt.module>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>generate-sources</phase>
<configuration>
<target>
<echo>include following as source in your IDE </echo>
<echo>${delombok.dir}</echo>
<echo>exclude following as source in your IDE</echo>
<echo>${lombok.source.dir}</echo>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.projectlombok</groupId>
<artifactId>lombok-maven-plugin</artifactId>
<version>0.11.0.0</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>delombok</goal>
</goals>
<configuration>
<sourceDirectory>${lombok.source.dir}</sourceDirectory>
<outputDirectory>${delombok.dir}</outputDirectory>
<verbose>true</verbose>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>sun.jdk</groupId>
<artifactId>tools</artifactId>
<version>1.6</version>
<scope>system</scope>
<systemPath>${java.home}/../lib/tools.jar</systemPath>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</profile>
</profiles>

<modules>
<module>zanata-model</module>
<module>zanata-war</module>
Expand Down
Expand Up @@ -28,8 +28,20 @@ public class ContainingWorkspaceBridge implements FieldBridge
@Override
public void set(String name, Object value, Document luceneDocument, LuceneOptions luceneOptions)
{
HTextFlow textFlow = (HTextFlow) value;
HDocument doc = textFlow.getDocument();
HDocument doc;
if (value instanceof HTextFlow)
{
doc = ((HTextFlow) value).getDocument();
}
else if (value instanceof HDocument)
{
doc = (HDocument) value;
}
else
{
throw new IllegalArgumentException("ContainingWorkspaceBridge used on a non HDocument or HTextFlow type");
}

HProjectIteration iteration = doc.getProjectIteration();
HIterationProject project = iteration.getProject();

Expand Down
Expand Up @@ -12,7 +12,27 @@ public interface IndexFieldLabels
public static final String ITERATION_FIELD = "iteration";
public static final String DOCUMENT_ID_FIELD = "documentId";
public static final String LOCALE_ID_FIELD = "locale";
public static final String CONTENT_STATE_FIELD = "state";

public static final String CONTENT_CASE_FOLDED = "content-nocase";
public static final String CONTENT_CASE_PRESERVED = "content-case";

public static final String CONTENT_FIELDS_CASE_FOLDED[] = {
CONTENT_CASE_FOLDED + 0,
CONTENT_CASE_FOLDED + 1,
CONTENT_CASE_FOLDED + 2,
CONTENT_CASE_FOLDED + 3,
CONTENT_CASE_FOLDED + 4,
CONTENT_CASE_FOLDED + 5
};

public static final String CONTENT_FIELDS_CASE_PRESERVED[] = {
CONTENT_CASE_PRESERVED + 0,
CONTENT_CASE_PRESERVED + 1,
CONTENT_CASE_PRESERVED + 2,
CONTENT_CASE_PRESERVED + 3,
CONTENT_CASE_PRESERVED + 4,
CONTENT_CASE_PRESERVED + 5
};

}
Expand Up @@ -44,19 +44,22 @@
@TypeDef(name = "contentType", typeClass = ContentTypeType.class)
@org.hibernate.annotations.Entity(mutable = false)
@Setter
@Getter
public class HDocumentHistory implements IDocumentHistory
{

private String docId;
@Getter
private String name;
@Getter
private String path;
private ContentType contentType;
private Integer revision;
private HLocale locale;
private HPerson lastModifiedBy;
protected Long id;
@Getter
protected Date lastChanged;
@Getter
private boolean obsolete;
private HDocument document;

Expand Down
Expand Up @@ -53,7 +53,7 @@
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@Indexed
@Setter
@EqualsAndHashCode(callSuper = true)
@EqualsAndHashCode(callSuper = true, doNotUseGetters = true)
@ToString(of = {"sourceRef", "srcLocale"})
public class HGlossaryEntry extends ModelEntityBase
{
Expand Down

0 comments on commit 184df7d

Please sign in to comment.