package p.studio.app; import org.junit.jupiter.api.Test; import org.springframework.boot.WebApplicationType; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.context.ConfigurableApplicationContext; import p.packer.PackerWorkspaceService; import p.studio.api.operation.OperationExecutor; import java.util.concurrent.ExecutorService; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; class StudioApplicationConfigurationTest { @Test void bootsAndClosesWithoutAWebApplicationContext() { final ConfigurableApplicationContext context = new SpringApplicationBuilder(StudioApplicationConfiguration.class) .web(WebApplicationType.NONE) .headless(true) .run(); final ExecutorService executor = context.getBean(ExecutorService.class); final var mcp = context.getBean(p.studio.app.mcp.LocalMcpServer.class); try (context) { assertNotNull(context.getBean(StudioUiFactory.class)); assertNotNull(context.getBean(PackerWorkspaceService.class)); assertNotNull(context.getBean(OperationExecutor.class)); assertFalse(context.getClass().getName().contains("WebServer")); assertFalse(executor.isShutdown()); assertTrue(mcp.isRunning()); var tools = context.getBean(p.studio.app.mcp.McpToolRegistry.class).descriptors(); org.junit.jupiter.api.Assertions.assertEquals(17, tools.size()); assertTrue(context.getBean(p.studio.core.runtime.HeadlessGateway.class) instanceof p.studio.app.runtime.HeadlessProcessGateway); org.junit.jupiter.api.Assertions.assertEquals("studio_project_context", tools.get(0).path("name").asText()); org.junit.jupiter.api.Assertions.assertEquals("studio_reference_read", tools.get(1).path("name").asText()); assertTrue(tools.toString().contains("studio_language_query")); assertTrue(tools.toString().contains("studio_build_start")); assertTrue(tools.toString().contains("studio_headless_boot")); } assertTrue(executor.isShutdown()); assertFalse(mcp.isRunning()); } }