use of org.apache.camel.Endpoint in project camel by apache.
the class LdapRouteTest method testLdapRouteWithPaging.
@Test
public void testLdapRouteWithPaging() throws Exception {
camel.addRoutes(createRouteBuilder("ldap:localhost:" + port + "?base=ou=system&pageSize=5"));
camel.start();
Endpoint endpoint = camel.getEndpoint("direct:start");
Exchange exchange = endpoint.createExchange();
// then we set the LDAP filter on the in body
exchange.getIn().setBody("(objectClass=*)");
// now we send the exchange to the endpoint, and receives the response from Camel
Exchange out = template.send(endpoint, exchange);
Collection<SearchResult> searchResults = defaultLdapModuleOutAssertions(out);
assertEquals(16, searchResults.size());
}
use of org.apache.camel.Endpoint in project camel by apache.
the class LdapRouteTest method testLdapRouteStandard.
@Test
public void testLdapRouteStandard() throws Exception {
camel.addRoutes(createRouteBuilder("ldap:localhost:" + port + "?base=ou=system"));
camel.start();
// START SNIPPET: invoke
Endpoint endpoint = camel.getEndpoint("direct:start");
Exchange exchange = endpoint.createExchange();
// then we set the LDAP filter on the in body
exchange.getIn().setBody("(!(ou=test1))");
// now we send the exchange to the endpoint, and receives the response from Camel
Exchange out = template.send(endpoint, exchange);
Collection<SearchResult> searchResults = defaultLdapModuleOutAssertions(out);
assertFalse(contains("uid=test1,ou=test,ou=system", searchResults));
assertTrue(contains("uid=test2,ou=test,ou=system", searchResults));
assertTrue(contains("uid=testNoOU,ou=test,ou=system", searchResults));
assertTrue(contains("uid=tcruise,ou=actors,ou=system", searchResults));
// START SNIPPET: invoke
}
use of org.apache.camel.Endpoint in project camel by apache.
the class LdapRouteTest method testLdapRouteReturnedAttributes.
@Test
public void testLdapRouteReturnedAttributes() throws Exception {
// LDAP servers behave differently when it comes to what attributes are returned
// by default (Apache Directory server returns all attributes by default)
// Using the returnedAttributes parameter this behavior can be controlled
camel.addRoutes(createRouteBuilder("ldap:localhost:" + port + "?base=ou=system&returnedAttributes=uid,cn"));
camel.start();
Endpoint endpoint = camel.getEndpoint("direct:start");
Exchange exchange = endpoint.createExchange();
// then we set the LDAP filter on the in body
exchange.getIn().setBody("(uid=tcruise)");
// now we send the exchange to the endpoint, and receives the response from Camel
Exchange out = template.send(endpoint, exchange);
Collection<SearchResult> searchResults = defaultLdapModuleOutAssertions(out);
assertEquals(1, searchResults.size());
assertTrue(contains("uid=tcruise,ou=actors,ou=system", searchResults));
Attributes theOneResultAtts = searchResults.iterator().next().getAttributes();
assertEquals("tcruise", theOneResultAtts.get("uid").get());
assertEquals("Tom Cruise", theOneResultAtts.get("cn").get());
// make sure this att is NOT returned anymore
assertNull(theOneResultAtts.get("sn"));
}
use of org.apache.camel.Endpoint in project camel by apache.
the class LumberjackComponent method createEndpoint.
@Override
protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
// Extract host and port
String host;
int port;
int separatorIndex = remaining.indexOf(':');
if (separatorIndex >= 0) {
host = remaining.substring(0, separatorIndex);
port = Integer.parseInt(remaining.substring(separatorIndex + 1));
} else {
host = remaining;
port = DEFAULT_PORT;
}
// Create the endpoint
Endpoint answer = new LumberjackEndpoint(uri, this, host, port);
setProperties(answer, parameters);
return answer;
}
use of org.apache.camel.Endpoint in project camel by apache.
the class InvalidConfigurationTest method testSMTPCanNotBeUsedForConsumingMails.
@Test
public void testSMTPCanNotBeUsedForConsumingMails() throws Exception {
Endpoint endpoint = context.getEndpoint("smtp://localhost?username=james");
PollingConsumer consumer = endpoint.createPollingConsumer();
try {
consumer.start();
fail("Should have thrown NoSuchProviderException as stmp protocol cannot be used for consuming mails");
} catch (IllegalArgumentException e) {
// expected
}
}
Aggregations