use of org.finra.herd.core.helper.ConfigurationHelper in project herd by FINRAOS.
the class SampleDataJmsMessageListenerTest method testControlListener.
@Test
public void testControlListener() {
configurationHelper = Mockito.mock(ConfigurationHelper.class);
ReflectionTestUtils.setField(sampleDataJmsMessageListener, "configurationHelper", configurationHelper);
MessageListenerContainer mockMessageListenerContainer = Mockito.mock(MessageListenerContainer.class);
// The listener is not enabled
when(configurationHelper.getProperty(ConfigurationValue.SAMPLE_DATA_JMS_LISTENER_ENABLED)).thenReturn("false");
JmsListenerEndpointRegistry registry = ApplicationContextHolder.getApplicationContext().getBean("org.springframework.jms.config.internalJmsListenerEndpointRegistry", JmsListenerEndpointRegistry.class);
when(registry.getListenerContainer(HerdJmsDestinationResolver.SQS_DESTINATION_SAMPLE_DATA_QUEUE)).thenReturn(mockMessageListenerContainer);
// the listener is not running, nothing happened
when(mockMessageListenerContainer.isRunning()).thenReturn(false);
sampleDataJmsMessageListener.controlSampleDataJmsMessageListener();
verify(mockMessageListenerContainer, Mockito.times(0)).stop();
verify(mockMessageListenerContainer, Mockito.times(0)).start();
// the listener is running, but it is not enable, should stop
when(mockMessageListenerContainer.isRunning()).thenReturn(true);
sampleDataJmsMessageListener.controlSampleDataJmsMessageListener();
verify(mockMessageListenerContainer).stop();
// The listener is enabled
when(configurationHelper.getProperty(ConfigurationValue.SAMPLE_DATA_JMS_LISTENER_ENABLED)).thenReturn("true");
// the listener is running, should not call the start method
when(mockMessageListenerContainer.isRunning()).thenReturn(true);
sampleDataJmsMessageListener.controlSampleDataJmsMessageListener();
verify(mockMessageListenerContainer, Mockito.times(0)).start();
// the listener is not running, but it is enabled, should start
when(mockMessageListenerContainer.isRunning()).thenReturn(false);
sampleDataJmsMessageListener.controlSampleDataJmsMessageListener();
verify(mockMessageListenerContainer).start();
}
use of org.finra.herd.core.helper.ConfigurationHelper in project herd by FINRAOS.
the class HerdJmsMessageListenerTest method testControlListener.
@Test
public void testControlListener() {
configurationHelper = Mockito.mock(ConfigurationHelper.class);
ReflectionTestUtils.setField(herdJmsMessageListener, "configurationHelper", configurationHelper);
MessageListenerContainer mockMessageListenerContainer = Mockito.mock(MessageListenerContainer.class);
// The listener is not enabled
when(configurationHelper.getProperty(ConfigurationValue.JMS_LISTENER_ENABLED)).thenReturn("false");
JmsListenerEndpointRegistry registry = ApplicationContextHolder.getApplicationContext().getBean("org.springframework.jms.config.internalJmsListenerEndpointRegistry", JmsListenerEndpointRegistry.class);
when(registry.getListenerContainer(HerdJmsDestinationResolver.SQS_DESTINATION_HERD_INCOMING)).thenReturn(mockMessageListenerContainer);
// the listener is not running, nothing happened
when(mockMessageListenerContainer.isRunning()).thenReturn(false);
herdJmsMessageListener.controlHerdJmsMessageListener();
verify(mockMessageListenerContainer, Mockito.times(0)).stop();
verify(mockMessageListenerContainer, Mockito.times(0)).start();
// the listener is running, but it is not enable, should stop
when(mockMessageListenerContainer.isRunning()).thenReturn(true);
herdJmsMessageListener.controlHerdJmsMessageListener();
verify(mockMessageListenerContainer).stop();
// The listener is enabled
when(configurationHelper.getProperty(ConfigurationValue.JMS_LISTENER_ENABLED)).thenReturn("true");
// the listener is running, should not call the start method
when(mockMessageListenerContainer.isRunning()).thenReturn(true);
herdJmsMessageListener.controlHerdJmsMessageListener();
verify(mockMessageListenerContainer, Mockito.times(0)).start();
// the listener is not running, but it is enabled, should start
when(mockMessageListenerContainer.isRunning()).thenReturn(false);
herdJmsMessageListener.controlHerdJmsMessageListener();
verify(mockMessageListenerContainer).start();
}
use of org.finra.herd.core.helper.ConfigurationHelper in project herd by FINRAOS.
the class StoragePolicyProcessorJmsMessageListenerTest method testControlListener.
@Test
public void testControlListener() {
configurationHelper = Mockito.mock(ConfigurationHelper.class);
ReflectionTestUtils.setField(storagePolicyProcessorJmsMessageListener, "configurationHelper", configurationHelper);
MessageListenerContainer mockMessageListenerContainer = Mockito.mock(MessageListenerContainer.class);
// The listener is not enabled
when(configurationHelper.getProperty(ConfigurationValue.STORAGE_POLICY_PROCESSOR_JMS_LISTENER_ENABLED)).thenReturn("false");
JmsListenerEndpointRegistry registry = ApplicationContextHolder.getApplicationContext().getBean("org.springframework.jms.config.internalJmsListenerEndpointRegistry", JmsListenerEndpointRegistry.class);
when(registry.getListenerContainer(HerdJmsDestinationResolver.SQS_DESTINATION_STORAGE_POLICY_SELECTOR_JOB_SQS_QUEUE)).thenReturn(mockMessageListenerContainer);
// the listener is not running, nothing happened
when(mockMessageListenerContainer.isRunning()).thenReturn(false);
storagePolicyProcessorJmsMessageListener.controlStoragePolicyProcessorJmsMessageListener();
verify(mockMessageListenerContainer, Mockito.times(0)).stop();
verify(mockMessageListenerContainer, Mockito.times(0)).start();
// the listener is running, but it is not enable, should stop
when(mockMessageListenerContainer.isRunning()).thenReturn(true);
storagePolicyProcessorJmsMessageListener.controlStoragePolicyProcessorJmsMessageListener();
verify(mockMessageListenerContainer).stop();
// The listener is enabled
when(configurationHelper.getProperty(ConfigurationValue.STORAGE_POLICY_PROCESSOR_JMS_LISTENER_ENABLED)).thenReturn("true");
// the listener is running, should not call the start method
when(mockMessageListenerContainer.isRunning()).thenReturn(true);
storagePolicyProcessorJmsMessageListener.controlStoragePolicyProcessorJmsMessageListener();
verify(mockMessageListenerContainer, Mockito.times(0)).start();
// the listener is not running, but it is enabled, should start
when(mockMessageListenerContainer.isRunning()).thenReturn(false);
storagePolicyProcessorJmsMessageListener.controlStoragePolicyProcessorJmsMessageListener();
verify(mockMessageListenerContainer).start();
}
Aggregations