Launch the JavaFX 2 project shell on Java 25 with an interactive viewport, managed Play lifecycle and project mutation guards. Preserve headless/MCP and save compatibility, and qualify exact runtime executable bundles. Separate unit JaCoCo gates from opt-in integration suites and use the internal Pong fixture for the headless visual pilot. Move maintenance and native conformance tools into tooling; retain the VS Code extension and update current navigation links. Validation: tooling make verify passed, including 1064 Studio unit tests, JaCoCo thresholds and 22 headless integration tests.
65 lines
3.1 KiB
Java
65 lines
3.1 KiB
Java
package p.studio.app.lsp;
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import org.junit.jupiter.api.Test;
|
|
import org.junit.jupiter.api.io.TempDir;
|
|
import p.studio.api.project.*;
|
|
import p.studio.lsp.services.LspServerLifecycleImpl;
|
|
import java.nio.file.*;
|
|
import static org.junit.jupiter.api.Assertions.*;
|
|
|
|
@org.junit.jupiter.api.Tag("integration")
|
|
class LspDiscoveryTest {
|
|
@TempDir Path root;
|
|
final ObjectMapper mapper = new ObjectMapper();
|
|
ProjectReference project() { return new ProjectReference("app", "1.0", "pbs", 1, ProjectTarget.Game, root); }
|
|
|
|
@Test void publishesActualProjectEndpointAndRemovesItOnClose() throws Exception {
|
|
var lifecycle = new LspServerLifecycleImpl();
|
|
var adapter = new LspLifecycleAdapter(lifecycle);
|
|
var project = project();
|
|
adapter.boot(project);
|
|
try {
|
|
var data = mapper.readTree(root.resolve(".studio/lsp.json").toFile());
|
|
assertEquals(1, data.path("schemaVersion").asInt());
|
|
assertEquals(root.toRealPath().toString(), data.path("projectRoot").asText());
|
|
assertEquals(ProcessHandle.current().pid(), data.path("processId").asLong());
|
|
var endpoint = lifecycle.endpoint(LspLifecycleAdapter.context(project)).orElseThrow();
|
|
assertEquals(endpoint.port(), data.path("port").asInt());
|
|
assertEquals("127.0.0.1", data.path("host").asText());
|
|
assertFalse(data.path("sessionId").asText().isBlank());
|
|
} finally { adapter.shutdown(project); }
|
|
assertFalse(Files.exists(root.resolve(".studio/lsp.json")));
|
|
assertTrue(lifecycle.endpoint(LspLifecycleAdapter.context(project)).isEmpty());
|
|
}
|
|
|
|
@Test void newSessionGetsFreshIdentityAndPortCanBeRediscovered() throws Exception {
|
|
var adapter = new LspLifecycleAdapter(new LspServerLifecycleImpl());
|
|
var project = project();
|
|
adapter.boot(project);
|
|
String first;
|
|
try { first = mapper.readTree(root.resolve(".studio/lsp.json").toFile()).path("sessionId").asText(); }
|
|
finally { adapter.shutdown(project); }
|
|
adapter.boot(project);
|
|
try { assertNotEquals(first, mapper.readTree(root.resolve(".studio/lsp.json").toFile()).path("sessionId").asText()); }
|
|
finally { adapter.shutdown(project); }
|
|
}
|
|
|
|
@Test void shutdownPreservesMetadataOwnedByAnotherSession() throws Exception {
|
|
var adapter = new LspLifecycleAdapter(new LspServerLifecycleImpl());
|
|
var project = project();
|
|
adapter.boot(project);
|
|
Files.writeString(root.resolve(".studio/lsp.json"), "{\"sessionId\":\"replacement\"}");
|
|
adapter.shutdown(project);
|
|
assertTrue(Files.readString(root.resolve(".studio/lsp.json")).contains("replacement"));
|
|
}
|
|
|
|
@Test void failedPublicationRollsBackListeningServer() throws Exception {
|
|
Files.writeString(root.resolve(".studio"), "blocked");
|
|
var lifecycle = new LspServerLifecycleImpl();
|
|
var adapter = new LspLifecycleAdapter(lifecycle);
|
|
assertThrows(IllegalStateException.class, () -> adapter.boot(project()));
|
|
assertTrue(lifecycle.endpoint(LspLifecycleAdapter.context(project())).isEmpty());
|
|
}
|
|
}
|