Search in sources :

Example 1 with AbstractMessageSource

use of org.springframework.integration.endpoint.AbstractMessageSource in project spring-integration by spring-projects.

the class IntegrationManagementConfigurerTests method testDefaults.

@Test
public void testDefaults() {
    DirectChannel channel = new DirectChannel();
    AbstractMessageHandler handler = new RecipientListRouter();
    AbstractMessageSource<?> source = new AbstractMessageSource<Object>() {

        @Override
        public String getComponentType() {
            return null;
        }

        @Override
        protected Object doReceive() {
            return null;
        }
    };
    assertTrue(channel.isLoggingEnabled());
    assertTrue(handler.isLoggingEnabled());
    assertTrue(source.isLoggingEnabled());
    channel.setCountsEnabled(true);
    channel.setStatsEnabled(true);
    ApplicationContext ctx = mock(ApplicationContext.class);
    Map<String, IntegrationManagement> beans = new HashMap<String, IntegrationManagement>();
    beans.put("foo", channel);
    beans.put("bar", handler);
    beans.put("baz", source);
    when(ctx.getBeansOfType(IntegrationManagement.class)).thenReturn(beans);
    IntegrationManagementConfigurer configurer = new IntegrationManagementConfigurer();
    configurer.setBeanName(IntegrationManagementConfigurer.MANAGEMENT_CONFIGURER_NAME);
    configurer.setApplicationContext(ctx);
    configurer.setDefaultLoggingEnabled(false);
    configurer.afterSingletonsInstantiated();
    assertFalse(channel.isLoggingEnabled());
    assertFalse(handler.isLoggingEnabled());
    assertFalse(source.isLoggingEnabled());
    assertTrue(channel.isCountsEnabled());
    assertTrue(channel.isStatsEnabled());
}
Also used : IntegrationManagementConfigurer(org.springframework.integration.config.IntegrationManagementConfigurer) ApplicationContext(org.springframework.context.ApplicationContext) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) DirectChannel(org.springframework.integration.channel.DirectChannel) HashMap(java.util.HashMap) EnableIntegrationManagement(org.springframework.integration.config.EnableIntegrationManagement) RecipientListRouter(org.springframework.integration.router.RecipientListRouter) AbstractMessageSource(org.springframework.integration.endpoint.AbstractMessageSource) AbstractMessageHandler(org.springframework.integration.handler.AbstractMessageHandler) Test(org.junit.Test)

Aggregations

HashMap (java.util.HashMap)1 Test (org.junit.Test)1 ApplicationContext (org.springframework.context.ApplicationContext)1 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)1 DirectChannel (org.springframework.integration.channel.DirectChannel)1 EnableIntegrationManagement (org.springframework.integration.config.EnableIntegrationManagement)1 IntegrationManagementConfigurer (org.springframework.integration.config.IntegrationManagementConfigurer)1 AbstractMessageSource (org.springframework.integration.endpoint.AbstractMessageSource)1 AbstractMessageHandler (org.springframework.integration.handler.AbstractMessageHandler)1 RecipientListRouter (org.springframework.integration.router.RecipientListRouter)1