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

Commit

Permalink
rhbz1124630 - move client interface to server to avoid massive change…
Browse files Browse the repository at this point in the history
… in testing
  • Loading branch information
Patrick Huang committed Mar 26, 2015
1 parent 5c0fe34 commit d1cdaca
Show file tree
Hide file tree
Showing 24 changed files with 1,563 additions and 324 deletions.
89 changes: 54 additions & 35 deletions functional-test/pom.xml
Expand Up @@ -207,65 +207,57 @@
<version>2.4</version>
</dependency>


<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
</dependency>

<dependency>
<groupId>org.zanata</groupId>
<artifactId>zanata-common-api</artifactId>
<exclusions>
<exclusion>
<groupId>org.jboss.resteasy</groupId>
<artifactId>jaxrs-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxrs</artifactId>
</exclusion>
<exclusion>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxb-provider</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-core-asl</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>jaxrs-api</artifactId>
<scope>${resteasy.scope}</scope>
</dependency>

<!-- to use rest client in test -->
<dependency>
<groupId>org.zanata</groupId>
<artifactId>zanata-rest-client</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxrs</artifactId>
<exclusions>
<exclusion>
<groupId>javassist</groupId>
<artifactId>javassist</artifactId>
</exclusion>
<exclusion>
<groupId>javax.annotation</groupId>
<artifactId>jsr250-api</artifactId>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.zanata</groupId>
<artifactId>zanata-common-util</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxb-provider</artifactId>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3.1</version>
<exclusions>
<exclusion>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.zanata</groupId>
<artifactId>zanata-common-util</artifactId>
</dependency>

<dependency>
<groupId>org.zanata</groupId>
Expand Down Expand Up @@ -327,6 +319,33 @@
<artifactId>joda-time</artifactId>
</dependency>

<dependency>
<groupId>com.jayway.awaitility</groupId>
<artifactId>awaitility</artifactId>
<version>1.6.3</version>
<exclusions>
<exclusion>
<groupId>cglib</groupId>
<artifactId>cglib-nodep</artifactId>
</exclusion>
<exclusion>
<groupId>org.objenesis</groupId>
<artifactId>objenesis</artifactId>
</exclusion>
</exclusions>
<scope>test</scope>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib-nodep</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.objenesis</groupId>
<artifactId>objenesis</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
Expand Down Expand Up @@ -855,7 +874,6 @@
<usedDependencies combine.children="append">
<usedDependency>mysql:mysql-connector-java</usedDependency>
<usedDependency>org.codehaus.groovy:groovy-all</usedDependency>
<usedDependency>org.jboss.resteasy:resteasy-jaxb-provider</usedDependency>
<usedDependency>org.projectlombok:lombok</usedDependency>
</usedDependencies>
</configuration>
Expand Down Expand Up @@ -996,3 +1014,4 @@
</pluginManagement>
</build>
</project>

Expand Up @@ -20,6 +20,10 @@
*/
package org.zanata.feature.concurrentedit;

import static org.assertj.core.api.Assertions.assertThat;
import static org.zanata.util.ZanataRestCaller.buildSourceResource;
import static org.zanata.util.ZanataRestCaller.buildTextFlow;

import java.util.Collections;
import java.util.List;
import java.util.concurrent.Callable;
Expand All @@ -29,31 +33,26 @@
import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicInteger;

import org.jboss.resteasy.client.ClientRequest;
import javax.ws.rs.core.MediaType;

import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.zanata.feature.Feature;
import org.zanata.feature.testharness.ZanataTestCase;
import org.zanata.feature.testharness.TestPlan.DetailedTest;
import org.zanata.feature.testharness.ZanataTestCase;
import org.zanata.rest.dto.resource.Resource;
import org.zanata.util.AddUsersRule;
import org.zanata.util.Constants;
import org.zanata.util.PropertiesHolder;
import org.zanata.util.ZanataRestCaller;

import com.google.common.base.Function;
import com.google.common.base.Throwables;
import com.google.common.collect.Lists;

import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import static org.assertj.core.api.Assertions.assertThat;
import static org.zanata.util.ZanataRestCaller.buildSourceResource;
import static org.zanata.util.ZanataRestCaller.buildTextFlow;
import static org.zanata.util.ZanataRestCaller.checkStatusAndReleaseConnection;
import static org.zanata.util.ZanataRestCaller.getStatusAndReleaseConnection;
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.WebResource;

/**
* @author Patrick Huang <a
Expand All @@ -68,13 +67,10 @@ public class ConcurrentAccessTest extends ZanataTestCase {
@BeforeClass
// Need to ensure that the correct concurrent slots are available
public static void beforeClass() throws Exception {
ClientRequest clientRequest =
clientRequestAsAdmin("rest/configurations/"
+ "c/max.concurrent.req.per.apikey");
// Default
clientRequest.body("text/plain", "6");
Response putResponse = clientRequest.put();
assertThat(getStatusAndReleaseConnection(putResponse)).isEqualTo(201);
String path = "rest/configurations/c/max.concurrent.req.per.apikey";
WebResource.Builder configRequest = clientRequestAsAdmin(path);
configRequest.entity("1", MediaType.TEXT_PLAIN_TYPE);
configRequest.put();
}

@Feature(summary = "The system will handle concurrent document " +
Expand Down Expand Up @@ -139,15 +135,15 @@ private static Integer getResult(Future<Integer> input) {
}
}

private static ClientRequest clientRequestAsAdmin(String path) {
ClientRequest clientRequest =
new ClientRequest(
PropertiesHolder.getProperty(Constants.zanataInstance
.value()) + path);
clientRequest.header("X-Auth-User", "admin");
clientRequest.header("X-Auth-Token",
PropertiesHolder.getProperty(Constants.zanataApiKey.value()));
clientRequest.header("Content-Type", "application/xml");
return clientRequest;
private static WebResource.Builder clientRequestAsAdmin(String path) {
return Client
.create()
.resource(PropertiesHolder.getProperty(Constants.zanataInstance
.value()) + path)
.header("X-Auth-User", "admin")
.header("X-Auth-Token",
PropertiesHolder.getProperty(Constants.zanataApiKey
.value()))
.header("Content-Type", "application/xml");
}
}

0 comments on commit d1cdaca

Please sign in to comment.