use of com.quorum.tessera.config.Config in project tessera by ConsenSys.
the class EnclaveProviderTest method provider.
@Test
public void provider() {
try (var staticConfigFactory = mockStatic(ConfigFactory.class)) {
ConfigFactory configFactory = mock(ConfigFactory.class);
// FIXME: Having to use proper config object rather than mock
Config config = JaxbUtil.unmarshal(getClass().getResourceAsStream("/sample.json"), Config.class);
when(configFactory.getConfig()).thenReturn(config);
staticConfigFactory.when(ConfigFactory::create).thenReturn(configFactory);
Enclave enclave = EnclaveProvider.provider();
assertThat(enclave).isNotNull();
assertThat(enclave).describedAs("Second call should return cached/held instance").isSameAs(EnclaveProvider.provider());
}
}
use of com.quorum.tessera.config.Config in project tessera by ConsenSys.
the class EnclaveServerProviderTest method provider.
@Test
public void provider() {
try (var configFactoryMockedStatic = mockStatic(ConfigFactory.class);
var enclaveFactoryMockedStatic = mockStatic(EnclaveFactoryImpl.class)) {
ConfigFactory configFactory = mock(ConfigFactory.class);
Config config = mock(Config.class);
when(configFactory.getConfig()).thenReturn(config);
Enclave enclave = mock(Enclave.class);
enclaveFactoryMockedStatic.when(() -> EnclaveFactoryImpl.createServer(config)).thenReturn(enclave);
configFactoryMockedStatic.when(ConfigFactory::create).thenReturn(configFactory);
EnclaveServer result = EnclaveServerProvider.provider();
assertThat(result).isExactlyInstanceOf(EnclaveServerImpl.class);
enclaveFactoryMockedStatic.verify(() -> EnclaveFactoryImpl.createServer(config));
enclaveFactoryMockedStatic.verifyNoMoreInteractions();
verify(configFactory).getConfig();
verifyNoMoreInteractions(configFactory);
configFactoryMockedStatic.verify(ConfigFactory::create);
configFactoryMockedStatic.verifyNoMoreInteractions();
}
}
use of com.quorum.tessera.config.Config in project tessera by ConsenSys.
the class ConfigHolderTest method setGetConfig.
@Test
public void setGetConfig() {
ConfigHolder hdler = ConfigHolder.INSTANCE;
Config config = mock(Config.class);
hdler.setConfig(config);
assertThat(hdler.getConfig()).isSameAs(config);
}
use of com.quorum.tessera.config.Config in project tessera by ConsenSys.
the class ConfigFileStoreTest method save.
@Test
public void save() throws IOException {
Config config = new Config();
config.setJdbcConfig(new JdbcConfig());
config.getJdbcConfig().setUsername("JUNIT");
configFileStore.save(config);
Config result = JaxbUtil.unmarshal(Files.newInputStream(path), Config.class);
assertThat(result.getJdbcConfig().getUsername()).isEqualTo("JUNIT");
}
use of com.quorum.tessera.config.Config in project tessera by ConsenSys.
the class PayloadDigest method create.
static PayloadDigest create() {
Config config = ConfigFactory.create().getConfig();
// FIXME:
final Class implType;
if (config.getClientMode() == ClientMode.ORION) {
implType = SHA512256PayloadDigest.class;
} else {
implType = DefaultPayloadDigest.class;
}
return ServiceLoader.load(PayloadDigest.class).stream().filter(payloadDigestProvider -> payloadDigestProvider.type() == implType).map(ServiceLoader.Provider::get).findFirst().get();
}
Aggregations