use of org.apache.camel.CamelExecutionException in project camel by apache.
the class BeanLanguageMethodMissingParenthesisTest method testFooMissingParenthesis.
public void testFooMissingParenthesis() throws Exception {
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").filter(method(BeanLanguageMethodMissingParenthesisTest.class, "couldThisBeFoo(${body}, ${header.foo}")).to("mock:foo").end().to("mock:result");
}
});
context.start();
try {
template.sendBodyAndHeader("direct:start", "Hello World", "foo", "yes");
fail("Should throw exception");
} catch (CamelExecutionException e) {
IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, e.getCause().getCause());
assertEquals("Method should end with parenthesis, was couldThisBeFoo(${body}, ${header.foo}", iae.getMessage());
}
}
use of org.apache.camel.CamelExecutionException in project wildfly-camel by wildfly-extras.
the class AuthorizationPolicyTestCase method testInvalidCredentials.
@Test
public void testInvalidCredentials() throws Exception {
CamelContext camelctx = contextRegistry.getCamelContext("contextA");
ProducerTemplate producer = camelctx.createProducerTemplate();
try {
Subject subject = getAuthenticationToken("user-domain", AnnotatedSLSB.USERNAME, "bogus");
producer.requestBodyAndHeader("direct:start", "Kermit", Exchange.AUTHENTICATION, subject, String.class);
Assert.fail("CamelExecutionException expected");
} catch (CamelExecutionException ex) {
Throwable cause = ex.getCause();
Assert.assertEquals(CamelAuthorizationException.class, cause.getClass());
Assert.assertTrue(cause.getMessage(), cause.getMessage().contains("Password invalid/Password required"));
}
}
use of org.apache.camel.CamelExecutionException in project wildfly-camel by wildfly-extras.
the class AuthorizationPolicyTestCase method testInsufficientRoles.
@Test
public void testInsufficientRoles() throws Exception {
CamelContext camelctx = contextRegistry.getCamelContext("contextC");
ProducerTemplate producer = camelctx.createProducerTemplate();
try {
Subject subject = getAuthenticationToken("user-domain", AnnotatedSLSB.USERNAME, AnnotatedSLSB.PASSWORD);
producer.requestBodyAndHeader("direct:start", "Kermit", Exchange.AUTHENTICATION, subject, String.class);
Assert.fail("CamelExecutionException expected");
} catch (CamelExecutionException ex) {
Throwable cause = ex.getCause();
Assert.assertEquals(CamelAuthorizationException.class, cause.getClass());
Assert.assertTrue(cause.getMessage(), cause.getMessage().contains("User does not have required roles: [Role3]"));
}
}
use of org.apache.camel.CamelExecutionException in project wildfly-camel by wildfly-extras.
the class SecuredSpringRouteTestCase method testInvalidCredentials.
@Test
public void testInvalidCredentials() throws Exception {
CamelContext camelctx = contextRegistry.getCamelContext("contextA");
ProducerTemplate producer = camelctx.createProducerTemplate();
try {
Subject subject = getAuthenticationToken("user-domain", AnnotatedSLSB.USERNAME, "bogus");
producer.requestBodyAndHeader("direct:start", "Kermit", Exchange.AUTHENTICATION, subject, String.class);
Assert.fail("CamelExecutionException expected");
} catch (CamelExecutionException ex) {
Throwable cause = ex.getCause();
Assert.assertEquals(FailedLoginException.class, cause.getClass());
Assert.assertTrue(cause.getMessage(), cause.getMessage().contains("Password invalid/Password required"));
}
}
use of org.apache.camel.CamelExecutionException in project wildfly-camel by wildfly-extras.
the class SecuredRouteTestCase method testNoAuthenticationHeader.
@Test
public void testNoAuthenticationHeader() throws Exception {
CamelContext camelctx = new DefaultCamelContext();
camelctx.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").policy(new DomainAuthorizationPolicy()).transform(body().prepend("Hello "));
}
});
camelctx.start();
try {
ProducerTemplate producer = camelctx.createProducerTemplate();
try {
producer.requestBody("direct:start", "Kermit", String.class);
Assert.fail("CamelExecutionException expected");
} catch (CamelExecutionException ex) {
Throwable cause = ex.getCause();
Assert.assertEquals(SecurityException.class, cause.getClass());
Assert.assertTrue(cause.getMessage(), cause.getMessage().startsWith("Cannot obtain authentication subject"));
}
} finally {
camelctx.stop();
}
}
Aggregations