use of org.mockito.internal.verification.AtLeast in project x-pipe by ctripcorp.
the class OneThreadTaskExecutorTest method testClose.
@Test
public void testClose() throws Exception {
CommandFuture<Void> future = new DefaultCommandFuture<>();
when(command.execute()).thenReturn(future);
future.setFailure(new Exception());
RetryCommandFactory<Void> retryCommandFactory = DefaultRetryCommandFactory.retryForever(scheduled, 0);
OneThreadTaskExecutor oneThreadTaskExecutor = new OneThreadTaskExecutor(retryCommandFactory, executors);
oneThreadTaskExecutor.executeCommand(command);
sleep(100);
logger.info("[testClose][destroy]");
oneThreadTaskExecutor.destroy();
retryCommandFactory.destroy();
sleep(50);
verify(command, new AtLeast(1)).execute();
verify(command, new AtLeast(1)).reset();
logger.info("[testClose][sleep verify no more interactions]");
sleep(100);
verifyNoMoreInteractions(command);
}
use of org.mockito.internal.verification.AtLeast in project hazelcast by hazelcast.
the class ClientDiscoverySpiTest method test_CustomDiscoveryService_whenDiscoveredNodes_isEmpty.
@Test
public void test_CustomDiscoveryService_whenDiscoveredNodes_isEmpty() {
ClientConfig config = new ClientConfig();
config.setProperty(ClusterProperty.DISCOVERY_SPI_ENABLED.getName(), "true");
final DiscoveryService discoveryService = mock(DiscoveryService.class);
when(discoveryService.discoverNodes()).thenReturn(Collections.emptyList());
DiscoveryServiceProvider discoveryServiceProvider = arg0 -> discoveryService;
ClientNetworkConfig networkConfig = config.getNetworkConfig();
config.getConnectionStrategyConfig().getConnectionRetryConfig().setClusterConnectTimeoutMillis(0);
networkConfig.getDiscoveryConfig().addDiscoveryStrategyConfig(new DiscoveryStrategyConfig());
networkConfig.getDiscoveryConfig().setDiscoveryServiceProvider(discoveryServiceProvider);
try {
HazelcastClient.newHazelcastClient(config);
} catch (IllegalStateException expected) {
// no server available
}
verify(discoveryService, new AtLeast(1)).discoverNodes();
}
Aggregations