[OLINGO-260] async tests

This commit is contained in:
Francesco Chicchiriccò 2014-05-14 16:34:19 +02:00 committed by Stephan Klevenz
parent f17482ae4a
commit a1050e1306
2 changed files with 16 additions and 17 deletions

View File

@ -27,7 +27,7 @@ import java.util.UUID;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import org.apache.olingo.ext.proxy.api.AsyncCall; import org.apache.olingo.ext.proxy.api.AsyncCall;
import org.apache.olingo.ext.proxy.api.Filter; import org.apache.olingo.ext.proxy.api.Query;
import org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.types.Employee; import org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.types.Employee;
import org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.types. import org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.types.
EmployeeCollection; EmployeeCollection;
@ -45,7 +45,7 @@ public class AsyncTestITCase extends AbstractTestITCase {
@Test @Test
public void retrieveEntitySet() throws InterruptedException, ExecutionException { public void retrieveEntitySet() throws InterruptedException, ExecutionException {
final Future<ProductCollection> futureProds = final Future<ProductCollection> futureProds =
new AsyncCall<ProductCollection>(containerFactory.getClient().getConfiguration()) { new AsyncCall<ProductCollection>(containerFactory.getConfiguration()) {
@Override @Override
public ProductCollection call() { public ProductCollection call() {
@ -73,7 +73,7 @@ public class AsyncTestITCase extends AbstractTestITCase {
final Product product = container.getProduct().get(-10); final Product product = container.getProduct().get(-10);
product.setDescription("AsyncTest#updateEntity " + random); product.setDescription("AsyncTest#updateEntity " + random);
final Future<Void> futureFlush = new AsyncCall<Void>(containerFactory.getClient().getConfiguration()) { final Future<Void> futureFlush = new AsyncCall<Void>(containerFactory.getConfiguration()) {
@Override @Override
public Void call() { public Void call() {
@ -87,7 +87,7 @@ public class AsyncTestITCase extends AbstractTestITCase {
Thread.sleep(1000L); Thread.sleep(1000L);
} }
final Future<Product> futureProd = new AsyncCall<Product>(containerFactory.getClient().getConfiguration()) { final Future<Product> futureProd = new AsyncCall<Product>(containerFactory.getConfiguration()) {
@Override @Override
public Product call() { public Product call() {
@ -100,23 +100,22 @@ public class AsyncTestITCase extends AbstractTestITCase {
@Test @Test
public void polymorphQuery() throws Exception { public void polymorphQuery() throws Exception {
final Future<Filter<Employee, EmployeeCollection>> queryEmployee = final Future<Query<Employee, EmployeeCollection>> queryEmployee =
new AsyncCall<Filter<Employee, EmployeeCollection>>(containerFactory.getClient().getConfiguration()) { new AsyncCall<Query<Employee, EmployeeCollection>>(containerFactory.getConfiguration()) {
@Override @Override
public Filter<Employee, EmployeeCollection> call() { public Query<Employee, EmployeeCollection> call() {
return container.getPerson().createFilter(EmployeeCollection.class); return container.getPerson().createQuery(EmployeeCollection.class);
} }
}; };
assertFalse(queryEmployee.get().getResult().isEmpty()); assertFalse(queryEmployee.get().getResult().isEmpty());
final Future<Filter<SpecialEmployee, SpecialEmployeeCollection>> querySpecialEmployee = final Future<Query<SpecialEmployee, SpecialEmployeeCollection>> querySpecialEmployee =
new AsyncCall<Filter<SpecialEmployee, SpecialEmployeeCollection>>( new AsyncCall<Query<SpecialEmployee, SpecialEmployeeCollection>>(containerFactory.getConfiguration()) {
containerFactory.getClient().getConfiguration()) {
@Override @Override
public Filter<SpecialEmployee, SpecialEmployeeCollection> call() { public Query<SpecialEmployee, SpecialEmployeeCollection> call() {
return container.getPerson().createFilter(SpecialEmployeeCollection.class); return container.getPerson().createQuery(SpecialEmployeeCollection.class);
} }
}; };
assertFalse(querySpecialEmployee.get().getResult().isEmpty()); assertFalse(querySpecialEmployee.get().getResult().isEmpty());

View File

@ -37,7 +37,7 @@ public class AsyncTestITCase extends AbstractTestITCase {
@Test @Test
public void retrieveEntitySet() throws InterruptedException, ExecutionException { public void retrieveEntitySet() throws InterruptedException, ExecutionException {
final Future<CustomerCollection> futureCustomers = final Future<CustomerCollection> futureCustomers =
new AsyncCall<CustomerCollection>(containerFactory.getClient().getConfiguration()) { new AsyncCall<CustomerCollection>(containerFactory.getConfiguration()) {
@Override @Override
public CustomerCollection call() { public CustomerCollection call() {
@ -60,12 +60,12 @@ public class AsyncTestITCase extends AbstractTestITCase {
@Test @Test
public void updateEntity() throws InterruptedException { public void updateEntity() throws InterruptedException {
final String randomFirstName = RandomStringUtils.random(10, "abcedfghijklmnopqrstuvwxyz"); final String randomFirstName = RandomStringUtils.random(10);
Person person = container.getPeople().get(1); Person person = container.getPeople().get(1);
person.setFirstName(randomFirstName); person.setFirstName(randomFirstName);
final Future<Void> futureFlush = new AsyncCall<Void>(containerFactory.getClient().getConfiguration()) { final Future<Void> futureFlush = new AsyncCall<Void>(containerFactory.getConfiguration()) {
@Override @Override
public Void call() { public Void call() {
@ -79,7 +79,7 @@ public class AsyncTestITCase extends AbstractTestITCase {
Thread.sleep(1000L); Thread.sleep(1000L);
} }
final Future<Person> futureProd = new AsyncCall<Person>(containerFactory.getClient().getConfiguration()) { final Future<Person> futureProd = new AsyncCall<Person>(containerFactory.getConfiguration()) {
@Override @Override
public Person call() { public Person call() {