SpringWSEndpointOrchestrator implements WebSocketDeploymentStatusProvider { @Nonnull public DeploymentStatus getDeploymentStatus() { return status.get(); } SpringWSEndpointOrchestrator(ClassNameResolver clsResolver, ServletContext servletCtx, ApplicationContext
            appCtx, Map<String, Class<?>> endpointMappings); void deployEndpoints(); @Nonnull DeploymentStatus getDeploymentStatus(); final static String SERVLET_CONTAINER_CLASS; }
@Test public void initialDeploymentStatus() { ClassNameResolver classNameResolver = new TestClassNameResolver().knownClass(ServerContainer.class.getName()); TestServletContext servletCtx = new TestServletContext(); TestServerContainer serverContainer = new TestServerContainer(); servletCtx.setAttribute(SpringWSEndpointOrchestrator.SERVLET_CONTAINER_CLASS, serverContainer); SpringWSEndpointOrchestrator orchestrator = new SpringWSEndpointOrchestrator(classNameResolver, servletCtx, new TestApplicationContext(), mapOf(pair("/dummy_endpoint", DummyEndpoint.class))); assertThat(orchestrator.getDeploymentStatus()).isEqualTo(NOT_PERFORMED); }
@Test public void runningDeploymentStatus() { ClassNameResolver classNameResolver = new TestClassNameResolver().knownClass(ServerContainer.class.getName()); TestServletContext servletCtx = new TestServletContext(); TestServerContainer serverContainer = new TestServerContainer(); servletCtx.setAttribute(SpringWSEndpointOrchestrator.SERVLET_CONTAINER_CLASS, serverContainer); SpringWSEndpointOrchestrator orchestrator = new SpringWSEndpointOrchestrator(classNameResolver, servletCtx, new TestApplicationContext(), mapOf(pair("/dummy_endpoint", DummyEndpoint.class))); serverContainer.getDeploymentLock().lock(); runAsync(orchestrator::deployEndpoints); waitUntil(() -> orchestrator.getDeploymentStatus() == RUNNING); serverContainer.getDeploymentLock().unlock(); waitUntil(() -> orchestrator.getDeploymentStatus() == SUCCESS);; }
@Test public void throwExceptionWhenDeployingTwice() { ClassNameResolver classNameResolver = new TestClassNameResolver().knownClass(ServerContainer.class.getName()); TestServletContext servletCtx = new TestServletContext(); TestServerContainer serverContainer = new TestServerContainer(); servletCtx.setAttribute(SpringWSEndpointOrchestrator.SERVLET_CONTAINER_CLASS, serverContainer); SpringWSEndpointOrchestrator orchestrator = new SpringWSEndpointOrchestrator(classNameResolver, servletCtx, new TestApplicationContext(), mapOf(pair("/dummy_endpoint", DummyEndpoint.class))); serverContainer.getDeploymentLock().lock(); runAsync(orchestrator::deployEndpoints); waitUntil(() -> orchestrator.getDeploymentStatus() == RUNNING); assertThatExceptionOfType(IllegalStateException.class).isThrownBy(orchestrator::deployEndpoints); serverContainer.getDeploymentLock().unlock(); waitUntil(() -> orchestrator.getDeploymentStatus() == SUCCESS); assertThatExceptionOfType(IllegalStateException.class).isThrownBy(orchestrator::deployEndpoints); }