[OLINGO-1004] moved ClientAsyncTest to AsyncSupportITCase

Signed-off-by: Christian Amend <[email protected]>


Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/b9a71ff8
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/b9a71ff8
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/b9a71ff8

Branch: refs/heads/master
Commit: b9a71ff88a8f304d4bb2b382b6ffb46e5cc8cb1e
Parents: f3cee9b
Author: Morten Riedel <[email protected]>
Authored: Thu Sep 8 11:01:04 2016 +0200
Committer: Christian Amend <[email protected]>
Committed: Thu Sep 29 14:19:04 2016 +0200

----------------------------------------------------------------------
 .../apache/olingo/fit/base/AsyncTestITCase.java | 20 --------------
 .../fit/tecsvc/client/AsyncSupportITCase.java   | 28 +++++++++++++++++---
 2 files changed, 24 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b9a71ff8/fit/src/test/java/org/apache/olingo/fit/base/AsyncTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/base/AsyncTestITCase.java 
b/fit/src/test/java/org/apache/olingo/fit/base/AsyncTestITCase.java
index 1f2cc23..f862de7 100644
--- a/fit/src/test/java/org/apache/olingo/fit/base/AsyncTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/base/AsyncTestITCase.java
@@ -25,8 +25,6 @@ import static org.junit.Assert.assertTrue;
 
 import java.net.URI;
 import java.util.List;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
 
 import org.apache.olingo.client.api.communication.request.AsyncRequestWrapper;
 import 
org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
@@ -45,24 +43,6 @@ import org.junit.Test;
 
 public class AsyncTestITCase extends AbstractTestITCase {
 
-  @Test
-  public void clientAsync() throws InterruptedException, ExecutionException {
-    final URIBuilder uriBuilder = 
client.newURIBuilder(testStaticServiceRootURL).
-        appendEntitySetSegment("Customers");
-    final Future<ODataRetrieveResponse<ClientEntitySet>> futureRes =
-        
client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build()).asyncExecute();
-    assertNotNull(futureRes);
-
-    while (!futureRes.isDone()) {
-      Thread.sleep(1000L);
-    }
-
-    final ODataRetrieveResponse<ClientEntitySet> res = futureRes.get();
-    assertNotNull(res);
-    assertEquals(200, res.getStatusCode());
-    assertFalse(res.getBody().getEntities().isEmpty());
-  }
-
   private void withInlineEntry(final ContentType contentType) {
     final URIBuilder uriBuilder = 
client.newURIBuilder(testStaticServiceRootURL).
         
appendEntitySetSegment("Customers").appendKeySegment(1).expand("Company");

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b9a71ff8/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/AsyncSupportITCase.java
----------------------------------------------------------------------
diff --git 
a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/AsyncSupportITCase.java 
b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/AsyncSupportITCase.java
index ed23cc3..68098e6 100644
--- 
a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/AsyncSupportITCase.java
+++ 
b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/AsyncSupportITCase.java
@@ -18,14 +18,14 @@
  */
 package org.apache.olingo.fit.tecsvc.client;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
 import java.net.URI;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
 
 import org.apache.olingo.client.api.ODataClient;
 import org.apache.olingo.client.api.communication.ODataClientErrorException;
@@ -45,12 +45,17 @@ import org.apache.olingo.client.api.data.ResWrap;
 import org.apache.olingo.client.api.domain.ClientEntity;
 import org.apache.olingo.client.api.domain.ClientEntitySet;
 import org.apache.olingo.client.api.domain.ClientProperty;
+import org.apache.olingo.client.api.uri.URIBuilder;
 import org.apache.olingo.commons.api.data.Entity;
 import org.apache.olingo.commons.api.data.EntityCollection;
 import org.apache.olingo.commons.api.edm.FullQualifiedName;
 import org.apache.olingo.commons.api.format.PreferenceName;
 import org.apache.olingo.commons.api.http.HttpHeader;
 import org.apache.olingo.commons.api.http.HttpStatusCode;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 import org.junit.Test;
 
 public final class AsyncSupportITCase extends AbstractParamTecSvcITCase {
@@ -61,6 +66,21 @@ public final class AsyncSupportITCase extends 
AbstractParamTecSvcITCase {
   private static final int SLEEP_TIMEOUT_IN_MS = 100;
 
   @Test
+  public void clientAsync() throws InterruptedException, ExecutionException, 
TimeoutException {
+    ODataClient client = getClient();
+    final URIBuilder uriBuilder = client.newURIBuilder(SERVICE_URI)
+            .appendEntitySetSegment(ES_ALL_PRIM);
+    final Future<ODataRetrieveResponse<ClientEntitySet>> futureRes =
+        
client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build()).asyncExecute();
+    assertNotNull(futureRes);
+    //wait a maximum of 10 seconds, otherwise throw TimeoutException
+    final ODataRetrieveResponse<ClientEntitySet> res = futureRes.get(10, 
TimeUnit.SECONDS);
+    assertNotNull(res);
+    assertEquals(200, res.getStatusCode());
+    assertFalse(res.getBody().getEntities().isEmpty());
+  }
+  
+  @Test
   public void readEntity() throws Exception {
     ODataClient client = getClient();
     URI uri = client.newURIBuilder(SERVICE_URI)

Reply via email to