/** * Resolves an endpoint and asserts that it is found */ public static <T extends Endpoint> T resolveMandatoryEndpoint(CamelContext context, String uri, Class<T> endpointType) { T endpoint = context.getEndpoint(uri, endpointType); assertNotNull("No endpoint found for URI: " + uri, endpoint); return endpoint; }
/** * Resolves an endpoint and asserts that it is found */ public static <T extends Endpoint> T resolveMandatoryEndpoint(CamelContext context, String uri, Class<T> endpointType) { T endpoint = context.getEndpoint(uri, endpointType); assertNotNull("No endpoint found for URI: " + uri, endpoint); return endpoint; }
/** * Resolves an endpoint and asserts that it is found */ public static Endpoint resolveMandatoryEndpoint(CamelContext context, String uri) { Endpoint endpoint = context.getEndpoint(uri); assertNotNull("No endpoint found for URI: " + uri, endpoint); return endpoint; }
/** * Resolves an endpoint and asserts that it is found */ public static Endpoint resolveMandatoryEndpoint(CamelContext context, String uri) { Endpoint endpoint = context.getEndpoint(uri); assertNotNull("No endpoint found for URI: " + uri, endpoint); return endpoint; }
endpoint = camelContext.getRegistry().lookupByNameAndType(getServiceRef(), Endpoint.class); } else { endpoint = camelContext.getEndpoint(getServiceUrl());
/** * Creates endpoint instance from given model. * * @param model Endpoint configuration model (will be used to obtain uri). * @param enpointType Expected endpoint type. * @return Endpoint instance created with model URI. */ protected <E extends Endpoint> E getEndpoint(CamelBindingModel model, Class<E> enpointType) { String configUri = model.getComponentURI().toString(); return context.getEndpoint(configUri, enpointType); }
public MasterEndpoint(String uri, MasterComponent component, String groupName, String consumerEndpointUri) { super(uri, component); this.component = component; this.groupName = groupName; this.consumerEndpointUri = consumerEndpointUri; this.consumerEndpoint = getCamelContext().getEndpoint(consumerEndpointUri); }
public VelocityEndpoint findOrCreateEndpoint(String uri, String newResourceUri) { String newUri = uri.replace(getResourceUri(), newResourceUri); log.debug("Getting endpoint with URI: {}", newUri); return getCamelContext().getEndpoint(newUri, VelocityEndpoint.class); }
public MvelEndpoint findOrCreateEndpoint(String uri, String newResourceUri) { String newUri = uri.replace(getResourceUri(), newResourceUri); log.debug("Getting endpoint with URI: {}", newUri); return getCamelContext().getEndpoint(newUri, MvelEndpoint.class); }
Producer createProducerFor(final Swagger swagger, final Operation operation, final String method, final String uriTemplate) throws Exception { final String basePath = determineBasePath(swagger); final StringBuilder componentEndpointUri = new StringBuilder(200).append("rest:").append(method).append(":") .append(basePath).append(":").append(uriTemplate); final CamelContext camelContext = getCamelContext(); final Endpoint endpoint = camelContext.getEndpoint(componentEndpointUri.toString()); setProperties(endpoint, determineEndpointParameters(swagger, operation)); return endpoint.createProducer(); }
public void validate(CamelContext context) { //check if a route Object result = context.getRouteDefinition(fromId); if (result == null) { //check if an endpoint result = context.getEndpoint(fromId); } if (result == null) { throw new RuntimeCamelException("Failed to find RouteDefinition with id: " + fromId); } }
public void testManageTracer() throws Exception { System.out.println("Connect to JConsole and try managing Tracer by enabling and disabling it on individual routes"); MockEndpoint mock = context.getEndpoint("jms:queue:orders", MockEndpoint.class); mock.expectedMessageCount(100); for (int i = 0; i < 100; i++) { template.sendBody("file://target/rider/orders", "" + i + ",4444,20100110,222,1"); } mock.await(100 * 10, TimeUnit.SECONDS); System.out.println("Complete sending 100 files will stop now"); }
@Produces @Typed(MockEndpoint.class) // Qualifiers are dynamically added in CdiCamelExtension private static MockEndpoint mockEndpointFromMember(InjectionPoint ip, @Any Instance<CamelContext> instance, CdiCamelExtension extension) { String uri = "mock:" + ip.getMember().getName(); try { return selectContext(ip, instance, extension).getEndpoint(uri, MockEndpoint.class); } catch (Exception cause) { throw new InjectionException("Error injecting mock endpoint into " + ip, cause); } }
@Override protected void doStart() throws Exception { jsonMarshalEndpoint = getCamelContext().getEndpoint("dataformat:json-jackson:marshal"); Objects.requireNonNull(jsonMarshalEndpoint, "jsonMarshalEndpoint"); jsonMarshalProducer = jsonMarshalEndpoint.createProducer(); Objects.requireNonNull(jsonMarshalProducer, "jsonMarshalProducer"); ServiceHelper.startServices(jsonMarshalEndpoint, jsonMarshalProducer); super.doStart(); }
@Test public void testSend() throws Exception { assertThat(context.getBean("my-bean", MyBean.class)).isNotNull(); final ProducerTemplate template = camelContext.createProducerTemplate(); final MockEndpoint mock = camelContext.getEndpoint("mock:result", MockEndpoint.class); final String body = "hello"; final String expected = Base64.getEncoder().encodeToString("HELLO WORLD!".toUpperCase().getBytes(StandardCharsets.US_ASCII)); mock.expectedMessageCount(1); mock.expectedBodiesReceived(expected); template.sendBody("direct:start", body); mock.assertIsSatisfied(); }
@Test public void testSend() throws Exception { assertThat(context.getBean("my-bean", MyBean.class)).isNotNull(); final ProducerTemplate template = camelContext.createProducerTemplate(); final MockEndpoint mock = camelContext.getEndpoint("mock:result", MockEndpoint.class); final String body = "hello"; final String expected = Base64.getEncoder().encodeToString("HELLO WORLD!".toUpperCase().getBytes(StandardCharsets.US_ASCII)); mock.expectedMessageCount(1); mock.expectedBodiesReceived(expected); template.sendBody("direct:start", body); mock.assertIsSatisfied(); }
@Test public void testSend() throws Exception { assertThat(context.getBean("my-bean", MyBean.class)).isNotNull(); final ProducerTemplate template = camelContext.createProducerTemplate(); final MockEndpoint mock = camelContext.getEndpoint("mock:result", MockEndpoint.class); final String body = "hello"; final String expected = Base64.getEncoder().encodeToString("HELLO WORLD!".toUpperCase().getBytes(StandardCharsets.US_ASCII)); mock.expectedMessageCount(1); mock.expectedBodiesReceived(expected); template.sendBody("direct:start", body); mock.assertIsSatisfied(); }
@Override protected void doStart() throws Exception { String url = getEndpoint().getUrl() + "?authUsername=" + getEndpoint().getUsername() + "&authPassword=" + getEndpoint().getPassword() + "&authMethod=Basic"; if (log.isInfoEnabled()) { log.info("Creating NetWeaverProducer using url: {}", URISupport.sanitizeUri(url)); } http = getEndpoint().getCamelContext().getEndpoint(url).createProducer(); ServiceHelper.startService(http); }
@Test public void testSplit() throws InterruptedException { final ProducerTemplate template = camelContext.createProducerTemplate(); final MockEndpoint mock = camelContext.getEndpoint("mock:result", MockEndpoint.class); final String values = "a,b,c"; final String[] result = values.split(","); mock.expectedMessageCount(result.length); mock.expectedBodiesReceived((Object[])result); template.sendBody("direct:start", values); mock.assertIsSatisfied(); }
@Test public void testSplit() throws InterruptedException { final ProducerTemplate template = camelContext.createProducerTemplate(); final MockEndpoint mock = camelContext.getEndpoint("mock:result", MockEndpoint.class); final String[] values = { "a","b","c" }; mock.expectedMessageCount(values.length); mock.expectedBodiesReceived((Object[])values); template.sendBody("direct:start", Arrays.asList(values)); mock.assertIsSatisfied(); }