/** * Creates a new instance * * @param name the name of the server * @param acceptor the {@link ConnectionAcceptor} to call when the server has been created * @throws NullPointerException if {@code name} or {@code acceptor} is {@code null} */ ServerDuplexConnectionAcceptor(String name, ConnectionAcceptor acceptor) { Objects.requireNonNull(name, "name must not be null"); this.address = new LocalSocketAddress(name); this.acceptor = Objects.requireNonNull(acceptor, "acceptor must not be null"); }
@Override public void dispose() { if (!registry.remove(address.getName(), this)) { throw new AssertionError(); } onClose.onComplete(); }
@DisplayName("returns the configured name") @Test void name() { assertThat(new LocalSocketAddress("test-name").getName()).isEqualTo("test-name"); } }
@DisplayName("constructor throws NullPointerException with null name") @Test void constructorNullName() { assertThatNullPointerException() .isThrownBy(() -> new LocalSocketAddress(null)) .withMessage("name must not be null"); }
@Override public void dispose() { if (!registry.remove(address.getName(), this)) { throw new AssertionError(); } onClose.onComplete(); }
/** * Creates a new instance * * @param name the name of the server * @param acceptor the {@link ConnectionAcceptor} to call when the server has been created * @throws NullPointerException if {@code name} or {@code acceptor} is {@code null} */ ServerDuplexConnectionAcceptor(String name, ConnectionAcceptor acceptor) { Objects.requireNonNull(name, "name must not be null"); this.address = new LocalSocketAddress(name); this.acceptor = Objects.requireNonNull(acceptor, "acceptor must not be null"); }