Search in sources :

Example 1 with DefaultHeaderChannelRegistry

use of org.springframework.integration.channel.DefaultHeaderChannelRegistry in project spring-integration by spring-projects.

the class HeaderChannelRegistryTests method testExpire.

@Test
public void testExpire() throws Exception {
    DefaultHeaderChannelRegistry registry = new DefaultHeaderChannelRegistry(50);
    registry.setTaskScheduler(this.taskScheduler);
    String id = (String) registry.channelToChannelName(new DirectChannel());
    int n = 0;
    while (n++ < 100 && registry.channelNameToChannel(id) != null) {
        Thread.sleep(100);
    }
    assertNull(registry.channelNameToChannel(id));
    registry.stop();
}
Also used : DirectChannel(org.springframework.integration.channel.DirectChannel) DefaultHeaderChannelRegistry(org.springframework.integration.channel.DefaultHeaderChannelRegistry) Test(org.junit.Test)

Example 2 with DefaultHeaderChannelRegistry

use of org.springframework.integration.channel.DefaultHeaderChannelRegistry in project spring-integration by spring-projects.

the class HeaderChannelRegistryTests method testRemoveOnGet.

@Test
public void testRemoveOnGet() {
    DefaultHeaderChannelRegistry registry = new DefaultHeaderChannelRegistry();
    MessageChannel channel = new DirectChannel();
    String foo = (String) registry.channelToChannelName(channel);
    Map<?, ?> map = TestUtils.getPropertyValue(registry, "channels", Map.class);
    assertEquals(1, map.size());
    assertSame(channel, registry.channelNameToChannel(foo));
    assertEquals(1, map.size());
    registry.setRemoveOnGet(true);
    assertSame(channel, registry.channelNameToChannel(foo));
    assertEquals(0, map.size());
}
Also used : MessageChannel(org.springframework.messaging.MessageChannel) DirectChannel(org.springframework.integration.channel.DirectChannel) DefaultHeaderChannelRegistry(org.springframework.integration.channel.DefaultHeaderChannelRegistry) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 DefaultHeaderChannelRegistry (org.springframework.integration.channel.DefaultHeaderChannelRegistry)2 DirectChannel (org.springframework.integration.channel.DirectChannel)2 MessageChannel (org.springframework.messaging.MessageChannel)1