forked from github/copilot-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInternalExecutorProviderTest.java
More file actions
55 lines (42 loc) · 1.72 KB
/
Copy pathInternalExecutorProviderTest.java
File metadata and controls
55 lines (42 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------------------------------------------*/
package com.github.copilot;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertSame;
import java.lang.reflect.Modifier;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ForkJoinPool;
import org.junit.jupiter.api.Test;
import com.github.copilot.rpc.CopilotClientOptions;
class InternalExecutorProviderTest {
@Test
void baseProviderReturnsCommonPool() {
Executor executor = new InternalExecutorProvider(null).get();
assertSame(ForkJoinPool.commonPool(), executor);
}
@Test
void userProvidedExecutorIsNotOwned() {
Executor executor = ForkJoinPool.commonPool();
assertFalse(new InternalExecutorProvider(executor).canBeShutdown());
}
@Test
void providerIsPackagePrivate() {
assertFalse(Modifier.isPublic(InternalExecutorProvider.class.getModifiers()));
}
@Test
void clientDoesNotShutDownUserProvidedExecutor() {
ExecutorService executor = Executors.newSingleThreadExecutor();
try {
try (var client = new CopilotClient(new CopilotClientOptions().setAutoStart(false).setExecutor(executor))) {
assertNotNull(client);
}
assertFalse(executor.isShutdown());
} finally {
executor.shutdownNow();
}
}
}