Skip to content

Commit de17ac8

Browse files
edburnsCopilot
andauthored
Test real turns over Java in-process transport (#2414)
Add a replay-backed session round trip to InProcessTransportIT so the native transport covers authentication, tool initialization, model traffic, assistant responses, and idle event delivery. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 1e36f86f-389d-4ea7-8050-d11db997c7c7
1 parent 7016935 commit de17ac8

1 file changed

Lines changed: 32 additions & 6 deletions

File tree

java/sdk/src/test/java/com/github/copilot/e2e/InProcessTransportIT.java

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,36 @@
88
import static org.junit.jupiter.api.Assertions.assertNotNull;
99

1010
import java.util.Map;
11+
import java.util.concurrent.CompletableFuture;
12+
import java.util.concurrent.TimeUnit;
1113

1214
import org.junit.jupiter.api.AfterAll;
1315
import org.junit.jupiter.api.BeforeAll;
1416
import org.junit.jupiter.api.Test;
1517

1618
import com.github.copilot.AllowCopilotExperimental;
1719
import com.github.copilot.CopilotClient;
20+
import com.github.copilot.CopilotSession;
1821
import com.github.copilot.E2ETestContext;
1922
import com.github.copilot.ffi.InProcessEnvGuard;
23+
import com.github.copilot.generated.AssistantMessageEvent;
24+
import com.github.copilot.generated.SessionIdleEvent;
2025
import com.github.copilot.rpc.CopilotClientOptions;
26+
import com.github.copilot.rpc.MessageOptions;
27+
import com.github.copilot.rpc.PermissionHandler;
2128
import com.github.copilot.rpc.PingResponse;
2229
import com.github.copilot.rpc.RuntimeConnection;
30+
import com.github.copilot.rpc.SessionConfig;
2331

2432
/**
2533
* Failsafe integration test for the in-process (FFI) transport.
2634
*
2735
* <p>
2836
* Loads the real {@code runtime.node} native library into this test process via
29-
* {@link com.github.copilot.ffi.FfiRuntimeHost}, performs a purely local
30-
* {@code ping} round-trip through the runtime, and stops cleanly. {@code ping}
31-
* is answered by the runtime itself, so no auth or replay proxy is involved —
32-
* this mirrors {@code nodejs/test/e2e/inprocess_ffi.e2e.test.ts},
33-
* {@code go/internal/e2e/inprocess_ffi_e2e_test.go}, and
34-
* {@code python/e2e/test_inprocess_ffi_e2e.py}.
37+
* {@link com.github.copilot.ffi.FfiRuntimeHost}. Coverage includes both a
38+
* purely local {@code ping} round-trip and a replay-backed session turn that
39+
* exercises authentication, tool initialization, model traffic, and
40+
* asynchronous session event delivery over the FFI transport.
3541
*
3642
* <p>
3743
* {@link InProcessEnvGuard} demonstrates how the harness redirects the native
@@ -98,4 +104,24 @@ void shouldStartPingAndStopOverInProcessFfi() throws Exception {
98104
}
99105
}
100106
}
107+
108+
@Test
109+
void shouldCreateSessionAndCompleteTurnOverInProcessFfi() throws Exception {
110+
ctx.configureForTest("session", "should_receive_session_events");
111+
112+
try (CopilotClient client = ctx.createClient();
113+
CopilotSession session = client
114+
.createSession(new SessionConfig().setOnPermissionRequest(PermissionHandler.APPROVE_ALL))
115+
.get(30, TimeUnit.SECONDS)) {
116+
var idleReceived = new CompletableFuture<SessionIdleEvent>();
117+
session.on(SessionIdleEvent.class, idleReceived::complete);
118+
119+
AssistantMessageEvent response = session.sendAndWait(new MessageOptions().setPrompt("What is 100+200?"))
120+
.get(60, TimeUnit.SECONDS);
121+
122+
assertNotNull(response);
123+
assertEquals("100 + 200 = 300", response.getData().content());
124+
assertNotNull(idleReceived.get(5, TimeUnit.SECONDS));
125+
}
126+
}
101127
}

0 commit comments

Comments
 (0)