Search in sources :

Example 1 with ConnectionProvider

use of reactor.netty.resources.ConnectionProvider in project spring-framework by spring-projects.

the class ReactorResourceFactoryTests method localResourcesViaSupplier.

@Test
void localResourcesViaSupplier() throws Exception {
    this.resourceFactory.setUseGlobalResources(false);
    this.resourceFactory.setConnectionProviderSupplier(() -> this.connectionProvider);
    this.resourceFactory.setLoopResourcesSupplier(() -> this.loopResources);
    this.resourceFactory.afterPropertiesSet();
    ConnectionProvider connectionProvider = this.resourceFactory.getConnectionProvider();
    LoopResources loopResources = this.resourceFactory.getLoopResources();
    assertThat(connectionProvider).isSameAs(this.connectionProvider);
    assertThat(loopResources).isSameAs(this.loopResources);
    verifyNoMoreInteractions(this.connectionProvider, this.loopResources);
    this.resourceFactory.destroy();
    // Managed (destroy disposes)..
    verify(this.connectionProvider).disposeLater();
    verify(this.loopResources).disposeLater(eq(Duration.ofSeconds(LoopResources.DEFAULT_SHUTDOWN_QUIET_PERIOD)), eq(Duration.ofSeconds(LoopResources.DEFAULT_SHUTDOWN_TIMEOUT)));
    verifyNoMoreInteractions(this.connectionProvider, this.loopResources);
}
Also used : LoopResources(reactor.netty.resources.LoopResources) ConnectionProvider(reactor.netty.resources.ConnectionProvider) Test(org.junit.jupiter.api.Test)

Example 2 with ConnectionProvider

use of reactor.netty.resources.ConnectionProvider in project spring-framework by spring-projects.

the class ReactorResourceFactoryTests method localResources.

@Test
void localResources() throws Exception {
    this.resourceFactory.setUseGlobalResources(false);
    this.resourceFactory.afterPropertiesSet();
    ConnectionProvider connectionProvider = this.resourceFactory.getConnectionProvider();
    LoopResources loopResources = this.resourceFactory.getLoopResources();
    assertThat(connectionProvider).isNotSameAs(HttpResources.get());
    assertThat(loopResources).isNotSameAs(HttpResources.get());
    // The below does not work since ConnectionPoolProvider simply checks if pool is empty.
    // assertFalse(connectionProvider.isDisposed());
    assertThat(loopResources.isDisposed()).isFalse();
    this.resourceFactory.destroy();
    assertThat(connectionProvider.isDisposed()).isTrue();
    assertThat(loopResources.isDisposed()).isTrue();
}
Also used : LoopResources(reactor.netty.resources.LoopResources) ConnectionProvider(reactor.netty.resources.ConnectionProvider) Test(org.junit.jupiter.api.Test)

Example 3 with ConnectionProvider

use of reactor.netty.resources.ConnectionProvider in project spring-framework by spring-projects.

the class ReactorResourceFactoryTests method externalResources.

@Test
void externalResources() throws Exception {
    this.resourceFactory.setUseGlobalResources(false);
    this.resourceFactory.setConnectionProvider(this.connectionProvider);
    this.resourceFactory.setLoopResources(this.loopResources);
    this.resourceFactory.afterPropertiesSet();
    ConnectionProvider connectionProvider = this.resourceFactory.getConnectionProvider();
    LoopResources loopResources = this.resourceFactory.getLoopResources();
    assertThat(connectionProvider).isSameAs(this.connectionProvider);
    assertThat(loopResources).isSameAs(this.loopResources);
    verifyNoMoreInteractions(this.connectionProvider, this.loopResources);
    this.resourceFactory.destroy();
    // Not managed (destroy has no impact)..
    verifyNoMoreInteractions(this.connectionProvider, this.loopResources);
}
Also used : LoopResources(reactor.netty.resources.LoopResources) ConnectionProvider(reactor.netty.resources.ConnectionProvider) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)3 ConnectionProvider (reactor.netty.resources.ConnectionProvider)3 LoopResources (reactor.netty.resources.LoopResources)3