ChannelEndpointComponent extends AbstractEndpointComponent { @Override protected Endpoint createEndpoint(String resourcePath, Map<String, String> parameters, TestContext context) { ChannelEndpoint endpoint; if (resourcePath.startsWith("sync:")) { ChannelSyncEndpointConfiguration endpointConfiguration = new ChannelSyncEndpointConfiguration(); endpoint = new ChannelSyncEndpoint(endpointConfiguration); endpoint.getEndpointConfiguration().setChannelName(resourcePath.substring("sync:".length())); } else { endpoint = new ChannelEndpoint(); endpoint.getEndpointConfiguration().setChannelName(resourcePath); } if (context.getReferenceResolver() != null) { endpoint.getEndpointConfiguration().setChannelResolver(channelName -> context.getReferenceResolver().resolve(channelName, MessageChannel.class)); } enrichEndpointConfiguration(endpoint.getEndpointConfiguration(), parameters, context); return endpoint; } ChannelEndpointComponent();   }
@Test public void testCreateChannelEndpoint() throws Exception { ChannelEndpointComponent component = new ChannelEndpointComponent(); reset(referenceResolver); Endpoint endpoint = component.createEndpoint("channel:channelName", context); Assert.assertEquals(endpoint.getClass(), ChannelEndpoint.class); Assert.assertEquals(((ChannelEndpoint)endpoint).getEndpointConfiguration().getChannelName(), "channelName"); Assert.assertNull(((ChannelEndpoint) endpoint).getEndpointConfiguration().getBeanFactory()); Assert.assertNotNull(((ChannelEndpoint) endpoint).getEndpointConfiguration().getChannelResolver()); Assert.assertEquals(((ChannelEndpoint) endpoint).getEndpointConfiguration().getTimeout(), 5000L); }
@Test public void testCreateSyncChannelEndpoint() throws Exception { ChannelEndpointComponent component = new ChannelEndpointComponent(); reset(referenceResolver); Endpoint endpoint = component.createEndpoint("channel:sync:channelName", context); Assert.assertEquals(endpoint.getClass(), ChannelSyncEndpoint.class); Assert.assertEquals(((ChannelSyncEndpoint)endpoint).getEndpointConfiguration().getChannelName(), "channelName"); Assert.assertNull(((ChannelEndpoint) endpoint).getEndpointConfiguration().getBeanFactory()); Assert.assertNotNull(((ChannelEndpoint) endpoint).getEndpointConfiguration().getChannelResolver()); }
@Test public void testCreateChannelEndpointWithParameters() throws Exception { ChannelEndpointComponent component = new ChannelEndpointComponent(); reset(referenceResolver); when(referenceResolver.isResolvable("myChannelResolver")).thenReturn(true); when(referenceResolver.resolve("myChannelResolver", DestinationResolver.class)).thenReturn(channelResolver); Endpoint endpoint = component.createEndpoint("channel:channelName?timeout=10000&channelResolver=myChannelResolver", context); Assert.assertEquals(endpoint.getClass(), ChannelEndpoint.class); Assert.assertEquals(((ChannelEndpoint)endpoint).getEndpointConfiguration().getChannelName(), "channelName"); Assert.assertNull(((ChannelEndpoint) endpoint).getEndpointConfiguration().getBeanFactory()); Assert.assertEquals(((ChannelEndpoint) endpoint).getEndpointConfiguration().getChannelResolver(), channelResolver); Assert.assertEquals(((ChannelEndpoint) endpoint).getEndpointConfiguration().getTimeout(), 10000L); }