Skip to content

Commit 0e98702

Browse files
committed
- adds end to end unit test for throttling handler
1 parent 8b8dc16 commit 0e98702

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

src/test/java/com/microsoft/graph/functional/UserTests.java

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
package com.microsoft.graph.functional;
22

3+
import static org.junit.Assert.assertNotEquals;
34
import static org.junit.Assert.assertNotNull;
45

56
import java.io.File;
67
import java.io.FileInputStream;
78
import java.io.InputStream;
89
import java.util.List;
10+
import java.util.concurrent.ExecutorService;
11+
import java.util.concurrent.Executors;
12+
import java.util.concurrent.TimeUnit;
913

1014
import org.junit.Before;
1115
import org.junit.Ignore;
@@ -24,7 +28,6 @@
2428
import com.microsoft.graph.requests.extensions.IOrganizationCollectionPage;
2529
import com.microsoft.graph.requests.extensions.IUsedInsightCollectionPage;
2630
import com.microsoft.graph.requests.extensions.IUserCollectionPage;
27-
2831
@Ignore
2932
public class UserTests {
3033
IGraphServiceClient graphServiceClient = null;
@@ -163,5 +166,26 @@ public void meMemberof() {
163166
IDirectoryObjectCollectionWithReferencesPage page = graphServiceClient.me().memberOf().buildRequest().get();
164167
assertNotNull(page);
165168
}
169+
@Test
170+
public void getMeAndRetryOnThrottling() throws Exception {
171+
ExecutorService exec = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() * 2);
172+
try {
173+
for(Integer i = 0; i < 2000; i++) {
174+
exec.submit(new Runnable() {
175+
@Override
176+
public void run() {
177+
final IUserCollectionPage users = graphServiceClient.users().buildRequest().get();
178+
assertNotNull(users);
179+
final List<User> currentPage = users.getCurrentPage();
180+
assertNotNull(currentPage);
181+
assertNotEquals(0, currentPage.size());
182+
}
183+
});
184+
}
185+
exec.awaitTermination(5L, TimeUnit.MINUTES);
186+
} finally {
187+
exec.shutdown();
188+
}
189+
}
166190

167191
}

0 commit comments

Comments
 (0)