use of com.quorum.tessera.ssl.context.ClientSSLContextFactory in project tessera by ConsenSys.
the class ResendClientProviderTest method provider.
@Test
public void provider() {
try (var configFactoryMockedStatic = mockStatic(ConfigFactory.class);
var clientSSLContextFactoryMockedStatic = mockStatic(ClientSSLContextFactory.class)) {
ConfigFactory configFactory = mock(ConfigFactory.class);
Config config = mock(Config.class);
ServerConfig serverConfig = mock(ServerConfig.class);
when(config.getP2PServerConfig()).thenReturn(serverConfig);
when(configFactory.getConfig()).thenReturn(config);
configFactoryMockedStatic.when(ConfigFactory::create).thenReturn(configFactory);
clientSSLContextFactoryMockedStatic.when(ClientSSLContextFactory::create).thenReturn(mock(ClientSSLContextFactory.class));
ResendClient resendClient = ResendClientProvider.provider();
assertThat(resendClient).isNotNull().isExactlyInstanceOf(RestResendClient.class);
clientSSLContextFactoryMockedStatic.verify(ClientSSLContextFactory::create);
clientSSLContextFactoryMockedStatic.verifyNoMoreInteractions();
configFactoryMockedStatic.verify(ConfigFactory::create);
configFactoryMockedStatic.verifyNoMoreInteractions();
}
}
use of com.quorum.tessera.ssl.context.ClientSSLContextFactory in project tessera by ConsenSys.
the class RecoveryClientProviderTest method provider.
@Test
public void provider() {
try (var configFactoryMockedStatic = mockStatic(ConfigFactory.class);
var clientSSLContextFactoryMockedStatic = mockStatic(ClientSSLContextFactory.class)) {
ConfigFactory configFactory = mock(ConfigFactory.class);
Config config = mock(Config.class);
ServerConfig serverConfig = mock(ServerConfig.class);
when(config.getP2PServerConfig()).thenReturn(serverConfig);
when(configFactory.getConfig()).thenReturn(config);
configFactoryMockedStatic.when(ConfigFactory::create).thenReturn(configFactory);
clientSSLContextFactoryMockedStatic.when(ClientSSLContextFactory::create).thenReturn(mock(ClientSSLContextFactory.class));
RecoveryClient recoveryClient = RecoveryClientProvider.provider();
assertThat(recoveryClient).isNotNull().isExactlyInstanceOf(RestRecoveryClient.class);
clientSSLContextFactoryMockedStatic.verify(ClientSSLContextFactory::create);
clientSSLContextFactoryMockedStatic.verifyNoMoreInteractions();
configFactoryMockedStatic.verify(ConfigFactory::create);
configFactoryMockedStatic.verifyNoMoreInteractions();
}
}
use of com.quorum.tessera.ssl.context.ClientSSLContextFactory in project tessera by ConsenSys.
the class P2pClientProvider method provider.
public static P2pClient provider() {
Config config = ConfigFactory.create().getConfig();
SSLContextFactory clientSSLContextFactory = ClientSSLContextFactory.create();
ClientFactory clientFactory = new ClientFactory(clientSSLContextFactory);
Client client = clientFactory.buildFrom(config.getP2PServerConfig());
return new RestP2pClient(client);
}
use of com.quorum.tessera.ssl.context.ClientSSLContextFactory in project tessera by ConsenSys.
the class RecoveryClientProvider method provider.
public static RecoveryClient provider() {
final Config config = ConfigFactory.create().getConfig();
final ServerConfig serverConfig = config.getP2PServerConfig();
final Map<String, String> properties = serverConfig.getProperties();
final String waitTime = new IntervalPropertyHelper(properties).resendWaitTime();
final SSLContextFactory clientSSLContextFactory = ClientSSLContextFactory.create();
final ClientFactory clientFactory = new ClientFactory(clientSSLContextFactory);
final Client client = clientFactory.buildFrom(config.getP2PServerConfig());
client.property("jersey.config.client.readTimeout", waitTime);
return new RestRecoveryClient(client);
}
use of com.quorum.tessera.ssl.context.ClientSSLContextFactory in project tessera by ConsenSys.
the class ResendClientProvider method provider.
public static ResendClient provider() {
final Config config = ConfigFactory.create().getConfig();
final ServerConfig serverConfig = config.getP2PServerConfig();
final Map<String, String> properties = serverConfig.getProperties();
final String waitTime = new IntervalPropertyHelper(properties).resendWaitTime();
final SSLContextFactory clientSSLContextFactory = ClientSSLContextFactory.create();
final ClientFactory clientFactory = new ClientFactory(clientSSLContextFactory);
final Client client = clientFactory.buildFrom(config.getP2PServerConfig());
client.property("jersey.config.client.readTimeout", waitTime);
return new RestResendClient(client);
}
Aggregations