LocalServerTransport implements ServerTransport<Closeable> { static @Nullable ConnectionAcceptor findServer(String name) { Objects.requireNonNull(name, "name must not be null"); return registry.get(name); } private  LocalServerTransport(String name); static LocalServerTransport create(String name); static LocalServerTransport createEphemeral(); static void dispose(String name); LocalClientTransport clientTransport(); @Override Mono<Closeable> start(ConnectionAcceptor acceptor);  }
@DisplayName("returns the server by name") @Test void findServer() { LocalServerTransport serverTransport = LocalServerTransport.createEphemeral(); serverTransport .start(duplexConnection -> Mono.empty()) .as(StepVerifier::create) .expectNextCount(1) .verifyComplete(); assertThat(LocalServerTransport.findServer(serverTransport.getName())).isNotNull(); }
@DisplayName("returns null if server hasn't been started") @Test void findServerMissingName() { assertThat(LocalServerTransport.findServer("test-name")).isNull(); }
@DisplayName("findServer throws NullPointerException with null name") @Test void findServerNullName() { assertThatNullPointerException() .isThrownBy(() -> LocalServerTransport.findServer(null)) .withMessage("name must not be null"); }