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

Commit

Permalink
Merge branch 'integration/master' into rhbz995324
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Eng committed Dec 1, 2013
2 parents 20d96de + 5515f00 commit 5474be0
Show file tree
Hide file tree
Showing 14 changed files with 264 additions and 24 deletions.
14 changes: 13 additions & 1 deletion .travis.yml
@@ -1,2 +1,14 @@
language: java
script: "mvn test -Dgwt.compiler.skip -q"
install: true
script: mvn test -Dgwt.validateOnly -Darquillian.jboss.home=/dev/null

jdk:
- openjdk6
- openjdk7
- oraclejdk7
- oraclejdk8

matrix:
fast_finish: true
allow_failures:
- jdk: oraclejdk8
2 changes: 1 addition & 1 deletion functional-test/pom.xml
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.zanata</groupId>
<artifactId>server</artifactId>
<version>3.2-SNAPSHOT</version>
<version>3.3.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 @@ -28,6 +28,7 @@
import org.zanata.feature.document.DocumentTestSuite;
import org.zanata.feature.glossary.GlossaryTestSuite;
import org.zanata.feature.googleopenid.GoogleOpenIDTestSuite;
import org.zanata.feature.infrastructure.InfrastructureTestSuite;
import org.zanata.feature.language.LanguageTestSuite;
import org.zanata.feature.project.ProjectTestSuite;
import org.zanata.feature.security.SecurityTestSuite;
Expand All @@ -42,7 +43,8 @@
* href="mailto:djansen@redhat.com">djansen@redhat.com</a>
*/
@RunWith(Suite.class)
@Suite.SuiteClasses({ AccountTestSuite.class, AdministrationTestSuite.class,
@Suite.SuiteClasses({InfrastructureTestSuite.class,
AccountTestSuite.class, AdministrationTestSuite.class,
GlossaryTestSuite.class, SecurityTestSuite.class,
CreateSampleProjectTestSuite.class, VersionGroupTestSuite.class,
DocumentTestSuite.class, DashboardTestSuite.class,
Expand Down
Expand Up @@ -23,13 +23,15 @@
import org.hamcrest.Matchers;
import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.openqa.selenium.Alert;
import org.zanata.feature.DetailedTest;
import org.zanata.page.administration.TranslationMemoryEditPage;
import org.zanata.page.administration.TranslationMemoryPage;
import org.zanata.util.ResetDatabaseRule;
import org.zanata.util.RetryRule;
import org.zanata.util.TestFileGenerator;
import org.zanata.workflow.BasicWorkFlow;
import org.zanata.workflow.LoginWorkFlow;
Expand All @@ -47,6 +49,10 @@
public class EditTranslationMemoryTest {
@ClassRule
public static ResetDatabaseRule resetDatabaseRule = new ResetDatabaseRule();

@Rule
public RetryRule retryRule = new RetryRule(2);

TestFileGenerator testFileGenerator = new TestFileGenerator();

@Before
Expand Down
@@ -0,0 +1,35 @@
/*
* Copyright 2013, Red Hat, Inc. and individual contributors as indicated by the
* @author tags. See the copyright.txt file in the distribution for a full
* listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this software; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
* site: http://www.fsf.org.
*/
package org.zanata.feature.infrastructure;

import org.junit.runner.RunWith;
import org.junit.runners.Suite;

/**
* This suite comprises the tests to validate the test harness and framework
* for Zanata functional tests.
* @author Damian Jansen <a
* href="mailto:djansen@redhat.com">djansen@redhat.com</a>
*/
@RunWith(Suite.class)
@Suite.SuiteClasses({ RetryRuleTest.class })
public class InfrastructureTestSuite {
}
@@ -0,0 +1,72 @@
/*
* Copyright 2013, Red Hat, Inc. and individual contributors as indicated by the
* @author tags. See the copyright.txt file in the distribution for a full
* listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this software; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
* site: http://www.fsf.org.
*/

package org.zanata.feature.infrastructure;

import org.hamcrest.Matchers;
import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.zanata.feature.BasicAcceptanceTest;
import org.zanata.util.RetryRule;

import static org.hamcrest.MatcherAssert.assertThat;

/**
* @author Damian Jansen <a
* href="mailto:djansen@redhat.com">djansen@redhat.com</a>
*/
@Category(BasicAcceptanceTest.class)
public class RetryRuleTest {

@Rule
public RetryRule retryRule = new RetryRule(2);

@Test
public void retryPassAfterFail() {
// Fail on the first execution, but pass on the second
assertThat("Current try is greater than 1", retryRule.currentTry(),
Matchers.greaterThan(1));
// Can only pass on second execution
assertThat("This is the second try", retryRule.currentTry(),
Matchers.equalTo(2));
}

@Test
public void passWillPass() {
assertThat("A normal passing test will pass", true);
assertThat("And pass on the first try", retryRule.currentTry(),
Matchers.equalTo(1));
}

@Test(expected = AssertionError.class)
public void retryFailsWhenAllTriesFail() throws Exception {
// Fail the first execution
if (retryRule.currentTry() == 1) {
throw new Exception();
}
// Passes on the second execution, expect-fails on the third
assertThat("The execution count is correct", retryRule.currentTry(),
Matchers.equalTo(2));
// Fails on the second execution
throw new Exception();
}
}
83 changes: 83 additions & 0 deletions functional-test/src/test/java/org/zanata/util/RetryRule.java
@@ -0,0 +1,83 @@
/*
* This work is licensed under a Creative Commons Attribution-ShareAlike 2.5
* Generic License - See http://creativecommons.org/licenses/by-sa/2.5/
*/

package org.zanata.util;

import lombok.extern.slf4j.Slf4j;
import org.junit.rules.TestRule;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;

/**
* @author Damian Jansen <a
* href="mailto:djansen@redhat.com">djansen@redhat.com</a>
*
* Provide a retry mechanism that allows a test to be executed repeatedly
* until it has passed, or fails the given threshold.
* This threshold is defined as the original execution, plus the number
* of given retries, i.e<br/>
* RetryRule retryRule = new RetryRule(2);<br/>
* will execute a failing test 3 times before giving up.
*
* This file is an edited form of the work provided by <a
* href="http://stackoverflow.com/users/1836/matthew-farwell">Matthew
* Farwell</a> on the Stack Exchange Network, specifically <a
* href="http://stackoverflow.com/a/8301639">this submission</a> to Stack
* Overflow.
*/
@Slf4j
public class RetryRule implements TestRule {

private int retries;
private int currentExecution;

/**
* Constructor
* @param retries maximum number of added attempts before failing a test
*/
public RetryRule(int retries) {
this.retries = retries;
}

/**
* Return the human number of the current execution (1 for first try, etc)
* @return integer
*/
public int currentTry() {
return currentExecution + 1;
}

/**
* Executes the TestRule repeatedly until the retries have been exceeded,
* or the test passes
* @param base TestRule base link
* @param description TestRule description link
* @return TestRule statement
* @see TestRule
*/
public Statement apply(final Statement base,
final Description description) {
return new Statement() {
@Override
public void evaluate() throws Throwable {
Throwable throwable = null;
for (currentExecution = 0; currentExecution <= retries;
currentExecution++) {
try {
base.evaluate();
return;
} catch (Throwable t) {
throwable = t;
log.info(description.getDisplayName() + ": Execution "
+ (currentTry()) + " failed");
}
}
log.info(description.getDisplayName() +
": Failure threshold (" + retries + ") exceeded");
throw throwable;
}
};
}
}
22 changes: 17 additions & 5 deletions pom.xml
Expand Up @@ -2,13 +2,13 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>server</artifactId>
<version>3.2-SNAPSHOT</version>
<version>3.3.0-SNAPSHOT</version>
<name>Zanata server modules</name>
<packaging>pom</packaging>
<parent>
<groupId>org.zanata</groupId>
<artifactId>zanata-parent</artifactId>
<version>15-SNAPSHOT</version>
<version>15</version>
<relativePath>../parent</relativePath>
</parent>

Expand All @@ -31,10 +31,10 @@
<gwteventservice.version>1.2.1</gwteventservice.version>
<okapi.version>0.22</okapi.version>

<zanata.api.version>3.2-SNAPSHOT</zanata.api.version>
<zanata.api.version>3.2.0</zanata.api.version>
<!-- This should always be the previous version of the used api version above (but only 3.0.1 or later will work) -->
<zanata.api.compat.version>3.1.0</zanata.api.compat.version>
<zanata.client.version>3.2.0-SNAPSHOT</zanata.client.version>
<zanata.api.compat.version>3.1.1</zanata.api.compat.version>
<zanata.client.version>3.2.0</zanata.client.version>
<zanata.common.version>3.0.2</zanata.common.version>

<richfaces.version>4.3.4.Final</richfaces.version>
Expand Down Expand Up @@ -544,6 +544,18 @@
-->

<repositories>
<!-- This is needed for bootstrapping with a zanata-parent SNAPSHOT -->
<repository>
<id>sonatype-nexus-snapshots</id>
<name>Sonatype Nexus Snapshots</name>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>jboss-public-repository-group</id>
<name>JBoss Public Maven Repository Group</name>
Expand Down
2 changes: 1 addition & 1 deletion zanata-model/pom.xml
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.zanata</groupId>
<artifactId>server</artifactId>
<version>3.2-SNAPSHOT</version>
<version>3.3.0-SNAPSHOT</version>
</parent>
<artifactId>zanata-model</artifactId>
<name>Zanata model</name>
Expand Down
2 changes: 1 addition & 1 deletion zanata-war/pom.xml
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.zanata</groupId>
<artifactId>server</artifactId>
<version>3.2-SNAPSHOT</version>
<version>3.3.0-SNAPSHOT</version>
</parent>
<artifactId>zanata-war</artifactId>
<packaging>war</packaging>
Expand Down

0 comments on commit 5474be0

Please sign in to comment.