use of org.apache.camel.Endpoint in project camel by apache.
the class SpringJmsClientServerTest method testCamelEndpointInvocation.
@Test
public void testCamelEndpointInvocation() throws Exception {
// get the endpoint from the camel context
Endpoint endpoint = context.getEndpoint("jms:queue:numbers");
// create the exchange used for the communication
// we use the in out pattern for a synchronized exchange where we expect a response
Exchange exchange = endpoint.createExchange(ExchangePattern.InOut);
// set the input on the in body
// must you correct type to match the expected type of an Integer object
exchange.getIn().setBody(11);
// to send the exchange we need an producer to do it for us
Producer producer = endpoint.createProducer();
// start the producer so it can operate
producer.start();
// let the producer process the exchange where it does all the work in this one line of code
producer.process(exchange);
// get the response from the out body and cast it to an integer
int response = exchange.getOut().getBody(Integer.class);
assertEquals("Get a wrong response.", 33, response);
// stop the producer after usage
producer.stop();
}
use of org.apache.camel.Endpoint in project camel by apache.
the class AbstractLocalCamelController method getEndpoints.
public List<Map<String, String>> getEndpoints(String camelContextName) throws Exception {
List<Map<String, String>> answer = new ArrayList<Map<String, String>>();
if (camelContextName != null) {
CamelContext context = this.getLocalCamelContext(camelContextName);
if (context != null) {
List<Endpoint> endpoints = new ArrayList<Endpoint>(context.getEndpoints());
// sort routes
Collections.sort(endpoints, new Comparator<Endpoint>() {
@Override
public int compare(Endpoint o1, Endpoint o2) {
return o1.getEndpointKey().compareTo(o2.getEndpointKey());
}
});
for (Endpoint endpoint : endpoints) {
Map<String, String> row = new LinkedHashMap<String, String>();
row.put("camelContextName", context.getName());
row.put("uri", endpoint.getEndpointUri());
row.put("state", getEndpointState(endpoint));
answer.add(row);
}
}
}
return answer;
}
use of org.apache.camel.Endpoint in project camel by apache.
the class MongoDbReadPreferenceOptionTest method createMongoDbEndpoint.
private MongoDbEndpoint createMongoDbEndpoint(String uri) throws Exception {
Endpoint endpoint = context().getComponent("mongodb").createEndpoint(uri);
endpoint.start();
return (MongoDbEndpoint) endpoint;
}
use of org.apache.camel.Endpoint in project camel by apache.
the class MQTTConfigurationTest method testBasicConfiguration.
@Test
public void testBasicConfiguration() throws Exception {
Endpoint endpoint = context.getEndpoint("mqtt:todo?byDefaultRetain=true&qualityOfService=exactlyOnce&publishTopicName=" + TEST_TOPIC + "&subscribeTopicName=" + TEST_TOPIC + "&host=" + MQTTTestSupport.getHostForMQTTEndpoint());
assertTrue("Endpoint not a MQTTEndpoint: " + endpoint, endpoint instanceof MQTTEndpoint);
MQTTEndpoint mqttEndpoint = (MQTTEndpoint) endpoint;
assertEquals(mqttEndpoint.getConfiguration().getQoS(), QoS.EXACTLY_ONCE);
assertEquals(mqttEndpoint.getConfiguration().getPublishTopicName(), TEST_TOPIC);
assertEquals(mqttEndpoint.getConfiguration().getSubscribeTopicName(), TEST_TOPIC);
assertTrue(mqttEndpoint.getConfiguration().isByDefaultRetain());
}
use of org.apache.camel.Endpoint in project camel by apache.
the class AbstractSpanDecoratorTest method testStripSchemeNoOptions.
@Test
public void testStripSchemeNoOptions() {
Endpoint endpoint = Mockito.mock(Endpoint.class);
Mockito.when(endpoint.getEndpointUri()).thenReturn("direct:hello");
assertEquals("hello", AbstractSpanDecorator.stripSchemeAndOptions(endpoint));
}
Aggregations