/* * @see DATAREDIS-415 */ @Test public void interruptAtStart() throws Exception { final Thread main = Thread.currentThread(); // interrupt thread once Executor.execute is called doAnswer( new Answer<Object>() { @Override public Object answer(final InvocationOnMock invocationOnMock) throws Throwable { main.interrupt(); return null; } }) .when(executorMock) .execute(any(Runnable.class)); container.addMessageListener(adapter, new ChannelTopic("a")); container.start(); // reset the interrupted flag to not destroy the teardown assertThat(Thread.interrupted(), is(true)); assertThat(container.isRunning(), is(false)); }
@Before public void setUp() throws Exception { executorMock = mock(Executor.class); connectionFactory = new JedisConnectionFactory(); connectionFactory.setPort(SettingsUtils.getPort()); connectionFactory.setHostName(SettingsUtils.getHost()); connectionFactory.setDatabase(2); connectionFactory.afterPropertiesSet(); container = new RedisMessageListenerContainer(); container.setConnectionFactory(connectionFactory); container.setBeanName("container"); container.setTaskExecutor(new SyncTaskExecutor()); container.setSubscriptionExecutor(executorMock); container.afterPropertiesSet(); }
@After public void tearDown() throws Exception { container.destroy(); connectionFactory.destroy(); }