DirectEndpointComponent extends AbstractEndpointComponent { @Override protected Endpoint createEndpoint(String resourcePath, Map<String, String> parameters, TestContext context) { DirectEndpoint endpoint; final String queueName; if (resourcePath.startsWith("sync:")) { DirectSyncEndpointConfiguration endpointConfiguration = new DirectSyncEndpointConfiguration(); endpoint = new DirectSyncEndpoint(endpointConfiguration); queueName = resourcePath.substring("sync:".length()); } else { endpoint = new DirectEndpoint(); queueName = resourcePath; } endpoint.getEndpointConfiguration().setQueueName(queueName); if (!context.getReferenceResolver().isResolvable(queueName)) { context.getReferenceResolver().bind(queueName, new DefaultMessageQueue(queueName)); } enrichEndpointConfiguration(endpoint.getEndpointConfiguration(), parameters, context); return endpoint; } DirectEndpointComponent();   }
@Test public void testCreateDirectEndpoint() throws Exception { DirectEndpointComponent component = new DirectEndpointComponent(); Assert.assertFalse(context.getReferenceResolver().isResolvable("queueName")); Endpoint endpoint = component.createEndpoint("direct:queueName", context); Assert.assertEquals(endpoint.getClass(), DirectEndpoint.class); Assert.assertEquals(((DirectEndpoint)endpoint).getEndpointConfiguration().getQueueName(), "queueName"); Assert.assertEquals(((DirectEndpoint) endpoint).getEndpointConfiguration().getTimeout(), 5000L); Assert.assertTrue(context.getReferenceResolver().isResolvable("queueName")); }
@Test public void testCreateSyncDirectEndpoint() throws Exception { DirectEndpointComponent component = new DirectEndpointComponent(); Assert.assertFalse(context.getReferenceResolver().isResolvable("queueName")); Endpoint endpoint = component.createEndpoint("direct:sync:queueName", context); Assert.assertEquals(endpoint.getClass(), DirectSyncEndpoint.class); Assert.assertEquals(((DirectSyncEndpoint)endpoint).getEndpointConfiguration().getQueueName(), "queueName"); Assert.assertTrue(context.getReferenceResolver().isResolvable("queueName")); }
@Test public void testCreateDirectEndpointWithParameters() throws Exception { DirectEndpointComponent component = new DirectEndpointComponent(); Endpoint endpoint = component.createEndpoint("direct:queueName?timeout=10000", context); Assert.assertEquals(endpoint.getClass(), DirectEndpoint.class); Assert.assertEquals(((DirectEndpoint)endpoint).getEndpointConfiguration().getQueueName(), "queueName"); Assert.assertEquals(((DirectEndpoint) endpoint).getEndpointConfiguration().getTimeout(), 10000L); }